$http.post(galileoServer + "actions.php", {
"action": "get-attendance-graph",
"user": window.localStorage.getItem("username")
}).success(function(result){
//console.log(result)
busyIndicator("hide");
$('#attendance-graph').highcharts({
credits: 0,
tooltip:{
enabled: false
},
chart: {
type: 'bar'
},
title: {
text: '',
style: {
display: "none"
}
},
xAxis: {
categories: ['June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec', 'Jan', 'Feb', 'Mar', 'Apr', 'May']
},
yAxis: {
min: 0,
title: {
text: 'No. of days'
},
gridLineWidth: 0,
minorGridLineWidth: 0,
labels: { //to disable points displayed
enabled: false
}
},
legend: {
reversed: true
},
plotOptions: {
series: {
stacking: 'normal',
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
formatter: function() { //function to avoid displaying zero values
if (this.y != 0) {
return this.y;
} else {
return null;
}
}
/*style: {
textShadow: '0 0 3px black, 0 0 3px black'
}*/
}
}
},
series: [{
name: 'Absent',
data: [result.absentData]
}, {
name: 'Present',
data: [result.presentData]
}]
});
}).error(function(result, status){
alert(status + "\nCouldn't connect to Galileo server due to network problem")
});
我想通過ajax加載數據,但沒有得到加載圖加載的圖是空白的。 提供了編碼片段。 我也嘗試了getJSON部分,但它也沒有奏效。 請讓我知道解決方案,因爲我無法從最近兩天獲取圖表。
控制檯輸出{"absentData":"0,0,2,0,0,1,0,0,0,0,0,0","presentData":"30,31,29,30,31,29,31,31,28,31,30,31"}
空白圖形表示您的數據格式不正確。首先,檢查你的控制檯是否有錯誤。其次,用'console.log(result)'的輸出更新你的問題。在你這樣做之前,我們無法幫助你。 – Mark 2014-11-24 16:03:25
控制檯顯示完美結果。我將附上輸出 – 2014-11-24 17:03:43
@Mark 控制檯輸出爲http://prntscr.com/59p18w – 2014-11-24 17:29:40