import type { ScaleLinear, ScaleLogarithmic, ScaleSymLog } from 'd3-scale'; import { type ReactElement } from 'react'; import { type MaskingProps, type StylingProps } from '@dynatrace/strato-components/core'; import type { TruncationMode } from '@dynatrace/strato-components/typography'; import type { ConvertibleUnit, FormatOptions, Unit } from '@dynatrace-sdk/units'; import type { ChartUnit } from '../../core/types/chart-unit.js'; import type { ColorPalette, ColorToken, CustomColorPalette } from '../../core/types/color-palette.js'; import type { Formatter } from '../../core/types/formatter.js'; import type { ChartInteractionsConfig, ZoomInteractions } from '../../core/types/interactions.js'; import type { LegendProps } from '../../core/types/legend.js'; import type { AxisScaleType, ValueRepresentation } from '../../core/types/scales.js'; import type { ChartToolbarConfig } from '../../core/types/toolbar.js'; import type { WithId } from '../../core/types/with-id.js'; import type { HistogramAnnotationsConfigProps } from '../components/annotations-histogram/types.js'; import type { SelectProps } from '../slots/Select.js'; import type { HistogramThresholdProps } from '../slots/Threshold.js'; /** * @public */ export type HistogramZoomDomain = number[]; /** * @public */ export interface HistogramBin { /** * The start of the bin or bucket */ from: number; /** * The end of the bin or bucket */ to: number; /** * The value, better known as "frequency" */ value: number; } /** * @public */ export interface HistogramSeries { /** * The histogram series data to be graphed by the component */ bins: HistogramBin[]; /** * The name for the histogram series */ name: string; /** * Unit token for the values in the y-axis of the histogram series */ unit?: ChartUnit; /** * The color to be applied to the series */ color?: string; } /** * @internal */ export interface SeriesMetadata { id: string; color: ColorToken; scaleIndex: number; } /** * @internal */ export interface TooltipValueMetadata { value: number; unit: ChartUnit; } /** * @internal */ export interface BinMetadata extends HistogramBin { seriesId: string; color: ColorToken; unit: ChartUnit; seriesName: string; cumulativeValue?: number; absolute?: TooltipValueMetadata; } /** * @internal */ export type WeakMapSeries = WeakMap; /** * @internal */ export type WeakMapBins = WeakMap; /** * @public */ export interface HistogramChartProps extends StylingProps, MaskingProps, ZoomInteractions { /** * Data object for the histogram chart */ data: HistogramSeries[]; /** * Chart height. When a number is specified, it's treated as pixels, * otherwise a valid height string is expected. * @defaultValue 300px */ height?: number | string; /** * Chart width. A number in pixels is expected. Otherwise, it will take the full width of the container * @defaultValue 100% */ width?: number; /** * Actions to be shown in the legend and tooltip actions */ seriesActions?: (series: HistogramSeries, bin: HistogramBin) => ReactElement; /** * Truncation mode to use (start, middle, end) * Applied to all the parts that truncate text. * @defaultValue 'middle' */ truncationMode?: TruncationMode; /** * Color palette to be used for the bar category. * @defaultValue "categorical" */ colorPalette?: ColorPalette | CustomColorPalette; /** Show the loading indicator when truthy. * @defaultValue false */ loading?: boolean; /** * The way values are represented. "absolute" will display the value as it is, and "relative" displays a percentage value considering the other dimensions values within a categories. * @defaultValue "absolute" */ valueRepresentation?: ValueRepresentation; /** * Enables infinite zooming * @defaultValue false */ infiniteZoom?: boolean; } /** * @internal */ export interface HistogramDataPoint { /** * The value in X axis */ x: number; /** * The value in Y axis */ y: number; } /** * @internal */ export interface ContinuousSeries { /** * The continuous series data to be graphed by the component */ dataPoints: HistogramDataPoint[]; /** * The name or names in case of multiple dimensions for the continuous series */ name: string; /** * Unit token for the values in the y-axis of the histogram chart */ unit?: ChartUnit; } /** * Configuration properties for histogram chart * @public */ export interface HistogramChartConfigProperties extends ZoomInteractions { /** * Chart toolbar configuration */ toolbar?: HistogramChartToolbarProps; /** * Chart interactions configuration * */ interactions?: ChartInteractionsConfig; /** * Chart legend properties */ legend?: HistogramChartLegendProps; /** * Chart X axis properties */ xAxis?: HistogramChartXAxisProps; /** * Chart Y axis properties */ yAxis?: HistogramChartYAxisProps[]; /** * Chart tooltip properties */ tooltip?: HistogramChartTooltipProps; /** * Color palette */ colorPalette?: ColorPalette | CustomColorPalette; /** * The truncation mode to use (start, middle, center) * Applied to all the parts that truncate text. * @defaultValue 'middle' */ truncationMode?: TruncationMode; /** * Chart thresholds configuration */ thresholds?: HistogramThresholdProps[]; /** * Defines if values are absolute or relative * @defaultValue 'absolute' */ valueRepresentation?: ValueRepresentation; /** * Enables infinite zooming */ infiniteZoom?: boolean; } /** * @public */ export declare const histogramTooltipVariantOptions: readonly ["single", "shared", "grouped"]; /** * @public */ export type HistogramTooltipVariant = (typeof histogramTooltipVariantOptions)[number]; /** * Props for the HistogramChart.Tooltip slot component * @public */ export interface HistogramChartTooltipProps { /** * Whether the tooltip should contain bins from * all series or just the closest one. */ variant?: HistogramTooltipVariant; } /** * @public */ export interface HistogramChartXAxisProps { /** * The max value configuration to display in the axis * @defaultValue 'auto' */ max?: number | 'auto' | 'data-max'; /** * The min value configuration to display in the axis * @defaultValue 'auto' */ min?: number | 'auto' | 'data-min'; /** * The title used for the axis */ label?: string; /** * The scale to be used */ scale?: AxisScaleType; /** * Formatter to be applied for each tick of the axis */ formatter?: Formatter | FormatOptions; /** * The unit for the axis */ unit?: ChartUnit; } /** * @public */ export interface HistogramChartYAxisProps { /** * The max value configuration to display in the axis * @defaultValue 'auto' */ max?: number | 'auto' | 'data-max'; /** * The min value configuration to display in the axis * @defaultValue 'auto' */ min?: number | 'auto' | 'data-min'; /** * The title used for the axis */ label?: string; /** * The scale to be used */ scale?: AxisScaleType; /** * Formatter to be applied for each tick of the axis */ formatter?: Formatter | FormatOptions; /** * The position of the y axis relative to * the histogram chart * @defaultValue 'left' */ position?: 'left' | 'right'; } /** * @internal */ export type HistogramThresholdConfig = HistogramThresholdProps; /** * @internal */ export interface HistogramThresholdsConfig { leftThreshold?: WithId[]; rightThreshold?: WithId[]; } /** * @internal */ export interface HistogramChartConfiguration extends ZoomInteractions { /** * Color palette */ colorPalette: ColorPalette | CustomColorPalette; /** * Defines tooltip configuration * */ tooltip: HistogramChartTooltipConfig; /** * Chart toolbar configuration */ toolbar?: HistogramChartToolbarConfig; /** * Chart legend configuration */ legend: HistogramChartLegendConfig; /** * Chart X axis configuration */ xAxis: HistogramChartXAxisConfig; /** * Chart Y axis configuration */ yAxis: HistogramChartYAxisConfig; /** * Truncation mode applied when text overflows */ truncationMode: TruncationMode; /** * Value representation configuration */ valueRepresentation: ValueRepresentation; /** * Annotations configuration */ annotations?: HistogramAnnotationsConfigProps; /** * Chart Interactions configuration */ interactions?: ChartInteractionsConfig; /** * Chart thresholds configuration */ thresholds?: HistogramThresholdsConfig; /** * Enables the infiniteZoom */ infiniteZoom: boolean; /** * Enables and configures select interaction */ select?: SelectProps; } /** * @internal */ export type HistogramChartTooltipConfig = Required; /** * @internal */ export type AxesUnits = [ChartUnit, ChartUnit]; /** * @public */ export type HistogramChartLegendProps = LegendProps; /** * Props for the ChartToolbar implementation in HistogramChart * @public */ export interface HistogramChartToolbarProps extends ChartToolbarConfig { /** Toggles the toolbar display */ enabled?: boolean; } /** * @internal */ export type HistogramChartToolbarConfig = HistogramChartToolbarProps; /** * @internal */ export type HistogramChartLegendConfig = HistogramChartLegendProps; /** * @internal */ export interface HistogramChartXAxisConfig extends HistogramChartXAxisProps { scale: AxisScaleType; } /** * @internal */ export interface HistogramChartYAxisConfig { left?: HistogramChartYAxisProps; right?: HistogramChartYAxisProps; } /** * @internal */ export type HistogramSelectConfig = SelectProps; /** @internal */ export interface HistogramChartConfigProps extends ZoomInteractions { toolbar?: HistogramChartToolbarProps; legend?: HistogramChartLegendProps; xAxis?: HistogramChartXAxisProps; yAxis?: HistogramChartYAxisProps; tooltip?: HistogramChartTooltipProps; colorPalette?: ColorPalette | CustomColorPalette; truncationMode?: TruncationMode; valueRepresentation?: ValueRepresentation; infiniteZoom?: boolean; } /** * @internal */ export interface HistogramChartSlots { /** * Chart Toolbar slot */ toolbar: HistogramChartToolbarProps; /** * Chart legend slot */ legend: HistogramChartLegendProps; /** * Chart X axis slot */ xAxis?: HistogramChartXAxisProps; /** * Chart Y axis slot */ yAxis: HistogramChartYAxisProps[]; /** * Chart tooltip slot */ tooltip: HistogramChartTooltipProps; /** * Chart Annotations slot */ annotations?: HistogramAnnotationsConfigProps; /** * Chart Interactions slot */ interactions?: ChartInteractionsConfig; /** * Chart thresholds slot */ thresholds: HistogramThresholdProps[]; /** * ValueRepresentation slot * @defaultValue "absolute" */ valueRepresentation?: ValueRepresentation; /** * Select interaction slot */ select?: HistogramSelectConfig; } /** * @internal */ export type XScale = ScaleLinear | ScaleLogarithmic | ScaleSymLog; /** * @internal */ export type YScale = ScaleLinear | ScaleLogarithmic | ScaleSymLog; /** * API config for a chart zoom interaction * @internal */ export interface ChartZoomConfig { /** Enables a specific zoom interaction on the chart. */ enabled?: boolean; }