score:1

Accepted answer

I found what seems to be a good solution:

function update(data) {
  const s = myChart.series;
  for (let i = 0; i < s.length; i++) {
    console.log(i);
    s[i].setData(data[s[i].name], false);  // add "redraw=false" argument
  }
  myChart.redraw(); // trigger redraw at end of loop
}

Adding false to the setData function prevents Highcharts from redrawing after each change. When I get to the end of the loop, I manually trigger a redraw.

This makes the updating much smoother!

score:0

You can just do it like this:

const receivedData = {
  'item1': [1, 2, 3],
  'item2': [1, 2, 3],
  'item3': [1, 2, 3]
};

const update = data => Object.keys(data).map(key => ({ name: key, data: data[key] }));

console.log(update(receivedData));


Related Query

More Query from same tag