UNPKG

2.42 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 var myDiagram = null;
18 function init() {
19 if (window.goSamples)
20 window.goSamples(); // init for these samples -- you don't need to call this
21 var $ = go.GraphObject.make; // for conciseness in defining templates
22 // Initialize the Diagram
23 myDiagram =
24 $(go.Diagram, 'myDiagramDiv', // create a Diagram for the DIV HTML element
25 { 'undoManager.isEnabled': true });
26 // define a simple Node template (but use the default Link template)
27 myDiagram.nodeTemplate =
28 $(go.Node, 'Auto', { contextMenu: window.myHTMLLightBox }, // window.myHTMLLightBox is defined in extensions/LightBoxContextMenu.js
29 $(go.Shape, 'RoundedRectangle', { strokeWidth: 0 },
30 // Shape.fill is bound to Node.data.color
31 new go.Binding('fill', 'color')), $(go.TextBlock, { margin: 8 }, // some room around the text
32 // TextBlock.text is bound to Node.data.key
33 new go.Binding('text', 'key')));
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 myDiagram.contextMenu = window.myHTMLLightBox; // window.myHTMLLightBox is defined in extensions/LightBoxContextMenu.js
48 } // end init
49 exports.init = init;
50});