refactor: support customize legend function

This commit is contained in:
vicanso 2021-12-12 12:17:13 +08:00
parent deb77f5761
commit 40b7eb3ee2
3 changed files with 207 additions and 16 deletions

View file

@ -23,6 +23,7 @@
package charts
import (
"github.com/dustin/go-humanize"
"github.com/wcharczuk/go-chart/v2"
"github.com/wcharczuk/go-chart/v2/drawing"
)
@ -80,7 +81,13 @@ func GetYAxis(theme string) chart.YAxis {
A: 255,
}
return chart.YAxis{
ValueFormatter: func(v interface{}) string {
value, ok := v.(float64)
if !ok {
return ""
}
return humanize.Commaf(value)
},
AxisType: chart.YAxisSecondary,
GridMajorStyle: chart.Style{
StrokeColor: strokeColor,