StateTimeline: Properly type tooltip prop, remove ts-ignore (#83189)

This commit is contained in:
Leon Sorokin 2024-02-22 06:14:53 -06:00 committed by GitHub
parent 0dcdfc261b
commit dbbbfa282d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { DataFrame, FALLBACK_COLOR, FieldType, TimeRange } from '@grafana/data'; import { DataFrame, FALLBACK_COLOR, FieldType, TimeRange } from '@grafana/data';
import { VisibilityMode, TimelineValueAlignment, TooltipDisplayMode } from '@grafana/schema'; import { VisibilityMode, TimelineValueAlignment, TooltipDisplayMode, VizTooltipOptions } from '@grafana/schema';
import { PanelContext, PanelContextRoot, UPlotConfigBuilder, VizLayout, VizLegend, VizLegendItem } from '@grafana/ui'; import { PanelContext, PanelContextRoot, UPlotConfigBuilder, VizLayout, VizLegend, VizLegendItem } from '@grafana/ui';
import { GraphNG, GraphNGProps } from '../GraphNG/GraphNG'; import { GraphNG, GraphNGProps } from '../GraphNG/GraphNG';
@ -18,6 +18,7 @@ export interface TimelineProps extends Omit<GraphNGProps, 'prepConfig' | 'propsT
alignValue?: TimelineValueAlignment; alignValue?: TimelineValueAlignment;
colWidth?: number; colWidth?: number;
legendItems?: VizLegendItem[]; legendItems?: VizLegendItem[];
tooltip?: VizTooltipOptions;
} }
const propsToDiff = ['rowHeight', 'colWidth', 'showValue', 'mergeValues', 'alignValue', 'tooltip']; const propsToDiff = ['rowHeight', 'colWidth', 'showValue', 'mergeValues', 'alignValue', 'tooltip'];
@ -58,7 +59,7 @@ export class TimelineChart extends React.Component<TimelineProps> {
// When there is only one row, use the full space // When there is only one row, use the full space
rowHeight: alignedFrame.fields.length > 2 ? this.props.rowHeight : 1, rowHeight: alignedFrame.fields.length > 2 ? this.props.rowHeight : 1,
getValueColor: this.getValueColor, getValueColor: this.getValueColor,
// @ts-ignore
hoverMulti: this.props.tooltip?.mode === TooltipDisplayMode.Multi, hoverMulti: this.props.tooltip?.mode === TooltipDisplayMode.Multi,
}); });
}; };