2011-06-17 83 views
11

我有一個xaxis,它是在highcharts上的日期時間格式。Highcharts,在datetime xaxis類型上顯示特定的刻度

我發送xaxis的毫秒位置以將點放在圖表上。

xaxis的總時間約爲2年。

但是我只想在有點(約6分)的地方顯示刻度。

目前,蜱與日期定期顯示。

這裏是我有:

enter image description here

而且我需要什麼:

enter image description here

感謝,

+0

可否請你發佈的工作代碼示例的數量?我似乎無法達到預期的效果jsfiddle.net/blowsie/7hdpz – Blowsie 2012-02-16 15:04:10

+0

@Dragouf你能找到解決方案嗎?下面的解決方案似乎都不適合我。 – Naveen 2015-09-18 23:31:36

回答

4

這是可能的,

可以使用

xAxis.labels.formatter 

這是一個用於格式化標籤,你必須保持{realaxis:{標籤:labelValue},realaxis:{標籤:labelValue } ...}對象格式化標籤

設置

xAxis.tickInterval

爲標籤的格式化函數調用您提供

0

如果你想顯示蜱需要什麼你可以做的是實現一個custom formatter。基本上,如果數值與你的數據相同,你只會繪製一個點:

var data = []; //assuming this is your array of timestamps 

var chart = new Highcharts.chart({ 
    //other options 
    xAxis: { 
     labels: { 
      formatter: function() { 
       //some cleanup may be required, but this is the general form of the solution 
       if (this.value in data) { 
        return this.value; 
       } 
      } 
     } 
    } 
}); 
+0

不,它似乎不起作用,因爲格式化程序只是調用格式化已經放置的刻度。不在x軸的每個單元上。我試圖減少pointInterval,但它沒有改變。 – Dragouf 2011-06-20 08:25:36

2

我認爲你不能這樣做。 Highcharts只在某個固定的時間間隔內繪製標記。如果他們沒有定期出現,那麼他們就不再是蜱蟲了。 您可以嘗試設置minorTickInterval,但仍然取決於您的數據,它們出現在時間軸上的位置。