Skip to content

Commit 6506ff6

Browse files
committed
Fix focused tree graph spacing layout
1 parent 71718b9 commit 6506ff6

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

src/visualization/figure.jl

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,14 @@ function treeGraphFigure(
993993
labelPlacement,
994994
showFactorLabels
995995
)
996-
variableX = [levelX[depth] for depth in variableDepths]
997-
factorX = [levelX[depth] for depth in factorDepths]
996+
variableX = zeros(Float64, length(graph.variables))
997+
factorX = zeros(Float64, length(graph.factors))
998+
for index in view.variables
999+
variableX[index] = levelX[variableDepths[index]]
1000+
end
1001+
for index in view.factors
1002+
factorX[index] = levelX[factorDepths[index]]
1003+
end
9981004
variableY = zeros(Float64, length(graph.variables))
9991005
factorY = zeros(Float64, length(graph.factors))
10001006

@@ -1298,8 +1304,14 @@ function verticalTreeGraphFigure(
12981304
)
12991305
variableX = zeros(Float64, length(graph.variables))
13001306
factorX = zeros(Float64, length(graph.factors))
1301-
variableY = [levelY[depth] for depth in variableDepths]
1302-
factorY = [levelY[depth] for depth in factorDepths]
1307+
variableY = zeros(Float64, length(graph.variables))
1308+
factorY = zeros(Float64, length(graph.factors))
1309+
for index in view.variables
1310+
variableY[index] = levelY[variableDepths[index]]
1311+
end
1312+
for index in view.factors
1313+
factorY[index] = levelY[factorDepths[index]]
1314+
end
13031315

13041316
for depth in 1:maxDepth
13051317
nodes = Tuple{Symbol, Int}[]

test/graph_figure.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,13 @@ end
296296
@test occursin("variable-context", viewSvg)
297297
@test occursin("<title>Variable x1", viewSvg)
298298
@test occursin(r"<text class=\"label[^\"]*\"[^>]*>\s*<title>Variable x1", viewSvg)
299+
300+
spacedViewSvg = graphFigure(
301+
tree;
302+
layout = (rowSpacing = 80, columnSpacing = (90, 210)),
303+
view = (variables = [:x1], hops = 2)
304+
)
305+
@test startswith(spacedViewSvg, "<svg")
299306
end
300307

301308
@testset "File output" begin

0 commit comments

Comments
 (0)