UNPKG

2.32 kBJavaScriptView Raw
1(function (factory) {
2 if (typeof module === "object" && typeof module.exports === "object") {
3 var v = factory(require, exports);
4 if (v !== undefined) module.exports = v;
5 }
6 else if (typeof define === "function" && define.amd) {
7 define(["require", "exports", "../release/go.js"], factory);
8 }
9})(function (require, exports) {
10 'use strict';
11 Object.defineProperty(exports, "__esModule", { value: true });
12 exports.init = void 0;
13 /*
14 * Copyright (C) 1998-2021 by Northwoods Software Corporation. All Rights Reserved.
15 */
16 var go = require("../release/go.js");
17 function init() {
18 if (window.goSamples)
19 window.goSamples(); // init for these samples -- you don't need to call this
20 var $ = go.GraphObject.make; // for conciseness in defining templates
21 var myDiagram = $(go.Diagram, 'myDiagramDiv', // create a Diagram for the DIV HTML element
22 {
23 'undoManager.isEnabled': true // enable undo & redo
24 });
25 // define a simple Node template
26 myDiagram.nodeTemplate =
27 $(go.Node, 'Auto', // the Shape will go around the TextBlock
28 $(go.Shape, 'RoundedRectangle', { strokeWidth: 0 },
29 // Shape.fill is bound to Node.data.color
30 new go.Binding('fill', 'color')), $(go.TextBlock, { margin: 8 }, // some room around the text
31 // TextBlock.text is bound to Node.data.key
32 new go.Binding('text', 'key')));
33 // but use the default Link template, by not setting Diagram.linkTemplate
34 // create the model data that will be represented by Nodes and Links
35 myDiagram.model = new go.GraphLinksModel([
36 { key: 'Alpha', color: 'lightblue' },
37 { key: 'Beta', color: 'orange' },
38 { key: 'Gamma', color: 'lightgreen' },
39 { key: 'Delta', color: 'pink' }
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 // Attach to the window for console manipulation
48 window.myDiagram = myDiagram;
49 }
50 exports.init = init;
51});