0
我想在我的Xaxis標籤上添加幾個月,但是當我嘗試添加它時,顯示從0到2,但沒有月份,我該如何修復它?我試着只檢索一個月的部分將它添加到Xaxis,但它沒有工作,我怎麼能做到這一點工作?它的任何提示,這是我的代碼迄今爲止的樣子。Xaxis月份標籤不起作用。
var sales_by_month = new Array();
var month = new Array();
$.ajax({
url: URL_GET_SALES_BY_MONTH,
type: 'POST',
dataType: 'json',
success: function (data) {
for (i = 0; i < data.length; i++) {
sales_by_month.push([data[i].month, data[i].total]);
month.push(data[i].month);
}
Highcharts.chart('income_chart', {
title: {
text: 'Total Earnings'
},
yAxis: {
title: {
text: ''
}
},
xAxis: {
type: 'date'
},
legend: {
enabled: false
},
credits: {
enabled: false
},
exporting: {
buttons: {
contextButton: {
menuItems: [{
textKey: 'downloadPNG',
onclick: function() {
this.exportChart();
}
}, {
textKey: 'downloadJPEG',
onclick: function() {
this.exportChart({
type: 'image/jpeg'
});
}
}, {
textKey: 'downloadPDF',
onclick: function() {
this.exportChart({
type: 'application/pdf'
});
}
}]
}
}
},
series: [{
name: 'Sales & Distribution',
data: sales_by_month
}]
});
}
});
JSON
[{"orders":3,"total":9500,"month":"June"},{"orders":55,"total":71200,"month":"July"},{"orders":10,"total":1529,"month":"August"}]
只需使用幾個月數組作爲'xAxis.categories'。例如:http://jsfiddle.net/eayzkk0r/。 –