https://github.com/plotly/plotly.js
Raw File
Tip revision: 3dcd3c4ffcdb71a36cbc17e39fe06a4a876d0acc authored by Mojtaba Samimi on 11 July 2024, 20:23:29 UTC
bump madge v7
Tip revision: 3dcd3c4
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