body { margin:1; /* This is used to reset any browser-default margins */ }
#myDiagramDiv { height:95vh; }
#myOverviewDiv {
position: absolute;
width:162px;
height:100px;
top: 6px;
left: 6px;
background-color: lightgrey;
z-index: 300; /* make sure its in front */
border: solid 1px grey;
}
JavaScript
$(document).ready(function()
{
var $ = go.GraphObject.make; // for conciseness in defining templates
myDiagram =
$(go.Diagram, "myDiagramDiv", // create a Diagram for the DIV HTML element
{
allowMove: true, // Set falue so user cannot move any nodes
initialAutoScale: go.Diagram.Uniform, // initially the whole diagram fits in the viewport
initialContentAlignment: go.Spot.Center, // center the content
layout:
$(go.TreeLayout,
{
treeStyle: go.TreeLayout.StyleLastParents,
arrangement: go.TreeLayout.ArrangementHorizontal,
// properties for most of the tree:
compaction: go.TreeLayout.CompactionNone,
angle: 90,
alignment: go.TreeLayout.AlignmentCenterSubtrees,
layerSpacing: 80,
nodeSpacing: 60,
breadthLimit:0,
// properties for the "last parents":
alternateAngle: 90,
//alternateLayerSpacing: 35,
alternateAlignment: go.TreeLayout.AlignmentBus,
//alternateNodeIndent: 10,
//alternateNodeIndentPastParent: 1.0,
//alternateNodeSpacing: 10,
// alternateLayerSpacing: 20,
//alternateLayerSpacingParentOverlap: 1.0,
// alternatePortSpot: new go.Spot(0.01, 1, 4, 0),
//alternateChildPortSpot: go.Spot.Left
}),
"LayoutCompleted": function(e) {
var y = Infinity;
var h = 0;
e.diagram.findTopLevelGroups().each(function(g) {
y = Math.min(y, g.actualBounds.y);
h = Math.max(h, g.actualBounds.height);
});
e.diagram.findTopLevelGroups().each(function(g) {
g.position = new go.Point(g.position.x, y);
if (g.isSubGraphExpanded) { g.height = h;}
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.