With NVD3.js (nv.models.lineWithFocusChart), how do you set specific ticks on X-axis, when x values are dates?
- by Panagiotis Panagi
I'm using nv.models.lineWithFocusChart, where I'm showing some hourly measurements. So the x domain is dates.
What I need is to show a tick per hour on X axis:
00:00 01:00 02:00 ... 24:00
I've tried everything I could find but nothing works. It seems that its easy to set specific ticks when values are not dates. But can't figure out how to do it for dates.
Here's the code that creates the graph, if it can help:
nv.addGraph ->
chart = nv.models.lineWithFocusChart(view)
chart.yAxis.tickFormat(d3.format(".02f"))
d3.select(graphSelector).datum([]).transition().duration(500).call(chart)
nv.utils.windowResize ->
d3.select(graphSelector).call(chart)
chart.xAxis.tickFormat (d) ->
d3.time.format(ticksFormat)(new Date(d))
chart.x2Axis.tickFormat (d) ->
d3.time.format(ticksFormat)(new Date(d))
chart.xAxis.tickSubdivide(9)