import type { ReactNode } from 'react'; import type { ConvertibleUnit, FormatOptions, Unit } from '@dynatrace-sdk/units'; import type { BehaviorTrackingProps } from '../../../../core/types/behavior-tracking-props.js'; import type { DataTestId } from '../../../../core/types/data-props.js'; import type { MaskingProps } from '../../../../core/types/masking-props.js'; import type { StylingProps } from '../../../../core/types/styling-props.js'; import type { ColorRuleProps } from '../../../core/types/color-rule.js'; import type { Formatter } from '../../../core/types/formatter.js'; import type { SeriesActionsTemplate } from '../../../core/types/series-actions-template.js'; import type { MeterBarSize } from '../../shared/types/meter-bars.js'; /** * Information hold by the meter bar chart * @public */ export type MeterBarSegmentData = { id: string; name: string; values: string[]; }; /** * @public */ export interface MeterBarChartData { [key: string]: unknown; } /** * @public */ export interface MeterBarChartBaseProps extends StylingProps, MaskingProps, DataTestId, BehaviorTrackingProps { /** * The chart width. A valid CSS width is expected. * @defaultValue 100% */ width?: number | string; /** * The chart height. A valid CSS height is expected. * @defaultValue 300px */ height?: number | string; /** * Min value for the meter bar chart scale. * @defaultValue 0 */ min?: number; /** * Max value for the meter bar chart scale. * @defaultValue 100 */ max?: number; /** * Color of the meter bar segment. If not provided, it will display a default color. * @defaultValue 'Categorical.Color11' */ color?: string; /** Show the loading indicator when truthy. * @defaultValue false */ loading?: boolean; /** * The size that applies to the value, icon, and label. * @defaultValue 'size16' */ size?: MeterBarSize; /** * The custom unit for the value of the meter bar. */ unit?: string | Unit; /** * Segment name. If not provided, it will display a default name. * @defaultValue 'value' */ name?: string; /** * Custom Formatter for the chart */ formatter?: Formatter | FormatOptions; /** * Icon to show left of the label. */ prefixIcon?: ReactNode; /** Exposed callback to display series actions */ seriesActions?: (seriesData: MeterBarSegmentData) => SeriesActionsTemplate; /** Color rules to apply to the meter bar chart */ colorRules?: ColorRuleProps[]; } /** * @public */ export interface MeterBarChartPropsWithAccessor extends MeterBarChartBaseProps { /** * Data object to retrieve the value from using the valueAccessor. */ value: MeterBarChartData; /** * Accessor string to retrieve the value from the data object. */ valueAccessor: string; } /** * @public */ export interface MeterBarChartPropsWithNumericValue extends MeterBarChartBaseProps { /** * Numeric value to be displayed by the Gauge Chart. */ value: number; valueAccessor?: never; } /** * @public */ export type MeterBarChartProps = MeterBarChartPropsWithAccessor | MeterBarChartPropsWithNumericValue; /** * The active threshold the current value falls into. * @public */ export interface MeterBarChartActiveThreshold { /** Threshold label */ label?: string; /** Threshold color */ color: string; } /** * Data passed to the custom tooltip render function for MeterBarChart. * @public */ export interface MeterBarChartTooltipPayload { /** Numeric value currently displayed */ value: number; /** Scale minimum */ min: number; /** Scale maximum */ max: number; /** Segment color */ color: string; /** Segment name */ name: string; /** Active threshold range the current value falls into, or undefined if none */ threshold: MeterBarChartActiveThreshold | undefined; } /** * Props for the MeterBarChart.Tooltip slot component * @public */ export interface MeterBarChartTooltipProps { /** * Hides the tooltip when true. The tooltip is shown by default. * @defaultValue false */ hidden?: boolean; /** * The name shown in the tooltip. */ name?: string; /** * Custom render function. When provided, replaces the default tooltip content. */ children?: (payload: MeterBarChartTooltipPayload) => ReactNode; } /** * Props for the MeterBarChart.Threshold slot component * @public */ export interface MeterBarChartThresholdIndicatorProps { /** * Name of the threshold displayed in the threshold legend. */ name?: string; /** * The color of the threshold. * @defaultValue 'Categorical.Color11' */ color?: string; /** * The value of the threshold. */ value: number; /** * When set to true, it shows the indicator of the threshold. * @defaultValue false */ showIndicator?: boolean; }