Skip to content

Commit 4ffddbc

Browse files
ryantxutoddtreecekylebrandt
authored
FieldConfig: add interval to field config (#454)
* add interval to FieldConfig * format * Update data/field_config.go Co-authored-by: Kyle Brandt <[email protected]> Co-authored-by: Todd Treece <[email protected]> Co-authored-by: Kyle Brandt <[email protected]>
1 parent 4f7bae6 commit 4ffddbc

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

data/arrow_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ func goldenDF() *data.Frame {
239239
time.Unix(1568039450, 0),
240240
time.Unix(0, maxEcma6Int),
241241
time.Unix(0, math.MaxInt64),
242+
}).SetConfig(&data.FieldConfig{
243+
Interval: 1000,
242244
}),
243245
// Note: This is intentionally repeated to create a duplicate field.
244246
data.NewField("timestamps", nil, []time.Time{

data/field_config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ type FieldConfig struct {
4141
Min *ConfFloat64 `json:"min,omitempty"` // is the maximum value of fields in the column. When present the frontend can skip the calculation.
4242
Max *ConfFloat64 `json:"max,omitempty"` // see Min
4343

44+
// Interval indicates the expected regular step between values in the series.
45+
// When an interval exists, consumers can identify "missing" values when the expected value is not present.
46+
// The grafana timeseries visualization will render disconnected values when missing values are found it the time field.
47+
// The interval uses the same units as the values. For time.Time, this is defined in milliseconds.
48+
Interval float64 `json:"interval,omitempty"`
49+
4450
// Convert input values into a display string
4551
Mappings ValueMappings `json:"mappings,omitempty"`
4652

104 Bytes
Binary file not shown.

data/testdata/all_types.golden.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
},
7272
{ "name": "bool_values", "type": "boolean", "typeInfo": { "frame": "bool" } },
7373
{ "name": "nullable_bool_values", "type": "boolean", "typeInfo": { "frame": "bool", "nullable": true } },
74-
{ "name": "timestamps", "type": "time", "typeInfo": { "frame": "time.Time" } },
74+
{ "name": "timestamps", "type": "time", "typeInfo": { "frame": "time.Time" }, "config": { "interval": 1000 } },
7575
{ "name": "timestamps", "type": "time", "typeInfo": { "frame": "time.Time" } },
7676
{ "name": "nullable_timestamps", "type": "time", "typeInfo": { "frame": "time.Time", "nullable": true } }
7777
]

0 commit comments

Comments
 (0)