Published
Edited
Jan 17, 2022
1 fork
Importers
10 stars
Insert cell
Insert cell
dot`digraph { a -> b }`
Insert cell
dot`graph G {
B [label="Hello World"]
A [label=<Hello<I>World</I>>, color=red]
}`
Insert cell
dot = {
const Viz = await require("viz.js@2");

const viz = await require.resolve("viz.js@2/full.render.js")
.then(url => fetch(url))
.then(response => response.blob())
.then(blob => URL.createObjectURL(blob))
.then(url => new Worker(url))
.then(worker => new Viz({worker}));

const defaults = {files: [], format: "svg", engine: "dot"};

function Dot(options) {
options = Object.assign({}, defaults, options);
return async function dot(strings) {
let string = strings[0] + "", i = 0, n = arguments.length;
while (++i < n) string += arguments[i] + "" + strings[i];
const template = document.createElement("template");
template.innerHTML = await viz.renderString(string, options);
const svg = document.importNode(template.content.firstElementChild, true);
svg.style.maxWidth = "100%";
svg.style.height = "auto";
return svg;
};
}

return Object.assign(Dot(), {options: Dot});
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more