@acronis-platform/ui-react 5.5.2 → 5.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"chart-format.js","names":[],"sources":["../../../../src/components/ui/chart/chart-format.ts"],"sourcesContent":["// Shared axis helpers for the cartesian chart components (BarChart, LineChart,\n// AreaChart, ComposedChart, ScatterChart, ConfidenceCone, Histogram). Three\n// concerns live here so every chart formats + toggles axes the same way rather\n// than each reimplementing it:\n//\n// 1. `CartesianChartProps` — the common axis knobs each cartesian chart mixes\n// into its own props (show/hide either axis, per-axis tick formatting).\n// 2. A small set of tick formatters (+ a factory) callers pass to\n// `xTickFormatter` / `yTickFormatter`.\n// 3. `resolveAxisDomain` — maps the `yAxisDomain` preset to a recharts\n// `domain`, shared so all 7 charts can't drift apart on it.\n//\n// These format only the axis *tick labels*; series colors and tokens are\n// unaffected. Formatters coerce to a number and pass non-numeric values through\n// untouched (a category axis stays readable if a formatter is applied to it).\n\nimport type { AxisDomainItem } from 'recharts';\n\nimport type { ChartTooltipContentType } from './chart';\n\n/** A recharts-compatible tick formatter: `(value, index) => label`. */\nexport type TickFormatter = (value: number | string, index?: number) => string;\n\n/**\n * Format the source values a chart may render on its X axis. The concrete ticks\n * remain recharts' responsibility; the displayed values become a stable layout\n * key so a rotated category row is remeasured when they change.\n */\nexport function resolveXAxisTickLabels(\n values: readonly unknown[],\n formatter?: TickFormatter\n): Array<string | number> {\n return values.map((value, index) => {\n if (typeof value !== 'string' && typeof value !== 'number') return '';\n return formatter ? formatter(value, index) : value;\n });\n}\n\n/**\n * Props shared by every cartesian chart (Bar, Line, Area, Composed, Scatter,\n * ConfidenceCone, Histogram) — chrome toggles, axis titles/units, tick\n * formatting/visibility, and grid trim. All optional. `showLegend` and `xUnit`\n * are deliberately *not* here: `showLegend` doesn't apply to `Histogram` and\n * `xUnit` only to charts with a numeric X axis, so they stay per-component.\n */\nexport interface CartesianChartProps {\n /** Render the CartesianGrid. Defaults to `true`. */\n showGrid?: boolean;\n /** Render the hover tooltip. Defaults to `true`. */\n showTooltip?: boolean;\n /**\n * Replace the default tooltip. Pass a configured `ChartTooltipContent` (from\n * this library) — e.g. with a `formatter` / `labelFormatter` — to customize it\n * without composing recharts yourself. Ignored when `showTooltip` is false.\n */\n tooltipContent?: ChartTooltipContentType;\n /** Title rendered beneath the X axis. */\n xAxisLabel?: string;\n /** Title rendered beside the Y axis (rotated). */\n yAxisLabel?: string;\n /**\n * Unit suffix appended to the Y axis's tick values (recharts `unit`) — applies\n * when the Y axis is the numeric one. `ComposedChart` with\n * `orientation=\"horizontal\"` puts the values on X instead; use `xUnit` there.\n */\n yUnit?: string;\n /** Show the X axis (its ticks + title). Defaults to `true`. */\n showXAxis?: boolean;\n /** Show the Y axis (its ticks + title). Defaults to `true`. */\n showYAxis?: boolean;\n /** Format each X-axis tick value — e.g. `formatCompactNumber` or a `createTickFormatter(...)`. */\n xTickFormatter?: TickFormatter;\n /** Format each Y-axis tick value — e.g. `formatCompactNumber` or a `createTickFormatter(...)`. */\n yTickFormatter?: TickFormatter;\n /**\n * Rotate the X-axis tick labels by this many degrees. A negative angle (e.g.\n * `-45`) tilts them up toward the right; the tick anchor + axis height adjust\n * to keep long labels readable.\n */\n xAxisAngle?: number;\n /**\n * X-axis tick density — a recharts placement strategy, or a fixed number of\n * ticks to *skip* between two rendered ones (recharts `interval`: `0` shows\n * every tick, `1` every other one, `2` every third, …).\n */\n xAxisInterval?:\n | number\n | 'preserveStart'\n | 'preserveEnd'\n | 'preserveStartEnd'\n | 'equidistantPreserveStart';\n /**\n * Desired number of ticks on the value axis (recharts `tickCount`; a hint, not\n * exact). Applies to whichever axis holds the values — Y for most charts, X for\n * `BarChart` with `orientation=\"horizontal\"`.\n */\n yAxisTickCount?: number;\n /**\n * Value-axis domain preset. Applies to whichever axis holds the values — Y for\n * most charts, X for `BarChart` with `orientation=\"horizontal\"`.\n *\n * - `auto` — fit the data at both ends; the axis need not include 0.\n * - `zero` — anchor the axis at 0. This is also recharts' behavior when the\n * prop is omitted, so it's the explicit form of the default.\n * - `dataMin-dataMax` — tight to the data, with no padding.\n */\n yAxisDomain?: 'auto' | 'dataMin-dataMax' | 'zero';\n /** Draw grid lines dashed instead of solid. */\n gridDashed?: boolean;\n /** Show horizontal grid lines. Defaults to each chart's own default when unset. */\n gridHorizontal?: boolean;\n /** Show vertical grid lines. Defaults to each chart's own default when unset. */\n gridVertical?: boolean;\n}\n\n/**\n * Map a `yAxisDomain` preset to a recharts `domain`. Shared by all 7 cartesian\n * charts, and applied to whichever axis holds the values (X for horizontal bars).\n *\n * `undefined` (no preset) is left to recharts, whose default is `[0, 'auto']` —\n * i.e. already zero-anchored. That's why `auto` has to be spelled out as\n * `['auto', 'auto']`: passing `undefined` for it would silently anchor at 0 and\n * make the preset indistinguishable from `zero`.\n */\nexport function resolveAxisDomain(\n preset: 'auto' | 'dataMin-dataMax' | 'zero' | undefined\n): Readonly<[AxisDomainItem, AxisDomainItem]> | undefined {\n switch (preset) {\n case 'auto':\n return ['auto', 'auto'];\n case 'zero':\n return [0, 'auto'];\n case 'dataMin-dataMax':\n return ['dataMin', 'dataMax'];\n default:\n return undefined;\n }\n}\n\n/**\n * `text-anchor` for a rotated X tick row, so the tick's text ends (or begins) at\n * the tick it labels instead of straddling it. Shared by all 7 cartesian charts.\n *\n * A tick rotated anti-clockwise trails off to the lower left, so it must be\n * anchored at its end; a clockwise one trails to the lower right and is anchored\n * at its start. Only an *omitted* angle keeps recharts' own default (`middle`):\n * the branch is on `angle < 0`, so `angle={0}` anchors at `start` like any\n * clockwise rotation. A caller that normalises \"upright\" to `0` instead of\n * leaving `xAxisAngle` off therefore gets the rotated-tick treatment — here and\n * in `resolveXAxisHeight`.\n */\nexport function resolveRotatedTickAnchor(\n angle: number | undefined\n): 'start' | 'end' | undefined {\n if (angle == null) return undefined;\n return angle < 0 ? 'end' : 'start';\n}\n\n/**\n * Height to reserve for the X tick row, or `undefined` to keep recharts' own\n * default. Shared by all 7 cartesian charts.\n *\n * recharts' default 30 covers one upright tick row and nothing else. The\n * browser refines the rotated-label fallback after layout through\n * `useXAxisLayout`, using the labels' actual SVG bounds rather than an\n * estimate based on character count.\n *\n * The +20 keys off the angle being *present*, not non-zero, so `angle={0}`\n * reserves the rotated row's height as well — the same edge case\n * `resolveRotatedTickAnchor` has, kept consistent between the two.\n */\nexport function resolveXAxisHeight(\n label: string | undefined,\n angle: number | undefined\n): number | undefined {\n if (!label && angle == null) return undefined;\n\n const titleHeight = label ? 18 : 0;\n if (angle == null) return 30 + titleHeight;\n\n // This modest first-pass allocation prevents a visible jump for ordinary\n // rotated labels. A longest-label estimate is exactly what creates the empty\n // area the post-layout measurement replaces.\n return 30 + 20 + titleHeight;\n}\n\n/**\n * recharts `label` for an X axis title, placed below the tick row. Shared by all\n * 7 cartesian charts; `insideTop` is for a secondary scale on the top edge.\n */\nexport function resolveXAxisTitle(\n label: string | undefined,\n position: 'insideBottom' | 'insideTop' = 'insideBottom',\n offset = 0\n) {\n if (!label) return undefined;\n return { value: label, position, offset };\n}\n\n/**\n * recharts `label` for a rotated value-axis title, angled so it reads from the\n * outside in — upward on a left axis (the convention), downward on a right one,\n * where -90° would put the text's baseline against the plot. Shared by all 7\n * cartesian charts; only `ComposedChart` currently uses the right-hand side.\n */\nexport function resolveYAxisTitle(\n label: string | undefined,\n orientation: 'left' | 'right' = 'left'\n) {\n if (!label) return undefined;\n return {\n value: label,\n angle: orientation === 'left' ? -90 : 90,\n position:\n orientation === 'left' ? ('insideLeft' as const) : ('insideRight' as const),\n style: { textAnchor: 'middle' as const },\n };\n}\n\n/**\n * A category range on a cartesian chart: `from`/`to` accept either the\n * category's value (an `xKey` cell, e.g. `'Sep'`) or its 0-based row index. Both\n * ends are inclusive, and either can be omitted to run to that end of the data.\n * Shared by the charts that scope something to a slice of the categories — a\n * reference band, a per-series style override.\n */\nexport interface ChartCategoryRange {\n from?: string | number;\n to?: string | number;\n}\n\n/**\n * Resolve a category range to inclusive row indices. A bound is either the\n * category's own value (matched against the `xKey` cell) or a 0-based index;\n * an omitted bound runs to that end of the data. Returns `undefined` when the\n * data is empty or the range resolves to nothing (an unknown value, or a `to`\n * that lands before its `from`).\n *\n * Exported for unit tests; not part of the package's public API.\n */\nexport function resolveCategoryRange(\n range: ChartCategoryRange,\n data: ReadonlyArray<Record<string, unknown>>,\n xKey: string\n): [number, number] | undefined {\n if (data.length === 0) return undefined;\n\n const resolve = (bound: string | number | undefined, fallback: number) => {\n if (bound === undefined) return fallback;\n // A numeric bound is an index unless the categories are numbers themselves,\n // in which case matching a category value is the more useful reading.\n const asValue = data.findIndex((row) => row[xKey] === bound);\n if (asValue !== -1) return asValue;\n if (typeof bound === 'number' && Number.isInteger(bound)) {\n return bound >= 0 && bound < data.length ? bound : -1;\n }\n return -1;\n };\n\n const start = resolve(range.from, 0);\n const end = resolve(range.to, data.length - 1);\n if (start === -1 || end === -1 || start > end) return undefined;\n return [start, end];\n}\n\n/**\n * Which value axis a series is measured against, on a chart that can carry two.\n *\n * `secondary` is the opt-in: the second axis exists only when at least one series\n * asks for it, so a chart whose series all leave this unset keeps the single\n * shared scale — and its recharts output — exactly as before.\n */\nexport type ChartYAxisTarget = 'primary' | 'secondary';\n\n/**\n * Second value-axis props, for a chart whose series can be measured on two\n * independent scales. **Only `ComposedChart` implements these today.** It is the\n * one chart in the suite where two scales are unambiguous: its series already\n * differ in mark type, so a bar read against the left axis and a line against the\n * right can't be mistaken for two marks sharing one. On a single-mark chart (Bar,\n * Area) two scales invite comparing heights that aren't comparable, which is why\n * these props are not mixed into `CartesianChartProps`.\n *\n * The primary axis is configured through `CartesianChartProps` (`yAxisLabel`,\n * `yUnit`, `yTickFormatter`, `yAxisTickCount`, `yAxisDomain`, `showYAxis`); every\n * `secondary*` prop here is its counterpart on the second axis, so the two scales\n * format and bound themselves independently, and each is inert until a series\n * selects that axis.\n *\n * `yAxisOrientation` is the exception on both counts: it places the *primary*\n * axis, and it applies whether or not a second one exists. It lives here because\n * it is only meaningful once a chart can mirror a pair of axes — a single-axis\n * chart has no second side to give up.\n */\nexport interface SecondaryYAxisProps {\n /**\n * Which side the *primary* value axis sits on. Defaults to `left`. The secondary\n * axis always takes the opposite side. Unlike the `secondary*` props below, this\n * one applies to a single-scale chart too.\n *\n * Inert on a chart whose marks grow horizontally: the value axis is X there, so\n * the primary sits along the bottom edge and the secondary along the top, and\n * neither has a left/right side to pick.\n */\n yAxisOrientation?: 'left' | 'right';\n /**\n * Show the secondary axis's ticks + title. Defaults to `true`. Setting it false\n * keeps the second *scale* (series still measure against it) and only drops its\n * chrome — the same meaning `showYAxis` has for the primary axis.\n */\n showSecondaryYAxis?: boolean;\n /** Title rendered beside the secondary axis (rotated). */\n secondaryYAxisLabel?: string;\n /** Unit suffix appended to the secondary axis's tick values (recharts `unit`). */\n secondaryYUnit?: string;\n /** Format each secondary-axis tick value — the counterpart of `yTickFormatter`. */\n secondaryYTickFormatter?: TickFormatter;\n /** Desired number of ticks on the secondary axis (recharts `tickCount`; a hint, not exact). */\n secondaryYAxisTickCount?: number;\n /** Domain preset for the secondary axis — same presets as `yAxisDomain`. */\n secondaryYAxisDomain?: 'auto' | 'dataMin-dataMax' | 'zero';\n}\n\n/**\n * How a series interpolates between its points (recharts `type`), shared by the\n * Line and Area families so both offer the same set:\n *\n * - `linear` — straight segments between points.\n * - `monotone` — smoothed, without overshooting a point's value.\n * - `natural` — a natural cubic spline; smoother than `monotone`, but it may\n * overshoot, so read it as a trend rather than exact values.\n * - `basis` — a B-spline that is *not* required to pass through the points at\n * all; the smoothest option, and the least literal.\n * - `step` — right-angle segments, changing value at the midpoint between two\n * points; `stepBefore` changes at the leading point and `stepAfter` at the\n * trailing one.\n */\nexport type ChartCurveType =\n | 'linear'\n | 'monotone'\n | 'natural'\n | 'basis'\n | 'step'\n | 'stepBefore'\n | 'stepAfter';\n\n/** recharts animation easing curves. */\nexport type ChartAnimationEasing =\n | 'ease'\n | 'ease-in'\n | 'ease-out'\n | 'ease-in-out'\n | 'linear';\n\n/**\n * Entrance-animation props shared by *every* chart type (not just the cartesian\n * ones) — charts hardcode `isAnimationActive={false}` otherwise. All optional and\n * off by default, so an unset chart renders byte-identically to before (and its\n * VR baselines stay stable). Spread `resolveAnimation(props)` onto each series.\n */\nexport interface ChartAnimationProps {\n /** Enable entrance animation. Defaults to `false` (keeps output/baselines stable). */\n animate?: boolean;\n /** Animation duration in ms (recharts `animationDuration`). */\n animationDuration?: number;\n /** Delay before the animation starts, in ms (recharts `animationBegin`). */\n animationBegin?: number;\n /** Easing curve (recharts `animationEasing`). */\n animationEasing?: ChartAnimationEasing;\n}\n\n/** The resolved recharts animation props to spread onto a series/shape. */\nexport interface ResolvedAnimation {\n isAnimationActive: boolean | 'auto';\n animationDuration?: number;\n animationBegin?: number;\n animationEasing?: ChartAnimationEasing;\n}\n\n/**\n * Turn the shared `ChartAnimationProps` into the recharts series props. The\n * timing props only appear when given, so an unset chart spreads exactly\n * `{ isAnimationActive: false }` — the previous hardcoded value.\n *\n * `animate` maps to recharts' `'auto'`, not to a literal `true`: `'auto'` is the\n * only value that honors `prefers-reduced-motion` (and disables the animation in\n * SSR). recharts resolves it as\n * `isActive = isActiveProp === 'auto' ? !isSsr && !prefersReducedMotion : isActiveProp`,\n * so a literal `true` would force motion on users who asked for none — this\n * library has no other reduced-motion escape hatch.\n */\nexport function resolveAnimation(props: ChartAnimationProps): ResolvedAnimation {\n const { animate = false, animationDuration, animationBegin, animationEasing } =\n props;\n return {\n isAnimationActive: animate ? 'auto' : false,\n ...(animationDuration !== undefined ? { animationDuration } : {}),\n ...(animationBegin !== undefined ? { animationBegin } : {}),\n ...(animationEasing !== undefined ? { animationEasing } : {}),\n };\n}\n\n/**\n * Remove synthetic `_proj_*` series entries from a recharts payload array so\n * they don't appear in custom tooltip or legend content. Safe to call with\n * `undefined` — returns `undefined` unchanged.\n */\nexport function dropProjectionPayload<T extends { dataKey?: unknown }>(\n payload: readonly T[] | undefined\n): T[] | undefined {\n return payload?.filter(\n (item) =>\n !(typeof item.dataKey === 'string' && item.dataKey.startsWith('_proj_'))\n );\n}\n\n/** Where a data label sits on a cartesian series (recharts `LabelList` position). */\nexport type CartesianLabelPosition =\n | 'top'\n | 'bottom'\n | 'left'\n | 'right'\n | 'center'\n | 'insideTop'\n | 'insideBottom'\n | 'insideLeft'\n | 'insideRight'\n | 'insideStart'\n | 'insideEnd';\n\n/**\n * Where a data label sits on a *polar* series (Pie, RadialBar). Deliberately not\n * `CartesianLabelPosition`: recharts routes a polar label list through\n * `getAttrsOfPolarLabel` / `renderRadialLabel`, which understand only these\n * seven values — every cartesian-only position (`top`, `insideLeft`, …) silently\n * collapses to the same mid-radius placement, so offering them would advertise\n * distinctions that don't exist.\n */\nexport type PolarLabelPosition =\n | 'outside'\n | 'center'\n | 'centerTop'\n | 'centerBottom'\n | 'insideStart'\n | 'insideEnd'\n | 'end';\n\n/** Any position accepted by the suite's data labels. */\nexport type ChartLabelPosition = CartesianLabelPosition | PolarLabelPosition;\n\n/**\n * Data-label props shared by the charts that can annotate each point/segment with\n * its value. `labelPosition` stays per-chart (the valid position set differs by\n * family), but `showLabels` + `labelFormatter` are common. Label formatting reuses\n * the same `TickFormatter` type as the axes, so a label and its axis read the same.\n */\nexport interface ChartDataLabelProps {\n /** Render a value label on each data point/segment. Defaults to `false`. */\n showLabels?: boolean;\n /** Format each label value — pass the same formatter used on the value axis. */\n labelFormatter?: TickFormatter;\n}\n\n/**\n * Fill for a label that sits on the chart *surface* — i.e. an outside position\n * (`top`, `right`, polar `outside`). Inverts with the theme, so it only works\n * against the surface background.\n */\nexport const CHART_LABEL_FILL_CLASS = 'fill-[var(--ui-text-on-surface-primary)]!';\n\n/**\n * Fill for a label that sits on an *opaque series fill* — any `inside*`\n * position, a polar mid-radius/centroid placement, or a stacked bar/arc segment\n * (an area's fill is translucent, so it uses the on-surface token). The on-surface\n * token must not be used there: it resolves near-white in dark mode and drops to\n * ~1.6:1 against the saturated status/brand fills the charts colour series with,\n * failing the `accessibility/contrast` grammar rule (`must`, WCAG 1.4.3). This is\n * the same \"text on a strong colored surface\" token `Treemap` already uses; it is\n * white in both themes, so it holds up over every series colour.\n */\nexport const CHART_LABEL_FILL_ON_SERIES_CLASS =\n 'fill-[var(--ui-text-on-status-strong-neutral)]!';\n\nexport const CHART_LABEL_FONT_SIZE = 12;\n\n/**\n * Plot-area inset to apply when a Line/Area series carries outside data labels.\n * recharts hands those label lists `parentViewBox: undefined` (its own source\n * calls this out as a bug in `cartesian/Line.js`), so `getCartesianPosition`'s\n * `clamp` has nothing to clamp against and the first/last point's value is cut\n * off at the SVG edge. Widening the margin is the only lever a composition over\n * recharts has. `Bar` does pass a `parentViewBox`, so bar series don't need it.\n */\nexport const CHART_LABEL_MARGIN = {\n top: 16,\n right: 24,\n bottom: 5,\n left: 12,\n} as const;\n\n/** Positions that draw the label on top of the series fill rather than the surface. */\nconst ON_SERIES_LABEL_POSITIONS = new Set<ChartLabelPosition>([\n 'center',\n 'centerTop',\n 'centerBottom',\n 'insideTop',\n 'insideBottom',\n 'insideLeft',\n 'insideRight',\n 'insideStart',\n 'insideEnd',\n 'end',\n]);\n\n/**\n * Resolve where a cartesian value label sits, given the caller's override, the\n * layout, and the position of the series' growing end (`top` for a vertical bar\n * or a line/area point, `right` for a horizontal bar).\n *\n * The stacked branch is the reason this isn't inlined: a stacked segment has no\n * free space at its growing end — the next segment is drawn there — so a `top`\n * label lands *inside* its neighbour rather than over its own segment. Centring\n * it in its own segment is the readable placement; `resolveLabelFillClass` then\n * pairs it with the fill that has contrast over that family's series colour.\n */\nexport function resolveCartesianLabelPosition(options: {\n labelPosition?: CartesianLabelPosition;\n isStacked?: boolean;\n growingEnd?: CartesianLabelPosition;\n}): CartesianLabelPosition {\n const { labelPosition, isStacked = false, growingEnd = 'top' } = options;\n if (labelPosition !== undefined) return labelPosition;\n return isStacked ? 'center' : growingEnd;\n}\n\n/**\n * Pick the label fill that actually has contrast at `position`. Callers must pass\n * the *resolved* position (after their own default), never `undefined` for a\n * polar chart — recharts' polar fallback is a mid-radius placement, which is on\n * the fill even though no `inside*` value was given.\n *\n * Returns a `className`, not a `fill` attribute, and the utility is `!`-flagged:\n * the cartesian charts scope `[&_.recharts-label]:fill-foreground` on their\n * container to theme axis titles, and a `LabelList`'s text carries\n * `.recharts-label` too — so a CSS rule would quietly beat an SVG presentation\n * attribute and undo the contrast fix.\n *\n * `translucentSeries` opts a family out of the on-fill token: an area's fill is\n * a gradient (0.8 → 0.1 alpha) or a flat `fillOpacity`, so what sits behind the\n * label is the surface tinted by the series colour, not the series colour. The\n * white on-fill token disappears into it in light mode — the theme-inverting\n * on-surface token is the readable one there, and stays white in dark mode.\n */\nexport function resolveLabelFillClass(\n position: ChartLabelPosition,\n options: { translucentSeries?: boolean } = {}\n): string {\n if (options.translucentSeries) return CHART_LABEL_FILL_CLASS;\n return ON_SERIES_LABEL_POSITIONS.has(position)\n ? CHART_LABEL_FILL_ON_SERIES_CLASS\n : CHART_LABEL_FILL_CLASS;\n}\n\n/**\n * Adapt a `TickFormatter` to recharts' `LabelList` `formatter` prop, whose value\n * type is wider. Returns `undefined` when no formatter is given, so a label\n * renders its raw value. Lets labels reuse the same formatters as the value axis.\n *\n * Null/undefined is filtered out rather than forwarded: recharts builds a label\n * entry for *every* point including the null ones that `connectNulls` is meant to\n * bridge, and the tick formatters coerce (`formatCompactNumber(null)` is `\"0\"`,\n * `formatPercent(undefined)` is `\"undefined\"`) — which would paint a phantom\n * value over an intentional gap.\n */\nexport function toLabelFormatter(\n formatter: TickFormatter | undefined\n): ((value: unknown) => string) | undefined {\n if (!formatter) return undefined;\n return (value: unknown) =>\n value == null ? '' : formatter(value as number | string);\n}\n\n/** Where a reference line's caption sits relative to the rule. */\nexport type ChartReferenceLabelPosition =\n | 'top'\n | 'insideTopLeft'\n | 'insideTopRight'\n | 'insideBottomLeft'\n | 'insideBottomRight';\n\n/**\n * A dashed rule across the value axis — a target, a threshold, or a series\n * average. Shared by the cartesian charts that draw one (`BarChart`,\n * `LineChart`, `AreaChart`) so the config reads the same on all three.\n */\nexport interface ChartReferenceLine {\n /** Fixed position on the value axis. Takes precedence over `average`. */\n value?: number;\n /**\n * Draw the line at the mean of one series (a `dataKeys` entry) or, when\n * `true`, of every plotted series' values.\n */\n average?: boolean | string;\n /** Optional caption rendered alongside the line. */\n label?: string;\n /**\n * Where the caption sits. Defaults to the chart's own placement — move it\n * when the rule lands where the series already is and the two collide.\n */\n labelPosition?: ChartReferenceLabelPosition;\n}\n\n/**\n * Normalize the `referenceLine` prop — a single config or an array — to a list.\n * Every chart accepts both forms, so this keeps the render path uniform.\n */\nexport function toReferenceLineList(\n referenceLine: ChartReferenceLine | ChartReferenceLine[] | undefined\n): ChartReferenceLine[] {\n if (!referenceLine) return [];\n return Array.isArray(referenceLine) ? referenceLine : [referenceLine];\n}\n\n/**\n * Resolve a `referenceLine` config to a position on the value axis: a fixed\n * `value` wins; otherwise the mean of the requested series (a single `dataKeys`\n * entry, or all of them when `average` is `true`). Returns `undefined` when\n * there is nothing to draw (no config, or no numeric values to average) — the\n * caller skips the line rather than drawing it at 0.\n *\n * Rows are `unknown`-valued because `ComposedChart` types its data that way; the\n * body only ever reads cells that are numbers, so a wider row type costs nothing\n * and saves every caller a cast.\n */\nexport function resolveChartReferenceValue(\n referenceLine: ChartReferenceLine | undefined,\n data: ReadonlyArray<Record<string, unknown>>,\n dataKeys: string[]\n): number | undefined {\n if (!referenceLine) return undefined;\n if (typeof referenceLine.value === 'number') return referenceLine.value;\n if (!referenceLine.average) return undefined;\n\n const keys =\n typeof referenceLine.average === 'string'\n ? [referenceLine.average]\n : dataKeys;\n const nums = data.flatMap((row) =>\n keys\n .map((key) => row[key])\n .filter((value): value is number => typeof value === 'number')\n );\n if (nums.length === 0) return undefined;\n return nums.reduce((sum, n) => sum + n, 0) / nums.length;\n}\n\n/**\n * Stroke (and caption fill) of a reference rule. The muted text token, so the\n * rule reads as annotation rather than as another series — and stays legible in\n * both themes without competing with the series colors.\n */\nexport const CHART_REFERENCE_LINE_STROKE =\n 'var(--ui-text-on-surface-secondary)';\n\n/**\n * The recharts props that paint a reference rule: a dashed line in the muted\n * text token with an optional caption. Shared so the three charts that draw one\n * can't drift on the stroke, dash pattern, or caption styling.\n *\n * `labelPosition` is the chart's default placement; a config's own\n * `labelPosition` overrides it at the call site.\n *\n * `ifOverflow: 'extendDomain'` is part of the contract, not a detail: a target\n * above the data maximum is exactly the case a reference line is for, and\n * recharts' default (`discard`) would silently drop it.\n */\nexport function resolveReferenceLineProps(\n label: string | undefined,\n labelPosition: ChartReferenceLabelPosition = 'insideTopRight'\n) {\n return {\n stroke: CHART_REFERENCE_LINE_STROKE,\n strokeDasharray: '4 4',\n ifOverflow: 'extendDomain' as const,\n label: label\n ? {\n value: label,\n position: labelPosition,\n fill: CHART_REFERENCE_LINE_STROKE,\n fontSize: CHART_LABEL_FONT_SIZE,\n }\n : undefined,\n };\n}\n\n/**\n * Range-brush props for the cartesian charts that support one — `BarChart`,\n * `LineChart`, `AreaChart`, `ComposedChart`. Deliberately not folded into\n * `CartesianChartProps`: `ScatterChart` plots a continuous X (the brush indexes\n * rows, not values) and `Histogram` / `ConfidenceCone` render a derived series,\n * so a brush over their row order would slice the wrong thing.\n */\nexport interface ChartBrushProps {\n /**\n * Render a range brush beneath the chart — drag its handles (or the selected\n * window) to zoom the series to a slice of the data. Defaults to `false`.\n */\n showBrush?: boolean;\n /** Height of the brush strip in px. Defaults to 28. */\n brushHeight?: number;\n /**\n * Accessible name for the brush's two range handles. Both are focusable\n * `role=\"slider\"` elements, so they need one. Defaults to\n * `'Chart range selector'`.\n */\n brushAriaLabel?: string;\n}\n\n/**\n * Height of the brush strip. recharts' own default is 40, which eats an eighth\n * of a 320px-tall dashboard widget; 28 still fits the travellers and the\n * range captions.\n */\nexport const CHART_BRUSH_HEIGHT = 28;\n\n/**\n * Accessible name for the brush handles. recharts' own fallback is\n * `\"Min value: \".concat(start, \", Max value: \").concat(end)`, where both halves\n * come from a `name` property on the data row — a field none of our charts\n * require, so it announces \"Min value: undefined, Max value: undefined\". Always\n * pass `ariaLabel` to suppress it.\n */\nexport const CHART_BRUSH_ARIA_LABEL = 'Chart range selector';\n\n/** The resolved recharts brush props to spread onto a `<Brush>`. */\nexport interface ResolvedBrush {\n height: number;\n fill: string;\n stroke: string;\n travellerWidth: number;\n ariaLabel: string;\n}\n\n/**\n * Theme + size a recharts `<Brush>` from the shared `ChartBrushProps`.\n *\n * recharts derives the *whole* brush from two color props, so both have to be\n * chosen for every element they reach (`cartesian/Brush.js`):\n * - `fill` paints only the strip's background rect.\n * - `stroke` paints its border, the traveller handles' **fill**, the selected\n * window at 20% opacity, and the range caption text.\n *\n * Hence the mid-grey text token rather than the border one: the travellers are\n * solid `stroke`-colored rects with two hardcoded `#fff` grip lines drawn on\n * top, so a pale stroke would render the grips invisible in light mode. That\n * token is theme-stable (same grey in light and dark), and white grips read\n * against it either way.\n */\nexport function resolveBrushProps({\n brushHeight,\n brushAriaLabel = CHART_BRUSH_ARIA_LABEL,\n}: Omit<ChartBrushProps, 'showBrush'>): ResolvedBrush {\n return {\n // recharts drops the brush entirely when height <= 0, which would turn\n // `showBrush` into a silent no-op — treat a non-positive height as unset.\n height:\n brushHeight != null && brushHeight > 0 ? brushHeight : CHART_BRUSH_HEIGHT,\n fill: 'var(--ui-background-surface-secondary)',\n stroke: 'var(--ui-text-on-surface-secondary)',\n travellerWidth: 8,\n ariaLabel: brushAriaLabel,\n };\n}\n\nconst toNumber = (value: number | string): number | null => {\n // `Number('')` and `Number(' ')` are 0, not NaN — so blank strings have to be\n // rejected before the finite check, or an empty tick label would render \"0\".\n if (typeof value === 'string' && value.trim() === '') return null;\n const n = typeof value === 'number' ? value : Number(value);\n return Number.isFinite(n) ? n : null;\n};\n\n/**\n * Compact thousands/millions: `1234 → \"1.2K\"`, `1_500_000 → \"1.5M\"`. Non-numeric\n * values (including blank strings) pass through unchanged. Use for large-count\n * axes (revenue, users, …).\n *\n * Formats in `en`. For another locale use\n * `createTickFormatter({ notation: 'compact', maximumFractionDigits: 1 }, locale)`.\n */\nexport const formatCompactNumber: TickFormatter = (value) => {\n const n = toNumber(value);\n if (n === null) return String(value);\n return new Intl.NumberFormat('en', {\n notation: 'compact',\n maximumFractionDigits: 1,\n }).format(n);\n};\n\n/**\n * Append a percent sign to an already-scaled value: `41.8 → \"41.8%\"`. (The value\n * is treated as a percentage, not a 0–1 fraction.) Non-numeric values (including\n * blank strings) pass through.\n *\n * Appends a bare `%`, which is not how every locale writes it. For locale-correct\n * output on values that really are fractions, use\n * `createTickFormatter({ style: 'percent' }, locale)`.\n */\nexport const formatPercent: TickFormatter = (value) => {\n const n = toNumber(value);\n if (n === null) return String(value);\n return `${n}%`;\n};\n\n/**\n * Build a tick formatter from `Intl.NumberFormat` options — the escape hatch for\n * currency, fixed decimals, or a specific locale. E.g.\n * `createTickFormatter({ style: 'currency', currency: 'USD', notation: 'compact' })`\n * → `146500 → \"$147K\"`. Non-numeric values pass through unchanged.\n */\nexport function createTickFormatter(\n options: Intl.NumberFormatOptions,\n locale = 'en'\n): TickFormatter {\n const nf = new Intl.NumberFormat(locale, options);\n return (value) => {\n const n = toNumber(value);\n return n === null ? String(value) : nf.format(n);\n };\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"chart-format.js","names":[],"sources":["../../../../src/components/ui/chart/chart-format.ts"],"sourcesContent":["// Shared axis helpers for the cartesian chart components (BarChart, LineChart,\n// AreaChart, ComposedChart, ScatterChart, ConfidenceCone, Histogram). Three\n// concerns live here so every chart formats + toggles axes the same way rather\n// than each reimplementing it:\n//\n// 1. `CartesianChartProps` — the common axis knobs each cartesian chart mixes\n// into its own props (show/hide either axis, per-axis tick formatting).\n// 2. A small set of tick formatters (+ a factory) callers pass to\n// `xTickFormatter` / `yTickFormatter`.\n// 3. `resolveAxisDomain` — maps the `yAxisDomain` preset to a recharts\n// `domain`, shared so all 7 charts can't drift apart on it.\n//\n// These format only the axis *tick labels*; series colors and tokens are\n// unaffected. Formatters coerce to a number and pass non-numeric values through\n// untouched (a category axis stays readable if a formatter is applied to it).\n\nimport type { AxisDomainItem } from 'recharts';\n\nimport type { ChartTooltipContentType } from './chart';\n\n/** A recharts-compatible tick formatter: `(value, index) => label`. */\nexport type TickFormatter = (value: number | string, index?: number) => string;\n\n/**\n * Format the source values a chart may render on its X axis. The concrete ticks\n * remain recharts' responsibility; the displayed values become a stable layout\n * key so a rotated category row is remeasured when they change.\n */\nexport function resolveXAxisTickLabels(\n values: readonly unknown[],\n formatter?: TickFormatter\n): Array<string | number> {\n return values.map((value, index) => {\n if (typeof value !== 'string' && typeof value !== 'number') return '';\n return formatter ? formatter(value, index) : value;\n });\n}\n\n// Preserve the charts' previous 72px reserve for a rotated Y-axis title while\n// empty. It is only a pre-measurement fallback; rendered ticks determine the\n// width as soon as data exists.\nconst Y_AXIS_LABEL_FALLBACK_WIDTH = 72;\n\n/**\n * Internal shared layout helper. Recharts measures an automatic Y axis from\n * rendered tick nodes. Starting that process with no data can store a zero-width\n * axis before any tick exists, so retain the title fallback until it can measure.\n */\nexport function resolveYAxisWidth(\n hasData: boolean,\n hasYAxisLabel: boolean\n): 'auto' | number | undefined {\n return hasData ? 'auto' : hasYAxisLabel ? Y_AXIS_LABEL_FALLBACK_WIDTH : undefined;\n}\n\n/**\n * Props shared by every cartesian chart (Bar, Line, Area, Composed, Scatter,\n * ConfidenceCone, Histogram) — chrome toggles, axis titles/units, tick\n * formatting/visibility, and grid trim. All optional. `showLegend` and `xUnit`\n * are deliberately *not* here: `showLegend` doesn't apply to `Histogram` and\n * `xUnit` only to charts with a numeric X axis, so they stay per-component.\n */\nexport interface CartesianChartProps {\n /** Render the CartesianGrid. Defaults to `true`. */\n showGrid?: boolean;\n /** Render the hover tooltip. Defaults to `true`. */\n showTooltip?: boolean;\n /**\n * Replace the default tooltip. Pass a configured `ChartTooltipContent` (from\n * this library) — e.g. with a `formatter` / `labelFormatter` — to customize it\n * without composing recharts yourself. Ignored when `showTooltip` is false.\n */\n tooltipContent?: ChartTooltipContentType;\n /** Title rendered beneath the X axis. */\n xAxisLabel?: string;\n /** Title rendered beside the Y axis (rotated). */\n yAxisLabel?: string;\n /**\n * Unit suffix appended to the Y axis's tick values (recharts `unit`) — applies\n * when the Y axis is the numeric one. `ComposedChart` with\n * `orientation=\"horizontal\"` puts the values on X instead; use `xUnit` there.\n */\n yUnit?: string;\n /** Show the X axis (its ticks + title). Defaults to `true`. */\n showXAxis?: boolean;\n /** Show the Y axis (its ticks + title). Defaults to `true`. */\n showYAxis?: boolean;\n /** Format each X-axis tick value — e.g. `formatCompactNumber` or a `createTickFormatter(...)`. */\n xTickFormatter?: TickFormatter;\n /** Format each Y-axis tick value — e.g. `formatCompactNumber` or a `createTickFormatter(...)`. */\n yTickFormatter?: TickFormatter;\n /**\n * Rotate the X-axis tick labels by this many degrees. A negative angle (e.g.\n * `-45`) tilts them up toward the right; the tick anchor + axis height adjust\n * to keep long labels readable.\n */\n xAxisAngle?: number;\n /**\n * X-axis tick density — a recharts placement strategy, or a fixed number of\n * ticks to *skip* between two rendered ones (recharts `interval`: `0` shows\n * every tick, `1` every other one, `2` every third, …).\n */\n xAxisInterval?:\n | number\n | 'preserveStart'\n | 'preserveEnd'\n | 'preserveStartEnd'\n | 'equidistantPreserveStart';\n /**\n * Desired number of ticks on the value axis (recharts `tickCount`; a hint, not\n * exact). Applies to whichever axis holds the values — Y for most charts, X for\n * `BarChart` with `orientation=\"horizontal\"`.\n */\n yAxisTickCount?: number;\n /**\n * Value-axis domain preset. Applies to whichever axis holds the values — Y for\n * most charts, X for `BarChart` with `orientation=\"horizontal\"`.\n *\n * - `auto` — fit the data at both ends; the axis need not include 0.\n * - `zero` — anchor the axis at 0. This is also recharts' behavior when the\n * prop is omitted, so it's the explicit form of the default.\n * - `dataMin-dataMax` — tight to the data, with no padding.\n */\n yAxisDomain?: 'auto' | 'dataMin-dataMax' | 'zero';\n /** Draw grid lines dashed instead of solid. */\n gridDashed?: boolean;\n /** Show horizontal grid lines. Defaults to each chart's own default when unset. */\n gridHorizontal?: boolean;\n /** Show vertical grid lines. Defaults to each chart's own default when unset. */\n gridVertical?: boolean;\n}\n\n/**\n * Map a `yAxisDomain` preset to a recharts `domain`. Shared by all 7 cartesian\n * charts, and applied to whichever axis holds the values (X for horizontal bars).\n *\n * `undefined` (no preset) is left to recharts, whose default is `[0, 'auto']` —\n * i.e. already zero-anchored. That's why `auto` has to be spelled out as\n * `['auto', 'auto']`: passing `undefined` for it would silently anchor at 0 and\n * make the preset indistinguishable from `zero`.\n */\nexport function resolveAxisDomain(\n preset: 'auto' | 'dataMin-dataMax' | 'zero' | undefined\n): Readonly<[AxisDomainItem, AxisDomainItem]> | undefined {\n switch (preset) {\n case 'auto':\n return ['auto', 'auto'];\n case 'zero':\n return [0, 'auto'];\n case 'dataMin-dataMax':\n return ['dataMin', 'dataMax'];\n default:\n return undefined;\n }\n}\n\n/**\n * `text-anchor` for a rotated X tick row, so the tick's text ends (or begins) at\n * the tick it labels instead of straddling it. Shared by all 7 cartesian charts.\n *\n * A tick rotated anti-clockwise trails off to the lower left, so it must be\n * anchored at its end; a clockwise one trails to the lower right and is anchored\n * at its start. Only an *omitted* angle keeps recharts' own default (`middle`):\n * the branch is on `angle < 0`, so `angle={0}` anchors at `start` like any\n * clockwise rotation. A caller that normalises \"upright\" to `0` instead of\n * leaving `xAxisAngle` off therefore gets the rotated-tick treatment — here and\n * in `resolveXAxisHeight`.\n */\nexport function resolveRotatedTickAnchor(\n angle: number | undefined\n): 'start' | 'end' | undefined {\n if (angle == null) return undefined;\n return angle < 0 ? 'end' : 'start';\n}\n\n/**\n * Height to reserve for the X tick row, or `undefined` to keep recharts' own\n * default. Shared by all 7 cartesian charts.\n *\n * recharts' default 30 covers one upright tick row and nothing else. The\n * browser refines the rotated-label fallback after layout through\n * `useXAxisLayout`, using the labels' actual SVG bounds rather than an\n * estimate based on character count.\n *\n * The +20 keys off the angle being *present*, not non-zero, so `angle={0}`\n * reserves the rotated row's height as well — the same edge case\n * `resolveRotatedTickAnchor` has, kept consistent between the two.\n */\nexport function resolveXAxisHeight(\n label: string | undefined,\n angle: number | undefined\n): number | undefined {\n if (!label && angle == null) return undefined;\n\n const titleHeight = label ? 18 : 0;\n if (angle == null) return 30 + titleHeight;\n\n // This modest first-pass allocation prevents a visible jump for ordinary\n // rotated labels. A longest-label estimate is exactly what creates the empty\n // area the post-layout measurement replaces.\n return 30 + 20 + titleHeight;\n}\n\n/**\n * recharts `label` for an X axis title, placed below the tick row. Shared by all\n * 7 cartesian charts; `insideTop` is for a secondary scale on the top edge.\n */\nexport function resolveXAxisTitle(\n label: string | undefined,\n position: 'insideBottom' | 'insideTop' = 'insideBottom',\n offset = 0\n) {\n if (!label) return undefined;\n return { value: label, position, offset };\n}\n\n/**\n * recharts `label` for a rotated value-axis title, angled so it reads from the\n * outside in — upward on a left axis (the convention), downward on a right one,\n * where -90° would put the text's baseline against the plot. Shared by all 7\n * cartesian charts; only `ComposedChart` currently uses the right-hand side.\n */\nexport function resolveYAxisTitle(\n label: string | undefined,\n orientation: 'left' | 'right' = 'left'\n) {\n if (!label) return undefined;\n return {\n value: label,\n angle: orientation === 'left' ? -90 : 90,\n position:\n orientation === 'left' ? ('insideLeft' as const) : ('insideRight' as const),\n style: { textAnchor: 'middle' as const },\n };\n}\n\n/**\n * A category range on a cartesian chart: `from`/`to` accept either the\n * category's value (an `xKey` cell, e.g. `'Sep'`) or its 0-based row index. Both\n * ends are inclusive, and either can be omitted to run to that end of the data.\n * Shared by the charts that scope something to a slice of the categories — a\n * reference band, a per-series style override.\n */\nexport interface ChartCategoryRange {\n from?: string | number;\n to?: string | number;\n}\n\n/**\n * Resolve a category range to inclusive row indices. A bound is either the\n * category's own value (matched against the `xKey` cell) or a 0-based index;\n * an omitted bound runs to that end of the data. Returns `undefined` when the\n * data is empty or the range resolves to nothing (an unknown value, or a `to`\n * that lands before its `from`).\n *\n * Exported for unit tests; not part of the package's public API.\n */\nexport function resolveCategoryRange(\n range: ChartCategoryRange,\n data: ReadonlyArray<Record<string, unknown>>,\n xKey: string\n): [number, number] | undefined {\n if (data.length === 0) return undefined;\n\n const resolve = (bound: string | number | undefined, fallback: number) => {\n if (bound === undefined) return fallback;\n // A numeric bound is an index unless the categories are numbers themselves,\n // in which case matching a category value is the more useful reading.\n const asValue = data.findIndex((row) => row[xKey] === bound);\n if (asValue !== -1) return asValue;\n if (typeof bound === 'number' && Number.isInteger(bound)) {\n return bound >= 0 && bound < data.length ? bound : -1;\n }\n return -1;\n };\n\n const start = resolve(range.from, 0);\n const end = resolve(range.to, data.length - 1);\n if (start === -1 || end === -1 || start > end) return undefined;\n return [start, end];\n}\n\n/**\n * Which value axis a series is measured against, on a chart that can carry two.\n *\n * `secondary` is the opt-in: the second axis exists only when at least one series\n * asks for it, so a chart whose series all leave this unset keeps the single\n * shared scale — and its recharts output — exactly as before.\n */\nexport type ChartYAxisTarget = 'primary' | 'secondary';\n\n/**\n * Second value-axis props, for a chart whose series can be measured on two\n * independent scales. **Only `ComposedChart` implements these today.** It is the\n * one chart in the suite where two scales are unambiguous: its series already\n * differ in mark type, so a bar read against the left axis and a line against the\n * right can't be mistaken for two marks sharing one. On a single-mark chart (Bar,\n * Area) two scales invite comparing heights that aren't comparable, which is why\n * these props are not mixed into `CartesianChartProps`.\n *\n * The primary axis is configured through `CartesianChartProps` (`yAxisLabel`,\n * `yUnit`, `yTickFormatter`, `yAxisTickCount`, `yAxisDomain`, `showYAxis`); every\n * `secondary*` prop here is its counterpart on the second axis, so the two scales\n * format and bound themselves independently, and each is inert until a series\n * selects that axis.\n *\n * `yAxisOrientation` is the exception on both counts: it places the *primary*\n * axis, and it applies whether or not a second one exists. It lives here because\n * it is only meaningful once a chart can mirror a pair of axes — a single-axis\n * chart has no second side to give up.\n */\nexport interface SecondaryYAxisProps {\n /**\n * Which side the *primary* value axis sits on. Defaults to `left`. The secondary\n * axis always takes the opposite side. Unlike the `secondary*` props below, this\n * one applies to a single-scale chart too.\n *\n * Inert on a chart whose marks grow horizontally: the value axis is X there, so\n * the primary sits along the bottom edge and the secondary along the top, and\n * neither has a left/right side to pick.\n */\n yAxisOrientation?: 'left' | 'right';\n /**\n * Show the secondary axis's ticks + title. Defaults to `true`. Setting it false\n * keeps the second *scale* (series still measure against it) and only drops its\n * chrome — the same meaning `showYAxis` has for the primary axis.\n */\n showSecondaryYAxis?: boolean;\n /** Title rendered beside the secondary axis (rotated). */\n secondaryYAxisLabel?: string;\n /** Unit suffix appended to the secondary axis's tick values (recharts `unit`). */\n secondaryYUnit?: string;\n /** Format each secondary-axis tick value — the counterpart of `yTickFormatter`. */\n secondaryYTickFormatter?: TickFormatter;\n /** Desired number of ticks on the secondary axis (recharts `tickCount`; a hint, not exact). */\n secondaryYAxisTickCount?: number;\n /** Domain preset for the secondary axis — same presets as `yAxisDomain`. */\n secondaryYAxisDomain?: 'auto' | 'dataMin-dataMax' | 'zero';\n}\n\n/**\n * How a series interpolates between its points (recharts `type`), shared by the\n * Line and Area families so both offer the same set:\n *\n * - `linear` — straight segments between points.\n * - `monotone` — smoothed, without overshooting a point's value.\n * - `natural` — a natural cubic spline; smoother than `monotone`, but it may\n * overshoot, so read it as a trend rather than exact values.\n * - `basis` — a B-spline that is *not* required to pass through the points at\n * all; the smoothest option, and the least literal.\n * - `step` — right-angle segments, changing value at the midpoint between two\n * points; `stepBefore` changes at the leading point and `stepAfter` at the\n * trailing one.\n */\nexport type ChartCurveType =\n | 'linear'\n | 'monotone'\n | 'natural'\n | 'basis'\n | 'step'\n | 'stepBefore'\n | 'stepAfter';\n\n/** recharts animation easing curves. */\nexport type ChartAnimationEasing =\n | 'ease'\n | 'ease-in'\n | 'ease-out'\n | 'ease-in-out'\n | 'linear';\n\n/**\n * Entrance-animation props shared by *every* chart type (not just the cartesian\n * ones) — charts hardcode `isAnimationActive={false}` otherwise. All optional and\n * off by default, so an unset chart renders byte-identically to before (and its\n * VR baselines stay stable). Spread `resolveAnimation(props)` onto each series.\n */\nexport interface ChartAnimationProps {\n /** Enable entrance animation. Defaults to `false` (keeps output/baselines stable). */\n animate?: boolean;\n /** Animation duration in ms (recharts `animationDuration`). */\n animationDuration?: number;\n /** Delay before the animation starts, in ms (recharts `animationBegin`). */\n animationBegin?: number;\n /** Easing curve (recharts `animationEasing`). */\n animationEasing?: ChartAnimationEasing;\n}\n\n/** The resolved recharts animation props to spread onto a series/shape. */\nexport interface ResolvedAnimation {\n isAnimationActive: boolean | 'auto';\n animationDuration?: number;\n animationBegin?: number;\n animationEasing?: ChartAnimationEasing;\n}\n\n/**\n * Turn the shared `ChartAnimationProps` into the recharts series props. The\n * timing props only appear when given, so an unset chart spreads exactly\n * `{ isAnimationActive: false }` — the previous hardcoded value.\n *\n * `animate` maps to recharts' `'auto'`, not to a literal `true`: `'auto'` is the\n * only value that honors `prefers-reduced-motion` (and disables the animation in\n * SSR). recharts resolves it as\n * `isActive = isActiveProp === 'auto' ? !isSsr && !prefersReducedMotion : isActiveProp`,\n * so a literal `true` would force motion on users who asked for none — this\n * library has no other reduced-motion escape hatch.\n */\nexport function resolveAnimation(props: ChartAnimationProps): ResolvedAnimation {\n const { animate = false, animationDuration, animationBegin, animationEasing } =\n props;\n return {\n isAnimationActive: animate ? 'auto' : false,\n ...(animationDuration !== undefined ? { animationDuration } : {}),\n ...(animationBegin !== undefined ? { animationBegin } : {}),\n ...(animationEasing !== undefined ? { animationEasing } : {}),\n };\n}\n\n/**\n * Remove synthetic `_proj_*` series entries from a recharts payload array so\n * they don't appear in custom tooltip or legend content. Safe to call with\n * `undefined` — returns `undefined` unchanged.\n */\nexport function dropProjectionPayload<T extends { dataKey?: unknown }>(\n payload: readonly T[] | undefined\n): T[] | undefined {\n return payload?.filter(\n (item) =>\n !(typeof item.dataKey === 'string' && item.dataKey.startsWith('_proj_'))\n );\n}\n\n/** Where a data label sits on a cartesian series (recharts `LabelList` position). */\nexport type CartesianLabelPosition =\n | 'top'\n | 'bottom'\n | 'left'\n | 'right'\n | 'center'\n | 'insideTop'\n | 'insideBottom'\n | 'insideLeft'\n | 'insideRight'\n | 'insideStart'\n | 'insideEnd';\n\n/**\n * Where a data label sits on a *polar* series (Pie, RadialBar). Deliberately not\n * `CartesianLabelPosition`: recharts routes a polar label list through\n * `getAttrsOfPolarLabel` / `renderRadialLabel`, which understand only these\n * seven values — every cartesian-only position (`top`, `insideLeft`, …) silently\n * collapses to the same mid-radius placement, so offering them would advertise\n * distinctions that don't exist.\n */\nexport type PolarLabelPosition =\n | 'outside'\n | 'center'\n | 'centerTop'\n | 'centerBottom'\n | 'insideStart'\n | 'insideEnd'\n | 'end';\n\n/** Any position accepted by the suite's data labels. */\nexport type ChartLabelPosition = CartesianLabelPosition | PolarLabelPosition;\n\n/**\n * Data-label props shared by the charts that can annotate each point/segment with\n * its value. `labelPosition` stays per-chart (the valid position set differs by\n * family), but `showLabels` + `labelFormatter` are common. Label formatting reuses\n * the same `TickFormatter` type as the axes, so a label and its axis read the same.\n */\nexport interface ChartDataLabelProps {\n /** Render a value label on each data point/segment. Defaults to `false`. */\n showLabels?: boolean;\n /** Format each label value — pass the same formatter used on the value axis. */\n labelFormatter?: TickFormatter;\n}\n\n/**\n * Fill for a label that sits on the chart *surface* — i.e. an outside position\n * (`top`, `right`, polar `outside`). Inverts with the theme, so it only works\n * against the surface background.\n */\nexport const CHART_LABEL_FILL_CLASS = 'fill-[var(--ui-text-on-surface-primary)]!';\n\n/**\n * Fill for a label that sits on an *opaque series fill* — any `inside*`\n * position, a polar mid-radius/centroid placement, or a stacked bar/arc segment\n * (an area's fill is translucent, so it uses the on-surface token). The on-surface\n * token must not be used there: it resolves near-white in dark mode and drops to\n * ~1.6:1 against the saturated status/brand fills the charts colour series with,\n * failing the `accessibility/contrast` grammar rule (`must`, WCAG 1.4.3). This is\n * the same \"text on a strong colored surface\" token `Treemap` already uses; it is\n * white in both themes, so it holds up over every series colour.\n */\nexport const CHART_LABEL_FILL_ON_SERIES_CLASS =\n 'fill-[var(--ui-text-on-status-strong-neutral)]!';\n\nexport const CHART_LABEL_FONT_SIZE = 12;\n\n/**\n * Plot-area inset to apply when a Line/Area series carries outside data labels.\n * recharts hands those label lists `parentViewBox: undefined` (its own source\n * calls this out as a bug in `cartesian/Line.js`), so `getCartesianPosition`'s\n * `clamp` has nothing to clamp against and the first/last point's value is cut\n * off at the SVG edge. Widening the margin is the only lever a composition over\n * recharts has. `Bar` does pass a `parentViewBox`, so bar series don't need it.\n */\nexport const CHART_LABEL_MARGIN = {\n top: 16,\n right: 24,\n bottom: 5,\n left: 12,\n} as const;\n\n/** Positions that draw the label on top of the series fill rather than the surface. */\nconst ON_SERIES_LABEL_POSITIONS = new Set<ChartLabelPosition>([\n 'center',\n 'centerTop',\n 'centerBottom',\n 'insideTop',\n 'insideBottom',\n 'insideLeft',\n 'insideRight',\n 'insideStart',\n 'insideEnd',\n 'end',\n]);\n\n/**\n * Resolve where a cartesian value label sits, given the caller's override, the\n * layout, and the position of the series' growing end (`top` for a vertical bar\n * or a line/area point, `right` for a horizontal bar).\n *\n * The stacked branch is the reason this isn't inlined: a stacked segment has no\n * free space at its growing end — the next segment is drawn there — so a `top`\n * label lands *inside* its neighbour rather than over its own segment. Centring\n * it in its own segment is the readable placement; `resolveLabelFillClass` then\n * pairs it with the fill that has contrast over that family's series colour.\n */\nexport function resolveCartesianLabelPosition(options: {\n labelPosition?: CartesianLabelPosition;\n isStacked?: boolean;\n growingEnd?: CartesianLabelPosition;\n}): CartesianLabelPosition {\n const { labelPosition, isStacked = false, growingEnd = 'top' } = options;\n if (labelPosition !== undefined) return labelPosition;\n return isStacked ? 'center' : growingEnd;\n}\n\n/**\n * Pick the label fill that actually has contrast at `position`. Callers must pass\n * the *resolved* position (after their own default), never `undefined` for a\n * polar chart — recharts' polar fallback is a mid-radius placement, which is on\n * the fill even though no `inside*` value was given.\n *\n * Returns a `className`, not a `fill` attribute, and the utility is `!`-flagged:\n * the cartesian charts scope `[&_.recharts-label]:fill-foreground` on their\n * container to theme axis titles, and a `LabelList`'s text carries\n * `.recharts-label` too — so a CSS rule would quietly beat an SVG presentation\n * attribute and undo the contrast fix.\n *\n * `translucentSeries` opts a family out of the on-fill token: an area's fill is\n * a gradient (0.8 → 0.1 alpha) or a flat `fillOpacity`, so what sits behind the\n * label is the surface tinted by the series colour, not the series colour. The\n * white on-fill token disappears into it in light mode — the theme-inverting\n * on-surface token is the readable one there, and stays white in dark mode.\n */\nexport function resolveLabelFillClass(\n position: ChartLabelPosition,\n options: { translucentSeries?: boolean } = {}\n): string {\n if (options.translucentSeries) return CHART_LABEL_FILL_CLASS;\n return ON_SERIES_LABEL_POSITIONS.has(position)\n ? CHART_LABEL_FILL_ON_SERIES_CLASS\n : CHART_LABEL_FILL_CLASS;\n}\n\n/**\n * Adapt a `TickFormatter` to recharts' `LabelList` `formatter` prop, whose value\n * type is wider. Returns `undefined` when no formatter is given, so a label\n * renders its raw value. Lets labels reuse the same formatters as the value axis.\n *\n * Null/undefined is filtered out rather than forwarded: recharts builds a label\n * entry for *every* point including the null ones that `connectNulls` is meant to\n * bridge, and the tick formatters coerce (`formatCompactNumber(null)` is `\"0\"`,\n * `formatPercent(undefined)` is `\"undefined\"`) — which would paint a phantom\n * value over an intentional gap.\n */\nexport function toLabelFormatter(\n formatter: TickFormatter | undefined\n): ((value: unknown) => string) | undefined {\n if (!formatter) return undefined;\n return (value: unknown) =>\n value == null ? '' : formatter(value as number | string);\n}\n\n/** Where a reference line's caption sits relative to the rule. */\nexport type ChartReferenceLabelPosition =\n | 'top'\n | 'insideTopLeft'\n | 'insideTopRight'\n | 'insideBottomLeft'\n | 'insideBottomRight';\n\n/**\n * A dashed rule across the value axis — a target, a threshold, or a series\n * average. Shared by the cartesian charts that draw one (`BarChart`,\n * `LineChart`, `AreaChart`) so the config reads the same on all three.\n */\nexport interface ChartReferenceLine {\n /** Fixed position on the value axis. Takes precedence over `average`. */\n value?: number;\n /**\n * Draw the line at the mean of one series (a `dataKeys` entry) or, when\n * `true`, of every plotted series' values.\n */\n average?: boolean | string;\n /** Optional caption rendered alongside the line. */\n label?: string;\n /**\n * Where the caption sits. Defaults to the chart's own placement — move it\n * when the rule lands where the series already is and the two collide.\n */\n labelPosition?: ChartReferenceLabelPosition;\n}\n\n/**\n * Normalize the `referenceLine` prop — a single config or an array — to a list.\n * Every chart accepts both forms, so this keeps the render path uniform.\n */\nexport function toReferenceLineList(\n referenceLine: ChartReferenceLine | ChartReferenceLine[] | undefined\n): ChartReferenceLine[] {\n if (!referenceLine) return [];\n return Array.isArray(referenceLine) ? referenceLine : [referenceLine];\n}\n\n/**\n * Resolve a `referenceLine` config to a position on the value axis: a fixed\n * `value` wins; otherwise the mean of the requested series (a single `dataKeys`\n * entry, or all of them when `average` is `true`). Returns `undefined` when\n * there is nothing to draw (no config, or no numeric values to average) — the\n * caller skips the line rather than drawing it at 0.\n *\n * Rows are `unknown`-valued because `ComposedChart` types its data that way; the\n * body only ever reads cells that are numbers, so a wider row type costs nothing\n * and saves every caller a cast.\n */\nexport function resolveChartReferenceValue(\n referenceLine: ChartReferenceLine | undefined,\n data: ReadonlyArray<Record<string, unknown>>,\n dataKeys: string[]\n): number | undefined {\n if (!referenceLine) return undefined;\n if (typeof referenceLine.value === 'number') return referenceLine.value;\n if (!referenceLine.average) return undefined;\n\n const keys =\n typeof referenceLine.average === 'string'\n ? [referenceLine.average]\n : dataKeys;\n const nums = data.flatMap((row) =>\n keys\n .map((key) => row[key])\n .filter((value): value is number => typeof value === 'number')\n );\n if (nums.length === 0) return undefined;\n return nums.reduce((sum, n) => sum + n, 0) / nums.length;\n}\n\n/**\n * Stroke (and caption fill) of a reference rule. The muted text token, so the\n * rule reads as annotation rather than as another series — and stays legible in\n * both themes without competing with the series colors.\n */\nexport const CHART_REFERENCE_LINE_STROKE =\n 'var(--ui-text-on-surface-secondary)';\n\n/**\n * The recharts props that paint a reference rule: a dashed line in the muted\n * text token with an optional caption. Shared so the three charts that draw one\n * can't drift on the stroke, dash pattern, or caption styling.\n *\n * `labelPosition` is the chart's default placement; a config's own\n * `labelPosition` overrides it at the call site.\n *\n * `ifOverflow: 'extendDomain'` is part of the contract, not a detail: a target\n * above the data maximum is exactly the case a reference line is for, and\n * recharts' default (`discard`) would silently drop it.\n */\nexport function resolveReferenceLineProps(\n label: string | undefined,\n labelPosition: ChartReferenceLabelPosition = 'insideTopRight'\n) {\n return {\n stroke: CHART_REFERENCE_LINE_STROKE,\n strokeDasharray: '4 4',\n ifOverflow: 'extendDomain' as const,\n label: label\n ? {\n value: label,\n position: labelPosition,\n fill: CHART_REFERENCE_LINE_STROKE,\n fontSize: CHART_LABEL_FONT_SIZE,\n }\n : undefined,\n };\n}\n\n/**\n * Range-brush props for the cartesian charts that support one — `BarChart`,\n * `LineChart`, `AreaChart`, `ComposedChart`. Deliberately not folded into\n * `CartesianChartProps`: `ScatterChart` plots a continuous X (the brush indexes\n * rows, not values) and `Histogram` / `ConfidenceCone` render a derived series,\n * so a brush over their row order would slice the wrong thing.\n */\nexport interface ChartBrushProps {\n /**\n * Render a range brush beneath the chart — drag its handles (or the selected\n * window) to zoom the series to a slice of the data. Defaults to `false`.\n */\n showBrush?: boolean;\n /** Height of the brush strip in px. Defaults to 28. */\n brushHeight?: number;\n /**\n * Accessible name for the brush's two range handles. Both are focusable\n * `role=\"slider\"` elements, so they need one. Defaults to\n * `'Chart range selector'`.\n */\n brushAriaLabel?: string;\n}\n\n/**\n * Height of the brush strip. recharts' own default is 40, which eats an eighth\n * of a 320px-tall dashboard widget; 28 still fits the travellers and the\n * range captions.\n */\nexport const CHART_BRUSH_HEIGHT = 28;\n\n/**\n * Accessible name for the brush handles. recharts' own fallback is\n * `\"Min value: \".concat(start, \", Max value: \").concat(end)`, where both halves\n * come from a `name` property on the data row — a field none of our charts\n * require, so it announces \"Min value: undefined, Max value: undefined\". Always\n * pass `ariaLabel` to suppress it.\n */\nexport const CHART_BRUSH_ARIA_LABEL = 'Chart range selector';\n\n/** The resolved recharts brush props to spread onto a `<Brush>`. */\nexport interface ResolvedBrush {\n height: number;\n fill: string;\n stroke: string;\n travellerWidth: number;\n ariaLabel: string;\n}\n\n/**\n * Theme + size a recharts `<Brush>` from the shared `ChartBrushProps`.\n *\n * recharts derives the *whole* brush from two color props, so both have to be\n * chosen for every element they reach (`cartesian/Brush.js`):\n * - `fill` paints only the strip's background rect.\n * - `stroke` paints its border, the traveller handles' **fill**, the selected\n * window at 20% opacity, and the range caption text.\n *\n * Hence the mid-grey text token rather than the border one: the travellers are\n * solid `stroke`-colored rects with two hardcoded `#fff` grip lines drawn on\n * top, so a pale stroke would render the grips invisible in light mode. That\n * token is theme-stable (same grey in light and dark), and white grips read\n * against it either way.\n */\nexport function resolveBrushProps({\n brushHeight,\n brushAriaLabel = CHART_BRUSH_ARIA_LABEL,\n}: Omit<ChartBrushProps, 'showBrush'>): ResolvedBrush {\n return {\n // recharts drops the brush entirely when height <= 0, which would turn\n // `showBrush` into a silent no-op — treat a non-positive height as unset.\n height:\n brushHeight != null && brushHeight > 0 ? brushHeight : CHART_BRUSH_HEIGHT,\n fill: 'var(--ui-background-surface-secondary)',\n stroke: 'var(--ui-text-on-surface-secondary)',\n travellerWidth: 8,\n ariaLabel: brushAriaLabel,\n };\n}\n\nconst toNumber = (value: number | string): number | null => {\n // `Number('')` and `Number(' ')` are 0, not NaN — so blank strings have to be\n // rejected before the finite check, or an empty tick label would render \"0\".\n if (typeof value === 'string' && value.trim() === '') return null;\n const n = typeof value === 'number' ? value : Number(value);\n return Number.isFinite(n) ? n : null;\n};\n\n/**\n * Compact thousands/millions: `1234 → \"1.2K\"`, `1_500_000 → \"1.5M\"`. Non-numeric\n * values (including blank strings) pass through unchanged. Use for large-count\n * axes (revenue, users, …).\n *\n * Formats in `en`. For another locale use\n * `createTickFormatter({ notation: 'compact', maximumFractionDigits: 1 }, locale)`.\n */\nexport const formatCompactNumber: TickFormatter = (value) => {\n const n = toNumber(value);\n if (n === null) return String(value);\n return new Intl.NumberFormat('en', {\n notation: 'compact',\n maximumFractionDigits: 1,\n }).format(n);\n};\n\n/**\n * Append a percent sign to an already-scaled value: `41.8 → \"41.8%\"`. (The value\n * is treated as a percentage, not a 0–1 fraction.) Non-numeric values (including\n * blank strings) pass through.\n *\n * Appends a bare `%`, which is not how every locale writes it. For locale-correct\n * output on values that really are fractions, use\n * `createTickFormatter({ style: 'percent' }, locale)`.\n */\nexport const formatPercent: TickFormatter = (value) => {\n const n = toNumber(value);\n if (n === null) return String(value);\n return `${n}%`;\n};\n\n/**\n * Build a tick formatter from `Intl.NumberFormat` options — the escape hatch for\n * currency, fixed decimals, or a specific locale. E.g.\n * `createTickFormatter({ style: 'currency', currency: 'USD', notation: 'compact' })`\n * → `146500 → \"$147K\"`. Non-numeric values pass through unchanged.\n */\nexport function createTickFormatter(\n options: Intl.NumberFormatOptions,\n locale = 'en'\n): TickFormatter {\n const nf = new Intl.NumberFormat(locale, options);\n return (value) => {\n const n = toNumber(value);\n return n === null ? String(value) : nf.format(n);\n };\n}\n"],"mappings":"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"}
@@ -2,11 +2,11 @@
2
2
  import { cn as e } from "../../../lib/utils.js";
3
3
  import { cva as t } from "../../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js";
4
4
  import { ChartContainer as n, ChartLegend as r, ChartLegendContent as i, ChartTooltip as a, ChartTooltipContent as o, toCssKey as s } from "../chart/chart.js";
5
- import { CHART_LABEL_MARGIN as c, resolveAnimation as l, resolveAxisDomain as u, resolveBrushProps as d, resolveCartesianLabelPosition as ee, resolveCategoryRange as f, resolveChartReferenceValue as p, resolveLabelFillClass as te, resolveReferenceLineProps as ne, resolveRotatedTickAnchor as re, resolveXAxisTickLabels as ie, resolveXAxisTitle as m, resolveYAxisTitle as h, toLabelFormatter as ae } from "../chart/chart-format.js";
5
+ import { CHART_LABEL_MARGIN as c, resolveAnimation as l, resolveAxisDomain as u, resolveBrushProps as d, resolveCartesianLabelPosition as ee, resolveCategoryRange as f, resolveChartReferenceValue as p, resolveLabelFillClass as te, resolveReferenceLineProps as ne, resolveRotatedTickAnchor as re, resolveXAxisTickLabels as ie, resolveXAxisTitle as m, resolveYAxisTitle as h, resolveYAxisWidth as g, toLabelFormatter as ae } from "../chart/chart-format.js";
6
6
  import { mergeXAxisLayoutMargin as oe, useXAxisLayout as se } from "../chart/use-x-axis-layout.js";
7
- import * as g from "react";
8
- import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
9
- import { Area as ce, Bar as le, Brush as ue, CartesianGrid as de, ComposedChart as fe, LabelList as pe, Line as me, ReferenceArea as he, ReferenceLine as ge, XAxis as b, YAxis as x } from "recharts";
7
+ import * as _ from "react";
8
+ import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
9
+ import { Area as ce, Bar as le, Brush as ue, CartesianGrid as de, ComposedChart as fe, LabelList as pe, Line as me, ReferenceArea as he, ReferenceLine as ge, XAxis as x, YAxis as S } from "recharts";
10
10
  //#region src/components/ui/composed-chart/composed-chart.tsx
11
11
  var _e = t("", {
12
12
  variants: { orientation: {
@@ -14,148 +14,148 @@ var _e = t("", {
14
14
  horizontal: ""
15
15
  } },
16
16
  defaultVariants: { orientation: "vertical" }
17
- }), ve = 100, ye = 50, S = "secondary", be = {
17
+ }), ve = 100, ye = 50, C = "secondary", be = {
18
18
  top: 5,
19
19
  right: 5,
20
20
  bottom: 5,
21
21
  left: 5
22
- }, xe = .85, Se = { top: 16 }, C = g.forwardRef(({ className: t, config: C, palette: Ce, data: w, series: T, xKey: E, referenceLine: D, referenceArea: O, orientation: k = "vertical", xAxisLabel: A, yAxisLabel: j, xUnit: we, yUnit: Te, curve: M = "monotone", barRadius: Ee = 4, barSize: De, barGap: Oe, barCategoryGap: ke, showBackground: Ae = !1, backgroundFill: je = "var(--ui-background-surface-secondary)", showActiveBar: Me = !1, fillOpacity: Ne = .3, strokeWidth: N, showDots: Pe = !1, showActiveDots: Fe, connectNulls: Ie = !1, margin: P, showGrid: Le = !0, showTooltip: Re = !0, tooltipCursor: ze = !0, showLegend: Be = !0, legendPosition: F = "bottom", legendFontSize: I, legendAriaLabel: L, showXAxis: R = !0, showYAxis: z = !0, xTickFormatter: B, yTickFormatter: V, xAxisAngle: H, xAxisInterval: U, yAxisTickCount: Ve, yAxisDomain: He, yAxisOrientation: W, showSecondaryYAxis: Ue = !0, secondaryYAxisLabel: G, secondaryYUnit: We, secondaryYTickFormatter: Ge, secondaryYAxisTickCount: Ke, secondaryYAxisDomain: qe, gridDashed: Je, gridHorizontal: Ye, gridVertical: Xe, tooltipContent: Ze, animate: Qe, animationDuration: $e, animationBegin: et, animationEasing: tt, showLabels: nt = !1, labelPosition: rt, labelFormatter: it, showBrush: at = !1, brushHeight: ot, brushAriaLabel: st, ...ct }, lt) => {
22
+ }, xe = .85, Se = { top: 16 }, w = _.forwardRef(({ className: t, config: w, palette: Ce, data: T, series: E, xKey: D, referenceLine: O, referenceArea: k, orientation: A = "vertical", xAxisLabel: j, yAxisLabel: M, xUnit: we, yUnit: Te, curve: N = "monotone", barRadius: Ee = 4, barSize: De, barGap: Oe, barCategoryGap: ke, showBackground: Ae = !1, backgroundFill: je = "var(--ui-background-surface-secondary)", showActiveBar: Me = !1, fillOpacity: Ne = .3, strokeWidth: P, showDots: Pe = !1, showActiveDots: Fe, connectNulls: Ie = !1, margin: F, showGrid: Le = !0, showTooltip: Re = !0, tooltipCursor: ze = !0, showLegend: Be = !0, legendPosition: I = "bottom", legendFontSize: L, legendAriaLabel: R, showXAxis: z = !0, showYAxis: B = !0, xTickFormatter: V, yTickFormatter: H, xAxisAngle: U, xAxisInterval: Ve, yAxisTickCount: He, yAxisDomain: Ue, yAxisOrientation: W, showSecondaryYAxis: We = !0, secondaryYAxisLabel: G, secondaryYUnit: Ge, secondaryYTickFormatter: Ke, secondaryYAxisTickCount: qe, secondaryYAxisDomain: Je, gridDashed: Ye, gridHorizontal: Xe, gridVertical: Ze, tooltipContent: Qe, animate: $e, animationDuration: et, animationBegin: tt, animationEasing: nt, showLabels: rt = !1, labelPosition: it, labelFormatter: at, showBrush: ot = !1, brushHeight: st, brushAriaLabel: ct, ...lt }, ut) => {
23
23
  let K = l({
24
- animate: Qe,
25
- animationDuration: $e,
26
- animationBegin: et,
27
- animationEasing: tt
28
- }), q = k === "horizontal", ut = m(A), J = T.some((e) => e.yAxis === "secondary"), dt = T.some((e) => e.yAxis !== "secondary"), Y = J && !dt, ft = W ?? "left", pt = ft === "left" ? "right" : "left", mt = h(j, q ? "left" : ft), ht = h(G, pt), gt = m(G, "insideTop"), _t = u(He), vt = u(qe), X = (e) => {
29
- let t = e === "secondary" ? S : void 0;
24
+ animate: $e,
25
+ animationDuration: et,
26
+ animationBegin: tt,
27
+ animationEasing: nt
28
+ }), q = A === "horizontal", dt = m(j), J = E.some((e) => e.yAxis === "secondary"), ft = E.some((e) => e.yAxis !== "secondary"), Y = J && !ft, pt = W ?? "left", mt = pt === "left" ? "right" : "left", ht = h(M, q ? "left" : pt), gt = h(G, mt), _t = m(G, "insideTop"), vt = u(Ue), yt = u(Je), bt = g(T.length > 0, !!M), xt = g(T.length > 0, !!G), X = (e) => {
29
+ let t = e === "secondary" ? C : void 0;
30
30
  return q ? { xAxisId: t } : { yAxisId: t };
31
- }, yt = Y ? X("secondary") : {}, bt = ie(q ? [] : w.map((e) => e[E]), B), Z = g.useRef(null), Q = se(Z, H, A, bt.join("\0")), xt = D ? Array.isArray(D) ? D : [D] : [], St = (O ? Array.isArray(O) ? O : [O] : []).map((e) => ({
31
+ }, St = Y ? X("secondary") : {}, Ct = ie(q ? [] : T.map((e) => e[D]), V), wt = _.useRef(null), Z = se(wt, U, j, Ct.join("\0")), Tt = O ? Array.isArray(O) ? O : [O] : [], Et = (k ? Array.isArray(k) ? k : [k] : []).map((e) => ({
32
32
  area: e,
33
- range: f(e, w, E)
34
- })).filter((e) => e.range !== void 0), Ct = Y ? "secondary" : "primary", wt = (e) => e.yAxis ?? "primary", Tt = new Map(T.map((e) => [e.key, wt(e)])), Et = (e) => T.filter((t) => wt(t) === e).map((e) => e.key), Dt = new Set(T.filter((e) => e.legendType === "none").map((e) => e.key)), $ = (e) => w[e]?.[E] ?? void 0, Ot = xt.map((e) => {
33
+ range: f(e, T, D)
34
+ })).filter((e) => e.range !== void 0), Dt = Y ? "secondary" : "primary", Ot = (e) => e.yAxis ?? "primary", kt = new Map(E.map((e) => [e.key, Ot(e)])), At = (e) => E.filter((t) => Ot(t) === e).map((e) => e.key), jt = new Set(E.filter((e) => e.legendType === "none").map((e) => e.key)), Q = (e) => T[e]?.[D] ?? void 0, Mt = Tt.map((e) => {
35
35
  let t = e.category === void 0 ? void 0 : f({
36
36
  from: e.category,
37
37
  to: e.category
38
- }, w, E), n = e.yAxis ?? (typeof e.average == "string" ? Tt.get(e.average) ?? Ct : Ct), r = p(e, w, Et(n)), i = t ? $(t[0]) : void 0;
38
+ }, T, D), n = e.yAxis ?? (typeof e.average == "string" ? kt.get(e.average) ?? Dt : Dt), r = p(e, T, At(n)), i = t ? Q(t[0]) : void 0;
39
39
  return {
40
40
  line: e,
41
41
  lineAxis: n,
42
42
  position: r === void 0 ? i === void 0 ? void 0 : q ? { y: i } : { x: i } : q ? { x: r } : { y: r },
43
43
  isVerticalRule: r !== void 0 === q
44
44
  };
45
- }).filter((e) => e.position !== void 0), kt = nt ? c : void 0, At = Ot.some((e) => e.line.label && e.isVerticalRule) ? Se : void 0, jt = P || kt || At ? {
46
- ...P ? be : {},
47
- ...At,
48
- ...kt,
49
- ...P
50
- } : void 0, Mt = oe(jt, Q.margin), Nt = /* @__PURE__ */ new Map();
51
- T.forEach((e, t) => {
52
- e.stackId && e.type !== "line" && Nt.set(`${e.type}-${e.stackId}`, t);
45
+ }).filter((e) => e.position !== void 0), $ = rt ? c : void 0, Nt = Mt.some((e) => e.line.label && e.isVerticalRule) ? Se : void 0, Pt = F || $ || Nt ? {
46
+ ...F ? be : {},
47
+ ...Nt,
48
+ ...$,
49
+ ...F
50
+ } : void 0, Ft = oe(Pt, Z.margin), It = /* @__PURE__ */ new Map();
51
+ E.forEach((e, t) => {
52
+ e.stackId && e.type !== "line" && It.set(`${e.type}-${e.stackId}`, t);
53
53
  });
54
- let Pt = () => /* @__PURE__ */ y(_, { children: [
55
- /* @__PURE__ */ v(b, {
54
+ let Lt = () => /* @__PURE__ */ b(v, { children: [
55
+ /* @__PURE__ */ y(x, {
56
56
  type: "number",
57
- hide: !R || Y,
57
+ hide: !z || Y,
58
58
  tickLine: !1,
59
59
  axisLine: !1,
60
60
  unit: we,
61
- tickFormatter: B,
62
- angle: H,
63
- interval: U,
64
- textAnchor: re(H),
65
- tickCount: Ve,
66
- domain: _t,
67
- height: Q.height,
68
- label: ut
61
+ tickFormatter: V,
62
+ angle: U,
63
+ interval: Ve,
64
+ textAnchor: re(U),
65
+ tickCount: He,
66
+ domain: vt,
67
+ height: Z.height,
68
+ label: dt
69
69
  }),
70
- /* @__PURE__ */ v(x, {
71
- dataKey: E,
70
+ /* @__PURE__ */ y(S, {
71
+ dataKey: D,
72
72
  type: "category",
73
- hide: !z,
73
+ hide: !B,
74
74
  tickLine: !1,
75
75
  axisLine: !1,
76
- tickFormatter: V,
77
- width: j ? 96 : 80,
78
- label: mt
76
+ tickFormatter: H,
77
+ width: M ? 96 : 80,
78
+ label: ht
79
79
  }),
80
- J && /* @__PURE__ */ v(b, {
81
- xAxisId: S,
80
+ J && /* @__PURE__ */ y(x, {
81
+ xAxisId: C,
82
82
  type: "number",
83
- hide: !Ue,
83
+ hide: !We,
84
84
  orientation: "top",
85
85
  tickLine: !1,
86
86
  axisLine: !1,
87
- unit: We,
88
- tickFormatter: Ge,
89
- tickCount: Ke,
90
- domain: vt,
91
- label: gt
87
+ unit: Ge,
88
+ tickFormatter: Ke,
89
+ tickCount: qe,
90
+ domain: yt,
91
+ label: _t
92
92
  })
93
- ] }), Ft = () => /* @__PURE__ */ y(_, { children: [
94
- /* @__PURE__ */ v(b, {
95
- dataKey: E,
93
+ ] }), Rt = () => /* @__PURE__ */ b(v, { children: [
94
+ /* @__PURE__ */ y(x, {
95
+ dataKey: D,
96
96
  type: "category",
97
- hide: !R,
97
+ hide: !z,
98
98
  tickLine: !1,
99
99
  axisLine: !1,
100
100
  tickMargin: 8,
101
- tickFormatter: B,
102
- angle: H,
103
- interval: U,
104
- textAnchor: re(H),
105
- height: Q.height,
106
- label: ut
101
+ tickFormatter: V,
102
+ angle: U,
103
+ interval: Ve,
104
+ textAnchor: re(U),
105
+ height: Z.height,
106
+ label: dt
107
107
  }),
108
- /* @__PURE__ */ v(x, {
108
+ /* @__PURE__ */ y(S, {
109
109
  type: "number",
110
- hide: !z || Y,
110
+ hide: !B || Y,
111
111
  ...W ? { orientation: W } : {},
112
112
  tickLine: !1,
113
113
  axisLine: !1,
114
114
  unit: Te,
115
- tickFormatter: V,
116
- tickCount: Ve,
117
- domain: _t,
118
- width: j ? 72 : void 0,
119
- label: mt
115
+ tickFormatter: H,
116
+ tickCount: He,
117
+ domain: vt,
118
+ width: bt,
119
+ label: ht
120
120
  }),
121
- J && /* @__PURE__ */ v(x, {
122
- yAxisId: S,
121
+ J && /* @__PURE__ */ y(S, {
122
+ yAxisId: C,
123
123
  type: "number",
124
- hide: !Ue,
125
- orientation: pt,
124
+ hide: !We,
125
+ orientation: mt,
126
126
  tickLine: !1,
127
127
  axisLine: !1,
128
- unit: We,
129
- tickFormatter: Ge,
130
- tickCount: Ke,
131
- domain: vt,
132
- width: G ? 72 : void 0,
133
- label: ht
128
+ unit: Ge,
129
+ tickFormatter: Ke,
130
+ tickCount: qe,
131
+ domain: yt,
132
+ width: xt,
133
+ label: gt
134
134
  })
135
- ] }), It = Dt.size > 0 ? (e) => /* @__PURE__ */ v(i, {
136
- verticalAlign: F,
137
- fontSize: I,
138
- ariaLabel: L,
139
- payload: e.payload?.filter((e) => !Dt.has(String(e.dataKey)))
140
- }) : /* @__PURE__ */ v(i, {
141
- verticalAlign: F,
142
- fontSize: I,
143
- ariaLabel: L
144
- }), Lt = (e, t) => {
135
+ ] }), zt = jt.size > 0 ? (e) => /* @__PURE__ */ y(i, {
136
+ verticalAlign: I,
137
+ fontSize: L,
138
+ ariaLabel: R,
139
+ payload: e.payload?.filter((e) => !jt.has(String(e.dataKey)))
140
+ }) : /* @__PURE__ */ y(i, {
141
+ verticalAlign: I,
142
+ fontSize: L,
143
+ ariaLabel: R
144
+ }), Bt = (e, t) => {
145
145
  let n = e.color ?? `var(--color-${s(e.key)})`, r = ve + t, i = X(e.yAxis), a = e.stackId && e.type !== "line" ? `${e.type}-${e.stackId}` : void 0, o = e.fillOpacity ?? Ne, c = e.connectNulls ?? Ie, l = e.showDots ?? Pe, u = e.showActiveDots ?? Fe, d = e.legendType ? { legendType: e.legendType } : {}, f = ee({
146
- labelPosition: rt,
146
+ labelPosition: it,
147
147
  isStacked: a !== void 0,
148
148
  growingEnd: q ? "right" : "top"
149
- }), p = nt ? /* @__PURE__ */ v(pe, {
149
+ }), p = rt ? /* @__PURE__ */ y(pe, {
150
150
  dataKey: e.key,
151
151
  position: f,
152
- formatter: ae(it),
152
+ formatter: ae(at),
153
153
  className: te(f, { translucentSeries: e.type === "area" }),
154
154
  fontSize: 12
155
155
  }) : null;
156
156
  if (e.type === "bar") {
157
- let o = e.barRadius ?? Ee, s = a === void 0 || Nt.get(a) === t, c = e.showBackground ?? Ae, l = e.showActiveBar ?? Me;
158
- return /* @__PURE__ */ v(le, {
157
+ let o = e.barRadius ?? Ee, s = a === void 0 || It.get(a) === t, c = e.showBackground ?? Ae, l = e.showActiveBar ?? Me;
158
+ return /* @__PURE__ */ y(le, {
159
159
  dataKey: e.key,
160
160
  ...i,
161
161
  fill: n,
@@ -187,9 +187,9 @@ var _e = t("", {
187
187
  }, e.key);
188
188
  }
189
189
  if (e.type === "area") {
190
- let t = e.strokeWidth ?? N, s = t === void 0 ? {} : { strokeWidth: t };
191
- return /* @__PURE__ */ v(ce, {
192
- type: e.curve ?? M,
190
+ let t = e.strokeWidth ?? P, s = t === void 0 ? {} : { strokeWidth: t };
191
+ return /* @__PURE__ */ y(ce, {
192
+ type: e.curve ?? N,
193
193
  dataKey: e.key,
194
194
  ...i,
195
195
  stroke: n,
@@ -207,12 +207,12 @@ var _e = t("", {
207
207
  children: p
208
208
  }, e.key);
209
209
  }
210
- return /* @__PURE__ */ v(me, {
211
- type: e.curve ?? M,
210
+ return /* @__PURE__ */ y(me, {
211
+ type: e.curve ?? N,
212
212
  dataKey: e.key,
213
213
  ...i,
214
214
  stroke: n,
215
- strokeWidth: e.strokeWidth ?? N ?? 2,
215
+ strokeWidth: e.strokeWidth ?? P ?? 2,
216
216
  dot: l ? { r: 3 } : !1,
217
217
  zIndex: r,
218
218
  ...e.strokeDasharray === void 0 ? {} : { strokeDasharray: e.strokeDasharray },
@@ -222,16 +222,16 @@ var _e = t("", {
222
222
  ...K,
223
223
  children: p
224
224
  }, e.key);
225
- }, Rt = ({ area: e, range: t }, n) => {
225
+ }, Vt = ({ area: e, range: t }, n) => {
226
226
  let [r, i] = t;
227
- return /* @__PURE__ */ v(he, {
228
- ...yt,
227
+ return /* @__PURE__ */ y(he, {
228
+ ...St,
229
229
  ...q ? {
230
- y1: $(r),
231
- y2: $(i)
230
+ y1: Q(r),
231
+ y2: Q(i)
232
232
  } : {
233
- x1: $(r),
234
- x2: $(i)
233
+ x1: Q(r),
234
+ x2: Q(i)
235
235
  },
236
236
  fill: "var(--ui-background-surface-secondary)",
237
237
  fillOpacity: .6,
@@ -244,53 +244,53 @@ var _e = t("", {
244
244
  fontSize: 12
245
245
  } : void 0
246
246
  }, `${e.label ?? "area"}-${n}`);
247
- }, zt = ({ line: e, lineAxis: t, position: n, isVerticalRule: r }, i) => /* @__PURE__ */ v(ge, {
247
+ }, Ht = ({ line: e, lineAxis: t, position: n, isVerticalRule: r }, i) => /* @__PURE__ */ y(ge, {
248
248
  ...t === "secondary" && J ? X("secondary") : {},
249
249
  ...n,
250
250
  ...ne(e.label, e.labelPosition ?? (r ? "top" : "insideTopRight"))
251
251
  }, `${e.label ?? "ref"}-${i}`);
252
- return /* @__PURE__ */ v("div", {
253
- ref: lt,
254
- "data-orientation": k,
255
- className: e(_e({ orientation: k }), t),
256
- ...ct,
257
- children: /* @__PURE__ */ v(n, {
258
- ref: Z,
259
- config: C,
252
+ return /* @__PURE__ */ y("div", {
253
+ ref: ut,
254
+ "data-orientation": A,
255
+ className: e(_e({ orientation: A }), t),
256
+ ...lt,
257
+ children: /* @__PURE__ */ y(n, {
258
+ ref: wt,
259
+ config: w,
260
260
  palette: Ce,
261
261
  className: "size-full [&_.recharts-label]:fill-foreground",
262
- children: /* @__PURE__ */ y(fe, {
263
- data: w,
262
+ children: /* @__PURE__ */ b(fe, {
263
+ data: T,
264
264
  layout: q ? "vertical" : "horizontal",
265
265
  barSize: De,
266
266
  barGap: Oe,
267
267
  barCategoryGap: ke,
268
- margin: Mt,
268
+ margin: Ft,
269
269
  children: [
270
- Le && /* @__PURE__ */ v(de, {
271
- ...yt,
272
- horizontal: Ye ?? !q,
273
- vertical: Xe ?? q,
274
- strokeDasharray: Je ? "3 3" : void 0
270
+ Le && /* @__PURE__ */ y(de, {
271
+ ...St,
272
+ horizontal: Xe ?? !q,
273
+ vertical: Ze ?? q,
274
+ strokeDasharray: Ye ? "3 3" : void 0
275
275
  }),
276
- q ? Pt() : Ft(),
277
- Re && /* @__PURE__ */ v(a, {
276
+ q ? Lt() : Rt(),
277
+ Re && /* @__PURE__ */ y(a, {
278
278
  ...ze ? {} : { cursor: !1 },
279
- content: Ze ?? /* @__PURE__ */ v(o, {})
279
+ content: Qe ?? /* @__PURE__ */ y(o, {})
280
280
  }),
281
- Be && /* @__PURE__ */ v(r, {
282
- verticalAlign: F,
283
- content: It
281
+ Be && /* @__PURE__ */ y(r, {
282
+ verticalAlign: I,
283
+ content: zt
284
284
  }),
285
- T.map(Lt),
286
- St.map(Rt),
287
- Ot.map(zt),
288
- at && /* @__PURE__ */ v(ue, {
289
- dataKey: E,
290
- tickFormatter: q ? V : B,
285
+ E.map(Bt),
286
+ Et.map(Vt),
287
+ Mt.map(Ht),
288
+ ot && /* @__PURE__ */ y(ue, {
289
+ dataKey: D,
290
+ tickFormatter: q ? H : V,
291
291
  ...d({
292
- brushHeight: ot,
293
- brushAriaLabel: st
292
+ brushHeight: st,
293
+ brushAriaLabel: ct
294
294
  })
295
295
  })
296
296
  ]
@@ -298,8 +298,8 @@ var _e = t("", {
298
298
  })
299
299
  });
300
300
  });
301
- C.displayName = "ComposedChart";
301
+ w.displayName = "ComposedChart";
302
302
  //#endregion
303
- export { C as ComposedChart, _e as composedChartVariants };
303
+ export { w as ComposedChart, _e as composedChartVariants };
304
304
 
305
305
  //# sourceMappingURL=composed-chart.js.map