Here’s one possibility:
<!DOCTYPE html>
<html>
<head>
<title>Minimal GoJS Sample</title>
<!-- Copyright 1998-2023 by Northwoods Software Corporation. -->
</head>
<body>
<div id="myDiagramDiv" style="border: solid 1px black; width:100%; height:600px"></div>
<textarea id="mySavedModel" style="width:100%;height:250px"></textarea>
<script src="https://unpkg.com/gojs"></script>
<script src="https://unpkg.com/gojs/extensions/TableLayout.js"></script>
<script id="code">
const $ = go.GraphObject.make;
const myDiagram =
new go.Diagram("myDiagramDiv",
{
allowCopy: false, allowMove: false, allowMove: false,
layout: new TableLayout(),
"undoManager.isEnabled": true,
"ModelChanged": e => { // just for demonstration purposes,
if (e.isTransactionFinished) { // show the model data in the page's TextArea
document.getElementById("mySavedModel").textContent = e.model.toJson();
}
}
});
myDiagram.nodeTemplate =
$(go.Node, "Auto",
$(go.Shape, { fill: "white" },
new go.Binding("fill", "color")),
$(go.TextBlock, { margin: 8 },
new go.Binding("text"))
);
myDiagram.groupTemplate =
$(go.Group, "Auto",
{ column: 1, stretch: go.GraphObject.Fill },
new go.Binding("row"),
$(go.Shape, { fill: null, stroke: "gold", strokeWidth: 2 }),
$(go.Placeholder, { padding: 5, alignment: go.Spot.TopLeft })
);
myDiagram.nodeTemplateMap.add("Rectangle",
$(go.Part,
{ selectable: true, stretch: go.GraphObject.Fill },
new go.Binding("row"),
new go.Binding("rowSpan"),
new go.Binding("column", "col"),
new go.Binding("columnSpan", "colSpan"),
$(go.Shape, { stretch: go.GraphObject.Fill },
new go.Binding("fill", "color"),
new go.Binding("width"),
new go.Binding("height"))
))
myDiagram.model = new go.GraphLinksModel(
[
{ category: "Rectangle", row: 0, col: 0, colSpan: 3, color: "gray", height: 20 },
{ category: "Rectangle", row: 1, col: 0, rowSpan: 8, color: "lightgreen", width: 20 },
{ category: "Rectangle", row: 1, col: 2, rowSpan: 8, color: "lightgreen", width: 20 },
{ category: "Rectangle", row: 9, col: 0, colSpan: 3, color: "slateblue", height: 20 },
{ category: "Rectangle", row: 10, col: 1, color: "pink", height: 20 },
{ key: "G1", isGroup: true, text: "G1", row: 1 },
{ key: "G2", isGroup: true, text: "G2", row: 2 },
{ key: "G3", isGroup: true, text: "G3", row: 3 },
{ key: 1, text: "Alpha", color: "lightblue", group: "G1" },
{ key: 2, text: "Beta", color: "orange", group: "G1" },
{ key: 3, text: "Gamma", color: "lightgreen", group: "G1" },
{ key: 4, text: "Delta", color: "pink", group: "G2" },
{ key: 5, text: "Epsilon", color: "yellow", group: "G3" },
]);
</script>
</body>
</html>
The result:
