forked from go-echarts/go-echarts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
themeriver.go
executable file
路47 lines (40 loc) 路 1.25 KB
/
themeriver.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package charts
import (
"github.com/KiVirgil/go-echarts/v2/opts"
"github.com/KiVirgil/go-echarts/v2/render"
"github.com/KiVirgil/go-echarts/v2/types"
)
// ThemeRiver represents a theme river chart.
type ThemeRiver struct {
BaseConfiguration
}
// Type returns the chart type.
func (ThemeRiver) Type() string { return types.ChartThemeRiver }
// NewThemeRiver creates a new theme river chart.
func NewThemeRiver() *ThemeRiver {
c := &ThemeRiver{}
c.initBaseConfiguration()
c.Renderer = render.NewChartRender(c, c.Validate)
c.hasSingleAxis = true
return c
}
// AddSeries adds new data sets.
func (c *ThemeRiver) AddSeries(name string, data []opts.ThemeRiverData, options ...SeriesOpts) *ThemeRiver {
cd := make([][3]interface{}, len(data))
for i := 0; i < len(data); i++ {
cd[i] = data[i].ToList()
}
series := SingleSeries{Name: name, Type: types.ChartThemeRiver, Data: cd}
series.configureSeriesOpts(options...)
c.MultiSeries = append(c.MultiSeries, series)
return c
}
// SetGlobalOptions sets options for the ThemeRiver instance.
func (c *ThemeRiver) SetGlobalOptions(options ...GlobalOpts) *ThemeRiver {
c.BaseConfiguration.setBaseGlobalOptions(options...)
return c
}
// Validate
func (c *ThemeRiver) Validate() {
c.Assets.Validate(c.AssetsHost)
}