2017-06-16 79 views
0

我製作了基於時間軸x軸的條形圖,它和tickValues()一起工作。d3 - 軸ticks不像tickValues那樣工作

xAxis.tickFormat(customTimeFormat) 
    .tickValues(xScale.domain() 
    .filter(function(d, i) { 
      // return true or false by some process 
    }); 

它的效果和我預期的一樣,但是當我用蜱做軸時,它不起作用。

xAxis.tickFormat(customTimeFormat).ticks(4); 

我應該如何設置座標軸中的刻度?

回答

1

你可以嘗試設置刻度爲時間間隔

xAxis.tickFormat(d3.timeFormat("%H:%M")).ticks(d3.timeHour, 1); 

此代碼創建時間軸上的每個小時刻度。也可以改爲d3.timeDay,d3.timeMonth等。

相關問題