Visualize d3 linear beautiful scale with integers

I am currently using d3.scale.linear().nice()the y axis to render. However, sometimes this is a problem when the values ​​are only integers, for example. 1 - 5, but ticks are displayed 1-5 in increments of 0.5. Is there a way to specify integers only in this case?

+4
source share
1 answer

Use the method tickFormat.

d3.scale.linear().nice().tickFormat(d3.format("d"));
+3
source

All Articles