0
我目前使用HighCharts一些數據嵌入到我的用戶界面,顯示從過去7天的銷售利潤
,這裏是當前的Javascript,我使用:HighCharts顯示錯誤月
function weeks_ago(date_object) {
var d = new Date();
var newDate = d.setDate(d.getDate()-6);
var date = new Date(newDate);
return date.getDate();
}
var d = new Date();
function createGraph(jsonObj) {
$('#container').highcharts({
credits: {
enabled: false
},
chart: {
type: 'line'
},
title: {
text: 'Profit Graph'
},
subtitle: {
text: 'Data from the past week'
},
xAxis: {
type: "datetime",
dateTimeLabelFormats: {
month: "%e. %b",
year: "%b"
}
},
yAxis: {
title: {
text: 'Profit'
},
min: 0
},
tooltip: {
formatter: function() {
return '<span style="color:#33333;">'+this.series.name +': '+ Highcharts.numberFormat(this.y,0);
}
},
series: [
{
name: 'Platform1',
data: jsonObj.Platform1,
pointStart: Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), weeks_ago(new Date())),
pointInterval: 24 * 3600 * 1000,
color: '#55CCA2',
}, {
name: "Platform2",
data: jsonObj.Platform2,
pointStart: Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), weeks_ago(new Date())),
pointInterval: 24 * 3600 * 1000,
color: '#3498db',
}
]
});
};
我jsonObj
陣列擁有以下內容:
{"Platform1":[0,0,0,14580,105585,75410,19212],"Platform2":[0,0,0,0,0,0,0]}
但由於某種原因,我的圖表顯示10月30日至11月5日?數據點在正確的位置,只是xAxis標籤是錯誤的。
加上'jsonObj'在後調試問題 –
@ Deep3015了'jsonObj'不是問題,只是持有數據。這是'pointStart'這是我的問題 – Curtis