Debian Codegraph @

charts/kline.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 // Kline represents a kline chart.
10 type Kline struct {
11 RectChart
12 }
13
14 // Type returns the chart type.
15 func (*Kline) Type() string { return types.ChartKline }
16
17 // NewKLine creates a new kline chart.
18 func NewKLine() *Kline {
19 c := &Kline{}
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 *Kline) SetXAxis(xAxis interface{}) *Kline {
28 c.xAxisData = xAxis
29 return c
30 }
31
32 // AddSeries adds the new series.
33 func (c *Kline) AddSeries(name string, data []opts.KlineData, options ...SeriesOpts) *Kline {
34 series := SingleSeries{Name: name, Type: types.ChartKline, 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 *Kline) Validate() {
42 c.XAxisList[0].Data = c.xAxisData
43 c.Assets.Validate(c.AssetsHost)
44 }