javascript - Different type of series in highstock with json data -
in example below, how have:
- serie 'msft' in type line
- serie 'aapl' in type column
- serie 'goog' in type spline
$.each(names, function (i, name) { $.getjson('https://www.highcharts.com/samples/data/jsonp.php?filename=' + name.tolowercase() + '-c.json&callback=?', function (data) { seriesoptions[i] = { name: name, data: data }; // we're loading data asynchronously, don't know order arrive. // keep counter , create chart when data loaded. seriescounter += 1; if (seriescounter === names.length) { createchart(); } }); });
simply create types
array , use in loop function: http://jsfiddle.net/epaltjre/
var seriesoptions = [], seriescounter = 0, names = ['msft', 'aapl', 'goog'], types = ['line', 'column', 'spline']; // add types
and later:
seriesoptions[i] = { name: name, data: data, type: types[i] // apply type series };
Comments
Post a Comment