@vitavision/charts 0.8.0 → 0.8.3
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 +2 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/BarChart.tsx +2 -8
- package/src/ColormapLegend.tsx +1 -2
- package/src/Frame.tsx +12 -66
- package/src/Histogram.tsx +3 -16
- package/src/LineChart.tsx +1 -5
- package/src/LineProfile.tsx +2 -14
- package/src/ScoreHistogram.tsx +4 -21
- package/src/ThresholdRule.tsx +1 -12
- package/src/bars.ts +1 -5
- package/src/colormap.ts +2 -6
- package/src/index.ts +4 -33
- package/src/scale.ts +5 -21
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @vitavision/charts
|
|
2
2
|
|
|
3
|
-
Small, hand-rolled SVG charts for the vitavision
|
|
3
|
+
Small, hand-rolled SVG charts for the vitavision apps, on `@vitavision/ui` tokens.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
bun add @vitavision/charts @vitavision/ui
|
|
@@ -35,8 +35,7 @@ along a scan line or caliper axis, with detected edges drawn as labelled vertica
|
|
|
35
35
|
|
|
36
36
|
**Sequential colour maps**: `colormap("viridis" | "cividis", t)` and
|
|
37
37
|
`colormapValue(map, value, domain)`, for a magnitude such as an error, a validity or a
|
|
38
|
-
confidence. `ColormapLegend` shows the scale with its units; a map is never shown without one
|
|
39
|
-
(visual-language §4).
|
|
38
|
+
confidence. `ColormapLegend` shows the scale with its units; a map is never shown without one.
|
|
40
39
|
|
|
41
40
|
## License
|
|
42
41
|
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { MeasureTone } from "@vitavision/ui";
|
|
|
5
5
|
* The arithmetic behind every chart: domains, ticks, and the map from a value to a pixel.
|
|
6
6
|
*
|
|
7
7
|
* Hand-rolled SVG rather than a charting library: the chart types this design system needs
|
|
8
|
-
* are few and simple, and a library that lags the React and Tailwind versions the
|
|
8
|
+
* are few and simple, and a library that lags the React and Tailwind versions the apps
|
|
9
9
|
* are deliberately on would mean either downgrading a consumer or isolating a laggard — a
|
|
10
10
|
* cost that outweighs a few hundred lines of scale maths.
|
|
11
11
|
*
|
|
@@ -227,7 +227,7 @@ export declare function Legend({ items, className }: LegendProps): import("react
|
|
|
227
227
|
* a neutral grey as the sixth — and only its lightness changes, so every colour holds 3:1
|
|
228
228
|
* against the panel in both. The six stay distinguishable under simulated protanopia,
|
|
229
229
|
* deuteranopia and tritanopia, and none of them is a verdict colour (`--normal`,
|
|
230
|
-
* `--defect`, `--warn`): a series is never read as a verdict
|
|
230
|
+
* `--defect`, `--warn`): a series is never read as a verdict.
|
|
231
231
|
*
|
|
232
232
|
* Before 0.6 these were fixed hex strings; the names are unchanged.
|
|
233
233
|
*/
|
|
@@ -615,7 +615,7 @@ export declare function LineProfile({ series, edges, label, xLabel, yLabel, xDom
|
|
|
615
615
|
//#endregion
|
|
616
616
|
//#region src/colormap.d.ts
|
|
617
617
|
/**
|
|
618
|
-
* Sequential colour maps for a magnitude
|
|
618
|
+
* Sequential colour maps for a magnitude: a residual's size, a per-cell
|
|
619
619
|
* error, a confidence, a validity fraction.
|
|
620
620
|
*
|
|
621
621
|
* Only perceptually uniform maps ship, so equal steps in the data look like equal steps.
|
package/dist/index.js
CHANGED
|
@@ -226,7 +226,7 @@ function Legend({ items, className }) {
|
|
|
226
226
|
* a neutral grey as the sixth — and only its lightness changes, so every colour holds 3:1
|
|
227
227
|
* against the panel in both. The six stay distinguishable under simulated protanopia,
|
|
228
228
|
* deuteranopia and tritanopia, and none of them is a verdict colour (`--normal`,
|
|
229
|
-
* `--defect`, `--warn`): a series is never read as a verdict
|
|
229
|
+
* `--defect`, `--warn`): a series is never read as a verdict.
|
|
230
230
|
*
|
|
231
231
|
* Before 0.6 these were fixed hex strings; the names are unchanged.
|
|
232
232
|
*/
|
|
@@ -1269,8 +1269,7 @@ function colormapGradient(name, direction = "to right") {
|
|
|
1269
1269
|
//#endregion
|
|
1270
1270
|
//#region src/ColormapLegend.tsx
|
|
1271
1271
|
/**
|
|
1272
|
-
* The scale of a colour map, shown beside the map:
|
|
1273
|
-
* map to show its scale, with units.
|
|
1272
|
+
* The scale of a colour map, shown beside the map: every chart or map shows its scale, with units.
|
|
1274
1273
|
*/
|
|
1275
1274
|
/**
|
|
1276
1275
|
* A gradient bar with its end values and unit, read as one line: "Edge error 0 [bar] 2.5 px".
|
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(height: number = FLUID_DEFAULT_HEIGHT): [\n (element: HTMLElement | null) => void,\n { width: number; height: number },\n] {\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\n role=\"img\"\n aria-label={label}\n viewBox={`0 0 ${PLOT.width} ${PLOT.height}`}\n className=\"w-full\"\n >\n {vertical.map((tick) => {\n const y = yScale.project(tick.value);\n return (\n <g key={`y-${tick.value}`}>\n <line\n x1={plotArea.x0}\n x2={plotArea.x1}\n y1={y}\n y2={y}\n stroke={AXIS}\n strokeWidth={0.5}\n opacity={0.25}\n />\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\n x1={x}\n x2={x}\n y1={plotArea.y0}\n y2={plotArea.y1}\n stroke={AXIS}\n strokeWidth={0.5}\n opacity={0.15}\n />\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\n x1={plotArea.x0}\n x2={plotArea.x1}\n y1={plotArea.y0}\n y2={plotArea.y0}\n stroke={AXIS}\n strokeWidth={1}\n opacity={0.6}\n />\n <line\n x1={plotArea.x0}\n x2={plotArea.x0}\n y1={plotArea.y0}\n y2={plotArea.y1}\n stroke={AXIS}\n strokeWidth={1}\n opacity={0.6}\n />\n\n {children}\n\n {xLabel && (\n <text\n x={(plotArea.x0 + plotArea.x1) / 2}\n y={PLOT.height - 2}\n textAnchor=\"middle\"\n fontSize={10}\n fill={AXIS}\n >\n {xLabel}\n </text>\n )}\n {yLabel && (\n <text\n transform={`translate(10 ${(plotArea.y0 + plotArea.y1) / 2}) rotate(-90)`}\n textAnchor=\"middle\"\n fontSize={10}\n fill={AXIS}\n >\n {yLabel}\n </text>\n )}\n </svg>\n {footer && <figcaption className=\"text-xs\">{footer}</figcaption>}\n </figure>\n );\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\n aria-hidden\n className=\"inline-block h-0.5 w-4 rounded-full\"\n style={{ backgroundColor: item.colour }}\n />\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 (PLAN §5).\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 lab 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(\n domain: [number, number],\n rangeStart: number,\n rangeEnd: number,\n): 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 (\n let exponent = Math.ceil(paddedLow);\n exponent <= paddedHigh + 1e-9;\n exponent += stride\n ) {\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(\n points: readonly { x: number; y: number }[],\n xScale: Scale,\n yScale: Scale,\n): 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(\n values: readonly number[],\n domain: [number, number],\n count: number,\n): 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 && (\n <Legend\n items={coloured.map((entry) => ({ label: entry.name, colour: entry.colour }))}\n />\n )}\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(\n 1,\n ...rows.map((row) => row.segments.reduce((total, segment) => total + segment.value, 0)),\n );\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\n className=\"flex h-4 flex-1 overflow-hidden rounded-control bg-raised\"\n role=\"cell\"\n >\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(\n values: ArrayLike<number>,\n bins: number | undefined,\n domain?: [number, number],\n): 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 (\n <line\n data-threshold=\"\"\n x1={x}\n x2={x}\n y1={area.y0}\n y2={area.y1}\n stroke=\"currentColor\"\n strokeWidth={1.25}\n strokeDasharray=\"3 2\"\n />\n );\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\n ? cleanCounts(props.counts, props.domain)\n : 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\n data-cursor-bin={highlighted}\n d={barsPath(counts, yScale, plotArea, { only: highlighted })}\n fill=\"var(--signal)\"\n />\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\n xScale={xScale}\n yScale={yScale}\n area={plotArea}\n series={[]}\n onHover={onHover}\n onPick={onPick}\n />\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({\n normal,\n defect,\n threshold,\n bins = 32,\n label,\n className,\n}: 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\n aria-hidden\n className=\"inline-block h-2 w-3 rounded-sm\"\n style={{ backgroundColor: NORMAL_FILL, opacity: 0.75 }}\n />\n <span className=\"font-mono text-xs\">normal ({normal.length})</span>\n </li>\n <li className=\"flex items-center gap-1.5\">\n <span\n aria-hidden\n className=\"inline-block h-2 w-3 rounded-sm\"\n style={{ backgroundColor: DEFECT_FILL, opacity: 0.75 }}\n />\n <span className=\"font-mono text-xs\">defect ({defect.length})</span>\n </li>\n {threshold !== undefined && (\n <li className=\"font-mono text-xs\">threshold {threshold.toFixed(4)}</li>\n )}\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 && (\n <Legend\n items={coloured.map((entry) => ({ label: entry.name, colour: entry.colour }))}\n />\n )}\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\n x1={x}\n x2={x}\n y1={plotArea.y0}\n y2={plotArea.y1}\n stroke={colour}\n strokeWidth={1.25}\n strokeDasharray=\"3 2\"\n />\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 (visual-language §4): 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 [\n Math.round(a[0] + f * (b[0] - a[0])),\n Math.round(a[1] + f * (b[1] - a[1])),\n Math.round(a[2] + f * (b[2] - a[2])),\n ];\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: visual-language §4 requires every chart or\n * map to show 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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AM,UAAU,QAAQ;CAExB,OAAO,mBAAmB,UAAU,IADtB,QAAQ,KAAK,CAAC,GAAG,GAAG,IAAI,MAAM,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,KAAM,KAAK,QAAQ,SAAS,KAAM,IAAA,CAAK,QAAQ,CAAC,EAAE,EACrE,CAAC,CAAC,KAAK,IAAI,EAAE;AAC3D;;;;;;;;;;;AC/EA,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/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;C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8.3",
|
|
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": {
|
|
7
7
|
"type": "git",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"react-dom": "^19.2.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@vitavision/ui": "^0.
|
|
49
|
+
"@vitavision/ui": "^0.14.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@storybook/react-vite": "10.6.0",
|
package/src/BarChart.tsx
CHANGED
|
@@ -37,10 +37,7 @@ export interface StackedBarsProps {
|
|
|
37
37
|
* on bar width. A row with no non-zero segment shows its total.
|
|
38
38
|
*/
|
|
39
39
|
export function StackedBars({ rows, label, className }: StackedBarsProps) {
|
|
40
|
-
const widest = Math.max(
|
|
41
|
-
1,
|
|
42
|
-
...rows.map((row) => row.segments.reduce((total, segment) => total + segment.value, 0)),
|
|
43
|
-
);
|
|
40
|
+
const widest = Math.max(1, ...rows.map((row) => row.segments.reduce((total, segment) => total + segment.value, 0)));
|
|
44
41
|
|
|
45
42
|
return (
|
|
46
43
|
<div className={cn("flex flex-col gap-2", className)} role="table" aria-label={label}>
|
|
@@ -51,10 +48,7 @@ export function StackedBars({ rows, label, className }: StackedBarsProps) {
|
|
|
51
48
|
<span className="w-28 shrink-0 truncate font-mono" role="rowheader" title={row.label}>
|
|
52
49
|
{row.label}
|
|
53
50
|
</span>
|
|
54
|
-
<div
|
|
55
|
-
className="flex h-4 flex-1 overflow-hidden rounded-control bg-raised"
|
|
56
|
-
role="cell"
|
|
57
|
-
>
|
|
51
|
+
<div className="flex h-4 flex-1 overflow-hidden rounded-control bg-raised" role="cell">
|
|
58
52
|
{row.segments.map((segment) =>
|
|
59
53
|
segment.value === 0 ? null : (
|
|
60
54
|
<div
|
package/src/ColormapLegend.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The scale of a colour map, shown beside the map:
|
|
3
|
-
* map to show its scale, with units.
|
|
2
|
+
* The scale of a colour map, shown beside the map: every chart or map shows its scale, with units.
|
|
4
3
|
*/
|
|
5
4
|
|
|
6
5
|
import { cn } from "@vitavision/ui";
|
package/src/Frame.tsx
CHANGED
|
@@ -75,10 +75,9 @@ export const plotArea = areaFor("panel");
|
|
|
75
75
|
* @returns `[ref, size]`. Attach `ref` to the element whose width the chart takes (the
|
|
76
76
|
* `Frame`'s `figureRef`). The size is a 480 px-wide default until the first measure.
|
|
77
77
|
*/
|
|
78
|
-
export function useFluidSize(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
] {
|
|
78
|
+
export function useFluidSize(
|
|
79
|
+
height: number = FLUID_DEFAULT_HEIGHT,
|
|
80
|
+
): [(element: HTMLElement | null) => void, { width: number; height: number }] {
|
|
82
81
|
const [width, setWidth] = useState(FLUID_INITIAL_WIDTH);
|
|
83
82
|
const ref = useCallback((element: HTMLElement | null) => {
|
|
84
83
|
if (!element) return;
|
|
@@ -155,25 +154,12 @@ export function Frame({
|
|
|
155
154
|
|
|
156
155
|
return (
|
|
157
156
|
<figure ref={figureRef} className={cn("flex flex-col gap-1 text-fg-muted", className)}>
|
|
158
|
-
<svg
|
|
159
|
-
role="img"
|
|
160
|
-
aria-label={label}
|
|
161
|
-
viewBox={`0 0 ${PLOT.width} ${PLOT.height}`}
|
|
162
|
-
className="w-full"
|
|
163
|
-
>
|
|
157
|
+
<svg role="img" aria-label={label} viewBox={`0 0 ${PLOT.width} ${PLOT.height}`} className="w-full">
|
|
164
158
|
{vertical.map((tick) => {
|
|
165
159
|
const y = yScale.project(tick.value);
|
|
166
160
|
return (
|
|
167
161
|
<g key={`y-${tick.value}`}>
|
|
168
|
-
<line
|
|
169
|
-
x1={plotArea.x0}
|
|
170
|
-
x2={plotArea.x1}
|
|
171
|
-
y1={y}
|
|
172
|
-
y2={y}
|
|
173
|
-
stroke={AXIS}
|
|
174
|
-
strokeWidth={0.5}
|
|
175
|
-
opacity={0.25}
|
|
176
|
-
/>
|
|
162
|
+
<line x1={plotArea.x0} x2={plotArea.x1} y1={y} y2={y} stroke={AXIS} strokeWidth={0.5} opacity={0.25} />
|
|
177
163
|
<text x={plotArea.x0 - 6} y={y + 3.5} textAnchor="end" fontSize={10} fill={AXIS}>
|
|
178
164
|
{tick.label}
|
|
179
165
|
</text>
|
|
@@ -185,15 +171,7 @@ export function Frame({
|
|
|
185
171
|
const x = xScale.project(tick.value);
|
|
186
172
|
return (
|
|
187
173
|
<g key={`x-${tick.value}`}>
|
|
188
|
-
<line
|
|
189
|
-
x1={x}
|
|
190
|
-
x2={x}
|
|
191
|
-
y1={plotArea.y0}
|
|
192
|
-
y2={plotArea.y1}
|
|
193
|
-
stroke={AXIS}
|
|
194
|
-
strokeWidth={0.5}
|
|
195
|
-
opacity={0.15}
|
|
196
|
-
/>
|
|
174
|
+
<line x1={x} x2={x} y1={plotArea.y0} y2={plotArea.y1} stroke={AXIS} strokeWidth={0.5} opacity={0.15} />
|
|
197
175
|
<text x={x} y={plotArea.y0 + 14} textAnchor="middle" fontSize={10} fill={AXIS}>
|
|
198
176
|
{tick.label}
|
|
199
177
|
</text>
|
|
@@ -201,45 +179,18 @@ export function Frame({
|
|
|
201
179
|
);
|
|
202
180
|
})}
|
|
203
181
|
|
|
204
|
-
<line
|
|
205
|
-
|
|
206
|
-
x2={plotArea.x1}
|
|
207
|
-
y1={plotArea.y0}
|
|
208
|
-
y2={plotArea.y0}
|
|
209
|
-
stroke={AXIS}
|
|
210
|
-
strokeWidth={1}
|
|
211
|
-
opacity={0.6}
|
|
212
|
-
/>
|
|
213
|
-
<line
|
|
214
|
-
x1={plotArea.x0}
|
|
215
|
-
x2={plotArea.x0}
|
|
216
|
-
y1={plotArea.y0}
|
|
217
|
-
y2={plotArea.y1}
|
|
218
|
-
stroke={AXIS}
|
|
219
|
-
strokeWidth={1}
|
|
220
|
-
opacity={0.6}
|
|
221
|
-
/>
|
|
182
|
+
<line x1={plotArea.x0} x2={plotArea.x1} y1={plotArea.y0} y2={plotArea.y0} stroke={AXIS} strokeWidth={1} opacity={0.6} />
|
|
183
|
+
<line x1={plotArea.x0} x2={plotArea.x0} y1={plotArea.y0} y2={plotArea.y1} stroke={AXIS} strokeWidth={1} opacity={0.6} />
|
|
222
184
|
|
|
223
185
|
{children}
|
|
224
186
|
|
|
225
187
|
{xLabel && (
|
|
226
|
-
<text
|
|
227
|
-
x={(plotArea.x0 + plotArea.x1) / 2}
|
|
228
|
-
y={PLOT.height - 2}
|
|
229
|
-
textAnchor="middle"
|
|
230
|
-
fontSize={10}
|
|
231
|
-
fill={AXIS}
|
|
232
|
-
>
|
|
188
|
+
<text x={(plotArea.x0 + plotArea.x1) / 2} y={PLOT.height - 2} textAnchor="middle" fontSize={10} fill={AXIS}>
|
|
233
189
|
{xLabel}
|
|
234
190
|
</text>
|
|
235
191
|
)}
|
|
236
192
|
{yLabel && (
|
|
237
|
-
<text
|
|
238
|
-
transform={`translate(10 ${(plotArea.y0 + plotArea.y1) / 2}) rotate(-90)`}
|
|
239
|
-
textAnchor="middle"
|
|
240
|
-
fontSize={10}
|
|
241
|
-
fill={AXIS}
|
|
242
|
-
>
|
|
193
|
+
<text transform={`translate(10 ${(plotArea.y0 + plotArea.y1) / 2}) rotate(-90)`} textAnchor="middle" fontSize={10} fill={AXIS}>
|
|
243
194
|
{yLabel}
|
|
244
195
|
</text>
|
|
245
196
|
)}
|
|
@@ -249,7 +200,6 @@ export function Frame({
|
|
|
249
200
|
);
|
|
250
201
|
}
|
|
251
202
|
|
|
252
|
-
|
|
253
203
|
/** One entry of a {@link Legend}. */
|
|
254
204
|
export interface LegendItem {
|
|
255
205
|
/** The series name, rendered as text — it is what a screen reader announces. */
|
|
@@ -279,11 +229,7 @@ export function Legend({ items, className }: LegendProps) {
|
|
|
279
229
|
<ul className={cn("flex flex-wrap items-center gap-x-4 gap-y-1", className)}>
|
|
280
230
|
{items.map((item) => (
|
|
281
231
|
<li key={item.label} className="flex items-center gap-1.5">
|
|
282
|
-
<span
|
|
283
|
-
aria-hidden
|
|
284
|
-
className="inline-block h-0.5 w-4 rounded-full"
|
|
285
|
-
style={{ backgroundColor: item.colour }}
|
|
286
|
-
/>
|
|
232
|
+
<span aria-hidden className="inline-block h-0.5 w-4 rounded-full" style={{ backgroundColor: item.colour }} />
|
|
287
233
|
<span className="font-mono text-xs">{item.label}</span>
|
|
288
234
|
</li>
|
|
289
235
|
))}
|
|
@@ -304,7 +250,7 @@ export function Legend({ items, className }: LegendProps) {
|
|
|
304
250
|
* a neutral grey as the sixth — and only its lightness changes, so every colour holds 3:1
|
|
305
251
|
* against the panel in both. The six stay distinguishable under simulated protanopia,
|
|
306
252
|
* deuteranopia and tritanopia, and none of them is a verdict colour (`--normal`,
|
|
307
|
-
* `--defect`, `--warn`): a series is never read as a verdict
|
|
253
|
+
* `--defect`, `--warn`): a series is never read as a verdict.
|
|
308
254
|
*
|
|
309
255
|
* Before 0.6 these were fixed hex strings; the names are unchanged.
|
|
310
256
|
*/
|
package/src/Histogram.tsx
CHANGED
|
@@ -100,9 +100,7 @@ export function Histogram(props: HistogramProps) {
|
|
|
100
100
|
} = props;
|
|
101
101
|
|
|
102
102
|
const { counts, domain } =
|
|
103
|
-
props.counts !== undefined
|
|
104
|
-
? cleanCounts(props.counts, props.domain)
|
|
105
|
-
: binValues(props.values, props.bins, props.domain);
|
|
103
|
+
props.counts !== undefined ? cleanCounts(props.counts, props.domain) : binValues(props.values, props.bins, props.domain);
|
|
106
104
|
|
|
107
105
|
const [fluidRef, fluidSize] = useFluidSize(height);
|
|
108
106
|
const size = variant === "fluid" ? fluidSize : undefined;
|
|
@@ -138,23 +136,12 @@ export function Histogram(props: HistogramProps) {
|
|
|
138
136
|
opacity={0.8}
|
|
139
137
|
/>
|
|
140
138
|
{hasHighlight && (
|
|
141
|
-
<path
|
|
142
|
-
data-cursor-bin={highlighted}
|
|
143
|
-
d={barsPath(counts, yScale, plotArea, { only: highlighted })}
|
|
144
|
-
fill="var(--signal)"
|
|
145
|
-
/>
|
|
139
|
+
<path data-cursor-bin={highlighted} d={barsPath(counts, yScale, plotArea, { only: highlighted })} fill="var(--signal)" />
|
|
146
140
|
)}
|
|
147
141
|
<ThresholdRule value={threshold} xScale={xScale} area={plotArea} />
|
|
148
142
|
{markers && markers.length > 0 && <Markers markers={markers} xScale={xScale} area={plotArea} />}
|
|
149
143
|
{(onHover || onPick) && (
|
|
150
|
-
<PlotInteraction
|
|
151
|
-
xScale={xScale}
|
|
152
|
-
yScale={yScale}
|
|
153
|
-
area={plotArea}
|
|
154
|
-
series={[]}
|
|
155
|
-
onHover={onHover}
|
|
156
|
-
onPick={onPick}
|
|
157
|
-
/>
|
|
144
|
+
<PlotInteraction xScale={xScale} yScale={yScale} area={plotArea} series={[]} onHover={onHover} onPick={onPick} />
|
|
158
145
|
)}
|
|
159
146
|
</Frame>
|
|
160
147
|
);
|
package/src/LineChart.tsx
CHANGED
|
@@ -115,11 +115,7 @@ export function LineChart({
|
|
|
115
115
|
figureRef={variant === "fluid" ? fluidRef : undefined}
|
|
116
116
|
footer={
|
|
117
117
|
<div className="flex flex-col gap-1">
|
|
118
|
-
{showLegend && (
|
|
119
|
-
<Legend
|
|
120
|
-
items={coloured.map((entry) => ({ label: entry.name, colour: entry.colour }))}
|
|
121
|
-
/>
|
|
122
|
-
)}
|
|
118
|
+
{showLegend && <Legend items={coloured.map((entry) => ({ label: entry.name, colour: entry.colour }))} />}
|
|
123
119
|
{footer}
|
|
124
120
|
</div>
|
|
125
121
|
}
|
package/src/LineProfile.tsx
CHANGED
|
@@ -121,11 +121,7 @@ export function LineProfile({
|
|
|
121
121
|
figureRef={variant === "fluid" ? fluidRef : undefined}
|
|
122
122
|
footer={
|
|
123
123
|
<div className="flex flex-col gap-1">
|
|
124
|
-
{showLegend && series.length > 1 && (
|
|
125
|
-
<Legend
|
|
126
|
-
items={coloured.map((entry) => ({ label: entry.name, colour: entry.colour }))}
|
|
127
|
-
/>
|
|
128
|
-
)}
|
|
124
|
+
{showLegend && series.length > 1 && <Legend items={coloured.map((entry) => ({ label: entry.name, colour: entry.colour }))} />}
|
|
129
125
|
{footer}
|
|
130
126
|
</div>
|
|
131
127
|
}
|
|
@@ -158,15 +154,7 @@ export function LineProfile({
|
|
|
158
154
|
const colour = toneColor(edge.tone, "signal");
|
|
159
155
|
return (
|
|
160
156
|
<g key={`${edge.position}-${edge.label ?? ""}-${edge.tone ?? ""}`}>
|
|
161
|
-
<line
|
|
162
|
-
x1={x}
|
|
163
|
-
x2={x}
|
|
164
|
-
y1={plotArea.y0}
|
|
165
|
-
y2={plotArea.y1}
|
|
166
|
-
stroke={colour}
|
|
167
|
-
strokeWidth={1.25}
|
|
168
|
-
strokeDasharray="3 2"
|
|
169
|
-
/>
|
|
157
|
+
<line x1={x} x2={x} y1={plotArea.y0} y2={plotArea.y1} stroke={colour} strokeWidth={1.25} strokeDasharray="3 2" />
|
|
170
158
|
{edge.label && (
|
|
171
159
|
<text x={x} y={plotArea.y1 - 3} textAnchor="middle" fontSize={9} fill={colour}>
|
|
172
160
|
{edge.label}
|
package/src/ScoreHistogram.tsx
CHANGED
|
@@ -46,14 +46,7 @@ export interface ScoreHistogramProps {
|
|
|
46
46
|
* Always the `wide` variant. Painted in the verdict tokens (`--normal`, `--defect`); the
|
|
47
47
|
* legend names both classes with their counts, so the chart does not rely on colour alone.
|
|
48
48
|
*/
|
|
49
|
-
export function ScoreHistogram({
|
|
50
|
-
normal,
|
|
51
|
-
defect,
|
|
52
|
-
threshold,
|
|
53
|
-
bins = 32,
|
|
54
|
-
label,
|
|
55
|
-
className,
|
|
56
|
-
}: ScoreHistogramProps) {
|
|
49
|
+
export function ScoreHistogram({ normal, defect, threshold, bins = 32, label, className }: ScoreHistogramProps) {
|
|
57
50
|
const domain = extent([...normal, ...defect]);
|
|
58
51
|
const normalBins = histogram(normal, domain, bins);
|
|
59
52
|
const defectBins = histogram(defect, domain, bins);
|
|
@@ -73,24 +66,14 @@ export function ScoreHistogram({
|
|
|
73
66
|
footer={
|
|
74
67
|
<ul className="flex flex-wrap items-center gap-x-4 gap-y-1">
|
|
75
68
|
<li className="flex items-center gap-1.5">
|
|
76
|
-
<span
|
|
77
|
-
aria-hidden
|
|
78
|
-
className="inline-block h-2 w-3 rounded-sm"
|
|
79
|
-
style={{ backgroundColor: NORMAL_FILL, opacity: 0.75 }}
|
|
80
|
-
/>
|
|
69
|
+
<span aria-hidden className="inline-block h-2 w-3 rounded-sm" style={{ backgroundColor: NORMAL_FILL, opacity: 0.75 }} />
|
|
81
70
|
<span className="font-mono text-xs">normal ({normal.length})</span>
|
|
82
71
|
</li>
|
|
83
72
|
<li className="flex items-center gap-1.5">
|
|
84
|
-
<span
|
|
85
|
-
aria-hidden
|
|
86
|
-
className="inline-block h-2 w-3 rounded-sm"
|
|
87
|
-
style={{ backgroundColor: DEFECT_FILL, opacity: 0.75 }}
|
|
88
|
-
/>
|
|
73
|
+
<span aria-hidden className="inline-block h-2 w-3 rounded-sm" style={{ backgroundColor: DEFECT_FILL, opacity: 0.75 }} />
|
|
89
74
|
<span className="font-mono text-xs">defect ({defect.length})</span>
|
|
90
75
|
</li>
|
|
91
|
-
{threshold !== undefined && (
|
|
92
|
-
<li className="font-mono text-xs">threshold {threshold.toFixed(4)}</li>
|
|
93
|
-
)}
|
|
76
|
+
{threshold !== undefined && <li className="font-mono text-xs">threshold {threshold.toFixed(4)}</li>}
|
|
94
77
|
</ul>
|
|
95
78
|
}
|
|
96
79
|
>
|
package/src/ThresholdRule.tsx
CHANGED
|
@@ -9,16 +9,5 @@ import type { Scale } from "./scale";
|
|
|
9
9
|
export function ThresholdRule({ value, xScale, area }: { value: number | undefined; xScale: Scale; area: PlotArea }) {
|
|
10
10
|
if (value === undefined || !Number.isFinite(value)) return null;
|
|
11
11
|
const x = xScale.project(value);
|
|
12
|
-
return
|
|
13
|
-
<line
|
|
14
|
-
data-threshold=""
|
|
15
|
-
x1={x}
|
|
16
|
-
x2={x}
|
|
17
|
-
y1={area.y0}
|
|
18
|
-
y2={area.y1}
|
|
19
|
-
stroke="currentColor"
|
|
20
|
-
strokeWidth={1.25}
|
|
21
|
-
strokeDasharray="3 2"
|
|
22
|
-
/>
|
|
23
|
-
);
|
|
12
|
+
return <line data-threshold="" x1={x} x2={x} y1={area.y0} y2={area.y1} stroke="currentColor" strokeWidth={1.25} strokeDasharray="3 2" />;
|
|
24
13
|
}
|
package/src/bars.ts
CHANGED
|
@@ -34,11 +34,7 @@ function usableDomain(low: number, high: number): [number, number] {
|
|
|
34
34
|
* widened so it lands in a middle bin rather than on an edge.
|
|
35
35
|
* @returns The counts and the domain they span.
|
|
36
36
|
*/
|
|
37
|
-
export function binValues(
|
|
38
|
-
values: ArrayLike<number>,
|
|
39
|
-
bins: number | undefined,
|
|
40
|
-
domain?: [number, number],
|
|
41
|
-
): BinnedData {
|
|
37
|
+
export function binValues(values: ArrayLike<number>, bins: number | undefined, domain?: [number, number]): BinnedData {
|
|
42
38
|
const count = bins === undefined ? DEFAULT_BINS : Number.isFinite(bins) ? Math.max(1, Math.floor(bins)) : 1;
|
|
43
39
|
const finite: number[] = [];
|
|
44
40
|
for (let index = 0; index < values.length; index += 1) {
|
package/src/colormap.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Sequential colour maps for a magnitude
|
|
2
|
+
* Sequential colour maps for a magnitude: a residual's size, a per-cell
|
|
3
3
|
* error, a confidence, a validity fraction.
|
|
4
4
|
*
|
|
5
5
|
* Only perceptually uniform maps ship, so equal steps in the data look like equal steps.
|
|
@@ -74,11 +74,7 @@ export function colormapRgb(name: ColormapName, t: number): [number, number, num
|
|
|
74
74
|
const f = scaled - i;
|
|
75
75
|
const a = anchors[i]!;
|
|
76
76
|
const b = anchors[i + 1]!;
|
|
77
|
-
return [
|
|
78
|
-
Math.round(a[0] + f * (b[0] - a[0])),
|
|
79
|
-
Math.round(a[1] + f * (b[1] - a[1])),
|
|
80
|
-
Math.round(a[2] + f * (b[2] - a[2])),
|
|
81
|
-
];
|
|
77
|
+
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]))];
|
|
82
78
|
}
|
|
83
79
|
|
|
84
80
|
/**
|
package/src/index.ts
CHANGED
|
@@ -19,39 +19,17 @@ export {
|
|
|
19
19
|
type Variant,
|
|
20
20
|
} from "./Frame";
|
|
21
21
|
|
|
22
|
-
export {
|
|
23
|
-
extent,
|
|
24
|
-
formatTick,
|
|
25
|
-
histogram,
|
|
26
|
-
linePath,
|
|
27
|
-
linearScale,
|
|
28
|
-
logScale,
|
|
29
|
-
niceStep,
|
|
30
|
-
padDomain,
|
|
31
|
-
type Scale,
|
|
32
|
-
type Tick,
|
|
33
|
-
} from "./scale";
|
|
22
|
+
export { extent, formatTick, histogram, linePath, linearScale, logScale, niceStep, padDomain, type Scale, type Tick } from "./scale";
|
|
34
23
|
|
|
35
24
|
export { LineChart, type LineChartProps, type Series } from "./LineChart";
|
|
36
25
|
|
|
37
26
|
export { StackedBars, type BarRow, type StackedBarsProps } from "./BarChart";
|
|
38
27
|
|
|
39
|
-
export {
|
|
40
|
-
Histogram,
|
|
41
|
-
type HistogramCounts,
|
|
42
|
-
type HistogramOptions,
|
|
43
|
-
type HistogramProps,
|
|
44
|
-
type HistogramValues,
|
|
45
|
-
} from "./Histogram";
|
|
28
|
+
export { Histogram, type HistogramCounts, type HistogramOptions, type HistogramProps, type HistogramValues } from "./Histogram";
|
|
46
29
|
|
|
47
30
|
export { ScoreHistogram, type ScoreHistogramProps } from "./ScoreHistogram";
|
|
48
31
|
|
|
49
|
-
export {
|
|
50
|
-
LineProfile,
|
|
51
|
-
type EdgeMark,
|
|
52
|
-
type LineProfileProps,
|
|
53
|
-
type ProfileSeries,
|
|
54
|
-
} from "./LineProfile";
|
|
32
|
+
export { LineProfile, type EdgeMark, type LineProfileProps, type ProfileSeries } from "./LineProfile";
|
|
55
33
|
|
|
56
34
|
export {
|
|
57
35
|
Bands,
|
|
@@ -65,13 +43,6 @@ export {
|
|
|
65
43
|
type ReadoutSeries,
|
|
66
44
|
} from "./interaction";
|
|
67
45
|
|
|
68
|
-
export {
|
|
69
|
-
COLORMAPS,
|
|
70
|
-
colormap,
|
|
71
|
-
colormapGradient,
|
|
72
|
-
colormapRgb,
|
|
73
|
-
colormapValue,
|
|
74
|
-
type ColormapName,
|
|
75
|
-
} from "./colormap";
|
|
46
|
+
export { COLORMAPS, colormap, colormapGradient, colormapRgb, colormapValue, type ColormapName } from "./colormap";
|
|
76
47
|
|
|
77
48
|
export { ColormapLegend, type ColormapLegendProps } from "./ColormapLegend";
|
package/src/scale.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The arithmetic behind every chart: domains, ticks, and the map from a value to a pixel.
|
|
3
3
|
*
|
|
4
4
|
* Hand-rolled SVG rather than a charting library: the chart types this design system needs
|
|
5
|
-
* are few and simple, and a library that lags the React and Tailwind versions the
|
|
5
|
+
* are few and simple, and a library that lags the React and Tailwind versions the apps
|
|
6
6
|
* are deliberately on would mean either downgrading a consumer or isolating a laggard — a
|
|
7
7
|
* cost that outweighs a few hundred lines of scale maths.
|
|
8
8
|
*
|
|
@@ -128,11 +128,7 @@ export function extent(values: readonly number[]): [number, number] {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
/** A linear scale from `domain` onto `[rangeStart, rangeEnd]` pixels. */
|
|
131
|
-
export function linearScale(
|
|
132
|
-
domain: [number, number],
|
|
133
|
-
rangeStart: number,
|
|
134
|
-
rangeEnd: number,
|
|
135
|
-
): Scale {
|
|
131
|
+
export function linearScale(domain: [number, number], rangeStart: number, rangeEnd: number): Scale {
|
|
136
132
|
const [low, high] = padDomain(domain[0], domain[1]);
|
|
137
133
|
const span = high - low;
|
|
138
134
|
return {
|
|
@@ -179,11 +175,7 @@ export function logScale(domain: [number, number], rangeStart: number, rangeEnd:
|
|
|
179
175
|
// One tick per decade, thinned when the range covers more decades than fit.
|
|
180
176
|
const stride = Math.max(1, Math.ceil(span / Math.max(1, count)));
|
|
181
177
|
const ticks: Tick[] = [];
|
|
182
|
-
for (
|
|
183
|
-
let exponent = Math.ceil(paddedLow);
|
|
184
|
-
exponent <= paddedHigh + 1e-9;
|
|
185
|
-
exponent += stride
|
|
186
|
-
) {
|
|
178
|
+
for (let exponent = Math.ceil(paddedLow); exponent <= paddedHigh + 1e-9; exponent += stride) {
|
|
187
179
|
const value = 10 ** exponent;
|
|
188
180
|
ticks.push({ value, label: formatTick(value, value) });
|
|
189
181
|
}
|
|
@@ -193,11 +185,7 @@ export function logScale(domain: [number, number], rangeStart: number, rangeEnd:
|
|
|
193
185
|
}
|
|
194
186
|
|
|
195
187
|
/** An SVG `d` attribute through the projected points, skipping non-finite ones. */
|
|
196
|
-
export function linePath(
|
|
197
|
-
points: readonly { x: number; y: number }[],
|
|
198
|
-
xScale: Scale,
|
|
199
|
-
yScale: Scale,
|
|
200
|
-
): string {
|
|
188
|
+
export function linePath(points: readonly { x: number; y: number }[], xScale: Scale, yScale: Scale): string {
|
|
201
189
|
const commands: string[] = [];
|
|
202
190
|
let pen = "M";
|
|
203
191
|
for (const point of points) {
|
|
@@ -219,11 +207,7 @@ export function linePath(
|
|
|
219
207
|
* Used for the score histogram, where the two classes must share one set of edges or the
|
|
220
208
|
* bars cannot be compared. Callers pass the shared domain in for exactly that reason.
|
|
221
209
|
*/
|
|
222
|
-
export function histogram(
|
|
223
|
-
values: readonly number[],
|
|
224
|
-
domain: [number, number],
|
|
225
|
-
count: number,
|
|
226
|
-
): number[] {
|
|
210
|
+
export function histogram(values: readonly number[], domain: [number, number], count: number): number[] {
|
|
227
211
|
const bins = new Array<number>(Math.max(1, count)).fill(0);
|
|
228
212
|
const [low, high] = domain;
|
|
229
213
|
const span = high - low;
|