Chartjs-How to display multiple graphs in real time with chartjs

1👍

datasets is an array so it would be dataset[0].data.push rather than dataset.data [0] .push

But your forEach is looping through each dataset so you can just check if its the dataset you want to update:

function onRefresh(chart) {
  for( var i=0; i<set.label.length; i++) {
  chart.config.data.datasets.forEach(function(dataset) {
    if (dataset.label === 'a') {
      // push the data to update a here
      dataset.data.push({
        x: Date.now(),
        y: set.lebel[set.label.length-1]
      })
    }
    // do the same for b
  });
 }
}

Leave a comment