[Solved] Fixed point rounding

format

#1

Is there a helper to round numbers to a fixed number of digits after the decimal, similar to JavaScript toFixed()? I’d like to tidy up numbers before presentation in the HTML of the sendgrid node.


#2

Yup! You can use the format helper to format a number however you would like.


#3

You are referring to {{format val formatStr}}?


#4

That’s the one, yes. D3 Format can be a bit complicated but that also provides you a lot of flexibility in how you want the numbers to display.

In your case, if you wanted to round the number 1234.56 to the nearest whole number and include the comma after the thousands digit, the format would be .4n.

Here are some common D3 examples and a tester where you can enter a value and your own format to see how it will behave.


#5

That’s a great page and makes thing much more clear.

Thank you so much!