Created
May 19, 2015 09:46
-
-
Save ryanand26/b391972140857561fb81 to your computer and use it in GitHub Desktop.
D3.js: Generate the ticks for an axis without having to render them to the svg. Allows us to adapt the tickSize and tickPadding to these values before drawing rather than afterwards.
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
/** | |
* Generate the tick values for a given axis | |
* Reference: https://github.com/mbostock/d3/blob/master/src/svg/axis.js | |
*/ | |
function getAxisTicks(axis) { | |
var scale1 = axis.scale(), | |
tickArguments_ = axis.ticks(), | |
tickValues = axis.tickValues(), | |
ticks; | |
ticks = tickValues == null ? (scale1.ticks ? scale1.ticks.apply(scale1, tickArguments_) : scale1.domain()) : tickValues, | |
return ticks; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment