在d3.js中的x轴上以不同格式打印日期 [英] printing date in different format on x-axis in d3.js
本文介绍了在d3.js中的x轴上以不同格式打印日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用D3.js来构建这个折线图,它的工作正常。但我不能以缩写形式(jan,feb ....)打印x轴上的月份
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....)
这里我如何解析日期。 p>
here how i am parsing the date.
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);
帮助我。
推荐答案
只需使用tickFormat和内部的d3.time.format
just use tickFormat with a d3.time.format inside
var xAxis = d3.svg.axis().scale(x).orient("bottom").tickFormat(d3.time.format("%H"))
这篇关于在d3.js中的x轴上以不同格式打印日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文