我是highchart的初學者。我正在嘗試一些東西並卡住了。我的x軸具有重複多次的值。工具提示值應該包含日期和時間,如圖所示。但我想改變的是x軸值。相同的值只能顯示一次,並且在有數據的地方不會重複。Highcharts x軸格式化選項
X軸格式必須是DD-MMM,工具提示應該是DD-MM-YY HH am/pm。 這可能嗎?
這裏是我的審判代碼
Highcharts.chart('container', {
chart: {
type: 'spline'
},
title: {
text: 'Snow depth at Vikjafjellet, Norway'
},
subtitle: {
text: 'Irregular time data in Highcharts JS'
},
xAxis: {
categories:['01-Feb-17 12 AM','01-Feb-17 01 AM','01-Feb-17 02 AM','02-Feb-17 04 AM','02-Feb-17 05 AM','02-Feb-17 06 AM','02-Feb-17 07 AM'],
labels: {
formatter: function() {
y=(this.value).substring(1,6);
return y;
}
}
},
yAxis: {
title: {
text: 'Snow depth (m)'
},
min: 0
},
tooltip: {
formatter: function() {
y=(this.x).substring(0,15);
return y;
},
shared:false
},
plotOptions: {
spline: {
marker: {
enabled: true
}
}
},
series: [{
name: 'Winter 2012-2013',
// Define the data points. All series have a dummy year
// of 1970/71 in order to be compared on the same x axis. Note
// that in JavaScript, months start at 0 for January, 1 for February etc.
data: [5,10,19,10,4,6,8]
}]
});
and this is how i want it to be
對於初學者來說,由於您正在繪製時間序列數據,因此我會使用'datetime'軸類型。這將使得使用日期信息更加直觀,並且消除了愚蠢的東西獲取類別值的子字符串的需要。然後,它仍然是一個控制'tickInterval'的問題,正如Mike在下面的回答中所指出的那樣。 – jlbriggs