https://github.com/plotly/plotly.js
Raw File
Tip revision: 1eda36e676dc85bf5a8912e3c55e6adef2b062f2 authored by Mojtaba Samimi on 06 October 2022, 19:27:50 UTC
2.15.0
Tip revision: 1eda36e
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