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/。 –