Skip to content

Commit f3f6d2f

Browse files
authored
Merge pull request #187 from nyanshak/more-yaxis-fields
Add support for units and includeZero in Yaxis
2 parents 456ae6c + dbd5726 commit f3f6d2f

File tree

3 files changed

+88
-18
lines changed

3 files changed

+88
-18
lines changed

dashboards.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@ type GraphEvent struct {
5252
}
5353

5454
type Yaxis struct {
55-
Min *float64 `json:"min,omitempty"`
56-
AutoMin bool `json:"-"`
57-
Max *float64 `json:"max,omitempty"`
58-
AutoMax bool `json:"-"`
59-
Scale *string `json:"scale,omitempty"`
55+
Min *float64 `json:"min,omitempty"`
56+
AutoMin bool `json:"-"`
57+
Max *float64 `json:"max,omitempty"`
58+
AutoMax bool `json:"-"`
59+
Scale *string `json:"scale,omitempty"`
60+
IncludeZero *bool `json:"includeZero,omitempty"`
61+
IncludeUnits *bool `json:"units,omitempty"`
6062
}
6163

6264
// UnmarshalJSON is a Custom Unmarshal for Yaxis.Min/Yaxis.Max. If the datadog API

dashboards_test.go

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,33 @@ type YAxisTestSuite struct {
2525

2626
func (suite *YAxisTestSuite) SetupTest() {
2727
// Custom Y.Min, Y.Max
28-
suite.yJSON = []byte(`{"min":0,"max":1,"scale":"linear"}`)
28+
suite.yJSON = []byte(`{"min":0,"max":1,"scale":"linear","includeZero":true,"units":true}`)
2929
suite.yMarshalledJSON = suite.yJSON
3030
yMinFloat := float64(0)
3131
yMaxFloat := float64(1)
3232
yScale := "linear"
33+
yIncludeZero := true
34+
yIncludeUnits := true
3335
suite.y = Yaxis{
34-
Min: &yMinFloat,
35-
AutoMin: false,
36-
Max: &yMaxFloat,
37-
AutoMax: false,
38-
Scale: &yScale,
36+
Min: &yMinFloat,
37+
AutoMin: false,
38+
Max: &yMaxFloat,
39+
AutoMax: false,
40+
Scale: &yScale,
41+
IncludeZero: &yIncludeZero,
42+
IncludeUnits: &yIncludeUnits,
3943
}
4044
// Auto Y.Min, Y.Max
41-
suite.yAutoMinMaxJSON = []byte(`{"min":"auto","max":"auto","scale":"linear"}`)
42-
suite.yAutoMinMaxMarshalledJSON = []byte(`{"scale":"linear"}`)
45+
suite.yAutoMinMaxJSON = []byte(`{"min":"auto","max":"auto","scale":"linear","includeZero":true,"units":true}`)
46+
suite.yAutoMinMaxMarshalledJSON = []byte(`{"scale":"linear","includeZero":true,"units":true}`)
4347
suite.yAutoMinMax = Yaxis{
44-
Min: nil,
45-
AutoMin: true,
46-
Max: nil,
47-
AutoMax: true,
48-
Scale: &yScale,
48+
Min: nil,
49+
AutoMin: true,
50+
Max: nil,
51+
AutoMax: true,
52+
Scale: &yScale,
53+
IncludeZero: &yIncludeZero,
54+
IncludeUnits: &yIncludeUnits,
4955
}
5056
}
5157

datadog-accessors.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10863,6 +10863,68 @@ func (w *Widget) SetY(v int) {
1086310863
w.Y = &v
1086410864
}
1086510865

10866+
// GetIncludeUnits returns the IncludeUnits field if non-nil, zero value otherwise.
10867+
func (y *Yaxis) GetIncludeUnits() bool {
10868+
if y == nil || y.IncludeUnits == nil {
10869+
return false
10870+
}
10871+
return *y.IncludeUnits
10872+
}
10873+
10874+
// GetIncludeUnitsOk returns a tuple with the IncludeUnits field if it's non-nil, zero value otherwise
10875+
// and a boolean to check if the value has been set.
10876+
func (y *Yaxis) GetIncludeUnitsOk() (bool, bool) {
10877+
if y == nil || y.IncludeUnits == nil {
10878+
return false, false
10879+
}
10880+
return *y.IncludeUnits, true
10881+
}
10882+
10883+
// HasIncludeUnits returns a boolean if a field has been set.
10884+
func (y *Yaxis) HasIncludeUnits() bool {
10885+
if y != nil && y.IncludeUnits != nil {
10886+
return true
10887+
}
10888+
10889+
return false
10890+
}
10891+
10892+
// SetIncludeUnits allocates a new y.IncludeUnits and returns the pointer to it.
10893+
func (y *Yaxis) SetIncludeUnits(v bool) {
10894+
y.IncludeUnits = &v
10895+
}
10896+
10897+
// GetIncludeZero returns the IncludeZero field if non-nil, zero value otherwise.
10898+
func (y *Yaxis) GetIncludeZero() bool {
10899+
if y == nil || y.IncludeZero == nil {
10900+
return false
10901+
}
10902+
return *y.IncludeZero
10903+
}
10904+
10905+
// GetIncludeZeroOk returns a tuple with the IncludeZero field if it's non-nil, zero value otherwise
10906+
// and a boolean to check if the value has been set.
10907+
func (y *Yaxis) GetIncludeZeroOk() (bool, bool) {
10908+
if y == nil || y.IncludeZero == nil {
10909+
return false, false
10910+
}
10911+
return *y.IncludeZero, true
10912+
}
10913+
10914+
// HasIncludeZero returns a boolean if a field has been set.
10915+
func (y *Yaxis) HasIncludeZero() bool {
10916+
if y != nil && y.IncludeZero != nil {
10917+
return true
10918+
}
10919+
10920+
return false
10921+
}
10922+
10923+
// SetIncludeZero allocates a new y.IncludeZero and returns the pointer to it.
10924+
func (y *Yaxis) SetIncludeZero(v bool) {
10925+
y.IncludeZero = &v
10926+
}
10927+
1086610928
// GetMax returns the Max field if non-nil, zero value otherwise.
1086710929
func (y *Yaxis) GetMax() float64 {
1086810930
if y == nil || y.Max == nil {

0 commit comments

Comments
 (0)