Ok there may be so many duplicates to this question on SO, I have checked almost all of them but I couldn't figure out an answer to my quest.
I have this service which gives a count of hits to my site every minute and I want to display it in a dashboard using a d3 nvd3 line graph.
I got it all working except one thing, I want the labels on the x axis to go from midnight to midnight, i.e (00:00 to 23:00)
in intervals of 1 hour [00:00, 01:00, 02:00, 03:00, 04:00, ..., 22:00, 23:00]
But I am not able to get this right. I have tried all possible combinations using d3.time.scale
but I am not getting it right. I get all random labels on x axis.
This is the function I am currently using which gives those random values:
$scope.xAxisTickFormatFunction = function() {
return function(d) {
return d3.time.format("%H:%M")(new Date(d));
};
};
After I get this timeline of a day working, I would like to do this per each day of the week too.
I really can't figure out how d3.time.scale
works, I have been working on this since yesterday.