https://github.com/plotly/plotly.js
Raw File
Tip revision: 4836ad1de7f9eefd851bdc0075b01dfecb6f3547 authored by Mojtaba Samimi on 16 February 2023, 14:31:04 UTC
Merge remote-tracking branch 'origin/master' into config-react
Tip revision: 4836ad1
plotly_node.js
var fs = require('fs');
var JSDOM = require('jsdom').JSDOM;

var window = new JSDOM('', {
    runScripts: 'dangerously'
}).window;

// Mock things that jsdom doesn't support out-of-the-box
window.URL.createObjectURL = function() {};

module.exports = function plotlyNode(plotlyPath) {
    // Execute source code by inserting a <script> tag containing it
    var scriptEl = window.document.createElement('script');
    scriptEl.textContent = fs.readFileSync(plotlyPath, { encoding: 'utf-8' });
    window.document.body.appendChild(scriptEl);

    return window.Plotly;
};
back to top