Reputation: 606
I've been trying and failing to implement data decimation in vue chartJS, I'm assuming parsing is the hurdle stopping me as it is the one requirement I cant seem to fulfil.
My current chart options are:
oilOptions: {
responsive: true,
scales: {
y: {
... // Formatting and title
},
x: {
type: 'time'
... // Formatting and title
}
},
plugins: {
title: {
...
},
zoom: {
...
},
decimation: {
enabled: true,
algorithm: 'lttb',
samples: 500
}
The dataset is historical Brent oil price data structured like:
{
labels: [
"1987-05-20",
"1987-05-21",
...
],
datasets: [
label: "Brent Oil Price",
fill: false,
borderWidth: 2,
borderColor: "rgb(75, 192, 192)",
tension: 0.5,
pointRadius: 0,
// parsing: false (This stops data from rendering anyway)
data: [
18,
18,
...
]
]
I'm using vue-chartjs but that shouldn't be an issue.
Any help would be appreciated, my other option would be to reduce the data on the backend before passing it to the client, or have a separately saved reduced data set on my DB.
Upvotes: 1
Views: 929
Reputation: 31431
No parsing means that you need to provide the data like the internal format so no labels array and objects in your data array like so:
{
datasets: [{
label: "Brent Oil Price",
fill: false,
borderWidth: 2,
borderColor: "rgb(75, 192, 192)",
tension: 0.5,
pointRadius: 0,
parsing: false
data: [{
x: '1987-05-20',
y: 5
},
{
x: '1987-05-21',
y: 6
}
]
}]
}
The internal data format can be found in the docs here
Upvotes: 2