Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The multi-scale time format isn’t exposed as a public API outside of the standard one returned by a <a href="https://github.com/mbostock/d3/wiki/Time-Scales" rel="nofollow noreferrer">d3.time.scale</a>’s <a href="https://github.com/mbostock/d3/wiki/Time-Scales#wiki-tickFormat" rel="nofollow noreferrer">tickFormat</a> method.</p> <p>That said, the <a href="https://github.com/mbostock/d3/blob/master/src/time/scale.js#L134-143" rel="nofollow noreferrer">implementation itself</a> is fairly simple, so you could create your own multi-scale time format without a lot of work. The multi-scale time format is simply an ordered array of <a href="https://github.com/mbostock/d3/wiki/Time-Formatting" rel="nofollow noreferrer">time formats</a>, each of which has an associated test function. The first test function that returns true determines which time format is used.</p> <p>The time format used by d3.time.scale has the following formats (taken from <a href="https://github.com/mbostock/d3/blob/master/src/time/scale.js#L134-143" rel="nofollow noreferrer">time/scale.js</a>), specified in reverse order:</p> <pre><code> [".%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() &amp;&amp; d.getDate() != 1; }], ["%b %d", function(d) { return d.getDate() != 1; }], ["%B", function(d) { return d.getMonth(); }], ["%Y", d3_true] </code></pre> <p>So, for example, if the time has a non-zero milliseconds field, then the ".%L" format is used; otherwise, if it has a non-zero seconds field, then ":%S" is used; and so on.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload