Debian Codegraph @

charts/sankey.go

raw symbols SCIP
1 package charts
2
3 import (
4 "github.com/go-echarts/go-echarts/v2/opts"
5 "github.com/go-echarts/go-echarts/v2/render"
6 "github.com/go-echarts/go-echarts/v2/types"
7 )
8
9 // Sankey represents a sankey chart.
10 type Sankey struct {
11 BaseConfiguration
12 }
13
14 // Type returns the chart type.
15 func (*Sankey) Type() string { return types.ChartSankey }
16
17 // NewSankey creates a new sankey chart.
18 func NewSankey() *Sankey {
19 c := &Sankey{}
20 c.initBaseConfiguration()
21 c.Renderer = render.NewChartRender(c, c.Validate)
22 return c
23 }
24
25 // AddSeries adds new data sets.
26 func (c *Sankey) AddSeries(name string, nodes []opts.SankeyNode, links []opts.SankeyLink, options ...SeriesOpts) *Sankey {
27 series := SingleSeries{Name: name, Type: types.ChartSankey, Data: nodes, Links: links}
28 series.ConfigureSeriesOpts(options...)
29 c.MultiSeries = append(c.MultiSeries, series)
30 return c
31 }
32
33 // SetGlobalOptions sets options for the Sankey instance.
34 func (c *Sankey) SetGlobalOptions(options ...GlobalOpts) *Sankey {
35 c.BaseConfiguration.setBaseGlobalOptions(options...)
36 return c
37 }
38
39 // Validate validates the given configuration.
40 func (c *Sankey) Validate() {
41 c.Assets.Validate(c.AssetsHost)
42 }