Skip to content

Commit

Permalink
Fix initial dataset stacks (#11882)
Browse files Browse the repository at this point in the history
* Update cahced _stacked value after updating stacks

* Add test

---------

Co-authored-by: Jacco van den Berg <[email protected]>
  • Loading branch information
LeeLenaleee and Jacco van den Berg authored Aug 26, 2024
1 parent dd554e0 commit 680cd22
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core/core.datasetController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
49 changes: 49 additions & 0 deletions test/fixtures/core.datasetController/stacked-initial-render.js
Original file line number Diff line number Diff line change
@@ -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
}
}
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions test/specs/core.datasetController.tests.js
Original file line number Diff line number Diff line change
@@ -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({
Expand Down

0 comments on commit 680cd22

Please sign in to comment.