我想知道是否有可能在 highcharts 中构建一个图表,例如双轴柱和线但具有多个系列数据。
例如,以显示东京、纽约、伦敦和柏林月平均降雨量的基本柱形图为例:http://www.highcharts.com/demo/column-basic .然后还在相反的 Y 轴上添加四个城市的平均温度(基本上向图表添加四条线)。
我知道要将大量数据塞入一张图表,但我很好奇是否可以做到。抱歉,我没有更好的例子可以展示。到目前为止,我在玩 JSFiddle 时运气不佳。感谢您的帮助。
最佳答案
是的,你可以做到这一点。您创建您的 yAxis
项:
yAxis: [{
min: 0,
title: {
text: 'Rainfall (mm)'
}
}, {
min: 0,
opposite: true, //optional, you can have it on the same side.
title: {
text: 'Temp (K)'
}
}],
然后你需要告诉系列使用哪个yAxis
:
series: [{
name: 'Tokyo',
yAxis: 1, //use new yAxis on right side.
data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}, {
name: 'New York',
yAxis: 0, //if using primary (0) yAxis can leave this out.
data: [83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3]
}, {
name: 'London',
data: [48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2]
}, {
name: 'Berlin',
data: [42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1]
}]
查看演示 here .
关于javascript - Highcharts:具有多个系列的双轴线和柱形图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23136555/