Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix toggling showLine option on scatter controller #11334

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading