score:1

Accepted answer

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
  });
 }
}

Related Query

More Query from same tag