Debian Codegraph @

charts/scatter.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 // Scatter represents a scatter chart.
10 type Scatter struct {
11 RectChart
12 }
13
14 // Type returns the chart type.
15 func (*Scatter) Type() string { return types.ChartScatter }
16
17 // NewScatter creates a new scatter chart.
18 func NewScatter() *Scatter {
19 c := &Scatter{}
20 c.initBaseConfiguration()
21 c.Renderer = render.NewChartRender(c, c.Validate)
22 c.hasXYAxis = true
23 return c
24 }
25
26 // SetXAxis adds the X axis.
27 func (c *Scatter) SetXAxis(x interface{}) *Scatter {
28 c.xAxisData = x
29 return c
30 }
31
32 // AddSeries adds the new series.
33 func (c *Scatter) AddSeries(name string, data []opts.ScatterData, options ...SeriesOpts) *Scatter {
34 series := SingleSeries{Name: name, Type: types.ChartScatter, Data: data}
35 series.ConfigureSeriesOpts(options...)
36 c.MultiSeries = append(c.MultiSeries, series)
37 return c
38 }
39
40 // Validate validates the given configuration.
41 func (c *Scatter) Validate() {
42 c.XAxisList[0].Data = c.xAxisData
43 c.Assets.Validate(c.AssetsHost)
44 }