On my application, I added a prototype to Math to round decimals. After that, Plot.ly (minified, version 1.40.0, for whatever reason couldn’t make npm package and require work) started failing when trying to plot a valid OHLC graph giving the error message below:

Uncaught TypeError: e._subplots[f].sort is not a function

For whatever reason, adding that prototype to Math breaks Plotly as a whole.

How to reproduce:

- Add a prototype to Math as example below:

Math.**proto**.roundDecimal = function (value, decimals){

return Number(Math.round(value+‘e’+decimals)+‘e-’+decimals);

} - Plot anything (add it to https://codepen.io/plotly/pen/PPVeer before Plotly call)
- ???
- Open Console
- “Uncaught TypeError: e._subplots[f].sort is not a function”

While I know that one should not change core libraries/classes prototypes, but this kind of abstraction helps a lot when you need proper decimal rounding and Math doesn’t bother to have it. Also, I don’t understand how one additional prototype that doesn’t overwrite any other on Math can break a whole API.