GWM: empty oo value removed
This commit is contained in:
parent
d18af8373a
commit
6f23844859
@ -149,8 +149,35 @@ func difference(data []Observation) float64 {
|
||||
return ((latest - previous) / previous) * 100
|
||||
}
|
||||
|
||||
func applyConversion(value float64, conversion string, numberFormat string) string {
|
||||
// func applyConversion(value float64, conversion string, numberFormat string) string {
|
||||
|
||||
// if numberFormat == "T" {
|
||||
// value *= 1000000000000
|
||||
// } else if numberFormat == "B" {
|
||||
// value *= 1000000000
|
||||
// } else if numberFormat == "M" {
|
||||
// value *= 1000000
|
||||
// } else if numberFormat == "K" {
|
||||
// value *= 1000
|
||||
// }
|
||||
|
||||
// switch conversion {
|
||||
// case "T":
|
||||
// return fmt.Sprintf("%.2fT", value/1000000000000)
|
||||
// case "B":
|
||||
// return fmt.Sprintf("%.2fB", value/1000000000)
|
||||
// case "M":
|
||||
// return fmt.Sprintf("%.2fM", value/1000000)
|
||||
// case "K":
|
||||
// return fmt.Sprintf("%.2fK", value/1000)
|
||||
// case "%":
|
||||
// return fmt.Sprintf("%.2f%%", value)
|
||||
// default:
|
||||
// return fmt.Sprintf("%.2f", value)
|
||||
// }
|
||||
// }
|
||||
|
||||
func applyConversion(value float64, conversion string, numberFormat string) string {
|
||||
if numberFormat == "T" {
|
||||
value *= 1000000000000
|
||||
} else if numberFormat == "B" {
|
||||
@ -161,19 +188,27 @@ func applyConversion(value float64, conversion string, numberFormat string) stri
|
||||
value *= 1000
|
||||
}
|
||||
|
||||
// Helper function to format the number properly
|
||||
formatNumber := func(v float64, suffix string) string {
|
||||
if v == float64(int(v)) { // Check if v has no decimal part
|
||||
return fmt.Sprintf("%d%s", int(v), suffix)
|
||||
}
|
||||
return fmt.Sprintf("%.2f%s", v, suffix)
|
||||
}
|
||||
|
||||
switch conversion {
|
||||
case "T":
|
||||
return fmt.Sprintf("%.2fM", value/1000000000000)
|
||||
return formatNumber(value/1000000000000, "T")
|
||||
case "B":
|
||||
return fmt.Sprintf("%.2fT", value/1000000000)
|
||||
return formatNumber(value/1000000000, "B")
|
||||
case "M":
|
||||
return fmt.Sprintf("%.2fT", value/1000000)
|
||||
return formatNumber(value/1000000, "M")
|
||||
case "K":
|
||||
return fmt.Sprintf("%.2fK", value/1000)
|
||||
return formatNumber(value/1000, "K")
|
||||
case "%":
|
||||
return fmt.Sprintf("%.2f%%", value)
|
||||
return formatNumber(value, "%")
|
||||
default:
|
||||
return fmt.Sprintf("%.2f", value)
|
||||
return formatNumber(value, "")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user