Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added MarkAreaDataItem #288

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
71 changes: 5 additions & 66 deletions charts/series.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,13 @@ func WithMarkLineNameYAxisItemOpts(opt ...opts.MarkLineNameYAxisItem) SeriesOpts
}
}

// WithMarkAreaNameTypeItemOpts sets the type of the MarkArea.
func WithMarkAreaNameTypeItemOpts(opt ...opts.MarkAreaNameTypeItem) SeriesOpts {
// WithMarkAreaDataItem adds a row to data of the MarkArea.
func WithMarkAreaDataItem(a, b opts.MarkAreaDataItem) SeriesOpts {
return func(s *SingleSeries) {
if s.MarkAreas == nil {
s.MarkAreas = &opts.MarkAreas{}
}
for _, o := range opt {
s.MarkAreas.Data = append(s.MarkAreas.Data, o)
}
s.MarkAreas.Data = append(s.MarkAreas.Data, []interface{}{a, b})
}
}

Expand All @@ -445,55 +443,8 @@ func WithMarkAreaStyleOpts(opt opts.MarkAreaStyle) SeriesOpts {
}
}

// WithMarkAreaNameCoordItemOpts sets the coordinates of the MarkLine.
func WithMarkAreaNameCoordItemOpts(opt ...opts.MarkAreaNameCoordItem) SeriesOpts {
type MANameCoord struct {
Name string `json:"name,omitempty"`
ItemStyle *opts.ItemStyle `json:"itemStyle"`
Coord []interface{} `json:"coord"`
}
return func(s *SingleSeries) {
if s.MarkAreas == nil {
s.MarkAreas = &opts.MarkAreas{}
}
for _, o := range opt {
s.MarkAreas.Data = append(
s.MarkAreas.Data,
[]MANameCoord{
{Name: o.Name, ItemStyle: o.ItemStyle, Coord: o.Coordinate0},
{Coord: o.Coordinate1},
},
)
}
}
}

// WithMarkAreaNameXAxisItemOpts sets the X axis of the MarkLine.
func WithMarkAreaNameXAxisItemOpts(opt ...opts.MarkAreaNameXAxisItem) SeriesOpts {
return func(s *SingleSeries) {
if s.MarkAreas == nil {
s.MarkAreas = &opts.MarkAreas{}
}
for _, o := range opt {
s.MarkAreas.Data = append(s.MarkAreas.Data, o)
}
}
}

// WithMarkAreaNameYAxisItemOpts sets the Y axis of the MarkLine.
func WithMarkAreaNameYAxisItemOpts(opt ...opts.MarkAreaNameYAxisItem) SeriesOpts {
return func(s *SingleSeries) {
if s.MarkAreas == nil {
s.MarkAreas = &opts.MarkAreas{}
}
for _, o := range opt {
s.MarkAreas.Data = append(s.MarkAreas.Data, o)
}
}
}

// WithMarkPointNameTypeItemOpts sets the type of the MarkPoint.
func WithMarkPointNameTypeItemOpts(opt ...opts.MarkPointNameTypeItem) SeriesOpts {
// WithMarkPointDataItem sets the data of the MarkPoint.
func WithMarkPointDataItem(opt ...opts.MarkPointDataItem) SeriesOpts {
return func(s *SingleSeries) {
if s.MarkPoints == nil {
s.MarkPoints = &opts.MarkPoints{}
Expand All @@ -515,18 +466,6 @@ func WithMarkPointStyleOpts(opt opts.MarkPointStyle) SeriesOpts {
}
}

// WithMarkPointNameCoordItemOpts sets the coordinated of the MarkPoint.
func WithMarkPointNameCoordItemOpts(opt ...opts.MarkPointNameCoordItem) SeriesOpts {
return func(s *SingleSeries) {
if s.MarkPoints == nil {
s.MarkPoints = &opts.MarkPoints{}
}
for _, o := range opt {
s.MarkPoints.Data = append(s.MarkPoints.Data, o)
}
}
}

func (s *SingleSeries) InitSeriesDefaultOpts(c BaseConfiguration) {
util.SetDefaultValue(s)
// some special inherited options from BaseConfiguration
Expand Down
94 changes: 46 additions & 48 deletions opts/series.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ type LabelLine struct {
LineStyle *LineStyle `json:"lineStyle,omitempty"`
}

// Blur is the style when it is blurred.
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 @@ -259,8 +269,7 @@ type MarkAreaStyle struct {
ItemStyle *ItemStyle `json:"itemStyle,omitempty"`
}

// MarkAreaNameTypeItem represents type for a MarkArea.
type MarkAreaNameTypeItem struct {
type MarkAreaDataItem struct {
// Mark area name.
Name string `json:"name,omitempty"`

Expand All @@ -275,48 +284,34 @@ type MarkAreaNameTypeItem struct {

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

// MarkAreaNameYAxisItem defines a MarkArea on a Y axis.
type MarkAreaNameYAxisItem struct {
// Mark area name
Name string `json:"name,omitempty"`
// Specify the dimension on which min, max, average are calculated, available when type used.
// The value can be 0 (means xAxis, radiusAxis) or 1 (means yAxis, angleAxis),
// using the dimension of the first axis by default.
ValueIndex int `json:"valueIndex,omitempty"`

// Y axis data
YAxis interface{} `json:"yAxis,omitempty"`
}

// MarkAreaNameXAxisItem defines a MarkArea on a X axis.
type MarkAreaNameXAxisItem struct {
// Mark area name
Name string `json:"name,omitempty"`

// X axis data
XAxis interface{} `json:"xAxis,omitempty"`
}

// MarkAreaNameCoordItem represents coordinates for a MarkArea.
type MarkAreaNameCoordItem struct {
// Mark area name
Name string `json:"name,omitempty"`
// Mark point text options.
Label *Label `json:"label,omitempty"`

// Mark area start coordinate
Coordinate0 []interface{}
// The format is [start coordinate, end coordinate], where the coordinate system can be x, y on cartesian, or radius, angle on polar.
Coord []interface{} `json:"coord,omitempty"`

// Mark area end coordinate
Coordinate1 []interface{}
// x value on screen coordinate system, can be pixel number (like 5), or percent value (like '20%').
X interface{} `json:"x,omitempty"`

// Works only when type is assigned.
// It is used to state the dimension used to calculate maximum value or minimum value.
// It may be the direct name of a dimension, like x,
// or angle for line charts, or open, or close for candlestick charts.
ValueDim string `json:"valueDim,omitempty"`
// y value on screen coordinate system, can be pixel number (like 5), or percent value (like '20%').
Y interface{} `json:"y,omitempty"`

// Mark point text options.
Label *Label `json:"label,omitempty"`
// Emphasis settings in this series data.
Emphasis *Emphasis `json:"emphasis,omitempty"`

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

// MarkPoints represents a series of markpoints.
Expand All @@ -341,8 +336,8 @@ type MarkPointStyle struct {
Label *Label `json:"label,omitempty"`
}

// MarkPointNameTypeItem represents type for a MarkPoint.
type MarkPointNameTypeItem struct {
// MarkPointDataItem represents data for a MarkPoint.
type MarkPointDataItem struct {
// Name of markpoint
Name string `json:"name,omitempty"`

Expand All @@ -357,31 +352,17 @@ type MarkPointNameTypeItem struct {

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

// MarkPointNameCoordItem represents coordinates for a MarkPoint.
type MarkPointNameCoordItem struct {
// Name of markpoint
Name string `json:"name,omitempty"`

// Mark point coordinate
// https://echarts.apache.org/en/option.html#series-candlestick.markPoint.data.coord
Coordinate []interface{} `json:"coord,omitempty"`

// Value in mark point
Value string `json:"value,omitempty"`

// Works only when type is assigned.
// It is used to state the dimension used to calculate maximum value or minimum value.
// It may be the direct name of a dimension, like x,
// or angle for line charts, or open, or close for candlestick charts.
ValueDim string `json:"valueDim,omitempty"`

// Mark point text options.
Label *Label `json:"label,omitempty"`

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

// Symbol type
// Options: "circle", "rect", "roundRect", "triangle", "diamond", "pin", "arrow", "none"
Symbol string `json:"symbol,omitempty"`
Expand All @@ -391,6 +372,23 @@ type MarkPointNameCoordItem struct {

// Symbol rotate.
SymbolRotate float32 `json:"symbolRotate,omitempty"`

// Y axis data
YAxis interface{} `json:"yAxis,omitempty"`

// X axis data
XAxis interface{} `json:"xAxis,omitempty"`

// x value on screen coordinate system, can be pixel number (like 5), or percent value (like '20%').
X interface{} `json:"x,omitempty"`

// y value on screen coordinate system, can be pixel number (like 5), or percent value (like '20%').
Y interface{} `json:"y,omitempty"`

// Emphasis settings in this series data.
Emphasis *Emphasis `json:"emphasis,omitempty"`

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

// RippleEffect is the option set for the ripple effect.
Expand Down