Published
Edited
Apr 23, 2021
Importers
Insert cell
Insert cell
Insert cell
Insert cell
// Create a new directed graph
graph = {
const g = new dagre.graphlib.Graph();

// Set an object for the graph label
g.setGraph({});

// Default to assigning a new object as a label for each new edge.
g.setDefaultEdgeLabel(function() { return {}; });

// Add nodes to the graph. The first argument is the node id. The second is
// metadata about the node. In this case we're going to add labels to each of
// our nodes.
// g.setNode("kspacey", { label: "Kevin Spacey", width: 144, height: 100 });
// g.setNode("rwright", { label: "Robin Wright", width: 144, height: 100 });
// g.setNode("bpitt", { label: "Brad Pitt", width: 108, height: 100 });
// g.setNode("hford", { label: "Harrison Ford", width: 168, height: 100 });
// g.setNode("sweaver", { label: "Sigourney Weaver", width: 168, height: 100 });
// g.setNode("kbacon", { label: "Kevin Bacon", width: 121, height: 100 });

// // Add edges to the graph.
// g.setEdge("kspacey", "rwright");
// g.setEdge("rwright", "kbacon");
// g.setEdge("bpitt", "kbacon");
// g.setEdge("hford", "sweaver");
// g.setEdge("sweaver", "kbacon");
g.setNode('name', { label: 'name', url:'/name' })
g.setNode('state', { label: 'state', url:'/state' });
g.setNode('bizType', { label: 'bizTyoe', url: '/biztype' });
g.setNode('California', { label: 'California', url:'/california' });
g.setNode('Delaware', { label: 'Delaware', url:'/delaware' });
g.setNode('Florida', { label: 'Florida', url:'/florida' });
g.setNode('AllStates', { label: 'AllStates', url:'/allstates' });
g.setNode('licenses', { label: 'licenses', url:'/licenses' });
g.setNode('employees', { label: 'Employees', url:'/employees' });
g.setNode('llc', { label: 'LLC', url:'/llc' });
g.setNode('sole', { label: 'Sole', url:'/sole' });
g.setNode('finish', { label: 'Congrats', url:'/congrats' });

g.setEdge('name', 'state');
g.setEdge('state', 'bizType');
g.setEdge('bizType', 'California');
g.setEdge('bizType', 'Delaware');
g.setEdge('bizType', 'Florida');
g.setEdge('bizType', 'AllStates');
g.setEdge('AllStates', 'licenses');
g.setEdge('California', 'licenses');
g.setEdge('Delaware', 'licenses');
g.setEdge('Florida', 'licenses');
g.setEdge('licenses', 'employees');
g.setEdge('employees', 'llc');
g.setEdge('employees', 'sole');
g.setEdge('sole', 'finish');
return g;
}
Insert cell
Insert cell
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