chartjs / chartjs/Chart.js

Hiding/Showing multiple datasets at the same time causes animation glitch

Open
#11,705 4 comments 1 reaction 0 assignees View on GitHub
type: bug
Dominant language
JavaScript
Stars
67.7k
Forks
11.9k
Avg merge
7h 39m
Merged PRs (30d)
5

Description

### Expected behavior

Datasets should animate at the same time when running `chart.hide(0); chart.hide(1); chart.hide(2);`.

### Current behavior

The animation is glitched, and some of the datasets don't fade out, but instead immediately disappear.

### Reproducible sample

https://jsfiddle.net/jqgatsk8/

### Optional extra steps/info to reproduce

Using the codepend template, simply adjust the JS to:
```js
var options = {
type: 'line',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [
{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
borderWidth: 1
},
{
label: '# of Points',
data: [7, 11, 5, 8, 3, 7],
borderWidth: 1
},
{
label: '# of Foos',
data: [8, 12, 3, 19, 12, 4],
borderWidth: 1
},
{
label: '# of Bars',
data: [1, 2, 3, 4, 5, 6],
borderWidth: 1
},
]
}
}

var ctx = document.getElementById('chartJSContainer').getContext('2d');
const c = new Chart(ctx, options);

c.hide(0);
c.hide(1);
c.hide(2);
```

### Possible solution

_No response_

### Context

_No response_

### chart.js version

v4.4.2

### Browser name and version

Chrome

### Link to your project

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.