Fix edge padding
This commit is contained in:
parent
1c3a73207f
commit
4c41794ea2
3 changed files with 8 additions and 6 deletions
|
|
@ -20,6 +20,8 @@ const SPAN_DEPTH_GROWTH_FACTOR = 8.
|
||||||
// when a span has a single messages
|
// when a span has a single messages
|
||||||
const MIN_SPAN_HEIGHT = 80.
|
const MIN_SPAN_HEIGHT = 80.
|
||||||
|
|
||||||
|
const SPAN_MESSAGE_PAD = 16.
|
||||||
|
|
||||||
const LIFELINE_STROKE_WIDTH int = 2
|
const LIFELINE_STROKE_WIDTH int = 2
|
||||||
|
|
||||||
const LIFELINE_STROKE_DASH int = 8
|
const LIFELINE_STROKE_DASH int = 8
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,7 @@ func TestSpansSequenceDiagram(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Y diff of the 2 first edges
|
// Y diff of the 2 first edges
|
||||||
expectedHeight := g.Edges[1].Route[0].Y - g.Edges[0].Route[0].Y
|
expectedHeight := g.Edges[1].Route[0].Y - g.Edges[0].Route[0].Y + (2 * SPAN_MESSAGE_PAD)
|
||||||
if a_t1.Height != expectedHeight {
|
if a_t1.Height != expectedHeight {
|
||||||
t.Fatalf("expected a.t1 height to be %.5f, got %.5f", expectedHeight, a_t1.Height)
|
t.Fatalf("expected a.t1 height to be %.5f, got %.5f", expectedHeight, a_t1.Height)
|
||||||
}
|
}
|
||||||
|
|
@ -268,7 +268,7 @@ func TestSpansSequenceDiagram(t *testing.T) {
|
||||||
if a_t1.TopLeft.Y != b_t1.TopLeft.Y {
|
if a_t1.TopLeft.Y != b_t1.TopLeft.Y {
|
||||||
t.Fatal("expected a.t1 and b.t1 to be placed at the same Y")
|
t.Fatal("expected a.t1 and b.t1 to be placed at the same Y")
|
||||||
}
|
}
|
||||||
if a_t1.TopLeft.Y != g.Edges[0].Route[0].Y {
|
if a_t1.TopLeft.Y-SPAN_MESSAGE_PAD != g.Edges[0].Route[0].Y {
|
||||||
t.Fatal("expected a.t1 to be placed at the same Y of the first message")
|
t.Fatal("expected a.t1 to be placed at the same Y of the first message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -210,12 +210,12 @@ func (sd *sequenceDiagram) placeSpans() {
|
||||||
|
|
||||||
// if it is the same as the child top left, add some padding
|
// if it is the same as the child top left, add some padding
|
||||||
minY := math.Min(minMessageY, minChildY)
|
minY := math.Min(minMessageY, minChildY)
|
||||||
if minY == minChildY {
|
if minY == minChildY || minY == minMessageY {
|
||||||
minY -= SPAN_DEPTH_GROWTH_FACTOR
|
minY -= SPAN_MESSAGE_PAD
|
||||||
}
|
}
|
||||||
maxY := math.Max(maxMessageY, maxChildY)
|
maxY := math.Max(maxMessageY, maxChildY)
|
||||||
if maxY == maxChildY {
|
if maxY == maxChildY || maxY == maxMessageY {
|
||||||
maxY += SPAN_DEPTH_GROWTH_FACTOR
|
maxY += SPAN_MESSAGE_PAD
|
||||||
}
|
}
|
||||||
|
|
||||||
height := math.Max(maxY-minY, MIN_SPAN_HEIGHT)
|
height := math.Max(maxY-minY, MIN_SPAN_HEIGHT)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue