import { BinEdge, BinningOptions } from './bins'; import { HistogramNormalize } from './normalize'; import { Datum } from '../../../shared/options'; /** How the groups of one bin share the space. */ export type HistogramGroupMode = /** Piled on top of each other — the bin total stays readable. */ 'stacked' /** Piled and scaled to 100 per bin: the composition of every bin. */ | 'normalized' /** Side by side within the bin. */ | 'grouped' /** All from zero, drawn over each other — the shapes are compared. */ | 'overlay'; /** Whose total a share is a share of. */ export type HistogramNormalizeWithin = 'total' | 'group'; export interface HistogramModelOptions extends BinningOptions { xField: string; yField?: string; aggregation?: 'count' | 'sum' | 'mean'; normalize?: HistogramNormalize; normalizeWithin?: HistogramNormalizeWithin; groupField?: string; groupMode?: HistogramGroupMode; } /** One group's share of one bin. */ export interface BinSlice { /** What the bar draws — the aggregate restated by `normalize`. */ value: number; /** The aggregate before normalization. */ raw: number; /** Rows of this group that landed in the bin. */ count: number; } export interface HistogramGroup { /** The value of `groupField` this group stands for; undefined without grouping. */ key: unknown; label: string; /** Hidden groups keep their place in the legend and draw nothing. */ hidden: boolean; /** One slice per bin, in bin order. */ slices: BinSlice[]; } export interface HistogramModel { edges: BinEdge[]; groups: HistogramGroup[]; /** True when `groupField` split the data — the legend and the tooltip say so. */ grouped: boolean; } /** * The values the grid is built from. A calendar grain reads them as dates — * a Date, a timestamp or an ISO string; a numeric grid takes numbers, and a * Date beside them still means the moment it stands for. */ export declare function binnedValues(data: Datum[], key: string, time: boolean): number[]; /** * Bins, groups and the value of every slice. `hidden` holds the indices of the * groups switched off in the legend: they draw nothing and count towards no * total, the way a filtered-out category does in a BI tool. */ export declare function buildModel(data: Datum[], options: HistogramModelOptions, hidden?: ReadonlySet): HistogramModel;