feat(pkger): extend dashboards to capture position fields for xy and line plus stat charts
parent
cf96cc4a84
commit
51500396b3
|
@ -141,6 +141,7 @@ func convertCellView(cv cellView) chart {
|
|||
ch.Shade = p.ShadeBelow
|
||||
ch.XCol = p.XColumn
|
||||
ch.YCol = p.YColumn
|
||||
ch.Position = p.Position
|
||||
case influxdb.SingleStatViewProperties:
|
||||
setCommon(chartKindSingleStat, p.ViewColors, p.DecimalPlaces, p.Queries)
|
||||
setNoteFixes(p.Note, p.ShowNoteWhenEmpty, p.Prefix, p.Suffix)
|
||||
|
@ -165,6 +166,7 @@ func convertCellView(cv cellView) chart {
|
|||
ch.Shade = p.ShadeBelow
|
||||
ch.XCol = p.XColumn
|
||||
ch.YCol = p.YColumn
|
||||
ch.Position = p.Position
|
||||
}
|
||||
|
||||
return ch
|
||||
|
|
|
@ -1048,6 +1048,7 @@ func (c chart) properties() influxdb.ViewProperties {
|
|||
Queries: c.Queries.influxDashQueries(),
|
||||
ViewColors: c.Colors.influxViewColors(),
|
||||
Axes: c.Axes.influxAxes(),
|
||||
Position: c.Position,
|
||||
}
|
||||
case chartKindXY:
|
||||
return influxdb.XYViewProperties{
|
||||
|
@ -1062,6 +1063,7 @@ func (c chart) properties() influxdb.ViewProperties {
|
|||
ViewColors: c.Colors.influxViewColors(),
|
||||
Axes: c.Axes.influxAxes(),
|
||||
Geom: c.Geom,
|
||||
Position: c.Position,
|
||||
}
|
||||
default:
|
||||
return nil
|
||||
|
@ -1100,14 +1102,27 @@ func (c chart) validProperties() []validationErr {
|
|||
case chartKindSingleStatPlusLine:
|
||||
fails = append(fails, c.Colors.hasTypes(colorTypeText)...)
|
||||
fails = append(fails, c.Axes.hasAxes("x", "y")...)
|
||||
fails = append(fails, validPosition(c.Position)...)
|
||||
case chartKindXY:
|
||||
fails = append(fails, validGeometry(c.Geom)...)
|
||||
fails = append(fails, c.Axes.hasAxes("x", "y")...)
|
||||
fails = append(fails, validPosition(c.Position)...)
|
||||
}
|
||||
|
||||
return fails
|
||||
}
|
||||
|
||||
func validPosition(pos string) []validationErr {
|
||||
pos = strings.ToLower(pos)
|
||||
if pos != "" && pos != "overlaid" && pos != "stacked" {
|
||||
return []validationErr{{
|
||||
Field: fieldChartPosition,
|
||||
Msg: fmt.Sprintf("invalid position supplied %q; valid positions is one of [overlaid, stacked]", pos),
|
||||
}}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var geometryTypes = map[string]bool{
|
||||
"line": true,
|
||||
"step": true,
|
||||
|
|
|
@ -686,7 +686,7 @@ spec:
|
|||
})
|
||||
})
|
||||
|
||||
t.Run("single dashboard heatmap chart", func(t *testing.T) {
|
||||
t.Run("single heatmap chart", func(t *testing.T) {
|
||||
testfileRunner(t, "testdata/dashboard_heatmap", func(t *testing.T, pkg *Pkg) {
|
||||
sum := pkg.Summary()
|
||||
require.Len(t, sum.Dashboards, 1)
|
||||
|
@ -934,7 +934,7 @@ spec:
|
|||
})
|
||||
})
|
||||
|
||||
t.Run("single dashboard histogram chart", func(t *testing.T) {
|
||||
t.Run("single histogram chart", func(t *testing.T) {
|
||||
testfileRunner(t, "testdata/dashboard_histogram", func(t *testing.T, pkg *Pkg) {
|
||||
sum := pkg.Summary()
|
||||
require.Len(t, sum.Dashboards, 1)
|
||||
|
@ -1176,7 +1176,7 @@ spec:
|
|||
})
|
||||
})
|
||||
|
||||
t.Run("single dashboard markdown chart", func(t *testing.T) {
|
||||
t.Run("single markdown chart", func(t *testing.T) {
|
||||
testfileRunner(t, "testdata/dashboard_markdown", func(t *testing.T, pkg *Pkg) {
|
||||
sum := pkg.Summary()
|
||||
require.Len(t, sum.Dashboards, 1)
|
||||
|
@ -2029,6 +2029,7 @@ spec:
|
|||
assert.Equal(t, int32(1), props.DecimalPlaces.Digits)
|
||||
assert.Equal(t, "days", props.Suffix)
|
||||
assert.Equal(t, "sumtin", props.Prefix)
|
||||
assert.Equal(t, "overlaid", props.Position)
|
||||
assert.Equal(t, "leg_type", props.Legend.Type)
|
||||
assert.Equal(t, "horizontal", props.Legend.Orientation)
|
||||
|
||||
|
@ -2400,6 +2401,7 @@ spec:
|
|||
assert.Equal(t, true, props.ShadeBelow)
|
||||
assert.Equal(t, "xy chart note", props.Note)
|
||||
assert.True(t, props.ShowNoteWhenEmpty)
|
||||
assert.Equal(t, "stacked", props.Position)
|
||||
|
||||
require.Len(t, props.Queries, 1)
|
||||
q := props.Queries[0]
|
||||
|
|
|
@ -953,6 +953,7 @@ func TestService(t *testing.T) {
|
|||
ViewColors: []influxdb.ViewColor{{Type: "text", Hex: "red"}},
|
||||
XColumn: "x",
|
||||
YColumn: "y",
|
||||
Position: "stacked",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -975,6 +976,7 @@ func TestService(t *testing.T) {
|
|||
ViewColors: []influxdb.ViewColor{{Type: "text", Hex: "red"}},
|
||||
XColumn: "x",
|
||||
YColumn: "y",
|
||||
Position: "overlaid",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
"shade": true,
|
||||
"xColumn": "_time",
|
||||
"yColumn": "_value",
|
||||
"position": "overlaid",
|
||||
"legend": {
|
||||
"type": "leg_type",
|
||||
"orientation": "horizontal"
|
||||
|
|
|
@ -22,6 +22,7 @@ spec:
|
|||
width: 6
|
||||
height: 3
|
||||
shade: true
|
||||
position: overlaid
|
||||
legend:
|
||||
type: leg_type
|
||||
orientation: horizontal
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
"width": 6,
|
||||
"height": 3,
|
||||
"decimalPlaces": 1,
|
||||
"position": "stacked",
|
||||
"shade": true,
|
||||
"xColumn": "_time",
|
||||
"yColumn": "_value",
|
||||
|
|
|
@ -20,6 +20,7 @@ spec:
|
|||
height: 3
|
||||
shade: true
|
||||
geom: line
|
||||
position: stacked
|
||||
legend:
|
||||
queries:
|
||||
- query: >
|
||||
|
|
Loading…
Reference in New Issue