Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <body onload="init()">
  <div id="myDiagramDiv" style="border: solid 1px black; width:400px; height:400px"></div>
  <p><a href=""/><a/></p>




                function init() {
  var $ = go.GraphObject.make;

  myDiagram =
    $(go.Diagram, "myDiagramDiv",
        "undoManager.isEnabled": true,
        layout: $(go.TreeLayout)

  // define a simple Node template
  myDiagram.nodeTemplate =
    $(go.Node, "Spot",  // the Shape will go around the TextBlock
      new go.Binding("visible", "isOther", function (o) { return !o; }),
      $(go.Panel, "Auto",
        $(go.Shape, "RoundedRectangle", { strokeWidth: 0 },
          // Shape.fill is bound to
          new go.Binding("fill", "color")),
          { margin: 8 },  // some room around the text
          // TextBlock.text is bound to
          new go.Binding("text", "key"))
      makeCustomExpander(go.Spot.Right, false),
      makeCustomExpander(go.Spot.TopRight, true)

  function makeCustomExpander(align, others) {
    return $("Button",
        alignment: align,
        click: function(e, obj) {
          var node = obj.part;  // get the Node containing this Button
          if (node === null) return;
          e.handled = true;
          expandNode(node, others);
      $(go.Shape,  // the icon
          name: 'ButtonIcon',
          figure: 'MinusLine',
          stroke: '#424242',
          strokeWidth: 2,
          desiredSize: new go.Size(8, 8)
        // bind the Shape.figure to the value using this converter:
        new go.Binding('figure', others ? '_othersExpanded' : '_primariesExpanded',
          function (exp, shape) {
            var but = shape.panel;
            return exp ? 'MinusLine' : 'PlusLine';
      // assume initially not visible because there are no links coming out
      { visible: false },
      // bind the button visibility to whether it's not a leaf node
      new go.Binding('visible', 'isTreeLeaf',
        function (leaf) { return !leaf; }

  function expandNode(node, others) {
    var diagram = node.diagram;
    var nd =;
    var children = node.findTreeChildrenNodes();
    children.each(function(c) {
      var cd =;
      if (others && !cd.isOther) return;
      if (!others && cd.isOther) return;
      if (c.visible) {
        c.visible = false;
      } else {
        c.visible = true;
    if (others) {
      myDiagram.model.set(, '_othersExpanded', !;
    } else {
      myDiagram.model.set(, '_primariesExpanded', !;

  // create the model data that will be represented by Nodes and Links
  myDiagram.model = new go.TreeModel(
    { key: "Alpha", _othersExpanded: false, _primariesExpanded: true, color: "lightblue" },
    { key: "Beta",  _othersExpanded: false, _primariesExpanded: true, color: "orange", parent: "Alpha" },
    { key: "Gamma", _othersExpanded: false, _primariesExpanded: true, color: "lightgreen", parent: "Alpha" },
    { key: "Delta", _othersExpanded: false, _primariesExpanded: true, color: "pink", isOther: true, parent: "Alpha" }