diff --git a/src/core/core.datasetController.js b/src/core/core.datasetController.js index 9b7126a93fd..145a2b6a11e 100644 --- a/src/core/core.datasetController.js +++ b/src/core/core.datasetController.js @@ -217,7 +217,7 @@ function clearStacks(meta, items) { for (const parsed of items) { const stacks = parsed._stacks; if (!stacks || stacks[axis] === undefined || stacks[axis][datasetIndex] === undefined) { - return; + continue; } delete stacks[axis][datasetIndex]; if (stacks[axis]._visualValues !== undefined && stacks[axis]._visualValues[datasetIndex] !== undefined) { diff --git a/test/fixtures/controller.line/stacking/stack-cache.js b/test/fixtures/controller.line/stacking/stack-cache.js new file mode 100644 index 00000000000..7bf42d3c5c0 --- /dev/null +++ b/test/fixtures/controller.line/stacking/stack-cache.js @@ -0,0 +1,56 @@ +function makeDs(label, offset) { + return { + label, + data: [ + [0, 12], + [1, 19], + [2, 3], + [2, 5], + [3, 2], + [4, 3], + ].map(([x, y]) => ({x, y: y === null ? null : y + offset})), + showLine: true, + spanGaps: false, + stack: `stack${label}`, + borderColor: label === 'A' ? '#c00' : '#00c' + }; +} + +const dsA = makeDs('A', 0); +const dsB = makeDs('B', 1); + +module.exports = { + config: { + type: 'scatter', + data: { + datasets: [dsA, dsB], + }, + options: { + scales: { + x: {display: false}, + y: {display: false}, + }, + elements: { + point: { + backgroundColor: '#444', + }, + }, + layout: { + padding: { + left: 24, + right: 24, + }, + }, + }, + }, + options: { + canvas: { + height: 128, + width: 256, + }, + async run(chart) { + chart.data = {datasets: [dsB, dsA]}; + chart.update(); + } + }, +}; diff --git a/test/fixtures/controller.line/stacking/stack-cache.png b/test/fixtures/controller.line/stacking/stack-cache.png new file mode 100644 index 00000000000..4ef82b1be9a Binary files /dev/null and b/test/fixtures/controller.line/stacking/stack-cache.png differ