Public
Edited
Oct 12, 2023
Insert cell
Insert cell
Insert cell
nodeCount = 10;
Insert cell
Insert cell
vis = require("vis")
Insert cell
// Create a div where our vis will eventually live
div = {
const div = document.createElement("div");
div.setAttribute("style","height:500px");
return div;
}
Insert cell
// generate {nodeCount} nodes
nodes = Array(nodeCount).fill(0).map((_, i) => {
return { id: i, label: `Node ${i}` }
});
Insert cell
// let's create the edges
edges = {
var arr = [];
for (var id = 0; id < nodeCount; id++) {
arr.push({
from: id,
to: nodes[Math.floor(Math.random() * nodeCount)]["id"]
})
}
return arr;
return new vis.DataSet(arr);
};

Insert cell
// Finally let's make the vis. The third parameter, the dictionary, is the "options" for the vis.
new vis.Network(div, {edges, nodes}, {});

Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more