The multiscale time format does not display as an open API outside the standard returned by d3.time.scale s tickFormat .
However, the implementation itself is quite simple, so you can create your own multiscale time format without much work. A multiscale time format is simply an ordered array of time formats , each of which has a test function associated with it. The first test function, which returns true, determines which time format is used.
The time format used by d3.time.scale has the following formats (taken from time / scale.js ), indicated in reverse order:
[".%L", function(d) { return d.getMilliseconds(); }], [":%S", function(d) { return d.getSeconds(); }], ["%I:%M", function(d) { return d.getMinutes(); }], ["%I %p", function(d) { return d.getHours(); }], ["%a %d", function(d) { return d.getDay() && d.getDate() != 1; }], ["%b %d", function(d) { return d.getDate() != 1; }], ["%B", function(d) { return d.getMonth(); }], ["%Y", d3_true]
So, for example, if time has a nonzero millisecond field, then the format is ".% L"; otherwise, if it has a nonzero field, then ":% S" is used; etc.
source share