From df81a5aeaa039666b397d52f811d39df8554c999 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 4 Dec 2022 22:31:37 -0800 Subject: [PATCH] fix span width --- d2layouts/d2sequence/sequence_diagram.go | 4 +- .../dagre/board.exp.json | 26 +- .../dagre/sketch.exp.svg | 16 +- .../sequence_diagram_real/elk/board.exp.json | 26 +- .../sequence_diagram_real/elk/sketch.exp.svg | 16 +- .../sequence_diagrams/dagre/board.exp.json | 280 +++++++++--------- .../sequence_diagrams/dagre/sketch.exp.svg | 6 +- .../sequence_diagrams/elk/board.exp.json | 280 +++++++++--------- .../sequence_diagrams/elk/sketch.exp.svg | 6 +- 9 files changed, 330 insertions(+), 330 deletions(-) diff --git a/d2layouts/d2sequence/sequence_diagram.go b/d2layouts/d2sequence/sequence_diagram.go index 9edcf2d72..33ea2fc40 100644 --- a/d2layouts/d2sequence/sequence_diagram.go +++ b/d2layouts/d2sequence/sequence_diagram.go @@ -389,8 +389,8 @@ func (sd *sequenceDiagram) placeSpans() { } 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_BASE_WIDTH + (float64(span.Level()-2) * SPAN_DEPTH_GROWTH_FACTOR) + // -1 because the actors count as 1 level + width := SPAN_BASE_WIDTH + (float64(span.Level()-sd.root.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 = SPAN_Z_INDEX diff --git a/e2etests/testdata/stable/sequence_diagram_real/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_real/dagre/board.exp.json index b674a70ba..8103cdff0 100644 --- a/e2etests/testdata/stable/sequence_diagram_real/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_real/dagre/board.exp.json @@ -8,7 +8,7 @@ "x": 0, "y": 0 }, - "width": 1504, + "width": 1508, "height": 180, "opacity": 1, "strokeDash": 0, @@ -359,7 +359,7 @@ "x": 50, "y": 50 }, - "width": 1404, + "width": 1408, "height": 80, "opacity": 1, "strokeDash": 0, @@ -395,10 +395,10 @@ "id": "How this is rendered.d2layout.layout", "type": "rectangle", "pos": { - "x": 764, + "x": 768, "y": 1125 }, - "width": 20, + "width": 12, "height": 422, "opacity": 1, "strokeDash": 0, @@ -511,10 +511,10 @@ "id": "How this is rendered.d2exporter.export", "type": "rectangle", "pos": { - "x": 1007, + "x": 1011, "y": 1905 }, - "width": 20, + "width": 12, "height": 292, "opacity": 1, "strokeDash": 0, @@ -733,7 +733,7 @@ "y": 1141 }, { - "x": 764.5, + "x": 768.5, "y": 1141 } ], @@ -768,7 +768,7 @@ "labelPercentage": 0, "route": [ { - "x": 784.5, + "x": 780.5, "y": 1271 }, { @@ -807,7 +807,7 @@ "labelPercentage": 0, "route": [ { - "x": 784.5, + "x": 780.5, "y": 1401 }, { @@ -846,7 +846,7 @@ "labelPercentage": 0, "route": [ { - "x": 784.5, + "x": 780.5, "y": 1531 }, { @@ -963,7 +963,7 @@ "labelPercentage": 0, "route": [ { - "x": 1027, + "x": 1023, "y": 1921 }, { @@ -1002,7 +1002,7 @@ "labelPercentage": 0, "route": [ { - "x": 1027, + "x": 1023, "y": 2051 }, { @@ -1041,7 +1041,7 @@ "labelPercentage": 0, "route": [ { - "x": 1007, + "x": 1011, "y": 2181 }, { diff --git a/e2etests/testdata/stable/sequence_diagram_real/dagre/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_real/dagre/sketch.exp.svg index a08f96df1..670f54329 100644 --- a/e2etests/testdata/stable/sequence_diagram_real/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_real/dagre/sketch.exp.svg @@ -14,21 +14,21 @@ width="2393" height="2511" viewBox="-100 -100 2393 2511">How this is renderedCLId2astd2compilerd2layoutd2exporterd2themesd2rendererd2sequencelayoutd2dagrelayoutonly if root is not sequence 'How this is rendered: {...}'tokenized ASTcompile ASTobjects and edgesrun layout enginesrun engine on shape: sequence_diagram, temporarily removerun core engine on rest add back in sequence diagramsdiagram with correct positions and dimensionsexport diagram with chosen theme and rendererget theme stylesrender to SVGresulting SVGmeasurements also take place +How this is renderedCLId2astd2compilerd2layoutd2exporterd2themesd2rendererd2sequencelayoutd2dagrelayoutonly if root is not sequence 'How this is rendered: {...}'tokenized ASTcompile ASTobjects and edgesrun layout enginesrun engine on shape: sequence_diagram, temporarily removerun core engine on rest add back in sequence diagramsdiagram with correct positions and dimensionsexport diagram with chosen theme and rendererget theme stylesrender to SVGresulting SVGmeasurements also take place - - - - + + + + - - - + + + How this is renderedCLId2astd2compilerd2layoutd2exporterd2themesd2rendererd2sequencelayoutd2dagrelayoutonly if root is not sequence 'How this is rendered: {...}'tokenized ASTcompile ASTobjects and edgesrun layout enginesrun engine on shape: sequence_diagram, temporarily removerun core engine on rest add back in sequence diagramsdiagram with correct positions and dimensionsexport diagram with chosen theme and rendererget theme stylesrender to SVGresulting SVGmeasurements also take place +How this is renderedCLId2astd2compilerd2layoutd2exporterd2themesd2rendererd2sequencelayoutd2dagrelayoutonly if root is not sequence 'How this is rendered: {...}'tokenized ASTcompile ASTobjects and edgesrun layout enginesrun engine on shape: sequence_diagram, temporarily removerun core engine on rest add back in sequence diagramsdiagram with correct positions and dimensionsexport diagram with chosen theme and rendererget theme stylesrender to SVGresulting SVGmeasurements also take place - - - - + + + + - - - + + + a_shapea_sequenceanotherfinallysequencesequencesequencescoreritemResponseitemessayRubricconceptitemOutcomescorerconceptessayRubricitemitemOutcomeitemResponsescoreritemResponseitemessayRubricconceptitemOutcome getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts) +a_shapea_sequenceanotherfinallysequencesequencesequencescoreritemResponseitemessayRubricconceptitemOutcomescorerconceptessayRubricitemitemOutcomeitemResponsescoreritemResponseitemessayRubricconceptitemOutcome getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts) @@ -22,7 +22,7 @@ width="3244" height="4201" viewBox="-100 -100 3244 4201">a_shapea_sequenceanotherfinallysequencesequencesequencescoreritemResponseitemessayRubricconceptitemOutcomescorerconceptessayRubricitemitemOutcomeitemResponsescoreritemResponseitemessayRubricconceptitemOutcome getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts) +a_shapea_sequenceanotherfinallysequencesequencesequencescoreritemResponseitemessayRubricconceptitemOutcomescorerconceptessayRubricitemitemOutcomeitemResponsescoreritemResponseitemessayRubricconceptitemOutcome getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts) @@ -22,7 +22,7 @@ width="3166" height="4321" viewBox="-88 -88 3166 4321">