Skip to content

Commit

Permalink
update: remove limited action. (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
Koooooo-7 committed Feb 4, 2024
1 parent 7646fee commit 3b17b94
Show file tree
Hide file tree
Showing 20 changed files with 1 addition and 212 deletions.
29 changes: 0 additions & 29 deletions actions/global.go

This file was deleted.

49 changes: 0 additions & 49 deletions charts/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/go-echarts/go-echarts/v2/types"
"github.com/go-echarts/go-echarts/v2/util"

"github.com/go-echarts/go-echarts/v2/actions"
"github.com/go-echarts/go-echarts/v2/datasets"
"github.com/go-echarts/go-echarts/v2/opts"
"github.com/go-echarts/go-echarts/v2/render"
Expand All @@ -18,9 +17,6 @@ import (
// GlobalOpts sets the Global options for charts.
type GlobalOpts func(bc *BaseConfiguration)

// GlobalActions sets the Global actions for charts
type GlobalActions func(ba *BaseActions)

// BaseConfiguration represents an option set needed by all chart types.
type BaseConfiguration struct {
opts.Legend `json:"legend"`
Expand Down Expand Up @@ -85,12 +81,6 @@ type BaseConfiguration struct {
GridList []opts.Grid `json:"grid,omitempty"`
}

// BaseActions represents a dispatchAction set needed by all chart types.
type BaseActions struct {
actions.Type `json:"type,omitempty"`
actions.Areas `json:"areas,omitempty"`
}

// JSON wraps all the options to a map so that it could be used in the base template
//
// Get data in bytes
Expand All @@ -110,17 +100,6 @@ func (bc *BaseConfiguration) JSONNotEscaped() template.HTML {
return template.HTML(buff.String())
}

// JSONNotEscapedAction works like method JSON, but it returns a marshaled object whose characters will not be escaped in the template
func (ba *BaseActions) JSONNotEscapedAction() template.HTML {
obj := ba.json()
buff := bytes.NewBufferString("")
enc := json.NewEncoder(buff)
enc.SetEscapeHTML(false)
enc.Encode(obj)

return template.HTML(buff.String())
}

func (bc *BaseConfiguration) json() map[string]interface{} {
obj := map[string]interface{}{
"title": bc.Title,
Expand Down Expand Up @@ -257,34 +236,6 @@ func (bc *BaseConfiguration) setBaseGlobalOptions(opts ...GlobalOpts) {
}
}

func (ba *BaseActions) setBaseGlobalActions(opts ...GlobalActions) {
for _, opt := range opts {
opt(ba)
}
}

func (ba *BaseActions) json() map[string]interface{} {
obj := map[string]interface{}{
"type": ba.Type,
"areas": ba.Areas,
}
return obj
}

// WithAreas sets the areas of the action
func WithAreas(act actions.Areas) GlobalActions {
return func(ba *BaseActions) {
ba.Areas = act
}
}

// WithType sets the type of the action
func WithType(act actions.Type) GlobalActions {
return func(ba *BaseActions) {
ba.Type = act
}
}

// WithAngleAxisOps sets the angle of the axis.
func WithAngleAxisOps(opt opts.AngleAxis) GlobalOpts {
return func(bc *BaseConfiguration) {
Expand Down
7 changes: 0 additions & 7 deletions charts/funnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
// Funnel represents a funnel chart.
type Funnel struct {
BaseConfiguration
BaseActions
}

// Type returns the chart type.
Expand Down Expand Up @@ -37,12 +36,6 @@ func (c *Funnel) SetGlobalOptions(options ...GlobalOpts) *Funnel {
return c
}

// SetDispatchActions sets actions for the Gauge instance.
func (c *Funnel) SetDispatchActions(actions ...GlobalActions) *Funnel {
c.BaseActions.setBaseGlobalActions(actions...)
return c
}

// Validate validates the given configuration.
func (c *Funnel) Validate() {
c.Assets.Validate(c.AssetsHost)
Expand Down
7 changes: 0 additions & 7 deletions charts/gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
// Gauge represents a gauge chart.
type Gauge struct {
BaseConfiguration
BaseActions
}

// Type returns the chart type.
Expand Down Expand Up @@ -37,12 +36,6 @@ func (c *Gauge) SetGlobalOptions(options ...GlobalOpts) *Gauge {
return c
}

// SetDispatchActions sets actions for the Gauge instance.
func (c *Gauge) SetDispatchActions(actions ...GlobalActions) *Gauge {
c.BaseActions.setBaseGlobalActions(actions...)
return c
}

// Validate validates the given configuration.
func (c *Gauge) Validate() {
c.Assets.Validate(c.AssetsHost)
Expand Down
7 changes: 0 additions & 7 deletions charts/geo.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
// Geo represents a geo chart.
type Geo struct {
BaseConfiguration
BaseActions
}

// Type returns the chart type.
Expand Down Expand Up @@ -60,12 +59,6 @@ func (c *Geo) SetGlobalOptions(options ...GlobalOpts) *Geo {
return c
}

// SetDispatchActions sets actions for the Geo instance.
func (c *Geo) SetDispatchActions(actions ...GlobalActions) *Geo {
c.BaseActions.setBaseGlobalActions(actions...)
return c
}

// Validate validates the given configuration.
func (c *Geo) Validate() {
if c.Tooltip.Formatter == "" {
Expand Down
7 changes: 0 additions & 7 deletions charts/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
// Graph represents a graph chart.
type Graph struct {
BaseConfiguration
BaseActions
}

// Type returns the chart type.
Expand Down Expand Up @@ -37,12 +36,6 @@ func (c *Graph) SetGlobalOptions(options ...GlobalOpts) *Graph {
return c
}

// SetDispatchActions sets actions for the Graph instance.
func (c *Graph) SetDispatchActions(actions ...GlobalActions) *Graph {
c.BaseActions.setBaseGlobalActions(actions...)
return c
}

// Validate validates the given configuration.
func (c *Graph) Validate() {
// If there is no layout setting, default layout is set to "force".
Expand Down
7 changes: 0 additions & 7 deletions charts/liquid.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
// Liquid represents a liquid chart.
type Liquid struct {
BaseConfiguration
BaseActions
}

// Type returns the chart type.
Expand Down Expand Up @@ -39,12 +38,6 @@ func (c *Liquid) SetGlobalOptions(options ...GlobalOpts) *Liquid {
return c
}

// SetDispatchActions sets actions for the Liquid instance.
func (c *Liquid) SetDispatchActions(actions ...GlobalActions) *Liquid {
c.BaseActions.setBaseGlobalActions(actions...)
return c
}

// Validate validates the given configuration.
func (c *Liquid) Validate() {
c.Assets.Validate(c.AssetsHost)
Expand Down
7 changes: 0 additions & 7 deletions charts/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
// Map represents a map chart.
type Map struct {
BaseConfiguration
BaseActions

mapType string
}
Expand Down Expand Up @@ -46,12 +45,6 @@ func (c *Map) SetGlobalOptions(options ...GlobalOpts) *Map {
return c
}

// SetDispatchActions sets actions for the Radar instance.
func (c *Map) SetDispatchActions(actions ...GlobalActions) *Map {
c.BaseActions.setBaseGlobalActions(actions...)
return c
}

// Validate validates the given configuration.
func (c *Map) Validate() {
c.Assets.Validate(c.AssetsHost)
Expand Down
7 changes: 0 additions & 7 deletions charts/parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
// Parallel represents a parallel axis.
type Parallel struct {
BaseConfiguration
BaseActions
}

// Type returns the chart type.
Expand Down Expand Up @@ -38,12 +37,6 @@ func (c *Parallel) SetGlobalOptions(options ...GlobalOpts) *Parallel {
return c
}

// SetDispatchActions sets actions for the Radar instance.
func (c *Parallel) SetDispatchActions(actions ...GlobalActions) *Parallel {
c.BaseActions.setBaseGlobalActions(actions...)
return c
}

// Validate validates the given configuration.
func (c *Parallel) Validate() {
c.Assets.Validate(c.AssetsHost)
Expand Down
7 changes: 0 additions & 7 deletions charts/pie.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
// Pie represents a pie chart.
type Pie struct {
BaseConfiguration
BaseActions
}

// Type returns the chart type.
Expand Down Expand Up @@ -37,12 +36,6 @@ func (c *Pie) SetGlobalOptions(options ...GlobalOpts) *Pie {
return c
}

// SetDispatchActions sets actions for the Pie instance.
func (c *Pie) SetDispatchActions(actions ...GlobalActions) *Pie {
c.BaseActions.setBaseGlobalActions(actions...)
return c
}

// Validate validates the given configuration.
func (c *Pie) Validate() {
c.Assets.Validate(c.AssetsHost)
Expand Down
7 changes: 0 additions & 7 deletions charts/radar.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
// Radar represents a radar chart.
type Radar struct {
BaseConfiguration
BaseActions

// SymbolKeepAspect is whether to keep aspect for symbols in the form of path://.
SymbolKeepAspect types.Bool
Expand Down Expand Up @@ -42,12 +41,6 @@ func (c *Radar) SetGlobalOptions(options ...GlobalOpts) *Radar {
return c
}

// SetDispatchActions sets actions for the Radar instance.
func (c *Radar) SetDispatchActions(actions ...GlobalActions) *Radar {
c.BaseActions.setBaseGlobalActions(actions...)
return c
}

// Validate validates the given configuration.
func (c *Radar) Validate() {
c.Legend.Data = c.legends
Expand Down
11 changes: 0 additions & 11 deletions charts/rectangle.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,12 @@ func WithYAxisOpts(opt opts.YAxis, index ...int) GlobalOpts {
// RectConfiguration contains options for the rectangular coordinates.
type RectConfiguration struct {
BaseConfiguration
BaseActions
}

func (rect *RectConfiguration) setRectGlobalOptions(options ...GlobalOpts) {
rect.BaseConfiguration.setBaseGlobalOptions(options...)
}

func (rect *RectConfiguration) setRectGlobalActions(options ...GlobalActions) {
rect.BaseActions.setBaseGlobalActions(options...)
}

// RectChart is a chart in RectChart coordinate.
type RectChart struct {
RectConfiguration
Expand All @@ -84,12 +79,6 @@ func (rc *RectChart) SetGlobalOptions(options ...GlobalOpts) *RectChart {
return rc
}

// SetDispatchActions sets actions for the RectChart instance.
func (rc *RectChart) SetDispatchActions(options ...GlobalActions) *RectChart {
rc.RectConfiguration.setRectGlobalActions(options...)
return rc
}

// Overlap composes multiple charts into one single canvas.
// It is only suited for some of the charts which are in rectangular coordinate.
// Supported charts: Bar/BoxPlot/Line/Scatter/EffectScatter/Kline/HeatMap/Custom
Expand Down
7 changes: 0 additions & 7 deletions charts/sankey.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
// Sankey represents a sankey chart.
type Sankey struct {
BaseConfiguration
BaseActions
}

// Type returns the chart type.
Expand Down Expand Up @@ -37,12 +36,6 @@ func (c *Sankey) SetGlobalOptions(options ...GlobalOpts) *Sankey {
return c
}

// SetDispatchActions sets actions for the Sankey instance.
func (c *Sankey) SetDispatchActions(actions ...GlobalActions) *Sankey {
c.BaseActions.setBaseGlobalActions(actions...)
return c
}

// Validate validates the given configuration.
func (c *Sankey) Validate() {
c.Assets.Validate(c.AssetsHost)
Expand Down
7 changes: 0 additions & 7 deletions charts/sunburst.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
// Sunburst represents a sunburst chart.
type Sunburst struct {
BaseConfiguration
BaseActions
}

// Type returns the chart type.
Expand Down Expand Up @@ -37,12 +36,6 @@ func (c *Sunburst) SetGlobalOptions(options ...GlobalOpts) *Sunburst {
return c
}

// SetDispatchActions sets actions for the Sunburst instance.
func (c *Sunburst) SetDispatchActions(actions ...GlobalActions) *Sunburst {
c.BaseActions.setBaseGlobalActions(actions...)
return c
}

// Validate validates the given configuration.
func (c *Sunburst) Validate() {
c.Assets.Validate(c.AssetsHost)
Expand Down
7 changes: 0 additions & 7 deletions charts/themeriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
// ThemeRiver represents a theme river chart.
type ThemeRiver struct {
BaseConfiguration
BaseActions
}

// Type returns the chart type.
Expand Down Expand Up @@ -42,12 +41,6 @@ func (c *ThemeRiver) SetGlobalOptions(options ...GlobalOpts) *ThemeRiver {
return c
}

// SetDispatchActions sets actions for the ThemeRiver instance.
func (c *ThemeRiver) SetDispatchActions(actions ...GlobalActions) *ThemeRiver {
c.BaseActions.setBaseGlobalActions(actions...)
return c
}

// Validate validates the given configuration.
func (c *ThemeRiver) Validate() {
c.Assets.Validate(c.AssetsHost)
Expand Down

0 comments on commit 3b17b94

Please sign in to comment.