问题
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