Public
Edited
Apr 20
4 forks
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
{
function main(container) {
// Checks if the browser is supported
// if (!mxClient.isBrowserSupported()) {
// Displays an error message if the browser is not supported.
// mxUtils.error("Browser is not supported!", 200, false);
// } else {
// Disables the built-in context menu
mxEvent.disableContextMenu(container);

// Creates the graph inside the given container
var graph = new mxGraph(container);

// Enables rubberband selection
new mxRubberband(graph);

// Gets the default parent for inserting new cells. This
// is normally the first child of the root (ie. layer 0).
var parent = graph.getDefaultParent();

// Adds cells to the model in a single step
graph.model.beginUpdate();
try {
var v1 = graph.insertVertex(parent, null, "Hello,", 20, 20, 80, 30);
var v2 = graph.insertVertex(parent, null, "World!", 200, 150, 80, 30);
var e1 = graph.insertEdge(parent, null, "", v1, v2);
} finally {
// Updates the display
graph.model.endUpdate();
}
}
// }
var a;
return main((a = html`<div></div>`)), a;
}
Insert cell
mx = import("https://esm.sh/@maxgraph/core")
Insert cell
mxRubberband = mx.RubberBandHandler
Insert cell
mxClient = mx.Client
Insert cell
mxUtils = mx.utils
Insert cell
mxEvent = mx.InternalEvent
Insert cell
mxGraph = mx.Graph
Insert cell
mx.Ed
Insert cell
new mxGraph(html`<div></div>`)
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