Home > Blockchain >  Chart.JS - updating Labels from Chart 0 also updated Labels from Chart 1
Chart.JS - updating Labels from Chart 0 also updated Labels from Chart 1

Time:01-30

I have two line chart. I want to update the data for both of them, but somehow, after I update only the first Chart, the Label data on the 2nd Chart is also udpated at the same time. Am i Doing Something Wrong?

As shown in the image, i do print both label Chart 0 and 1, at first it was as expected. But After i do insert new label data to chart 0 using chartRpm[0].data.labels.push(0); the label on chart 1 also is inserted with the new label enter image description here

sc

console.log("CHART 0 LABELS");
console.log(chartRpm[0].data.labels);

console.log("CHART 1 LABELS");
console.log(chartRpm[1].data.labels);

chartRpm[0].data.labels.push(0);

console.log("CHART 0 LABELS");
console.log(chartRpm[0].data.labels);

console.log("CHART 1 LABELS");
console.log(chartRpm[1].data.labels);

CodePudding user response:

This looks like chartRpm[0].data.labels and chartRpm[1].data.labels point to the same reference, how do you define chartRpm?

  • Related