You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there. Please help, how to make decimation work? I have 500+ points. Decimation works only if I pass redraw prop (or by toggling enabled off and then on in react devtools).
The dataset object must be mutable. The plugin stores the original data as dataset._data and then defines a new data property on the dataset.
Because of how react works with immutable props, I believe this is where it fails. If someone has a working example of decimation with this package, do tell :)
Reacted by Aleksei Petrov, Kyle Bollinger and alannesta
constChart=(data)=>{constchart=useRef(chartRef);constoptions={// ...};constdatasets=data.map((datum)=>{// do your mapping here});return(<Lineoptions={options}data={{datasets: [...datasets],}}ref={chartRef}/>);};
The important bit being that you're passing a copy of your datasets to the chart component, rather than something that is contained in the component lifecycle. For me it was enough to use the spread operator.
Activity
mateogianolio commentedon Aug 27, 2021
Same here.. Whatever I do I can't make it work. I have followed the exact steps in chart.js docs (https://www.chartjs.org/docs/latest/configuration/decimation.html).
I even copied the code from here and ran it to see if any of the if clauses return for my datasets but nope.
mateogianolio commentedon Aug 27, 2021
Because of how react works with immutable props, I believe this is where it fails. If someone has a working example of decimation with this package, do tell :)
dangreen commentedon Oct 26, 2021
@hydrognomik @mateogianolio Hi. Would you please try the latest version of react-chartjs-2?
dangreen commentedon Nov 1, 2021
Closed due to inactivity.
lifenouveau commentedon Jan 3, 2022
Still cannot get it to work in v4.0.0I got it to work in a sandbox.
aklein24 commentedon Jun 7, 2022
@lifenouveau Do you have a link to the sandbox? I've been trying hard to get decimation to work without success.
applesin commentedon Jul 6, 2022
Still not working...
emab commentedon Sep 1, 2023
A quick fix that seemed to work for me:
The important bit being that you're passing a copy of your datasets to the chart component, rather than something that is contained in the component lifecycle. For me it was enough to use the spread operator.
digiage commentedon Sep 29, 2023
with
react-chartjs-2 v5.2.0the decimation seems to work, but just forlttb. I was not able to make it work withmin-maxhpertaia commentedon Feb 9, 2024
react-chartjs-2 v5.2.0withchart.js v4.4.1lttb decimation isn't working . Error:Сannot destructure property 'x' of 'data[a]' as it is undefinedEdit: happens only when x scale type is set to
time. When set tolinear, decimation works.mhai217 commentedon Jun 17, 2024
any update?
takuro-kira commentedon Dec 23, 2025
In my case.
datasets inner data's x is
Date
Graph can drawing, but decimation enable cause
Сannot destructure property 'x' of 'data[a]' as it is undefinederrorepoch time milliseconds
It's works
But, some sampling setting value cause same error again.
I think, In development time, because of small data.
I can't figure out.
If it helps someone.