在下面的示例中,如何:
$.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
};
// As we're loading the data asynchronously, we don't know what order it will arrive. So
// we keep a counter and create the chart when all the data is loaded.
seriesCounter += 1;
if (seriesCounter === names.length) {
createChart();
}
});
});
答案 0 :(得分:0)
也许你想要的是显示组合图表,这里是这个方案的一个例子。
http://www.highcharts.com/docs/chart-and-series-types/combining-chart-types
答案 1 :(得分:0)
只需创建一个types
数组并在循环函数中使用它:http://jsfiddle.net/epaLtjre/
var seriesOptions = [],
seriesCounter = 0,
names = ['MSFT', 'AAPL', 'GOOG'],
types = ['line', 'column', 'spline']; // add types
后来:
seriesOptions[i] = {
name: name,
data: data,
type: types[i] // apply type to the series
};