Forum Bugs

JavaScript toExponential issue

dmar
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 (https://github.com/d3/d3-format/blob/master/src/formatDecimal.js#L5)

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