1 |
|
2 |
|
3 |
|
4 |
|
5 | import * as go from '../release/go.js';
|
6 | import { RotateMultipleTool } from './RotateMultipleTool.js';
|
7 |
|
8 | export function init() {
|
9 | if ((window as any).goSamples) (window as any).goSamples();
|
10 |
|
11 | const $ = go.GraphObject.make;
|
12 |
|
13 | const myDiagram = $(go.Diagram, 'myDiagramDiv',
|
14 | {
|
15 | rotatingTool: new RotateMultipleTool(),
|
16 | 'undoManager.isEnabled': true
|
17 | });
|
18 |
|
19 |
|
20 | myDiagram.nodeTemplate =
|
21 | $(go.Node, 'Auto',
|
22 | { locationSpot: go.Spot.Center, rotatable: true },
|
23 | new go.Binding('location', 'location', go.Point.parse).makeTwoWay(go.Point.stringify),
|
24 | new go.Binding('angle').makeTwoWay(),
|
25 | $(go.Shape, 'RoundedRectangle', { strokeWidth: 0 },
|
26 |
|
27 | new go.Binding('fill', 'color')),
|
28 | $(go.TextBlock,
|
29 | { margin: 8 },
|
30 |
|
31 | new go.Binding('text', 'key'))
|
32 | );
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | myDiagram.model = new go.GraphLinksModel(
|
38 | [
|
39 | { key: 'Alpha', color: 'lightblue' },
|
40 | { key: 'Beta', color: 'orange' },
|
41 | { key: 'Gamma', color: 'lightgreen' },
|
42 | { key: 'Delta', color: 'pink' }
|
43 | ],
|
44 | [
|
45 | { from: 'Alpha', to: 'Beta' },
|
46 | { from: 'Alpha', to: 'Gamma' },
|
47 | { from: 'Beta', to: 'Beta' },
|
48 | { from: 'Gamma', to: 'Delta' },
|
49 | { from: 'Delta', to: 'Alpha' }
|
50 | ]);
|
51 | }
|