@vitavision/charts 0.8.3 → 0.8.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.
- package/README.md +24 -5
- package/dist/index.d.ts +372 -77
- package/dist/index.js +1294 -406
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/ColormapLegend.tsx +250 -11
- package/src/Frame.tsx +15 -2
- package/src/LineChart.tsx +45 -4
- package/src/ScatterChart.tsx +416 -0
- package/src/band.ts +105 -0
- package/src/colormap.ts +86 -6
- package/src/index.ts +24 -2
- package/src/interaction.tsx +16 -28
- package/src/interpolate.ts +27 -0
- package/src/scatter.ts +77 -0
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["plotArea"],"sources":["../src/Frame.tsx","../src/scale.ts","../src/interaction.tsx","../src/LineChart.tsx","../src/BarChart.tsx","../src/bars.ts","../src/ThresholdRule.tsx","../src/Histogram.tsx","../src/ScoreHistogram.tsx","../src/LineProfile.tsx","../src/colormap.ts","../src/ColormapLegend.tsx"],"sourcesContent":["/**\n * The plot frame every chart here composes: axes, ticks, grid, labels.\n *\n * Charts are drawn into a fixed `viewBox` and scaled by CSS, so one component works at\n * any panel width without measuring the DOM. The consequence is that font sizes are in\n * viewBox units and therefore scale with the chart: the *same* 10-unit label renders at\n * 9 px in a half-width panel and at 21 px across a full-width one, which looks like two\n * different design systems on one screen.\n *\n * So the viewBox is chosen to roughly match the width the chart will actually be given.\n * `panel` is for the two-column grids, `wide` for a chart that spans a panel on its own.\n * That keeps the scale factor near 1 in both, and it is why callers pick a variant rather\n * than a pixel width — the variant says where the chart is going, not how big to draw it.\n */\n\nimport { useCallback, useState, type ReactNode, type Ref } from \"react\";\n\nimport { cn } from \"@vitavision/ui\";\n\nimport type { Scale } from \"./scale\";\n\n/**\n * Where a chart is going: `panel` (a 480×280 viewBox) for one column of a two-column grid,\n * `wide` (960×320) for a chart that spans a panel on its own, or `fluid` to take its\n * container's width at a fixed height, with text at its true size at any width.\n *\n * @remarks\n * Pick it by placement, not by pixel width — it keeps the chart's text at the same rendered\n * size as its neighbours'. `fluid` measures its container (a `ResizeObserver`), for a chart\n * in a resizable inspector or under a canvas.\n */\nexport type Variant = \"panel\" | \"wide\" | \"fluid\";\n\n/** The width a `fluid` chart assumes before it has been measured, and on the server. */\nconst FLUID_INITIAL_WIDTH = 480;\n/** A `fluid` chart's default height, in CSS pixels. */\nexport const FLUID_DEFAULT_HEIGHT = 200;\n\nconst GEOMETRY = {\n panel: { width: 480, height: 280 },\n wide: { width: 960, height: 320 },\n} as const;\n\nconst MARGIN = { left: 56, right: 12, top: 12, bottom: 34 } as const;\n\n/**\n * The drawable rectangle for one variant, in that variant's viewBox units.\n *\n * @param variant - Which viewBox the chart is drawn in.\n * @param size - For `fluid`: the measured size in CSS pixels (see {@link useFluidSize}).\n * @returns The plot area's edges — `x0`/`x1` left to right, `y0` the bottom and `y1` the top\n * (SVG y grows downwards) — and the whole viewBox's `width`/`height`. Build scales over\n * `[x0, x1]` and `[y0, y1]`.\n */\nexport function areaFor(variant: Variant, size?: { width: number; height: number }) {\n const { width, height } =\n variant === \"fluid\" ? (size ?? { width: FLUID_INITIAL_WIDTH, height: FLUID_DEFAULT_HEIGHT }) : GEOMETRY[variant];\n return {\n x0: MARGIN.left,\n x1: width - MARGIN.right,\n y0: height - MARGIN.bottom,\n y1: MARGIN.top,\n width,\n height,\n };\n}\n\n/** The default geometry, for callers that do not care which variant they are in. */\nexport const plotArea = areaFor(\"panel\");\n\n/**\n * The size of a `fluid` chart: its container's width, measured, at `height`.\n *\n * @param height - The chart's height in CSS pixels. Defaults to {@link FLUID_DEFAULT_HEIGHT}.\n * @returns `[ref, size]`. Attach `ref` to the element whose width the chart takes (the\n * `Frame`'s `figureRef`). The size is a 480 px-wide default until the first measure.\n */\nexport function useFluidSize(\n height: number = FLUID_DEFAULT_HEIGHT,\n): [(element: HTMLElement | null) => void, { width: number; height: number }] {\n const [width, setWidth] = useState(FLUID_INITIAL_WIDTH);\n const ref = useCallback((element: HTMLElement | null) => {\n if (!element) return;\n const measure = (w: number) => {\n if (w > 0) setWidth(Math.round(w));\n };\n measure(element.getBoundingClientRect().width);\n const observer = new ResizeObserver((entries) => measure(entries[0]?.contentRect.width ?? 0));\n observer.observe(element);\n return () => observer.disconnect();\n }, []);\n return [ref, { width, height }];\n}\n\n/** Held at the two ends of the neutral ramp, matching the design system's chrome colours. */\nconst AXIS = \"currentColor\";\n\n/** Props for {@link Frame}. */\nexport interface FrameProps {\n /** The horizontal scale, built over this variant's `x0`…`x1` (see {@link areaFor}). */\n xScale: Scale;\n /** The vertical scale, built over this variant's `y0`…`y1` (see {@link areaFor}). */\n yScale: Scale;\n /** Axis title under the x axis. Omitted: no title. */\n xLabel?: string | undefined;\n /** Axis title beside the y axis, rotated. Omitted: no title. */\n yLabel?: string | undefined;\n /** Rough number of x ticks to ask the scale for. Default 5. */\n xTicks?: number;\n /** Rough number of y ticks to ask the scale for. Default 4. */\n yTicks?: number;\n /** Drawn inside the plot area, above the grid and below nothing. */\n children?: ReactNode;\n /** Accessible name — every chart must have one; it is what the tests query on. */\n label: string;\n /** Rendered under the plot: a legend, a caption, a truncation note. */\n footer?: ReactNode;\n /** Where this chart is going, so its text renders at the same size as its neighbours. */\n variant?: Variant;\n /** Extra classes for the outer `<figure>`, merged with `cn`. */\n className?: string | undefined;\n /** For `fluid`: the measured size (see {@link useFluidSize}). */\n size?: { width: number; height: number } | undefined;\n /** A ref to the outer `<figure>`, e.g. {@link useFluidSize}'s measuring ref. */\n figureRef?: Ref<HTMLElement> | undefined;\n}\n\n/**\n * The plot shell every chart here composes: grid, ticks, axes, axis titles, a footer.\n *\n * @remarks\n * Renders a `<figure>` holding an SVG with `role=\"img\"` named by `label`, and the `footer`\n * as its `<figcaption>`. `children` are drawn in viewBox units over the grid.\n */\nexport function Frame({\n xScale,\n yScale,\n xLabel,\n yLabel,\n xTicks = 5,\n yTicks = 4,\n children,\n label,\n footer,\n variant = \"panel\",\n className,\n size,\n figureRef,\n}: FrameProps) {\n const horizontal = xScale.ticks(xTicks);\n const vertical = yScale.ticks(yTicks);\n const plotArea = areaFor(variant, size);\n const PLOT = { width: plotArea.width, height: plotArea.height };\n\n return (\n <figure ref={figureRef} className={cn(\"flex flex-col gap-1 text-fg-muted\", className)}>\n <svg role=\"img\" aria-label={label} viewBox={`0 0 ${PLOT.width} ${PLOT.height}`} className=\"w-full\">\n {vertical.map((tick) => {\n const y = yScale.project(tick.value);\n return (\n <g key={`y-${tick.value}`}>\n <line x1={plotArea.x0} x2={plotArea.x1} y1={y} y2={y} stroke={AXIS} strokeWidth={0.5} opacity={0.25} />\n <text x={plotArea.x0 - 6} y={y + 3.5} textAnchor=\"end\" fontSize={10} fill={AXIS}>\n {tick.label}\n </text>\n </g>\n );\n })}\n\n {horizontal.map((tick) => {\n const x = xScale.project(tick.value);\n return (\n <g key={`x-${tick.value}`}>\n <line x1={x} x2={x} y1={plotArea.y0} y2={plotArea.y1} stroke={AXIS} strokeWidth={0.5} opacity={0.15} />\n <text x={x} y={plotArea.y0 + 14} textAnchor=\"middle\" fontSize={10} fill={AXIS}>\n {tick.label}\n </text>\n </g>\n );\n })}\n\n <line x1={plotArea.x0} x2={plotArea.x1} y1={plotArea.y0} y2={plotArea.y0} stroke={AXIS} strokeWidth={1} opacity={0.6} />\n <line x1={plotArea.x0} x2={plotArea.x0} y1={plotArea.y0} y2={plotArea.y1} stroke={AXIS} strokeWidth={1} opacity={0.6} />\n\n {children}\n\n {xLabel && (\n <text x={(plotArea.x0 + plotArea.x1) / 2} y={PLOT.height - 2} textAnchor=\"middle\" fontSize={10} fill={AXIS}>\n {xLabel}\n </text>\n )}\n {yLabel && (\n <text transform={`translate(10 ${(plotArea.y0 + plotArea.y1) / 2}) rotate(-90)`} textAnchor=\"middle\" fontSize={10} fill={AXIS}>\n {yLabel}\n </text>\n )}\n </svg>\n {footer && <figcaption className=\"text-xs\">{footer}</figcaption>}\n </figure>\n );\n}\n\n/** One entry of a {@link Legend}. */\nexport interface LegendItem {\n /** The series name, rendered as text — it is what a screen reader announces. */\n label: string;\n /** Any CSS colour: a `var(--series-n)` from {@link seriesColour}, or a verdict token. */\n colour: string;\n}\n\n/** Props for {@link Legend}. */\nexport interface LegendProps {\n /** Entries, in the order the series were drawn. */\n items: LegendItem[];\n /** Extra classes for the `<ul>`, merged with `cn`. */\n className?: string | undefined;\n}\n\n/**\n * A legend row. Kept beside the frame rather than inside the SVG so the swatches are real\n * text and CSS rather than a second typography in viewBox units.\n *\n * @remarks\n * The swatches are `aria-hidden`; each series is identified by its name, never by colour\n * alone.\n */\nexport function Legend({ items, className }: LegendProps) {\n return (\n <ul className={cn(\"flex flex-wrap items-center gap-x-4 gap-y-1\", className)}>\n {items.map((item) => (\n <li key={item.label} className=\"flex items-center gap-1.5\">\n <span aria-hidden className=\"inline-block h-0.5 w-4 rounded-full\" style={{ backgroundColor: item.colour }} />\n <span className=\"font-mono text-xs\">{item.label}</span>\n </li>\n ))}\n </ul>\n );\n}\n\n/**\n * The shared categorical series palette, as CSS paint values: `var(--series-1)` …\n * `var(--series-6)`.\n *\n * @remarks\n * The colours themselves are tokens in `@vitavision/charts/styles.css`, defined for both\n * themes, so that stylesheet must be imported after `@vitavision/ui/styles.css`. The chrome\n * carries no saturation, which makes this the one place a chart is allowed to be loud.\n *\n * Each slot keeps its hue family across the themes — cyan, orange, violet, blue, pink, then\n * a neutral grey as the sixth — and only its lightness changes, so every colour holds 3:1\n * against the panel in both. The six stay distinguishable under simulated protanopia,\n * deuteranopia and tritanopia, and none of them is a verdict colour (`--normal`,\n * `--defect`, `--warn`): a series is never read as a verdict.\n *\n * Before 0.6 these were fixed hex strings; the names are unchanged.\n */\nexport const SERIES_COLOURS = [\n \"var(--series-1)\",\n \"var(--series-2)\",\n \"var(--series-3)\",\n \"var(--series-4)\",\n \"var(--series-5)\",\n \"var(--series-6)\",\n] as const;\n\n/**\n * The paint for outcomes judged normal — `var(--normal)`, the design system's verdict token.\n *\n * @remarks\n * Exported so a histogram and any caught/missed bars share one green rather than each\n * restating it: a green that means \"normal\" has to be one green. Before 0.6 this was a\n * fixed hex string.\n */\nexport const NORMAL_COLOUR = \"var(--normal)\";\n\n/**\n * The paint for outcomes judged defective — `var(--defect)`, the design system's verdict\n * token.\n *\n * @remarks\n * The partner of {@link NORMAL_COLOUR}. Before 0.6 this was a fixed hex string.\n */\nexport const DEFECT_COLOUR = \"var(--defect)\";\n\n/**\n * The series colour for the `index`-th series, cycling through {@link SERIES_COLOURS}.\n *\n * @param index - Zero-based series index. Negative or non-integer indices fall back to the\n * neutral `var(--fg-muted)`.\n * @returns A CSS paint value, usable as an SVG `fill`/`stroke` or a CSS `color`.\n */\nexport function seriesColour(index: number): string {\n return SERIES_COLOURS[index % SERIES_COLOURS.length] ?? \"var(--fg-muted)\";\n}\n","/**\n * The arithmetic behind every chart: domains, ticks, and the map from a value to a pixel.\n *\n * Hand-rolled SVG rather than a charting library: the chart types this design system needs\n * are few and simple, and a library that lags the React and Tailwind versions the apps\n * are deliberately on would mean either downgrading a consumer or isolating a laggard — a\n * cost that outweighs a few hundred lines of scale maths.\n *\n * Everything here is pure. That is the point: it is the part worth unit-testing, and it\n * leaves the components themselves as thin as an SVG element list.\n */\n\n/** A tick's position in domain units, with the label to draw beside it. */\nexport interface Tick {\n /** Where the tick sits, in domain units — pass it to {@link Scale.project}. */\n value: number;\n /** The text to draw beside it, formatted by {@link formatTick}. */\n label: string;\n}\n\n/**\n * A map from a numeric domain onto a pixel range, with the ticks to label it.\n *\n * @remarks\n * Built by {@link linearScale} or {@link logScale}. `project` is not clamped: a value\n * outside the domain lands outside the range.\n */\nexport interface Scale {\n /** Domain, after padding and after any log transform's guard. */\n domain: [number, number];\n /** Map one domain value onto the pixel range this scale was built for. */\n project: (value: number) => number;\n /** The inverse of `project`: the domain value at a pixel. Not clamped. */\n invert: (pixel: number) => number;\n /**\n * Ticks inside the domain, in ascending order.\n *\n * @param count - Roughly how many ticks to aim for (default 5). The result may have a\n * few more or fewer: steps are \"nice\" (see {@link niceStep}), or whole decades on a log\n * scale.\n */\n ticks: (count?: number) => Tick[];\n}\n\n/** Smallest value a log scale will accept, so a zero loss cannot become `-Infinity`. */\nconst LOG_FLOOR = 1e-12;\n\nconst TICK_STEPS = [1, 2, 2.5, 5, 10];\n\n/** Past this a label is noise; anything finer is shown as an exponent instead. */\nconst MAX_DECIMALS = 6;\n\n/**\n * A \"nice\" step at or above `rough` — one of 1, 2, 2.5 or 5 times a power of ten.\n *\n * Axis labels a reader can hold in their head are the whole reason: 0.25 / 0.50 / 0.75\n * rather than 0.237 / 0.474 / 0.711.\n */\nexport function niceStep(rough: number): number {\n if (!Number.isFinite(rough) || rough <= 0) return 1;\n const magnitude = 10 ** Math.floor(Math.log10(rough));\n const normalized = rough / magnitude;\n const step = TICK_STEPS.find((candidate) => candidate >= normalized - 1e-9) ?? 10;\n return step * magnitude;\n}\n\n/**\n * How many decimals a label needs so that neighbouring ticks do not print identically.\n *\n * Derived from the step rather than fixed, because one chart here might be a loss around\n * 1e-4 and another a residual in whole pixels. Enough decimals to print the *step* exactly\n * is the right rule, and `ceil(-log10(step))` is not it: a 0.25 step gets one decimal that\n * way, and the axis reads 0.3 / 0.5 / 0.8 — three labels for four evenly spaced ticks.\n */\nfunction decimalsFor(step: number): number {\n if (!Number.isFinite(step) || step <= 0) return 0;\n for (let decimals = 0; decimals < MAX_DECIMALS; decimals += 1) {\n if (Math.abs(Number(step.toFixed(decimals)) - step) < step * 1e-6) return decimals;\n }\n return MAX_DECIMALS;\n}\n\n/**\n * The label for one tick: as many decimals as the step needs, or an exponent for a\n * magnitude below 1e-3 or from 1e6 upwards.\n *\n * @param value - The tick's value.\n * @param step - The spacing between neighbouring ticks; it decides the decimals.\n * @returns The label, or `\"\"` for a non-finite value.\n */\nexport function formatTick(value: number, step: number): string {\n if (!Number.isFinite(value)) return \"\";\n const magnitude = Math.abs(value);\n // Outside the range where a decimal reads better than an exponent. A loss of 3.2e-5 is\n // legible; 0.000032 is a row of zeroes the eye has to count.\n if (magnitude !== 0 && (magnitude < 1e-3 || magnitude >= 1e6)) {\n return value.toExponential(1);\n }\n return value.toFixed(decimalsFor(step));\n}\n\n/**\n * Widen a degenerate domain into one that can be drawn.\n *\n * A single-point series, or a constant one, has `min === max`. Left alone that divides by\n * zero and the line vanishes; widened, the point sits in the middle of a sensible axis,\n * which is what watching the first moments of a training run, or a profile with one sample\n * so far, should look like.\n */\nexport function padDomain(min: number, max: number): [number, number] {\n if (!Number.isFinite(min) || !Number.isFinite(max)) return [0, 1];\n if (min === max) {\n const margin = Math.abs(min) > 0 ? Math.abs(min) * 0.1 : 1;\n return [min - margin, max + margin];\n }\n return [min, max];\n}\n\n/**\n * The `[min, max]` of the finite values, ignoring `NaN` and infinities.\n *\n * @returns `[0, 1]` when there is no finite value, so an empty series still has an axis.\n */\nexport function extent(values: readonly number[]): [number, number] {\n const finite = values.filter((value) => Number.isFinite(value));\n if (finite.length === 0) return [0, 1];\n return [Math.min(...finite), Math.max(...finite)];\n}\n\n/** A linear scale from `domain` onto `[rangeStart, rangeEnd]` pixels. */\nexport function linearScale(domain: [number, number], rangeStart: number, rangeEnd: number): Scale {\n const [low, high] = padDomain(domain[0], domain[1]);\n const span = high - low;\n return {\n domain: [low, high],\n project: (value) => rangeStart + ((value - low) / span) * (rangeEnd - rangeStart),\n invert: (pixel) => low + ((pixel - rangeStart) / (rangeEnd - rangeStart)) * span,\n ticks: (count = 5) => {\n const step = niceStep(span / Math.max(1, count));\n const first = Math.ceil(low / step) * step;\n const ticks: Tick[] = [];\n for (let value = first; value <= high + step * 1e-9; value += step) {\n // Re-derived from the step index rather than accumulated, so floating-point drift\n // cannot turn 0.30000000000000004 into a label.\n const exact = Math.round(value / step) * step;\n ticks.push({ value: exact, label: formatTick(exact, step) });\n }\n return ticks;\n },\n };\n}\n\n/**\n * A base-10 log scale, for series that span decades.\n *\n * A loss curve is the canonical case: three terms that span decades and start far apart\n * are a flat line along the bottom for two of the three on a linear axis. Non-positive\n * values are clamped to `LOG_FLOOR` rather than dropped: a value that reaches exactly zero\n * is a real observation, and a gap in the line would read as missing data.\n */\nexport function logScale(domain: [number, number], rangeStart: number, rangeEnd: number): Scale {\n const low = Math.log10(Math.max(domain[0], LOG_FLOOR));\n const high = Math.log10(Math.max(domain[1], LOG_FLOOR));\n const [paddedLow, paddedHigh] = padDomain(low, high);\n const span = paddedHigh - paddedLow;\n\n return {\n domain: [10 ** paddedLow, 10 ** paddedHigh],\n project: (value) => {\n const transformed = Math.log10(Math.max(value, LOG_FLOOR));\n return rangeStart + ((transformed - paddedLow) / span) * (rangeEnd - rangeStart);\n },\n invert: (pixel) => 10 ** (paddedLow + ((pixel - rangeStart) / (rangeEnd - rangeStart)) * span),\n ticks: (count = 5) => {\n // One tick per decade, thinned when the range covers more decades than fit.\n const stride = Math.max(1, Math.ceil(span / Math.max(1, count)));\n const ticks: Tick[] = [];\n for (let exponent = Math.ceil(paddedLow); exponent <= paddedHigh + 1e-9; exponent += stride) {\n const value = 10 ** exponent;\n ticks.push({ value, label: formatTick(value, value) });\n }\n return ticks;\n },\n };\n}\n\n/** An SVG `d` attribute through the projected points, skipping non-finite ones. */\nexport function linePath(points: readonly { x: number; y: number }[], xScale: Scale, yScale: Scale): string {\n const commands: string[] = [];\n let pen = \"M\";\n for (const point of points) {\n if (!Number.isFinite(point.x) || !Number.isFinite(point.y)) {\n // Lift the pen rather than bridging the gap: a straight line across missing data\n // is an assertion nobody made.\n pen = \"M\";\n continue;\n }\n commands.push(`${pen}${xScale.project(point.x).toFixed(2)} ${yScale.project(point.y).toFixed(2)}`);\n pen = \"L\";\n }\n return commands.join(\" \");\n}\n\n/**\n * Bin values into `count` equal-width buckets over their own extent.\n *\n * Used for the score histogram, where the two classes must share one set of edges or the\n * bars cannot be compared. Callers pass the shared domain in for exactly that reason.\n */\nexport function histogram(values: readonly number[], domain: [number, number], count: number): number[] {\n const bins = new Array<number>(Math.max(1, count)).fill(0);\n const [low, high] = domain;\n const span = high - low;\n if (span <= 0) {\n bins[0] = values.length;\n return bins;\n }\n for (const value of values) {\n if (!Number.isFinite(value)) continue;\n const index = Math.min(bins.length - 1, Math.floor(((value - low) / span) * bins.length));\n if (index >= 0) bins[index] = (bins[index] ?? 0) + 1;\n }\n return bins;\n}\n","/**\n * What `LineChart` and `LineProfile` share beyond the frame:\n * - x ranges and positions marked on the plot (`bands`, `markers`);\n * - a pointer that reads the plot back (hover readout, click to pick);\n * - a cursor the app can drive from elsewhere, e.g. the canvas a profile was sampled on.\n */\n\nimport { useState } from \"react\";\n\nimport { toneColor, type MeasureTone } from \"@vitavision/ui\";\n\nimport type { Scale } from \"./scale\";\n\n/** An x range marked on the plot: a gap, a stretch out of tolerance, a region of interest. */\nexport interface Band {\n /** Start of the range, in x domain units. */\n from: number;\n /** End of the range. */\n to: number;\n /** Its colour. Default `\"muted\"`. */\n tone?: MeasureTone | undefined;\n /** Text at the top of the band. */\n label?: string | undefined;\n}\n\n/** A position marked on the x axis with a short tick: a station, a sample, a frame. */\nexport interface Marker {\n /** Where, in x domain units. */\n position: number;\n /** Its colour. Default `\"muted\"`. */\n tone?: MeasureTone | undefined;\n /** Shown as the tick's tooltip (`<title>`). */\n label?: string | undefined;\n}\n\n/** A series as the readout sees it. */\nexport interface ReadoutSeries {\n /** Its name. */\n name: string;\n /** Its points. */\n points: readonly { x: number; y: number }[];\n /** Its colour. */\n colour: string;\n}\n\n/** The props `LineChart` and `LineProfile` share for interaction and marking. */\nexport interface InteractionProps {\n /** x ranges drawn behind the series. */\n bands?: readonly Band[] | undefined;\n /** Positions ticked on the x axis. */\n markers?: readonly Marker[] | undefined;\n /** An x position drawn as a vertical rule, from outside the chart (e.g. a canvas hover). */\n cursor?: number | null | undefined;\n /** Called with the x under the pointer (in domain units, clamped to the domain), or `null` on leaving. */\n onHover?: ((x: number | null) => void) | undefined;\n /** Called with the x under a click. Makes the plot area a pointer target. */\n onPick?: ((x: number) => void) | undefined;\n}\n\n/** Plot-area edges in viewBox units, as `areaFor` returns them (`y0` is the bottom). */\nexport interface PlotArea {\n /** Left edge. */\n x0: number;\n /** Right edge. */\n x1: number;\n /** Bottom edge. */\n y0: number;\n /** Top edge. */\n y1: number;\n}\n\n/** The ranges behind the series. */\nexport function Bands({ bands, xScale, area }: { bands: readonly Band[]; xScale: Scale; area: PlotArea }) {\n return (\n <g data-bands=\"\">\n {bands.map((band) => {\n const a = clamp(xScale.project(Math.min(band.from, band.to)), area.x0, area.x1);\n const b = clamp(xScale.project(Math.max(band.from, band.to)), area.x0, area.x1);\n const colour = toneColor(band.tone, \"muted\");\n return (\n <g key={`${band.from}-${band.to}-${band.label ?? \"\"}`}>\n <rect x={a} y={area.y1} width={Math.max(1, b - a)} height={area.y0 - area.y1} fill={colour} opacity={0.14} />\n {band.label && (\n <text x={(a + b) / 2} y={area.y1 + 10} textAnchor=\"middle\" fontSize={9} fill={colour}>\n {band.label}\n </text>\n )}\n </g>\n );\n })}\n </g>\n );\n}\n\n/** The ticks on the x axis. */\nexport function Markers({ markers, xScale, area }: { markers: readonly Marker[]; xScale: Scale; area: PlotArea }) {\n return (\n <g data-markers=\"\">\n {markers.map((marker) => {\n const x = xScale.project(marker.position);\n if (x < area.x0 - 0.5 || x > area.x1 + 0.5) return null;\n return (\n <line\n key={`${marker.position}-${marker.label ?? \"\"}`}\n x1={x}\n x2={x}\n y1={area.y0}\n y2={area.y0 - 6}\n stroke={toneColor(marker.tone, \"muted\")}\n strokeWidth={1.5}\n >\n {marker.label && <title>{marker.label}</title>}\n </line>\n );\n })}\n </g>\n );\n}\n\n/**\n * The pointer layer over the plot area: a crosshair and a value readout while hovering, the\n * external `cursor` otherwise, and clicks as picks.\n */\nexport function PlotInteraction({\n xScale,\n yScale,\n area,\n series,\n cursor,\n onHover,\n onPick,\n format = (value: number) => (Math.abs(value) >= 100 ? value.toFixed(0) : value.toPrecision(3)),\n}: {\n xScale: Scale;\n yScale: Scale;\n area: PlotArea;\n series: readonly ReadoutSeries[];\n cursor?: number | null | undefined;\n onHover?: ((x: number | null) => void) | undefined;\n onPick?: ((x: number) => void) | undefined;\n format?: (value: number) => string;\n}) {\n const [hover, setHover] = useState<number | null>(null);\n const interactive = onHover !== undefined || onPick !== undefined;\n\n const xAt = (event: { clientX: number; clientY: number; currentTarget: SVGRectElement }): number => {\n const svg = event.currentTarget.ownerSVGElement;\n const ctm = svg?.getScreenCTM();\n let local = event.clientX;\n if (svg && ctm) {\n const point = svg.createSVGPoint();\n point.x = event.clientX;\n point.y = event.clientY;\n local = point.matrixTransform(ctm.inverse()).x;\n }\n const [low, high] = xScale.domain;\n return clamp(xScale.invert(local), Math.min(low, high), Math.max(low, high));\n };\n\n const shown = hover ?? cursor ?? null;\n const x = shown === null ? null : xScale.project(shown);\n const readout =\n hover === null\n ? []\n : series.flatMap((entry) => {\n const y = seriesValueAt(entry.points, hover);\n return y === null ? [] : [{ name: entry.name, colour: entry.colour, y }];\n });\n\n return (\n <g data-interaction=\"\">\n {x !== null && x >= area.x0 - 0.5 && x <= area.x1 + 0.5 && (\n <line\n data-crosshair=\"\"\n x1={x}\n x2={x}\n y1={area.y0}\n y2={area.y1}\n stroke=\"currentColor\"\n strokeWidth={1}\n opacity={hover === null ? 0.6 : 0.9}\n />\n )}\n {readout.map((entry) => (\n <circle\n key={entry.name}\n cx={x ?? 0}\n cy={yScale.project(entry.y)}\n r={3}\n fill={entry.colour}\n stroke=\"var(--surface)\"\n strokeWidth={1}\n />\n ))}\n {hover !== null && x !== null && (\n <text\n data-readout=\"\"\n x={x > (area.x0 + area.x1) / 2 ? x - 6 : x + 6}\n y={area.y1 + 10}\n textAnchor={x > (area.x0 + area.x1) / 2 ? \"end\" : \"start\"}\n fontSize={10}\n fill=\"currentColor\"\n >\n {[format(hover), ...readout.map((entry) => `${entry.name} ${format(entry.y)}`)].join(\" · \")}\n </text>\n )}\n {interactive && (\n <rect\n data-plot-target=\"\"\n x={area.x0}\n y={area.y1}\n width={area.x1 - area.x0}\n height={area.y0 - area.y1}\n fill=\"transparent\"\n style={{ cursor: onPick ? \"pointer\" : \"crosshair\" }}\n onPointerMove={(event) => {\n const value = xAt(event);\n setHover(value);\n onHover?.(value);\n }}\n onPointerLeave={() => {\n setHover(null);\n onHover?.(null);\n }}\n onClick={(event) => onPick?.(xAt(event))}\n />\n )}\n </g>\n );\n}\n\n/**\n * A series' value at `x`, linearly interpolated between the points either side, or `null`\n * outside its range or across a gap.\n *\n * @param points - The series, in ascending `x`.\n * @param x - Where.\n * @returns The interpolated value, or `null`.\n */\nexport function seriesValueAt(points: readonly { x: number; y: number }[], x: number): number | null {\n if (points.length === 0) return null;\n if (points.length === 1) return points[0]!.x === x ? points[0]!.y : null;\n let lo = 0;\n let hi = points.length - 1;\n if (x < points[lo]!.x || x > points[hi]!.x) return null;\n while (hi - lo > 1) {\n const mid = (lo + hi) >> 1;\n if (points[mid]!.x <= x) lo = mid;\n else hi = mid;\n }\n const a = points[lo]!;\n const b = points[hi]!;\n if (!Number.isFinite(a.y) || !Number.isFinite(b.y)) return null;\n if (b.x === a.x) return a.y;\n return a.y + ((x - a.x) / (b.x - a.x)) * (b.y - a.y);\n}\n\nfunction clamp(value: number, low: number, high: number): number {\n return Math.min(high, Math.max(low, value));\n}\n","/**\n * Multi-series line chart — training curves, or any series plotted over a shared axis.\n *\n * A series with no points draws nothing but still claims its legend entry, so a term that\n * has not reported yet is visibly pending rather than silently absent. A series with one\n * point draws a dot: at the start of a run that is genuinely all there is, and an empty\n * chart would read as \"nothing is happening\".\n */\n\nimport type { ReactNode } from \"react\";\n\nimport { FLUID_DEFAULT_HEIGHT, Frame, Legend, areaFor, seriesColour, useFluidSize } from \"./Frame\";\nimport { Bands, Markers, PlotInteraction, type InteractionProps } from \"./interaction\";\nimport type { Variant } from \"./Frame\";\nimport type { Scale } from \"./scale\";\nimport { extent, linePath, linearScale, logScale } from \"./scale\";\n\n/** One line of a {@link LineChart}. */\nexport interface Series {\n /** Legend text, and the React key — unique within one chart. */\n name: string;\n /**\n * Points in draw order. A non-finite coordinate lifts the pen rather than bridging the\n * gap; a single point draws a dot; no points draws nothing but keeps the legend entry.\n */\n points: { x: number; y: number }[];\n /** Any CSS colour. Omitted: {@link seriesColour} of the series' index. */\n colour?: string;\n}\n\n/** Props for {@link LineChart}. */\nexport interface LineChartProps extends InteractionProps {\n /** The lines, drawn in order — a later series paints over an earlier one. */\n series: Series[];\n /** Accessible name of the chart (the SVG's `aria-label`). Required. */\n label: string;\n /** x-axis title. */\n xLabel?: string;\n /** y-axis title. */\n yLabel?: string;\n /** Losses span decades; a linear axis flattens two of the three onto the floor. */\n logY?: boolean;\n /** Fixed domains, for charts whose axes are known — ROC and PR are both `[0, 1]`. */\n xDomain?: [number, number];\n /** Fixed y domain. Omitted: the extent of every series' `y`. */\n yDomain?: [number, number];\n /** Drawn behind the series, in plot pixels. A chance diagonal or a tolerance band uses this. */\n underlay?: (x: Scale, y: Scale) => ReactNode;\n /** Rendered under the legend, inside the `<figcaption>`. */\n footer?: ReactNode;\n /** Show the legend row. Default `true`. */\n showLegend?: boolean;\n /** Where the chart is going (see {@link Variant}). Default `\"panel\"`. */\n variant?: Variant;\n /** Extra classes for the outer `<figure>`, merged with `cn`. */\n className?: string | undefined;\n /** For `variant=\"fluid\"`: the chart's height in CSS pixels. Default 200. */\n height?: number | undefined;\n}\n\n/**\n * A multi-series line chart over a shared x axis — training curves, ROC and PR curves.\n *\n * @remarks\n * An SVG `role=\"img\"` named by `label`, with the legend as real text under it. Series are\n * told apart by the legend's names, never by colour alone. `bands` and `markers` mark x\n * ranges and positions; `onHover` adds a crosshair and a value readout, `onPick` makes a\n * click report its x, and `cursor` draws an x chosen elsewhere.\n */\nexport function LineChart({\n series,\n label,\n xLabel,\n yLabel,\n logY = false,\n xDomain,\n yDomain,\n underlay,\n footer,\n showLegend = true,\n variant = \"panel\",\n className,\n height = FLUID_DEFAULT_HEIGHT,\n bands,\n markers,\n cursor,\n onHover,\n onPick,\n}: LineChartProps) {\n const allX = series.flatMap((entry) => entry.points.map((point) => point.x));\n const allY = series.flatMap((entry) => entry.points.map((point) => point.y));\n const [fluidRef, fluidSize] = useFluidSize(height);\n const size = variant === \"fluid\" ? fluidSize : undefined;\n const plotArea = areaFor(variant, size);\n\n const xScale = linearScale(xDomain ?? extent(allX), plotArea.x0, plotArea.x1);\n const makeY = logY ? logScale : linearScale;\n const yScale = makeY(yDomain ?? extent(allY), plotArea.y0, plotArea.y1);\n\n const coloured = series.map((entry, index) => ({\n ...entry,\n colour: entry.colour ?? seriesColour(index),\n }));\n\n return (\n <Frame\n xScale={xScale}\n yScale={yScale}\n xLabel={xLabel}\n yLabel={yLabel}\n label={label}\n variant={variant}\n className={className}\n size={size}\n figureRef={variant === \"fluid\" ? fluidRef : undefined}\n footer={\n <div className=\"flex flex-col gap-1\">\n {showLegend && <Legend items={coloured.map((entry) => ({ label: entry.name, colour: entry.colour }))} />}\n {footer}\n </div>\n }\n >\n {bands && bands.length > 0 && <Bands bands={bands} xScale={xScale} area={plotArea} />}\n {underlay?.(xScale, yScale)}\n {coloured.map((entry) =>\n entry.points.length === 1 ? (\n <circle\n key={entry.name}\n cx={xScale.project(entry.points[0]?.x ?? 0)}\n cy={yScale.project(entry.points[0]?.y ?? 0)}\n r={2.5}\n fill={entry.colour}\n />\n ) : (\n <path\n key={entry.name}\n d={linePath(entry.points, xScale, yScale)}\n fill=\"none\"\n stroke={entry.colour}\n strokeWidth={1.5}\n strokeLinejoin=\"round\"\n vectorEffect=\"non-scaling-stroke\"\n />\n ),\n )}\n {markers && markers.length > 0 && <Markers markers={markers} xScale={xScale} area={plotArea} />}\n {(onHover || onPick || cursor !== undefined) && (\n <PlotInteraction\n xScale={xScale}\n yScale={yScale}\n area={plotArea}\n series={coloured}\n cursor={cursor}\n onHover={onHover}\n onPick={onPick}\n />\n )}\n </Frame>\n );\n}\n","/**\n * Horizontal stacked bars — a per-category breakdown.\n *\n * Horizontal because the categories are free text — a defect type, a part family — and a\n * vertical axis would either truncate them or turn them sideways. Stacked because the\n * usual question is \"of this category, how many landed in each outcome\", which is a\n * proportion of a known total rather than independent counts.\n */\n\nimport { cn } from \"@vitavision/ui\";\n\n/** One category of {@link StackedBars}: a label and its segments. */\nexport interface BarRow {\n /** The category, shown truncated in a fixed-width column (full text in `title`). */\n label: string;\n /** Segments in draw order, left to right. */\n segments: { name: string; value: number; colour: string }[];\n}\n\n/** Props for {@link StackedBars}. */\nexport interface StackedBarsProps {\n /** The categories, top to bottom. */\n rows: BarRow[];\n /** Accessible name of the table. Required. */\n label: string;\n /** Extra classes for the outer element, merged with `cn`. */\n className?: string | undefined;\n}\n\n/**\n * Horizontal stacked bars, one row per category, all on one shared scale (the widest row's\n * total).\n *\n * @remarks\n * Exposed as an ARIA `table`: each row has a `rowheader` (the category) and a text cell that\n * spells every non-zero segment out as `\"<value> <name>\"`, so nothing depends on colour or\n * on bar width. A row with no non-zero segment shows its total.\n */\nexport function StackedBars({ rows, label, className }: StackedBarsProps) {\n const widest = Math.max(1, ...rows.map((row) => row.segments.reduce((total, segment) => total + segment.value, 0)));\n\n return (\n <div className={cn(\"flex flex-col gap-2\", className)} role=\"table\" aria-label={label}>\n {rows.map((row) => {\n const total = row.segments.reduce((sum, segment) => sum + segment.value, 0);\n return (\n <div key={row.label} className=\"flex items-center gap-3 text-xs\" role=\"row\">\n <span className=\"w-28 shrink-0 truncate font-mono\" role=\"rowheader\" title={row.label}>\n {row.label}\n </span>\n <div className=\"flex h-4 flex-1 overflow-hidden rounded-control bg-raised\" role=\"cell\">\n {row.segments.map((segment) =>\n segment.value === 0 ? null : (\n <div\n key={segment.name}\n className=\"h-full\"\n style={{\n width: `${(segment.value / widest) * 100}%`,\n backgroundColor: segment.colour,\n }}\n title={`${segment.name}: ${segment.value}`}\n />\n ),\n )}\n </div>\n <span className=\"w-24 shrink-0 text-right font-mono text-fg-muted\" role=\"cell\">\n {row.segments\n .filter((segment) => segment.value > 0)\n .map((segment) => `${segment.value} ${segment.name}`)\n .join(\" · \") || `${total}`}\n </span>\n </div>\n );\n })}\n </div>\n );\n}\n","/**\n * The pure core of the histogram charts: binning, bin lookup and the one path that draws\n * every bar. Nothing here touches React or the DOM.\n */\n\nimport type { PlotArea } from \"./interaction\";\nimport type { Scale } from \"./scale\";\nimport { extent, padDomain } from \"./scale\";\n\n/** Bins used when the caller does not say. */\nexport const DEFAULT_BINS = 32;\n\n/** A histogram as the chart draws it: counts over equal-width bins spanning `domain`. */\nexport interface BinnedData {\n /** One non-negative finite count per bin, left to right. */\n counts: number[];\n /** The x range the bins span, never degenerate (`low < high`). */\n domain: [number, number];\n}\n\n/** A finite, ordered, non-degenerate domain; `[0, 1]` when `domain` is unusable. */\nfunction usableDomain(low: number, high: number): [number, number] {\n return padDomain(Math.min(low, high), Math.max(low, high));\n}\n\n/**\n * Bin raw values into `bins` equal-width buckets.\n *\n * @param values - The samples. Non-finite values are ignored, and so are values outside an\n * explicit `domain` (the upper edge itself belongs to the last bin).\n * @param bins - Bucket count; a non-finite or sub-1 request falls back to 1, and `undefined`\n * to {@link DEFAULT_BINS}.\n * @param domain - The x range. Omitted: the data's extent. A single distinct value is\n * widened so it lands in a middle bin rather than on an edge.\n * @returns The counts and the domain they span.\n */\nexport function binValues(values: ArrayLike<number>, bins: number | undefined, domain?: [number, number]): BinnedData {\n const count = bins === undefined ? DEFAULT_BINS : Number.isFinite(bins) ? Math.max(1, Math.floor(bins)) : 1;\n const finite: number[] = [];\n for (let index = 0; index < values.length; index += 1) {\n const value = values[index];\n if (value !== undefined && Number.isFinite(value)) finite.push(value);\n }\n const [low, high] = domain ? usableDomain(domain[0], domain[1]) : usableDomain(...extent(finite));\n const counts = new Array<number>(count).fill(0);\n const span = high - low;\n for (const value of finite) {\n if (value < low || value > high) continue;\n const index = Math.min(count - 1, Math.floor(((value - low) / span) * count));\n counts[index] = (counts[index] ?? 0) + 1;\n }\n return { counts, domain: [low, high] };\n}\n\n/**\n * Take pre-binned counts as given, with the junk removed.\n *\n * @param counts - One count per bin, left to right.\n * @param domain - The x range the bins span.\n * @returns The counts with every non-finite or negative entry set to 0, and a usable domain.\n */\nexport function cleanCounts(counts: ArrayLike<number>, domain: [number, number]): BinnedData {\n const clean = Array.from(counts, (value) => (Number.isFinite(value) && value > 0 ? value : 0));\n return { counts: clean, domain: usableDomain(domain[0], domain[1]) };\n}\n\n/**\n * The bin containing `x`, or `null` when `x` is not finite, outside `domain`, or there are\n * no bins. The domain's upper edge belongs to the last bin.\n */\nexport function binAt(binCount: number, domain: [number, number], x: number | null | undefined): number | null {\n if (x === null || x === undefined || !Number.isFinite(x) || binCount < 1) return null;\n const [low, high] = domain;\n if (x < low || x > high) return null;\n return Math.min(binCount - 1, Math.floor(((x - low) / (high - low)) * binCount));\n}\n\n/**\n * One SVG path `d` drawing every non-empty bar as a rectangle from the baseline.\n *\n * @param counts - The bins' counts.\n * @param yScale - Maps a count to a pixel `y`.\n * @param area - The plot area; the bins fill `x0`…`x1` and stand on `y0`.\n * @param select - `{ skip: null }` (the default) draws every bar; `{ only: i }` draws just\n * bin `i`; `{ skip: i }` draws all but bin `i` — so a highlighted bin is its own path.\n */\nexport function barsPath(\n counts: readonly number[],\n yScale: Scale,\n area: PlotArea,\n select: { only: number } | { skip: number | null } = { skip: null },\n): string {\n const width = (area.x1 - area.x0) / Math.max(1, counts.length);\n // A hairline gap separates bars while they are wide enough to afford one.\n const barWidth = Math.max(0.5, width > 3 ? width - 0.5 : width);\n const parts: string[] = [];\n counts.forEach((count, index) => {\n if (count <= 0) return;\n if (\"only\" in select ? index !== select.only : index === select.skip) return;\n const x = area.x0 + index * width;\n const y = yScale.project(count);\n if (!Number.isFinite(y)) return;\n parts.push(`M${x.toFixed(2)} ${area.y0}V${y.toFixed(2)}h${barWidth.toFixed(2)}V${area.y0}z`);\n });\n return parts.join(\"\");\n}\n\n/** The largest count, at least 1, so an empty or all-zero histogram still has a y axis. */\nexport function tallest(...series: readonly (readonly number[])[]): number {\n let max = 1;\n for (const counts of series) for (const count of counts) if (count > max) max = count;\n return max;\n}\n","/**\n * The decision threshold of a histogram: a dashed rule across the plot at one x.\n */\n\nimport type { PlotArea } from \"./interaction\";\nimport type { Scale } from \"./scale\";\n\n/** A dashed vertical rule at `value`; nothing when it is missing or not finite. */\nexport function ThresholdRule({ value, xScale, area }: { value: number | undefined; xScale: Scale; area: PlotArea }) {\n if (value === undefined || !Number.isFinite(value)) return null;\n const x = xScale.project(value);\n return <line data-threshold=\"\" x1={x} x2={x} y1={area.y0} y2={area.y1} stroke=\"currentColor\" strokeWidth={1.25} strokeDasharray=\"3 2\" />;\n}\n","/**\n * A single-series histogram: one distribution, from raw values or from counts already binned.\n *\n * Raw values are binned here; counts are for the caller that cannot hand over its samples —\n * a 20 MP image's luminance is 256 numbers, not 20 million. Either way the bars are one\n * `<path>`, and the bin under `cursor` is a second one in the selection colour.\n */\n\nimport type { ReactNode } from \"react\";\n\nimport { barsPath, binAt, binValues, cleanCounts, tallest } from \"./bars\";\nimport { FLUID_DEFAULT_HEIGHT, Frame, areaFor, seriesColour, useFluidSize, type Variant } from \"./Frame\";\nimport { Bands, Markers, PlotInteraction, type InteractionProps } from \"./interaction\";\nimport { linearScale, logScale } from \"./scale\";\nimport { ThresholdRule } from \"./ThresholdRule\";\n\n/** Props every {@link Histogram} takes, whichever way its data is given. */\nexport interface HistogramOptions extends InteractionProps {\n /** Accessible name of the chart (the SVG's `aria-label`). Required. */\n label: string;\n /** x-axis title. */\n xLabel?: string | undefined;\n /** y-axis title. */\n yLabel?: string | undefined;\n /** Unit of x, appended to the x-axis title in parentheses: `luminance (DN)`. */\n unit?: string | undefined;\n /**\n * A decision threshold on x, drawn as a dashed rule across the plot (as `ScoreHistogram`\n * draws its own). Omitted or non-finite: none. For other x positions use `markers`.\n */\n threshold?: number | undefined;\n /** Counts span decades in a long-tailed distribution; a log axis keeps the tail visible. */\n logY?: boolean | undefined;\n /** Where the chart is going (see {@link Variant}). Default `\"panel\"`. */\n variant?: Variant | undefined;\n /** For `variant=\"fluid\"`: the chart's height in CSS pixels. Default 200. */\n height?: number | undefined;\n /** Rendered under the plot, inside the `<figcaption>`. */\n footer?: ReactNode;\n /** Extra classes for the outer `<figure>`, merged with `cn`. */\n className?: string | undefined;\n}\n\n/** A histogram given as raw samples, binned by the chart. */\nexport interface HistogramValues {\n /** The samples. Non-finite values, and values outside `domain`, are ignored. */\n values: ArrayLike<number>;\n /** Number of equal-width bins. Default 32. */\n bins?: number | undefined;\n /** The x range the bins span. Omitted: the extent of `values`. */\n domain?: [number, number] | undefined;\n /** Not accepted with `values` — pass one or the other. */\n counts?: undefined;\n}\n\n/** A histogram given as counts per bin, already binned by the caller. */\nexport interface HistogramCounts {\n /** One count per bin, left to right; the bins are equal-width and fill `domain`. */\n counts: ArrayLike<number>;\n /** The x range the bins span. Required: without samples there is no extent to fall back on. */\n domain: [number, number];\n /** Not accepted with `counts` — pass one or the other. */\n values?: undefined;\n}\n\n/**\n * Props for {@link Histogram}: {@link HistogramOptions} plus data as either\n * {@link HistogramValues} or {@link HistogramCounts}, never both.\n */\nexport type HistogramProps = HistogramOptions & (HistogramValues | HistogramCounts);\n\n/**\n * One distribution as a bar chart over equal-width bins.\n *\n * @remarks\n * An SVG `role=\"img\"` named by `label`. `threshold` draws a dashed decision rule, `markers`\n * tick the x axis, `bands` shade x ranges, `onHover` adds a crosshair and the x under it,\n * `onPick` reports the x of a click, and `cursor` draws the bin containing an x chosen\n * elsewhere in the selection colour (`--signal`) — no highlight when it lies outside the\n * domain. Empty data draws an empty frame. For two classes sharing a threshold use\n * {@link ScoreHistogram}.\n */\nexport function Histogram(props: HistogramProps) {\n const {\n label,\n xLabel,\n yLabel,\n unit,\n logY = false,\n variant = \"panel\",\n height = FLUID_DEFAULT_HEIGHT,\n footer,\n className,\n threshold,\n bands,\n markers,\n cursor,\n onHover,\n onPick,\n } = props;\n\n const { counts, domain } =\n props.counts !== undefined ? cleanCounts(props.counts, props.domain) : binValues(props.values, props.bins, props.domain);\n\n const [fluidRef, fluidSize] = useFluidSize(height);\n const size = variant === \"fluid\" ? fluidSize : undefined;\n const plotArea = areaFor(variant, size);\n\n const xScale = linearScale(domain, plotArea.x0, plotArea.x1);\n const top = tallest(counts);\n // Half a count of floor, so a bin of one is a visible bar on the log axis.\n const yScale = logY ? logScale([0.5, top], plotArea.y0, plotArea.y1) : linearScale([0, top], plotArea.y0, plotArea.y1);\n\n const highlighted = binAt(counts.length, domain, cursor);\n const hasHighlight = highlighted !== null && (counts[highlighted] ?? 0) > 0;\n const xTitle = [xLabel, unit ? `(${unit})` : undefined].filter(Boolean).join(\" \") || undefined;\n\n return (\n <Frame\n xScale={xScale}\n yScale={yScale}\n xLabel={xTitle}\n yLabel={yLabel}\n label={label}\n variant={variant}\n className={className}\n size={size}\n figureRef={variant === \"fluid\" ? fluidRef : undefined}\n footer={footer}\n >\n {bands && bands.length > 0 && <Bands bands={bands} xScale={xScale} area={plotArea} />}\n <path\n data-bars=\"\"\n d={barsPath(counts, yScale, plotArea, { skip: hasHighlight ? highlighted : null })}\n fill={seriesColour(0)}\n opacity={0.8}\n />\n {hasHighlight && (\n <path data-cursor-bin={highlighted} d={barsPath(counts, yScale, plotArea, { only: highlighted })} fill=\"var(--signal)\" />\n )}\n <ThresholdRule value={threshold} xScale={xScale} area={plotArea} />\n {markers && markers.length > 0 && <Markers markers={markers} xScale={xScale} area={plotArea} />}\n {(onHover || onPick) && (\n <PlotInteraction xScale={xScale} yScale={yScale} area={plotArea} series={[]} onHover={onHover} onPick={onPick} />\n )}\n </Frame>\n );\n}\n","/**\n * Score distribution by class, with a threshold drawn on it.\n *\n * This is the chart that makes a threshold decision legible: a confusion matrix says how\n * many were wrong, and this says *why* — two distributions that barely separate, or one\n * long normal tail crossing the line.\n *\n * Both classes share one set of bin edges, computed over the union of their scores. Binned\n * separately they would be drawn on different axes and the overlap — the only thing worth\n * looking at — would be an artefact of the binning.\n */\n\nimport { barsPath, tallest } from \"./bars\";\nimport { DEFECT_COLOUR, Frame, NORMAL_COLOUR, areaFor } from \"./Frame\";\nimport { extent, histogram, linearScale } from \"./scale\";\nimport { ThresholdRule } from \"./ThresholdRule\";\n\n// The histogram is always given a whole panel, never a column of a grid.\nconst plotArea = areaFor(\"wide\");\n\n// Green for normal, red for defect — the verdict tokens, named once in `Frame`.\nconst NORMAL_FILL = NORMAL_COLOUR;\nconst DEFECT_FILL = DEFECT_COLOUR;\n\n/** Props for {@link ScoreHistogram}. */\nexport interface ScoreHistogramProps {\n /** Anomaly scores of the samples labelled normal. */\n normal: number[];\n /** Anomaly scores of the samples labelled defective. */\n defect: number[];\n /** The decision threshold, drawn as a dashed vertical rule. Omitted or non-finite: none. */\n threshold?: number;\n /** Number of equal-width bins over the union of both classes' scores. Default 32. */\n bins?: number;\n /** Accessible name of the chart (the SVG's `aria-label`). Required. */\n label: string;\n /** Extra classes for the outer `<figure>`, merged with `cn`. */\n className?: string | undefined;\n}\n\n/**\n * Overlaid histograms of the normal and defect score distributions, with the threshold on\n * them.\n *\n * @remarks\n * Always the `wide` variant. Painted in the verdict tokens (`--normal`, `--defect`); the\n * legend names both classes with their counts, so the chart does not rely on colour alone.\n */\nexport function ScoreHistogram({ normal, defect, threshold, bins = 32, label, className }: ScoreHistogramProps) {\n const domain = extent([...normal, ...defect]);\n const normalBins = histogram(normal, domain, bins);\n const defectBins = histogram(defect, domain, bins);\n const top = tallest(normalBins, defectBins);\n\n const xScale = linearScale(domain, plotArea.x0, plotArea.x1);\n const yScale = linearScale([0, top], plotArea.y0, plotArea.y1);\n return (\n <Frame\n xScale={xScale}\n yScale={yScale}\n xLabel=\"anomaly score\"\n yLabel=\"samples\"\n label={label}\n variant=\"wide\"\n className={className}\n footer={\n <ul className=\"flex flex-wrap items-center gap-x-4 gap-y-1\">\n <li className=\"flex items-center gap-1.5\">\n <span aria-hidden className=\"inline-block h-2 w-3 rounded-sm\" style={{ backgroundColor: NORMAL_FILL, opacity: 0.75 }} />\n <span className=\"font-mono text-xs\">normal ({normal.length})</span>\n </li>\n <li className=\"flex items-center gap-1.5\">\n <span aria-hidden className=\"inline-block h-2 w-3 rounded-sm\" style={{ backgroundColor: DEFECT_FILL, opacity: 0.75 }} />\n <span className=\"font-mono text-xs\">defect ({defect.length})</span>\n </li>\n {threshold !== undefined && <li className=\"font-mono text-xs\">threshold {threshold.toFixed(4)}</li>}\n </ul>\n }\n >\n {/* Normals first and defects over them: the defect bars are the smaller population\n in every realistic split, so drawing them last keeps them from being buried. */}\n <path data-bars=\"\" d={barsPath(normalBins, yScale, plotArea)} fill={NORMAL_FILL} opacity={0.65} />\n <path data-bars=\"\" d={barsPath(defectBins, yScale, plotArea)} fill={DEFECT_FILL} opacity={0.65} />\n\n <ThresholdRule value={threshold} xScale={xScale} area={plotArea} />\n </Frame>\n );\n}\n","/**\n * A 1-D profile chart — intensity or value against arc length along a scan line or a\n * caliper axis.\n *\n * Built on the same `Frame` and `scale.ts` every other chart here uses, so a profile reads\n * as part of the same visual system as a training curve or a score histogram rather than a\n * one-off. The one thing a profile chart needs that a loss curve does not is a way to mark\n * *where along x a decision landed* — a detected edge, a caliper's chosen crossing — as a\n * vertical rule with its own label, independent of the series being plotted.\n */\n\nimport type { ReactNode } from \"react\";\n\nimport { FLUID_DEFAULT_HEIGHT, Frame, Legend, areaFor, seriesColour, useFluidSize } from \"./Frame\";\nimport { Bands, Markers, PlotInteraction, type InteractionProps } from \"./interaction\";\nimport type { Variant } from \"./Frame\";\nimport { extent, linePath, linearScale } from \"./scale\";\nimport { toneColor, type MeasureTone } from \"@vitavision/ui\";\n\n/** One sampled profile of a {@link LineProfile}. */\nexport interface ProfileSeries {\n /** Legend text, and the React key — unique within one chart. */\n name: string;\n /** `x` is arc length along the scan line or caliper axis, in pixels. */\n points: { x: number; y: number }[];\n /** Any CSS colour. Omitted: {@link seriesColour} of the series' index. */\n colour?: string;\n}\n\n/** A detected edge or chosen crossing, drawn as a dashed vertical rule. */\nexport interface EdgeMark {\n /** Position along the same arc-length axis as `ProfileSeries.points[].x`. */\n position: number;\n /** Text drawn above the rule, in the rule's colour. Omitted: no text. */\n label?: string;\n /** The rule's colour, as a `@vitavision/ui` measurement tone. Default `\"signal\"`. */\n tone?: MeasureTone;\n}\n\n/** Props for {@link LineProfile}. */\nexport interface LineProfileProps extends InteractionProps {\n /** The profiles, drawn in order. */\n series: ProfileSeries[];\n /** Detected edge positions, drawn as vertical rules over the series. */\n edges?: EdgeMark[];\n /** Accessible name of the chart (the SVG's `aria-label`). Required. */\n label: string;\n /** x-axis title. Default `\"arc length (px)\"`. */\n xLabel?: string;\n /** y-axis title. Default `\"value\"`. */\n yLabel?: string;\n /** Fixed x domain. Omitted: the extent of every point's `x` and every edge's position. */\n xDomain?: [number, number];\n /** Fixed y domain. Omitted: the extent of every point's `y`. */\n yDomain?: [number, number];\n /** Rendered under the legend, inside the `<figcaption>`. */\n footer?: ReactNode;\n /** Show the legend row when there is more than one series. Default `true`. */\n showLegend?: boolean;\n /** Where the chart is going (see {@link Variant}). Default `\"wide\"`. */\n variant?: Variant;\n /** Extra classes for the outer `<figure>`, merged with `cn`. */\n className?: string | undefined;\n /** For `variant=\"fluid\"`: the chart's height in CSS pixels. Default 200. */\n height?: number | undefined;\n}\n\n/**\n * One or more series against arc length along a scan line or caliper axis, with detected\n * edges as labelled vertical rules.\n *\n * @remarks\n * An SVG `role=\"img\"` named by `label`. The legend appears only for two or more series — a\n * single profile is named by the chart's label. `bands`, `markers`, `cursor`, `onHover` and\n * `onPick` work as on `LineChart`: a caliper's profile can follow the canvas, and a click\n * can pick a position along it.\n */\nexport function LineProfile({\n series,\n edges = [],\n label,\n xLabel = \"arc length (px)\",\n yLabel = \"value\",\n xDomain,\n yDomain,\n footer,\n showLegend = true,\n variant = \"wide\",\n className,\n height = FLUID_DEFAULT_HEIGHT,\n bands,\n markers,\n cursor,\n onHover,\n onPick,\n}: LineProfileProps) {\n const allX = [...series.flatMap((entry) => entry.points.map((point) => point.x)), ...edges.map((edge) => edge.position)];\n const allY = series.flatMap((entry) => entry.points.map((point) => point.y));\n const [fluidRef, fluidSize] = useFluidSize(height);\n const size = variant === \"fluid\" ? fluidSize : undefined;\n const plotArea = areaFor(variant, size);\n\n const xScale = linearScale(xDomain ?? extent(allX), plotArea.x0, plotArea.x1);\n const yScale = linearScale(yDomain ?? extent(allY), plotArea.y0, plotArea.y1);\n\n const coloured = series.map((entry, index) => ({\n ...entry,\n colour: entry.colour ?? seriesColour(index),\n }));\n\n return (\n <Frame\n xScale={xScale}\n yScale={yScale}\n xLabel={xLabel}\n yLabel={yLabel}\n label={label}\n variant={variant}\n className={className}\n size={size}\n figureRef={variant === \"fluid\" ? fluidRef : undefined}\n footer={\n <div className=\"flex flex-col gap-1\">\n {showLegend && series.length > 1 && <Legend items={coloured.map((entry) => ({ label: entry.name, colour: entry.colour }))} />}\n {footer}\n </div>\n }\n >\n {bands && bands.length > 0 && <Bands bands={bands} xScale={xScale} area={plotArea} />}\n {coloured.map((entry) =>\n entry.points.length === 1 ? (\n <circle\n key={entry.name}\n cx={xScale.project(entry.points[0]?.x ?? 0)}\n cy={yScale.project(entry.points[0]?.y ?? 0)}\n r={2.5}\n fill={entry.colour}\n />\n ) : (\n <path\n key={entry.name}\n d={linePath(entry.points, xScale, yScale)}\n fill=\"none\"\n stroke={entry.colour}\n strokeWidth={1.5}\n strokeLinejoin=\"round\"\n vectorEffect=\"non-scaling-stroke\"\n />\n ),\n )}\n\n {edges.map((edge) => {\n const x = xScale.project(edge.position);\n const colour = toneColor(edge.tone, \"signal\");\n return (\n <g key={`${edge.position}-${edge.label ?? \"\"}-${edge.tone ?? \"\"}`}>\n <line x1={x} x2={x} y1={plotArea.y0} y2={plotArea.y1} stroke={colour} strokeWidth={1.25} strokeDasharray=\"3 2\" />\n {edge.label && (\n <text x={x} y={plotArea.y1 - 3} textAnchor=\"middle\" fontSize={9} fill={colour}>\n {edge.label}\n </text>\n )}\n </g>\n );\n })}\n {markers && markers.length > 0 && <Markers markers={markers} xScale={xScale} area={plotArea} />}\n {(onHover || onPick || cursor !== undefined) && (\n <PlotInteraction\n xScale={xScale}\n yScale={yScale}\n area={plotArea}\n series={coloured}\n cursor={cursor}\n onHover={onHover}\n onPick={onPick}\n />\n )}\n </Frame>\n );\n}\n","/**\n * Sequential colour maps for a magnitude: a residual's size, a per-cell\n * error, a confidence, a validity fraction.\n *\n * Only perceptually uniform maps ship, so equal steps in the data look like equal steps.\n * - `viridis` is the default on the chrome.\n * - `cividis` is for when the map alone carries the finding and the reader's colour vision is\n * unknown.\n *\n * A continuous quality is a magnitude even when low values are \"good\": stepping it onto verdict\n * colours (green / amber / red) claims a threshold judgement nobody made.\n *\n * The anchors are matplotlib's maps sampled at nine evenly spaced points. Linear interpolation\n * between them stays within a few units of the full 256-entry tables.\n */\n\n/** The shipped maps. */\nexport type ColormapName = \"viridis\" | \"cividis\";\n\ntype Rgb = readonly [number, number, number];\n\nconst ANCHORS: Record<ColormapName, readonly Rgb[]> = {\n viridis: [\n [68, 1, 84],\n [71, 44, 122],\n [59, 81, 139],\n [44, 113, 142],\n [33, 144, 141],\n [39, 173, 129],\n [92, 200, 99],\n [170, 220, 50],\n [253, 231, 37],\n ],\n cividis: [\n [0, 34, 78],\n [18, 53, 112],\n [59, 73, 108],\n [87, 93, 109],\n [112, 113, 115],\n [138, 135, 121],\n [165, 157, 116],\n [196, 182, 101],\n [254, 232, 56],\n ],\n};\n\n/** The names of the shipped maps. */\nexport const COLORMAPS: readonly ColormapName[] = [\"viridis\", \"cividis\"];\n\n/**\n * The colour of `t` on a map.\n *\n * @param name - The map.\n * @param t - Position in `[0, 1]`; clamped. A non-finite `t` gives the map's low end.\n * @returns A CSS `rgb(r g b)` colour.\n */\nexport function colormap(name: ColormapName, t: number): string {\n const [r, g, b] = colormapRgb(name, t);\n return `rgb(${r} ${g} ${b})`;\n}\n\n/**\n * The colour of `t` on a map, as integer channels.\n *\n * @param name - The map.\n * @param t - Position in `[0, 1]`; clamped.\n * @returns `[r, g, b]`, each 0–255.\n */\nexport function colormapRgb(name: ColormapName, t: number): [number, number, number] {\n const anchors = ANCHORS[name];\n const clamped = Number.isFinite(t) ? Math.min(1, Math.max(0, t)) : 0;\n const scaled = clamped * (anchors.length - 1);\n const i = Math.min(anchors.length - 2, Math.floor(scaled));\n const f = scaled - i;\n const a = anchors[i]!;\n const b = anchors[i + 1]!;\n return [Math.round(a[0] + f * (b[0] - a[0])), Math.round(a[1] + f * (b[1] - a[1])), Math.round(a[2] + f * (b[2] - a[2]))];\n}\n\n/**\n * A value's colour on a map, over a domain.\n *\n * @param name - The map.\n * @param value - The value.\n * @param domain - `[low, high]`: low maps to the map's start. A reversed domain reverses the map.\n * @returns A CSS colour.\n */\nexport function colormapValue(name: ColormapName, value: number, domain: readonly [number, number]): string {\n const [low, high] = domain;\n const span = high - low;\n return colormap(name, span === 0 ? 0 : (value - low) / span);\n}\n\n/**\n * A CSS `linear-gradient` of a map, for a legend bar.\n *\n * @param name - The map.\n * @param direction - The gradient's direction. Defaults to `to right`.\n * @returns A CSS `background-image` value.\n */\nexport function colormapGradient(name: ColormapName, direction = \"to right\"): string {\n const anchors = ANCHORS[name];\n const stops = anchors.map(([r, g, b], i) => `rgb(${r} ${g} ${b}) ${((i / (anchors.length - 1)) * 100).toFixed(1)}%`);\n return `linear-gradient(${direction}, ${stops.join(\", \")})`;\n}\n","/**\n * The scale of a colour map, shown beside the map: every chart or map shows its scale, with units.\n */\n\nimport { cn } from \"@vitavision/ui\";\n\nimport { colormapGradient, type ColormapName } from \"./colormap\";\n\n/** Props of `ColormapLegend`. */\nexport interface ColormapLegendProps {\n /** The map. */\n map: ColormapName;\n /** The values at the two ends, `[low, high]`. */\n domain: readonly [number, number];\n /** The values' unit, written after them (`px`, `%`). */\n unit?: string | undefined;\n /** What the colour encodes, written before the bar (\"Validity\", \"Edge error\"). */\n label: string;\n /** Formats the end values. Defaults to at most 3 significant figures, without trailing zeros. */\n format?: ((value: number) => string) | undefined;\n /** Merged onto the row with `cn`. */\n className?: string | undefined;\n}\n\n/**\n * A gradient bar with its end values and unit, read as one line: \"Edge error 0 [bar] 2.5 px\".\n * The bar is decorative; the label and the end values carry the meaning as text.\n */\nexport function ColormapLegend({\n map,\n domain,\n unit,\n label,\n format = (value) => String(Number(value.toPrecision(3))),\n className,\n}: ColormapLegendProps) {\n const end = (value: number) => (unit ? `${format(value)} ${unit}` : format(value));\n return (\n <div className={cn(\"flex items-center gap-2 text-xs text-fg-muted\", className)} data-colormap={map}>\n <span>{label}</span>\n <span className=\"font-mono tabular-nums\">{end(domain[0])}</span>\n <span aria-hidden className=\"h-2 w-24 rounded-full\" style={{ backgroundImage: colormapGradient(map) }} />\n <span className=\"font-mono tabular-nums\">{end(domain[1])}</span>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkCA,MAAM,sBAAsB;;AAE5B,MAAa,uBAAuB;AAEpC,MAAM,WAAW;CACf,OAAO;EAAE,OAAO;EAAK,QAAQ;CAAI;CACjC,MAAM;EAAE,OAAO;EAAK,QAAQ;CAAI;AAClC;AAEA,MAAM,SAAS;CAAE,MAAM;CAAI,OAAO;CAAI,KAAK;CAAI,QAAQ;AAAG;;;;;;;;;;AAW1D,SAAgB,QAAQ,SAAkB,MAA0C;CAClF,MAAM,EAAE,OAAO,WACb,YAAY,UAAW,QAAQ;EAAE,OAAO;EAAqB,QAAA;CAA6B,IAAK,SAAS;CAC1G,OAAO;EACL,IAAI,OAAO;EACX,IAAI,QAAQ,OAAO;EACnB,IAAI,SAAS,OAAO;EACpB,IAAI,OAAO;EACX;EACA;CACF;AACF;;AAGA,MAAa,WAAW,QAAQ,OAAO;;;;;;;;AASvC,SAAgB,aACd,SAAA,KAC4E;CAC5E,MAAM,CAAC,OAAO,YAAY,SAAS,mBAAmB;CAWtD,OAAO,CAVK,aAAa,YAAgC;EACvD,IAAI,CAAC,SAAS;EACd,MAAM,WAAW,MAAc;GAC7B,IAAI,IAAI,GAAG,SAAS,KAAK,MAAM,CAAC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KAAK,QAAQ,SAAS,KAAM,IAAA,CAAK,QAAQ,CAAC,EAAE,EACrE,CAAC,CAAC,KAAK,IAAI,EAAE;AAC3D;;;;;;;;;;AC5EA,SAAgB,eAAe,EAC7B,KACA,QACA,MACA,OACA,UAAU,UAAU,OAAO,OAAO,MAAM,YAAY,CAAC,CAAC,CAAC,GACvD,aACsB;CACtB,MAAM,OAAO,UAAmB,OAAO,GAAG,OAAO,KAAK,EAAE,GAAG,SAAS,OAAO,KAAK;CAChF,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,iDAAiD,SAAS;EAAG,iBAAe;EAA/F,UAAA;GACE,oBAAC,QAAD,EAAA,UAAO,MAAY,CAAA;GACnB,oBAAC,QAAD;IAAM,WAAU;IAA0B,UAAA,IAAI,OAAO,EAAE;GAAQ,CAAA;GAC/D,oBAAC,QAAD;IAAM,eAAA;IAAY,WAAU;IAAwB,OAAO,EAAE,iBAAiB,iBAAiB,GAAG,EAAE;GAAI,CAAA;GACxG,oBAAC,QAAD;IAAM,WAAU;IAA0B,UAAA,IAAI,OAAO,EAAE;GAAQ,CAAA;EAC5D;;AAET"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["plotArea"],"sources":["../src/Frame.tsx","../src/scale.ts","../src/interpolate.ts","../src/band.ts","../src/interaction.tsx","../src/LineChart.tsx","../src/colormap.ts","../src/ColormapLegend.tsx","../src/scatter.ts","../src/ScatterChart.tsx","../src/BarChart.tsx","../src/bars.ts","../src/ThresholdRule.tsx","../src/Histogram.tsx","../src/ScoreHistogram.tsx","../src/LineProfile.tsx"],"sourcesContent":["/**\n * The plot frame every chart here composes: axes, ticks, grid, labels.\n *\n * Charts are drawn into a fixed `viewBox` and scaled by CSS, so one component works at\n * any panel width without measuring the DOM. The consequence is that font sizes are in\n * viewBox units and therefore scale with the chart: the *same* 10-unit label renders at\n * 9 px in a half-width panel and at 21 px across a full-width one, which looks like two\n * different design systems on one screen.\n *\n * So the viewBox is chosen to roughly match the width the chart will actually be given.\n * `panel` is for the two-column grids, `wide` for a chart that spans a panel on its own.\n * That keeps the scale factor near 1 in both, and it is why callers pick a variant rather\n * than a pixel width — the variant says where the chart is going, not how big to draw it.\n */\n\nimport { useCallback, useState, type ReactNode, type Ref } from \"react\";\n\nimport { cn } from \"@vitavision/ui\";\n\nimport type { Scale } from \"./scale\";\n\n/**\n * Where a chart is going: `panel` (a 480×280 viewBox) for one column of a two-column grid,\n * `wide` (960×320) for a chart that spans a panel on its own, or `fluid` to take its\n * container's width at a fixed height, with text at its true size at any width.\n *\n * @remarks\n * Pick it by placement, not by pixel width — it keeps the chart's text at the same rendered\n * size as its neighbours'. `fluid` measures its container (a `ResizeObserver`), for a chart\n * in a resizable inspector or under a canvas.\n */\nexport type Variant = \"panel\" | \"wide\" | \"fluid\";\n\n/** The width a `fluid` chart assumes before it has been measured, and on the server. */\nconst FLUID_INITIAL_WIDTH = 480;\n/** A `fluid` chart's default height, in CSS pixels. */\nexport const FLUID_DEFAULT_HEIGHT = 200;\n\nconst GEOMETRY = {\n panel: { width: 480, height: 280 },\n wide: { width: 960, height: 320 },\n} as const;\n\nconst MARGIN = { left: 56, right: 12, top: 12, bottom: 34 } as const;\n\n/**\n * The drawable rectangle for one variant, in that variant's viewBox units.\n *\n * @param variant - Which viewBox the chart is drawn in.\n * @param size - For `fluid`: the measured size in CSS pixels (see {@link useFluidSize}).\n * @returns The plot area's edges — `x0`/`x1` left to right, `y0` the bottom and `y1` the top\n * (SVG y grows downwards) — and the whole viewBox's `width`/`height`. Build scales over\n * `[x0, x1]` and `[y0, y1]`.\n */\nexport function areaFor(variant: Variant, size?: { width: number; height: number }) {\n const { width, height } =\n variant === \"fluid\" ? (size ?? { width: FLUID_INITIAL_WIDTH, height: FLUID_DEFAULT_HEIGHT }) : GEOMETRY[variant];\n return {\n x0: MARGIN.left,\n x1: width - MARGIN.right,\n y0: height - MARGIN.bottom,\n y1: MARGIN.top,\n width,\n height,\n };\n}\n\n/** The default geometry, for callers that do not care which variant they are in. */\nexport const plotArea = areaFor(\"panel\");\n\n/**\n * The size of a `fluid` chart: its container's width, measured, at `height`.\n *\n * @param height - The chart's height in CSS pixels. Defaults to {@link FLUID_DEFAULT_HEIGHT}.\n * @returns `[ref, size]`. Attach `ref` to the element whose width the chart takes (the\n * `Frame`'s `figureRef`). The size is a 480 px-wide default until the first measure.\n */\nexport function useFluidSize(\n height: number = FLUID_DEFAULT_HEIGHT,\n): [(element: HTMLElement | null) => void, { width: number; height: number }] {\n const [width, setWidth] = useState(FLUID_INITIAL_WIDTH);\n const ref = useCallback((element: HTMLElement | null) => {\n if (!element) return;\n const measure = (w: number) => {\n if (w > 0) setWidth(Math.round(w));\n };\n measure(element.getBoundingClientRect().width);\n const observer = new ResizeObserver((entries) => measure(entries[0]?.contentRect.width ?? 0));\n observer.observe(element);\n return () => observer.disconnect();\n }, []);\n return [ref, { width, height }];\n}\n\n/** Held at the two ends of the neutral ramp, matching the design system's chrome colours. */\nconst AXIS = \"currentColor\";\n\n/** Props for {@link Frame}. */\nexport interface FrameProps {\n /** The horizontal scale, built over this variant's `x0`…`x1` (see {@link areaFor}). */\n xScale: Scale;\n /** The vertical scale, built over this variant's `y0`…`y1` (see {@link areaFor}). */\n yScale: Scale;\n /** Axis title under the x axis. Omitted: no title. */\n xLabel?: string | undefined;\n /** Axis title beside the y axis, rotated. Omitted: no title. */\n yLabel?: string | undefined;\n /** Rough number of x ticks to ask the scale for. Default 5. */\n xTicks?: number;\n /** Rough number of y ticks to ask the scale for. Default 4. */\n yTicks?: number;\n /** Writes an x tick's label from its value (a date, a unit). Omitted: the scale's own label. */\n xFormat?: ((value: number) => string) | undefined;\n /** Drawn inside the plot area, above the grid and below nothing. */\n children?: ReactNode;\n /** Accessible name — every chart must have one; it is what the tests query on. */\n label: string;\n /** Rendered under the plot: a legend, a caption, a truncation note. */\n footer?: ReactNode;\n /** Where this chart is going, so its text renders at the same size as its neighbours. */\n variant?: Variant;\n /** Extra classes for the outer `<figure>`, merged with `cn`. */\n className?: string | undefined;\n /** For `fluid`: the measured size (see {@link useFluidSize}). */\n size?: { width: number; height: number } | undefined;\n /** A ref to the outer `<figure>`, e.g. {@link useFluidSize}'s measuring ref. */\n figureRef?: Ref<HTMLElement> | undefined;\n}\n\n/**\n * The plot shell every chart here composes: grid, ticks, axes, axis titles, a footer.\n *\n * @remarks\n * Renders a `<figure>` holding an SVG with `role=\"img\"` named by `label`, and the `footer`\n * as its `<figcaption>`. `children` are drawn in viewBox units over the grid.\n */\nexport function Frame({\n xScale,\n yScale,\n xLabel,\n yLabel,\n xTicks = 5,\n yTicks = 4,\n xFormat,\n children,\n label,\n footer,\n variant = \"panel\",\n className,\n size,\n figureRef,\n}: FrameProps) {\n const horizontal = xScale.ticks(xTicks);\n const vertical = yScale.ticks(yTicks);\n const plotArea = areaFor(variant, size);\n const PLOT = { width: plotArea.width, height: plotArea.height };\n\n return (\n <figure ref={figureRef} className={cn(\"flex flex-col gap-1 text-fg-muted\", className)}>\n <svg role=\"img\" aria-label={label} viewBox={`0 0 ${PLOT.width} ${PLOT.height}`} className=\"w-full\">\n {vertical.map((tick) => {\n const y = yScale.project(tick.value);\n return (\n <g key={`y-${tick.value}`}>\n <line x1={plotArea.x0} x2={plotArea.x1} y1={y} y2={y} stroke={AXIS} strokeWidth={0.5} opacity={0.25} />\n <text x={plotArea.x0 - 6} y={y + 3.5} textAnchor=\"end\" fontSize={10} fill={AXIS}>\n {tick.label}\n </text>\n </g>\n );\n })}\n\n {horizontal.map((tick) => {\n const x = xScale.project(tick.value);\n return (\n <g key={`x-${tick.value}`}>\n <line x1={x} x2={x} y1={plotArea.y0} y2={plotArea.y1} stroke={AXIS} strokeWidth={0.5} opacity={0.15} />\n <text x={x} y={plotArea.y0 + 14} textAnchor=\"middle\" fontSize={10} fill={AXIS}>\n {xFormat ? xFormat(tick.value) : tick.label}\n </text>\n </g>\n );\n })}\n\n <line x1={plotArea.x0} x2={plotArea.x1} y1={plotArea.y0} y2={plotArea.y0} stroke={AXIS} strokeWidth={1} opacity={0.6} />\n <line x1={plotArea.x0} x2={plotArea.x0} y1={plotArea.y0} y2={plotArea.y1} stroke={AXIS} strokeWidth={1} opacity={0.6} />\n\n {children}\n\n {xLabel && (\n <text x={(plotArea.x0 + plotArea.x1) / 2} y={PLOT.height - 2} textAnchor=\"middle\" fontSize={10} fill={AXIS}>\n {xLabel}\n </text>\n )}\n {yLabel && (\n <text transform={`translate(10 ${(plotArea.y0 + plotArea.y1) / 2}) rotate(-90)`} textAnchor=\"middle\" fontSize={10} fill={AXIS}>\n {yLabel}\n </text>\n )}\n </svg>\n {footer && <figcaption className=\"text-xs\">{footer}</figcaption>}\n </figure>\n );\n}\n\n/** One entry of a {@link Legend}. */\nexport interface LegendItem {\n /** The series name, rendered as text — it is what a screen reader announces. */\n label: string;\n /** Any CSS colour: a `var(--series-n)` from {@link seriesColour}, or a verdict token. */\n colour: string;\n /** The series has an error band: its swatch shows one, and this text follows the name (`±1σ`). */\n band?: string | undefined;\n}\n\n/** Props for {@link Legend}. */\nexport interface LegendProps {\n /** Entries, in the order the series were drawn. */\n items: LegendItem[];\n /** Extra classes for the `<ul>`, merged with `cn`. */\n className?: string | undefined;\n}\n\n/**\n * A legend row. Kept beside the frame rather than inside the SVG so the swatches are real\n * text and CSS rather than a second typography in viewBox units.\n *\n * @remarks\n * The swatches are `aria-hidden`; each series is identified by its name, never by colour\n * alone.\n */\nexport function Legend({ items, className }: LegendProps) {\n return (\n <ul className={cn(\"flex flex-wrap items-center gap-x-4 gap-y-1\", className)}>\n {items.map((item) => (\n <li key={item.label} className=\"flex items-center gap-1.5\">\n {item.band === undefined ? (\n <span aria-hidden className=\"inline-block h-0.5 w-4 rounded-full\" style={{ backgroundColor: item.colour }} />\n ) : (\n <span aria-hidden data-band-swatch=\"\" className=\"relative inline-block h-2.5 w-4\">\n <span className=\"absolute inset-0 rounded-sm opacity-20\" style={{ backgroundColor: item.colour }} />\n <span className=\"absolute inset-x-0 top-1/2 h-0.5 -translate-y-1/2 rounded-full\" style={{ backgroundColor: item.colour }} />\n </span>\n )}\n <span className=\"font-mono text-xs\">{item.label}</span>\n {item.band !== undefined && <span className=\"font-mono text-xs text-fg-subtle\">{item.band}</span>}\n </li>\n ))}\n </ul>\n );\n}\n\n/**\n * The shared categorical series palette, as CSS paint values: `var(--series-1)` …\n * `var(--series-6)`.\n *\n * @remarks\n * The colours themselves are tokens in `@vitavision/charts/styles.css`, defined for both\n * themes, so that stylesheet must be imported after `@vitavision/ui/styles.css`. The chrome\n * carries no saturation, which makes this the one place a chart is allowed to be loud.\n *\n * Each slot keeps its hue family across the themes — cyan, orange, violet, blue, pink, then\n * a neutral grey as the sixth — and only its lightness changes, so every colour holds 3:1\n * against the panel in both. The six stay distinguishable under simulated protanopia,\n * deuteranopia and tritanopia, and none of them is a verdict colour (`--normal`,\n * `--defect`, `--warn`): a series is never read as a verdict.\n *\n * Before 0.6 these were fixed hex strings; the names are unchanged.\n */\nexport const SERIES_COLOURS = [\n \"var(--series-1)\",\n \"var(--series-2)\",\n \"var(--series-3)\",\n \"var(--series-4)\",\n \"var(--series-5)\",\n \"var(--series-6)\",\n] as const;\n\n/**\n * The paint for outcomes judged normal — `var(--normal)`, the design system's verdict token.\n *\n * @remarks\n * Exported so a histogram and any caught/missed bars share one green rather than each\n * restating it: a green that means \"normal\" has to be one green. Before 0.6 this was a\n * fixed hex string.\n */\nexport const NORMAL_COLOUR = \"var(--normal)\";\n\n/**\n * The paint for outcomes judged defective — `var(--defect)`, the design system's verdict\n * token.\n *\n * @remarks\n * The partner of {@link NORMAL_COLOUR}. Before 0.6 this was a fixed hex string.\n */\nexport const DEFECT_COLOUR = \"var(--defect)\";\n\n/**\n * The series colour for the `index`-th series, cycling through {@link SERIES_COLOURS}.\n *\n * @param index - Zero-based series index. Negative or non-integer indices fall back to the\n * neutral `var(--fg-muted)`.\n * @returns A CSS paint value, usable as an SVG `fill`/`stroke` or a CSS `color`.\n */\nexport function seriesColour(index: number): string {\n return SERIES_COLOURS[index % SERIES_COLOURS.length] ?? \"var(--fg-muted)\";\n}\n","/**\n * The arithmetic behind every chart: domains, ticks, and the map from a value to a pixel.\n *\n * Hand-rolled SVG rather than a charting library: the chart types this design system needs\n * are few and simple, and a library that lags the React and Tailwind versions the apps\n * are deliberately on would mean either downgrading a consumer or isolating a laggard — a\n * cost that outweighs a few hundred lines of scale maths.\n *\n * Everything here is pure. That is the point: it is the part worth unit-testing, and it\n * leaves the components themselves as thin as an SVG element list.\n */\n\n/** A tick's position in domain units, with the label to draw beside it. */\nexport interface Tick {\n /** Where the tick sits, in domain units — pass it to {@link Scale.project}. */\n value: number;\n /** The text to draw beside it, formatted by {@link formatTick}. */\n label: string;\n}\n\n/**\n * A map from a numeric domain onto a pixel range, with the ticks to label it.\n *\n * @remarks\n * Built by {@link linearScale} or {@link logScale}. `project` is not clamped: a value\n * outside the domain lands outside the range.\n */\nexport interface Scale {\n /** Domain, after padding and after any log transform's guard. */\n domain: [number, number];\n /** Map one domain value onto the pixel range this scale was built for. */\n project: (value: number) => number;\n /** The inverse of `project`: the domain value at a pixel. Not clamped. */\n invert: (pixel: number) => number;\n /**\n * Ticks inside the domain, in ascending order.\n *\n * @param count - Roughly how many ticks to aim for (default 5). The result may have a\n * few more or fewer: steps are \"nice\" (see {@link niceStep}), or whole decades on a log\n * scale.\n */\n ticks: (count?: number) => Tick[];\n}\n\n/** Smallest value a log scale will accept, so a zero loss cannot become `-Infinity`. */\nconst LOG_FLOOR = 1e-12;\n\nconst TICK_STEPS = [1, 2, 2.5, 5, 10];\n\n/** Past this a label is noise; anything finer is shown as an exponent instead. */\nconst MAX_DECIMALS = 6;\n\n/**\n * A \"nice\" step at or above `rough` — one of 1, 2, 2.5 or 5 times a power of ten.\n *\n * Axis labels a reader can hold in their head are the whole reason: 0.25 / 0.50 / 0.75\n * rather than 0.237 / 0.474 / 0.711.\n */\nexport function niceStep(rough: number): number {\n if (!Number.isFinite(rough) || rough <= 0) return 1;\n const magnitude = 10 ** Math.floor(Math.log10(rough));\n const normalized = rough / magnitude;\n const step = TICK_STEPS.find((candidate) => candidate >= normalized - 1e-9) ?? 10;\n return step * magnitude;\n}\n\n/**\n * How many decimals a label needs so that neighbouring ticks do not print identically.\n *\n * Derived from the step rather than fixed, because one chart here might be a loss around\n * 1e-4 and another a residual in whole pixels. Enough decimals to print the *step* exactly\n * is the right rule, and `ceil(-log10(step))` is not it: a 0.25 step gets one decimal that\n * way, and the axis reads 0.3 / 0.5 / 0.8 — three labels for four evenly spaced ticks.\n */\nfunction decimalsFor(step: number): number {\n if (!Number.isFinite(step) || step <= 0) return 0;\n for (let decimals = 0; decimals < MAX_DECIMALS; decimals += 1) {\n if (Math.abs(Number(step.toFixed(decimals)) - step) < step * 1e-6) return decimals;\n }\n return MAX_DECIMALS;\n}\n\n/**\n * The label for one tick: as many decimals as the step needs, or an exponent for a\n * magnitude below 1e-3 or from 1e6 upwards.\n *\n * @param value - The tick's value.\n * @param step - The spacing between neighbouring ticks; it decides the decimals.\n * @returns The label, or `\"\"` for a non-finite value.\n */\nexport function formatTick(value: number, step: number): string {\n if (!Number.isFinite(value)) return \"\";\n const magnitude = Math.abs(value);\n // Outside the range where a decimal reads better than an exponent. A loss of 3.2e-5 is\n // legible; 0.000032 is a row of zeroes the eye has to count.\n if (magnitude !== 0 && (magnitude < 1e-3 || magnitude >= 1e6)) {\n return value.toExponential(1);\n }\n return value.toFixed(decimalsFor(step));\n}\n\n/**\n * Widen a degenerate domain into one that can be drawn.\n *\n * A single-point series, or a constant one, has `min === max`. Left alone that divides by\n * zero and the line vanishes; widened, the point sits in the middle of a sensible axis,\n * which is what watching the first moments of a training run, or a profile with one sample\n * so far, should look like.\n */\nexport function padDomain(min: number, max: number): [number, number] {\n if (!Number.isFinite(min) || !Number.isFinite(max)) return [0, 1];\n if (min === max) {\n const margin = Math.abs(min) > 0 ? Math.abs(min) * 0.1 : 1;\n return [min - margin, max + margin];\n }\n return [min, max];\n}\n\n/**\n * The `[min, max]` of the finite values, ignoring `NaN` and infinities.\n *\n * @returns `[0, 1]` when there is no finite value, so an empty series still has an axis.\n */\nexport function extent(values: readonly number[]): [number, number] {\n const finite = values.filter((value) => Number.isFinite(value));\n if (finite.length === 0) return [0, 1];\n return [Math.min(...finite), Math.max(...finite)];\n}\n\n/** A linear scale from `domain` onto `[rangeStart, rangeEnd]` pixels. */\nexport function linearScale(domain: [number, number], rangeStart: number, rangeEnd: number): Scale {\n const [low, high] = padDomain(domain[0], domain[1]);\n const span = high - low;\n return {\n domain: [low, high],\n project: (value) => rangeStart + ((value - low) / span) * (rangeEnd - rangeStart),\n invert: (pixel) => low + ((pixel - rangeStart) / (rangeEnd - rangeStart)) * span,\n ticks: (count = 5) => {\n const step = niceStep(span / Math.max(1, count));\n const first = Math.ceil(low / step) * step;\n const ticks: Tick[] = [];\n for (let value = first; value <= high + step * 1e-9; value += step) {\n // Re-derived from the step index rather than accumulated, so floating-point drift\n // cannot turn 0.30000000000000004 into a label.\n const exact = Math.round(value / step) * step;\n ticks.push({ value: exact, label: formatTick(exact, step) });\n }\n return ticks;\n },\n };\n}\n\n/**\n * A base-10 log scale, for series that span decades.\n *\n * A loss curve is the canonical case: three terms that span decades and start far apart\n * are a flat line along the bottom for two of the three on a linear axis. Non-positive\n * values are clamped to `LOG_FLOOR` rather than dropped: a value that reaches exactly zero\n * is a real observation, and a gap in the line would read as missing data.\n */\nexport function logScale(domain: [number, number], rangeStart: number, rangeEnd: number): Scale {\n const low = Math.log10(Math.max(domain[0], LOG_FLOOR));\n const high = Math.log10(Math.max(domain[1], LOG_FLOOR));\n const [paddedLow, paddedHigh] = padDomain(low, high);\n const span = paddedHigh - paddedLow;\n\n return {\n domain: [10 ** paddedLow, 10 ** paddedHigh],\n project: (value) => {\n const transformed = Math.log10(Math.max(value, LOG_FLOOR));\n return rangeStart + ((transformed - paddedLow) / span) * (rangeEnd - rangeStart);\n },\n invert: (pixel) => 10 ** (paddedLow + ((pixel - rangeStart) / (rangeEnd - rangeStart)) * span),\n ticks: (count = 5) => {\n // One tick per decade, thinned when the range covers more decades than fit.\n const stride = Math.max(1, Math.ceil(span / Math.max(1, count)));\n const ticks: Tick[] = [];\n for (let exponent = Math.ceil(paddedLow); exponent <= paddedHigh + 1e-9; exponent += stride) {\n const value = 10 ** exponent;\n ticks.push({ value, label: formatTick(value, value) });\n }\n return ticks;\n },\n };\n}\n\n/** An SVG `d` attribute through the projected points, skipping non-finite ones. */\nexport function linePath(points: readonly { x: number; y: number }[], xScale: Scale, yScale: Scale): string {\n const commands: string[] = [];\n let pen = \"M\";\n for (const point of points) {\n if (!Number.isFinite(point.x) || !Number.isFinite(point.y)) {\n // Lift the pen rather than bridging the gap: a straight line across missing data\n // is an assertion nobody made.\n pen = \"M\";\n continue;\n }\n commands.push(`${pen}${xScale.project(point.x).toFixed(2)} ${yScale.project(point.y).toFixed(2)}`);\n pen = \"L\";\n }\n return commands.join(\" \");\n}\n\n/**\n * Bin values into `count` equal-width buckets over their own extent.\n *\n * Used for the score histogram, where the two classes must share one set of edges or the\n * bars cannot be compared. Callers pass the shared domain in for exactly that reason.\n */\nexport function histogram(values: readonly number[], domain: [number, number], count: number): number[] {\n const bins = new Array<number>(Math.max(1, count)).fill(0);\n const [low, high] = domain;\n const span = high - low;\n if (span <= 0) {\n bins[0] = values.length;\n return bins;\n }\n for (const value of values) {\n if (!Number.isFinite(value)) continue;\n const index = Math.min(bins.length - 1, Math.floor(((value - low) / span) * bins.length));\n if (index >= 0) bins[index] = (bins[index] ?? 0) + 1;\n }\n return bins;\n}\n","/** Reading a series between its points. */\n\n/**\n * A series' value at `x`, linearly interpolated between the points either side, or `null`\n * outside its range or across a gap.\n *\n * @param points - The series, in ascending `x`.\n * @param x - Where.\n * @returns The interpolated value, or `null`.\n */\nexport function seriesValueAt(points: readonly { x: number; y: number }[], x: number): number | null {\n if (points.length === 0) return null;\n if (points.length === 1) return points[0]!.x === x ? points[0]!.y : null;\n let lo = 0;\n let hi = points.length - 1;\n if (x < points[lo]!.x || x > points[hi]!.x) return null;\n while (hi - lo > 1) {\n const mid = (lo + hi) >> 1;\n if (points[mid]!.x <= x) lo = mid;\n else hi = mid;\n }\n const a = points[lo]!;\n const b = points[hi]!;\n if (!Number.isFinite(a.y) || !Number.isFinite(b.y)) return null;\n if (b.x === a.x) return a.y;\n return a.y + ((x - a.x) / (b.x - a.x)) * (b.y - a.y);\n}\n","/**\n * The arithmetic of a series' error band: the ribbon between a lower and an upper value at every\n * point of a series, its outline, and its value at an x between two points. Pure, so the geometry\n * is testable apart from the SVG.\n */\n\nimport { seriesValueAt } from \"./interpolate\";\nimport type { Scale } from \"./scale\";\n\n/** A series' band: the values either side of its line, one per point, by index. */\nexport interface SeriesBand {\n /** The lower edge at each point. A non-finite value breaks the band there. */\n lower: readonly number[];\n /** The upper edge at each point. */\n upper: readonly number[];\n /** What the legend says after the series' name. Default `\"± band\"`. */\n label?: string | undefined;\n}\n\n/** The band's edges at point `index`, ordered low to high, or `null` where either is missing or non-finite. */\nexport function bandBoundsAt(band: Pick<SeriesBand, \"lower\" | \"upper\">, index: number): [number, number] | null {\n const a = band.lower[index];\n const b = band.upper[index];\n if (a === undefined || b === undefined || !Number.isFinite(a) || !Number.isFinite(b)) return null;\n return a <= b ? [a, b] : [b, a];\n}\n\n/**\n * The outline of a band as an SVG path `d`: the upper edge left to right and the lower edge back,\n * closed, once for every run of points whose x and both edges are finite. A run of one point has\n * no area and draws nothing; a gap ends the run, so the band is not bridged across missing data.\n *\n * @param points - The series' points, in draw order.\n * @param band - The edges, by point index. Missing entries count as gaps.\n * @param xScale - The horizontal scale.\n * @param yScale - The vertical scale.\n * @returns The path, or `\"\"` when there is nothing to fill.\n */\nexport function bandPath(\n points: readonly { x: number; y: number }[],\n band: Pick<SeriesBand, \"lower\" | \"upper\">,\n xScale: Scale,\n yScale: Scale,\n): string {\n const runs: { x: number; lo: number; hi: number }[][] = [];\n let run: { x: number; lo: number; hi: number }[] = [];\n const close = () => {\n if (run.length > 1) runs.push(run);\n run = [];\n };\n points.forEach((point, index) => {\n const bounds = bandBoundsAt(band, index);\n if (!Number.isFinite(point.x) || bounds === null) {\n close();\n return;\n }\n run.push({ x: xScale.project(point.x), lo: yScale.project(bounds[0]), hi: yScale.project(bounds[1]) });\n });\n close();\n const f = (n: number) => n.toFixed(2);\n return runs\n .map((r) => {\n const top = r.map((p, i) => `${i === 0 ? \"M\" : \"L\"}${f(p.x)} ${f(p.hi)}`);\n const bottom = r.map((p) => `L${f(p.x)} ${f(p.lo)}`).reverse();\n return `${[...top, ...bottom].join(\" \")} Z`;\n })\n .join(\" \");\n}\n\n/** Every finite edge of a band, for the chart's y extent. */\nexport function bandValues(band: Pick<SeriesBand, \"lower\" | \"upper\">): number[] {\n return [...band.lower, ...band.upper].filter(Number.isFinite);\n}\n\n/** A series' band at `x`, interpolated like {@link seriesValueAt}: `[lower, upper]`, or `null` outside the series or across a gap. */\nexport function bandValueAt(\n points: readonly { x: number; y: number }[],\n band: Pick<SeriesBand, \"lower\" | \"upper\">,\n x: number,\n): [number, number] | null {\n const edge = (pick: 0 | 1) =>\n seriesValueAt(\n points.map((point, index) => ({ x: point.x, y: bandBoundsAt(band, index)?.[pick] ?? Number.NaN })),\n x,\n );\n const lo = edge(0);\n const hi = edge(1);\n return lo === null || hi === null ? null : [lo, hi];\n}\n\n/**\n * A value with its band as text: `3.2 ± 0.4` when the band is symmetric about the value, else\n * `3.2 [2.8, 3.9]`.\n *\n * @param value - The series' value.\n * @param bounds - The band's `[lower, upper]` there.\n * @param format - Formats one number.\n */\nexport function formatWithBand(value: number, bounds: readonly [number, number], format: (n: number) => string): string {\n const [lo, hi] = bounds;\n const up = hi - value;\n const down = value - lo;\n const symmetric = Math.abs(up - down) <= 1e-6 * Math.max(Math.abs(up), Math.abs(down), Number.MIN_VALUE);\n return symmetric ? `${format(value)} ± ${format(up)}` : `${format(value)} [${format(lo)}, ${format(hi)}]`;\n}\n","/**\n * What `LineChart` and `LineProfile` share beyond the frame:\n * - x ranges and positions marked on the plot (`bands`, `markers`);\n * - a pointer that reads the plot back (hover readout, click to pick);\n * - a cursor the app can drive from elsewhere, e.g. the canvas a profile was sampled on.\n */\n\nimport { useState } from \"react\";\n\nimport { toneColor, type MeasureTone } from \"@vitavision/ui\";\n\nimport { seriesValueAt } from \"./interpolate\";\nimport { bandValueAt, formatWithBand, type SeriesBand } from \"./band\";\nimport type { Scale } from \"./scale\";\n\n/** An x range marked on the plot: a gap, a stretch out of tolerance, a region of interest. */\nexport interface Band {\n /** Start of the range, in x domain units. */\n from: number;\n /** End of the range. */\n to: number;\n /** Its colour. Default `\"muted\"`. */\n tone?: MeasureTone | undefined;\n /** Text at the top of the band. */\n label?: string | undefined;\n}\n\n/** A position marked on the x axis with a short tick: a station, a sample, a frame. */\nexport interface Marker {\n /** Where, in x domain units. */\n position: number;\n /** Its colour. Default `\"muted\"`. */\n tone?: MeasureTone | undefined;\n /** Shown as the tick's tooltip (`<title>`). */\n label?: string | undefined;\n}\n\n/** A series as the readout sees it. */\nexport interface ReadoutSeries {\n /** Its name. */\n name: string;\n /** Its points. */\n points: readonly { x: number; y: number }[];\n /** Its colour. */\n colour: string;\n /** Its error band: the readout then reads `value ± half-width`, or the value with its range. */\n band?: SeriesBand | undefined;\n}\n\n/** The props `LineChart` and `LineProfile` share for interaction and marking. */\nexport interface InteractionProps {\n /** x ranges drawn behind the series. */\n bands?: readonly Band[] | undefined;\n /** Positions ticked on the x axis. */\n markers?: readonly Marker[] | undefined;\n /** An x position drawn as a vertical rule, from outside the chart (e.g. a canvas hover). */\n cursor?: number | null | undefined;\n /** Called with the x under the pointer (in domain units, clamped to the domain), or `null` on leaving. */\n onHover?: ((x: number | null) => void) | undefined;\n /** Called with the x under a click. Makes the plot area a pointer target. */\n onPick?: ((x: number) => void) | undefined;\n}\n\n/** Plot-area edges in viewBox units, as `areaFor` returns them (`y0` is the bottom). */\nexport interface PlotArea {\n /** Left edge. */\n x0: number;\n /** Right edge. */\n x1: number;\n /** Bottom edge. */\n y0: number;\n /** Top edge. */\n y1: number;\n}\n\nexport { seriesValueAt };\n\n/** The ranges behind the series. */\nexport function Bands({ bands, xScale, area }: { bands: readonly Band[]; xScale: Scale; area: PlotArea }) {\n return (\n <g data-bands=\"\">\n {bands.map((band) => {\n const a = clamp(xScale.project(Math.min(band.from, band.to)), area.x0, area.x1);\n const b = clamp(xScale.project(Math.max(band.from, band.to)), area.x0, area.x1);\n const colour = toneColor(band.tone, \"muted\");\n return (\n <g key={`${band.from}-${band.to}-${band.label ?? \"\"}`}>\n <rect x={a} y={area.y1} width={Math.max(1, b - a)} height={area.y0 - area.y1} fill={colour} opacity={0.14} />\n {band.label && (\n <text x={(a + b) / 2} y={area.y1 + 10} textAnchor=\"middle\" fontSize={9} fill={colour}>\n {band.label}\n </text>\n )}\n </g>\n );\n })}\n </g>\n );\n}\n\n/** The ticks on the x axis. */\nexport function Markers({ markers, xScale, area }: { markers: readonly Marker[]; xScale: Scale; area: PlotArea }) {\n return (\n <g data-markers=\"\">\n {markers.map((marker) => {\n const x = xScale.project(marker.position);\n if (x < area.x0 - 0.5 || x > area.x1 + 0.5) return null;\n return (\n <line\n key={`${marker.position}-${marker.label ?? \"\"}`}\n x1={x}\n x2={x}\n y1={area.y0}\n y2={area.y0 - 6}\n stroke={toneColor(marker.tone, \"muted\")}\n strokeWidth={1.5}\n >\n {marker.label && <title>{marker.label}</title>}\n </line>\n );\n })}\n </g>\n );\n}\n\n/**\n * The pointer layer over the plot area: a crosshair and a value readout while hovering, the\n * external `cursor` otherwise, and clicks as picks.\n */\nexport function PlotInteraction({\n xScale,\n yScale,\n area,\n series,\n cursor,\n onHover,\n onPick,\n format = (value: number) => (Math.abs(value) >= 100 ? value.toFixed(0) : value.toPrecision(3)),\n xFormat,\n}: {\n xScale: Scale;\n yScale: Scale;\n area: PlotArea;\n series: readonly ReadoutSeries[];\n cursor?: number | null | undefined;\n onHover?: ((x: number | null) => void) | undefined;\n onPick?: ((x: number) => void) | undefined;\n format?: (value: number) => string;\n /** Formats the x in the readout. Default: `format`. */\n xFormat?: ((value: number) => string) | undefined;\n}) {\n const [hover, setHover] = useState<number | null>(null);\n const interactive = onHover !== undefined || onPick !== undefined;\n\n const xAt = (event: { clientX: number; clientY: number; currentTarget: SVGRectElement }): number => {\n const svg = event.currentTarget.ownerSVGElement;\n const ctm = svg?.getScreenCTM();\n let local = event.clientX;\n if (svg && ctm) {\n const point = svg.createSVGPoint();\n point.x = event.clientX;\n point.y = event.clientY;\n local = point.matrixTransform(ctm.inverse()).x;\n }\n const [low, high] = xScale.domain;\n return clamp(xScale.invert(local), Math.min(low, high), Math.max(low, high));\n };\n\n const shown = hover ?? cursor ?? null;\n const x = shown === null ? null : xScale.project(shown);\n const readout =\n hover === null\n ? []\n : series.flatMap((entry) => {\n const y = seriesValueAt(entry.points, hover);\n if (y === null) return [];\n const bounds = entry.band ? bandValueAt(entry.points, entry.band, hover) : null;\n return [{ name: entry.name, colour: entry.colour, y, bounds }];\n });\n\n return (\n <g data-interaction=\"\">\n {x !== null && x >= area.x0 - 0.5 && x <= area.x1 + 0.5 && (\n <line\n data-crosshair=\"\"\n x1={x}\n x2={x}\n y1={area.y0}\n y2={area.y1}\n stroke=\"currentColor\"\n strokeWidth={1}\n opacity={hover === null ? 0.6 : 0.9}\n />\n )}\n {readout.map((entry) => (\n <circle\n key={entry.name}\n cx={x ?? 0}\n cy={yScale.project(entry.y)}\n r={3}\n fill={entry.colour}\n stroke=\"var(--surface)\"\n strokeWidth={1}\n />\n ))}\n {hover !== null && x !== null && (\n <text\n data-readout=\"\"\n x={x > (area.x0 + area.x1) / 2 ? x - 6 : x + 6}\n y={area.y1 + 10}\n textAnchor={x > (area.x0 + area.x1) / 2 ? \"end\" : \"start\"}\n fontSize={10}\n fill=\"currentColor\"\n >\n {[\n (xFormat ?? format)(hover),\n ...readout.map((entry) => `${entry.name} ${entry.bounds ? formatWithBand(entry.y, entry.bounds, format) : format(entry.y)}`),\n ].join(\" · \")}\n </text>\n )}\n {interactive && (\n <rect\n data-plot-target=\"\"\n x={area.x0}\n y={area.y1}\n width={area.x1 - area.x0}\n height={area.y0 - area.y1}\n fill=\"transparent\"\n style={{ cursor: onPick ? \"pointer\" : \"crosshair\" }}\n onPointerMove={(event) => {\n const value = xAt(event);\n setHover(value);\n onHover?.(value);\n }}\n onPointerLeave={() => {\n setHover(null);\n onHover?.(null);\n }}\n onClick={(event) => onPick?.(xAt(event))}\n />\n )}\n </g>\n );\n}\n\nfunction clamp(value: number, low: number, high: number): number {\n return Math.min(high, Math.max(low, value));\n}\n","/**\n * Multi-series line chart — training curves, or any series plotted over a shared axis.\n *\n * A series with no points draws nothing but still claims its legend entry, so a term that\n * has not reported yet is visibly pending rather than silently absent. A series with one\n * point draws a dot: at the start of a run that is genuinely all there is, and an empty\n * chart would read as \"nothing is happening\".\n */\n\nimport type { ReactNode } from \"react\";\n\nimport { bandPath, bandValues, type SeriesBand } from \"./band\";\nimport { FLUID_DEFAULT_HEIGHT, Frame, Legend, areaFor, seriesColour, useFluidSize } from \"./Frame\";\nimport { Bands, Markers, PlotInteraction, type InteractionProps } from \"./interaction\";\nimport type { Variant } from \"./Frame\";\nimport type { Scale } from \"./scale\";\nimport { extent, linePath, linearScale, logScale } from \"./scale\";\n\n/** One line of a {@link LineChart}. */\nexport interface Series {\n /** Legend text, and the React key — unique within one chart. */\n name: string;\n /**\n * Points in draw order. A non-finite coordinate lifts the pen rather than bridging the\n * gap; a single point draws a dot; no points draws nothing but keeps the legend entry.\n */\n points: { x: number; y: number }[];\n /** Any CSS colour. Omitted: {@link seriesColour} of the series' index. */\n colour?: string;\n /**\n * An error band around the line: `lower` and `upper` hold one value per point, by index (a\n * mean ± σ, a confidence interval). It is drawn as a translucent area in the series colour\n * under every line, shown in the legend, and read in the hover readout as `value ± half-width`\n * (or the value with its range when the band is not symmetric). A point whose edges are\n * missing or non-finite leaves a gap in the band. Unless `yDomain` is fixed, the y domain\n * grows to hold the band.\n */\n band?: SeriesBand;\n}\n\n/** Props for {@link LineChart}. */\nexport interface LineChartProps extends InteractionProps {\n /** The lines, drawn in order — a later series paints over an earlier one. */\n series: Series[];\n /** Accessible name of the chart (the SVG's `aria-label`). Required. */\n label: string;\n /** x-axis title. */\n xLabel?: string;\n /** y-axis title. */\n yLabel?: string;\n /** Losses span decades; a linear axis flattens two of the three onto the floor. */\n logY?: boolean;\n /** Fixed domains, for charts whose axes are known — ROC and PR are both `[0, 1]`. */\n xDomain?: [number, number];\n /**\n * Writes the x tick labels and the x in the hover readout from the x value: a date from a\n * timestamp, a unit. Omitted: the scale's own labels.\n */\n xFormat?: (x: number) => string;\n /** Fixed y domain. Omitted: the extent of every series' `y` and band edges. */\n yDomain?: [number, number];\n /** Drawn behind the series, in plot pixels. A chance diagonal or a tolerance band uses this. */\n underlay?: (x: Scale, y: Scale) => ReactNode;\n /** Rendered under the legend, inside the `<figcaption>`. */\n footer?: ReactNode;\n /** Show the legend row. Default `true`. */\n showLegend?: boolean;\n /** Where the chart is going (see {@link Variant}). Default `\"panel\"`. */\n variant?: Variant;\n /** Extra classes for the outer `<figure>`, merged with `cn`. */\n className?: string | undefined;\n /** For `variant=\"fluid\"`: the chart's height in CSS pixels. Default 200. */\n height?: number | undefined;\n}\n\n/**\n * A multi-series line chart over a shared x axis — training curves, ROC and PR curves.\n *\n * @remarks\n * An SVG `role=\"img\"` named by `label`, with the legend as real text under it. Series are\n * told apart by the legend's names, never by colour alone. `bands` and `markers` mark x\n * ranges and positions; `onHover` adds a crosshair and a value readout, `onPick` makes a\n * click report its x, and `cursor` draws an x chosen elsewhere. A series' `band` adds an error\n * band, and `xFormat` writes the x labels.\n */\nexport function LineChart({\n series,\n label,\n xLabel,\n yLabel,\n logY = false,\n xDomain,\n yDomain,\n xFormat,\n underlay,\n footer,\n showLegend = true,\n variant = \"panel\",\n className,\n height = FLUID_DEFAULT_HEIGHT,\n bands,\n markers,\n cursor,\n onHover,\n onPick,\n}: LineChartProps) {\n const allX = series.flatMap((entry) => entry.points.map((point) => point.x));\n const allY = series.flatMap((entry) => [...entry.points.map((point) => point.y), ...(entry.band ? bandValues(entry.band) : [])]);\n const [fluidRef, fluidSize] = useFluidSize(height);\n const size = variant === \"fluid\" ? fluidSize : undefined;\n const plotArea = areaFor(variant, size);\n\n const xScale = linearScale(xDomain ?? extent(allX), plotArea.x0, plotArea.x1);\n const makeY = logY ? logScale : linearScale;\n const yScale = makeY(yDomain ?? extent(allY), plotArea.y0, plotArea.y1);\n\n const coloured = series.map((entry, index) => ({\n ...entry,\n colour: entry.colour ?? seriesColour(index),\n }));\n\n return (\n <Frame\n xScale={xScale}\n yScale={yScale}\n xLabel={xLabel}\n yLabel={yLabel}\n label={label}\n variant={variant}\n className={className}\n size={size}\n figureRef={variant === \"fluid\" ? fluidRef : undefined}\n xFormat={xFormat}\n footer={\n <div className=\"flex flex-col gap-1\">\n {showLegend && (\n <Legend\n items={coloured.map((entry) => ({\n label: entry.name,\n colour: entry.colour,\n ...(entry.band ? { band: entry.band.label ?? \"± band\" } : {}),\n }))}\n />\n )}\n {footer}\n </div>\n }\n >\n {bands && bands.length > 0 && <Bands bands={bands} xScale={xScale} area={plotArea} />}\n {coloured.map(\n (entry) =>\n entry.band && (\n <path\n key={`band-${entry.name}`}\n data-series-band={entry.name}\n aria-hidden\n d={bandPath(entry.points, entry.band, xScale, yScale)}\n fill={entry.colour}\n fillOpacity={0.16}\n stroke=\"none\"\n />\n ),\n )}\n {underlay?.(xScale, yScale)}\n {coloured.map((entry) =>\n entry.points.length === 1 ? (\n <circle\n key={entry.name}\n cx={xScale.project(entry.points[0]?.x ?? 0)}\n cy={yScale.project(entry.points[0]?.y ?? 0)}\n r={2.5}\n fill={entry.colour}\n />\n ) : (\n <path\n key={entry.name}\n d={linePath(entry.points, xScale, yScale)}\n fill=\"none\"\n stroke={entry.colour}\n strokeWidth={1.5}\n strokeLinejoin=\"round\"\n vectorEffect=\"non-scaling-stroke\"\n />\n ),\n )}\n {markers && markers.length > 0 && <Markers markers={markers} xScale={xScale} area={plotArea} />}\n {(onHover || onPick || cursor !== undefined) && (\n <PlotInteraction\n xScale={xScale}\n yScale={yScale}\n area={plotArea}\n series={coloured}\n cursor={cursor}\n onHover={onHover}\n onPick={onPick}\n xFormat={xFormat}\n />\n )}\n </Frame>\n );\n}\n","/**\n * Colour maps for a magnitude: a residual's size, a per-cell error, a confidence, a validity\n * fraction, or a signed quantity around zero.\n *\n * Only perceptually uniform maps ship, so equal steps in the data look like equal steps.\n *\n * Sequential, low to high:\n * - `viridis` is the default on the chrome.\n * - `cividis` is for when the map alone carries the finding and the reader's colour vision is\n * unknown.\n * - `magma` and `inferno` run from black to a pale yellow through purple and red or orange. They\n * read well over a dark image, where `viridis`' dark end disappears.\n *\n * Diverging, for a signed value whose zero matters (a displacement toward or away from a\n * centre, a difference between two runs):\n * - `blueOrange` runs from a deep blue through a neutral light grey at the middle to a deep\n * orange-brown. Both arms fall in lightness at the same rate and carry the same amount of\n * colour, so +x and -x look equally strong, and its hues avoid the red-green axis. Centre it on zero with `symmetricDomain`.\n *\n * A continuous quality is a magnitude even when low values are \"good\": stepping it onto verdict\n * colours (green / amber / red) claims a threshold judgement nobody made.\n *\n * The sequential anchors are the matplotlib maps sampled at nine evenly spaced points. Linear\n * interpolation between them stays within a few units of the full 256-entry tables. The\n * diverging map was constructed in OKLab (equal lightness and chroma steps along each arm,\n * mirrored in lightness, kept inside sRGB) and sampled at seventeen points.\n */\n\n/** The shipped maps. */\nexport type ColormapName = \"viridis\" | \"cividis\" | \"magma\" | \"inferno\" | \"blueOrange\";\n\ntype Rgb = readonly [number, number, number];\n\nconst ANCHORS: Record<ColormapName, readonly Rgb[]> = {\n viridis: [\n [68, 1, 84],\n [71, 44, 122],\n [59, 81, 139],\n [44, 113, 142],\n [33, 144, 141],\n [39, 173, 129],\n [92, 200, 99],\n [170, 220, 50],\n [253, 231, 37],\n ],\n magma: [\n [0, 0, 4],\n [29, 17, 71],\n [81, 18, 124],\n [131, 38, 129],\n [183, 55, 121],\n [231, 82, 99],\n [252, 137, 97],\n [254, 196, 136],\n [252, 253, 191],\n ],\n inferno: [\n [0, 0, 4],\n [33, 12, 74],\n [87, 16, 110],\n [138, 34, 106],\n [188, 55, 84],\n [228, 90, 49],\n [249, 142, 9],\n [249, 203, 53],\n [252, 255, 164],\n ],\n blueOrange: [\n [0, 70, 140],\n [33, 90, 158],\n [64, 112, 172],\n [92, 133, 185],\n [121, 155, 198],\n [150, 176, 211],\n [179, 198, 222],\n [209, 220, 233],\n [242, 242, 242],\n [230, 216, 207],\n [216, 190, 175],\n [201, 165, 144],\n [186, 140, 113],\n [170, 116, 83],\n [153, 91, 52],\n [136, 67, 13],\n [113, 52, 0],\n ],\n cividis: [\n [0, 34, 78],\n [18, 53, 112],\n [59, 73, 108],\n [87, 93, 109],\n [112, 113, 115],\n [138, 135, 121],\n [165, 157, 116],\n [196, 182, 101],\n [254, 232, 56],\n ],\n};\n\n/** The names of the shipped maps. */\nexport const COLORMAPS: readonly ColormapName[] = [\"viridis\", \"cividis\", \"magma\", \"inferno\", \"blueOrange\"];\n\n/** The maps that run through a neutral middle, for a signed value: use them over a domain centred on zero. */\nexport const DIVERGING_COLORMAPS: readonly ColormapName[] = [\"blueOrange\"];\n\n/**\n * Whether a map is diverging.\n *\n * @param name - The map.\n * @returns `true` for a map meant for a signed value around zero.\n */\nexport function isDivergingColormap(name: ColormapName): boolean {\n return DIVERGING_COLORMAPS.includes(name);\n}\n\n/**\n * A domain centred on zero that holds a given one: `[-m, m]` with `m` the largest absolute end.\n * Feed it a diverging map so the middle colour means zero.\n *\n * @param domain - `[low, high]`, or the values to cover.\n * @returns `[-m, m]`; `[-1, 1]` when no end is finite and non-zero.\n */\nexport function symmetricDomain(domain: readonly number[]): [number, number] {\n let m = 0;\n for (const v of domain) if (Number.isFinite(v) && Math.abs(v) > m) m = Math.abs(v);\n return m > 0 ? [-m, m] : [-1, 1];\n}\n\n/**\n * The colour of `t` on a map.\n *\n * @param name - The map.\n * @param t - Position in `[0, 1]`; clamped. A non-finite `t` gives the map's low end.\n * @returns A CSS `rgb(r g b)` colour.\n */\nexport function colormap(name: ColormapName, t: number): string {\n const [r, g, b] = colormapRgb(name, t);\n return `rgb(${r} ${g} ${b})`;\n}\n\n/**\n * The colour of `t` on a map, as integer channels.\n *\n * @param name - The map.\n * @param t - Position in `[0, 1]`; clamped.\n * @returns `[r, g, b]`, each 0–255.\n */\nexport function colormapRgb(name: ColormapName, t: number): [number, number, number] {\n const anchors = ANCHORS[name];\n const clamped = Number.isFinite(t) ? Math.min(1, Math.max(0, t)) : 0;\n const scaled = clamped * (anchors.length - 1);\n const i = Math.min(anchors.length - 2, Math.floor(scaled));\n const f = scaled - i;\n const a = anchors[i]!;\n const b = anchors[i + 1]!;\n return [Math.round(a[0] + f * (b[0] - a[0])), Math.round(a[1] + f * (b[1] - a[1])), Math.round(a[2] + f * (b[2] - a[2]))];\n}\n\n/**\n * A value's colour on a map, over a domain.\n *\n * @param name - The map.\n * @param value - The value.\n * @param domain - `[low, high]`: low maps to the map's start. A reversed domain reverses the map.\n * For a diverging map pass a domain centred on zero (`symmetricDomain`).\n * @returns A CSS colour.\n */\nexport function colormapValue(name: ColormapName, value: number, domain: readonly [number, number]): string {\n const [low, high] = domain;\n const span = high - low;\n return colormap(name, span === 0 ? 0 : (value - low) / span);\n}\n\n/**\n * A CSS `linear-gradient` of a map, for a legend bar.\n *\n * @param name - The map.\n * @param direction - The gradient's direction. Defaults to `to right`.\n * @returns A CSS `background-image` value.\n */\nexport function colormapGradient(name: ColormapName, direction = \"to right\"): string {\n const anchors = ANCHORS[name];\n const stops = anchors.map(([r, g, b], i) => `rgb(${r} ${g} ${b}) ${((i / (anchors.length - 1)) * 100).toFixed(1)}%`);\n return `linear-gradient(${direction}, ${stops.join(\", \")})`;\n}\n","/**\n * The scale of a colour map, shown beside the map: every chart or map shows its scale, with units.\n */\n\nimport { cn } from \"@vitavision/ui\";\n\nimport { colormap, colormapGradient, symmetricDomain, type ColormapName } from \"./colormap\";\nimport { linearScale } from \"./scale\";\n\n/** A value marked on a {@link ColormapLegend}: a threshold, a cursor value, a reference. */\nexport interface ColormapMarker {\n /** Where, in the legend's value units. A value outside the domain is left out. */\n value: number;\n /** The marker's text. Default: the value, formatted with the legend's `format` and `unit`. */\n label?: string | undefined;\n}\n\n/** Which end of a {@link ColormapLegend} the data runs past: `\"high\"` is `≥ max`, `\"low\"` is `≤ min`. */\nexport type ColormapClipped = \"high\" | \"low\" | \"both\";\n\n/** Props of `ColormapLegend`. */\nexport interface ColormapLegendProps {\n /** The map. */\n map: ColormapName;\n /** The values at the two ends, `[low, high]`. */\n domain: readonly [number, number];\n /** The values' unit, written after them (`px`, `%`). */\n unit?: string | undefined;\n /** What the colour encodes, written before the bar (\"Validity\", \"Edge error\"). */\n label: string;\n /** Formats the end and tick values. Defaults to at most 3 significant figures, without trailing zeros. */\n format?: ((value: number) => string) | undefined;\n /**\n * How the bar runs. `horizontal` (the default) is one line, low to high; `vertical` is a\n * column with the label above and the high end at the top, for the side of a map.\n */\n orientation?: \"horizontal\" | \"vertical\" | undefined;\n /**\n * Values to label along the bar: a list, or a rough count of round ones. Without it a\n * `horizontal` legend labels its two ends in line with the bar and a `vertical` one labels\n * its two ends (and zero, when `symmetric`). With it the values sit along the bar, at their\n * position on the map; values outside `domain` are left out. A count also labels the two ends.\n */\n ticks?: number | readonly number[] | undefined;\n /**\n * Centre the scale on zero for a diverging map: `domain` is widened to `[-m, m]` with `m`\n * its largest absolute end, so the middle colour is zero and the middle tick says so.\n */\n symmetric?: boolean | undefined;\n /**\n * Values to mark on the bar: a number, a `{ value, label? }`, or a list of either. Each is a\n * tick across the bar with its text beside it (above a horizontal bar, to the right of the\n * ticks on a vertical one): the label, or else the value with the unit. The text carries the\n * meaning; the tick is decorative. A value outside `domain` is left out.\n */\n marker?: number | ColormapMarker | readonly (number | ColormapMarker)[] | undefined;\n /**\n * The scale saturates: the data runs past the end of `domain`. The end gets a cap (a small\n * arrow in the end colour) and its value reads `≥ max` (`high`) or `≤ min` (`low`); `both`\n * does both ends. The end value is labelled even when `ticks` leaves it out.\n */\n clipped?: ColormapClipped | undefined;\n /** For `vertical`: the bar's length in CSS pixels. Defaults to 160. */\n length?: number | undefined;\n /** Merged onto the legend with `cn`. */\n className?: string | undefined;\n}\n\nconst defaultFormat = (value: number) => String(Number(value.toPrecision(3)));\n\n/** The tick values: a given list inside the domain, or round values, or the default for the layout. */\nfunction tickValues(ticks: ColormapLegendProps[\"ticks\"], domain: readonly [number, number], symmetric: boolean): number[] {\n const [low, high] = domain;\n const inside = (v: number) => Number.isFinite(v) && v >= Math.min(low, high) - 1e-12 && v <= Math.max(low, high) + 1e-12;\n if (typeof ticks === \"number\") {\n // Round values, and the two ends: a scale is read from its ends. A round value within 8 % of an end gives way to it.\n const span = Math.abs(high - low);\n const round = linearScale([low, high], 0, 1)\n .ticks(ticks)\n .map((tick) => tick.value)\n .filter((v) => inside(v) && Math.abs(v - low) > 0.08 * span && Math.abs(v - high) > 0.08 * span);\n return [low, ...round, high];\n }\n if (ticks !== undefined) return ticks.filter(inside);\n return symmetric ? [low, 0, high] : [low, high];\n}\n\n/** `marker` as a list of `{ value, label }`, in domain, in the order given. */\nfunction markerList(marker: ColormapLegendProps[\"marker\"], low: number, high: number): ColormapMarker[] {\n if (marker === undefined) return [];\n const list =\n typeof marker === \"number\" || !Array.isArray(marker)\n ? [marker as number | ColormapMarker]\n : [...(marker as readonly (number | ColormapMarker)[])];\n const lo = Math.min(low, high) - 1e-12;\n const hi = Math.max(low, high) + 1e-12;\n return list\n .map((entry) => (typeof entry === \"number\" ? { value: entry } : entry))\n .filter((entry) => Number.isFinite(entry.value) && entry.value >= lo && entry.value <= hi);\n}\n\n/** The cap on a clipped end: an arrow in the map's end colour, pointing outward. */\nfunction EndCap({ map, end, orientation }: { map: ColormapName; end: \"low\" | \"high\"; orientation: \"horizontal\" | \"vertical\" }) {\n const horizontal = orientation === \"horizontal\";\n const clip = horizontal\n ? end === \"high\"\n ? \"polygon(0 0, 100% 50%, 0 100%)\"\n : \"polygon(100% 0, 0 50%, 100% 100%)\"\n : end === \"high\"\n ? \"polygon(50% 0, 100% 100%, 0 100%)\"\n : \"polygon(0 0, 100% 0, 50% 100%)\";\n const place = horizontal\n ? end === \"high\"\n ? \"left-full top-0.5 ml-px h-2 w-1.5\"\n : \"right-full top-0.5 mr-px h-2 w-1.5\"\n : end === \"high\"\n ? \"bottom-full left-0 mb-px h-1.5 w-2.5\"\n : \"top-full left-0 mt-px h-1.5 w-2.5\";\n return (\n <span\n aria-hidden\n data-cap={end}\n className={`absolute ${place}`}\n style={{ backgroundColor: colormap(map, end === \"high\" ? 1 : 0), clipPath: clip }}\n />\n );\n}\n\n/**\n * A gradient bar with its values and unit.\n *\n * - **Horizontal**: one line, \"Edge error 0 [bar] 2.5 px\". With `ticks` or `symmetric` the values\n * sit under the bar at their position instead.\n * - **Vertical**: the label above a column bar, the high end at the top, the values beside the\n * bar at their position, and the unit after the label.\n *\n * `marker` ticks values on the bar (a threshold, the value under a cursor) and `clipped` says\n * the scale saturates at an end, with a cap and `≥` / `≤` on its value.\n *\n * The bar is decorative; the label, the values and the markers' text carry the meaning.\n */\nexport function ColormapLegend({\n map,\n domain,\n unit,\n label,\n format = defaultFormat,\n orientation = \"horizontal\",\n ticks,\n symmetric = false,\n marker,\n clipped,\n length = 160,\n className,\n}: ColormapLegendProps) {\n const [low, high] = symmetric ? symmetricDomain(domain) : domain;\n const span = high - low;\n const end = (value: number) => (unit ? `${format(value)} ${unit}` : format(value));\n const fraction = (value: number) => (span === 0 ? 0 : (value - low) / span);\n const markers = markerList(marker, low, high);\n const capLow = clipped === \"low\" || clipped === \"both\";\n const capHigh = clipped === \"high\" || clipped === \"both\";\n // `≤ min` / `≥ max` on the clipped end's text. Where `low` and `high` coincide the high end wins.\n const text = (value: number, isLow: boolean, isHigh: boolean) =>\n `${isHigh && capHigh ? \"≥ \" : isLow && capLow ? \"≤ \" : \"\"}${format(value)}`;\n const markerText = (entry: ColormapMarker) => entry.label ?? end(entry.value);\n\n if (orientation === \"horizontal\" && ticks === undefined && !symmetric && markers.length === 0) {\n return (\n <div className={cn(\"flex items-center gap-2 text-xs text-fg-muted\", className)} data-colormap={map}>\n <span>{label}</span>\n <span className=\"font-mono tabular-nums\">{capLow ? `≤ ${end(low)}` : end(low)}</span>\n <span aria-hidden className=\"relative h-2 w-24 rounded-full\" style={{ backgroundImage: colormapGradient(map) }}>\n {capLow && <EndCap map={map} end=\"low\" orientation=\"horizontal\" />}\n {capHigh && <EndCap map={map} end=\"high\" orientation=\"horizontal\" />}\n </span>\n <span className=\"font-mono tabular-nums\">{capHigh ? `≥ ${end(high)}` : end(high)}</span>\n </div>\n );\n }\n\n const values = tickValues(ticks, [low, high], symmetric);\n // A clipped end is always labelled, even when a given `ticks` list leaves it out.\n if (capLow && !values.includes(low)) values.unshift(low);\n if (capHigh && !values.includes(high)) values.push(high);\n const tickText = (value: number) => text(value, value === low, value === high);\n\n if (orientation === \"horizontal\") {\n return (\n <div className={cn(\"flex items-start gap-2 text-xs text-fg-muted\", className)} data-colormap={map}>\n <span className={markers.length > 0 ? \"pt-4\" : undefined}>{label}</span>\n {/* The values are positioned against the bar; `pb-4` leaves the row room for them, `pt-4` the markers' text. */}\n <div className={cn(\"relative w-32 pb-4\", markers.length > 0 && \"pt-4\", (capLow || capHigh) && \"mx-2\")}>\n <div className=\"relative mt-0.5 h-2\">\n <div aria-hidden className=\"absolute inset-0 rounded-full\" style={{ backgroundImage: colormapGradient(map) }} />\n {capLow && <EndCap map={map} end=\"low\" orientation=\"horizontal\" />}\n {capHigh && <EndCap map={map} end=\"high\" orientation=\"horizontal\" />}\n {markers.map((entry) => (\n <span\n key={`m-${entry.value}-${entry.label ?? \"\"}`}\n aria-hidden\n data-marker-tick=\"\"\n className=\"absolute -top-0.5 h-3 w-0.5 -translate-x-1/2 rounded-full bg-fg ring-1 ring-surface\"\n style={{ left: `${(fraction(entry.value) * 100).toFixed(2)}%` }}\n />\n ))}\n </div>\n {markers.map((entry) => (\n <span\n key={`mt-${entry.value}-${entry.label ?? \"\"}`}\n data-marker=\"\"\n className=\"absolute top-0 -translate-x-1/2 whitespace-nowrap font-mono text-[10px] leading-none tabular-nums text-fg\"\n style={{ left: `${(fraction(entry.value) * 100).toFixed(2)}%` }}\n >\n {markerText(entry)}\n </span>\n ))}\n {values.map((value) => (\n <span\n key={value}\n data-tick=\"\"\n className={cn(\"absolute -translate-x-1/2 font-mono text-[10px] tabular-nums\", markers.length > 0 ? \"top-7\" : \"top-3\")}\n style={{ left: `${(fraction(value) * 100).toFixed(2)}%` }}\n >\n {tickText(value)}\n </span>\n ))}\n </div>\n {unit && <span className={cn(\"text-fg-subtle\", markers.length > 0 && \"pt-4\")}>{unit}</span>}\n </div>\n );\n }\n\n return (\n <div className={cn(\"inline-flex flex-col gap-1.5 text-xs text-fg-muted\", className)} data-colormap={map} data-orientation=\"vertical\">\n <span>\n {label}\n {unit && <span className=\"ml-1 text-fg-subtle\">{unit}</span>}\n </span>\n {/* The values sit on the bar's right; the margin above and below keeps the end values inside the box. */}\n <div className=\"relative my-1.5 flex\" style={{ height: length }}>\n <div className=\"relative w-2.5\">\n <div aria-hidden className=\"absolute inset-0 rounded-full\" style={{ backgroundImage: colormapGradient(map, \"to top\") }} />\n {capLow && <EndCap map={map} end=\"low\" orientation=\"vertical\" />}\n {capHigh && <EndCap map={map} end=\"high\" orientation=\"vertical\" />}\n {markers.map((entry) => (\n <span\n key={`m-${entry.value}-${entry.label ?? \"\"}`}\n aria-hidden\n data-marker-tick=\"\"\n className=\"absolute -left-0.5 -right-0.5 h-0.5 translate-y-1/2 rounded-full bg-fg ring-1 ring-surface\"\n style={{ bottom: `${(fraction(entry.value) * 100).toFixed(2)}%` }}\n />\n ))}\n </div>\n <div className=\"relative ml-1.5 min-w-8\">\n {values.map((value) => (\n <span\n key={value}\n data-tick=\"\"\n className=\"absolute left-0 translate-y-1/2 whitespace-nowrap font-mono text-[10px] leading-none tabular-nums\"\n style={{ bottom: `${(fraction(value) * 100).toFixed(2)}%` }}\n >\n {tickText(value)}\n </span>\n ))}\n </div>\n {markers.length > 0 && (\n <div className=\"relative ml-1.5 min-w-8\">\n {markers.map((entry) => (\n <span\n key={`mt-${entry.value}-${entry.label ?? \"\"}`}\n data-marker=\"\"\n className=\"absolute left-0 translate-y-1/2 whitespace-nowrap font-mono text-[10px] leading-none tabular-nums text-fg\"\n style={{ bottom: `${(fraction(entry.value) * 100).toFixed(2)}%` }}\n >\n {markerText(entry)}\n </span>\n ))}\n </div>\n )}\n </div>\n </div>\n );\n}\n","/**\n * The arithmetic behind `ScatterChart`: which point is under the pointer, which colour step a\n * value falls in, and the domain a colour scale covers.\n *\n * Pure: the component is a thin list of SVG elements over it.\n */\n\nimport { symmetricDomain } from \"./colormap\";\n\n/** The number of colour steps a value-coloured series is quantised into: one path each. */\nexport const SCATTER_COLOUR_STEPS = 24;\n\n/**\n * The projected point nearest to a position, within a radius.\n *\n * @param xy - Flat `[x0, y0, x1, y1, …]` in the plot's own units (viewBox units); a non-finite\n * coordinate is skipped.\n * @param x - The query's x.\n * @param y - The query's y.\n * @param radius - How far from a point the query still picks it.\n * @returns The index of the nearest point (the lower index on a tie), or `-1`.\n */\nexport function nearestProjected(xy: ArrayLike<number>, x: number, y: number, radius: number): number {\n const limit = radius * radius;\n let best = -1;\n let bestD = Infinity;\n const count = Math.floor(xy.length / 2);\n for (let i = 0; i < count; i++) {\n const dx = xy[2 * i]! - x;\n const dy = xy[2 * i + 1]! - y;\n const d = dx * dx + dy * dy;\n if (d <= limit && d < bestD) {\n best = i;\n bestD = d;\n }\n }\n return best;\n}\n\n/**\n * The colour step of a value.\n *\n * @param value - The point's value.\n * @param domain - `[low, high]`: `low` maps to the first step.\n * @param steps - How many steps. Defaults to `SCATTER_COLOUR_STEPS`.\n * @returns An integer in `[0, steps - 1]`; `-1` for a non-finite value; a degenerate domain puts\n * every value in step `0`.\n */\nexport function colourStep(value: number, domain: readonly [number, number], steps = SCATTER_COLOUR_STEPS): number {\n if (!Number.isFinite(value)) return -1;\n const [low, high] = domain;\n if (!(high > low)) return 0;\n return Math.min(steps - 1, Math.max(0, Math.floor(((value - low) / (high - low)) * steps)));\n}\n\n/**\n * The domain a value colouring covers.\n *\n * @param values - Every point's value; non-finite ones are ignored.\n * @param symmetric - Centre it on zero, for a diverging map.\n * @param given - A domain the caller fixed. It wins, centred if `symmetric`.\n * @returns `[low, high]`; `[0, 1]` when there is no finite value.\n */\nexport function colourDomain(values: Iterable<number>, symmetric: boolean, given?: readonly [number, number]): [number, number] {\n let low = Infinity;\n let high = -Infinity;\n if (given) [low, high] = given;\n else {\n for (const v of values) {\n if (!Number.isFinite(v)) continue;\n if (v < low) low = v;\n if (v > high) high = v;\n }\n if (low > high) return symmetric ? [-1, 1] : [0, 1];\n }\n return symmetric ? symmetricDomain([low, high]) : [low, high];\n}\n","/**\n * A scatter plot: points over two numeric axes, each optionally coloured by a third value.\n *\n * Points are drawn as a few batched paths (one per series, or one per colour step with\n * `colourBy`), never one element per point, and the pointer is resolved from the projected\n * positions, not from the DOM. A few thousand points stay cheap.\n */\n\nimport { useId, useMemo, useState, type ReactNode } from \"react\";\n\nimport { toneColor, type MeasureTone } from \"@vitavision/ui\";\n\nimport { ColormapLegend } from \"./ColormapLegend\";\nimport { colormapRgb, isDivergingColormap, type ColormapName } from \"./colormap\";\nimport { FLUID_DEFAULT_HEIGHT, Frame, Legend, areaFor, seriesColour, useFluidSize, type Variant } from \"./Frame\";\nimport { extent, linearScale, type Scale } from \"./scale\";\nimport { SCATTER_COLOUR_STEPS, colourDomain, colourStep, nearestProjected } from \"./scatter\";\n\n/** One point of a {@link ScatterChart}. */\nexport interface ScatterPoint {\n /** Horizontal position, in x domain units. A non-finite value skips the point. */\n x: number;\n /** Vertical position, in y domain units. A non-finite value skips the point. */\n y: number;\n /** What `colourBy` colours it by. A point without one is drawn in the muted tone. */\n value?: number | undefined;\n}\n\n/** One group of points of a {@link ScatterChart}. */\nexport interface ScatterSeries {\n /** Legend text, and the React key — unique within one chart. */\n name: string;\n /** The points. Their index here is what hover and pick report. */\n points: readonly ScatterPoint[];\n /** Any CSS colour. Omitted: {@link seriesColour} of the series' index. Ignored with `colourBy`. */\n colour?: string | undefined;\n}\n\n/** Colour every point by its `value` through a map. */\nexport interface ScatterColourBy {\n /** The map. A diverging map centres on zero by default. */\n map: ColormapName;\n /** The values at the map's ends. Omitted: the extent of the points' values. */\n domain?: readonly [number, number] | undefined;\n /** Centre the domain on zero. Defaults to `true` for a diverging map, `false` otherwise. */\n symmetric?: boolean | undefined;\n /** What the colour encodes, written beside the scale. Required: a map is never shown unlabelled. */\n label: string;\n /** The values' unit, written after the scale's numbers. */\n unit?: string | undefined;\n}\n\n/** A rule across the plot at one x or y: a tolerance, a mean, an expected value. */\nexport interface ScatterReferenceLine {\n /** Which axis the value is on: `\"y\"` is a horizontal rule, `\"x\"` a vertical one. */\n axis: \"x\" | \"y\";\n /** Where, in that axis' domain units. A value outside the domain is not drawn. */\n value: number;\n /** Text at the rule's end. */\n label?: string | undefined;\n /** Its colour. Default `\"muted\"`. */\n tone?: MeasureTone | undefined;\n}\n\n/** A point of a {@link ScatterChart}, as hover and pick report it. */\nexport interface ScatterPick {\n /** The name of its series. */\n series: string;\n /** Its index in that series' `points`. */\n index: number;\n /** Its x. */\n x: number;\n /** Its y. */\n y: number;\n /** Its value, when it has one. */\n value?: number | undefined;\n}\n\n/** Props for {@link ScatterChart}. */\nexport interface ScatterChartProps {\n /** The groups of points, drawn in order — a later series paints over an earlier one. */\n series: readonly ScatterSeries[];\n /** Accessible name of the chart (the SVG's `aria-label`). Required. */\n label: string;\n /** x-axis title. */\n xLabel?: string | undefined;\n /** y-axis title. */\n yLabel?: string | undefined;\n /** Fixed x domain. Omitted: the extent of every series' `x`, with 4 % on each side. */\n xDomain?: [number, number] | undefined;\n /** Fixed y domain. Omitted: the extent of every series' `y`, with 4 % on each side. */\n yDomain?: [number, number] | undefined;\n /** Colour points by their `value`, with a legend of the scale in the footer. */\n colourBy?: ScatterColourBy | undefined;\n /** Rules across the plot, drawn behind the points. */\n referenceLines?: readonly ScatterReferenceLine[] | undefined;\n /** Marker diameter in CSS pixels at the chart's own scale. Default 4. */\n markerSize?: number | undefined;\n /** Drawn behind the points, in plot pixels. A tolerance region or a fitted curve uses this. */\n underlay?: ((x: Scale, y: Scale) => ReactNode) | undefined;\n /** The point to draw as highlighted, from outside the chart (a hovered table row). */\n highlighted?: { series: string; index: number } | null | undefined;\n /**\n * Called with the point nearest the pointer (within 10 plot units), or `null` when none is.\n * Draws a ring on it and a readout of its numbers.\n */\n onHover?: ((point: ScatterPick | null) => void) | undefined;\n /** Called with the point under a click. Makes the plot area a pointer target. */\n onPick?: ((point: ScatterPick) => void) | undefined;\n /** Rendered under the legend, inside the `<figcaption>`. */\n footer?: ReactNode;\n /** Show the series legend row (without `colourBy`). Default `true`. */\n showLegend?: boolean | undefined;\n /** Where the chart is going (see {@link Variant}). Default `\"panel\"`. */\n variant?: Variant | undefined;\n /** Extra classes for the outer `<figure>`, merged with `cn`. */\n className?: string | undefined;\n /** For `variant=\"fluid\"`: the chart's height in CSS pixels. Default 200. */\n height?: number | undefined;\n}\n\n/** How near the pointer must be to a point, in viewBox units, to pick it. */\nconst PICK_RADIUS = 10;\nconst MUTED = \"var(--fg-subtle)\";\n\nconst formatValue = (value: number) => (Math.abs(value) >= 100 ? value.toFixed(0) : String(Number(value.toPrecision(3))));\n\n/**\n * A scatter plot over a shared frame — residuals against position, one run against another.\n *\n * @remarks\n * An SVG `role=\"img\"` named by `label`, with the series legend (or, with `colourBy`, the colour\n * scale) as real text under it. Series are told apart by the legend's names, never by colour\n * alone. `referenceLines` mark a value on either axis; `onHover` rings the nearest point and\n * reads its numbers, `onPick` reports a click's point, and `highlighted` rings one chosen\n * elsewhere. Picking is by pointer, so the same points must be reachable from a table beside\n * the chart. A point with a non-finite coordinate is skipped.\n */\nexport function ScatterChart({\n series,\n label,\n xLabel,\n yLabel,\n xDomain,\n yDomain,\n colourBy,\n referenceLines,\n markerSize = 4,\n underlay,\n highlighted,\n onHover,\n onPick,\n footer,\n showLegend = true,\n variant = \"panel\",\n className,\n height = FLUID_DEFAULT_HEIGHT,\n}: ScatterChartProps) {\n const clipId = useId();\n const [fluidRef, fluidSize] = useFluidSize(height);\n const size = variant === \"fluid\" ? fluidSize : undefined;\n const area = areaFor(variant, size);\n\n const allX: number[] = [];\n const allY: number[] = [];\n for (const entry of series) {\n for (const p of entry.points) {\n allX.push(p.x);\n allY.push(p.y);\n }\n }\n const xScale = linearScale(xDomain ?? paddedExtent(allX), area.x0, area.x1);\n const yScale = linearScale(yDomain ?? paddedExtent(allY), area.y0, area.y1);\n\n const symmetric = colourBy ? (colourBy.symmetric ?? isDivergingColormap(colourBy.map)) : false;\n const domain = useMemo(\n () =>\n colourBy\n ? colourDomain(\n series.flatMap((s) => s.points.map((p) => p.value ?? Number.NaN)),\n symmetric,\n colourBy.domain,\n )\n : null,\n [series, colourBy, symmetric],\n );\n\n // Projected positions, once per data or geometry change: they are what drawing and picking read.\n const projected = useMemo(() => {\n const xy: number[] = [];\n const owner: { series: number; index: number }[] = [];\n series.forEach((entry, s) => {\n entry.points.forEach((p, index) => {\n const px = xScale.project(p.x);\n const py = yScale.project(p.y);\n if (!Number.isFinite(p.x) || !Number.isFinite(p.y) || !Number.isFinite(px) || !Number.isFinite(py)) return;\n xy.push(px, py);\n owner.push({ series: s, index });\n });\n });\n return { xy, owner };\n // The scales are rebuilt every render from their domains and the area; these are what they depend on.\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n }, [series, xScale.domain[0], xScale.domain[1], yScale.domain[0], yScale.domain[1], area.x0, area.x1, area.y0, area.y1]);\n\n // One batched path per (series, colour step).\n const batches = useMemo(() => {\n const out: { key: string; d: string; colour: string }[] = [];\n let cursor = 0;\n series.forEach((entry, s) => {\n const parts = new Map<number, string>();\n while (cursor < projected.owner.length && projected.owner[cursor]!.series === s) {\n const point = entry.points[projected.owner[cursor]!.index]!;\n const step = colourBy && domain ? colourStep(point.value ?? Number.NaN, domain) : 0;\n parts.set(step, `${parts.get(step) ?? \"\"}M${projected.xy[2 * cursor]!.toFixed(2)} ${projected.xy[2 * cursor + 1]!.toFixed(2)}h0`);\n cursor++;\n }\n for (const [step, d] of parts) {\n let colour: string;\n if (!colourBy) colour = entry.colour ?? seriesColour(s);\n else if (step < 0) colour = MUTED;\n else {\n const [r, g, b] = colormapRgb(colourBy.map, (step + 0.5) / SCATTER_COLOUR_STEPS);\n colour = `rgb(${r} ${g} ${b})`;\n }\n out.push({ key: `${s}|${step}`, d, colour });\n }\n });\n return out;\n }, [series, projected, colourBy, domain]);\n\n const [hover, setHover] = useState<ScatterPick | null>(null);\n const pickAt = (event: { clientX: number; clientY: number; currentTarget: SVGRectElement }): ScatterPick | null => {\n const svg = event.currentTarget.ownerSVGElement;\n const ctm = svg?.getScreenCTM();\n let x = event.clientX;\n let y = event.clientY;\n if (svg && ctm) {\n const point = svg.createSVGPoint();\n point.x = event.clientX;\n point.y = event.clientY;\n const local = point.matrixTransform(ctm.inverse());\n x = local.x;\n y = local.y;\n }\n const found = nearestProjected(projected.xy, x, y, PICK_RADIUS);\n return found < 0 ? null : pointOf(found);\n };\n const pointOf = (k: number): ScatterPick => {\n const { series: s, index } = projected.owner[k]!;\n const entry = series[s]!;\n const point = entry.points[index]!;\n return { series: entry.name, index, x: point.x, y: point.y, value: point.value };\n };\n\n const ringed = hover ?? (highlighted ? findPick(series, highlighted) : null);\n const ringAt = ringed ? { cx: xScale.project(ringed.x), cy: yScale.project(ringed.y) } : null;\n const interactive = onHover !== undefined || onPick !== undefined;\n const radius = markerSize / 2;\n\n return (\n <Frame\n xScale={xScale}\n yScale={yScale}\n xLabel={xLabel}\n yLabel={yLabel}\n label={label}\n variant={variant}\n className={className}\n size={size}\n figureRef={variant === \"fluid\" ? fluidRef : undefined}\n footer={\n <div className=\"flex flex-col gap-1\">\n {colourBy && domain ? (\n <ColormapLegend\n map={colourBy.map}\n domain={domain}\n label={colourBy.label}\n unit={colourBy.unit}\n symmetric={symmetric}\n format={formatValue}\n />\n ) : (\n showLegend && <Legend items={series.map((entry, s) => ({ label: entry.name, colour: entry.colour ?? seriesColour(s) }))} />\n )}\n {footer}\n </div>\n }\n >\n <defs>\n <clipPath id={clipId}>\n <rect x={area.x0} y={area.y1} width={area.x1 - area.x0} height={area.y0 - area.y1} />\n </clipPath>\n </defs>\n {underlay?.(xScale, yScale)}\n {referenceLines && referenceLines.length > 0 && <ReferenceLines lines={referenceLines} xScale={xScale} yScale={yScale} area={area} />}\n <g clipPath={`url(#${clipId})`} data-points=\"\" fill=\"none\" strokeLinecap=\"round\">\n {batches.map((batch) => (\n <path key={batch.key} d={batch.d} stroke=\"var(--surface)\" strokeWidth={markerSize + 1.5} opacity={0.7} />\n ))}\n {batches.map((batch) => (\n <path key={`p|${batch.key}`} data-batch={batch.key} d={batch.d} stroke={batch.colour} strokeWidth={markerSize} />\n ))}\n </g>\n {ringAt && (\n <g data-highlight=\"\" pointerEvents=\"none\">\n <circle {...ringAt} r={radius + 3} fill=\"none\" stroke=\"var(--surface)\" strokeWidth={3.5} />\n <circle {...ringAt} r={radius + 3} fill=\"none\" stroke=\"var(--signal)\" strokeWidth={1.75} />\n </g>\n )}\n {hover && (\n <text\n data-readout=\"\"\n x={xScale.project(hover.x) > (area.x0 + area.x1) / 2 ? area.x1 - 4 : area.x0 + 4}\n y={area.y1 + 10}\n textAnchor={xScale.project(hover.x) > (area.x0 + area.x1) / 2 ? \"end\" : \"start\"}\n fontSize={10}\n fill=\"currentColor\"\n >\n {[`${formatValue(hover.x)}, ${formatValue(hover.y)}`, hover.value !== undefined ? formatValue(hover.value) : null]\n .filter((part) => part !== null)\n .join(\" · \")}\n </text>\n )}\n {interactive && (\n <rect\n data-plot-target=\"\"\n x={area.x0}\n y={area.y1}\n width={area.x1 - area.x0}\n height={area.y0 - area.y1}\n fill=\"transparent\"\n style={{ cursor: onPick ? \"pointer\" : \"crosshair\" }}\n onPointerMove={(event) => {\n const next = pickAt(event);\n setHover(next);\n onHover?.(next);\n }}\n onPointerLeave={() => {\n setHover(null);\n onHover?.(null);\n }}\n onClick={(event) => {\n const picked = pickAt(event);\n if (picked) onPick?.(picked);\n }}\n />\n )}\n </Frame>\n );\n}\n\n/** The extent of the values with 4 % on each side, so a marker on an extreme is not cut by the axis or the frame. */\nfunction paddedExtent(values: readonly number[]): [number, number] {\n const [low, high] = extent(values);\n const pad = (high - low) * 0.04;\n return [low - pad, high + pad];\n}\n\n/** The point a `highlighted` names, or `null` when it names none that exists and is finite. */\nfunction findPick(series: readonly ScatterSeries[], at: { series: string; index: number }): ScatterPick | null {\n const entry = series.find((s) => s.name === at.series);\n const point = entry?.points[at.index];\n if (!point || !Number.isFinite(point.x) || !Number.isFinite(point.y)) return null;\n return { series: at.series, index: at.index, x: point.x, y: point.y, value: point.value };\n}\n\n/** Dashed rules across the plot, with their labels at the end. */\nfunction ReferenceLines({\n lines,\n xScale,\n yScale,\n area,\n}: {\n lines: readonly ScatterReferenceLine[];\n xScale: Scale;\n yScale: Scale;\n area: { x0: number; x1: number; y0: number; y1: number };\n}) {\n return (\n <g data-reference-lines=\"\">\n {lines.map((line) => {\n const horizontal = line.axis === \"y\";\n const scale = horizontal ? yScale : xScale;\n const at = scale.project(line.value);\n const [lo, hi] = horizontal ? [area.y1, area.y0] : [area.x0, area.x1];\n if (!Number.isFinite(at) || at < Math.min(lo, hi) - 0.5 || at > Math.max(lo, hi) + 0.5) return null;\n const colour = toneColor(line.tone, \"muted\");\n return (\n <g key={`${line.axis}|${line.value}|${line.label ?? \"\"}`} data-reference-line={line.axis}>\n <line\n x1={horizontal ? area.x0 : at}\n x2={horizontal ? area.x1 : at}\n y1={horizontal ? at : area.y0}\n y2={horizontal ? at : area.y1}\n stroke={colour}\n strokeWidth={1.25}\n strokeDasharray=\"3 2\"\n />\n {line.label && (\n <text\n x={horizontal ? area.x1 - 3 : at + 3}\n y={horizontal ? at - 3 : area.y1 + 10}\n textAnchor={horizontal ? \"end\" : \"start\"}\n fontSize={9}\n fill={colour}\n >\n {line.label}\n </text>\n )}\n </g>\n );\n })}\n </g>\n );\n}\n","/**\n * Horizontal stacked bars — a per-category breakdown.\n *\n * Horizontal because the categories are free text — a defect type, a part family — and a\n * vertical axis would either truncate them or turn them sideways. Stacked because the\n * usual question is \"of this category, how many landed in each outcome\", which is a\n * proportion of a known total rather than independent counts.\n */\n\nimport { cn } from \"@vitavision/ui\";\n\n/** One category of {@link StackedBars}: a label and its segments. */\nexport interface BarRow {\n /** The category, shown truncated in a fixed-width column (full text in `title`). */\n label: string;\n /** Segments in draw order, left to right. */\n segments: { name: string; value: number; colour: string }[];\n}\n\n/** Props for {@link StackedBars}. */\nexport interface StackedBarsProps {\n /** The categories, top to bottom. */\n rows: BarRow[];\n /** Accessible name of the table. Required. */\n label: string;\n /** Extra classes for the outer element, merged with `cn`. */\n className?: string | undefined;\n}\n\n/**\n * Horizontal stacked bars, one row per category, all on one shared scale (the widest row's\n * total).\n *\n * @remarks\n * Exposed as an ARIA `table`: each row has a `rowheader` (the category) and a text cell that\n * spells every non-zero segment out as `\"<value> <name>\"`, so nothing depends on colour or\n * on bar width. A row with no non-zero segment shows its total.\n */\nexport function StackedBars({ rows, label, className }: StackedBarsProps) {\n const widest = Math.max(1, ...rows.map((row) => row.segments.reduce((total, segment) => total + segment.value, 0)));\n\n return (\n <div className={cn(\"flex flex-col gap-2\", className)} role=\"table\" aria-label={label}>\n {rows.map((row) => {\n const total = row.segments.reduce((sum, segment) => sum + segment.value, 0);\n return (\n <div key={row.label} className=\"flex items-center gap-3 text-xs\" role=\"row\">\n <span className=\"w-28 shrink-0 truncate font-mono\" role=\"rowheader\" title={row.label}>\n {row.label}\n </span>\n <div className=\"flex h-4 flex-1 overflow-hidden rounded-control bg-raised\" role=\"cell\">\n {row.segments.map((segment) =>\n segment.value === 0 ? null : (\n <div\n key={segment.name}\n className=\"h-full\"\n style={{\n width: `${(segment.value / widest) * 100}%`,\n backgroundColor: segment.colour,\n }}\n title={`${segment.name}: ${segment.value}`}\n />\n ),\n )}\n </div>\n <span className=\"w-24 shrink-0 text-right font-mono text-fg-muted\" role=\"cell\">\n {row.segments\n .filter((segment) => segment.value > 0)\n .map((segment) => `${segment.value} ${segment.name}`)\n .join(\" · \") || `${total}`}\n </span>\n </div>\n );\n })}\n </div>\n );\n}\n","/**\n * The pure core of the histogram charts: binning, bin lookup and the one path that draws\n * every bar. Nothing here touches React or the DOM.\n */\n\nimport type { PlotArea } from \"./interaction\";\nimport type { Scale } from \"./scale\";\nimport { extent, padDomain } from \"./scale\";\n\n/** Bins used when the caller does not say. */\nexport const DEFAULT_BINS = 32;\n\n/** A histogram as the chart draws it: counts over equal-width bins spanning `domain`. */\nexport interface BinnedData {\n /** One non-negative finite count per bin, left to right. */\n counts: number[];\n /** The x range the bins span, never degenerate (`low < high`). */\n domain: [number, number];\n}\n\n/** A finite, ordered, non-degenerate domain; `[0, 1]` when `domain` is unusable. */\nfunction usableDomain(low: number, high: number): [number, number] {\n return padDomain(Math.min(low, high), Math.max(low, high));\n}\n\n/**\n * Bin raw values into `bins` equal-width buckets.\n *\n * @param values - The samples. Non-finite values are ignored, and so are values outside an\n * explicit `domain` (the upper edge itself belongs to the last bin).\n * @param bins - Bucket count; a non-finite or sub-1 request falls back to 1, and `undefined`\n * to {@link DEFAULT_BINS}.\n * @param domain - The x range. Omitted: the data's extent. A single distinct value is\n * widened so it lands in a middle bin rather than on an edge.\n * @returns The counts and the domain they span.\n */\nexport function binValues(values: ArrayLike<number>, bins: number | undefined, domain?: [number, number]): BinnedData {\n const count = bins === undefined ? DEFAULT_BINS : Number.isFinite(bins) ? Math.max(1, Math.floor(bins)) : 1;\n const finite: number[] = [];\n for (let index = 0; index < values.length; index += 1) {\n const value = values[index];\n if (value !== undefined && Number.isFinite(value)) finite.push(value);\n }\n const [low, high] = domain ? usableDomain(domain[0], domain[1]) : usableDomain(...extent(finite));\n const counts = new Array<number>(count).fill(0);\n const span = high - low;\n for (const value of finite) {\n if (value < low || value > high) continue;\n const index = Math.min(count - 1, Math.floor(((value - low) / span) * count));\n counts[index] = (counts[index] ?? 0) + 1;\n }\n return { counts, domain: [low, high] };\n}\n\n/**\n * Take pre-binned counts as given, with the junk removed.\n *\n * @param counts - One count per bin, left to right.\n * @param domain - The x range the bins span.\n * @returns The counts with every non-finite or negative entry set to 0, and a usable domain.\n */\nexport function cleanCounts(counts: ArrayLike<number>, domain: [number, number]): BinnedData {\n const clean = Array.from(counts, (value) => (Number.isFinite(value) && value > 0 ? value : 0));\n return { counts: clean, domain: usableDomain(domain[0], domain[1]) };\n}\n\n/**\n * The bin containing `x`, or `null` when `x` is not finite, outside `domain`, or there are\n * no bins. The domain's upper edge belongs to the last bin.\n */\nexport function binAt(binCount: number, domain: [number, number], x: number | null | undefined): number | null {\n if (x === null || x === undefined || !Number.isFinite(x) || binCount < 1) return null;\n const [low, high] = domain;\n if (x < low || x > high) return null;\n return Math.min(binCount - 1, Math.floor(((x - low) / (high - low)) * binCount));\n}\n\n/**\n * One SVG path `d` drawing every non-empty bar as a rectangle from the baseline.\n *\n * @param counts - The bins' counts.\n * @param yScale - Maps a count to a pixel `y`.\n * @param area - The plot area; the bins fill `x0`…`x1` and stand on `y0`.\n * @param select - `{ skip: null }` (the default) draws every bar; `{ only: i }` draws just\n * bin `i`; `{ skip: i }` draws all but bin `i` — so a highlighted bin is its own path.\n */\nexport function barsPath(\n counts: readonly number[],\n yScale: Scale,\n area: PlotArea,\n select: { only: number } | { skip: number | null } = { skip: null },\n): string {\n const width = (area.x1 - area.x0) / Math.max(1, counts.length);\n // A hairline gap separates bars while they are wide enough to afford one.\n const barWidth = Math.max(0.5, width > 3 ? width - 0.5 : width);\n const parts: string[] = [];\n counts.forEach((count, index) => {\n if (count <= 0) return;\n if (\"only\" in select ? index !== select.only : index === select.skip) return;\n const x = area.x0 + index * width;\n const y = yScale.project(count);\n if (!Number.isFinite(y)) return;\n parts.push(`M${x.toFixed(2)} ${area.y0}V${y.toFixed(2)}h${barWidth.toFixed(2)}V${area.y0}z`);\n });\n return parts.join(\"\");\n}\n\n/** The largest count, at least 1, so an empty or all-zero histogram still has a y axis. */\nexport function tallest(...series: readonly (readonly number[])[]): number {\n let max = 1;\n for (const counts of series) for (const count of counts) if (count > max) max = count;\n return max;\n}\n","/**\n * The decision threshold of a histogram: a dashed rule across the plot at one x.\n */\n\nimport type { PlotArea } from \"./interaction\";\nimport type { Scale } from \"./scale\";\n\n/** A dashed vertical rule at `value`; nothing when it is missing or not finite. */\nexport function ThresholdRule({ value, xScale, area }: { value: number | undefined; xScale: Scale; area: PlotArea }) {\n if (value === undefined || !Number.isFinite(value)) return null;\n const x = xScale.project(value);\n return <line data-threshold=\"\" x1={x} x2={x} y1={area.y0} y2={area.y1} stroke=\"currentColor\" strokeWidth={1.25} strokeDasharray=\"3 2\" />;\n}\n","/**\n * A single-series histogram: one distribution, from raw values or from counts already binned.\n *\n * Raw values are binned here; counts are for the caller that cannot hand over its samples —\n * a 20 MP image's luminance is 256 numbers, not 20 million. Either way the bars are one\n * `<path>`, and the bin under `cursor` is a second one in the selection colour.\n */\n\nimport type { ReactNode } from \"react\";\n\nimport { barsPath, binAt, binValues, cleanCounts, tallest } from \"./bars\";\nimport { FLUID_DEFAULT_HEIGHT, Frame, areaFor, seriesColour, useFluidSize, type Variant } from \"./Frame\";\nimport { Bands, Markers, PlotInteraction, type InteractionProps } from \"./interaction\";\nimport { linearScale, logScale } from \"./scale\";\nimport { ThresholdRule } from \"./ThresholdRule\";\n\n/** Props every {@link Histogram} takes, whichever way its data is given. */\nexport interface HistogramOptions extends InteractionProps {\n /** Accessible name of the chart (the SVG's `aria-label`). Required. */\n label: string;\n /** x-axis title. */\n xLabel?: string | undefined;\n /** y-axis title. */\n yLabel?: string | undefined;\n /** Unit of x, appended to the x-axis title in parentheses: `luminance (DN)`. */\n unit?: string | undefined;\n /**\n * A decision threshold on x, drawn as a dashed rule across the plot (as `ScoreHistogram`\n * draws its own). Omitted or non-finite: none. For other x positions use `markers`.\n */\n threshold?: number | undefined;\n /** Counts span decades in a long-tailed distribution; a log axis keeps the tail visible. */\n logY?: boolean | undefined;\n /** Where the chart is going (see {@link Variant}). Default `\"panel\"`. */\n variant?: Variant | undefined;\n /** For `variant=\"fluid\"`: the chart's height in CSS pixels. Default 200. */\n height?: number | undefined;\n /** Rendered under the plot, inside the `<figcaption>`. */\n footer?: ReactNode;\n /** Extra classes for the outer `<figure>`, merged with `cn`. */\n className?: string | undefined;\n}\n\n/** A histogram given as raw samples, binned by the chart. */\nexport interface HistogramValues {\n /** The samples. Non-finite values, and values outside `domain`, are ignored. */\n values: ArrayLike<number>;\n /** Number of equal-width bins. Default 32. */\n bins?: number | undefined;\n /** The x range the bins span. Omitted: the extent of `values`. */\n domain?: [number, number] | undefined;\n /** Not accepted with `values` — pass one or the other. */\n counts?: undefined;\n}\n\n/** A histogram given as counts per bin, already binned by the caller. */\nexport interface HistogramCounts {\n /** One count per bin, left to right; the bins are equal-width and fill `domain`. */\n counts: ArrayLike<number>;\n /** The x range the bins span. Required: without samples there is no extent to fall back on. */\n domain: [number, number];\n /** Not accepted with `counts` — pass one or the other. */\n values?: undefined;\n}\n\n/**\n * Props for {@link Histogram}: {@link HistogramOptions} plus data as either\n * {@link HistogramValues} or {@link HistogramCounts}, never both.\n */\nexport type HistogramProps = HistogramOptions & (HistogramValues | HistogramCounts);\n\n/**\n * One distribution as a bar chart over equal-width bins.\n *\n * @remarks\n * An SVG `role=\"img\"` named by `label`. `threshold` draws a dashed decision rule, `markers`\n * tick the x axis, `bands` shade x ranges, `onHover` adds a crosshair and the x under it,\n * `onPick` reports the x of a click, and `cursor` draws the bin containing an x chosen\n * elsewhere in the selection colour (`--signal`) — no highlight when it lies outside the\n * domain. Empty data draws an empty frame. For two classes sharing a threshold use\n * {@link ScoreHistogram}.\n */\nexport function Histogram(props: HistogramProps) {\n const {\n label,\n xLabel,\n yLabel,\n unit,\n logY = false,\n variant = \"panel\",\n height = FLUID_DEFAULT_HEIGHT,\n footer,\n className,\n threshold,\n bands,\n markers,\n cursor,\n onHover,\n onPick,\n } = props;\n\n const { counts, domain } =\n props.counts !== undefined ? cleanCounts(props.counts, props.domain) : binValues(props.values, props.bins, props.domain);\n\n const [fluidRef, fluidSize] = useFluidSize(height);\n const size = variant === \"fluid\" ? fluidSize : undefined;\n const plotArea = areaFor(variant, size);\n\n const xScale = linearScale(domain, plotArea.x0, plotArea.x1);\n const top = tallest(counts);\n // Half a count of floor, so a bin of one is a visible bar on the log axis.\n const yScale = logY ? logScale([0.5, top], plotArea.y0, plotArea.y1) : linearScale([0, top], plotArea.y0, plotArea.y1);\n\n const highlighted = binAt(counts.length, domain, cursor);\n const hasHighlight = highlighted !== null && (counts[highlighted] ?? 0) > 0;\n const xTitle = [xLabel, unit ? `(${unit})` : undefined].filter(Boolean).join(\" \") || undefined;\n\n return (\n <Frame\n xScale={xScale}\n yScale={yScale}\n xLabel={xTitle}\n yLabel={yLabel}\n label={label}\n variant={variant}\n className={className}\n size={size}\n figureRef={variant === \"fluid\" ? fluidRef : undefined}\n footer={footer}\n >\n {bands && bands.length > 0 && <Bands bands={bands} xScale={xScale} area={plotArea} />}\n <path\n data-bars=\"\"\n d={barsPath(counts, yScale, plotArea, { skip: hasHighlight ? highlighted : null })}\n fill={seriesColour(0)}\n opacity={0.8}\n />\n {hasHighlight && (\n <path data-cursor-bin={highlighted} d={barsPath(counts, yScale, plotArea, { only: highlighted })} fill=\"var(--signal)\" />\n )}\n <ThresholdRule value={threshold} xScale={xScale} area={plotArea} />\n {markers && markers.length > 0 && <Markers markers={markers} xScale={xScale} area={plotArea} />}\n {(onHover || onPick) && (\n <PlotInteraction xScale={xScale} yScale={yScale} area={plotArea} series={[]} onHover={onHover} onPick={onPick} />\n )}\n </Frame>\n );\n}\n","/**\n * Score distribution by class, with a threshold drawn on it.\n *\n * This is the chart that makes a threshold decision legible: a confusion matrix says how\n * many were wrong, and this says *why* — two distributions that barely separate, or one\n * long normal tail crossing the line.\n *\n * Both classes share one set of bin edges, computed over the union of their scores. Binned\n * separately they would be drawn on different axes and the overlap — the only thing worth\n * looking at — would be an artefact of the binning.\n */\n\nimport { barsPath, tallest } from \"./bars\";\nimport { DEFECT_COLOUR, Frame, NORMAL_COLOUR, areaFor } from \"./Frame\";\nimport { extent, histogram, linearScale } from \"./scale\";\nimport { ThresholdRule } from \"./ThresholdRule\";\n\n// The histogram is always given a whole panel, never a column of a grid.\nconst plotArea = areaFor(\"wide\");\n\n// Green for normal, red for defect — the verdict tokens, named once in `Frame`.\nconst NORMAL_FILL = NORMAL_COLOUR;\nconst DEFECT_FILL = DEFECT_COLOUR;\n\n/** Props for {@link ScoreHistogram}. */\nexport interface ScoreHistogramProps {\n /** Anomaly scores of the samples labelled normal. */\n normal: number[];\n /** Anomaly scores of the samples labelled defective. */\n defect: number[];\n /** The decision threshold, drawn as a dashed vertical rule. Omitted or non-finite: none. */\n threshold?: number;\n /** Number of equal-width bins over the union of both classes' scores. Default 32. */\n bins?: number;\n /** Accessible name of the chart (the SVG's `aria-label`). Required. */\n label: string;\n /** Extra classes for the outer `<figure>`, merged with `cn`. */\n className?: string | undefined;\n}\n\n/**\n * Overlaid histograms of the normal and defect score distributions, with the threshold on\n * them.\n *\n * @remarks\n * Always the `wide` variant. Painted in the verdict tokens (`--normal`, `--defect`); the\n * legend names both classes with their counts, so the chart does not rely on colour alone.\n */\nexport function ScoreHistogram({ normal, defect, threshold, bins = 32, label, className }: ScoreHistogramProps) {\n const domain = extent([...normal, ...defect]);\n const normalBins = histogram(normal, domain, bins);\n const defectBins = histogram(defect, domain, bins);\n const top = tallest(normalBins, defectBins);\n\n const xScale = linearScale(domain, plotArea.x0, plotArea.x1);\n const yScale = linearScale([0, top], plotArea.y0, plotArea.y1);\n return (\n <Frame\n xScale={xScale}\n yScale={yScale}\n xLabel=\"anomaly score\"\n yLabel=\"samples\"\n label={label}\n variant=\"wide\"\n className={className}\n footer={\n <ul className=\"flex flex-wrap items-center gap-x-4 gap-y-1\">\n <li className=\"flex items-center gap-1.5\">\n <span aria-hidden className=\"inline-block h-2 w-3 rounded-sm\" style={{ backgroundColor: NORMAL_FILL, opacity: 0.75 }} />\n <span className=\"font-mono text-xs\">normal ({normal.length})</span>\n </li>\n <li className=\"flex items-center gap-1.5\">\n <span aria-hidden className=\"inline-block h-2 w-3 rounded-sm\" style={{ backgroundColor: DEFECT_FILL, opacity: 0.75 }} />\n <span className=\"font-mono text-xs\">defect ({defect.length})</span>\n </li>\n {threshold !== undefined && <li className=\"font-mono text-xs\">threshold {threshold.toFixed(4)}</li>}\n </ul>\n }\n >\n {/* Normals first and defects over them: the defect bars are the smaller population\n in every realistic split, so drawing them last keeps them from being buried. */}\n <path data-bars=\"\" d={barsPath(normalBins, yScale, plotArea)} fill={NORMAL_FILL} opacity={0.65} />\n <path data-bars=\"\" d={barsPath(defectBins, yScale, plotArea)} fill={DEFECT_FILL} opacity={0.65} />\n\n <ThresholdRule value={threshold} xScale={xScale} area={plotArea} />\n </Frame>\n );\n}\n","/**\n * A 1-D profile chart — intensity or value against arc length along a scan line or a\n * caliper axis.\n *\n * Built on the same `Frame` and `scale.ts` every other chart here uses, so a profile reads\n * as part of the same visual system as a training curve or a score histogram rather than a\n * one-off. The one thing a profile chart needs that a loss curve does not is a way to mark\n * *where along x a decision landed* — a detected edge, a caliper's chosen crossing — as a\n * vertical rule with its own label, independent of the series being plotted.\n */\n\nimport type { ReactNode } from \"react\";\n\nimport { FLUID_DEFAULT_HEIGHT, Frame, Legend, areaFor, seriesColour, useFluidSize } from \"./Frame\";\nimport { Bands, Markers, PlotInteraction, type InteractionProps } from \"./interaction\";\nimport type { Variant } from \"./Frame\";\nimport { extent, linePath, linearScale } from \"./scale\";\nimport { toneColor, type MeasureTone } from \"@vitavision/ui\";\n\n/** One sampled profile of a {@link LineProfile}. */\nexport interface ProfileSeries {\n /** Legend text, and the React key — unique within one chart. */\n name: string;\n /** `x` is arc length along the scan line or caliper axis, in pixels. */\n points: { x: number; y: number }[];\n /** Any CSS colour. Omitted: {@link seriesColour} of the series' index. */\n colour?: string;\n}\n\n/** A detected edge or chosen crossing, drawn as a dashed vertical rule. */\nexport interface EdgeMark {\n /** Position along the same arc-length axis as `ProfileSeries.points[].x`. */\n position: number;\n /** Text drawn above the rule, in the rule's colour. Omitted: no text. */\n label?: string;\n /** The rule's colour, as a `@vitavision/ui` measurement tone. Default `\"signal\"`. */\n tone?: MeasureTone;\n}\n\n/** Props for {@link LineProfile}. */\nexport interface LineProfileProps extends InteractionProps {\n /** The profiles, drawn in order. */\n series: ProfileSeries[];\n /** Detected edge positions, drawn as vertical rules over the series. */\n edges?: EdgeMark[];\n /** Accessible name of the chart (the SVG's `aria-label`). Required. */\n label: string;\n /** x-axis title. Default `\"arc length (px)\"`. */\n xLabel?: string;\n /** y-axis title. Default `\"value\"`. */\n yLabel?: string;\n /** Fixed x domain. Omitted: the extent of every point's `x` and every edge's position. */\n xDomain?: [number, number];\n /** Fixed y domain. Omitted: the extent of every point's `y`. */\n yDomain?: [number, number];\n /** Rendered under the legend, inside the `<figcaption>`. */\n footer?: ReactNode;\n /** Show the legend row when there is more than one series. Default `true`. */\n showLegend?: boolean;\n /** Where the chart is going (see {@link Variant}). Default `\"wide\"`. */\n variant?: Variant;\n /** Extra classes for the outer `<figure>`, merged with `cn`. */\n className?: string | undefined;\n /** For `variant=\"fluid\"`: the chart's height in CSS pixels. Default 200. */\n height?: number | undefined;\n}\n\n/**\n * One or more series against arc length along a scan line or caliper axis, with detected\n * edges as labelled vertical rules.\n *\n * @remarks\n * An SVG `role=\"img\"` named by `label`. The legend appears only for two or more series — a\n * single profile is named by the chart's label. `bands`, `markers`, `cursor`, `onHover` and\n * `onPick` work as on `LineChart`: a caliper's profile can follow the canvas, and a click\n * can pick a position along it.\n */\nexport function LineProfile({\n series,\n edges = [],\n label,\n xLabel = \"arc length (px)\",\n yLabel = \"value\",\n xDomain,\n yDomain,\n footer,\n showLegend = true,\n variant = \"wide\",\n className,\n height = FLUID_DEFAULT_HEIGHT,\n bands,\n markers,\n cursor,\n onHover,\n onPick,\n}: LineProfileProps) {\n const allX = [...series.flatMap((entry) => entry.points.map((point) => point.x)), ...edges.map((edge) => edge.position)];\n const allY = series.flatMap((entry) => entry.points.map((point) => point.y));\n const [fluidRef, fluidSize] = useFluidSize(height);\n const size = variant === \"fluid\" ? fluidSize : undefined;\n const plotArea = areaFor(variant, size);\n\n const xScale = linearScale(xDomain ?? extent(allX), plotArea.x0, plotArea.x1);\n const yScale = linearScale(yDomain ?? extent(allY), plotArea.y0, plotArea.y1);\n\n const coloured = series.map((entry, index) => ({\n ...entry,\n colour: entry.colour ?? seriesColour(index),\n }));\n\n return (\n <Frame\n xScale={xScale}\n yScale={yScale}\n xLabel={xLabel}\n yLabel={yLabel}\n label={label}\n variant={variant}\n className={className}\n size={size}\n figureRef={variant === \"fluid\" ? fluidRef : undefined}\n footer={\n <div className=\"flex flex-col gap-1\">\n {showLegend && series.length > 1 && <Legend items={coloured.map((entry) => ({ label: entry.name, colour: entry.colour }))} />}\n {footer}\n </div>\n }\n >\n {bands && bands.length > 0 && <Bands bands={bands} xScale={xScale} area={plotArea} />}\n {coloured.map((entry) =>\n entry.points.length === 1 ? (\n <circle\n key={entry.name}\n cx={xScale.project(entry.points[0]?.x ?? 0)}\n cy={yScale.project(entry.points[0]?.y ?? 0)}\n r={2.5}\n fill={entry.colour}\n />\n ) : (\n <path\n key={entry.name}\n d={linePath(entry.points, xScale, yScale)}\n fill=\"none\"\n stroke={entry.colour}\n strokeWidth={1.5}\n strokeLinejoin=\"round\"\n vectorEffect=\"non-scaling-stroke\"\n />\n ),\n )}\n\n {edges.map((edge) => {\n const x = xScale.project(edge.position);\n const colour = toneColor(edge.tone, \"signal\");\n return (\n <g key={`${edge.position}-${edge.label ?? \"\"}-${edge.tone ?? \"\"}`}>\n <line x1={x} x2={x} y1={plotArea.y0} y2={plotArea.y1} stroke={colour} strokeWidth={1.25} strokeDasharray=\"3 2\" />\n {edge.label && (\n <text x={x} y={plotArea.y1 - 3} textAnchor=\"middle\" fontSize={9} fill={colour}>\n {edge.label}\n </text>\n )}\n </g>\n );\n })}\n {markers && markers.length > 0 && <Markers markers={markers} xScale={xScale} area={plotArea} />}\n {(onHover || onPick || cursor !== undefined) && (\n <PlotInteraction\n xScale={xScale}\n yScale={yScale}\n area={plotArea}\n series={coloured}\n cursor={cursor}\n onHover={onHover}\n onPick={onPick}\n />\n )}\n </Frame>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkCA,MAAM,sBAAsB;;AAE5B,MAAa,uBAAuB;AAEpC,MAAM,WAAW;CACf,OAAO;EAAE,OAAO;EAAK,QAAQ;CAAI;CACjC,MAAM;EAAE,OAAO;EAAK,QAAQ;CAAI;AAClC;AAEA,MAAM,SAAS;CAAE,MAAM;CAAI,OAAO;CAAI,KAAK;CAAI,QAAQ;AAAG;;;;;;;;;;AAW1D,SAAgB,QAAQ,SAAkB,MAA0C;CAClF,MAAM,EAAE,OAAO,WACb,YAAY,UAAW,QAAQ;EAAE,OAAO;EAAqB,QAAA;CAA6B,IAAK,SAAS;CAC1G,OAAO;EACL,IAAI,OAAO;EACX,IAAI,QAAQ,OAAO;EACnB,IAAI,SAAS,OAAO;EACpB,IAAI,OAAO;EACX;EACA;CACF;AACF;;AAGA,MAAa,WAAW,QAAQ,OAAO;;;;;;;;AASvC,SAAgB,aACd,SAAA,KAC4E;CAC5E,MAAM,CAAC,OAAO,YAAY,SAAS,mBAAmB;CAWtD,OAAO,CAVK,aAAa,YAAgC;EACvD,IAAI,CAAC,SAAS;EACd,MAAM,WAAW,MAAc;GAC7B,IAAI,IAAI,GAAG,SAAS,KAAK,MAAM,CAAC,CAAC;EACnC;EACA,QAAQ,QAAQ,sBAAsB,CAAC,CAAC,KAAK;EAC7C,MAAM,WAAW,IAAI,gBAAgB,YAAY,QAAQ,QAAQ,EAAE,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S;KAAG,GAAG,SAAS,KAAK;KAAG,YAAW;KAAS,UAAU;KAAG,MAAM;KACpE,UAAA,KAAK;IACF,CAAA,CAEP,EAAA,GAPK,GAAG,KAAK,SAAS,GAAG,KAAK,SAAS,GAAG,GAAG,KAAK,QAAQ,IAO1D;GAEP,CAAC;GACA,WAAW,QAAQ,SAAS,KAAK,oBAAC,SAAD;IAAkB;IAAiB;IAAQ,MAAM;GAAW,CAAA;IAC5F,WAAW,UAAU,WAAW,KAAA,MAChC,oBAAC,iBAAD;IACU;IACA;IACR,MAAM;IACN,QAAQ;IACA;IACC;IACD;GACT,CAAA;EAEE;;AAEX"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitavision/charts",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"description": "Small SVG charts on @vitavision/ui: histogram, line, bar, line profile, scales, colour maps, hover and pick.",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"react-dom": "^19.2.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@vitavision/ui": "^0.14.
|
|
49
|
+
"@vitavision/ui": "^0.14.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@storybook/react-vite": "10.6.0",
|