0
我在x-as中遇到類型爲datetime的數據問題。我的日期範圍從01/07/2016(dd/MM/yyyy)和01/10/2016,但我無法正確顯示圖表。日期arent顯示正確,我得到錯誤15.HighCharts Line xas datetime
我得到的數據(chartInfo.DataSetTime)作爲字典(字符串,整數)。該字符串包含像2016年1月7日
這個日期是我得到:
var dataset = [];
$.each(chartInfo.DataSetTime, function (key, value) {
var datum = key.split('/');
var dateke = new Date(datum[2], datum[1] - 1, datum[0]);
dataset.push([Date.UTC(dateke.getFullYear(), dateke.getMonth() ,dateke.getDay()), value]);
});
for (var i in dataset) {
dataset[i].sort(function (a, b) {
if (a.x > b.x) {
return 1;
}
if (b.x > a.x) {
return -1;
}
return 0;
});
}
console.log(dataset);
$('#container').highcharts({
chart: {
zoomType: 'x',
defaultSeriesType: 'line',
renderTo: 'container'
},
title: {
text: chartInfo.TitleChart
},
subtitle: {
text: document.ontouchstart === undefined ?
'Klik en sleep in de grafiek om in te zoomen' : 'Swipe over de grafiek om in te zoomen'
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: { // don't display the dummy year
month: '%e. %b',
year: '%b'
},
},
yAxis: {
title: {
text: chartInfo.TitleYas
}
},
legend: {
enabled: false
},
plotOptions: {
area: {
fillColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0, Highcharts.getOptions().colors[0]],
[1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
]
},
marker: {
radius: 2
},
lineWidth: 1,
states: {
hover: {
lineWidth: 1
}
},
threshold: null
}
},
series: [{
type: 'area',
name: 'USD to EUR',
data: dataset.sort(function (a, b) {
return a[0] - b[0];
})
}]
});
任何幫助表示讚賞
你看過有趣的手冊? http://www.highcharts.com/errors/15 – 2016-09-18 18:58:18
是,更新了問題。試圖做一個排序,但仍然錯誤的日期顯示和圖形看起來很有趣 – Kaizer
你將不得不比「看起來有趣」更具體:) – jlbriggs