https://github.com/plotly/plotly.js
Raw File
Tip revision: 7a7b412703ff79d5e291c86f2868cba40da71506 authored by Mojtaba Samimi on 04 October 2023, 18:58:07 UTC
2.26.2
Tip revision: 7a7b412
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