Created
June 12, 2014 17:59
-
-
Save simonsarris/07e6c65ce3d38c5d0faf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Minimal GoJS Sample</title> | |
<!-- Copyright 1998-2014 by Northwoods Software Corporation. --> | |
<script src="go.js"></script> | |
<link href="goSamples.css" rel="stylesheet" type="text/css" /> <!-- you don't need to use this --> | |
<script src="goSamples.js"></script> <!-- this is only for the GoJS Samples framework --> | |
<script id="code"> | |
function init() { | |
var $ = go.GraphObject.make; // for conciseness in defining templates | |
myDiagram = $(go.Diagram, "myDiagram", // create a Diagram for the DIV HTML element | |
{ | |
initialContentAlignment: go.Spot.Center, // center the content | |
"undoManager.isEnabled": true // enable undo & redo | |
}); | |
// define a simple Node template | |
myDiagram.nodeTemplate = | |
$(go.Node, "Auto", // the Shape will go around the TextBlock | |
$(go.Shape, "RoundedRectangle", | |
// Shape.fill is bound to Node.data.color | |
new go.Binding("fill", "color")), | |
$(go.Panel, go.Panel.Spot, $(go.Picture, { source: "images/D3M.Repeater.svg", width: 350, height: 150 })) | |
); | |
// but use the default Link template, by not setting Diagram.linkTemplate | |
// create the model data that will be represented by Nodes and Links | |
myDiagram.model = new go.GraphLinksModel( | |
[ | |
{ key: "Alpha", color: "lightblue" }, | |
{ key: "Beta", color: "orange" }, | |
{ key: "Gamma", color: "lightgreen" }, | |
{ key: "Delta", color: "pink" } | |
], | |
[ | |
{ from: "Alpha", to: "Beta" }, | |
{ from: "Alpha", to: "Gamma" }, | |
{ from: "Beta", to: "Beta" }, | |
{ from: "Gamma", to: "Delta" }, | |
{ from: "Delta", to: "Alpha" } | |
]); | |
} | |
</script> | |
</head> | |
<body onload="init()"> | |
<div id="sample"> | |
<p>Minimal <b>GoJS</b> Sample</p> | |
<!-- The DIV for the Diagram needs an explicit size or else we won't see anything. | |
Also add a border to help see the edges. --> | |
<div id="myDiagram" style="border: solid 1px black; width:400px; height:400px"></div> | |
<p>This isn't a truly <i>minimal</i> demonstration of <b>GoJS</b>, | |
because we do specify a custom Node template, but it's pretty simple. | |
Click on the link below to see source code for this page, | |
or use your browser's "View Page Source" command.</p> | |
<p>The Node template data-binds both the text string and the shape's fill color.</p> | |
<p>You can select, move, copy, delete, and undo/redo.</p> | |
<p>The <a>Diagram.initialContentAlignment</a> setting causes the diagram's contents | |
to appear in the center of the diagram's viewport.</p> | |
<p>On touch devices, hold your finger stationary to bring up a context menu. | |
The default context menu supports most of the standard commands that | |
are enabled at that time for that object.</p> | |
<p>For a more elaborate and capable sample, see the <a href="basic.html">Basic</a> sample.</p> | |
<p>For a sample that loads JSON data from the server, | |
see the <a href="minimalJSON.html">Minimal JSON</a> sample.</p> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment