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.


                <script src=""></script>


  <div id="sample">
    <div id="myDiagramDiv" style="border: solid 1px black; width:100%; height:400px; background: #444"></div>
    <button onclick="load()">Load</button>
    <button onclick="save()">Save</button>
    <textarea id="mySavedModel" style="width:100%;height:250px">
{ "class": "go.GraphLinksModel",
  "nodeDataArray": [
{"key":1, "text":"Alpha", "color":"lightblue"},
{"key":2, "text":"Beta", "color":"orange"},
{"key":3, "text":"Gamma", "color":"lightgreen"}
  "linkDataArray": [
{"from":1, "to":2},
{"from":1, "to":3}





                  // Assume that a Link may have a  linkdata.colors  property that is an Array of CSS color strings.
  // Also assume that each Link has as many Shapes in it that are marked with  isPanelMain: true
  // as you want to get a color from the data.colors Array.
  function MultiColorLink() {;
  go.Diagram.inherit(MultiColorLink, go.Link);

  MultiColorLink.prototype.makeGeometry = function() {
    var geo =;
    var shape = this.findObject('highlightPath');
    // length of the colored section is 1/5th of the path
    var seclen = geo.flattenedTotalLength / 5;
    // make the dash array big enough that the section only presents at the middle
    // so start at 2/5ths, to give the middle 5th the color
    shape.strokeDashArray = [0, 2 * seclen, seclen, 99999];
    return geo;

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

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

    myDiagram.nodeTemplate =
      $(go.Node, "Auto",
        { fromSpot: go.Spot.AllSides, toSpot: go.Spot.AllSides },
          { fill: "white", strokeWidth: 0 },
          new go.Binding("fill", "color")),
          { margin: 12 },
          new go.Binding("text"))

    function linkPath() {  // common styling for each section
      return $(go.Shape, { isPanelMain: true, strokeWidth: 5 });

    myDiagram.linkTemplate =
          routing: go.Link.AvoidsNodes, corner: 10,
          relinkableFrom: true, relinkableTo: true,
          reshapable: true, resegmentable: true
        $(go.Shape, { isPanelMain: true, strokeWidth: 5 }),
        $(go.Shape, { isPanelMain: true, strokeWidth: 5, name: 'highlightPath', stroke: 'lime' })

  } // end init

  function save() {
    document.getElementById("mySavedModel").value = myDiagram.model.toJson();
    myDiagram.isModified = false;
  function load() {
    myDiagram.model = go.Model.fromJson(document.getElementById("mySavedModel").value);