Forum Bugs

JavaScript toExponential issue

Hey Everyone,

I'm trying to display scientific notation in my pdf using JavaScript but I keep running in to an issue where the .toExponential method thinks my input isn't a number and keeps throwing a type error. Has anyone else had this issue and if so what was your work around? Attached is my test html. The html works in the browser, it's just not rendering with Prince.

If it helps, this was found while working with a line chart from d3js. More specifically the "formatDecimal" method (I believe is only used under the hood) which uses the built in toExponential method (

  1. test.html0.3 kB
    Test HTML
I don't think Prince supports this method, I'll see if we can add it.
I was able to get around this by monkey patching the toExponential method with the toExponential method offered by big.js.
Handy! We have also added it to Prince 12.1, please let me know if you notice any issues with this new method.
Works great! Thanks, mikeday.