Skip to content

Commit

Permalink
update(markArea): add new MarkAreaData to suit data struct (#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
Koooooo-7 committed Jun 12, 2024
1 parent 2308209 commit a872ade
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
33 changes: 33 additions & 0 deletions charts/series.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,39 @@ func WithMarkAreaNameCoordItemOpts(opt ...opts.MarkAreaNameCoordItem) SeriesOpts
}
}

// WithMarkAreaData0 sets the markArea.data.0
func WithMarkAreaData0(data0 opts.MarkAreaData0) SeriesOpts {
return func(s *SingleSeries) {
if s.MarkAreas == nil {
s.MarkAreas = &opts.MarkAreas{}
}
s.MarkAreas.Data = append(s.MarkAreas.Data, data0)
}
}

// WithMarkAreaData1 sets the markArea.data.1
func WithMarkAreaData1(data1 opts.MarkAreaData1) SeriesOpts {
return func(s *SingleSeries) {
if s.MarkAreas == nil {
s.MarkAreas = &opts.MarkAreas{}
}
s.MarkAreas.Data = append(s.MarkAreas.Data, data1)
}
}

// WithMarkAreaData sets the markArea.data each item as array
// See https://echarts.apache.org/en/option.html#series-candlestick.markArea.data
func WithMarkAreaData(datas ...[]opts.MarkAreaData) SeriesOpts {
return func(s *SingleSeries) {
if s.MarkAreas == nil {
s.MarkAreas = &opts.MarkAreas{}
}
for _, d := range datas {
s.MarkAreas.Data = append(s.MarkAreas.Data, d)
}
}
}

// WithMarkAreaNameXAxisItemOpts sets the X axis of the MarkLine.
func WithMarkAreaNameXAxisItemOpts(opt ...opts.MarkAreaNameXAxisItem) SeriesOpts {
return func(s *SingleSeries) {
Expand Down
37 changes: 37 additions & 0 deletions opts/series.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ type LabelLine struct {
LineStyle *LineStyle `json:"lineStyle,omitempty"`
}

// Blur Configurations of blur state. Whether to blur follows the series.
type Blur struct {

// the blur style of item
ItemStyle *ItemStyle `json:"itemStyle,omitempty"`

// the blur style of label
Label *Label `json:"label,omitempty"`
}

// Emphasis is the style when it is highlighted, like being hovered by mouse, or highlighted via legend connect.
type Emphasis struct {
// the emphasis style of label
Expand Down Expand Up @@ -264,13 +274,40 @@ type MarkAreas struct {
MarkAreaStyle
}

// MarkAreaData a generic Data struct
type MarkAreaData struct {
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
ValueDim int `json:"valueDim,omitempty"`
Coord interface{} `json:"coord,omitempty"`
X interface{} `json:"x,omitempty"`
Y interface{} `json:"y,omitempty"`
XAxis interface{} `json:"xAxis,omitempty"`
YAxis interface{} `json:"YAxis,omitempty"`
MarkAreaStyle
}

type MarkAreaData0 struct {
LeftTop MarkAreaData `json:"0,omitempty"`
}

type MarkAreaData1 struct {
RightBottom MarkAreaData `json:"1,omitempty"`
}

// MarkAreaStyle contains styling options for a MarkArea.
type MarkAreaStyle struct {
// Mark area text options.
Label *Label `json:"label,omitempty"`

// ItemStyle settings
ItemStyle *ItemStyle `json:"itemStyle,omitempty"`

// Emphasis settings
Emphasis *Emphasis `json:"emphasis,omitempty"`

// Blur settings
Blur *Blur `json:"blur,omitempty"`
}

// MarkAreaNameTypeItem represents type for a MarkArea.
Expand Down

0 comments on commit a872ade

Please sign in to comment.