UNPKG

gojs

Version:

Interactive diagrams, charts, and graphs, such as trees, flowcharts, orgcharts, UML, BPMN, or business diagrams

106 lines (99 loc) 4.93 kB
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Spiral Layout</title> <meta name="description" content="A custom layout that arranges a chain of nodes in a spiral manner." /> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Copyright 1998-2020 by Northwoods Software Corporation. --> <script src="../release/go.js"></script> <script src="../assets/js/goSamples.js"></script> <!-- this is only for the GoJS Samples framework --> <script src="SpiralLayout.js"></script> <script id="code"> function init() { if (window.goSamples) goSamples(); // init for these samples -- you don't need to call this var $ = go.GraphObject.make; myDiagram = $(go.Diagram, "myDiagramDiv", // create a Diagram for the DIV HTML element { initialAutoScale: go.Diagram.Uniform, isTreePathToChildren: false, // links go from child to parent layout: $(SpiralLayout) // defined in SpiralLayout.js }); myDiagram.nodeTemplate = $(go.Node, go.Panel.Auto, { locationSpot: go.Spot.Center }, $(go.Shape, { figure: "Circle", fill: "white" }, new go.Binding("fill", "color")), $(go.TextBlock, { margin: 4 }, new go.Binding("text", "key"))); myDiagram.linkTemplate = $(go.Link, { curve: go.Link.Bezier, curviness: 10 }, $(go.Shape), $(go.Shape, { toArrow: "Standard" })); var model = new go.TreeModel(); model.nodeParentKeyProperty = "next"; model.nodeDataArray = [ { key: "Alpha", next: "Beta", color: "coral" }, { key: "Beta", next: "Gamma", color: "tomato" }, { key: "Gamma", next: "Delta", color: "goldenrod" }, { key: "Delta", next: "Epsilon", color: "orange" }, { key: "Epsilon", next: "Zeta", color: "coral" }, { key: "Zeta", next: "Eta", color: "tomato" }, { key: "Eta", next: "Theta", color: "goldenrod" }, { key: "Theta", next: "Iota", color: "orange" }, { key: "Iota", next: "Kappa", color: "coral" }, { key: "Kappa", next: "Lambda", color: "tomato" }, { key: "Lambda", next: "Mu", color: "goldenrod" }, { key: "Mu", next: "Nu", color: "orange" }, { key: "Nu", next: "Xi", color: "coral" }, { key: "Xi", next: "Omicron", color: "tomato" }, { key: "Omicron", next: "Pi", color: "goldenrod" }, { key: "Pi", next: "Rho", color: "orange" }, { key: "Rho", next: "Sigma", color: "coral" }, { key: "Sigma", next: "Tau", color: "tomato" }, { key: "Tau", next: "Upsilon", color: "goldenrod" }, { key: "Upsilon", next: "Phi", color: "orange" }, { key: "Phi", next: "Chi", color: "coral" }, { key: "Chi", next: "Psi", color: "tomato" }, { key: "Psi", next: "Omega", color: "goldenrod" }, { key: "Omega", next: "Alpha2", color: "orange" }, { key: "Alpha2", next: "Beta2", color: "coral" }, { key: "Beta2", next: "Gamma2", color: "tomato" }, { key: "Gamma2", next: "Delta2", color: "goldenrod" }, { key: "Delta2", next: "Epsilon2", color: "orange" }, { key: "Epsilon2", next: "Zeta2", color: "coral" }, { key: "Zeta2", next: "Eta2", color: "tomato" }, { key: "Eta2", next: "Theta2", color: "goldenrod" }, { key: "Theta2", next: "Iota2", color: "orange" }, { key: "Iota2", next: "Kappa2", color: "coral" }, { key: "Kappa2", next: "Lambda2", color: "tomato" }, { key: "Lambda2", next: "Mu2", color: "goldenrod" }, { key: "Mu2", next: "Nu2", color: "orange" }, { key: "Nu2", next: "Xi2", color: "coral" }, { key: "Xi2", next: "Omicron2", color: "tomato" }, { key: "Omicron2", next: "Pi2", color: "goldenrod" }, { key: "Pi2", next: "Rho2", color: "orange" }, { key: "Rho2", next: "Sigma2", color: "coral" }, { key: "Sigma2", next: "Tau2", color: "tomato" }, { key: "Tau2", next: "Upsilon2", color: "goldenrod" }, { key: "Upsilon2", next: "Phi2", color: "orange" }, { key: "Phi2", next: "Chi2", color: "coral" }, { key: "Chi2", next: "Psi2", color: "tomato" }, { key: "Psi2", next: "Omega2", color: "goldenrod" }, { key: "Omega2", color: "orange" }]; myDiagram.model = model; } </script> </head> <body onload="init()"> <div id="sample"> <div id="myDiagramDiv" style="border: solid 1px black; width:100%; height:700px; min-width: 200px"></div> <p> This sample demonstrates a custom Layout, SpiralLayout, which assumes the graph consists of a chain of nodes. The layout is defined in its own file, as <a href="SpiralLayout.js">SpiralLayout.js</a>. </p> </div> </body> </html>