Reputation: 87
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]
}]
Upvotes: 3
Views: 1703
Reputation: 25135
You can add more series objects in the same array. Use same color
for same country and change opacity
, dashStyle
etc. to indicate the difference in period
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'
}]
demo : http://jsfiddle.net/EEpZR/1/
Upvotes: 2
Reputation: 19093
You can just add two more data series to your chart to cover the second period:
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]
}]
(Note, I made up 'New York2' data as you didn't supply a second set).
Upvotes: 1