render connection label background according to style.fill
This commit is contained in:
parent
65dc45c119
commit
412713e2b7
3 changed files with 10 additions and 0 deletions
|
|
@ -200,6 +200,10 @@ func toConnection(edge *d2graph.Edge, theme *d2themes.Theme) d2target.Connection
|
|||
connection.StrokeWidth, _ = strconv.Atoi(edge.Attributes.Style.StrokeWidth.Value)
|
||||
}
|
||||
|
||||
if edge.Attributes.Style.Fill != nil {
|
||||
connection.Fill = edge.Attributes.Style.Fill.Value
|
||||
}
|
||||
|
||||
connection.FontSize = text.FontSize
|
||||
if edge.Attributes.Style.FontSize != nil {
|
||||
connection.FontSize, _ = strconv.Atoi(edge.Attributes.Style.FontSize.Value)
|
||||
|
|
|
|||
|
|
@ -432,6 +432,11 @@ func drawConnection(writer io.Writer, labelMaskID string, connection d2target.Co
|
|||
if connection.Color != "" {
|
||||
fontColor = connection.Color
|
||||
}
|
||||
|
||||
if connection.Fill != "" {
|
||||
fmt.Fprintf(writer, `<rect x="%f" y="%f" width="%d" height="%d" style="fill:%s" />`,
|
||||
labelTL.X, labelTL.Y, connection.LabelWidth, connection.LabelHeight, connection.Fill)
|
||||
}
|
||||
textStyle := fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "middle", connection.FontSize, fontColor)
|
||||
x := labelTL.X + float64(connection.LabelWidth)/2
|
||||
y := labelTL.Y + float64(connection.FontSize)
|
||||
|
|
|
|||
|
|
@ -207,6 +207,7 @@ type Connection struct {
|
|||
StrokeDash float64 `json:"strokeDash"`
|
||||
StrokeWidth int `json:"strokeWidth"`
|
||||
Stroke string `json:"stroke"`
|
||||
Fill string `json:"fill,omitempty"`
|
||||
|
||||
Text
|
||||
LabelPosition string `json:"labelPosition"`
|
||||
|
|
|
|||
Loading…
Reference in a new issue