|
@@ -1249,7 +1249,7 @@ func GetTableDataByMixedTableData(config [][]request.MixedTableCellDataReq, hide
|
|
|
}
|
|
|
|
|
|
if styleConfig.Decimal != nil {
|
|
|
- tmp.Monitor = roundNumber(cell.ShowValue, *styleConfig.Decimal, hasPercent)
|
|
|
+ tmp.Monitor = utils.RoundNumber(cell.ShowValue, *styleConfig.Decimal, hasPercent)
|
|
|
} else {
|
|
|
if hasPercent {
|
|
|
numDecimal, _ := decimal.NewFromString(cell.ShowValue)
|
|
@@ -1308,16 +1308,3 @@ func GetTableDataByMixedTableData(config [][]request.MixedTableCellDataReq, hide
|
|
|
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
-func roundNumber(num string, decimalPlaces int, hasPercent bool) string {
|
|
|
- numDecimal, _ := decimal.NewFromString(num)
|
|
|
- if hasPercent {
|
|
|
- numDecimal = numDecimal.Mul(decimal.NewFromInt(100))
|
|
|
- }
|
|
|
- numFloat, _ := numDecimal.Round(int32(decimalPlaces)).Float64()
|
|
|
- numStr := strconv.FormatFloat(numFloat, 'f', decimalPlaces, 64)
|
|
|
- if hasPercent {
|
|
|
- numStr += "%"
|
|
|
- }
|
|
|
- return numStr
|
|
|
-}
|