refactor: add examples of chart

This commit is contained in:
vicanso 2022-02-12 11:22:08 +08:00
parent e558634dda
commit 4262b148ca
10 changed files with 796 additions and 100 deletions

View file

@ -95,6 +95,35 @@ type Series struct {
MarkLine SeriesMarkLine
}
type PieSeriesOption struct {
Radius string
LabelShow bool
}
func NewPieSeriesList(values []float64, opts ...PieSeriesOption) []Series {
result := make([]Series, len(values))
var opt PieSeriesOption
if len(opts) != 0 {
opt = opts[0]
}
for index, v := range values {
s := Series{
Type: ChartTypePie,
Data: []SeriesData{
{
Value: v,
},
},
Radius: opt.Radius,
Label: SeriesLabel{
Show: opt.LabelShow,
},
}
result[index] = s
}
return result
}
type seriesSummary struct {
MaxIndex int
MaxValue float64