Debian Codegraph @

charts/line.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 // Line represents a line chart.
10 type Line struct {
11 RectChart
12 }
13
14 // Type returns the chart type.
15 func (*Line) Type() string { return types.ChartLine }
16
17 // NewLine creates a new line chart.
18 func NewLine() *Line {
19 c := &Line{}
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 *Line) SetXAxis(x interface{}) *Line {
28 c.xAxisData = x
29 return c
30 }
31
32 // AddSeries adds the new series.
33 func (c *Line) AddSeries(name string, data []opts.LineData, options ...SeriesOpts) *Line {
34 series := SingleSeries{Name: name, Type: types.ChartLine, Data: data}
35 series.InitSeriesDefaultOpts(c.BaseConfiguration)
36 series.ConfigureSeriesOpts(options...)
37 c.MultiSeries = append(c.MultiSeries, series)
38 return c
39 }
40
41 // Validate validates the given configuration.
42 func (c *Line) Validate() {
43 c.XAxisList[0].Data = c.xAxisData
44 c.Assets.Validate(c.AssetsHost)
45 }