d3.js - Converting seconds to minutes and formatting axes -


i have data in format of seconds. convert seconds data hours , minutes , display data along axis. example, i've been trying this:

var xaxis = d3.svg.axis()         .scale(x)         .orient("bottom")         .tickformat(function(d) {return d/60}); 

i see d3 has time formatter, can't seem display proper format. i'm looking a way in d3 convert data in seconds hours , minutes. how can this?

var xaxis = d3.svg.axis()         .scale(x)         .orient("bottom")         .tickformat(function(d) {         var minutes = math.floor(d / 60000);         var seconds = +((d % 60000) / 1000).tofixed(0);         return (seconds == 60 ? (minutes+1) + ":00" : minutes + ":" + (seconds < 10 ? "0" : "") + seconds);  }); 

this convert milliseconds minutes , seconds.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -