Skip to content

Commit

Permalink
Fix toggling showLine option on scatter controller (#11334)
Browse files Browse the repository at this point in the history
  • Loading branch information
stockiNail committed Jun 8, 2023
1 parent 6348f9c commit ec7be48
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/controllers/controller.scatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
34 changes: 34 additions & 0 deletions test/fixtures/controller.scatter/showLine/changed.js
Original file line number Diff line number Diff line change
@@ -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();
}
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ec7be48

Please sign in to comment.