Debian Codegraph @

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