mirror of
https://github.com/wahyd4/badger.git
synced 2026-08-09 05:15:58 +10:00
Update styling
This commit is contained in:
@@ -71,7 +71,7 @@ func main() {
|
||||
})
|
||||
|
||||
r.GET("/svg/:name", func(c *gin.Context) {
|
||||
if err := geneateSvg(client, c); err != nil {
|
||||
if err := generateSVG(client, c); err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
})
|
||||
@@ -85,7 +85,7 @@ func main() {
|
||||
log.Fatal(r.Run())
|
||||
}
|
||||
|
||||
func geneateSvg(client api.Client, c *gin.Context) error {
|
||||
func generateSVG(client api.Client, c *gin.Context) error {
|
||||
queryName := c.Param("name")
|
||||
query, ok := queriesMap[queryName]
|
||||
if !ok {
|
||||
@@ -98,18 +98,18 @@ func geneateSvg(client api.Client, c *gin.Context) error {
|
||||
w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%d, s-maxage=%d", badgeExpireSeconds, badgeExpireSeconds))
|
||||
canvas := svg.New(w)
|
||||
canvas.Start(badgeWidth, badgeHeight)
|
||||
canvas.Rect(0, 0, badgeWidth, badgeHeight, "fill-opacity:1.00; fill:rgb(90,90,90)")
|
||||
canvas.Rect(0, 0, badgeWidth, badgeHeight, "fill-opacity:1.00; fill:rgb(90,90,90); padding: 2px 5px;")
|
||||
|
||||
// labelContainerWidth := len(metric.Label)*fontSize + textMarginX
|
||||
labelContainerWidth := badgeWidth * 0.5
|
||||
//labelContainerWidth := len(metric.Label)*fontSize + textMarginX
|
||||
labelContainerWidth := badgeWidth * 0.6
|
||||
// if labelContainerWidth < badgeWidth*0.5 {
|
||||
// labelContainerWidth = badgeWidth * 0.5
|
||||
// }
|
||||
canvas.Rect(0, 0, int(labelContainerWidth), badgeHeight, "fill-opacity:1.00; fill:rgb(49, 197, 83)")
|
||||
canvas.Rect(0, 0, int(labelContainerWidth), badgeHeight, "fill-opacity:1.00; fill:rgb(49, 197, 83); padding: 2px 5px; float: right")
|
||||
canvas.Text(textMarginX, 15, metric.Label, textStyle)
|
||||
|
||||
valueText := strconv.Itoa(int(metric.Value))
|
||||
canvas.Text(badgeWidth-textMarginX-len(valueText)*fontSize, 15, valueText, textStyle)
|
||||
canvas.Text(badgeWidth*0.7, 15, valueText, textStyle)
|
||||
canvas.End()
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user