javascript - d3js set tickValues for time scale axis -
i've searched in official d3.js documentation, as, here in stackoverflow find way add custom tickvalues time scale axis; however, haven't stumble across documentation confirms possible.
so in essence, have time scale axis , show specific hours e.g. i'd :
xhouraxis .ticks(d3.time.hours, 2) .tickformat(d3.time.format('%i %p')) .tickvalues(2, 4, 6, 8, 10, 12) ; so want display tick values every 2 hours, not including first (12 am) , last (12 pm).
does know if there workaround that?
nearly there, code has 2 problems: first tick values must specified in array, , second values should javascript date objects. i.e. provide array of dates tickvalues code looks this:
xhouraxis .tickformat(d3.time.format('%i %p')) .tickvalues([new date(2000,10,5), new date(2005,2,7), new date(2007,11,11)]); also, note needn't call ticks() if going later specify custom values.
Comments
Post a Comment