UNPKG

2.68 kBJavaScriptView Raw
1/*
2* Copyright (C) 1998-2021 by Northwoods Software Corporation. All Rights Reserved.
3*/
4(function (factory) {
5 if (typeof module === "object" && typeof module.exports === "object") {
6 var v = factory(require, exports);
7 if (v !== undefined) module.exports = v;
8 }
9 else if (typeof define === "function" && define.amd) {
10 define(["require", "exports", "../release/go.js", "./RescalingTool.js"], factory);
11 }
12})(function (require, exports) {
13 "use strict";
14 Object.defineProperty(exports, "__esModule", { value: true });
15 exports.init = void 0;
16 /*
17 * This is an extension and not part of the main GoJS library.
18 * Note that the API for this class may change with any version, even point releases.
19 * If you intend to use an extension in production, you should copy the code to your own source directory.
20 * Extensions can be found in the GoJS kit under the extensions or extensionsTS folders.
21 * See the Extensions intro page (https://gojs.net/latest/intro/extensions.html) for more information.
22 */
23 var go = require("../release/go.js");
24 var RescalingTool_js_1 = require("./RescalingTool.js");
25 function init() {
26 if (window.goSamples)
27 window.goSamples(); // init for these samples -- you don't need to call this
28 var $ = go.GraphObject.make; // for conciseness in defining templates
29 var myDiagram = $(go.Diagram, "myDiagramDiv", // create a Diagram for the DIV HTML element
30 {
31 layout: $(go.TreeLayout),
32 "undoManager.isEnabled": true // enable undo & redo
33 });
34 // install the RescalingTool as a mouse-down tool
35 myDiagram.toolManager.mouseDownTools.add(new RescalingTool_js_1.RescalingTool());
36 myDiagram.nodeTemplate =
37 $(go.Node, "Auto", { locationSpot: go.Spot.Center }, new go.Binding("scale").makeTwoWay(), $(go.Shape, "RoundedRectangle", { strokeWidth: 0 }, new go.Binding("fill", "color")), $(go.TextBlock, { margin: 8 }, new go.Binding("text")));
38 // but use the default Link template, by not setting Diagram.linkTemplate
39 // create the model data that will be represented by Nodes and Links
40 myDiagram.model = new go.GraphLinksModel([
41 { key: 1, text: "Alpha", color: "lightblue" },
42 { key: 2, text: "Beta", color: "orange" },
43 { key: 3, text: "Gamma", color: "lightgreen" },
44 { key: 4, text: "Delta", color: "pink" }
45 ], [
46 { from: 1, to: 2 },
47 { from: 1, to: 3 },
48 { from: 3, to: 4 }
49 ]);
50 }
51 exports.init = init;
52});