timwis / vizwit

An interactive data visualization tool
http://vizwit.io
GNU General Public License v2.0
100 stars 35 forks source link

DateTime shows too many ticks sometimes #230

Open timwis opened 6 years ago

timwis commented 6 years ago

Works well on small screens but at larger viewports sometimes you get this:

screen shot 2018-04-26 at 5 57 30 am

width 1320.3692626953125 - tickWidth 100 = tickCount 13 but xAxis.scale(13) returns an array of 21 ticks. Yet xAxis.scale(12) returns an array of7`. Huh?

d3 docs say:

The specified count is only a hint; the scale may return more or fewer values depending on the domain.

and

Each value is a power of ten multiplied by 1, 2 or 5

I don't feel like that explains 13 turning into 21 though.

We could either stop using xScale.ticks() and instead pick out evenly spaced items from xScale.domain(), or keep using ticks and, if its length exceeds expected length, pick out its evenly spaced items. Ticks is nice because we could pick them by date type (http://devdocs.io/d3~4/d3-scale#time_ticks).