block by etpinard 26731a74bd746bc471ffeeafdc58612b

Use electron to export plotly.js graphs as images

Full Screen

electron-plotly.js

Use electron to export plotly.js graphs as images.

How to run this thing?

If you’re on Ubuntu (or maybe some other Linux distro) and you have xvfb installed, you can run this things headlessly (no joke) with:

npm run start:headless

and see results in fig.png.

You can also pass as argument any URL to a plotly "data"/"layout" JSON or the name of the plotly.js test mock you’d like to export. For example:

npm start -- gl3d_bunny

How does this thing work?

Using electron the main module sends plotly.js "data"/"layout" JSON data to the renderer module. The renderer calls Plotly.plot and Plotly.toImage in succession and then sends the image data back to the main module it writes a PNG file.

Some useful articles:

index.html

electron-plotly.js

cmd.js

main.js

package.json

renderer.js

test.js