使用highcharts填充我的图表,其取从MySQL数据库中的数据与类别x轴从DB已经取出并放置sorting.My图表之后有图表多个系列。数据值是低于:[{“名” : “0.1纳克/毫升”, “数据”:[[ “24小时”,1.2]]},{ “名称”: “1毫微克/毫升”, “数据”:[[ “24小时”,2.2]] },{ “名称”: “10纳克/毫升”, “数据”:[[ “24小时”,5.3]]},{ “名称”: “3.5纳克/毫升”, “数据”:[[“24小时”,3]]},{ “名称”: “5纳克/毫升”, “数据”:[[ “240分钟”,2.2],[ “480分钟”,3.1],[ “24小时”,2.63 ],[ “48小时”,8.1]]}]
所以通过取这些值它绘出了'24小时”错误地在‘240分钟’部分。
请帮我解决这个问题。
。功能InitHighChart1(V1){$( “#chart1”)HTML( “等候,正在graph1 ......”);
var options = {
chart: {type: 'line',
renderTo: 'chart1',
},colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4'],
credits: {
enabled: false
},
title: {
text: 'Pubmed Id: '+v1,
x: -20
},
xAxis: {categories:<?php echo $_SESSION["cat"]; ?>,
minPadding: 0.05,
maxPadding: 0.05,
title: {
enabled: true,
text: 'Time Point'
}
},
tooltip: {
shared: true,
useHTML: true,
headerFormat: '<small>Time Point:{point.key}</small><table>',
pointFormat: '<tr><td>Dosage:</td><td style="color: {series.color}">{series.name}: </td>' +
'<td style="text-align: right"><b>{point.y} </b></td></tr>',
footerFormat: '</table>',
enabled: true,
crosshairs: {
color: 'blue',
dashStyle: 'solid'
}
},
plotOptions: {
line: {
dataLabels: {
enabled: true
},
enableMouseTracking: true
}
},
series: [{}]
};
$.ajax({
url: "jdata.php",
data: 'show=impressions',
type:'get',
dataType: "json",
success: function(data){
var getSeries = data;
options.series = getSeries;
var chart = new Highcharts.Chart(options);
}
});
}
数据阵列中的字符串值被视为一个点名称。你需要将它们设置为数值:
series: [{
"name": "0.1 ng/ml",
"data": [
[2, 1.2]
]
}, {
"name": "1 ng/ml",
"data": [
[2, 2.2]
]
}, {
"name": "10 ng/ml",
"data": [
[2, 5.3]
]
}, {
"name": "3.5 ng/ml",
"data": [
[2, 3]
]
}, {
"name": "5 ng/ml",
"data": [
[0, 2.2],
[1, 3.1],
[2, 2.63],
[3, 8.1]
]
}]