import type { ContextCallbackParams, DatumCallbackParams, HighlightState, Listener, SelectionState, SeriesCallbackParams, Styler } from '../../chart/callbackOptions'; import type { AgNumericValue } from '../../chart/dataValues'; import type { AgDropShadowOptions } from '../../chart/dropShadowOptions'; import type { AgNodeClickEvent } from '../../chart/eventOptions'; import type { AgChartLabelOptions } from '../../chart/labelOptions'; import type { AgSeriesTooltip } from '../../chart/tooltipOptions'; import type { ContextDefault, DatumDefault, DatumKey, PixelSize } from '../../chart/types'; import type { AgBaseCartesianThemeableOptions, AgBaseSeriesOptions, AgHighlightStyleOptions, AgMultiSeriesHighlightOptions } from '../seriesOptions'; import type { AgCartesianSeriesTooltipRendererParams } from './cartesianSeriesTooltipOptions'; import type { AgBaseCartesianSeriesAxisOptions, FillOptions, LineDashOptions, StrokeOptions } from './commonOptions'; /** * The standard set of bin data exposed to every histogram callback (tooltip, label formatter, * node click/double-click, context menu and `getItemId`). */ export interface AgHistogramSeriesBinParams { /** Always `undefined` for a bin, which aggregates many rows; use `datums` for the source rows. */ readonly datum: undefined; /** Every source row grouped into the bin. */ readonly datums: TDatum[]; /** Zero-based positional index of the bin within the series. Defined for every bin, including empty ones. */ readonly binIndex: number; /** The bin's start and end bounds on the x-axis. `bigint` values for a bigint `xKey` column. */ readonly binRange: [AgNumericValue, AgNumericValue]; /** The aggregated `yKey` value for the bin. A `bigint` when a bigint `yKey` column is summed (`aggregation: 'sum'`). */ readonly aggregatedValue: AgNumericValue; /** The number of source rows within the bin. */ readonly frequency: number; } export interface AgHistogramSeriesTooltipRendererParams extends Omit, 'xKey' | 'yKey' | 'datum'>, AgHistogramSeriesBinParams, FillOptions, StrokeOptions { /** xKey as specified on series options. */ readonly xKey: DatumKey; /** yKey as specified on series options. */ readonly yKey?: DatumKey; } export interface AgHistogramSeriesLabelFormatterParams extends AgHistogramSeriesOptionsKeys, AgHistogramSeriesOptionsNames, AgHistogramSeriesBinParams { /** The default label value that would have been used without a formatter. */ readonly value: any; } export interface AgHistogramSeriesGetItemIdParams extends ContextCallbackParams, AgHistogramSeriesBinParams { } export interface AgHistogramSeriesStyle extends FillOptions, StrokeOptions, LineDashOptions { /** Apply rounded corners to each bar. */ cornerRadius?: PixelSize; } export interface AgHistogramSeriesItemStylerParams extends Omit, 'datum'>, ContextCallbackParams, AgHistogramSeriesOptionsKeys, AgHistogramSeriesBinParams, Required { } export interface AgHistogramSeriesStylerParams extends SeriesCallbackParams, ContextCallbackParams, AgHistogramSeriesOptionsKeys, Required { } export interface AgHistogramSeriesThemeableOptions extends Omit, 'selection'>, AgHistogramSeriesStyle { /** A callback function for adjusting the styles of the whole series based on the highlight or selection state. */ styler?: Styler, AgHistogramSeriesStyle>; /** A callback function for adjusting the styles of each bin individually, based on its range, frequency and aggregated value. */ itemStyler?: Styler, AgHistogramSeriesStyle>; /** Configuration for the shadow used behind the chart series. */ shadow?: AgDropShadowOptions; /** Configuration for the labels shown on bars. */ label?: AgChartLabelOptions, TContext>; /** Series-specific tooltip configuration. */ tooltip?: AgSeriesTooltip>; /** Configuration for highlighting when a series or legend item is hovered over. */ highlight?: AgMultiSeriesHighlightOptions; /** * If `true`, the aggregated `yKey` values will be represented using the area of the bar, instead of just the height. */ areaPlot?: boolean; /** Set the bin sizes explicitly. * * __Note:__ `bins` is ignored if `binCount` is also supplied. */ bins?: [number, number][]; /** The number of bins to try to split the x-axis into. */ binCount?: number; /** Dictates how the `yKey` values are aggregated within each bin. * * Default: `sum` */ aggregation?: 'count' | 'sum' | 'mean'; } export interface AgHistogramSeriesOptionsKeys { /** The key to use to retrieve x-values from the data. */ xKey: DatumKey; /** The key to use to retrieve y-values from the data. */ yKey?: DatumKey; } export interface AgHistogramSeriesOptionsNames { /** A human-readable description of the x-values. If supplied, this will be shown in the default tooltip and passed to the tooltip renderer as one of the parameters. */ xName?: string; /** A human-readable description of the y-values. If supplied, this will be shown in the default tooltip and passed to the tooltip renderer as one of the parameters. */ yName?: string; } /** Node click/double-click event fired for a histogram bin. */ export interface AgHistogramSeriesNodeClickEvent extends Omit, 'datum' | 'datums'>, AgHistogramSeriesBinParams { } export interface AgHistogramSeriesNodeDoubleClickEvent extends Omit, 'datum' | 'datums'>, AgHistogramSeriesBinParams { } export interface AgHistogramSeriesListeners { /** The listener to call when a histogram bin is clicked. */ seriesNodeClick?: Listener>; /** The listener to call when a histogram bin is double-clicked. */ seriesNodeDoubleClick?: Listener>; } export interface AgHistogramSeriesOptions extends Omit, 'highlight' | 'selection' | 'listeners'>, AgBaseCartesianSeriesAxisOptions, AgHistogramSeriesOptionsKeys, AgHistogramSeriesOptionsNames, Omit, 'listeners'> { /** Configuration for Histogram Series. */ type: 'histogram'; /** A map of event names to event listeners. */ listeners?: AgHistogramSeriesListeners; /** * A callback to provide a stable identifier for each bin, exposed as `itemId` in events and active state. * * The returned identifier must be unique across all bins in the series. * * If not supplied, an identifier is generated from the bin boundaries. */ getItemId?: (params: AgHistogramSeriesGetItemIdParams) => string; }