0

我需要创建一个多线 highstock 类型的图表:

我的 test.json 文件如下所示:

[{"name":"serverA","data":[[1372737609,2.6075],[1372737906,2.6533],[1372738205,2.7834],[1372738526,3.6527],[1372738802,0.6352],[1372739093,0.6073]]},{"name":"serverB","data":[[1372737602,36.3042],[1372737929,16.1145],[1372738218,6.4503],[1372738503,23.8908],[1372738803,3.9025],[1372739079,10.8216],[1372739371,3.1338]]},{"name":"serverC","data":[[1372737600,3.9025],[1372737908,13.8542],[1372738184,10.9094],[1372738491,14.6655],[1372738777,80.7615],[1372739081,6.9777],[1372739383,10.0971]]}]

这是我的脚本:

(function() {
    var seriesOptions = [],
        yAxisOptions = [],

        colors = Highcharts.getOptions().colors;



        $.getJSON('test.txt',   function(data) {
            alert(data);
            seriesOptions: data
            createChart();      
        });

    // create the chart when all data is loaded
    function createChart() {

        $('#container').highcharts('StockChart', {
            chart: {
            },

            rangeSelector: {
                selected: 4
            },

            yAxis: {
                labels: {
                    formatter: function() {
                        return (this.value > 0 ? '+' : '') + this.value + '%';
                    }
                },
                plotLines: [{
                    value: 0,
                    width: 2,
                    color: 'silver'
                }]
            },

            plotOptions: {
                series: {
                    compare: 'percent'
                }
            },

            tooltip: {
                pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>',
                valueDecimals: 2
            },

            series: seriesOptions
        });
    }

});

我收到此错误:

Uncaught TypeError: undefined is not a function

有什么想法我在这里做错了吗?

4

1 回答 1

1

从:更改seriesOptions: dataseriesOptions = data;

于 2013-07-03T10:41:08.687 回答