fix elk panic with empty label
This commit is contained in:
parent
a40a3a7f1f
commit
f8482ee96a
5 changed files with 188 additions and 5 deletions
|
|
@ -147,8 +147,10 @@ func Layout(ctx context.Context, g *d2graph.Graph) (err error) {
|
|||
|
||||
walk(g.Root, nil, func(obj, parent *d2graph.Object) {
|
||||
height := obj.Height
|
||||
if obj.Attributes.Shape.Value == d2target.ShapeImage || obj.Attributes.Icon != nil {
|
||||
height += float64(*obj.LabelHeight) + label.PADDING
|
||||
if obj.LabelWidth != nil && obj.LabelHeight != nil {
|
||||
if obj.Attributes.Shape.Value == d2target.ShapeImage || obj.Attributes.Icon != nil {
|
||||
height += float64(*obj.LabelHeight) + label.PADDING
|
||||
}
|
||||
}
|
||||
|
||||
n := &ELKNode{
|
||||
|
|
|
|||
50
e2etests/testdata/regression/elk_img_empty_label_panic/dagre/board.exp.json
generated
vendored
50
e2etests/testdata/regression/elk_img_empty_label_panic/dagre/board.exp.json
generated
vendored
|
|
@ -51,6 +51,56 @@
|
|||
"labelHeight": 0,
|
||||
"zIndex": 0,
|
||||
"level": 1
|
||||
},
|
||||
{
|
||||
"id": "ico",
|
||||
"type": "",
|
||||
"pos": {
|
||||
"x": 188,
|
||||
"y": 14
|
||||
},
|
||||
"width": 100,
|
||||
"height": 100,
|
||||
"opacity": 1,
|
||||
"strokeDash": 0,
|
||||
"strokeWidth": 2,
|
||||
"borderRadius": 0,
|
||||
"fill": "#F7F8FE",
|
||||
"stroke": "#0D32B2",
|
||||
"shadow": false,
|
||||
"3d": false,
|
||||
"multiple": false,
|
||||
"tooltip": "",
|
||||
"link": "",
|
||||
"icon": {
|
||||
"Scheme": "https",
|
||||
"Opaque": "",
|
||||
"User": null,
|
||||
"Host": "icons.terrastruct.com",
|
||||
"Path": "/infra/019-network.svg",
|
||||
"RawPath": "",
|
||||
"ForceQuery": false,
|
||||
"RawQuery": "",
|
||||
"Fragment": "",
|
||||
"RawFragment": ""
|
||||
},
|
||||
"iconPosition": "INSIDE_MIDDLE_CENTER",
|
||||
"blend": false,
|
||||
"fields": null,
|
||||
"methods": null,
|
||||
"columns": null,
|
||||
"label": "",
|
||||
"fontSize": 16,
|
||||
"fontFamily": "DEFAULT",
|
||||
"language": "",
|
||||
"color": "#0A0F25",
|
||||
"italic": false,
|
||||
"bold": true,
|
||||
"underline": false,
|
||||
"labelWidth": 0,
|
||||
"labelHeight": 0,
|
||||
"zIndex": 0,
|
||||
"level": 1
|
||||
}
|
||||
],
|
||||
"connections": []
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<svg
|
||||
style="background: white;"
|
||||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
width="328" height="328" viewBox="-100 -100 328 328"><style type="text/css">
|
||||
width="488" height="328" viewBox="-100 -100 488 328"><style type="text/css">
|
||||
<![CDATA[
|
||||
.shape {
|
||||
shape-rendering: geometricPrecision;
|
||||
|
|
@ -18,7 +18,7 @@ width="328" height="328" viewBox="-100 -100 328 328"><style type="text/css">
|
|||
}
|
||||
|
||||
]]>
|
||||
</style><g id="img"><g class="shape" ><image href="https://icons.terrastruct.com/infra/019-network.svg" x="0" y="0" width="128" height="128" style="fill:#FFFFFF;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g></g><mask id="1647785219" maskUnits="userSpaceOnUse" x="-100" y="-100" width="328" height="328">
|
||||
<rect x="-100" y="-100" width="328" height="328" fill="white"></rect>
|
||||
</style><g id="img"><g class="shape" ><image href="https://icons.terrastruct.com/infra/019-network.svg" x="0" y="0" width="128" height="128" style="fill:#FFFFFF;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g></g><g id="ico"><g class="shape" ><rect x="188" y="14" width="100" height="100" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><image href="https://icons.terrastruct.com/infra/019-network.svg" x="213.000000" y="39.000000" width="50" height="50" /></g><mask id="1654899612" maskUnits="userSpaceOnUse" x="-100" y="-100" width="488" height="328">
|
||||
<rect x="-100" y="-100" width="488" height="328" fill="white"></rect>
|
||||
|
||||
</mask><style type="text/css"><![CDATA[]]></style></svg>
|
||||
|
Before Width: | Height: | Size: 879 B After Width: | Height: | Size: 1.1 KiB |
107
e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json
generated
vendored
Normal file
107
e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
{
|
||||
"name": "",
|
||||
"fontFamily": "SourceSansPro",
|
||||
"shapes": [
|
||||
{
|
||||
"id": "img",
|
||||
"type": "image",
|
||||
"pos": {
|
||||
"x": 12,
|
||||
"y": 12
|
||||
},
|
||||
"width": 128,
|
||||
"height": 128,
|
||||
"opacity": 1,
|
||||
"strokeDash": 0,
|
||||
"strokeWidth": 2,
|
||||
"borderRadius": 0,
|
||||
"fill": "#FFFFFF",
|
||||
"stroke": "#0D32B2",
|
||||
"shadow": false,
|
||||
"3d": false,
|
||||
"multiple": false,
|
||||
"tooltip": "",
|
||||
"link": "",
|
||||
"icon": {
|
||||
"Scheme": "https",
|
||||
"Opaque": "",
|
||||
"User": null,
|
||||
"Host": "icons.terrastruct.com",
|
||||
"Path": "/infra/019-network.svg",
|
||||
"RawPath": "",
|
||||
"ForceQuery": false,
|
||||
"RawQuery": "",
|
||||
"Fragment": "",
|
||||
"RawFragment": ""
|
||||
},
|
||||
"iconPosition": "INSIDE_MIDDLE_CENTER",
|
||||
"blend": false,
|
||||
"fields": null,
|
||||
"methods": null,
|
||||
"columns": null,
|
||||
"label": "",
|
||||
"fontSize": 16,
|
||||
"fontFamily": "DEFAULT",
|
||||
"language": "",
|
||||
"color": "#0A0F25",
|
||||
"italic": false,
|
||||
"bold": true,
|
||||
"underline": false,
|
||||
"labelWidth": 0,
|
||||
"labelHeight": 0,
|
||||
"zIndex": 0,
|
||||
"level": 1
|
||||
},
|
||||
{
|
||||
"id": "ico",
|
||||
"type": "",
|
||||
"pos": {
|
||||
"x": 160,
|
||||
"y": 26
|
||||
},
|
||||
"width": 100,
|
||||
"height": 100,
|
||||
"opacity": 1,
|
||||
"strokeDash": 0,
|
||||
"strokeWidth": 2,
|
||||
"borderRadius": 0,
|
||||
"fill": "#F7F8FE",
|
||||
"stroke": "#0D32B2",
|
||||
"shadow": false,
|
||||
"3d": false,
|
||||
"multiple": false,
|
||||
"tooltip": "",
|
||||
"link": "",
|
||||
"icon": {
|
||||
"Scheme": "https",
|
||||
"Opaque": "",
|
||||
"User": null,
|
||||
"Host": "icons.terrastruct.com",
|
||||
"Path": "/infra/019-network.svg",
|
||||
"RawPath": "",
|
||||
"ForceQuery": false,
|
||||
"RawQuery": "",
|
||||
"Fragment": "",
|
||||
"RawFragment": ""
|
||||
},
|
||||
"iconPosition": "INSIDE_MIDDLE_CENTER",
|
||||
"blend": false,
|
||||
"fields": null,
|
||||
"methods": null,
|
||||
"columns": null,
|
||||
"label": "",
|
||||
"fontSize": 16,
|
||||
"fontFamily": "DEFAULT",
|
||||
"language": "",
|
||||
"color": "#0A0F25",
|
||||
"italic": false,
|
||||
"bold": true,
|
||||
"underline": false,
|
||||
"labelWidth": 0,
|
||||
"labelHeight": 0,
|
||||
"zIndex": 0,
|
||||
"level": 1
|
||||
}
|
||||
],
|
||||
"connections": []
|
||||
}
|
||||
24
e2etests/testdata/regression/elk_img_empty_label_panic/elk/sketch.exp.svg
vendored
Normal file
24
e2etests/testdata/regression/elk_img_empty_label_panic/elk/sketch.exp.svg
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg
|
||||
style="background: white;"
|
||||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
width="448" height="328" viewBox="-88 -88 448 328"><style type="text/css">
|
||||
<![CDATA[
|
||||
.shape {
|
||||
shape-rendering: geometricPrecision;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
.connection {
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
.blend {
|
||||
mix-blend-mode: multiply;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
]]>
|
||||
</style><g id="img"><g class="shape" ><image href="https://icons.terrastruct.com/infra/019-network.svg" x="12" y="12" width="128" height="128" style="fill:#FFFFFF;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g></g><g id="ico"><g class="shape" ><rect x="160" y="26" width="100" height="100" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><image href="https://icons.terrastruct.com/infra/019-network.svg" x="185.000000" y="51.000000" width="50" height="50" /></g><mask id="124328945" maskUnits="userSpaceOnUse" x="-100" y="-100" width="448" height="328">
|
||||
<rect x="-100" y="-100" width="448" height="328" fill="white"></rect>
|
||||
|
||||
</mask><style type="text/css"><![CDATA[]]></style></svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in a new issue