Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

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

Open tqwewe opened this issue 1 year ago • 4 comments

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:

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

tqwewe avatar Mar 05 '24 13:03 tqwewe

Please add a reproducible sample as required per the issue template. Because when I try this it works fine: https://jsfiddle.net/xo75mvaf/

LeeLenaleee avatar Mar 05 '24 14:03 LeeLenaleee

@LeeLenaleee here's a modified version of your fiddle: https://jsfiddle.net/jqgatsk8/

tqwewe avatar Mar 05 '24 14:03 tqwewe

@tqwewe Have you found a way to overcome this? 🙏🏻

Tbh, this library looks abandoned despite the number of stars. Too many unanswered and unresolved issues...

on3dd avatar Aug 20 '24 06:08 on3dd

@on3dd yeah i did actually, i solved it by simply downgrading from the latest version to the previous one.

Yeah it seems a little unstable, personally im planning to switch to a different charting library by Apache called ECharts which seems much more stable, it might be worth looking into that too

tqwewe avatar Aug 20 '24 06:08 tqwewe