forked from grafana/grafana-plugin-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frame_type.go
95 lines (84 loc) · 2.81 KB
/
frame_type.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package data
// A FrameType string, when present in a frame's metadata, asserts that the
// frame's structure conforms to the FrameType's specification.
// This property is currently optional, so FrameType may be FrameTypeUnknown even if the properties of
// the Frame correspond to a defined FrameType.
type FrameType string
const (
// FrameTypeUnknown indicates that we do not know the field type
FrameTypeUnknown FrameType = ""
// FrameTypeTimeSeriesWide has at least two fields:
// field[0]:
// * type time
// * unique ascending values
// field[1..n]:
// * distinct labels may be attached to each field
// * numeric & boolean fields can be drawn as lines on a graph
// See https://grafana.com/docs/grafana/latest/developers/plugins/data-frames/#wide-format
FrameTypeTimeSeriesWide = "timeseries-wide"
// FrameTypeTimeSeriesLong uses string fields to define dimensions. I has at least two fields:
// field[0]:
// * type time
// * ascending values
// * duplicate times exist for multiple dimensions
// field[1..n]:
// * string fields define series dimensions
// * non-string fields define the series progression
// See https://grafana.com/docs/grafana/latest/developers/plugins/data-frames/#long-format
FrameTypeTimeSeriesLong = "timeseries-long"
// FrameTypeTimeSeriesMany is the same as "Wide" with exactly one numeric value field
// field[0]:
// * type time
// * ascending values
// field[1]:
// * number field
// * labels represent the series dimensions
// This structure is typically part of a list of frames with the same structure
FrameTypeTimeSeriesMany = "timeseries-many"
// Soon?
// "timeseries-wide-ohlc" -- known fields for open/high/low/close
// "histogram" -- BucketMin, BucketMax, values...
// "trace" -- ??
// "node-graph-nodes"
// "node-graph-edges"
// FrameTypeDirectoryListing represents the items in a directory
// field[0]:
// * name
// * new paths can be constructed from the parent path + separator + name
// field[1]:
// * media-type
// * when "directory" it can be nested
FrameTypeDirectoryListing = "directory-listing"
// FrameTypeTable represents an arbitrary table structure with no constraints
FrameTypeTable = "table"
)
// IsKnownType checks if the value is a known structure
func (p FrameType) IsKnownType() bool {
switch p {
case
FrameTypeTimeSeriesWide,
FrameTypeTimeSeriesLong,
FrameTypeTimeSeriesMany:
return true
}
return false
}
// FrameTypes returns a slice of all known frame types
func FrameTypes() []FrameType {
return []FrameType{
FrameTypeTimeSeriesWide,
FrameTypeTimeSeriesLong,
FrameTypeTimeSeriesMany,
}
}
// IsTimeSeries checks if the type represents a timeseries
func (p FrameType) IsTimeSeries() bool {
switch p {
case
FrameTypeTimeSeriesWide,
FrameTypeTimeSeriesLong,
FrameTypeTimeSeriesMany:
return true
}
return false
}