I want to display the web traffics with StackedAreChart
use nvd3.js
.
I need to show a tick per hour on X axis:00:00 01:00 02:00 ... 24:00. How do I do that?
reference the StackedAreaChart in this page
nv.addGraph(function() {
var chart = nv.models.stackedAreaChart()
.x(function(d) { return d[0] })
.y(function(d) { return d[1] })
.clipEdge(true)
.useInteractiveGuideline(true)
;
chart.xAxis
.showMaxMin(false)
//.ticks(d3.time.hour,2) //I wrote this line,but is does not work
.tickFormat(function(d) { return d3.time.format('%H:%M')(new Date(d))
});
chart.yAxis.tickFormat(d3.format(',.2f'));
d3.select('#chart svg')
.datum(data)
.transition().duration(500).call(chart);
nv.utils.windowResize(chart.update);
return chart;
});