Open noobnoobdc137 opened 2 years ago
@noobnoobdc137 - You mind putting this in a stackblitz or codesandbox for all of us?
Not working for me either. Ideally, a simple way to have it would be;
public lineChartOptions: ChartConfiguration['options'] = {
elements: {
line: {
tension: 0.5
}
},
scales: {
x: {},
'y-axis-0':
{
position: 'left',
reverse: this.reverseInput
},
},
plugins: {
legend: { display: true },
decimation: {
enabled: true,
algorithm: 'lttb',
samples:50
},
}
};
And pass those option to the chart
<canvas baseChart
[data]="lineChartData"
[options]="lineChartOptions"
[type]="lineChartType"></canvas>
My line chart has too many points crowding the line. It would be great to 'thin the herd' with this simple plugin.
Probably decimation needs a re-render of the chart? Can you try using this.chart.render();
or setting the decimation.enabled
to true
from the start to see if it makes any difference?
Did anybody get this to work? I am having the same problem. My data gets rendered but decimation is not applied.
Any updates on this? I'm running into a similar issue
I did get it to work, but it took some fiddling. I preprocessed my data to not need any interpolation by converting my x axis from an ISO Date to Milliseconds, that did the trick. I used luxon and the luxon chart.js adapter for the conversion and formatting.
This is the code I applied to activate decimation:
plugins: {
// ...
decimation: {
algorithm: 'lttb',
enabled: true,
samples: 100,
threshold: 40,
},
// ...
}
For display purposes I formatted the date like this:
scales: {
x: {
type: 'time',
time: {
displayFormats: {
month: 'MMM ‘yy',
},
},
},
// ...
}
Hope it helps.
Hope it helps.
Thank you.
I realized that threshold
must be specified for small values. In my case it's
{
...
decimation: {
algorithm: 'lttb',
enabled: true,
samples: 25,
threshold: 25,
}
}
and it didn't work unless explicitly stated
Reproduction of the problem
TS file
Template HTML
Versions
Angular Version:
12.1.1