make the badge expires in a mintue to make the stats more accurate

This commit is contained in:
2020-08-09 15:48:08 +10:00
parent 77fbe78e3d
commit 551a012fda
+2 -5
View File
@@ -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()