feat: support legend render function

This commit is contained in:
vicanso 2022-01-29 16:35:45 +08:00
parent ffbda8f214
commit c4b5ac3f42
5 changed files with 140 additions and 10 deletions

18
util.go
View file

@ -22,7 +22,12 @@
package charts
import "github.com/wcharczuk/go-chart/v2"
import (
"strconv"
"strings"
"github.com/wcharczuk/go-chart/v2"
)
func TrueFlag() *bool {
t := true
@ -90,3 +95,14 @@ func reverseIntSlice(intList []int) {
intList[i], intList[j] = intList[j], intList[i]
}
}
func convertPercent(value string) float64 {
if !strings.HasSuffix(value, "%") {
return -1
}
v, err := strconv.Atoi(strings.ReplaceAll(value, "%", ""))
if err != nil {
return -1
}
return float64(v) / 100
}