0

我有这个 JSON 数组。有了这些数据,使用 Highcharts 可以很好地绘制图表。

现在我正在尝试添加额外的 Y 轴(特别是对于 data1 系列)。

[{“ name”:“ data1”,“数据”:[[13615740000,121201],[13620060000,122019],[1363388400000,122788],[1363820400000,123740],[1363820400000,123740] ,[1365544800000,126553],[1366063200000,127496],[1366668000000,128500],[1367272800000,129433],[1368309600000,130277],[1368655200000,131267],[1369346400000,132191],[1369864800000,133143]]} ,{"name":"data2","data":[[1361574000000,0],[1362006000000,40.6],[1363388400000,35.7],[1363820400000,41.24],[1364511600000,40.56],[1360000,40.56],[1365.16] ,[1365544800000,39.8],[1366063200000,40.58],[136666680000,40.79],[1367272800000,38.06],[1368309600000,000,37.95] ,{"name":"data3","data":[[1361574000000,0],[1362006000000,1.46],[1363388400000,1.42],[1363820400000,1.42],[1364511600000,1.37],[1365112800000,1.41],[1365544800000,1.41],[1366606063200000,1.35] ,1.36],[1369346400000,1.37],[1369864800000,1.359]]},{"name":"data4","data":[[1361574000000,0],[1362006000000,59.276],[13633884]400000,506. [1363820400000,58.5608],[1364511600000,55.5672],[1365112800000,54.9336],[1365544800000,56.118],[1366063200000,54.783],[1366668000000,59.1455],[1367272800000,51.7616],[1368309600000,51.612],[1368655200000 ,56.1816],[1369346400000,55.0192],[1369864800000,52.71561]]}]“ data4”,“数据”:[[13615740000,0],[1362006000000,59.276],[1363338400000,50.694],[1363820400000,000,58.5608] ,[136063200000,54.783],[13666680000,59.1455],[1367272800000,51.7616],[1368309600000,51.612]“ data4”,“数据”:[[13615740000,0],[1362006000000,59.276],[1363338400000,50.694],[1363820400000,000,58.5608] ,[136063200000,54.783],[13666680000,59.1455],[1367272800000,51.7616],[1368309600000,51.612]

但是,我就是无法让额外的 Y 轴工作。这段代码有什么问题?

$(function() {

    $.getJSON('testdata.php', function(data) {
        // Create the chart
        $('#container').highcharts('StockChart', {


            title : {
                text : 'test'
            },

            yAxis: [{
                title: {
                    text: 'A'
                }
            }, {
                title: {
                    text: 'B'
                }
            }, {
                title: {
                    text: 'C'
                }
            }, {
                title: {
                    text: 'D'
                }
            }],

            series: [{
                type: 'line',
                name: 'A',
                data: data1,
                yAxis: 0,
                dataGrouping: {
                    units: groupingUnits
                }
            }, {
                type: 'line',
                name: 'B',
                data: data2,
                yAxis: 1,
                dataGrouping: {
                    units: groupingUnits
                }
            }, {
                type: 'line',
                name: 'C',
                data: data3,
                yAxis: 2,
                dataGrouping: {
                    units: groupingUnits
                }
            }, {
                type: 'line',
                name: 'D',
                data: data4,
                yAxis: 3,
                dataGrouping: {
                    units: groupingUnits
                }
             }]
        });
    });

});
4

1 回答 1

0

在第一个系列中,您需要添加 ie yAxis:1 其中 1 i yAxis 的索引。

结果系列将如下所示:

[{"name":"data1",
yAxis:1,
"data":[[1361574000000,121201],[1362006000000,122019],[1363388400000,122788],[1363820400000,123740],[1364511600000,124703],[1365112800000,125618],[1365544800000,126553],[1366063200000,127496],[1366668000000,128500],[1367272800000,129433],[1368309600000,130277],[1368655200000,131267],[1369346400000,132191],[1369864800000,133143]]}]
于 2013-05-31T16:22:10.540 回答