Merge pull request #397 from ejulio-ts/gh-391-spans
sequence_diagram: Fix span size
This commit is contained in:
commit
cb414e5382
7 changed files with 506 additions and 7 deletions
|
|
@ -3,3 +3,5 @@
|
||||||
#### Improvements 🧹
|
#### Improvements 🧹
|
||||||
|
|
||||||
#### Bugfixes ⛑️
|
#### Bugfixes ⛑️
|
||||||
|
|
||||||
|
- Fixed sequence diagram span size for self-edges [#397](https://github.com/terrastruct/d2/pull/397)
|
||||||
|
|
@ -402,8 +402,7 @@ func (sd *sequenceDiagram) placeSpans() {
|
||||||
// finds the position if there are messages to this span
|
// finds the position if there are messages to this span
|
||||||
minMessageY := math.Inf(1)
|
minMessageY := math.Inf(1)
|
||||||
if firstMessage, exists := sd.firstMessage[span]; exists {
|
if firstMessage, exists := sd.firstMessage[span]; exists {
|
||||||
// needs to check Src/Dst because of self-edges or edges to/from descendants
|
if firstMessage.Src == firstMessage.Dst || span == firstMessage.Src {
|
||||||
if span == firstMessage.Src {
|
|
||||||
minMessageY = firstMessage.Route[0].Y
|
minMessageY = firstMessage.Route[0].Y
|
||||||
} else {
|
} else {
|
||||||
minMessageY = firstMessage.Route[len(firstMessage.Route)-1].Y
|
minMessageY = firstMessage.Route[len(firstMessage.Route)-1].Y
|
||||||
|
|
@ -411,10 +410,10 @@ func (sd *sequenceDiagram) placeSpans() {
|
||||||
}
|
}
|
||||||
maxMessageY := math.Inf(-1)
|
maxMessageY := math.Inf(-1)
|
||||||
if lastMessage, exists := sd.lastMessage[span]; exists {
|
if lastMessage, exists := sd.lastMessage[span]; exists {
|
||||||
if span == lastMessage.Src {
|
if lastMessage.Src == lastMessage.Dst || span == lastMessage.Dst {
|
||||||
maxMessageY = lastMessage.Route[0].Y
|
|
||||||
} else {
|
|
||||||
maxMessageY = lastMessage.Route[len(lastMessage.Route)-1].Y
|
maxMessageY = lastMessage.Route[len(lastMessage.Route)-1].Y
|
||||||
|
} else {
|
||||||
|
maxMessageY = lastMessage.Route[0].Y
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,12 @@ B: goodbye {
|
||||||
shape: sequence_diagram
|
shape: sequence_diagram
|
||||||
}
|
}
|
||||||
|
|
||||||
A->B
|
A->B`,
|
||||||
`,
|
}, {
|
||||||
|
name: "sequence_diagram_span_cover",
|
||||||
|
script: `shape: sequence_diagram
|
||||||
|
b.1 -> b.1
|
||||||
|
b.1 -> b.1`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
219
e2etests/testdata/regression/sequence_diagram_span_cover/dagre/board.exp.json
generated
vendored
Normal file
219
e2etests/testdata/regression/sequence_diagram_span_cover/dagre/board.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,219 @@
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"shapes": [
|
||||||
|
{
|
||||||
|
"id": "b",
|
||||||
|
"type": "",
|
||||||
|
"pos": {
|
||||||
|
"x": 24,
|
||||||
|
"y": 74
|
||||||
|
},
|
||||||
|
"width": 150,
|
||||||
|
"height": 126,
|
||||||
|
"opacity": 1,
|
||||||
|
"strokeDash": 0,
|
||||||
|
"strokeWidth": 2,
|
||||||
|
"borderRadius": 0,
|
||||||
|
"fill": "#EDF0FD",
|
||||||
|
"stroke": "#0D32B2",
|
||||||
|
"shadow": false,
|
||||||
|
"3d": false,
|
||||||
|
"multiple": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"link": "",
|
||||||
|
"icon": null,
|
||||||
|
"iconPosition": "",
|
||||||
|
"blend": false,
|
||||||
|
"fields": null,
|
||||||
|
"methods": null,
|
||||||
|
"columns": null,
|
||||||
|
"label": "b",
|
||||||
|
"fontSize": 16,
|
||||||
|
"fontFamily": "DEFAULT",
|
||||||
|
"language": "",
|
||||||
|
"color": "#0A0F25",
|
||||||
|
"italic": false,
|
||||||
|
"bold": false,
|
||||||
|
"underline": false,
|
||||||
|
"labelWidth": 13,
|
||||||
|
"labelHeight": 26,
|
||||||
|
"labelPosition": "INSIDE_MIDDLE_CENTER",
|
||||||
|
"zIndex": 0,
|
||||||
|
"level": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "b.1",
|
||||||
|
"type": "rectangle",
|
||||||
|
"pos": {
|
||||||
|
"x": 93,
|
||||||
|
"y": 314
|
||||||
|
},
|
||||||
|
"width": 12,
|
||||||
|
"height": 242,
|
||||||
|
"opacity": 1,
|
||||||
|
"strokeDash": 0,
|
||||||
|
"strokeWidth": 2,
|
||||||
|
"borderRadius": 0,
|
||||||
|
"fill": "#E3E9FD",
|
||||||
|
"stroke": "#0D32B2",
|
||||||
|
"shadow": false,
|
||||||
|
"3d": false,
|
||||||
|
"multiple": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"link": "",
|
||||||
|
"icon": null,
|
||||||
|
"iconPosition": "",
|
||||||
|
"blend": false,
|
||||||
|
"fields": null,
|
||||||
|
"methods": null,
|
||||||
|
"columns": null,
|
||||||
|
"label": "",
|
||||||
|
"fontSize": 16,
|
||||||
|
"fontFamily": "DEFAULT",
|
||||||
|
"language": "",
|
||||||
|
"color": "#0A0F25",
|
||||||
|
"italic": false,
|
||||||
|
"bold": false,
|
||||||
|
"underline": false,
|
||||||
|
"labelWidth": 12,
|
||||||
|
"labelHeight": 26,
|
||||||
|
"zIndex": 2,
|
||||||
|
"level": 2
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"connections": [
|
||||||
|
{
|
||||||
|
"id": "b.(1 -> 1)[0]",
|
||||||
|
"src": "b.1",
|
||||||
|
"srcArrow": "none",
|
||||||
|
"srcLabel": "",
|
||||||
|
"dst": "b.1",
|
||||||
|
"dstArrow": "triangle",
|
||||||
|
"dstLabel": "",
|
||||||
|
"opacity": 1,
|
||||||
|
"strokeDash": 0,
|
||||||
|
"strokeWidth": 2,
|
||||||
|
"stroke": "#0D32B2",
|
||||||
|
"label": "",
|
||||||
|
"fontSize": 16,
|
||||||
|
"fontFamily": "DEFAULT",
|
||||||
|
"language": "",
|
||||||
|
"color": "#676C7E",
|
||||||
|
"italic": true,
|
||||||
|
"bold": false,
|
||||||
|
"underline": false,
|
||||||
|
"labelWidth": 0,
|
||||||
|
"labelHeight": 0,
|
||||||
|
"labelPosition": "",
|
||||||
|
"labelPercentage": 0,
|
||||||
|
"route": [
|
||||||
|
{
|
||||||
|
"x": 105,
|
||||||
|
"y": 330
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 199,
|
||||||
|
"y": 330
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 199,
|
||||||
|
"y": 410
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 105,
|
||||||
|
"y": 410
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"animated": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"icon": null,
|
||||||
|
"zIndex": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "b.(1 -> 1)[1]",
|
||||||
|
"src": "b.1",
|
||||||
|
"srcArrow": "none",
|
||||||
|
"srcLabel": "",
|
||||||
|
"dst": "b.1",
|
||||||
|
"dstArrow": "triangle",
|
||||||
|
"dstLabel": "",
|
||||||
|
"opacity": 1,
|
||||||
|
"strokeDash": 0,
|
||||||
|
"strokeWidth": 2,
|
||||||
|
"stroke": "#0D32B2",
|
||||||
|
"label": "",
|
||||||
|
"fontSize": 16,
|
||||||
|
"fontFamily": "DEFAULT",
|
||||||
|
"language": "",
|
||||||
|
"color": "#676C7E",
|
||||||
|
"italic": true,
|
||||||
|
"bold": false,
|
||||||
|
"underline": false,
|
||||||
|
"labelWidth": 0,
|
||||||
|
"labelHeight": 0,
|
||||||
|
"labelPosition": "",
|
||||||
|
"labelPercentage": 0,
|
||||||
|
"route": [
|
||||||
|
{
|
||||||
|
"x": 105,
|
||||||
|
"y": 460
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 199,
|
||||||
|
"y": 460
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 199,
|
||||||
|
"y": 540
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 105,
|
||||||
|
"y": 540
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"animated": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"icon": null,
|
||||||
|
"zIndex": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "(b -- )[0]",
|
||||||
|
"src": "b",
|
||||||
|
"srcArrow": "none",
|
||||||
|
"srcLabel": "",
|
||||||
|
"dst": "b-lifeline-end-668380428",
|
||||||
|
"dstArrow": "none",
|
||||||
|
"dstLabel": "",
|
||||||
|
"opacity": 1,
|
||||||
|
"strokeDash": 6,
|
||||||
|
"strokeWidth": 2,
|
||||||
|
"stroke": "#0D32B2",
|
||||||
|
"label": "",
|
||||||
|
"fontSize": 16,
|
||||||
|
"fontFamily": "DEFAULT",
|
||||||
|
"language": "",
|
||||||
|
"color": "#676C7E",
|
||||||
|
"italic": true,
|
||||||
|
"bold": false,
|
||||||
|
"underline": false,
|
||||||
|
"labelWidth": 0,
|
||||||
|
"labelHeight": 0,
|
||||||
|
"labelPosition": "",
|
||||||
|
"labelPercentage": 0,
|
||||||
|
"route": [
|
||||||
|
{
|
||||||
|
"x": 99,
|
||||||
|
"y": 200
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 99,
|
||||||
|
"y": 670
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"animated": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"icon": null,
|
||||||
|
"zIndex": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
28
e2etests/testdata/regression/sequence_diagram_span_cover/dagre/sketch.exp.svg
vendored
Normal file
28
e2etests/testdata/regression/sequence_diagram_span_cover/dagre/sketch.exp.svg
vendored
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 326 KiB |
219
e2etests/testdata/regression/sequence_diagram_span_cover/elk/board.exp.json
generated
vendored
Normal file
219
e2etests/testdata/regression/sequence_diagram_span_cover/elk/board.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,219 @@
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"shapes": [
|
||||||
|
{
|
||||||
|
"id": "b",
|
||||||
|
"type": "",
|
||||||
|
"pos": {
|
||||||
|
"x": 24,
|
||||||
|
"y": 74
|
||||||
|
},
|
||||||
|
"width": 150,
|
||||||
|
"height": 126,
|
||||||
|
"opacity": 1,
|
||||||
|
"strokeDash": 0,
|
||||||
|
"strokeWidth": 2,
|
||||||
|
"borderRadius": 0,
|
||||||
|
"fill": "#EDF0FD",
|
||||||
|
"stroke": "#0D32B2",
|
||||||
|
"shadow": false,
|
||||||
|
"3d": false,
|
||||||
|
"multiple": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"link": "",
|
||||||
|
"icon": null,
|
||||||
|
"iconPosition": "",
|
||||||
|
"blend": false,
|
||||||
|
"fields": null,
|
||||||
|
"methods": null,
|
||||||
|
"columns": null,
|
||||||
|
"label": "b",
|
||||||
|
"fontSize": 16,
|
||||||
|
"fontFamily": "DEFAULT",
|
||||||
|
"language": "",
|
||||||
|
"color": "#0A0F25",
|
||||||
|
"italic": false,
|
||||||
|
"bold": false,
|
||||||
|
"underline": false,
|
||||||
|
"labelWidth": 13,
|
||||||
|
"labelHeight": 26,
|
||||||
|
"labelPosition": "INSIDE_MIDDLE_CENTER",
|
||||||
|
"zIndex": 0,
|
||||||
|
"level": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "b.1",
|
||||||
|
"type": "rectangle",
|
||||||
|
"pos": {
|
||||||
|
"x": 93,
|
||||||
|
"y": 314
|
||||||
|
},
|
||||||
|
"width": 12,
|
||||||
|
"height": 242,
|
||||||
|
"opacity": 1,
|
||||||
|
"strokeDash": 0,
|
||||||
|
"strokeWidth": 2,
|
||||||
|
"borderRadius": 0,
|
||||||
|
"fill": "#E3E9FD",
|
||||||
|
"stroke": "#0D32B2",
|
||||||
|
"shadow": false,
|
||||||
|
"3d": false,
|
||||||
|
"multiple": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"link": "",
|
||||||
|
"icon": null,
|
||||||
|
"iconPosition": "",
|
||||||
|
"blend": false,
|
||||||
|
"fields": null,
|
||||||
|
"methods": null,
|
||||||
|
"columns": null,
|
||||||
|
"label": "",
|
||||||
|
"fontSize": 16,
|
||||||
|
"fontFamily": "DEFAULT",
|
||||||
|
"language": "",
|
||||||
|
"color": "#0A0F25",
|
||||||
|
"italic": false,
|
||||||
|
"bold": false,
|
||||||
|
"underline": false,
|
||||||
|
"labelWidth": 12,
|
||||||
|
"labelHeight": 26,
|
||||||
|
"zIndex": 2,
|
||||||
|
"level": 2
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"connections": [
|
||||||
|
{
|
||||||
|
"id": "b.(1 -> 1)[0]",
|
||||||
|
"src": "b.1",
|
||||||
|
"srcArrow": "none",
|
||||||
|
"srcLabel": "",
|
||||||
|
"dst": "b.1",
|
||||||
|
"dstArrow": "triangle",
|
||||||
|
"dstLabel": "",
|
||||||
|
"opacity": 1,
|
||||||
|
"strokeDash": 0,
|
||||||
|
"strokeWidth": 2,
|
||||||
|
"stroke": "#0D32B2",
|
||||||
|
"label": "",
|
||||||
|
"fontSize": 16,
|
||||||
|
"fontFamily": "DEFAULT",
|
||||||
|
"language": "",
|
||||||
|
"color": "#676C7E",
|
||||||
|
"italic": true,
|
||||||
|
"bold": false,
|
||||||
|
"underline": false,
|
||||||
|
"labelWidth": 0,
|
||||||
|
"labelHeight": 0,
|
||||||
|
"labelPosition": "",
|
||||||
|
"labelPercentage": 0,
|
||||||
|
"route": [
|
||||||
|
{
|
||||||
|
"x": 105,
|
||||||
|
"y": 330
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 199,
|
||||||
|
"y": 330
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 199,
|
||||||
|
"y": 410
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 105,
|
||||||
|
"y": 410
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"animated": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"icon": null,
|
||||||
|
"zIndex": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "b.(1 -> 1)[1]",
|
||||||
|
"src": "b.1",
|
||||||
|
"srcArrow": "none",
|
||||||
|
"srcLabel": "",
|
||||||
|
"dst": "b.1",
|
||||||
|
"dstArrow": "triangle",
|
||||||
|
"dstLabel": "",
|
||||||
|
"opacity": 1,
|
||||||
|
"strokeDash": 0,
|
||||||
|
"strokeWidth": 2,
|
||||||
|
"stroke": "#0D32B2",
|
||||||
|
"label": "",
|
||||||
|
"fontSize": 16,
|
||||||
|
"fontFamily": "DEFAULT",
|
||||||
|
"language": "",
|
||||||
|
"color": "#676C7E",
|
||||||
|
"italic": true,
|
||||||
|
"bold": false,
|
||||||
|
"underline": false,
|
||||||
|
"labelWidth": 0,
|
||||||
|
"labelHeight": 0,
|
||||||
|
"labelPosition": "",
|
||||||
|
"labelPercentage": 0,
|
||||||
|
"route": [
|
||||||
|
{
|
||||||
|
"x": 105,
|
||||||
|
"y": 460
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 199,
|
||||||
|
"y": 460
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 199,
|
||||||
|
"y": 540
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 105,
|
||||||
|
"y": 540
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"animated": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"icon": null,
|
||||||
|
"zIndex": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "(b -- )[0]",
|
||||||
|
"src": "b",
|
||||||
|
"srcArrow": "none",
|
||||||
|
"srcLabel": "",
|
||||||
|
"dst": "b-lifeline-end-668380428",
|
||||||
|
"dstArrow": "none",
|
||||||
|
"dstLabel": "",
|
||||||
|
"opacity": 1,
|
||||||
|
"strokeDash": 6,
|
||||||
|
"strokeWidth": 2,
|
||||||
|
"stroke": "#0D32B2",
|
||||||
|
"label": "",
|
||||||
|
"fontSize": 16,
|
||||||
|
"fontFamily": "DEFAULT",
|
||||||
|
"language": "",
|
||||||
|
"color": "#676C7E",
|
||||||
|
"italic": true,
|
||||||
|
"bold": false,
|
||||||
|
"underline": false,
|
||||||
|
"labelWidth": 0,
|
||||||
|
"labelHeight": 0,
|
||||||
|
"labelPosition": "",
|
||||||
|
"labelPercentage": 0,
|
||||||
|
"route": [
|
||||||
|
{
|
||||||
|
"x": 99,
|
||||||
|
"y": 200
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 99,
|
||||||
|
"y": 670
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"animated": false,
|
||||||
|
"tooltip": "",
|
||||||
|
"icon": null,
|
||||||
|
"zIndex": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
28
e2etests/testdata/regression/sequence_diagram_span_cover/elk/sketch.exp.svg
vendored
Normal file
28
e2etests/testdata/regression/sequence_diagram_span_cover/elk/sketch.exp.svg
vendored
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 326 KiB |
Loading…
Reference in a new issue