mirror of
https://github.com/wahyd4/badger.git
synced 2026-08-09 05:15:58 +10:00
make the badge expires in a mintue to make the stats more accurate
This commit is contained in:
@@ -22,14 +22,13 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// backgroundImageFilename = "images/bg.png"
|
||||
radius = 0
|
||||
fontSize = 12
|
||||
textMarginX = 6.0
|
||||
textMarginY = 14
|
||||
badgeHeight = 20
|
||||
textStyle = "text-anchor:start;font-size:12px;fill:white;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;"
|
||||
badgeExpireSeconds = 120
|
||||
badgeExpireSeconds = 60
|
||||
labelWidthPortion = 0.65
|
||||
ColorSchemeGreen = "fill-opacity:1.00; fill:rgb(49, 197, 83);"
|
||||
ColorSchemeOrange = "fill-opacity:1.00; fill:rgb(255, 87, 34);"
|
||||
@@ -137,7 +136,7 @@ func generateSVG(client api.Client, c *gin.Context) error {
|
||||
|
||||
if metricValue > 10000 && metricValue < 1000000 {
|
||||
valueRectWidth = 50
|
||||
}else if metricValue >= 1000000 {
|
||||
} else if metricValue >= 1000000 {
|
||||
valueRectWidth = 66
|
||||
}
|
||||
badgeWidth := labelContainerWidth + valueRectWidth
|
||||
@@ -153,14 +152,12 @@ func generateSVG(client api.Client, c *gin.Context) error {
|
||||
|
||||
canvas.Rect(0, 0, int(labelContainerWidth), badgeHeight, string(query.Color))
|
||||
|
||||
|
||||
//when there is metric label then use default label
|
||||
if len(query.ValueField) == 0 {
|
||||
label = query.Label
|
||||
}
|
||||
canvas.Text(textMarginX, textMarginY, label, textStyle)
|
||||
|
||||
|
||||
valueText := strconv.Itoa(metricValue)
|
||||
canvas.Text(labelContainerWidth+textMarginX, textMarginY, valueText, textStyle)
|
||||
canvas.End()
|
||||
|
||||
Reference in New Issue
Block a user