Fix initial dataset stacks (#11882)

* Update cahced _stacked value after updating stacks

* Add test

---------

Co-authored-by: Jacco van den Berg <jacco@jem-id.nl>
This commit is contained in:
Jacco van den Berg 2024-08-26 17:13:12 +02:00 committed by GitHub
parent dd554e0d87
commit 680cd227d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 52 additions and 0 deletions

View File

@ -420,6 +420,7 @@ export default class DatasetController {
// if stack changed, update stack values for the whole dataset
if (stackChanged || oldStacked !== meta._stacked) {
updateStacks(this, meta._parsed);
meta._stacked = isStacked(meta.vScale, meta);
}
}

View File

@ -0,0 +1,49 @@
module.exports = {
config: {
type: 'line',
data: {
labels: [0, 1, 2, 3, 4, 5, 6],
datasets: [
{
// option in dataset
data: [9, 13, 15, 25, 22, 15, 21],
stack: 'construction_stack',
borderWidth: 10,
borderColor: 'rgb(54, 162, 235)'
},
{
data: [9, 13, 15, 25, 22, 15, 21],
stack: 'construction_stack',
borderWidth: 10,
borderColor: 'rgb(255, 99, 132)'
}
]
},
options: {
scales: {
x: {
ticks: {
display: false
}
},
y: {
ticks: {
display: false
}
}
},
plugins: {
legend: false,
title: false,
tooltip: false,
filler: false
}
}
},
options: {
canvas: {
height: 512,
width: 512
}
}
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -1,4 +1,6 @@
describe('Chart.DatasetController', function() {
describe('auto', jasmine.fixture.specs('core.datasetController'));
it('should listen for dataset data insertions or removals', function() {
var data = [0, 1, 2, 3, 4, 5];
var chart = acquireChart({