3

have example of line chart on Highcharts. We have Tokyo and New York there by 1 line each. I need to show 2 more compare lines, that will show Tokyo and New York but in other date period on same graphic in different color.

        series: [{
            name: 'Tokyo',
            data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6],
        }, {
            name: 'New York',
            data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
        }]
4

2 回答 2

2

您可以在同一个数组中添加更多系列对象。同color国同改opacitydashStyle表示时期的不同

series: [{
            name: 'Tokyo',
            data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6],
            color: 'rgb(170,70,67)'
        }, {
            name: 'Tokyo - Old',
            data: [5.0, 4.9, 6.5, 10.5, 16.2, 20.5, 24.2, 25.5, 22.3, 16.3, 11.9, 10.6],
            color: 'rgba(170,70,67,0.8)',
            dashStyle: 'dot'
        }, {
            name: 'New York',
            data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5],
            color: 'rgb(100,100,255)'
        }, {
            name: 'New York - Old',
            data: [-1.2, -0.8, 4.7, 10.3, 16.0, 21.0, 23.8, 23.1, 19.1, 13.1, 7.6, 1.5],
            color: 'rgba(100,100,255,0.8)',
            dashStyle: 'dot'
        }]

演示:http: //jsfiddle.net/EEpZR/1/

于 2013-06-19T08:29:35.357 回答
1

您可以在图表中再添加两个数据系列以涵盖第二个时期:

 series: [{
        name: 'Tokyo',
        data: [11.0, 5.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
    }, {
        name: 'New York',
        data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
    }, {
        name: 'Tokyo2',
        data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6],
    }, {
        name: 'New York2',
        data: [-1.2, 1.8, 7.7, 12.3, 16.0, 21.0, 23.8, 23.1, 21.1, 15.1, 9.6, 3.5]
    }]

(注意,我编造了“New York2”数据,因为您没有提供第二组数据)。

于 2013-06-19T08:21:37.373 回答