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

Support gauge typed panel #166

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
StatType
RowType
BarGaugeType
GaugeType
HeatmapType
)

Expand All @@ -58,6 +59,7 @@ type (
*RowPanel
*AlertlistPanel
*BarGaugePanel
*GaugePanel
*HeatmapPanel
*CustomPanel
}
Expand Down Expand Up @@ -133,7 +135,7 @@ type (
Bars bool `json:"bars"`
DashLength *uint `json:"dashLength,omitempty"`
Dashes *bool `json:"dashes,omitempty"`
Decimals *int `json:"decimals,omitempty"`
Decimals *int `json:"decimals,omitempty"`
Fill int `json:"fill"`
// Grid grid `json:"grid"` obsoleted in 4.1 by xaxis and yaxis

Expand Down Expand Up @@ -173,6 +175,11 @@ type (
} `json:"threshold"`
} `json:"defaults"`
}
GaugePanel struct {
CommonPanel
Targets []Target `json:"targets,omitempty"`
Styles []ColumnStyle `json:"styles"`
}
Options struct {
Orientation string `json:"orientation"`
TextMode string `json:"textMode"`
Expand Down Expand Up @@ -442,7 +449,7 @@ type (
Type string `json:"type"`
ColorMode *string `json:"colorMode,omitempty"`
Colors *[]string `json:"colors,omitempty"`
Decimals *int `json:"decimals,omitempty"`
Decimals *int `json:"decimals,omitempty"`
Thresholds *[]string `json:"thresholds,omitempty"`
Unit *string `json:"unit,omitempty"`
MappingType int `json:"mappingType,omitempty"`
Expand Down Expand Up @@ -967,6 +974,12 @@ func (p *Panel) UnmarshalJSON(b []byte) (err error) {
if err = json.Unmarshal(b, &heatmap); err == nil {
p.HeatmapPanel = &heatmap
}
case "gauge":
var gaugePanel GaugePanel
p.OfType = GaugeType
if err = json.Unmarshal(b, &gaugePanel); err == nil {
p.GaugePanel = &gaugePanel
}
case "row":
var rowpanel RowPanel
p.OfType = RowType
Expand Down Expand Up @@ -1046,6 +1059,12 @@ func (p *Panel) MarshalJSON() ([]byte, error) {
RowPanel
}{p.CommonPanel, *p.RowPanel}
return json.Marshal(outRow)
case GaugeType:
var outGauge = struct {
CommonPanel
GaugePanel
}{p.CommonPanel, *p.GaugePanel}
return json.Marshal(outGauge)
case HeatmapType:
var outHeatmap = struct {
CommonPanel
Expand Down