mirror of
https://github.com/wahyd4/badger.git
synced 2026-08-09 05:15:58 +10:00
Optimize the style
This commit is contained in:
@@ -9,5 +9,7 @@ Create badge from your prometheus metrics
|
||||

|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
[](https://microbadger.com/images/wahyd4/aria2-ui "Get your own image badge on microbadger.com")
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user