Plotly.js plots in typescript Jupyter Notebooks!
Also works in Notebooks inside VSCode.
And the plots are interactive, checkout the example in notebook viewer
npm i tslab-plotly
import Plotly from "tslab-plot";
import * as tslab from "tslab";
Plotly.newPlot(tslab, [
{
x: [1, 2, 3, 4, 5],
y: [1, 2, 4, 8, 16],
},
]);
The API exposed is exactly the same as that of plotly.js, except that the first argument is tslab
instead of the id of the HTML container element.
See example plots in https://plotly.com/javascript/.
Obviously node, npm and typescript. And the Jupyter lab environment:
This library uses tslab.display.html to inject:
- The DIV container for the plot
- A script tag that fetches plotly.js from a CDN
- Passess all the plot parameters to it in JSON format.