2013-01-25 125 views
2

我使用D3.js來構建此折線圖並且其工作正常。但我無法在x軸上以縮寫形式打印月份(jan,feb ....)d3.js在x軸上以不同格式打印日期

這裏我如何解析日期。

var parseDate = d3.time.format("%m-%Y").parse; 

爲x軸

var xAxis = d3.svg.axis().scale(x).orient("bottom"); 

打印和附加

svg.append("g") 
    .attr("class", "x axis") 
    .attr("transform", "translate(0," + height + ")") 
    .call(xAxis); 

幫助我的代碼。

+0

任何一個請..?不能解決它 –

+0

可能重複的[如何格式時間上xAxis使用d3.js](http://stackoverflow.com/questions/15471224/how-to-format-time-on-xaxis-use-d3- JS) – Marijn

回答

4

只使用tickFormat與d3.time.format內

var xAxis = d3.svg.axis().scale(x).orient("bottom").tickFormat(d3.time.format("%H"))