Skip to content

Commit

Permalink
chore(pkger): backfill missing fillColumns field for histograms
Browse files Browse the repository at this point in the history
closes: #18431
  • Loading branch information
jsteenb2 committed Jun 10, 2020
1 parent 1d75e3e commit 0d9f4f2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pkger/clone_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ func convertCellView(cell influxdb.Cell) chart {
ch.Kind = chartKindHistogram
ch.Queries = convertQueries(p.Queries)
ch.Colors = convertColors(p.ViewColors)
ch.FillColumns = p.FillColumns
ch.XCol = p.XColumn
ch.Axes = []axis{{Label: p.XAxisLabel, Name: "x", Domain: p.XDomain}}
ch.Note = p.Note
Expand Down Expand Up @@ -659,6 +660,10 @@ func convertChartToResource(ch chart) Resource {
r[fieldChartLegend] = ch.Legend
}

if len(ch.FillColumns) > 0 {
r[fieldChartFillColumns] = ch.FillColumns
}

if zero := new(tableOptions); ch.TableOptions != *zero {
tRes := make(Resource)
assignNonZeroBools(tRes, map[string]bool{
Expand Down
1 change: 1 addition & 0 deletions pkger/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,7 @@ func parseChart(r Resource) (chart, []validationErr) {
YCol: r.stringShort(fieldChartYCol),
XPos: r.intShort(fieldChartXPos),
YPos: r.intShort(fieldChartYPos),
FillColumns: r.slcStr(fieldChartFillColumns),
}

if presLeg, ok := r[fieldChartLegend].(legend); ok {
Expand Down
4 changes: 3 additions & 1 deletion pkger/parser_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ const (
fieldChartColors = "colors"
fieldChartDecimalPlaces = "decimalPlaces"
fieldChartDomain = "domain"
fieldChartFillColumns = "fillColumns"
fieldChartGeom = "geom"
fieldChartHeight = "height"
fieldChartLegend = "legend"
Expand Down Expand Up @@ -527,6 +528,7 @@ type chart struct {
BinCount int
Position string
FieldOptions []fieldOption
FillColumns []string
TableOptions tableOptions
TimeFormat string
}
Expand Down Expand Up @@ -574,7 +576,7 @@ func (c chart) properties() influxdb.ViewProperties {
Type: influxdb.ViewPropertyTypeHistogram,
Queries: c.Queries.influxDashQueries(),
ViewColors: c.Colors.influxViewColors(),
FillColumns: []string{},
FillColumns: c.FillColumns,
XColumn: c.XCol,
XDomain: c.Axes.get("x").Domain,
XAxisLabel: c.Axes.get("x").Label,
Expand Down
2 changes: 1 addition & 1 deletion pkger/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ spec:
assert.Equal(t, 30, props.BinCount)
assert.True(t, props.ShowNoteWhenEmpty)
assert.Equal(t, []float64{0, 10}, props.XDomain)
assert.Equal(t, []string{}, props.FillColumns)
assert.Equal(t, []string{"a", "b"}, props.FillColumns)
require.Len(t, props.Queries, 1)
q := props.Queries[0]
queryText := `from(bucket: v.bucket) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "boltdb_reads_total") |> filter(fn: (r) => r._field == "counter")`
Expand Down
1 change: 1 addition & 0 deletions pkger/testdata/dashboard_histogram.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"xCol": "_value",
"position": "stacked",
"binCount": 30,
"fillColumns": ["a", "b"],
"queries": [
{
"query": "from(bucket: v.bucket) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == \"boltdb_reads_total\") |> filter(fn: (r) => r._field == \"counter\")"
Expand Down
1 change: 1 addition & 0 deletions pkger/testdata/dashboard_histogram.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ spec:
width: 6
height: 3
binCount: 30
fillColumns: ["a", "b"]
queries:
- query: >
from(bucket: v.bucket) |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "boltdb_reads_total") |> filter(fn: (r) => r._field == "counter")
Expand Down

0 comments on commit 0d9f4f2

Please sign in to comment.