Merge pull request #374 from alixander/fix-sequence-distance

fix sequence distancing
This commit is contained in:
Alexander Wang 2022-12-05 22:47:06 -08:00 committed by GitHub
commit 177e132c21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 650 additions and 79 deletions

View file

@ -157,7 +157,7 @@ func newSequenceDiagram(objects []*d2graph.Object, messages []*d2graph.Edge) *se
if rankDiff != 0 {
// rankDiff = 0 for self edges
distributedLabelWidth := float64(message.LabelDimensions.Width) / rankDiff
for rank := sd.objectRank[message.Src]; rank <= sd.objectRank[message.Dst]-1; rank++ {
for rank := go2.IntMin(sd.objectRank[message.Src], sd.objectRank[message.Dst]); rank <= go2.IntMax(sd.objectRank[message.Src], sd.objectRank[message.Dst])-1; rank++ {
sd.actorXStep[rank] = math.Max(sd.actorXStep[rank], distributedLabelWidth+HORIZONTAL_PAD)
}
}

View file

@ -1476,6 +1476,13 @@ a -> b
b.note: "a note here to remember that padding must consider notes too"
a.note: "just\na\nlong\nnote\nhere"`,
},
{
name: "sequence_diagram_distance",
script: `shape: sequence_diagram
alice -> bob: what does it mean to be well-adjusted
bob -> alice: The ability to play bridge or golf as if they were games
`,
},
}
runa(t, tcs)

View file

@ -0,0 +1,243 @@
{
"name": "",
"shapes": [
{
"id": "alice",
"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": "alice",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"italic": false,
"bold": false,
"underline": false,
"labelWidth": 37,
"labelHeight": 26,
"labelPosition": "INSIDE_MIDDLE_CENTER",
"zIndex": 0,
"level": 1
},
{
"id": "bob",
"type": "",
"pos": {
"x": 426,
"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": "bob",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"italic": false,
"bold": false,
"underline": false,
"labelWidth": 31,
"labelHeight": 26,
"labelPosition": "INSIDE_MIDDLE_CENTER",
"zIndex": 0,
"level": 1
}
],
"connections": [
{
"id": "(alice -> bob)[0]",
"src": "alice",
"srcArrow": "none",
"srcLabel": "",
"dst": "bob",
"dstArrow": "triangle",
"dstLabel": "",
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"stroke": "#0D32B2",
"label": "what does it mean to be well-adjusted",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#676C7E",
"italic": true,
"bold": false,
"underline": false,
"labelWidth": 249,
"labelHeight": 21,
"labelPosition": "INSIDE_MIDDLE_CENTER",
"labelPercentage": 0,
"route": [
{
"x": 99,
"y": 330
},
{
"x": 501,
"y": 330
}
],
"animated": false,
"tooltip": "",
"icon": null,
"zIndex": 4
},
{
"id": "(bob -> alice)[0]",
"src": "bob",
"srcArrow": "none",
"srcLabel": "",
"dst": "alice",
"dstArrow": "triangle",
"dstLabel": "",
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"stroke": "#0D32B2",
"label": "The ability to play bridge or golf as if they were games",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#676C7E",
"italic": true,
"bold": false,
"underline": false,
"labelWidth": 352,
"labelHeight": 21,
"labelPosition": "INSIDE_MIDDLE_CENTER",
"labelPercentage": 0,
"route": [
{
"x": 501,
"y": 460
},
{
"x": 99,
"y": 460
}
],
"animated": false,
"tooltip": "",
"icon": null,
"zIndex": 4
},
{
"id": "(alice -- )[0]",
"src": "alice",
"srcArrow": "none",
"srcLabel": "",
"dst": "alice-lifeline-end-3851299086",
"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": 590
}
],
"animated": false,
"tooltip": "",
"icon": null,
"zIndex": 1
},
{
"id": "(bob -- )[0]",
"src": "bob",
"srcArrow": "none",
"srcLabel": "",
"dst": "bob-lifeline-end-3036726343",
"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": 501,
"y": 200
},
{
"x": 501,
"y": 590
}
],
"animated": false,
"tooltip": "",
"icon": null,
"zIndex": 1
}
]
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 469 KiB

View file

@ -0,0 +1,243 @@
{
"name": "",
"shapes": [
{
"id": "alice",
"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": "alice",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"italic": false,
"bold": false,
"underline": false,
"labelWidth": 37,
"labelHeight": 26,
"labelPosition": "INSIDE_MIDDLE_CENTER",
"zIndex": 0,
"level": 1
},
{
"id": "bob",
"type": "",
"pos": {
"x": 426,
"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": "bob",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"italic": false,
"bold": false,
"underline": false,
"labelWidth": 31,
"labelHeight": 26,
"labelPosition": "INSIDE_MIDDLE_CENTER",
"zIndex": 0,
"level": 1
}
],
"connections": [
{
"id": "(alice -> bob)[0]",
"src": "alice",
"srcArrow": "none",
"srcLabel": "",
"dst": "bob",
"dstArrow": "triangle",
"dstLabel": "",
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"stroke": "#0D32B2",
"label": "what does it mean to be well-adjusted",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#676C7E",
"italic": true,
"bold": false,
"underline": false,
"labelWidth": 249,
"labelHeight": 21,
"labelPosition": "INSIDE_MIDDLE_CENTER",
"labelPercentage": 0,
"route": [
{
"x": 99,
"y": 330
},
{
"x": 501,
"y": 330
}
],
"animated": false,
"tooltip": "",
"icon": null,
"zIndex": 4
},
{
"id": "(bob -> alice)[0]",
"src": "bob",
"srcArrow": "none",
"srcLabel": "",
"dst": "alice",
"dstArrow": "triangle",
"dstLabel": "",
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"stroke": "#0D32B2",
"label": "The ability to play bridge or golf as if they were games",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#676C7E",
"italic": true,
"bold": false,
"underline": false,
"labelWidth": 352,
"labelHeight": 21,
"labelPosition": "INSIDE_MIDDLE_CENTER",
"labelPercentage": 0,
"route": [
{
"x": 501,
"y": 460
},
{
"x": 99,
"y": 460
}
],
"animated": false,
"tooltip": "",
"icon": null,
"zIndex": 4
},
{
"id": "(alice -- )[0]",
"src": "alice",
"srcArrow": "none",
"srcLabel": "",
"dst": "alice-lifeline-end-3851299086",
"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": 590
}
],
"animated": false,
"tooltip": "",
"icon": null,
"zIndex": 1
},
{
"id": "(bob -- )[0]",
"src": "bob",
"srcArrow": "none",
"srcLabel": "",
"dst": "bob-lifeline-end-3036726343",
"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": 501,
"y": 200
},
{
"x": 501,
"y": 590
}
],
"animated": false,
"tooltip": "",
"icon": null,
"zIndex": 1
}
]
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 469 KiB

View file

@ -45,7 +45,7 @@
"id": "bob",
"type": "person",
"pos": {
"x": 288,
"x": 297,
"y": 165
},
"width": 150,
@ -85,7 +85,7 @@
"id": "db",
"type": "cylinder",
"pos": {
"x": 605,
"x": 614,
"y": 186
},
"width": 150,
@ -125,7 +125,7 @@
"id": "queue",
"type": "queue",
"pos": {
"x": 922,
"x": 931,
"y": 186
},
"width": 150,
@ -165,7 +165,7 @@
"id": "service",
"type": "",
"pos": {
"x": 1216,
"x": 1225,
"y": 74
},
"width": 197,
@ -233,7 +233,7 @@
"y": 442
},
{
"x": 363,
"x": 372,
"y": 442
}
],
@ -268,11 +268,11 @@
"labelPercentage": 0,
"route": [
{
"x": 363,
"x": 372,
"y": 572
},
{
"x": 1314.5,
"x": 1323.5,
"y": 572
}
],
@ -307,11 +307,11 @@
"labelPercentage": 0,
"route": [
{
"x": 1314.5,
"x": 1323.5,
"y": 702
},
{
"x": 680,
"x": 689,
"y": 702
}
],
@ -346,11 +346,11 @@
"labelPercentage": 0,
"route": [
{
"x": 680,
"x": 689,
"y": 832
},
{
"x": 1314.5,
"x": 1323.5,
"y": 832
}
],
@ -385,11 +385,11 @@
"labelPercentage": 0,
"route": [
{
"x": 1314.5,
"x": 1323.5,
"y": 962
},
{
"x": 363,
"x": 372,
"y": 962
}
],
@ -424,7 +424,7 @@
"labelPercentage": 0,
"route": [
{
"x": 363,
"x": 372,
"y": 1092
},
{
@ -467,7 +467,7 @@
"y": 1222
},
{
"x": 363,
"x": 372,
"y": 1222
}
],
@ -502,11 +502,11 @@
"labelPercentage": 0,
"route": [
{
"x": 363,
"x": 372,
"y": 1352
},
{
"x": 997,
"x": 1006,
"y": 1352
}
],
@ -541,11 +541,11 @@
"labelPercentage": 0,
"route": [
{
"x": 997,
"x": 1006,
"y": 1482
},
{
"x": 363,
"x": 372,
"y": 1482
}
],
@ -580,7 +580,7 @@
"labelPercentage": 0,
"route": [
{
"x": 363,
"x": 372,
"y": 1612
},
{
@ -658,11 +658,11 @@
"labelPercentage": 0,
"route": [
{
"x": 363,
"x": 372,
"y": 317
},
{
"x": 363,
"x": 372,
"y": 1742
}
],
@ -697,11 +697,11 @@
"labelPercentage": 0,
"route": [
{
"x": 680,
"x": 689,
"y": 312
},
{
"x": 680,
"x": 689,
"y": 1742
}
],
@ -736,11 +736,11 @@
"labelPercentage": 0,
"route": [
{
"x": 997,
"x": 1006,
"y": 312
},
{
"x": 997,
"x": 1006,
"y": 1742
}
],
@ -775,11 +775,11 @@
"labelPercentage": 0,
"route": [
{
"x": 1314.5,
"x": 1323.5,
"y": 312
},
{
"x": 1314.5,
"x": 1323.5,
"y": 1742
}
],

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 476 KiB

After

Width:  |  Height:  |  Size: 476 KiB

View file

@ -45,7 +45,7 @@
"id": "bob",
"type": "person",
"pos": {
"x": 288,
"x": 297,
"y": 165
},
"width": 150,
@ -85,7 +85,7 @@
"id": "db",
"type": "cylinder",
"pos": {
"x": 605,
"x": 614,
"y": 186
},
"width": 150,
@ -125,7 +125,7 @@
"id": "queue",
"type": "queue",
"pos": {
"x": 922,
"x": 931,
"y": 186
},
"width": 150,
@ -165,7 +165,7 @@
"id": "service",
"type": "",
"pos": {
"x": 1216,
"x": 1225,
"y": 74
},
"width": 197,
@ -233,7 +233,7 @@
"y": 442
},
{
"x": 363,
"x": 372,
"y": 442
}
],
@ -268,11 +268,11 @@
"labelPercentage": 0,
"route": [
{
"x": 363,
"x": 372,
"y": 572
},
{
"x": 1314.5,
"x": 1323.5,
"y": 572
}
],
@ -307,11 +307,11 @@
"labelPercentage": 0,
"route": [
{
"x": 1314.5,
"x": 1323.5,
"y": 702
},
{
"x": 680,
"x": 689,
"y": 702
}
],
@ -346,11 +346,11 @@
"labelPercentage": 0,
"route": [
{
"x": 680,
"x": 689,
"y": 832
},
{
"x": 1314.5,
"x": 1323.5,
"y": 832
}
],
@ -385,11 +385,11 @@
"labelPercentage": 0,
"route": [
{
"x": 1314.5,
"x": 1323.5,
"y": 962
},
{
"x": 363,
"x": 372,
"y": 962
}
],
@ -424,7 +424,7 @@
"labelPercentage": 0,
"route": [
{
"x": 363,
"x": 372,
"y": 1092
},
{
@ -467,7 +467,7 @@
"y": 1222
},
{
"x": 363,
"x": 372,
"y": 1222
}
],
@ -502,11 +502,11 @@
"labelPercentage": 0,
"route": [
{
"x": 363,
"x": 372,
"y": 1352
},
{
"x": 997,
"x": 1006,
"y": 1352
}
],
@ -541,11 +541,11 @@
"labelPercentage": 0,
"route": [
{
"x": 997,
"x": 1006,
"y": 1482
},
{
"x": 363,
"x": 372,
"y": 1482
}
],
@ -580,7 +580,7 @@
"labelPercentage": 0,
"route": [
{
"x": 363,
"x": 372,
"y": 1612
},
{
@ -658,11 +658,11 @@
"labelPercentage": 0,
"route": [
{
"x": 363,
"x": 372,
"y": 317
},
{
"x": 363,
"x": 372,
"y": 1742
}
],
@ -697,11 +697,11 @@
"labelPercentage": 0,
"route": [
{
"x": 680,
"x": 689,
"y": 312
},
{
"x": 680,
"x": 689,
"y": 1742
}
],
@ -736,11 +736,11 @@
"labelPercentage": 0,
"route": [
{
"x": 997,
"x": 1006,
"y": 312
},
{
"x": 997,
"x": 1006,
"y": 1742
}
],
@ -775,11 +775,11 @@
"labelPercentage": 0,
"route": [
{
"x": 1314.5,
"x": 1323.5,
"y": 312
},
{
"x": 1314.5,
"x": 1323.5,
"y": 1742
}
],

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 476 KiB

After

Width:  |  Height:  |  Size: 476 KiB