refactor: support customize legend function
This commit is contained in:
parent
deb77f5761
commit
40b7eb3ee2
3 changed files with 207 additions and 16 deletions
9
axis.go
9
axis.go
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue