Skip to content

Commit

Permalink
Add an option to connect nulls to the timeseries
Browse files Browse the repository at this point in the history
  • Loading branch information
valner committed Jul 24, 2024
1 parent bb1093e commit 571c833
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions timeseries/timeseries.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,11 @@ func FieldOverride(m fields.Matcher, opts ...fields.OverrideOption) Option {
return nil
}
}

func ConnectNulls(enabled bool) Option {
return func(timeseries *TimeSeries) error {
timeseries.Builder.TimeseriesPanel.FieldConfig.Defaults.Custom.SpanNulls = enabled

return nil
}
}
9 changes: 9 additions & 0 deletions timeseries/timeseries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,3 +468,12 @@ func TestValuesCanBeStacked(t *testing.T) {
req.NoError(err)
req.Equal("percent", panel.Builder.TimeseriesPanel.FieldConfig.Defaults.Custom.Stacking.Mode)
}

func TestConnectNullsCanBeConfigured(t *testing.T) {
req := require.New(t)

panel, err := New("", ConnectNulls(true))

req.NoError(err)
req.Equal(true, panel.Builder.TimeseriesPanel.FieldConfig.Defaults.Custom.SpanNulls)
}

0 comments on commit 571c833

Please sign in to comment.