adding percent value format
This commit is contained in:
parent
e7c2568a69
commit
1cbfb53b11
2 changed files with 11 additions and 0 deletions
|
|
@ -37,6 +37,15 @@ func FloatValueFormatter(v interface{}) string {
|
|||
return FloatValueFormatterWithFormat(v, DefaultFloatFormat)
|
||||
}
|
||||
|
||||
// PercentValueFormatter is a formatter for percent values.
|
||||
// NOTE: it normalizes the values, i.e. multiplies by 100.0.
|
||||
func PercentValueFormatter(v interface{}) string {
|
||||
if typed, isTyped := v.(float64); isTyped {
|
||||
return FloatValueFormatterWithFormat(typed*100.0, DefaultPercentValueFormat)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// FloatValueFormatterWithFormat is a ValueFormatter for float64 with a given format.
|
||||
func FloatValueFormatterWithFormat(v interface{}, floatFormat string) string {
|
||||
if typed, isTyped := v.(float64); isTyped {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue