feat: support mark point for line chart

This commit is contained in:
vicanso 2022-02-08 23:16:30 +08:00
parent 524eb79a8e
commit c0bb1654c2
11 changed files with 148 additions and 16 deletions

13
util.go
View file

@ -26,6 +26,7 @@ import (
"strconv"
"strings"
"github.com/dustin/go-humanize"
"github.com/wcharczuk/go-chart/v2"
)
@ -109,3 +110,15 @@ func toFloatPoint(f float64) *float64 {
v := f
return &v
}
func commafWithDigits(value float64) string {
decimals := 2
m := float64(1000 * 1000)
if value >= m {
return humanize.CommafWithDigits(value/m, decimals) + " M"
}
k := float64(1000)
if value >= k {
return humanize.CommafWithDigits(value/k, decimals) + " K"
}
return humanize.CommafWithDigits(value, decimals)
}