JSFiddle - React, Tailwind, and code Playground
by cfarmerga
HTML
<script src="https://gojs.net/latest/release/go.js"></script>
<div id="sample">
<div id="myDiagram" style="border: solid 1px black; width:100%; height:400px"></div>
</div>
JavaScript
init();
function init() {
var $ = go.GraphObject.make;
myDiagram =
$(go.Diagram, "myDiagram",
{
initialContentAlignment: go.Spot.Center,
});
var background_layer = myDiagram.findLayer("Background");
var lower_adornment = $(go.Layer, { name: 'Lower Adornment', isTemporary: true });
myDiagram.addLayerAfter(lower_adornment, background_layer);
var nodeTemplate = $(go.Node, "Vertical",
{
selectionObjectName: 'mainrect',
fromSpot: go.Spot.Right,
toSpot: go.Spot.Left
},
new go.Binding("location", "loc"),
$(go.Shape, "Rectangle",
{
name: 'mainrect',
isPanelMain: true,
fill: 'green',
width: 80,
height: 50
}
),
$(go.Panel, "Auto",
{
},
$(go.Shape, 'Rectangle',
{
strokeWidth: 1,
fill: 'transparent',
stroke: 'black',
desiredSize: new go.Size(80, 50)
}
),
$(go.TextBlock,
{
desiredSize: new go.Size(80, 50),
alignment: go.Spot.TopLeft,
textAlign: 'left',
isMultiline: true,
text: 'This is some really quite long text content',
wrap: go.TextBlock.WrapDesiredSize,
overflow: go.TextBlock.OverflowEllipsis,
editable: true
}
)
)
);
var linkTemplate = $(go.Link,
{
routing: go.Link.Normal,
fromEndSegmentLength: 10,
toEndSegmentLength: 10
},
$(go.Shape,
{
isPanelMain: true,
stroke: 'gray',
strokeWidth: 5
}
),
$(go.Shape,
{
isPanelMain: true,
stroke: 'lightgray',
strokeWidth: 3
}
...