Fix toggling showLine option on scatter controller (#11334)

This commit is contained in:
stockiNail
2023-06-08 14:53:50 +02:00
committed by GitHub
parent 6348f9ce9f
commit ec7be48470
3 changed files with 42 additions and 0 deletions

View File

@@ -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

View File

@@ -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();
}
}
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB