我在顯示基本列高圖時遇到問題。我的JSON看起來線以下:highcharts series data [] not populating/displayed
[
{
"name":"Target Assigned",
"data":["100000","100000","100000","100000","100000","100000","100000"]
},
{
"name":"Target achieved",
"data":["75000","80000","80000","75000","85000","90000","65000"]
}
]
我想要的「數據」被設置爲序列數據,爲了這個,我寫了下面的代碼,但它不顯示任何內容,
<script>$(document).ready(function() {
var options = {
chart: {
renderTo: 'container',
type: 'column',
marginRight: 130,
marginBottom: 70
},
title: {
text: 'Monthly Target Tracker'
},
subtitle: {
text: 'Source: Database'
},
xAxis: {
categories: [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec'
]
},
yAxis: {
min: 0,
tickInterval: 5,
title: {
text: 'Rupees (Lakhs)'
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f} Lakh</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [{name:'' , data: []},{name:'' , data: []}]
}
$.getJSON("tracktarget.json", function(json) {
//alert(1);
// var jp=JSON.parse(json);
options.series[0].name= json[0].name;
options.series[0].data= [JSON.parse(json[0].data[0])];
options.series[1].name= json[1].name;
options.series[1].data= [JSON.parse(json[1].data[0])];
chart = new Highcharts.Chart(options);
});
});
</script>
驗證碼將series元素的「name:」設置爲我的json中的「name」值,但不設置數據數組值。
任何幫助將不勝感激。
嗨,你可以請共享這個代碼的JS小提琴嗎?人們會幫助你更容易。 – 2015-01-04 12:51:03