diff --git a/public/app/features/alerting/unified/components/rule-editor/VizWrapper.tsx b/public/app/features/alerting/unified/components/rule-editor/VizWrapper.tsx index a033016d428..d826ec6439f 100644 --- a/public/app/features/alerting/unified/components/rule-editor/VizWrapper.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/VizWrapper.tsx @@ -4,6 +4,7 @@ import { css } from '@emotion/css'; import { FieldConfigSource, GrafanaTheme2, PanelData, ThresholdsConfig } from '@grafana/data'; import { PanelRenderer } from '@grafana/runtime'; import { PanelContext, PanelContextProvider, useStyles2 } from '@grafana/ui'; +import { GraphFieldConfig, GraphTresholdsStyleMode } from '@grafana/schema'; import { PanelOptions } from 'app/plugins/panel/table/models.gen'; import { useVizHeight } from '../../hooks/useVizHeight'; import { SupportedPanelPlugins, PanelPluginsButtonGroup } from '../PanelPluginsButtonGroup'; @@ -17,6 +18,8 @@ interface Props { onThresholdsChange: (thresholds: ThresholdsConfig) => void; } +type PanelFieldConfig = FieldConfigSource; + export const VizWrapper: FC = ({ data, currentPanel, changePanel, onThresholdsChange, thresholds }) => { const [options, setOptions] = useState({ frameIndex: 0, @@ -25,7 +28,7 @@ export const VizWrapper: FC = ({ data, currentPanel, changePanel, onThres const vizHeight = useVizHeight(data, currentPanel, options.frameIndex); const styles = useStyles2(getStyles(vizHeight)); - const [fieldConfig, setFieldConfig] = useState(defaultFieldConfig(thresholds, data)); + const [fieldConfig, setFieldConfig] = useState(defaultFieldConfig(thresholds, data)); useEffect(() => { setFieldConfig((fieldConfig) => ({ @@ -37,7 +40,7 @@ export const VizWrapper: FC = ({ data, currentPanel, changePanel, onThres custom: { ...fieldConfig.defaults.custom, thresholdsStyle: { - mode: 'line', + mode: GraphTresholdsStyleMode.Line, }, }, }, @@ -104,7 +107,7 @@ function defaultUnit(data: PanelData): string | undefined { return data.series[0]?.fields.find((field) => field.type === 'number')?.config.unit; } -function defaultFieldConfig(thresholds: ThresholdsConfig, data: PanelData): FieldConfigSource { +function defaultFieldConfig(thresholds: ThresholdsConfig, data: PanelData): PanelFieldConfig { if (!thresholds) { return { defaults: {}, overrides: [] }; } @@ -115,7 +118,7 @@ function defaultFieldConfig(thresholds: ThresholdsConfig, data: PanelData): Fiel unit: defaultUnit(data), custom: { thresholdsStyle: { - mode: 'line', + mode: GraphTresholdsStyleMode.Line, }, }, },