Skip to content

Commit ec7be48

Browse files
authored
Fix toggling showLine option on scatter controller (#11334)
1 parent 6348f9c commit ec7be48

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

Diff for: src/controllers/controller.scatter.js

+8
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ export default class ScatterController extends DatasetController {
7070

7171
if (this.options.showLine) {
7272

73+
// https://github.com/chartjs/Chart.js/issues/11333
74+
if (!this.datasetElementType) {
75+
this.addElements();
76+
}
7377
const {dataset: line, _dataset} = meta;
7478

7579
// Update Line
@@ -84,6 +88,10 @@ export default class ScatterController extends DatasetController {
8488
animated: !animationsDisabled,
8589
options
8690
}, mode);
91+
} else if (this.datasetElementType) {
92+
// https://github.com/chartjs/Chart.js/issues/11333
93+
delete meta.dataset;
94+
this.datasetElementType = false;
8795
}
8896

8997
// Update Points

Diff for: test/fixtures/controller.scatter/showLine/changed.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module.exports = {
2+
description: 'showLine option should draw a line if true',
3+
config: {
4+
type: 'scatter',
5+
data: {
6+
datasets: [{
7+
data: [{x: 10, y: 15}, {x: 15, y: 10}],
8+
pointRadius: 10,
9+
backgroundColor: 'red',
10+
label: 'dataset1'
11+
}],
12+
},
13+
options: {
14+
scales: {
15+
x: {
16+
display: false
17+
},
18+
y: {
19+
display: false
20+
}
21+
}
22+
}
23+
},
24+
options: {
25+
canvas: {
26+
width: 256,
27+
height: 256
28+
},
29+
run(chart) {
30+
chart.options.showLine = true;
31+
chart.update();
32+
}
33+
}
34+
};
3.83 KB
Loading

0 commit comments

Comments
 (0)