Skip to content

Commit

Permalink
Don't use hierachical layout in VisJS graphs.
Browse files Browse the repository at this point in the history
  • Loading branch information
allisterb committed Jul 25, 2023
1 parent 4a1887f commit dd6ae7b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
19 changes: 19 additions & 0 deletions src/Stratis.DevEx.Drawing/VisJS/Network.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,21 @@ public class NetworkHierarchical

[JsonProperty("levelSeparation"), JsonSuppressDefaultValue]
public int? LevelSeparation { get; set; }

[JsonProperty("treeSpacing"), JsonSuppressDefaultValue]
public int TreeSpacing { get; set; }

[JsonProperty("blockShifting"), JsonSuppressDefaultValue]
public bool BlockShifting { get; set; }

[JsonProperty("edgeMinimization"), JsonSuppressDefaultValue]
public bool edgeMinimization { get; set; }

[JsonProperty("parentCentralization"), JsonSuppressDefaultValue]
public bool parentCentralization { get; set; }

[JsonProperty("shakeTowards"), JsonSuppressDefaultValue]
public string? ShakeTowards { get; set; }
}

public class NetworkHierarchicalRepulsion
Expand All @@ -116,6 +131,9 @@ public class NetworkLayout

[JsonProperty("hierarchical"), JsonSuppressDefaultValue]
public NetworkHierarchical? Hierarchical { get; set; }

[JsonProperty("clusterThreshold"), JsonSuppressDefaultValue]
public int ClusterThreshold { get; set; }
}

public class NetworkNode
Expand Down Expand Up @@ -279,6 +297,7 @@ public class NetworkColor
}

}

/*
* // these are all options in full.
var options = {
Expand Down
14 changes: 8 additions & 6 deletions src/Stratis.DevEx.Drawing/VisJS/VisJS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,37 @@ public static Network Draw(Graph graph, string width="100%", string height="100%
var network = new Network();
var options = new NetworkOptions();
options.Width = width;
options.Height = "1200px";
options.Height = height;
string? nodeshape = null;
int? nodesize = null;

switch (graph.Kind)
{
case "cfg":
case "cg":
options.AutoResize = true;
options.AutoResize = false;
var layout = new NetworkLayout()
{
ImprovedLayout = true,

/*
Hierarchical = new NetworkHierarchical()
{
Enabled = true,
SortMethod = "directed",
Direction = "UD",
NodeSpacing = 150,
LevelSeparation = 150,
}
}*/
};
var physics = new NetworkPhysics()
{

HierarchicalRepulsion = new NetworkHierarchicalRepulsion()
{
AvoidOverlap = 1.0,
NodeDistance = 150,
AvoidOverlap = 2.0,
NodeDistance = 250,
}

};
var edgesOptions = new NetworkEdgesOptions()
{
Expand Down

0 comments on commit dd6ae7b

Please sign in to comment.