date format in d3, would like to have month as an integer instead of decimal

半腔热情 提交于 2019-12-12 10:03:25

问题


I would like to have format as 6/19 instead of 06/19 for my X axis. It does not seem to provide a way of doing so on its official documentation: https://github.com/mbostock/d3/wiki/Time-Formatting

Any clues? Thanks?


回答1:


See the part about padding:

The % sign indicating a directive may be immediately followed by a padding modifier:

  • 0 - zero-padding
  • _ - space-padding
  • - - disable padding

For example, "%-m/%-d" will disable padding for both the month and date, giving you "6/1" for June 1st, as opposed to "%m/%d" which gives "06/01".



来源:https://stackoverflow.com/questions/16681038/date-format-in-d3-would-like-to-have-month-as-an-integer-instead-of-decimal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!