refactor: add examples of chart
This commit is contained in:
parent
e558634dda
commit
4262b148ca
10 changed files with 796 additions and 100 deletions
29
series.go
29
series.go
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue