简体   繁体   中英

printing date in different format on x-axis in d3.js

I am using D3.js to build this line chart.and its working fine . but i am not able to print the months on x-axis in abbreviated form (jan,feb....)

here how i am parsing the date.

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

the code for x-axis

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

and printing and appending

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

help me with this.

只需在内部使用d3.time.format的tickFormat

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM