change spans base size and growth factor
This commit is contained in:
parent
2fdc1e7c76
commit
641850cf5e
3 changed files with 8 additions and 8 deletions
|
|
@ -12,10 +12,10 @@ const MIN_ACTOR_DISTANCE = 200.
|
|||
const MIN_MESSAGE_DISTANCE = 100.
|
||||
|
||||
// default size
|
||||
const SPAN_WIDTH = 20.
|
||||
const SPAN_BASE_WIDTH = 12.
|
||||
|
||||
// as the spans start getting nested, their size grows
|
||||
const SPAN_DEPTH_GROW_FACTOR = 10.
|
||||
const SPAN_DEPTH_GROWTH_FACTOR = 8.
|
||||
|
||||
// when a span has a single messages
|
||||
const MIN_SPAN_HEIGHT = MIN_MESSAGE_DISTANCE / 2.
|
||||
const MIN_SPAN_HEIGHT = 80.
|
||||
|
|
|
|||
|
|
@ -251,8 +251,8 @@ func TestSpansSequenceDiagram(t *testing.T) {
|
|||
t.Fatalf("expected a.t1 height to be %.5f, got %.5f", expectedHeight, a_t1.Height)
|
||||
}
|
||||
|
||||
if a_t1.Width != SPAN_WIDTH {
|
||||
t.Fatalf("expected span width to be %.5f, got %.5f", SPAN_WIDTH, a_t1.Width)
|
||||
if a_t1.Width != SPAN_BASE_WIDTH {
|
||||
t.Fatalf("expected span width to be %.5f, got %.5f", SPAN_BASE_WIDTH, a_t1.Width)
|
||||
}
|
||||
|
||||
// check positions
|
||||
|
|
|
|||
|
|
@ -201,16 +201,16 @@ func (sd *sequenceDiagram) placeSpans() {
|
|||
// if it is the same as the child top left, add some padding
|
||||
minY := math.Min(minMessageY, minChildY)
|
||||
if minY == minChildY {
|
||||
minY -= SPAN_DEPTH_GROW_FACTOR
|
||||
minY -= SPAN_DEPTH_GROWTH_FACTOR
|
||||
}
|
||||
maxY := math.Max(maxMessageY, maxChildY)
|
||||
if maxY == maxChildY {
|
||||
maxY += SPAN_DEPTH_GROW_FACTOR
|
||||
maxY += SPAN_DEPTH_GROWTH_FACTOR
|
||||
}
|
||||
|
||||
height := math.Max(maxY-minY, MIN_SPAN_HEIGHT)
|
||||
// -2 because the actors count as level 1 making the first level span getting 2*SPAN_DEPTH_GROW_FACTOR
|
||||
width := SPAN_WIDTH + (float64(span.Level()-2) * SPAN_DEPTH_GROW_FACTOR)
|
||||
width := SPAN_BASE_WIDTH + (float64(span.Level()-2) * SPAN_DEPTH_GROWTH_FACTOR)
|
||||
x := rankToX[sd.objectRank[span]] - (width / 2.)
|
||||
span.Box = geo.NewBox(geo.NewPoint(x, minY), width, height)
|
||||
span.ZIndex = 1
|
||||
|
|
|
|||
Loading…
Reference in a new issue