From ec68dc149c13a7daa282d26ff9de2a8014a197b7 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Thu, 24 Nov 2022 01:04:47 -0800 Subject: [PATCH 1/2] 2022-11-24 01:04:47AM --- d2renderers/d2svg/d2svg.go | 4 ++++ e2etests/stable_test.go | 1 + e2etests/testdata/stable/stylish/dagre/board.exp.json | 2 +- e2etests/testdata/stable/stylish/dagre/sketch.exp.svg | 2 +- e2etests/testdata/stable/stylish/elk/board.exp.json | 2 +- e2etests/testdata/stable/stylish/elk/sketch.exp.svg | 2 +- 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index 5cef9be2f6..d32a1749a1 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -755,6 +755,10 @@ func shapeStyle(shape d2target.Shape) string { out += fmt.Sprintf(`stroke:%s;`, shape.Stroke) out += fmt.Sprintf(`opacity:%f;`, shape.Opacity) out += fmt.Sprintf(`stroke-width:%d;`, shape.StrokeWidth) + if shape.StrokeDash != 0 { + dashSize, gapSize := getStrokeDashAttributes(float64(shape.StrokeWidth), shape.StrokeDash) + out += fmt.Sprintf(`stroke-dasharray:%f,%f;`, dashSize, gapSize) + } return out } diff --git a/e2etests/stable_test.go b/e2etests/stable_test.go index 0edc06849c..2bfb4d5a58 100644 --- a/e2etests/stable_test.go +++ b/e2etests/stable_test.go @@ -909,6 +909,7 @@ x: { y: { style: { + stroke-dash: 5 opacity: 0.6 fill: red 3d: true diff --git a/e2etests/testdata/stable/stylish/dagre/board.exp.json b/e2etests/testdata/stable/stylish/dagre/board.exp.json index 5b4f850f05..2fe57244ab 100644 --- a/e2etests/testdata/stable/stylish/dagre/board.exp.json +++ b/e2etests/testdata/stable/stylish/dagre/board.exp.json @@ -50,7 +50,7 @@ "height": 126, "level": 1, "opacity": 0.6, - "strokeDash": 0, + "strokeDash": 5, "strokeWidth": 2, "borderRadius": 0, "fill": "red", diff --git a/e2etests/testdata/stable/stylish/dagre/sketch.exp.svg b/e2etests/testdata/stable/stylish/dagre/sketch.exp.svg index 8930df741e..41ab463974 100644 --- a/e2etests/testdata/stable/stylish/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/stylish/dagre/sketch.exp.svg @@ -22,7 +22,7 @@ width="314" height="552" viewBox="-100 -100 314 552">