Skip to content

Commit 0974647

Browse files
authored
Merge pull request #109 from jongalloway/copilot/fix-chevron-diagram-shape
Fix chevron diagram: replace left-protruding hexagon with inward V-notch and overlap layout
2 parents 9233418 + f866e81 commit 0974647

4 files changed

Lines changed: 20 additions & 14 deletions

File tree

src/DiagramForge/Layout/DefaultLayoutEngine.Chevron.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ private static void LayoutChevronDiagram(
3737
{
3838
var node = orderedNodes[index];
3939

40-
// Zero gap: bounding boxes abut so the tip of stage N meets the notch of stage N+1.
41-
node.X = pad + index * nodeW;
40+
// Overlap layout: each stage overlaps the previous by tipDepth so the right tip of
41+
// stage N aligns exactly with the inward notch of stage N+1.
42+
node.X = pad + index * (nodeW - tipDepth);
4243
node.Y = pad + titleOffset;
4344
node.Width = nodeW;
4445
node.Height = nodeH;

src/DiagramForge/Rendering/SvgNodeWriter.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,12 @@ private static void AppendChevronNode(StringBuilder sb, Node node, string fill,
287287
double midY = h / 2;
288288

289289
// First chevron: flat left edge, pointed right – 5 points (pentagon).
290-
// Subsequent chevrons: notched left edge matching previous arrow point, pointed right – 6 points (hexagon).
290+
// Subsequent chevrons: inward V-notch on left matching previous arrow tip, pointed right – 6 points (hexagon).
291+
// The notch vertex at (tipDepth, midY) aligns with the tip of the preceding stage because
292+
// the layout overlaps bounding boxes by tipDepth.
291293
string points = index == 0
292294
? $"0,0 {SvgRenderSupport.F(w - tipDepth)},0 {SvgRenderSupport.F(w)},{SvgRenderSupport.F(midY)} {SvgRenderSupport.F(w - tipDepth)},{SvgRenderSupport.F(h)} 0,{SvgRenderSupport.F(h)}"
293-
: $"0,{SvgRenderSupport.F(midY)} {SvgRenderSupport.F(tipDepth)},0 {SvgRenderSupport.F(w - tipDepth)},0 {SvgRenderSupport.F(w)},{SvgRenderSupport.F(midY)} {SvgRenderSupport.F(w - tipDepth)},{SvgRenderSupport.F(h)} {SvgRenderSupport.F(tipDepth)},{SvgRenderSupport.F(h)}";
295+
: $"0,0 {SvgRenderSupport.F(w - tipDepth)},0 {SvgRenderSupport.F(w)},{SvgRenderSupport.F(midY)} {SvgRenderSupport.F(w - tipDepth)},{SvgRenderSupport.F(h)} 0,{SvgRenderSupport.F(h)} {SvgRenderSupport.F(tipDepth)},{SvgRenderSupport.F(midY)}";
294296

295297
sb.AppendLine($""" <polygon points="{points}" fill="{fill}" stroke="{stroke}" stroke-width="{SvgRenderSupport.F(theme.StrokeWidth)}"{fillOpacityAttribute}{shadowAttribute}/>""");
296298
}

tests/DiagramForge.E2ETests/Fixtures/conceptual-chevrons.expected.svg

Lines changed: 8 additions & 8 deletions
Loading

tests/DiagramForge.Tests/Layout/DefaultLayoutEngineTests.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,8 +1362,11 @@ public void Layout_Chevrons_AdjacentNodesAreImmediatelyAbutted()
13621362
var first = diagram.Nodes["node_0"];
13631363
var second = diagram.Nodes["node_1"];
13641364

1365-
// Zero gap: the tip of stage 0 meets the notch of stage 1 at their shared boundary.
1366-
Assert.Equal(first.X + first.Width, second.X, precision: 6);
1365+
// Overlap layout: the right tip of stage 0 aligns with the inward notch of stage 1.
1366+
// second.X is inset by tipDepth so the tip (first.X + first.Width) coincides with
1367+
// the notch vertex (second.X + tipDepth).
1368+
double tipDepth = (double)second.Metadata["conceptual:chevronTipDepth"];
1369+
Assert.Equal(first.X + first.Width, second.X + tipDepth, precision: 6);
13671370
}
13681371

13691372
[Fact]

0 commit comments

Comments
 (0)