import { AnchorContext, AnchorPosition, GeomCompileResult, GeomCompilerInput, GeomMappingValidationInput, GeomObservationPart, GeomStylePart, GeomStyleTarget, Observation, UserInputIssue, Geom } from '@graphysdk/react'; import { WhiskerExtent } from './utils/summarise-box'; import { BoxplotStat } from './boxplot.stat'; export interface BoxplotGeomParams { /** * How far past the quartiles a whisker may reach, in interquartile ranges: `1.5` (Tukey's) by default. A * value beyond it is drawn as an outlier. `'min-max'` runs the whiskers to the extremes, with no outliers. */ extent?: WhiskerExtent; /** * The fraction of its band a category's boxes spread across, in `(0, 1]`: `0.6` by default, so neighbours * keep a gap. Dodged, the groups share it. */ width?: number; /** Whether each value past a whisker is drawn: `true` by default. Hidden, it holds no room on the value axis. */ outliers?: boolean; /** Whether each box is notched at its median's rough 95% interval, so two boxes' medians compare at a glance. */ notch?: boolean; /** Whether each box marks its mean. */ showMean?: boolean; /** * Whether each box's width follows the root of how many values it summarises, against the layer's largest, * so a box drawn from few values reads as thinner evidence. */ varwidth?: boolean; } /** The observations paint the shared geom vocabulary on top of these. */ declare const BOX_VOCABULARY: { readonly strokeWidth: "pixels"; }; declare const LINE_VOCABULARY: { readonly stroke: "color"; readonly alpha: "unitInterval"; readonly strokeWidth: "pixels"; readonly dashArray: "dashArray"; }; declare const DOT_VOCABULARY: { readonly fill: "color"; readonly fillAlpha: "unitInterval"; readonly stroke: "color"; readonly alpha: "unitInterval"; readonly size: "pixels"; readonly strokeWidth: "pixels"; readonly symbol: "pointSymbol"; }; /** Named so the published types reach the observations and every part through `@graphysdk/react`, the package's one peer. */ interface BoxplotStyleTarget extends GeomStyleTarget { observation: GeomObservationPart; parts: { median: GeomStylePart; whisker: GeomStylePart; cap: GeomStylePart; outlier: GeomStylePart; mean: GeomStylePart; }; } /** * A boxplot: one box per category and group, from the first to the third quartile with a line at the median, * whiskers out to the furthest values within reach of the box, and every value beyond them as an outlier. * * By default data is long and raw, one row per value: `x` is the category, `y` the value and `color` the * group, and the `boxplot` stat summarises it. Under `stat: 'identity'` the data is already summarised, one * row per box: the author maps `lowerWhisker`, `q1`, `median`, `q3` and `upperWhisker` (and, if they have * them, `outlier`, `mean`, `notchLower`, `notchUpper` and `count`). A category holding several groups dodges * their boxes across its band, as a grouped bar does. A horizontal boxplot is `coord.flip()`. */ export declare class BoxplotGeom extends Geom { readonly type: "boxplot"; readonly defaultParams: BoxplotGeomParams; readonly defaultStat: BoxplotStat; readonly derivedVariables: ("boxplotQ1" | "boxplotMedian" | "boxplotQ3" | "boxplotLowerWhisker" | "boxplotUpperWhisker" | "boxplotCount" | "boxplotMean" | "boxplotNotchLower" | "boxplotNotchUpper" | "boxplotRelativeWidth" | "boxplotOutlier")[]; /** * The whiskers are the value interval, so they drive the value axis. The median, quartiles and outliers are * scaled on the same axis. */ readonly positionRoles: readonly [{ readonly axis: "x"; readonly role: "point"; readonly valueKind: "value"; }, { readonly axis: "y"; readonly role: "min"; readonly valueKind: "value"; readonly aesthetic: "lowerWhisker"; }, { readonly axis: "y"; readonly role: "max"; readonly valueKind: "value"; readonly aesthetic: "upperWhisker"; }, { readonly axis: "y"; readonly role: "scalar"; readonly valueKind: "value"; readonly aesthetic: "q1"; }, { readonly axis: "y"; readonly role: "scalar"; readonly valueKind: "value"; readonly aesthetic: "median"; }, { readonly axis: "y"; readonly role: "scalar"; readonly valueKind: "value"; readonly aesthetic: "q3"; }, { readonly axis: "y"; readonly role: "scalar"; readonly valueKind: "value"; readonly aesthetic: "outlier"; }, { readonly axis: "y"; readonly role: "scalar"; readonly valueKind: "value"; readonly aesthetic: "mean"; }, { readonly axis: "y"; readonly role: "scalar"; readonly valueKind: "value"; readonly aesthetic: "notchLower"; }, { readonly axis: "y"; readonly role: "scalar"; readonly valueKind: "value"; readonly aesthetic: "notchUpper"; }]; /** `y` is the raw values the stat summarises; `count` how many values a box summarises, which `varwidth` reads. */ readonly aesthetics: readonly [{ readonly kind: "visual"; readonly name: "color"; }, { readonly kind: "data"; readonly name: "y"; }, { readonly kind: "data"; readonly name: "count"; }]; readonly defaultPosition = "dodge"; /** A stacked box would start on the one below it, and its quartiles would read as lengths they are not. */ readonly supportedPositions: readonly ["identity", "dodge"]; readonly supportedCoordTypes: readonly ["cartesian", "flip"]; /** The value axis fits the data: a box encodes where values sit, not a length from zero. */ readonly scaleConstraints: { requireMainAxisBands: boolean; }; /** A grid line at each category's center would run along the whiskers and through the box. */ readonly grid: { cartesian: { hideGridX: boolean; }; flip: { hideGridX: boolean; }; }; readonly legend: { suppressWhenSingleItem: boolean; }; /** * A hovered box is one unit, from its lower whisker to its upper across its share of the band, so a dodged * group's box answers for itself. An outlier is a rect of no extent at its value on its box's share, so it * answers once the cursor is nearer it than the box. */ readonly spatialKind = "rects"; readonly highlightStrategy: "observationRerender"; /** * A box's tooltip reads its summary top to bottom, and an outlier's its own value, each formatted like the * value axis. The two kinds of observation carry none of each other's fields, so each drops the other's rows. */ readonly tooltip: { key: string; aesthetic: string; optional: boolean; }[]; readonly styleTarget: BoxplotStyleTarget; /** The boxes spread across `width` of their band, so an axis annotation aligned to an edge lands where they end. */ readonly resolveBandFraction: Geom['resolveBandFraction']; /** A pinned number or a difference arrow on a box measures its median, where the box is read. */ readonly resolveValueSource: Geom['resolveValueSource']; /** Substitutes an unreadable `extent` or `width` and reports it, so the same spec can't diverge across renderers. */ resolveParams(options: Parameters[0]): Record; /** * Under the `boxplot` stat the summary comes from the raw values of `y`, so a mapped summary aesthetic would * be overwritten. Under any other stat the author maps the summary, and a box needs its quartiles and median; * a stat that computes `y` would leave nothing to draw a box from. */ readonly validateMapping: ({ mapping, computedAesthetics, }: GeomMappingValidationInput) => readonly UserInputIssue[]; /** * Where the editor raises its annotation trigger and where an annotation lands: on a box's median at the * centre of the box, which is where a box is read, or on an outlier itself. */ readonly resolveAnchorPosition: (observation: Observation, { coordSystem }: AnchorContext) => AnchorPosition | null; compile({ data, mapping, params }: GeomCompilerInput): GeomCompileResult; private resolveExtent; /** * Above `1` the boxes would overlap the next category's, so it clamps to the full band; at or below `0` * nothing is drawable, so the default takes over. */ private resolveWidth; } export {};