diff --git a/src/controllers/controller.scatter.js b/src/controllers/controller.scatter.js index aae36ed6068..15445ea8ae3 100644 --- a/src/controllers/controller.scatter.js +++ b/src/controllers/controller.scatter.js @@ -70,6 +70,10 @@ export default class ScatterController extends DatasetController { if (this.options.showLine) { + // https://github.com/chartjs/Chart.js/issues/11333 + if (!this.datasetElementType) { + this.addElements(); + } const {dataset: line, _dataset} = meta; // Update Line @@ -84,6 +88,10 @@ export default class ScatterController extends DatasetController { animated: !animationsDisabled, options }, mode); + } else if (this.datasetElementType) { + // https://github.com/chartjs/Chart.js/issues/11333 + delete meta.dataset; + this.datasetElementType = false; } // Update Points diff --git a/test/fixtures/controller.scatter/showLine/changed.js b/test/fixtures/controller.scatter/showLine/changed.js new file mode 100644 index 00000000000..ac85be49f92 --- /dev/null +++ b/test/fixtures/controller.scatter/showLine/changed.js @@ -0,0 +1,34 @@ +module.exports = { + description: 'showLine option should draw a line if true', + config: { + type: 'scatter', + data: { + datasets: [{ + data: [{x: 10, y: 15}, {x: 15, y: 10}], + pointRadius: 10, + backgroundColor: 'red', + label: 'dataset1' + }], + }, + options: { + scales: { + x: { + display: false + }, + y: { + display: false + } + } + } + }, + options: { + canvas: { + width: 256, + height: 256 + }, + run(chart) { + chart.options.showLine = true; + chart.update(); + } + } +}; diff --git a/test/fixtures/controller.scatter/showLine/changed.png b/test/fixtures/controller.scatter/showLine/changed.png new file mode 100644 index 00000000000..9e5eae7c4b9 Binary files /dev/null and b/test/fixtures/controller.scatter/showLine/changed.png differ