From f6a26ee2b99c1225cf1ca09487ea8fb45e515860 Mon Sep 17 00:00:00 2001 From: Timmy Luong Date: Thu, 29 Oct 2020 10:59:25 -0700 Subject: [PATCH] feat: update generate ticks into an array of properties for each axis (#19850) * feat: update generate ticks into an array of properties for each axis * fix: add missing operand * chore: reorder properties to be consistent * fix: update GenerateYAxisTicks to array of strings * fix: change expected property to null --- dashboard.go | 24 ++++--- dashboard_test.go | 3 +- http/dashboard_test.go | 6 +- http/swagger.yml | 56 ++++++++++++---- pkger/clone_resource.go | 26 ++++++-- pkger/parser.go | 3 +- pkger/parser_models.go | 23 ++++--- pkger/parser_test.go | 17 +++-- pkger/service_test.go | 66 ++++++++++--------- pkger/testdata/dashboard_band.yml | 9 ++- pkger/testdata/dashboard_heatmap.json | 3 +- pkger/testdata/dashboard_heatmap.yml | 9 ++- pkger/testdata/dashboard_mosaic.yml | 5 +- pkger/testdata/dashboard_scatter.json | 3 +- pkger/testdata/dashboard_scatter.yml | 9 ++- .../dashboard_single_stat_plus_line.json | 3 +- .../dashboard_single_stat_plus_line.yml | 9 ++- pkger/testdata/dashboard_xy.json | 3 +- pkger/testdata/dashboard_xy.yml | 9 ++- 19 files changed, 196 insertions(+), 90 deletions(-) diff --git a/dashboard.go b/dashboard.go index 4da771bb5d7..f6ccd81d2ed 100644 --- a/dashboard.go +++ b/dashboard.go @@ -716,12 +716,13 @@ type LinePlusSingleStatProperties struct { DecimalPlaces DecimalPlaces `json:"decimalPlaces"` Note string `json:"note"` ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` - GenerateAxisTicks bool `json:"generateAxisTicks"` XColumn string `json:"xColumn"` + GenerateXAxisTicks []string `json:"generateXAxisTicks"` XTotalTicks int `json:"xTotalTicks"` XTickStart float64 `json:"xTickStart"` XTickStep float64 `json:"xTickStep"` YColumn string `json:"yColumn"` + GenerateYAxisTicks []string `json:"generateYAxisTicks"` YTotalTicks int `json:"yTotalTicks"` YTickStart float64 `json:"yTickStart"` YTickStep float64 `json:"yTickStep"` @@ -744,12 +745,13 @@ type XYViewProperties struct { ViewColors []ViewColor `json:"colors"` Note string `json:"note"` ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` - GenerateAxisTicks bool `json:"generateAxisTicks"` XColumn string `json:"xColumn"` + GenerateXAxisTicks []string `json:"generateXAxisTicks"` XTotalTicks int `json:"xTotalTicks"` XTickStart float64 `json:"xTickStart"` XTickStep float64 `json:"xTickStep"` YColumn string `json:"yColumn"` + GenerateYAxisTicks []string `json:"generateYAxisTicks"` YTotalTicks int `json:"yTotalTicks"` YTickStart float64 `json:"yTickStart"` YTickStep float64 `json:"yTickStep"` @@ -774,12 +776,13 @@ type BandViewProperties struct { ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"` TimeFormat string `json:"timeFormat"` HoverDimension string `json:"hoverDimension"` - GenerateAxisTicks bool `json:"generateAxisTicks"` XColumn string `json:"xColumn"` + GenerateXAxisTicks []string `json:"generateXAxisTicks"` XTotalTicks int `json:"xTotalTicks"` XTickStart float64 `json:"xTickStart"` XTickStep float64 `json:"xTickStep"` YColumn string `json:"yColumn"` + GenerateYAxisTicks []string `json:"generateYAxisTicks"` YTotalTicks int `json:"yTotalTicks"` YTickStart float64 `json:"yTickStart"` YTickStep float64 `json:"yTickStep"` @@ -797,13 +800,6 @@ type CheckViewProperties struct { CheckID string `json:"checkID"` Queries []DashboardQuery `json:"queries"` ViewColors []string `json:"colors"` - GenerateAxisTicks bool `json:"generateAxisTicks"` - XTotalTicks int `json:"xTotalTicks"` - XTickStart float64 `json:"xTickStart"` - XTickStep float64 `json:"xTickStep"` - YTotalTicks int `json:"yTotalTicks"` - YTickStart float64 `json:"yTickStart"` - YTickStep float64 `json:"yTickStep"` LegendColorizeRows bool `json:"legendColorizeRows"` LegendOpacity float64 `json:"legendOpacity"` LegendOrientationThreshold int `json:"legendOrientationThreshold"` @@ -847,12 +843,13 @@ type HeatmapViewProperties struct { Queries []DashboardQuery `json:"queries"` ViewColors []string `json:"colors"` BinSize int32 `json:"binSize"` - GenerateAxisTicks bool `json:"generateAxisTicks"` XColumn string `json:"xColumn"` + GenerateXAxisTicks []string `json:"generateXAxisTicks"` XTotalTicks int `json:"xTotalTicks"` XTickStart float64 `json:"xTickStart"` XTickStep float64 `json:"xTickStep"` YColumn string `json:"yColumn"` + GenerateYAxisTicks []string `json:"generateYAxisTicks"` YTotalTicks int `json:"yTotalTicks"` YTickStart float64 `json:"yTickStart"` YTickStep float64 `json:"yTickStep"` @@ -879,12 +876,13 @@ type ScatterViewProperties struct { ViewColors []string `json:"colors"` FillColumns []string `json:"fillColumns"` SymbolColumns []string `json:"symbolColumns"` - GenerateAxisTicks bool `json:"generateAxisTicks"` XColumn string `json:"xColumn"` + GenerateXAxisTicks []string `json:"generateXAxisTicks"` XTotalTicks int `json:"xTotalTicks"` XTickStart float64 `json:"xTickStart"` XTickStep float64 `json:"xTickStep"` YColumn string `json:"yColumn"` + GenerateYAxisTicks []string `json:"generateYAxisTicks"` YTotalTicks int `json:"yTotalTicks"` YTickStart float64 `json:"yTickStart"` YTickStep float64 `json:"yTickStep"` @@ -910,8 +908,8 @@ type MosaicViewProperties struct { Queries []DashboardQuery `json:"queries"` ViewColors []string `json:"colors"` FillColumns []string `json:"fillColumns"` - GenerateAxisTicks bool `json:"generateAxisTicks"` XColumn string `json:"xColumn"` + GenerateXAxisTicks []string `json:"generateXAxisTicks"` XTotalTicks int `json:"xTotalTicks"` XTickStart float64 `json:"xTickStart"` XTickStep float64 `json:"xTickStep"` diff --git a/dashboard_test.go b/dashboard_test.go index 0b6ed780583..b39139a70e0 100644 --- a/dashboard_test.go +++ b/dashboard_test.go @@ -48,12 +48,13 @@ func TestView_MarshalJSON(t *testing.T) { "geom": "", "note": "", "showNoteWhenEmpty": false, - "generateAxisTicks": false, "xColumn": "", + "generateXAxisTicks": null, "xTotalTicks": 0, "xTickStart": 0, "xTickStep": 0, "yColumn": "", + "generateYAxisTicks": null, "yTotalTicks": 0, "yTickStart": 0, "yTickStep": 0, diff --git a/http/dashboard_test.go b/http/dashboard_test.go index e1b70fef23d..b09aeeaac08 100644 --- a/http/dashboard_test.go +++ b/http/dashboard_test.go @@ -464,12 +464,13 @@ func TestService_handleGetDashboard(t *testing.T) { "showNoteWhenEmpty": false, "timeFormat": "", "type": "xy", - "generateAxisTicks": false, "xColumn": "", + "generateXAxisTicks": null, "xTotalTicks": 0, "xTickStart": 0, "xTickStep": 0, "yColumn": "", + "generateYAxisTicks": null, "yTotalTicks": 0, "yTickStart": 0, "yTickStep": 0, @@ -991,12 +992,13 @@ func TestService_handlePostDashboard(t *testing.T) { "showNoteWhenEmpty": false, "timeFormat": "", "type": "", - "generateAxisTicks": false, "xColumn": "", + "generateXAxisTicks": null, "xTotalTicks": 0, "xTickStart": 0, "xTickStep": 0, "yColumn": "", + "generateYAxisTicks": null, "yTotalTicks": 0, "yTickStart": 0, "yTickStep": 0, diff --git a/http/swagger.yml b/http/swagger.yml index a87ca7df5c3..2a89b119e2c 100644 --- a/http/swagger.yml +++ b/http/swagger.yml @@ -8976,10 +8976,12 @@ components: $ref: "#/components/schemas/Axes" legend: $ref: "#/components/schemas/Legend" - generateAxisTicks: - type: boolean xColumn: type: string + generateXAxisTicks: + type: array + items: + type: string xTotalTicks: type: integer xTickStart: @@ -8990,6 +8992,10 @@ components: format: float yColumn: type: string + generateYAxisTicks: + type: array + items: + type: string yTotalTicks: type: integer yTickStart: @@ -9057,10 +9063,12 @@ components: $ref: "#/components/schemas/Axes" legend: $ref: "#/components/schemas/Legend" - generateAxisTicks: - type: boolean xColumn: type: string + generateXAxisTicks: + type: array + items: + type: string xTotalTicks: type: integer xTickStart: @@ -9071,6 +9079,10 @@ components: format: float yColumn: type: string + generateYAxisTicks: + type: array + items: + type: string yTotalTicks: type: integer yTickStart: @@ -9139,10 +9151,12 @@ components: $ref: "#/components/schemas/Axes" legend: $ref: "#/components/schemas/Legend" - generateAxisTicks: - type: boolean xColumn: type: string + generateXAxisTicks: + type: array + items: + type: string xTotalTicks: type: integer xTickStart: @@ -9153,6 +9167,10 @@ components: format: float yColumn: type: string + generateYAxisTicks: + type: array + items: + type: string yTotalTicks: type: integer yTickStart: @@ -9225,10 +9243,12 @@ components: showNoteWhenEmpty: description: If true, will display note when empty type: boolean - generateAxisTicks: - type: boolean xColumn: type: string + generateXAxisTicks: + type: array + items: + type: string xTotalTicks: type: integer xTickStart: @@ -9318,10 +9338,12 @@ components: showNoteWhenEmpty: description: If true, will display note when empty type: boolean - generateAxisTicks: - type: boolean xColumn: type: string + generateXAxisTicks: + type: array + items: + type: string xTotalTicks: type: integer xTickStart: @@ -9332,6 +9354,10 @@ components: format: float yColumn: type: string + generateYAxisTicks: + type: array + items: + type: string yTotalTicks: type: integer yTickStart: @@ -9420,10 +9446,12 @@ components: showNoteWhenEmpty: description: If true, will display note when empty type: boolean - generateAxisTicks: - type: boolean xColumn: type: string + generateXAxisTicks: + type: array + items: + type: string xTotalTicks: type: integer xTickStart: @@ -9434,6 +9462,10 @@ components: format: float yColumn: type: string + generateYAxisTicks: + type: array + items: + type: string yTotalTicks: type: integer yTickStart: diff --git a/pkger/clone_resource.go b/pkger/clone_resource.go index 67f0aa40952..d3af7f8c8c3 100644 --- a/pkger/clone_resource.go +++ b/pkger/clone_resource.go @@ -753,12 +753,13 @@ func convertCellView(cell influxdb.Cell) chart { ch.Kind = chartKindHeatMap ch.Queries = convertQueries(p.Queries) ch.Colors = stringsToColors(p.ViewColors) - ch.GenerateAxisTicks = p.GenerateAxisTicks ch.XCol = p.XColumn + ch.GenerateXAxisTicks = p.GenerateXAxisTicks ch.XTotalTicks = p.XTotalTicks ch.XTickStart = p.XTickStart ch.XTickStep = p.XTickStep ch.YCol = p.YColumn + ch.GenerateYAxisTicks = p.GenerateYAxisTicks ch.YTotalTicks = p.YTotalTicks ch.YTickStart = p.YTickStart ch.YTickStep = p.YTickStep @@ -796,12 +797,13 @@ func convertCellView(cell influxdb.Cell) chart { ch.Axes = convertAxes(p.Axes) ch.Shade = p.ShadeBelow ch.HoverDimension = p.HoverDimension - ch.GenerateAxisTicks = p.GenerateAxisTicks ch.XCol = p.XColumn + ch.GenerateXAxisTicks = p.GenerateXAxisTicks ch.XTotalTicks = p.XTotalTicks ch.XTickStart = p.XTickStart ch.XTickStep = p.XTickStep ch.YCol = p.YColumn + ch.GenerateYAxisTicks = p.GenerateYAxisTicks ch.YTotalTicks = p.YTotalTicks ch.YTickStart = p.YTickStart ch.YTickStep = p.YTickStep @@ -818,8 +820,8 @@ func convertCellView(cell influxdb.Cell) chart { ch.Kind = chartKindMosaic ch.Queries = convertQueries(p.Queries) ch.Colors = stringsToColors(p.ViewColors) - ch.GenerateAxisTicks = p.GenerateAxisTicks ch.XCol = p.XColumn + ch.GenerateXAxisTicks = p.GenerateXAxisTicks ch.XTotalTicks = p.XTotalTicks ch.XTickStart = p.XTickStart ch.XTickStep = p.XTickStep @@ -837,12 +839,13 @@ func convertCellView(cell influxdb.Cell) chart { ch.Kind = chartKindScatter ch.Queries = convertQueries(p.Queries) ch.Colors = stringsToColors(p.ViewColors) - ch.GenerateAxisTicks = p.GenerateAxisTicks ch.XCol = p.XColumn + ch.GenerateXAxisTicks = p.GenerateXAxisTicks ch.XTotalTicks = p.XTotalTicks ch.XTickStart = p.XTickStart ch.XTickStep = p.XTickStep ch.YCol = p.YColumn + ch.GenerateYAxisTicks = p.GenerateYAxisTicks ch.YTotalTicks = p.YTotalTicks ch.YTickStart = p.YTickStart ch.YTickStep = p.YTickStep @@ -879,12 +882,13 @@ func convertCellView(cell influxdb.Cell) chart { ch.Axes = convertAxes(p.Axes) ch.Geom = p.Geom ch.HoverDimension = p.HoverDimension - ch.GenerateAxisTicks = p.GenerateAxisTicks ch.XCol = p.XColumn + ch.GenerateXAxisTicks = p.GenerateXAxisTicks ch.XTotalTicks = p.XTotalTicks ch.XTickStart = p.XTickStart ch.XTickStep = p.XTickStep ch.YCol = p.YColumn + ch.GenerateYAxisTicks = p.GenerateYAxisTicks ch.YTotalTicks = p.YTotalTicks ch.YTickStart = p.YTickStart ch.YTickStep = p.YTickStep @@ -902,12 +906,13 @@ func convertCellView(cell influxdb.Cell) chart { ch.Geom = p.Geom ch.Shade = p.ShadeBelow ch.HoverDimension = p.HoverDimension - ch.GenerateAxisTicks = p.GenerateAxisTicks ch.XCol = p.XColumn + ch.GenerateXAxisTicks = p.GenerateXAxisTicks ch.XTotalTicks = p.XTotalTicks ch.XTickStart = p.XTickStart ch.XTickStep = p.XTickStep ch.YCol = p.YColumn + ch.GenerateYAxisTicks = p.GenerateYAxisTicks ch.YTotalTicks = p.YTotalTicks ch.YTickStart = p.YTickStart ch.YTickStep = p.YTickStep @@ -969,6 +974,14 @@ func convertChartToResource(ch chart) Resource { r[fieldChartFillColumns] = ch.FillColumns } + if len(ch.GenerateXAxisTicks) > 0 { + r[fieldChartGenerateXAxisTicks] = ch.GenerateXAxisTicks + } + + if len(ch.GenerateYAxisTicks) > 0 { + r[fieldChartGenerateYAxisTicks] = ch.GenerateYAxisTicks + } + if zero := new(tableOptions); ch.TableOptions != *zero { tRes := make(Resource) assignNonZeroBools(tRes, map[string]bool{ @@ -1001,7 +1014,6 @@ func convertChartToResource(ch chart) Resource { assignNonZeroBools(r, map[string]bool{ fieldChartNoteOnEmpty: ch.NoteOnEmpty, fieldChartShade: ch.Shade, - fieldChartGenerateAxisTicks: ch.GenerateAxisTicks, fieldChartLegendColorizeRows: ch.LegendColorizeRows, }) diff --git a/pkger/parser.go b/pkger/parser.go index 3f372bb1699..f9772a51f45 100644 --- a/pkger/parser.go +++ b/pkger/parser.go @@ -1461,12 +1461,13 @@ func (p *Template) parseChart(dashMetaName string, chartIdx int, r Resource) (*c TickSuffix: r.stringShort(fieldChartTickSuffix), TimeFormat: r.stringShort(fieldChartTimeFormat), Width: r.intShort(fieldChartWidth), - GenerateAxisTicks: r.boolShort(fieldChartGenerateAxisTicks), XCol: r.stringShort(fieldChartXCol), + GenerateXAxisTicks: r.slcStr(fieldChartGenerateXAxisTicks), XTotalTicks: r.intShort(fieldChartXTotalTicks), XTickStart: r.float64Short(fieldChartXTickStart), XTickStep: r.float64Short(fieldChartXTickStep), YCol: r.stringShort(fieldChartYCol), + GenerateYAxisTicks: r.slcStr(fieldChartGenerateYAxisTicks), YTotalTicks: r.intShort(fieldChartYTotalTicks), YTickStart: r.float64Short(fieldChartYTickStart), YTickStep: r.float64Short(fieldChartYTickStep), diff --git a/pkger/parser_models.go b/pkger/parser_models.go index dec3d9e9fe5..65f35c68c82 100644 --- a/pkger/parser_models.go +++ b/pkger/parser_models.go @@ -557,13 +557,14 @@ const ( fieldChartMainColumn = "mainColumn" fieldChartLowerColumn = "lowerColumn" fieldChartWidth = "width" - fieldChartGenerateAxisTicks = "generateAxisTicks" fieldChartXCol = "xCol" + fieldChartGenerateXAxisTicks = "generateXAxisTicks" fieldChartXTotalTicks = "xTotalTicks" fieldChartXTickStart = "xTickStart" fieldChartXTickStep = "xTickStep" fieldChartXPos = "xPos" fieldChartYCol = "yCol" + fieldChartGenerateYAxisTicks = "generateYAxisTicks" fieldChartYTotalTicks = "yTotalTicks" fieldChartYTickStart = "yTickStart" fieldChartYTickStep = "yTickStep" @@ -592,8 +593,9 @@ type chart struct { Axes axes Geom string YSeriesColumns []string - GenerateAxisTicks bool XCol, YCol string + GenerateXAxisTicks []string + GenerateYAxisTicks []string XTotalTicks, YTotalTicks int XTickStart, YTickStart float64 XTickStep, YTickStep float64 @@ -638,12 +640,13 @@ func (c *chart) properties() influxdb.ViewProperties { Queries: c.Queries.influxDashQueries(), ViewColors: c.Colors.strings(), BinSize: int32(c.BinSize), - GenerateAxisTicks: c.GenerateAxisTicks, XColumn: c.XCol, + GenerateXAxisTicks: c.GenerateXAxisTicks, XTotalTicks: c.XTotalTicks, XTickStart: c.XTickStart, XTickStep: c.XTickStep, YColumn: c.YCol, + GenerateYAxisTicks: c.GenerateYAxisTicks, YTotalTicks: c.YTotalTicks, YTickStart: c.YTickStart, YTickStep: c.YTickStep, @@ -689,8 +692,8 @@ func (c *chart) properties() influxdb.ViewProperties { Type: influxdb.ViewPropertyTypeMosaic, Queries: c.Queries.influxDashQueries(), ViewColors: c.Colors.strings(), - GenerateAxisTicks: c.GenerateAxisTicks, XColumn: c.XCol, + GenerateXAxisTicks: c.GenerateXAxisTicks, XTotalTicks: c.XTotalTicks, XTickStart: c.XTickStart, XTickStep: c.XTickStep, @@ -717,12 +720,13 @@ func (c *chart) properties() influxdb.ViewProperties { ViewColors: c.Colors.influxViewColors(), Legend: c.Legend.influxLegend(), HoverDimension: c.HoverDimension, - GenerateAxisTicks: c.GenerateAxisTicks, XColumn: c.XCol, + GenerateXAxisTicks: c.GenerateXAxisTicks, XTotalTicks: c.XTotalTicks, XTickStart: c.XTickStart, XTickStep: c.XTickStep, YColumn: c.YCol, + GenerateYAxisTicks: c.GenerateYAxisTicks, YTotalTicks: c.YTotalTicks, YTickStart: c.YTickStart, YTickStep: c.YTickStep, @@ -743,12 +747,13 @@ func (c *chart) properties() influxdb.ViewProperties { Type: influxdb.ViewPropertyTypeScatter, Queries: c.Queries.influxDashQueries(), ViewColors: c.Colors.strings(), - GenerateAxisTicks: c.GenerateAxisTicks, XColumn: c.XCol, + GenerateXAxisTicks: c.GenerateXAxisTicks, XTotalTicks: c.XTotalTicks, XTickStart: c.XTickStart, XTickStep: c.XTickStep, YColumn: c.YCol, + GenerateYAxisTicks: c.GenerateYAxisTicks, YTotalTicks: c.YTotalTicks, YTickStart: c.YTickStart, YTickStep: c.YTickStep, @@ -794,12 +799,13 @@ func (c *chart) properties() influxdb.ViewProperties { }, Note: c.Note, ShowNoteWhenEmpty: c.NoteOnEmpty, - GenerateAxisTicks: c.GenerateAxisTicks, XColumn: c.XCol, + GenerateXAxisTicks: c.GenerateXAxisTicks, XTotalTicks: c.XTotalTicks, XTickStart: c.XTickStart, XTickStep: c.XTickStep, YColumn: c.YCol, + GenerateYAxisTicks: c.GenerateYAxisTicks, YTotalTicks: c.YTotalTicks, YTickStart: c.YTickStart, YTickStep: c.YTickStep, @@ -850,12 +856,13 @@ func (c *chart) properties() influxdb.ViewProperties { Type: influxdb.ViewPropertyTypeXY, Note: c.Note, ShowNoteWhenEmpty: c.NoteOnEmpty, - GenerateAxisTicks: c.GenerateAxisTicks, XColumn: c.XCol, + GenerateXAxisTicks: c.GenerateXAxisTicks, XTotalTicks: c.XTotalTicks, XTickStart: c.XTickStart, XTickStep: c.XTickStep, YColumn: c.YCol, + GenerateYAxisTicks: c.GenerateYAxisTicks, YTotalTicks: c.YTotalTicks, YTickStart: c.YTickStart, YTickStep: c.YTickStep, diff --git a/pkger/parser_test.go b/pkger/parser_test.go index ddda0bded45..0a61b58d979 100644 --- a/pkger/parser_test.go +++ b/pkger/parser_test.go @@ -1058,10 +1058,11 @@ spec: assert.Equal(t, "heatmap", props.GetType()) assert.Equal(t, "heatmap note", props.Note) assert.Equal(t, int32(10), props.BinSize) - assert.Equal(t, true, props.GenerateAxisTicks) + assert.Equal(t, []string{"xTotalTicks", "xTickStart", "xTickStep"}, props.GenerateXAxisTicks) assert.Equal(t, 15, props.XTotalTicks) assert.Equal(t, 0.0, props.XTickStart) assert.Equal(t, 1000.0, props.XTickStep) + assert.Equal(t, []string{"yTotalTicks", "yTickStart", "yTickStep"}, props.GenerateYAxisTicks) assert.Equal(t, 10, props.YTotalTicks) assert.Equal(t, 0.0, props.YTickStart) assert.Equal(t, 100.0, props.YTickStep) @@ -1302,7 +1303,7 @@ spec: assert.Equal(t, "y_prefix", props.YPrefix) assert.Equal(t, "x_suffix", props.XSuffix) assert.Equal(t, "y_suffix", props.YSuffix) - assert.Equal(t, true, props.GenerateAxisTicks) + assert.Equal(t, []string{"xTotalTicks", "xTickStart", "xTickStep"}, props.GenerateXAxisTicks) assert.Equal(t, 15, props.XTotalTicks) assert.Equal(t, 0.0, props.XTickStart) assert.Equal(t, 1000.0, props.XTickStep) @@ -1339,10 +1340,11 @@ spec: assert.Equal(t, "foo", props.UpperColumn) assert.Equal(t, "baz", props.MainColumn) assert.Equal(t, "bar", props.LowerColumn) - assert.Equal(t, true, props.GenerateAxisTicks) + assert.Equal(t, []string{"xTotalTicks", "xTickStart", "xTickStep"}, props.GenerateXAxisTicks) assert.Equal(t, 15, props.XTotalTicks) assert.Equal(t, 0.0, props.XTickStart) assert.Equal(t, 1000.0, props.XTickStep) + assert.Equal(t, []string{"yTotalTicks", "yTickStart", "yTickStep"}, props.GenerateYAxisTicks) assert.Equal(t, 10, props.YTotalTicks) assert.Equal(t, 0.0, props.YTickStart) assert.Equal(t, 100.0, props.YTickStep) @@ -1412,10 +1414,11 @@ spec: assert.Equal(t, "y_prefix", props.YPrefix) assert.Equal(t, "x_suffix", props.XSuffix) assert.Equal(t, "y_suffix", props.YSuffix) - assert.Equal(t, true, props.GenerateAxisTicks) + assert.Equal(t, []string{"xTotalTicks", "xTickStart", "xTickStep"}, props.GenerateXAxisTicks) assert.Equal(t, 15, props.XTotalTicks) assert.Equal(t, 0.0, props.XTickStart) assert.Equal(t, 1000.0, props.XTickStep) + assert.Equal(t, []string{"yTotalTicks", "yTickStart", "yTickStep"}, props.GenerateYAxisTicks) assert.Equal(t, 10, props.YTotalTicks) assert.Equal(t, 0.0, props.YTickStart) assert.Equal(t, 100.0, props.YTickStep) @@ -1860,10 +1863,11 @@ spec: assert.Equal(t, "overlaid", props.Position) assert.Equal(t, "leg_type", props.Legend.Type) assert.Equal(t, "horizontal", props.Legend.Orientation) - assert.Equal(t, true, props.GenerateAxisTicks) + assert.Equal(t, []string{"xTotalTicks", "xTickStart", "xTickStep"}, props.GenerateXAxisTicks) assert.Equal(t, 15, props.XTotalTicks) assert.Equal(t, 0.0, props.XTickStart) assert.Equal(t, 1000.0, props.XTickStep) + assert.Equal(t, []string{"yTotalTicks", "yTickStart", "yTickStep"}, props.GenerateYAxisTicks) assert.Equal(t, 10, props.YTotalTicks) assert.Equal(t, 0.0, props.YTickStart) assert.Equal(t, 100.0, props.YTickStep) @@ -2326,10 +2330,11 @@ spec: assert.Equal(t, "xy chart note", props.Note) assert.True(t, props.ShowNoteWhenEmpty) assert.Equal(t, "stacked", props.Position) - assert.Equal(t, true, props.GenerateAxisTicks) + assert.Equal(t, []string{"xTotalTicks", "xTickStart", "xTickStep"}, props.GenerateXAxisTicks) assert.Equal(t, 15, props.XTotalTicks) assert.Equal(t, 0.0, props.XTickStart) assert.Equal(t, 1000.0, props.XTickStep) + assert.Equal(t, []string{"yTotalTicks", "yTickStart", "yTickStep"}, props.GenerateYAxisTicks) assert.Equal(t, 10, props.YTotalTicks) assert.Equal(t, 0.0, props.YTickStart) assert.Equal(t, 100.0, props.YTickStep) diff --git a/pkger/service_test.go b/pkger/service_test.go index 670e0ec99d0..ac84c17ca7f 100644 --- a/pkger/service_test.go +++ b/pkger/service_test.go @@ -2360,12 +2360,13 @@ func TestService(t *testing.T) { Queries: []influxdb.DashboardQuery{newQuery()}, ShowNoteWhenEmpty: true, ViewColors: []string{"#8F8AF4", "#8F8AF4", "#8F8AF4"}, - GenerateAxisTicks: true, XColumn: "x", + GenerateXAxisTicks: []string{"xTotalTicks", "xTickStart", "xTickStep"}, XTotalTicks: 15, XTickStart: 0, XTickStep: 1000, YColumn: "y", + GenerateYAxisTicks: []string{"yTotalTicks", "yTickStart", "yTickStep"}, YTotalTicks: 10, YTickStart: 0, YTickStep: 100, @@ -2423,12 +2424,13 @@ func TestService(t *testing.T) { Queries: []influxdb.DashboardQuery{newQuery()}, ShowNoteWhenEmpty: true, ViewColors: []string{"#8F8AF4", "#8F8AF4", "#8F8AF4"}, - GenerateAxisTicks: true, XColumn: "x", + GenerateXAxisTicks: []string{"xTotalTicks", "xTickStart", "xTickStep"}, XTotalTicks: 15, XTickStart: 0, XTickStep: 1000, YColumn: "y", + GenerateYAxisTicks: []string{"yTotalTicks", "yTickStart", "yTickStep"}, YTotalTicks: 10, YTickStart: 0, YTickStep: 100, @@ -2459,8 +2461,8 @@ func TestService(t *testing.T) { Queries: []influxdb.DashboardQuery{newQuery()}, ShowNoteWhenEmpty: true, ViewColors: []string{"#8F8AF4", "#8F8AF4", "#8F8AF4"}, - GenerateAxisTicks: true, XColumn: "x", + GenerateXAxisTicks: []string{"xTotalTicks", "xTickStart", "xTickStep"}, XTotalTicks: 15, XTickStart: 0, XTickStep: 1000, @@ -2540,12 +2542,13 @@ func TestService(t *testing.T) { HoverDimension: "y", ShowNoteWhenEmpty: true, ViewColors: []influxdb.ViewColor{{Type: "text", Hex: "red"}}, - GenerateAxisTicks: true, XColumn: "x", + GenerateXAxisTicks: []string{"xTotalTicks", "xTickStart", "xTickStep"}, XTotalTicks: 15, XTickStart: 0, XTickStep: 1000, YColumn: "y", + GenerateYAxisTicks: []string{"yTotalTicks", "yTickStart", "yTickStep"}, YTotalTicks: 10, YTickStart: 0, YTickStep: 100, @@ -2574,12 +2577,13 @@ func TestService(t *testing.T) { HoverDimension: "y", ShowNoteWhenEmpty: true, ViewColors: []influxdb.ViewColor{{Type: "text", Hex: "red"}}, - GenerateAxisTicks: true, XColumn: "x", + GenerateXAxisTicks: []string{"xTotalTicks", "xTickStart", "xTickStep"}, XTotalTicks: 15, XTickStart: 0, XTickStep: 1000, YColumn: "y", + GenerateYAxisTicks: []string{"yTotalTicks", "yTickStart", "yTickStep"}, YTotalTicks: 10, YTickStart: 0, YTickStep: 100, @@ -2608,12 +2612,13 @@ func TestService(t *testing.T) { HoverDimension: "y", ShowNoteWhenEmpty: true, ViewColors: []influxdb.ViewColor{{Type: "text", Hex: "red"}}, - GenerateAxisTicks: true, XColumn: "x", + GenerateXAxisTicks: []string{"xTotalTicks", "xTickStart", "xTickStep"}, XTotalTicks: 15, XTickStart: 0, XTickStep: 1000, YColumn: "y", + GenerateYAxisTicks: []string{"yTotalTicks", "yTickStart", "yTickStep"}, YTotalTicks: 10, YTickStart: 0, YTickStep: 100, @@ -2879,30 +2884,31 @@ func TestService(t *testing.T) { Name: "view name", }, Properties: influxdb.HeatmapViewProperties{ - Type: influxdb.ViewPropertyTypeHeatMap, - Note: "a note", - Queries: []influxdb.DashboardQuery{newQuery()}, - ShowNoteWhenEmpty: true, - ViewColors: []string{"#8F8AF4", "#8F8AF4", "#8F8AF4"}, - GenerateAxisTicks: true, - XColumn: "x", - XTotalTicks: 15, - XTickStart: 0, - XTickStep: 1000, - YColumn: "y", - YTotalTicks: 10, - YTickStart: 0, - YTickStep: 100, - XDomain: []float64{0, 10}, - YDomain: []float64{0, 100}, - XAxisLabel: "x_label", - XPrefix: "x_prefix", - XSuffix: "x_suffix", - YAxisLabel: "y_label", - YPrefix: "y_prefix", - YSuffix: "y_suffix", - BinSize: 10, - TimeFormat: "", + Type: influxdb.ViewPropertyTypeHeatMap, + Note: "a note", + Queries: []influxdb.DashboardQuery{newQuery()}, + ShowNoteWhenEmpty: true, + ViewColors: []string{"#8F8AF4", "#8F8AF4", "#8F8AF4"}, + XColumn: "x", + GenerateXAxisTicks: []string{"xTotalTicks", "xTickStart", "xTickStep"}, + XTotalTicks: 15, + XTickStart: 0, + XTickStep: 1000, + YColumn: "y", + GenerateYAxisTicks: []string{"yTotalTicks", "yTickStart", "yTickStep"}, + YTotalTicks: 10, + YTickStart: 0, + YTickStep: 100, + XDomain: []float64{0, 10}, + YDomain: []float64{0, 100}, + XAxisLabel: "x_label", + XPrefix: "x_prefix", + XSuffix: "x_suffix", + YAxisLabel: "y_label", + YPrefix: "y_prefix", + YSuffix: "y_suffix", + BinSize: 10, + TimeFormat: "", }, }), newDash("prancer", influxdb.View{ diff --git a/pkger/testdata/dashboard_band.yml b/pkger/testdata/dashboard_band.yml index 34e5fee62b5..e00dc258069 100644 --- a/pkger/testdata/dashboard_band.yml +++ b/pkger/testdata/dashboard_band.yml @@ -22,10 +22,17 @@ spec: geom: line width: 6 height: 3 - generateAxisTicks: true + generateXAxisTicks: + - xTotalTicks + - xTickStart + - xTickStep xTotalTicks: 15 xTickStart: 0 xTickStep: 1000 + generateYAxisTicks: + - yTotalTicks + - yTickStart + - yTickStep yTotalTicks: 10 yTickStart: 0 yTickStep: 100 diff --git a/pkger/testdata/dashboard_heatmap.json b/pkger/testdata/dashboard_heatmap.json index 4a6d16e143d..c7e480d7fda 100644 --- a/pkger/testdata/dashboard_heatmap.json +++ b/pkger/testdata/dashboard_heatmap.json @@ -17,12 +17,13 @@ "yPos": 2, "width": 6, "height": 3, - "generateAxisTicks": true, "xCol": "_time", + "generateXAxisTicks": ["xTotalTicks", "xTickStart", "xTickStep"], "xTotalTicks": 15, "xTickStart": 0, "xTickStep": 1000, "yCol": "_value", + "generateYAxisTicks": ["yTotalTicks", "yTickStart", "yTickStep"], "yTotalTicks": 10, "yTickStart": 0, "yTickStep": 100, diff --git a/pkger/testdata/dashboard_heatmap.yml b/pkger/testdata/dashboard_heatmap.yml index ad30419b8ef..ec6d874ac98 100644 --- a/pkger/testdata/dashboard_heatmap.yml +++ b/pkger/testdata/dashboard_heatmap.yml @@ -17,12 +17,19 @@ spec: legendColorizeRows: true legendOpacity: 1.0 legendOrientationThreshold: 5 - generateAxisTicks: true + generateXAxisTicks: + - xTotalTicks + - xTickStart + - xTickStep xCol: _time xTotalTicks: 15 xTickStart: 0 xTickStep: 1000 yCol: _value + generateYAxisTicks: + - yTotalTicks + - yTickStart + - yTickStep yTotalTicks: 10 yTickStart: 0 yTickStep: 100 diff --git a/pkger/testdata/dashboard_mosaic.yml b/pkger/testdata/dashboard_mosaic.yml index 54ffb9e6b60..f0a2ff4b48c 100644 --- a/pkger/testdata/dashboard_mosaic.yml +++ b/pkger/testdata/dashboard_mosaic.yml @@ -13,7 +13,10 @@ spec: suffix: days xPos: 1 yPos: 2 - generateAxisTicks: true + generateXAxisTicks: + - xTotalTicks + - xTickStart + - xTickStep xCol: _time xTotalTicks: 15 xTickStart: 0 diff --git a/pkger/testdata/dashboard_scatter.json b/pkger/testdata/dashboard_scatter.json index 1aec22f6422..e99973cb96c 100644 --- a/pkger/testdata/dashboard_scatter.json +++ b/pkger/testdata/dashboard_scatter.json @@ -17,12 +17,13 @@ "yPos": 2, "width": 6, "height": 3, - "generateAxisTicks": true, + "generateXAxisTicks": ["xTotalTicks", "xTickStart", "xTickStep"], "xCol": "_time", "xTotalTicks": 15, "xTickStart": 0, "xTickStep": 1000, "yCol": "_value", + "generateYAxisTicks": ["yTotalTicks", "yTickStart", "yTickStep"], "yTotalTicks": 10, "yTickStart": 0, "yTickStep": 100, diff --git a/pkger/testdata/dashboard_scatter.yml b/pkger/testdata/dashboard_scatter.yml index b1214d38296..2297d467cc6 100644 --- a/pkger/testdata/dashboard_scatter.yml +++ b/pkger/testdata/dashboard_scatter.yml @@ -13,12 +13,19 @@ spec: suffix: days xPos: 1 yPos: 2 - generateAxisTicks: true + generateXAxisTicks: + - xTotalTicks + - xTickStart + - xTickStep xCol: _time xTotalTicks: 15 xTickStart: 0 xTickStep: 1000 yCol: _value + generateYAxisTicks: + - yTotalTicks + - yTickStart + - yTickStep yTotalTicks: 10 yTickStart: 0 yTickStep: 100 diff --git a/pkger/testdata/dashboard_single_stat_plus_line.json b/pkger/testdata/dashboard_single_stat_plus_line.json index fe5e9008e6d..d1323ff9858 100644 --- a/pkger/testdata/dashboard_single_stat_plus_line.json +++ b/pkger/testdata/dashboard_single_stat_plus_line.json @@ -22,12 +22,13 @@ "decimalPlaces": 1, "shade": true, "hoverDimension": "y", - "generateAxisTicks": true, + "generateXAxisTicks": ["xTotalTicks", "xTickStart", "xTickStep"], "xColumn": "_time", "xTotalTicks": 15, "xTickStart": 0, "xTickStep": 1000, "yColumn": "_value", + "generateYAxisTicks": ["yTotalTicks", "yTickStart", "yTickStep"], "yTotalTicks": 10, "yTickStart": 0, "yTickStep": 100, diff --git a/pkger/testdata/dashboard_single_stat_plus_line.yml b/pkger/testdata/dashboard_single_stat_plus_line.yml index 8c71fab17c1..6441f2c887a 100644 --- a/pkger/testdata/dashboard_single_stat_plus_line.yml +++ b/pkger/testdata/dashboard_single_stat_plus_line.yml @@ -19,10 +19,17 @@ spec: shade: true hoverDimension: "y" position: overlaid - generateAxisTicks: true + generateXAxisTicks: + - xTotalTicks + - xTickStart + - xTickStep xTotalTicks: 15 xTickStart: 0 xTickStep: 1000 + generateYAxisTicks: + - yTotalTicks + - yTickStart + - yTickStep yTotalTicks: 10 yTickStart: 0 yTickStep: 100 diff --git a/pkger/testdata/dashboard_xy.json b/pkger/testdata/dashboard_xy.json index 9ddd0a57a73..1e13c1fb959 100644 --- a/pkger/testdata/dashboard_xy.json +++ b/pkger/testdata/dashboard_xy.json @@ -22,12 +22,13 @@ "position": "stacked", "shade": true, "hoverDimension": "y", - "generateAxisTicks": true, + "generateXAxisTicks": ["xTotalTicks", "xTickStart", "xTickStep"], "xColumn": "_time", "xTotalTicks": 15, "xTickStart": 0, "xTickStep": 1000, "yColumn": "_value", + "generateYAxisTicks": ["yTotalTicks", "yTickStart", "yTickStep"], "yTotalTicks": 10, "yTickStart": 0, "yTickStep": 100, diff --git a/pkger/testdata/dashboard_xy.yml b/pkger/testdata/dashboard_xy.yml index c4079524796..b0958a2ff48 100644 --- a/pkger/testdata/dashboard_xy.yml +++ b/pkger/testdata/dashboard_xy.yml @@ -17,10 +17,17 @@ spec: hoverDimension: "y" geom: line position: stacked - generateAxisTicks: true + generateXAxisTicks: + - xTotalTicks + - xTickStart + - xTickStep xTotalTicks: 15 xTickStart: 0 xTickStep: 1000 + generateYAxisTicks: + - yTotalTicks + - yTickStart + - yTickStep yTotalTicks: 10 yTickStart: 0 yTickStep: 100