-
Hi there, I'm making an application that uses observableplot as a dependency, is this (/can this be) installed when the environment is created, as with python? i.e. if I wanted to run the application without an internet connection? or does it need to be loaded from a CDN? or am I thinking about it in the wrong way altogether? cheers |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, John! Importing dependencies from a CDN is the simplest option because it doesn't require any js tooling while developing. But in order to have your js dependencies included in the pip-installable package and available offline you'll need to use a bundler - as described in anywidget docs (Bundling). You will need to install npm and after that the easiest way to bootstrap the widget project is to run
Then after step 2 also run You should then be able to import and use this library in your code: // js/widget.js
import "./widget.css";
import * as Plot from "@observablehq/plot";
function render({ model, el }) {
// make an example plot
const plot = Plot.rectY({length: 5000}, Plot.binX({y: "count"}, {x: Math.random})).plot();
el.append(plot);
}
export default { render };
The bundler is configured to output into I hope this helps =). |
Beta Was this translation helpful? Give feedback.
Hi, John!
Importing dependencies from a CDN is the simplest option because it doesn't require any js tooling while developing. But in order to have your js dependencies included in the pip-installable package and available offline you'll need to use a bundler - as described in anywidget docs (Bundling).
You will need to install npm and after that the easiest way to bootstrap the widget project is to run
npm create anywidget@latest
. Follow the steps to get something like this: