Fix span rendering order

This commit is contained in:
Júlio César Batista 2022-11-30 13:41:20 -08:00
parent 4c6dd8d9f8
commit 641c809464
No known key found for this signature in database
GPG key ID: 10C4B861BF314878
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 {