|
@@ -1763,7 +1763,7 @@ func GetTableDataByMixedTableData(config [][]request.MixedTableCellDataReq, hide
|
|
|
}
|
|
|
showFormatValue := fmt.Sprintf("%v", cell.ShowFormatValue)
|
|
|
tmp.Monitor = showFormatValue
|
|
|
- tmpValue, err := strconv.ParseFloat(cell.ShowValue, 64)
|
|
|
+ _, err := strconv.ParseFloat(cell.ShowValue, 64)
|
|
|
if err == nil {
|
|
|
hasPercent := false
|
|
|
if styleConfig.Nt == "percent" {
|
|
@@ -1773,12 +1773,9 @@ func GetTableDataByMixedTableData(config [][]request.MixedTableCellDataReq, hide
|
|
|
tmp.Monitor = roundNumber(cell.ShowValue, *styleConfig.Decimal, hasPercent)
|
|
|
} else {
|
|
|
if hasPercent {
|
|
|
- tmpValue = tmpValue * 100
|
|
|
- tmpValueStr := strconv.FormatFloat(tmpValue, 'f', -1, 64)
|
|
|
- tmp.Monitor = tmpValueStr
|
|
|
- if hasPercent {
|
|
|
- tmp.Monitor += "%"
|
|
|
- }
|
|
|
+ numDecimal, _ := decimal.NewFromString(cell.ShowValue)
|
|
|
+ tmpStr := numDecimal.Mul(decimal.NewFromInt(100)).String()
|
|
|
+ tmp.Monitor = tmpStr + "%"
|
|
|
} else {
|
|
|
tmp.Monitor = cell.ShowValue
|
|
|
}
|
|
@@ -1832,11 +1829,11 @@ func GetTableDataByMixedTableData(config [][]request.MixedTableCellDataReq, hide
|
|
|
}
|
|
|
|
|
|
func roundNumber(num string, decimalPlaces int, hasPercent bool) string {
|
|
|
- numFloat, _ := strconv.ParseFloat(num, 64)
|
|
|
+ numDecimal, _ := decimal.NewFromString(num)
|
|
|
if hasPercent {
|
|
|
- numFloat = numFloat * 100
|
|
|
+ numDecimal = numDecimal.Mul(decimal.NewFromInt(100))
|
|
|
}
|
|
|
- numFloat, _ = decimal.NewFromFloat(numFloat).Round(int32(decimalPlaces)).Float64()
|
|
|
+ numFloat, _ := numDecimal.Round(int32(decimalPlaces)).Float64()
|
|
|
numStr := strconv.FormatFloat(numFloat, 'f', decimalPlaces, 64)
|
|
|
if hasPercent {
|
|
|
numStr += "%"
|