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.Shade = p.ShadeBelow
|
||||||
ch.XCol = p.XColumn
|
ch.XCol = p.XColumn
|
||||||
ch.YCol = p.YColumn
|
ch.YCol = p.YColumn
|
||||||
|
ch.Position = p.Position
|
||||||
case influxdb.SingleStatViewProperties:
|
case influxdb.SingleStatViewProperties:
|
||||||
setCommon(chartKindSingleStat, p.ViewColors, p.DecimalPlaces, p.Queries)
|
setCommon(chartKindSingleStat, p.ViewColors, p.DecimalPlaces, p.Queries)
|
||||||
setNoteFixes(p.Note, p.ShowNoteWhenEmpty, p.Prefix, p.Suffix)
|
setNoteFixes(p.Note, p.ShowNoteWhenEmpty, p.Prefix, p.Suffix)
|
||||||
|
@ -165,6 +166,7 @@ func convertCellView(cv cellView) chart {
|
||||||
ch.Shade = p.ShadeBelow
|
ch.Shade = p.ShadeBelow
|
||||||
ch.XCol = p.XColumn
|
ch.XCol = p.XColumn
|
||||||
ch.YCol = p.YColumn
|
ch.YCol = p.YColumn
|
||||||
|
ch.Position = p.Position
|
||||||
}
|
}
|
||||||
|
|
||||||
return ch
|
return ch
|
||||||
|
|
|
@ -1048,6 +1048,7 @@ func (c chart) properties() influxdb.ViewProperties {
|
||||||
Queries: c.Queries.influxDashQueries(),
|
Queries: c.Queries.influxDashQueries(),
|
||||||
ViewColors: c.Colors.influxViewColors(),
|
ViewColors: c.Colors.influxViewColors(),
|
||||||
Axes: c.Axes.influxAxes(),
|
Axes: c.Axes.influxAxes(),
|
||||||
|
Position: c.Position,
|
||||||
}
|
}
|
||||||
case chartKindXY:
|
case chartKindXY:
|
||||||
return influxdb.XYViewProperties{
|
return influxdb.XYViewProperties{
|
||||||
|
@ -1062,6 +1063,7 @@ func (c chart) properties() influxdb.ViewProperties {
|
||||||
ViewColors: c.Colors.influxViewColors(),
|
ViewColors: c.Colors.influxViewColors(),
|
||||||
Axes: c.Axes.influxAxes(),
|
Axes: c.Axes.influxAxes(),
|
||||||
Geom: c.Geom,
|
Geom: c.Geom,
|
||||||
|
Position: c.Position,
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
|
@ -1100,14 +1102,27 @@ func (c chart) validProperties() []validationErr {
|
||||||
case chartKindSingleStatPlusLine:
|
case chartKindSingleStatPlusLine:
|
||||||
fails = append(fails, c.Colors.hasTypes(colorTypeText)...)
|
fails = append(fails, c.Colors.hasTypes(colorTypeText)...)
|
||||||
fails = append(fails, c.Axes.hasAxes("x", "y")...)
|
fails = append(fails, c.Axes.hasAxes("x", "y")...)
|
||||||
|
fails = append(fails, validPosition(c.Position)...)
|
||||||
case chartKindXY:
|
case chartKindXY:
|
||||||
fails = append(fails, validGeometry(c.Geom)...)
|
fails = append(fails, validGeometry(c.Geom)...)
|
||||||
fails = append(fails, c.Axes.hasAxes("x", "y")...)
|
fails = append(fails, c.Axes.hasAxes("x", "y")...)
|
||||||
|
fails = append(fails, validPosition(c.Position)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fails
|
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{
|
var geometryTypes = map[string]bool{
|
||||||
"line": true,
|
"line": true,
|
||||||
"step": 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) {
|
testfileRunner(t, "testdata/dashboard_heatmap", func(t *testing.T, pkg *Pkg) {
|
||||||
sum := pkg.Summary()
|
sum := pkg.Summary()
|
||||||
require.Len(t, sum.Dashboards, 1)
|
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) {
|
testfileRunner(t, "testdata/dashboard_histogram", func(t *testing.T, pkg *Pkg) {
|
||||||
sum := pkg.Summary()
|
sum := pkg.Summary()
|
||||||
require.Len(t, sum.Dashboards, 1)
|
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) {
|
testfileRunner(t, "testdata/dashboard_markdown", func(t *testing.T, pkg *Pkg) {
|
||||||
sum := pkg.Summary()
|
sum := pkg.Summary()
|
||||||
require.Len(t, sum.Dashboards, 1)
|
require.Len(t, sum.Dashboards, 1)
|
||||||
|
@ -2029,6 +2029,7 @@ spec:
|
||||||
assert.Equal(t, int32(1), props.DecimalPlaces.Digits)
|
assert.Equal(t, int32(1), props.DecimalPlaces.Digits)
|
||||||
assert.Equal(t, "days", props.Suffix)
|
assert.Equal(t, "days", props.Suffix)
|
||||||
assert.Equal(t, "sumtin", props.Prefix)
|
assert.Equal(t, "sumtin", props.Prefix)
|
||||||
|
assert.Equal(t, "overlaid", props.Position)
|
||||||
assert.Equal(t, "leg_type", props.Legend.Type)
|
assert.Equal(t, "leg_type", props.Legend.Type)
|
||||||
assert.Equal(t, "horizontal", props.Legend.Orientation)
|
assert.Equal(t, "horizontal", props.Legend.Orientation)
|
||||||
|
|
||||||
|
@ -2400,6 +2401,7 @@ spec:
|
||||||
assert.Equal(t, true, props.ShadeBelow)
|
assert.Equal(t, true, props.ShadeBelow)
|
||||||
assert.Equal(t, "xy chart note", props.Note)
|
assert.Equal(t, "xy chart note", props.Note)
|
||||||
assert.True(t, props.ShowNoteWhenEmpty)
|
assert.True(t, props.ShowNoteWhenEmpty)
|
||||||
|
assert.Equal(t, "stacked", props.Position)
|
||||||
|
|
||||||
require.Len(t, props.Queries, 1)
|
require.Len(t, props.Queries, 1)
|
||||||
q := props.Queries[0]
|
q := props.Queries[0]
|
||||||
|
|
|
@ -953,6 +953,7 @@ func TestService(t *testing.T) {
|
||||||
ViewColors: []influxdb.ViewColor{{Type: "text", Hex: "red"}},
|
ViewColors: []influxdb.ViewColor{{Type: "text", Hex: "red"}},
|
||||||
XColumn: "x",
|
XColumn: "x",
|
||||||
YColumn: "y",
|
YColumn: "y",
|
||||||
|
Position: "stacked",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -975,6 +976,7 @@ func TestService(t *testing.T) {
|
||||||
ViewColors: []influxdb.ViewColor{{Type: "text", Hex: "red"}},
|
ViewColors: []influxdb.ViewColor{{Type: "text", Hex: "red"}},
|
||||||
XColumn: "x",
|
XColumn: "x",
|
||||||
YColumn: "y",
|
YColumn: "y",
|
||||||
|
Position: "overlaid",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
"shade": true,
|
"shade": true,
|
||||||
"xColumn": "_time",
|
"xColumn": "_time",
|
||||||
"yColumn": "_value",
|
"yColumn": "_value",
|
||||||
|
"position": "overlaid",
|
||||||
"legend": {
|
"legend": {
|
||||||
"type": "leg_type",
|
"type": "leg_type",
|
||||||
"orientation": "horizontal"
|
"orientation": "horizontal"
|
||||||
|
|
|
@ -22,6 +22,7 @@ spec:
|
||||||
width: 6
|
width: 6
|
||||||
height: 3
|
height: 3
|
||||||
shade: true
|
shade: true
|
||||||
|
position: overlaid
|
||||||
legend:
|
legend:
|
||||||
type: leg_type
|
type: leg_type
|
||||||
orientation: horizontal
|
orientation: horizontal
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
"width": 6,
|
"width": 6,
|
||||||
"height": 3,
|
"height": 3,
|
||||||
"decimalPlaces": 1,
|
"decimalPlaces": 1,
|
||||||
|
"position": "stacked",
|
||||||
"shade": true,
|
"shade": true,
|
||||||
"xColumn": "_time",
|
"xColumn": "_time",
|
||||||
"yColumn": "_value",
|
"yColumn": "_value",
|
||||||
|
|
|
@ -20,6 +20,7 @@ spec:
|
||||||
height: 3
|
height: 3
|
||||||
shade: true
|
shade: true
|
||||||
geom: line
|
geom: line
|
||||||
|
position: stacked
|
||||||
legend:
|
legend:
|
||||||
queries:
|
queries:
|
||||||
- query: >
|
- query: >
|
||||||
|
|
Loading…
Reference in New Issue