diff --git a/timeseries/timeseries.go b/timeseries/timeseries.go index 1fc2a236..e3e6cb1c 100644 --- a/timeseries/timeseries.go +++ b/timeseries/timeseries.go @@ -450,3 +450,12 @@ func FieldOverride(m fields.Matcher, opts ...fields.OverrideOption) Option { return nil } } + +// ConnectNulls allow to connect lines with null values +func ConnectNulls(enabled bool) Option { + return func(timeseries *TimeSeries) error { + timeseries.Builder.TimeseriesPanel.FieldConfig.Defaults.Custom.SpanNulls = enabled + + return nil + } +} diff --git a/timeseries/timeseries_test.go b/timeseries/timeseries_test.go index a26974af..14890578 100644 --- a/timeseries/timeseries_test.go +++ b/timeseries/timeseries_test.go @@ -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) +}