creativetimofficial / black-dashboard

MIT License
344 stars 313 forks source link

[Bug] Uncaught TypeError: Cannot read property 'skip' of undefined #37

Closed RyanJamesIndangan closed 3 years ago

RyanJamesIndangan commented 3 years ago

https://user-images.githubusercontent.com/41842060/111092487-2ac0a900-8571-11eb-9e20-0f8214c521a8.mp4

Version

1.0.1

Reproduction link

https://www.creative-tim.com/product/black-dashboard

Operating System

Windows 8.1

Device

Laptop

Browser & Version

Google Chrome Version 89.0.4389.82 (Official Build) (64-bit)

Steps to reproduce

So there are 2 charts, given that both charts have data of 12 and values are 0.

myGlobalChart and anything you want, maybe try myGlobalChart2.

When you try to do the code below to chart1, it will definitely work, but then when you hover to chart2, the error will occur.

Do this, update chart1 and then update chart2, now try to hover to chart1, it does produce the error, but then chart2 does not, now, try to update chart1, hovering on data works now, but then when you hover to chart2, it does not work.

I used this to remove the data on the chart myGlobalChart.data.datasets.forEach((dataset) => { for(let i = 1; i <= dataset.data.length; i++) { myGlobalChart.data.labels.pop(); } });

    myGlobalChart.data.datasets.forEach((dataset) => {
    for(let i = 1; i <= dataset.data.length; i++)
    {
      dataset.data.pop();
    }
    });
    myGlobalChart.update();

and used this to add new data let days = 10; for(let i = 0; i < days; i++) { let keys = Object.keys('data' + i); myGlobalChart.data.labels.push(keys); }

    myGlobalChart.data.datasets.forEach((dataset) =>
    {
      for(let i = 0; i < days; i++)
      {
        let values = Object.values('data' + i);
        dataset.data[i] = values;
      }

      dataset.data.push(config);
    });
    myGlobalChart.update();

What is expected?

On hover to the data in the chart, the error will occur and the tooltip will not appear.

What is actually happening?

I don't know, the error says it's in (search l._view.skip||e(l) in chart.min.js)


Solution

This is very odd, so have a config variable and I use it to both charts

var myGlobalChart = new Chart(globalChart, config); var myChart2= new Chart(chart2, config);

now, I just copy paste the config, and renamed the variable to config2

so now I have this var myGlobalChart = new Chart(globalChart, config); var myChart2= new Chart(chart2, config2);

and it worked, I'm like.. "What just happened? It doesn't make aaaaaanyy sense at all?!"

Additional comments