Optimize the style

This commit is contained in:
2020-07-11 00:06:24 +10:00
parent a91fa0bf78
commit 73be6f5eb4
2 changed files with 5 additions and 2 deletions
+2
View File
@@ -9,5 +9,7 @@ Create badge from your prometheus metrics
![Github Star](https://badge.home.toozhao.com/png/github)
![Air Index](https://badge.home.toozhao.com/svg/mel)
![Dockerhub Pull](https://badge.home.toozhao.com/svg/dockerhub)
![Github Star](https://badge.home.toozhao.com/svg/github)
[![](https://images.microbadger.com/badges/image/wahyd4/aria2-ui.svg)](https://microbadger.com/images/wahyd4/aria2-ui "Get your own image badge on microbadger.com")
+3 -2
View File
@@ -27,6 +27,7 @@ const (
textMarginY = -2.0
badgeWidth = 180
badgeHeight = 20
textStyle = "text-anchor:right;font-size:12px;fill:white;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;"
)
var (
@@ -95,10 +96,10 @@ func geneateSvg(client api.Client, c *gin.Context) error {
// labelContainerWidth = badgeWidth * 0.5
// }
canvas.Rect(0, 0, int(labelContainerWidth), badgeHeight, "fill-opacity:1.00; fill:rgb(49, 197, 83)")
canvas.Text(textMarginX, 15, metric.Label, "text-anchor:left;font-size:12px;fill:white;")
canvas.Text(textMarginX, 15, metric.Label, textStyle)
valueText := strconv.Itoa(int(metric.Value))
canvas.Text(badgeWidth-textMarginX-len(valueText)*fontSize, 15, valueText, "text-anchor:right;font-size:12px;fill:white;")
canvas.Text(badgeWidth-textMarginX-len(valueText)*fontSize, 15, valueText, textStyle)
canvas.End()
return nil
}