/
funnel.go
49 lines (41 loc) 路 1.29 KB
/
funnel.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
48
49
package charts
import (
"github.com/go-echarts/go-echarts/v2/opts"
"github.com/go-echarts/go-echarts/v2/render"
"github.com/go-echarts/go-echarts/v2/types"
)
// Funnel represents a funnel chart.
type Funnel struct {
BaseConfiguration
BaseActions
}
// Type returns the chart type.
func (*Funnel) Type() string { return types.ChartFunnel }
// NewFunnel creates a new funnel chart.
func NewFunnel() *Funnel {
c := &Funnel{}
c.initBaseConfiguration()
c.Renderer = render.NewChartRender(c, c.Validate)
return c
}
// AddSeries adds new data sets.
func (c *Funnel) AddSeries(name string, data []opts.FunnelData, options ...SeriesOpts) *Funnel {
series := SingleSeries{Name: name, Type: types.ChartFunnel, Data: data}
series.ConfigureSeriesOpts(options...)
c.MultiSeries = append(c.MultiSeries, series)
return c
}
// SetGlobalOptions sets options for the Funnel instance.
func (c *Funnel) SetGlobalOptions(options ...GlobalOpts) *Funnel {
c.BaseConfiguration.setBaseGlobalOptions(options...)
return c
}
// SetDispatchActions sets actions for the Gauge instance.
func (c *Funnel) SetDispatchActions(actions ...GlobalActions) *Funnel {
c.BaseActions.setBaseGlobalActions(actions...)
return c
}
// Validate validates the given configuration.
func (c *Funnel) Validate() {
c.Assets.Validate(c.AssetsHost)
}