1 | 'use strict';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | import * as go from '../release/go.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 | 'undoManager.isEnabled': true
|
16 | });
|
17 |
|
18 |
|
19 | myDiagram.nodeTemplate =
|
20 | $(go.Node, 'Auto',
|
21 | $(go.Shape, 'RoundedRectangle', { strokeWidth: 0 },
|
22 |
|
23 | new go.Binding('fill', 'color')),
|
24 | $(go.TextBlock,
|
25 | { margin: 8 },
|
26 |
|
27 | new go.Binding('text', 'key'))
|
28 | );
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | myDiagram.model = new go.GraphLinksModel(
|
34 | [
|
35 | { key: 'Alpha', color: 'lightblue' },
|
36 | { key: 'Beta', color: 'orange' },
|
37 | { key: 'Gamma', color: 'lightgreen' },
|
38 | { key: 'Delta', color: 'pink' }
|
39 | ],
|
40 | [
|
41 | { from: 'Alpha', to: 'Beta' },
|
42 | { from: 'Alpha', to: 'Gamma' },
|
43 | { from: 'Beta', to: 'Beta' },
|
44 | { from: 'Gamma', to: 'Delta' },
|
45 | { from: 'Delta', to: 'Alpha' }
|
46 | ]);
|
47 |
|
48 |
|
49 | (window as any).myDiagram = myDiagram;
|
50 | }
|