mirror of
https://github.com/wahyd4/badger.git
synced 2026-08-08 21:05:55 +10:00
Upate logic of how we calculate svg length
This commit is contained in:
+4
-16
@@ -288,23 +288,11 @@ func (handler *BadgesHandler) generateSVG(c *gin.Context, colorScheme ColorSchem
|
||||
label := metric.Label
|
||||
|
||||
valueRectWidth := 40
|
||||
labelContainerWidth := 120
|
||||
// TODO find a better way to handle this
|
||||
if len(label) <= 10 {
|
||||
labelContainerWidth = 74
|
||||
} else if len(label) >= 20 && len(label) < 25 {
|
||||
labelContainerWidth = 150
|
||||
} else if len(label) >= 25 {
|
||||
labelContainerWidth = 174
|
||||
}
|
||||
labelContainerWidth := 110
|
||||
// Calculate labelContainerWidth based on label length
|
||||
labelContainerWidth = len(label)*6 + 20
|
||||
|
||||
if metricValue > 10000 && metricValue < 100000 {
|
||||
valueRectWidth = 50
|
||||
} else if metricValue >= 100000 {
|
||||
valueRectWidth = 66
|
||||
} else if metricValue >= 1000000 {
|
||||
valueRectWidth = 82
|
||||
}
|
||||
valueRectWidth = len(strconv.Itoa(metricValue))*6 + 21
|
||||
badgeWidth := labelContainerWidth + valueRectWidth
|
||||
|
||||
w := c.Writer
|
||||
|
||||
Reference in New Issue
Block a user