javascript - D3.js time scale: nicely-spaced ticks at month intervals? -
i'm using d3.js create simple bar graphs, , using d3.time.scale()
x-axis. but, stumbled upon 1 irregularity (or seems me, although of course, i'm wrong :p)
when generate scale ticks @ monthly intervals, difference between ticks not equal.
scalex = d3.time.scale() .range([0, 1000]) .domain([new date('2014-01'), new date('2014-12')]) scalex(new date("2014-01")) // 0 scalex(new date("2014-02")) // 9.28... (diff ~ 9.3) scalex(new date("2014-03")) // 17.66... (diff ~ 8.4) scalex(new date("2014-04")) // 26.94... (diff ~ 9.3)
this causes bars in graph unevenly spaced, leading ugly graphs...
what's correct way evenly space out bars months ticks? realize there possibility use ordinal
scale this, doesn't feel right, ordinal scale not draw ticks months don't have data.
edit: little clarification on question: since programmers, asked "correct way" make ticks evenly spaced out. want ask this:
is acceptable display time-charts ticks of unequal length?
Comments
Post a Comment