Αποτελέσματα Αναζήτησης
There's so many conflicting answers to this, most of which had no effect for me. I was finally able to set (or retrieve current) X-axis minimum & maximum displayed values with chart.options.scales.xAxes[0].ticks.min (even if min & max are only a subset of the data assigned to the chart.)
Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand
Just mock out the chart component from react-chartjs-2. jest.mock('react-chartjs-2', => 'Chart') This will replace the original component with a dump one that will just render as <Chart prop="prop"> in your snapshot.
13 Αυγ 2020 · This can be done through the option lineTension that needs to be defined on your dataset. Choose a value below 1. datasets: [{. ... lineTension: 0.8. }] By default, you should however already see curved smooth lines since accoring to Chart.js documentation, the default value is 0.4.
3 Οκτ 2020 · Totally depends on the case. You cited an issue from React lib where its components indeed won't be rendered with shallow, it's not applicable to yours because you use Chart directly. Basically you need to mock Chart API in a minimal way that will allow tests pass. I.e. make Chart a spy and mock chartRef.current to have getContext spy method
5 Σεπ 2017 · How to update State of chart.js in React. 0. react-chartjs-2 Line graph doesnt update with data. 1.
7 Ιαν 2014 · ctx.font = "30px " + fontStyle; // Get the width of the string and also the width of the element minus 10 to give it 5px side padding. var stringWidth = ctx.measureText(txt).width; var elementWidth = (chart.innerRadius * 2) - sidePaddingCalculated; // Find out how much the font can grow in width.
23 Ιαν 2024 · When I implemented the same, I was not able to render the chart, I found that you set linear on your x-axis, in my example since data is not provided, I used string, so after removing linear, the chart got rendered! import { FC } from 'react'; import React from 'react'; import { Line } from 'react-chartjs-2';
I am using Chart.js v2 to draw a simple line chart ... How to hide the grid lines of react chart js. 0.
26 Σεπ 2018 · to reproduce, go to the example and if you close the menu, the chart grows, and if you open it, the chart does not shrink back down. it maintains it's size and overflows to the right. note: my actual project has two separate components for the chart and side bar. So a calc solution doesn't work in this case, I don't want to tightly couple any ...