UNPKG

@grafana/ui

Version:
47 lines (46 loc) 1.85 kB
import type * as React from 'react'; import type { JSX, ReactNode } from 'react'; import { type DataFrameFieldIndex, type DisplayValue } from '@grafana/data'; import { type LegendOverflow, type LegendDisplayMode, type LegendPlacement, type LineStyle } from '@grafana/schema'; export declare enum SeriesVisibilityChangeBehavior { Isolate = 0, Hide = 1 } export interface VizLegendBaseProps<T> { placement: LegendPlacement; className?: string; items: Array<VizLegendItem<T>>; thresholdItems?: Array<VizLegendItem<T>>; mappingItems?: Array<VizLegendItem<T>>; seriesVisibilityChangeBehavior?: SeriesVisibilityChangeBehavior; onLabelClick?: (item: VizLegendItem<T>, event: React.MouseEvent<HTMLButtonElement>) => void; itemRenderer?: (item: VizLegendItem<T>, index: number) => JSX.Element; onLabelMouseOver?: (item: VizLegendItem, event: React.MouseEvent<HTMLButtonElement> | React.FocusEvent<HTMLButtonElement>) => void; onLabelMouseOut?: (item: VizLegendItem, event: React.MouseEvent<HTMLButtonElement> | React.FocusEvent<HTMLButtonElement>) => void; readonly?: boolean; limit?: number; filterAction?: ReactNode; } export interface VizLegendTableProps<T> extends VizLegendBaseProps<T> { sortBy?: string; sortDesc?: boolean; onToggleSort?: (sortBy: string) => void; isSortable?: boolean; overflow?: LegendOverflow; } export interface LegendProps<T = any> extends VizLegendBaseProps<T>, VizLegendTableProps<T> { displayMode?: LegendDisplayMode; } export interface VizLegendItem<T = any> { getItemKey?: () => string; label: string; color?: string; gradient?: string; yAxis: number; disabled?: boolean; getDisplayValues?: () => DisplayValue[]; fieldIndex?: DataFrameFieldIndex; fieldName?: string; data?: T; lineStyle?: LineStyle; }