Merge pull request #287 from ejulio-ts/fix-sequence-diagram-zindex

Fix span render
This commit is contained in:
ejulio-ts 2022-11-30 13:57:44 -08:00 committed by GitHub
commit 20fd100431
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View file

@ -218,6 +218,7 @@ func (sd *sequenceDiagram) placeSpans() {
width := SPAN_WIDTH + (float64(span.Level()-2) * SPAN_DEPTH_GROW_FACTOR)
x := rankToX[sd.objectRank[span]] - (width / 2.)
span.Box = geo.NewBox(geo.NewPoint(x, minY), width, height)
span.ZIndex = 1
}
}

View file

@ -208,6 +208,12 @@ func TestSpansSequenceDiagram(t *testing.T) {
t.Fatalf("expected a.t1 and b.t1 to have the same height, got %.5f and %.5f", a_t1.Height, b_t1.Height)
}
for _, span := range []*d2graph.Object{a_t1, a_t2, b_t1} {
if span.ZIndex != 1 {
t.Fatalf("expected span ZIndex=1, got %d", span.ZIndex)
}
}
// Y diff of the 2 first edges
expectedHeight := g.Edges[1].Route[0].Y - g.Edges[0].Route[0].Y + (2 * SPAN_EDGE_PAD)
if a_t1.Height != expectedHeight {