我想制作一个包含多个系列的折线图。源是JSON代码。它适用于一个系列,但有多个它不起作用。解决。
接下来我想从JSON推送数据标签。
已编辑:这是我的javascript:
function slowips(target){
var options = {
chart: {
renderTo: target,
type: 'line',
borderColor: '#0072C6',
borderWidth: 3
},
title: {
text: ''
},
legend: {
enabled: false
},
yAxis: {
title: {
text: 'MS'
},
},
exporting: {
enabled: false
},
credits: {
enabled: false
},
xAxis: {
categories: {
enabled: true,
type: 'category'
},
minorTickLength: 0,
tickLength: 0
},
plotOptions: {
line: {
dataLabels: {
enabled: true,
rotation: 0,
color: '#0072C6',
align: 'center',
style: {
fontSize: '11px',
fontFamily: 'Verdana, sans-serif',
},
formatter: function() {
return this.y;
},
},
animation: false,
enableMouseTracking: false
}
},
series: [{}]
};
$.getJSON('graphs/slowips.php', function(data) {
options.series = data;
var chart = new Highcharts.Chart(options);
});
}
EDITED:这是正在加载的JSON数据的示例:
[
{"name":"s1","data":[36,52,46,94,45,31,31,31,30,29,32,35,151,137,161,146,29,42,52,155,168,146,141,165,140,145,37,30,40,151]},
{"name":"s2","data":[35,41,51,95,31,30,28,31,32,28,32,27,39,33,52,42,45,53,45,37,42,45,47,47,39,29,35,30,39,39]},
{"name":"s3","data":[34,41,43,90,60,117,32,27,28,26,28,24,39,33,49,39,39,43,46,30,41,44,48,50,43,25,33,25,35,46]},
{"name":"s4","data":[23,34,24,76,13,16,16,15,18,15,17,21,23,20,34,25,14,24,26,23,36,50,31,36,21,14,17,17,22,29]},
{"name":"s5","data":[22,37,31,88,22,15,14,23,18,14,14,25,17,19,35,20,25,23,31,23,29,26,27,25,18,15,14,12,24,29]}
]
然而,这并没有给我预期的结果。我究竟做错了什么?我希望图表包含5个系列中的5行。解决。