continuous.tickFormat([count[, specifier]])
Returns a number format function suitable for displaying a tick value, automatically computing the appropriate precision based on the fixed interval between tick values. The specified count should have the same value as the count that is used to generate the tick values.
An optional specifier allows a custom format where the precision of the format is automatically set by the scale as appropriate for the tick interval. For example, to format percentage change, you might say:
var x = d3.scaleLinear() .domain([-1, 1]) .range([0, 960]); var ticks = x.ticks(5), tickFormat = x.tickFormat(5, "+%"); ticks.map(tickFormat); // ["-100%", "-50%", "+0%", "+50%", "+100%"]
If specifier uses the format type s
, the scale will return a SI-prefix format based on the largest value in the domain. If the specifier already specifies a precision, this method is equivalent to locale.format.
Please login to continue.