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)
|
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
|
connection.FontSize = text.FontSize
|
||||||
if edge.Attributes.Style.FontSize != nil {
|
if edge.Attributes.Style.FontSize != nil {
|
||||||
connection.FontSize, _ = strconv.Atoi(edge.Attributes.Style.FontSize.Value)
|
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 != "" {
|
if connection.Color != "" {
|
||||||
fontColor = 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)
|
textStyle := fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "middle", connection.FontSize, fontColor)
|
||||||
x := labelTL.X + float64(connection.LabelWidth)/2
|
x := labelTL.X + float64(connection.LabelWidth)/2
|
||||||
y := labelTL.Y + float64(connection.FontSize)
|
y := labelTL.Y + float64(connection.FontSize)
|
||||||
|
|
|
||||||
|
|
@ -207,6 +207,7 @@ type Connection struct {
|
||||||
StrokeDash float64 `json:"strokeDash"`
|
StrokeDash float64 `json:"strokeDash"`
|
||||||
StrokeWidth int `json:"strokeWidth"`
|
StrokeWidth int `json:"strokeWidth"`
|
||||||
Stroke string `json:"stroke"`
|
Stroke string `json:"stroke"`
|
||||||
|
Fill string `json:"fill,omitempty"`
|
||||||
|
|
||||||
Text
|
Text
|
||||||
LabelPosition string `json:"labelPosition"`
|
LabelPosition string `json:"labelPosition"`
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue