Skip to content Skip to sidebar Skip to footer

How To Display Dynamic Object Arrays Into Chart Using Anychart.js

What i am trying to do is i want to display a chart based on my dynamic data i used Angular ForEach to loop through all my objects array see my code below: var parse = JSON.parse(j

Solution 1:

Everything depends on the value content inside the loop. You are applying the value to the series and dataSet as well. If you are using dataSet, you should apply the value to the dataSet, map the data, then apply the mapping to the series. Like this:

var dataSet = anychart.data.set(value);
  var mapping = dataSet.mapAs({'x': 0, 'value': 1}); // for examplevar chart = anychart.column();
  var series = chart.column(dataSet);

The mapping depends on your data. If the value includes ready-to-use data that matches the default mapping you can apply it directly to the series.

Can you share the value content?

Solution 2:

The chart can work with dynamic data. All you need is to apply new data to the existing dataSet, like this:

dataSet.data(newData);

And that's it! There's no need to recreate chart/series/dataSet.

Post a Comment for "How To Display Dynamic Object Arrays Into Chart Using Anychart.js"