Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. var $ = go.GraphObject.make; // for conciseness in defining templates
  2.  
  3. myDiagram = $(go.Diagram, "myDiagramDiv", // create a Diagram for the DIV HTML element
  4. {
  5. initialContentAlignment: go.Spot.Center, // center the content
  6. "undoManager.isEnabled": true // enable undo & redo
  7. });
  8.  
  9. // define a simple Node template
  10. myDiagram.nodeTemplate =
  11. $(go.Node, "Auto", // the Shape will go around the TextBlock
  12. $(go.Shape, "RoundedRectangle", { strokeWidth: 0},
  13. // Shape.fill is bound to Node.data.color
  14. new go.Binding("fill", "color")),
  15. $(go.TextBlock,
  16. { margin: 8 }, // some room around the text
  17. // TextBlock.text is bound to Node.data.key
  18. new go.Binding("text", "key")),
  19. $(go.Shape, "Circle", {
  20. width: 20,
  21. height: 20,
  22. stroke: 'transparent',
  23. fill: 'red',
  24. position: new go.Point(0, 0),
  25. isActionable: true,
  26. click: function(e, b) {
  27. console.log('foo');
  28. }
  29. })
  30. );
  31.  
  32. // but use the default Link template, by not setting Diagram.linkTemplate
  33.  
  34. // create the model data that will be represented by Nodes and Links
  35. myDiagram.model = new go.GraphLinksModel(
  36. [
  37. { key: "Alpha", color: "lightblue" },
  38. { key: "Beta", color: "orange" },
  39. { key: "Gamma", color: "lightgreen" },
  40. { key: "Delta", color: "pink" }
  41. ]);
  42. myDiagram.addDiagramListener("ChangedSelection",
  43. function(e, obj) {
  44. console.log('ChangedSelection');
  45. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement