Skip to content

Commit

Permalink
feat(gauge): add options 'progress', 'axistick' and 'detail' (#399)
Browse files Browse the repository at this point in the history
* feat(gauge): add options 'progress', 'axistick' and 'detail'

---------

Co-authored-by: Koy Zhuang <koy@ko8e24.top>
  • Loading branch information
simachri and Koooooo-7 committed Feb 10, 2024
1 parent a57ac99 commit 7fbb77b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
6 changes: 6 additions & 0 deletions charts/series.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ type SingleSeries struct {
Data interface{} `json:"data,omitempty"`
DatasetIndex int `json:"datasetIndex,omitempty"`

// Gauge
Progress *opts.Progress `json:"progress,omitempty"`
AxisTick *opts.AxisTick `json:"axisTick,omitempty"`
Detail *opts.Detail `json:"detail,omitempty"`
Title *opts.Title `json:"title,omitempty"`

// Shared below =====================================================
Large types.Bool `json:"large,omitempty"`
LargeThreshold int `json:"largeThreshold,omitempty"`
Expand Down
31 changes: 31 additions & 0 deletions opts/charts.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,37 @@ type CustomChart struct {
RenderItem types.FuncStr
}

// Progress is the options set for progress.
type Progress struct {
// Wether to show the progress
Show types.Bool `json:"show,omitempty"`
// Width of the progress in px
Width int `json:"width,omitempty"`
}

// Detail is the options set for detail (e.g. on a gauge).
type Detail struct {
// The content formatter of value
//
// 1. String template
// The template variable is {value}.
//
// 2. Callback function
// The format of callback function:
// (value: number) => string
Formatter types.FuncStr `json:"formatter,omitempty"`

// Font size of the value in px
FontSize int `json:"fontSize,omitempty"`

// Value position relative to the center of chart
// OffceCenter is provided as [x, y] where x and y are either a number (px, provided
// as string) or a percentage.
// Positive values move the chart value to [right, bottom], negative values vice
// versa.
OffsetCenter []string `json:"offsetCenter,omitempty"`
}

// CustomData
// https://echarts.apache.org/en/option.html#series-custom.data
type CustomData struct {
Expand Down
7 changes: 7 additions & 0 deletions opts/title.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,11 @@ type Title struct {
// borderRadius: [5, 5, 0, 0] // (clockwise upper left, upper right, bottom right and bottom left)
// FYI, use [1] is same to number 1
BorderRadius []int `json:"borderRadius,omitempty"`

// Value position relative to the center of chart
// OffceCenter is provided as [x, y] where x and y are either a number (px, provided
// as string) or a percentage.
// Positive values move the chart value to [right, bottom], negative values vice
// versa.
OffsetCenter []string `json:"offsetCenter,omitempty"`
}

0 comments on commit 7fbb77b

Please sign in to comment.