Created
April 7, 2015 11:18
-
-
Save timruffles/e1f14572412f43d09da4 to your computer and use it in GitHub Desktop.
custom d3 multi format time scale - get your own formats/intervals into axis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// array of [format string, useFormat]. formats are accessed in order, return true to use the format | |
// - this is the default - it pretty much just finds the smallest time period that's non-zero | |
var multiScale = d3.time.format.utc.multi([ | |
[".%L", function(d) { return d.getUTCMilliseconds(); }], | |
[":%S", function(d) { return d.getUTCSeconds(); }], | |
["%I:%M", function(d) { return d.getUTCMinutes(); }], | |
["%I %p", function(d) { return d.getUTCHours(); }], | |
["%a %d", function(d) { return d.getUTCDay() && d.getUTCDate() != 1; }], | |
["%b %d", function(d) { return d.getUTCDate() != 1; }], | |
["%B", function(d) { return d.getUTCMonth(); }], | |
["%Y", function(){ return true }] | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment