1 | <!DOCTYPE html>
|
2 | <html lang="en">
|
3 | <head>
|
4 | <meta charset="utf-8"/>
|
5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover"/>
|
6 | <meta name="description" content="TypeScript: A custom Layout that arranges a collection of nodes and links where there is a single 'split' node and a single 'merge' node, and all nodes are in paths of links that come from the 'split' node and go to the 'merge' node."/>
|
7 | <link rel="stylesheet" href="../assets/css/style.css"/>
|
8 |
|
9 | <title>Parallel Layout</title>
|
10 | </head>
|
11 |
|
12 | <body>
|
13 |
|
14 | <nav id="navTop" class="w-full z-30 top-0 text-white bg-nwoods-primary">
|
15 | <div class="w-full container max-w-screen-lg mx-auto flex flex-wrap sm:flex-nowrap items-center justify-between mt-0 py-2">
|
16 | <div class="md:pl-4">
|
17 | <a class="text-white hover:text-white no-underline hover:no-underline
|
18 | font-bold text-2xl lg:text-4xl rounded-lg hover:bg-nwoods-secondary " href="../">
|
19 | <h1 class="mb-0 p-1 ">GoJS</h1>
|
20 | </a>
|
21 | </div>
|
22 | <button id="topnavButton" class="rounded-lg sm:hidden focus:outline-none focus:ring" aria-label="Navigation">
|
23 | <svg fill="currentColor" viewBox="0 0 20 20" class="w-6 h-6">
|
24 | <path id="topnavOpen" fill-rule="evenodd" d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM9 15a1 1 0 011-1h6a1 1 0 110 2h-6a1 1 0 01-1-1z" clip-rule="evenodd"></path>
|
25 | <path id="topnavClosed" class="hidden" fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"></path>
|
26 | </svg>
|
27 | </button>
|
28 | <div id="topnavList" class="hidden sm:block items-center w-auto mt-0 text-white p-0 z-20">
|
29 | <ul class="list-reset list-none font-semibold flex justify-end flex-wrap sm:flex-nowrap items-center px-0 pb-0">
|
30 | <li class="p-1 sm:p-0"><a class="topnav-link" href="../learn/">Learn</a></li>
|
31 | <li class="p-1 sm:p-0"><a class="topnav-link" href="../samples/">Samples</a></li>
|
32 | <li class="p-1 sm:p-0"><a class="topnav-link" href="../intro/">Intro</a></li>
|
33 | <li class="p-1 sm:p-0"><a class="topnav-link" href="../api/">API</a></li>
|
34 | <li class="p-1 sm:p-0"><a class="topnav-link" href="https://www.nwoods.com/products/register.html">Register</a></li>
|
35 | <li class="p-1 sm:p-0"><a class="topnav-link" href="../download.html">Download</a></li>
|
36 | <li class="p-1 sm:p-0"><a class="topnav-link" href="https://forum.nwoods.com/c/gojs/11">Forum</a></li>
|
37 | <li class="p-1 sm:p-0"><a class="topnav-link" href="https://www.nwoods.com/contact.html"
|
38 | target="_blank" rel="noopener" onclick="getOutboundLink('https://www.nwoods.com/contact.html', 'contact');">Contact</a></li>
|
39 | <li class="p-1 sm:p-0"><a class="topnav-link" href="https://www.nwoods.com/sales/index.html"
|
40 | target="_blank" rel="noopener" onclick="getOutboundLink('https://www.nwoods.com/sales/index.html', 'buy');">Buy</a></li>
|
41 | </ul>
|
42 | </div>
|
43 | </div>
|
44 | <hr class="border-b border-gray-600 opacity-50 my-0 py-0" />
|
45 | </nav>
|
46 | <div class="md:flex flex-col md:flex-row md:min-h-screen w-full max-w-screen-xl mx-auto">
|
47 | <div id="navSide" class="flex flex-col w-full md:w-48 text-gray-700 bg-white flex-shrink-0"></div>
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | <div class="p-4 w-full">
|
53 | <div id="sample">
|
54 | <div id="myDiagramDiv" style="border: solid 1px black; background: white; width: 100%; height: 500px"></div>
|
55 | <p>
|
56 | This sample demonstrates a custom <a>TreeLayout</a>, ParallelLayout,
|
57 | which assumes that there is a single "Split" node that is the root of a tree,
|
58 | other than links that connect with a single "Merge" node.
|
59 | The layout is defined in its own file, as <a href="ParallelLayout.ts">ParallelLayout.ts</a>.
|
60 | </p>
|
61 | <p>
|
62 | Both the <a>Diagram.layout</a> and the <a>Group.layout</a> are instances of ParallelLayout,
|
63 | allowing for nested layouts that appear in parallel.
|
64 | </p>
|
65 | </div>
|
66 |
|
67 | <script type="module" id="code">
|
68 | import * as go from "../release/go-module.js";
|
69 | import { ParallelLayout } from './ParallelLayout.js';
|
70 |
|
71 | if (window.goSamples) window.goSamples();
|
72 | const $ = go.GraphObject.make;
|
73 |
|
74 | const myDiagram = $(go.Diagram, 'myDiagramDiv',
|
75 | {
|
76 | allowCopy: false,
|
77 | allowDelete: false,
|
78 | layout: $(ParallelLayout, { layerSpacing: 20, nodeSpacing: 10 })
|
79 | });
|
80 |
|
81 |
|
82 | myDiagram.nodeTemplate =
|
83 | $(go.Node, "Auto",
|
84 | { locationSpot: go.Spot.Center },
|
85 | $(go.Shape, "Rectangle",
|
86 | { fill: "wheat", stroke: null, strokeWidth: 0 }),
|
87 | $(go.TextBlock, { margin: 3 },
|
88 | new go.Binding("text"))
|
89 | );
|
90 |
|
91 | myDiagram.nodeTemplateMap.add("Split",
|
92 | $(go.Node, "Auto",
|
93 | { locationSpot: go.Spot.Center },
|
94 | $(go.Shape, "Diamond",
|
95 | {
|
96 | fill: "deepskyblue", stroke: null, strokeWidth: 0,
|
97 | desiredSize: new go.Size(28, 28)
|
98 | }),
|
99 | $(go.TextBlock,
|
100 | new go.Binding("text"))
|
101 | ));
|
102 |
|
103 | myDiagram.nodeTemplateMap.add("Merge",
|
104 | $(go.Node, "Auto",
|
105 | { locationSpot: go.Spot.Center },
|
106 | $(go.Shape, "Circle",
|
107 | {
|
108 | fill: "deepskyblue", stroke: null, strokeWidth: 0,
|
109 | desiredSize: new go.Size(28, 28)
|
110 | }),
|
111 | $(go.TextBlock,
|
112 | new go.Binding("text"))
|
113 | ));
|
114 |
|
115 |
|
116 | myDiagram.linkTemplate =
|
117 | $(go.Link,
|
118 | { routing: go.Link.Orthogonal, corner: 5 },
|
119 | $(go.Shape,
|
120 | { stroke: "gray", strokeWidth: 1.5 })
|
121 | );
|
122 |
|
123 |
|
124 | myDiagram.groupTemplate =
|
125 | $(go.Group, "Auto",
|
126 | {
|
127 | layout: $(ParallelLayout, { layerSpacing: 20, nodeSpacing: 10 })
|
128 | },
|
129 | $(go.Shape, { fill: "transparent", stroke: "darkgoldenrod" }),
|
130 | $(go.Placeholder, { padding: 10 }),
|
131 | $("SubGraphExpanderButton", { alignment: go.Spot.TopLeft, "ButtonBorder.figure": "Rectangle" })
|
132 | );
|
133 |
|
134 | myDiagram.model = new go.GraphLinksModel([
|
135 | { key: -1, isGroup: true },
|
136 | { key: -2, isGroup: true },
|
137 | { key: -3, isGroup: true },
|
138 | { key: 1, text: 'S', category: 'Split', group: -1 },
|
139 | { key: 2, text: 'C', group: -1 },
|
140 | { key: 3, text: 'Longer Node', group: -1 },
|
141 | { key: 4, text: 'A', group: -1 },
|
142 | { key: 5, text: 'B\nB', group: -1 },
|
143 | { key: 6, text: 'Another', group: -1 },
|
144 | { key: 9, text: 'J', category: 'Merge', group: -1 },
|
145 | { key: 11, text: 'T', category: 'Split', group: -2 },
|
146 | { key: 12, text: 'C', group: -2 },
|
147 | { key: 13, text: 'Here', group: -2 },
|
148 | { key: 14, text: 'D', group: -2 },
|
149 | { key: 15, text: 'Everywhere', group: -2 },
|
150 | { key: 16, text: 'EEEEE', group: -2 },
|
151 | { key: 19, text: 'K', category: 'Merge', group: -2 },
|
152 | { key: 21, text: 'U', category: 'Split', group: -3 },
|
153 | { key: 22, text: 'F', group: -3 },
|
154 | { key: 23, text: 'Medium\nTall\nNode', group: -3 },
|
155 | { key: 24, text: 'G', group: -3 },
|
156 | { key: 25, text: 'AS', group: -3 },
|
157 | { key: 26, text: 'H\nHH\nHHH', group: -3 },
|
158 | { key: 27, text: 'I', group: -3 },
|
159 | { key: 29, text: 'L', category: 'Merge', group: -3 },
|
160 | { key: 101, text: '0', category: 'Split' },
|
161 | { key: 107, text: 'ABCDEFG' },
|
162 | { key: 109, text: '*', category: 'Merge' }
|
163 | ], [
|
164 | { from: 1, to: 2 },
|
165 | { from: 2, to: 3 },
|
166 | { from: 3, to: 4 },
|
167 | { from: 4, to: 9 },
|
168 | { from: 1, to: 5 },
|
169 | { from: 5, to: 6 },
|
170 | { from: 6, to: 9 },
|
171 | { from: 9, to: 11 },
|
172 | { from: 9, to: 21 },
|
173 | { from: 11, to: 12 },
|
174 | { from: 12, to: 13 },
|
175 | { from: 13, to: 14 },
|
176 | { from: 14, to: 19 },
|
177 | { from: 11, to: 15 },
|
178 | { from: 15, to: 16 },
|
179 | { from: 16, to: 19 },
|
180 | { from: 21, to: 22 },
|
181 | { from: 22, to: 24 },
|
182 | { from: 24, to: 26 },
|
183 | { from: 23, to: 29 },
|
184 | { from: 21, to: 25 },
|
185 | { from: 25, to: 23 },
|
186 | { from: 21, to: 27 },
|
187 | { from: 26, to: 29 },
|
188 | { from: 27, to: 29 },
|
189 | { from: 101, to: 1 },
|
190 | { from: 19, to: 109 },
|
191 | { from: 29, to: 107 },
|
192 | { from: 107, to: 109 }
|
193 | ]);
|
194 |
|
195 | window.myDiagram = myDiagram;
|
196 | </script>
|
197 | </div>
|
198 |
|
199 |
|
200 | </div>
|
201 | </body>
|
202 |
|
203 | <script src="../assets/js/goSamples.js"></script>
|
204 | </html>
|