When using the sample but changing the layer direction to bottom->top it becomes apparent that there is a large chunk of extra space generated in the svg. The height properity of the SVG is almost double the height of the contained data.
`
...
`
Removing the hard coded height and width and setting the 2nd part of the translate to 0 in the svg fixes the issue for me.
Graph graph = new Graph();
graph.AddEdge("47", "58");
graph.AddEdge("70", "71");
var subgraph = new Subgraph("subgraph1");
graph.RootSubgraph.AddSubgraph(subgraph);
subgraph.AddNode(graph.FindNode("47"));
subgraph.AddNode(graph.FindNode("58"));
var subgraph2 = new Subgraph("subgraph2");
subgraph2.Attr.Color = Color.Black;
subgraph2.Attr.FillColor = Color.Yellow;
subgraph2.AddNode(graph.FindNode("70"));
subgraph2.AddNode(graph.FindNode("71"));
subgraph.AddSubgraph(subgraph2);
graph.AddEdge("58", subgraph2.Id);
graph.Attr.LayerDirection = LayerDirection.BT;
var gr = new GraphRenderer(graph);
gr.CalculateLayout();
using (var stream = File.Create(Path.Combine(Directory.GetCurrentDirectory(), @"example.svg")))
{
var writer = new SvgGraphWriter(stream, graph)
{
BlackAndWhite = false,
AllowedToWriteUri = true,
};
writer.Write();
}
When using the sample but changing the layer direction to bottom->top it becomes apparent that there is a large chunk of extra space generated in the svg. The height properity of the SVG is almost double the height of the contained data.
`
`
Removing the hard coded height and width and setting the 2nd part of the translate to 0 in the svg fixes the issue for me.