Skip to content

Commit

Permalink
feat: update generate ticks into an array of properties for each axis (
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
TCL735 authored Oct 29, 2020
1 parent 8aa3e6a commit f6a26ee
Show file tree
Hide file tree
Showing 19 changed files with 196 additions and 90 deletions.
24 changes: 11 additions & 13 deletions dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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"`
Expand All @@ -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"`
Expand All @@ -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"`
Expand Down Expand Up @@ -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"`
Expand All @@ -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"`
Expand All @@ -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"`
Expand Down
3 changes: 2 additions & 1 deletion dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions http/dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
56 changes: 44 additions & 12 deletions http/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -8990,6 +8992,10 @@ components:
format: float
yColumn:
type: string
generateYAxisTicks:
type: array
items:
type: string
yTotalTicks:
type: integer
yTickStart:
Expand Down Expand Up @@ -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:
Expand All @@ -9071,6 +9079,10 @@ components:
format: float
yColumn:
type: string
generateYAxisTicks:
type: array
items:
type: string
yTotalTicks:
type: integer
yTickStart:
Expand Down Expand Up @@ -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:
Expand All @@ -9153,6 +9167,10 @@ components:
format: float
yColumn:
type: string
generateYAxisTicks:
type: array
items:
type: string
yTotalTicks:
type: integer
yTickStart:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -9332,6 +9354,10 @@ components:
format: float
yColumn:
type: string
generateYAxisTicks:
type: array
items:
type: string
yTotalTicks:
type: integer
yTickStart:
Expand Down Expand Up @@ -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:
Expand All @@ -9434,6 +9462,10 @@ components:
format: float
yColumn:
type: string
generateYAxisTicks:
type: array
items:
type: string
yTotalTicks:
type: integer
yTickStart:
Expand Down
26 changes: 19 additions & 7 deletions pkger/clone_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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,
})

Expand Down
Loading

0 comments on commit f6a26ee

Please sign in to comment.