[Chartjs]-Chart.js can't push dataset to charts made dynamically

1👍

Apparently, the way to fix this was instead of using the variable chart in addData(), use window[chartname + index] when manipulating dynamically created charts. I found this out by trying to point to the chart by using both eval() and window[]. Eval didn’t work at all, but Window did the trick.

Example:

var number = 1;
window['linechart' + number];

This will call chart linechart1.

Leave a comment