Reputation: 92
I want to display values with floating point in my d3 chart, with two decimal places.
Data values set in floating point format as 12.385, 12.384, 13.627...
I create axis as yAxisR = d3.axisRight(y3).tickFormat(d3.format(".2f"))
but in axis tick still integer values (12, 13).
If change format for some another value, for example ".0s", axis ticks changes but still not on the that need
https://jsfiddle.net/ochp2dmu/ red right axis
Upvotes: 0
Views: 1978
Reputation: 345
This works just fine for me in your fiddle.
yAxisR = d3.axisRight(y3).tickFormat(d3.format(".2f"))
Make sure that you add more of a margin on the right side of your chart in order to see the entire tick label on the right y-axis. It was overflowing off of the window for me, so I changed the right margin to be 40px.
Upvotes: 4