mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-04 23:44:05 +01:00
Correct decimation plugin documentation (#8801)
* Correct decimation plugin documentation * The default for decimation is `false`. * Added a sample for data decimation * Corrected an issue in the decimation plugin when switched from enabled to disabled
This commit is contained in:
@@ -141,6 +141,17 @@ function minMaxDecimation(data, availableWidth) {
|
||||
return decimated;
|
||||
}
|
||||
|
||||
function cleanDecimatedData(chart) {
|
||||
chart.data.datasets.forEach((dataset) => {
|
||||
if (dataset._decimated) {
|
||||
const data = dataset._data;
|
||||
delete dataset._decimated;
|
||||
delete dataset._data;
|
||||
Object.defineProperty(dataset, 'data', {value: data});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
id: 'decimation',
|
||||
|
||||
@@ -151,6 +162,8 @@ export default {
|
||||
|
||||
beforeElementsUpdate: (chart, args, options) => {
|
||||
if (!options.enabled) {
|
||||
// The decimation plugin may have been previously enabled. Need to remove old `dataset._data` handlers
|
||||
cleanDecimatedData(chart);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -224,13 +237,6 @@ export default {
|
||||
},
|
||||
|
||||
destroy(chart) {
|
||||
chart.data.datasets.forEach((dataset) => {
|
||||
if (dataset._decimated) {
|
||||
const data = dataset._data;
|
||||
delete dataset._decimated;
|
||||
delete dataset._data;
|
||||
Object.defineProperty(dataset, 'data', {value: data});
|
||||
}
|
||||
});
|
||||
cleanDecimatedData(chart);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user