具有 json 数据的 highstock 中不同类型的系列

Different type of series in highstock with json data

在下面的例子中,如何有:


$.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();
        }
    });
});

http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/stock/demo/compare/

也许你想要的是显示组合图表,这里是这个方案的一个例子。

http://www.highcharts.com/docs/chart-and-series-types/combining-chart-types

只需创建一个 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
        };