feat(geo-widget): backend storage implementation for chronograf geo widget
parent
3b7cb529dc
commit
42085b2472
60
dashboard.go
60
dashboard.go
|
@ -377,6 +377,7 @@ const (
|
|||
ViewPropertyTypeXY = "xy"
|
||||
ViewPropertyTypeMosaic = "mosaic"
|
||||
ViewPropertyTypeBand = "band"
|
||||
ViewPropertyTypeGeo = "geo"
|
||||
)
|
||||
|
||||
// ViewProperties is used to mark other structures as conforming to a View.
|
||||
|
@ -444,6 +445,13 @@ func UnmarshalViewPropertiesJSON(b []byte) (ViewProperties, error) {
|
|||
return nil, err
|
||||
}
|
||||
vis = gv
|
||||
case ViewPropertyTypeGeo:
|
||||
var gvw GeoViewProperties
|
||||
if err := json.Unmarshal(v.B, &gvw); err != nil {
|
||||
fmt.Printf("Unmarshaling geo view failed. %+v", err)
|
||||
return nil, err
|
||||
}
|
||||
vis = gvw
|
||||
case ViewPropertyTypeTable:
|
||||
var tv TableViewProperties
|
||||
if err := json.Unmarshal(v.B, &tv); err != nil {
|
||||
|
@ -543,6 +551,14 @@ func MarshalViewPropertiesJSON(v ViewProperties) ([]byte, error) {
|
|||
|
||||
GaugeViewProperties: vis,
|
||||
}
|
||||
case GeoViewProperties:
|
||||
s = struct {
|
||||
Shape string `json:"shape"`
|
||||
GeoViewProperties
|
||||
}{
|
||||
Shape: "chronograf-v2",
|
||||
GeoViewProperties: vis,
|
||||
}
|
||||
case XYViewProperties:
|
||||
s = struct {
|
||||
Shape string `json:"shape"`
|
||||
|
@ -894,6 +910,48 @@ type GaugeViewProperties struct {
|
|||
ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"`
|
||||
}
|
||||
|
||||
// Geographical coordinates
|
||||
type Datum struct {
|
||||
Lat float64 `json:"lat"`
|
||||
Lon float64 `json:"lon"`
|
||||
}
|
||||
// Single visualization layer properties of a chronograf map widget
|
||||
type GeoLayer struct {
|
||||
Type string `json:"type"`
|
||||
RadiusField string `json:"radiusField"`
|
||||
ColorField string `json:"colorField"`
|
||||
IntensityField string `json:"intensityField"`
|
||||
// circle layer properties
|
||||
ViewColors []ViewColor `json:"colors"`
|
||||
Radius int32 `json:"radius"`
|
||||
Blur int32 `json:"blur"`
|
||||
RadiusDimension Axis `json:"radiusDimension"`
|
||||
ColorDimension Axis `json:"colorDimension"`
|
||||
IntensityDimension Axis `json:"intensityDimension"`
|
||||
InterpolateColors bool `json:"interpolateColors"`
|
||||
// track layer properties
|
||||
TrackWidth int32 `json:"trackWidth"`
|
||||
Speed int32 `json:"speed"`
|
||||
RandomColors bool `json:"randomColors"`
|
||||
// point layer properties
|
||||
IsClustered bool `json:"isClustered"`
|
||||
}
|
||||
|
||||
// GeoViewProperties represents options for map view in Chronograf
|
||||
type GeoViewProperties struct {
|
||||
Type string `json:"type"`
|
||||
Queries []DashboardQuery `json:"queries"`
|
||||
Center Datum `json:"center"`
|
||||
Zoom float64 `json:"zoom"`
|
||||
MapStyle string `json:"mapStyle"`
|
||||
AllowPanAndZoom bool `json:"allowPanAndZoom"`
|
||||
DetectCoordinateFields bool `json:"detectCoordinateFields"`
|
||||
ViewColor []ViewColor `json:"colors"`
|
||||
GeoLayers []GeoLayer `json:"layers"`
|
||||
Note string `json:"note"`
|
||||
ShowNoteWhenEmpty bool `json:"showNoteWhenEmpty"`
|
||||
}
|
||||
|
||||
// TableViewProperties represents options for table view in Chronograf
|
||||
type TableViewProperties struct {
|
||||
Type string `json:"type"`
|
||||
|
@ -941,6 +999,7 @@ func (HeatmapViewProperties) viewProperties() {}
|
|||
func (ScatterViewProperties) viewProperties() {}
|
||||
func (MosaicViewProperties) viewProperties() {}
|
||||
func (GaugeViewProperties) viewProperties() {}
|
||||
func (GeoViewProperties) viewProperties() {}
|
||||
func (TableViewProperties) viewProperties() {}
|
||||
func (MarkdownViewProperties) viewProperties() {}
|
||||
func (LogViewProperties) viewProperties() {}
|
||||
|
@ -955,6 +1014,7 @@ func (v HeatmapViewProperties) GetType() string { return v.Type }
|
|||
func (v ScatterViewProperties) GetType() string { return v.Type }
|
||||
func (v MosaicViewProperties) GetType() string { return v.Type }
|
||||
func (v GaugeViewProperties) GetType() string { return v.Type }
|
||||
func (v GeoViewProperties) GetType() string { return v.Type }
|
||||
func (v TableViewProperties) GetType() string { return v.Type }
|
||||
func (v MarkdownViewProperties) GetType() string { return v.Type }
|
||||
func (v LogViewProperties) GetType() string { return v.Type }
|
||||
|
|
165
http/swagger.yml
165
http/swagger.yml
|
@ -9640,6 +9640,170 @@ components:
|
|||
format: float
|
||||
legendOrientationThreshold:
|
||||
type: integer
|
||||
GeoViewLayer:
|
||||
type: object
|
||||
oneOf:
|
||||
- $ref: "#/components/schemas/GeoCircleViewLayer"
|
||||
- $ref: "#/components/schemas/GeoHeatMapViewLayer"
|
||||
- $ref: "#/components/schemas/GeoPointMapViewLayer"
|
||||
- $ref: "#/components/schemas/GeoTrackMapViewLayer"
|
||||
GeoViewLayerProperties:
|
||||
type: object
|
||||
required: [type, field, colors]
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
enum: [ heatmap, circleMap, pointMap, trackMap]
|
||||
FieldLegendProperties:
|
||||
type: object
|
||||
properties:
|
||||
label: string
|
||||
GeoCircleViewLayer:
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/GeoViewLayerProperties"
|
||||
- type: object
|
||||
required: [radiusField, radiusDimension,colorField, colorDimension, colors]
|
||||
properties:
|
||||
radiusField:
|
||||
type: string
|
||||
description: Radius field
|
||||
radiusDimension:
|
||||
$ref: '#/components/schemas/Axis'
|
||||
colorField:
|
||||
type: string
|
||||
description: Circle color field
|
||||
colorDimension:
|
||||
$ref: '#/components/schemas/Axis'
|
||||
colors:
|
||||
description: Colors define color encoding of data into a visualization
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/DashboardColor"
|
||||
radius:
|
||||
description: Maximum r adius size in pixels
|
||||
type: integer
|
||||
interpolateColors:
|
||||
description: Interpolate circle color based on displayed value
|
||||
type: boolean
|
||||
GeoPointMapViewLayer:
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/GeoViewLayerProperties"
|
||||
- type: object
|
||||
required: [colorField, colorDimension, colors]
|
||||
properties:
|
||||
colorField:
|
||||
type: string
|
||||
description: Marker color field
|
||||
colorDimension:
|
||||
$ref: '#/components/schemas/Axis'
|
||||
colors:
|
||||
description: Colors define color encoding of data into a visualization
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/DashboardColor"
|
||||
isClustered:
|
||||
description: Cluster close markers together
|
||||
type: boolean
|
||||
GeoTrackMapViewLayer:
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/GeoViewLayerProperties"
|
||||
- type: object
|
||||
required: [trackWidth, speed, randomColors, trackPointVisualization]
|
||||
properties:
|
||||
trackWidth:
|
||||
description: Width of the track
|
||||
type: integer
|
||||
speed:
|
||||
description: Speed of the track animation
|
||||
type: integer
|
||||
randomColors:
|
||||
description: Assign different colors to different tracks
|
||||
type: boolean
|
||||
colors:
|
||||
description: Colors define color encoding of data into a visualization
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/DashboardColor"
|
||||
GeoHeatMapViewLayer:
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/GeoViewLayerProperties"
|
||||
- type: object
|
||||
required: [intensityField, intensityDimension, radius, blur, colors]
|
||||
properties:
|
||||
intensityField:
|
||||
type: string
|
||||
description: Intensity field
|
||||
intensityDimension:
|
||||
$ref: '#/components/schemas/Axis'
|
||||
radius:
|
||||
description: Radius size in pixels
|
||||
type: integer
|
||||
blur:
|
||||
description: Blur for heatmap points
|
||||
type: integer
|
||||
colors:
|
||||
description: Colors define color encoding of data into a visualization
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/DashboardColor"
|
||||
GeoViewProperties:
|
||||
type: object
|
||||
required: [type, shape, queries, note, showNoteWhenEmpty, center, zoom, allowPanAndZoom, detectCoordinateFields, layers]
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
enum: [geo]
|
||||
queries:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/DashboardQuery"
|
||||
shape:
|
||||
type: string
|
||||
enum: ['chronograf-v2']
|
||||
center:
|
||||
description: Coordinates of the center of the map
|
||||
type: object
|
||||
required: [lat, lon]
|
||||
properties:
|
||||
lat:
|
||||
description: Latitude of the center of the map
|
||||
type: number
|
||||
format: double
|
||||
lon:
|
||||
description: Longitude of the center of the map
|
||||
type: number
|
||||
format: double
|
||||
zoom:
|
||||
description: Zoom level used for initial display of the map
|
||||
type: float64
|
||||
minimum: 1
|
||||
maximum: 28
|
||||
allowPanAndZoom:
|
||||
description: If true, map zoom and pan controls are enabled on the dashboard view
|
||||
type: boolean
|
||||
default: true
|
||||
detectCoordinateFields:
|
||||
description: If true, search results get automatically regroupped so that lon,lat and value are treated as columns
|
||||
type: boolean
|
||||
default: true
|
||||
mapStyle:
|
||||
description: Define map type - regular, satellite etc.
|
||||
type: string
|
||||
note:
|
||||
type: string
|
||||
showNoteWhenEmpty:
|
||||
description: If true, will display note when empty
|
||||
type: boolean
|
||||
colors:
|
||||
description: Colors define color encoding of data into a visualization
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/DashboardColor"
|
||||
layers:
|
||||
description: List of individual layers shown in the map
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/GeoViewLayer"
|
||||
Axes:
|
||||
description: The viewport for a View's visualizations
|
||||
type: object
|
||||
|
@ -9811,6 +9975,7 @@ components:
|
|||
- $ref: "#/components/schemas/HeatmapViewProperties"
|
||||
- $ref: "#/components/schemas/MosaicViewProperties"
|
||||
- $ref: "#/components/schemas/BandViewProperties"
|
||||
- $ref: "#/components/schemas/GeoViewProperties"
|
||||
View:
|
||||
required:
|
||||
- name
|
||||
|
|
Loading…
Reference in New Issue