From ec7be48470e42472a07572b7f1ca2abc91bfdad3 Mon Sep 17 00:00:00 2001 From: stockiNail Date: Thu, 8 Jun 2023 14:53:50 +0200 Subject: [PATCH] Fix toggling showLine option on scatter controller (#11334) --- src/controllers/controller.scatter.js | 8 +++++ .../controller.scatter/showLine/changed.js | 34 ++++++++++++++++++ .../controller.scatter/showLine/changed.png | Bin 0 -> 3919 bytes 3 files changed, 42 insertions(+) create mode 100644 test/fixtures/controller.scatter/showLine/changed.js create mode 100644 test/fixtures/controller.scatter/showLine/changed.png 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 0000000000000000000000000000000000000000..9e5eae7c4b9f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