Skip to content

Commit c2968ea

Browse files
authored
feat(observability-lib): add new overrides for lineStyle and color (#1660)
1 parent 36ed009 commit c2968ea

File tree

1 file changed

+50
-7
lines changed

1 file changed

+50
-7
lines changed

observability-lib/grafana/overrides.go

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,26 @@ type Property struct {
8181
type ColorMode string
8282

8383
const (
84-
ColorModeFixed ColorMode = "fixed"
84+
ColorModeFixed ColorMode = "fixed"
85+
ColorModeContinuousYlRd ColorMode = "continuous-YlRd"
8586
)
8687

87-
type ColorPropertyOptions struct {
88-
Mode ColorMode
89-
FixedColor string
88+
func NewColorModeFixedProperty(fixedColor string) *Property {
89+
return &Property{
90+
ID: "color",
91+
Value: map[string]any{
92+
"mode": ColorModeFixed,
93+
"fixedColor": fixedColor,
94+
},
95+
}
9096
}
9197

92-
func NewColorProperty(options *ColorPropertyOptions) *Property {
98+
func NewColorModeContinuousYlRdProperty(seriesBy string) *Property {
9399
return &Property{
94100
ID: "color",
95101
Value: map[string]any{
96-
"mode": options.Mode,
97-
"fixedColor": options.FixedColor,
102+
"mode": ColorModeContinuousYlRd,
103+
"seriesBy": seriesBy,
98104
},
99105
}
100106
}
@@ -183,3 +189,40 @@ func NewCellOptions(options *CellOptionsOptions) *Property {
183189
},
184190
}
185191
}
192+
193+
type LineStyleMode string
194+
195+
const (
196+
LineStyleSolid LineStyleMode = "solid"
197+
LineStyleDashed LineStyleMode = "dashed"
198+
LineStyleDotted LineStyleMode = "dotted"
199+
)
200+
201+
func NewLineStyleSolidProperty() *Property {
202+
return &Property{
203+
ID: "custom.lineStyle",
204+
Value: map[string]any{
205+
"fill": LineStyleSolid,
206+
},
207+
}
208+
}
209+
210+
func NewLineStyleDashedProperty(gaps ...int) *Property {
211+
return &Property{
212+
ID: "custom.lineStyle",
213+
Value: map[string]any{
214+
"fill": LineStyleDashed,
215+
"dash": gaps,
216+
},
217+
}
218+
}
219+
220+
func NewLineStyleDottedProperty(gaps ...int) *Property {
221+
return &Property{
222+
ID: "custom.lineStyle",
223+
Value: map[string]any{
224+
"fill": LineStyleDotted,
225+
"dash": gaps,
226+
},
227+
}
228+
}

0 commit comments

Comments
 (0)