Calling plotly like this:
var Plotly = require('plotly.js');
Causes this:
/Users/bryan/tibra/web3/node_modules/plotly.js/src/lib/index.js:416
var style = document.createElement('style');
^
ReferenceError: document is not defined
at Object.lib.addStyleRule (/Users/bryan/tibra/web3/node_modules/plotly.js/src/lib/index.js:416:21)
at Object.<anonymous> (/Users/bryan/tibra/web3/node_modules/plotly.js/build/plotcss.js:61:16)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/Users/bryan/tibra/web3/node_modules/plotly.js/src/plotly.js:30:1)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/Users/bryan/tibra/web3/node_modules/plotly.js/src/core.js:15:14)
plotly.js is browser package, with no intention of working in vanilla node.js.
In order to do so, you'll need use jsdom (or a similar package).
Here's my preliminary attempt: https://gist.github.com/etpinard/bee7d62b43b6bb286950
I ran into a few issues, and it is not in a working state. But, we hope to solve these issue shortly to offer server-side plotly.js rendering.
What about web frameworks that use SSR (server-side rendering)?
We use Next.js, which server-renders first, and it is a bug for us as well.
and it is a bug for us as well.
Even when using jsdom?
Most helpful comment
What about web frameworks that use SSR (server-side rendering)?
We use Next.js, which server-renders first, and it is a bug for us as well.