Last active
March 25, 2017 19:48
-
-
Save yusk90/7889ed01840e9a030adb863346382abe to your computer and use it in GitHub Desktop.
Gojs example http://jsbin.com/zoxowiduna/1/edit?js,output
This file contains 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
var $ = go.GraphObject.make; // for conciseness in defining templates | |
myDiagram = $(go.Diagram, "myDiagramDiv", // 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", { strokeWidth: 0}, | |
// Shape.fill is bound to Node.data.color | |
new go.Binding("fill", "color")), | |
$(go.TextBlock, | |
{ margin: 8 }, // some room around the text | |
// TextBlock.text is bound to Node.data.key | |
new go.Binding("text", "key")), | |
$(go.Shape, "Circle", { | |
width: 20, | |
height: 20, | |
stroke: 'transparent', | |
fill: 'red', | |
position: new go.Point(0, 0), | |
isActionable: true, | |
click: function(e, b) { | |
console.log('foo'); | |
} | |
}) | |
); | |
// 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" } | |
]); | |
myDiagram.addDiagramListener("ChangedSelection", | |
function(e, obj) { | |
console.log('ChangedSelection'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment