d3 / d3-axis

Human-readable reference marks for scales.

Home Page:https://d3js.org/d3-axis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Default formatter shows month name instead of Sunday

nitely opened this issue · comments

What's the rational behind this? I know I can set my own tickFormat, but not when dynamically changing the time range (i.e zoom). It's a minor detail, I guess, but I find it very odd. To illustrate, the time axis may show [..., Sat 02, 12 PM, Feb 03, 12PM, Mon 04, ...]

This is controlled by the scale’s tick format (in particular, time.tickFormat) not the axis component. Per the README:

Although somewhat unusual, this default behavior has the benefit of providing both local and global context: for example, formatting a sequence of ticks as [11 PM, Mon 07, 01 AM] reveals information about hours, dates, and day simultaneously, rather than just the hours [11 PM, 12 AM, 01 AM]. See d3-time-format if you’d like to roll your own conditional time format.

My bad. I found d3/d3-scale#103, but it does not explain why show the month instead of Sunday, oh well...