/* global Plotly:false */ const {ipcRenderer} = require('electron') ipcRenderer.on('fig', (event, fig, uid) => { const gd = document.createElement('div') document.body.appendChild(gd) Plotly.newPlot(gd, fig) .then(gd => Plotly.toImage(gd)) .then(imgData => { ipcRenderer.send(uid, { code: 200, imgData: imgData.replace(/^data:image\/\w+;base64,/, '') }) Plotly.purge(gd) document.body.removeChild(gd) }) .catch(err => { ipcRenderer.send(uid, { code: 525, msg: JSON.stringify(err, ['message', 'arguments', 'type', 'name']) }) }) })