@vitavision/charts 0.8.3 → 0.8.5

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 CHANGED
@@ -20,11 +20,23 @@ is accepted.
20
20
 
21
21
  **Charts** — hand-rolled SVG over the pure domain/tick/project math in `scale.ts`:
22
22
  `Frame` + `Legend` (the axes/grid/label shell every chart composes), `LineChart`
23
- (multi-series, optional log y), `StackedBars`, `Histogram` (one distribution from raw
23
+ (multi-series, optional log y, a `band` of y-error per series, `xFormat` for the x labels), `StackedBars`, `Histogram` (one distribution from raw
24
24
  `values` or pre-binned `counts`, with markers, a cursor bin and hover/pick), `ScoreHistogram` (two-class
25
- distribution with a threshold rule), and `LineProfile` (one or more series against arc length in pixels
25
+ distribution with a threshold rule), `ScatterChart` (below), and `LineProfile` (one or more series against arc length in pixels
26
26
  along a scan line or caliper axis, with detected edges drawn as labelled vertical rules).
27
27
 
28
+ **Scatter**: `ScatterChart` plots `series` of `{ x, y, value? }` points on the same frame, palette and variants.
29
+ - **Colour by value:** `colourBy={{ map, label, unit }}` colours each point through a map, with the scale in the
30
+ footer; a diverging map is centred on zero.
31
+ - **Reference lines:** `referenceLines` draw a dashed rule at a value of either axis, with a label and a tone.
32
+ - **Pointer:** `onHover` rings the nearest point and reads its numbers, `onPick` reports a click's point, and
33
+ `highlighted` rings one chosen elsewhere.
34
+ - Points are a few batched paths, not one element each.
35
+
36
+ **Error bands**: a series' `band` (`{ lower, upper, label? }`, one value per point) draws a translucent area in the
37
+ series colour under the lines. The legend notes it, the hover readout reads `value ± half-width`, a missing edge leaves a gap, and the y
38
+ domain grows to hold it unless `yDomain` is fixed.
39
+
28
40
  **Fitting a chart to its container**: `variant="fluid"` takes the container's width at a fixed
29
41
  `height`, for a chart in a resizable inspector.
30
42
 
@@ -33,9 +45,16 @@ along a scan line or caliper axis, with detected edges drawn as labelled vertica
33
45
  - `cursor` draws an x chosen elsewhere, such as the pointer on the canvas a profile came from.
34
46
  - `bands` shade x ranges, and `markers` tick positions on the x axis.
35
47
 
36
- **Sequential colour maps**: `colormap("viridis" | "cividis", t)` and
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.
48
+ **Colour maps**: `colormap(name, t)` and `colormapValue(map, value, domain)`, for a magnitude such as an error, a validity
49
+ or a confidence, or for a signed value around zero.
50
+ - **Sequential:** `viridis` (the default), `cividis` (for an unknown reader's colour vision), `magma` and `inferno`
51
+ (black to a pale end, for a heatmap over a dark image).
52
+ - **Diverging:** `blueOrange`, from a deep blue through a neutral light grey to a deep orange, with both arms falling in
53
+ lightness at the same rate. Centre a domain on zero with `symmetricDomain`; `isDivergingColormap` tells the two kinds apart.
54
+ - **Legend:** `ColormapLegend` shows the scale with its units; a map is never shown without one. It stands vertical
55
+ beside a map with `orientation="vertical"`, labels values along the bar with `ticks` (a list, or a rough count), and
56
+ with `symmetric` centres a diverging scale on zero. `marker` ticks a value (a threshold, the value under a cursor) with its
57
+ text, and `clipped` (`"high"`, `"low"`, `"both"`) caps a saturated end and reads it `≥ max` or `≤ min`.
39
58
 
40
59
  ## License
41
60
 
package/dist/index.d.ts CHANGED
@@ -165,6 +165,8 @@ interface FrameProps {
165
165
  xTicks?: number;
166
166
  /** Rough number of y ticks to ask the scale for. Default 4. */
167
167
  yTicks?: number;
168
+ /** Writes an x tick's label from its value (a date, a unit). Omitted: the scale's own label. */
169
+ xFormat?: ((value: number) => string) | undefined;
168
170
  /** Drawn inside the plot area, above the grid and below nothing. */
169
171
  children?: ReactNode;
170
172
  /** Accessible name — every chart must have one; it is what the tests query on. */
@@ -180,6 +182,12 @@ interface FrameProps {
180
182
  width: number;
181
183
  height: number;
182
184
  } | undefined;
185
+ /**
186
+ * The plot holds focusable controls (a draggable threshold). The SVG is then a
187
+ * `role="group"` named by `label` instead of an `img`, whose children assistive
188
+ * technology would otherwise hide.
189
+ */
190
+ interactive?: boolean | undefined;
183
191
  /** A ref to the outer `<figure>`, e.g. {@link useFluidSize}'s measuring ref. */
184
192
  figureRef?: Ref<HTMLElement> | undefined;
185
193
  }
@@ -190,13 +198,15 @@ interface FrameProps {
190
198
  * Renders a `<figure>` holding an SVG with `role="img"` named by `label`, and the `footer`
191
199
  * as its `<figcaption>`. `children` are drawn in viewBox units over the grid.
192
200
  */
193
- export declare function Frame({ xScale, yScale, xLabel, yLabel, xTicks, yTicks, children, label, footer, variant, className, size, figureRef }: FrameProps): import("react").JSX.Element;
201
+ export declare function Frame({ xScale, yScale, xLabel, yLabel, xTicks, yTicks, xFormat, children, label, footer, variant, className, size, figureRef, interactive }: FrameProps): import("react").JSX.Element;
194
202
  /** One entry of a {@link Legend}. */
195
203
  interface LegendItem {
196
204
  /** The series name, rendered as text — it is what a screen reader announces. */
197
205
  label: string;
198
206
  /** Any CSS colour: a `var(--series-n)` from {@link seriesColour}, or a verdict token. */
199
207
  colour: string;
208
+ /** The series has an error band: its swatch shows one, and this text follows the name (`±1σ`). */
209
+ band?: string | undefined;
200
210
  }
201
211
  /** Props for {@link Legend}. */
202
212
  interface LegendProps {
@@ -258,6 +268,56 @@ export declare const DEFECT_COLOUR = "var(--defect)";
258
268
  */
259
269
  export declare function seriesColour(index: number): string;
260
270
  //#endregion
271
+ //#region src/band.d.ts
272
+ /** A series' band: the values either side of its line, one per point, by index. */
273
+ interface SeriesBand {
274
+ /** The lower edge at each point. A non-finite value breaks the band there. */
275
+ lower: readonly number[];
276
+ /** The upper edge at each point. */
277
+ upper: readonly number[];
278
+ /** What the legend says after the series' name. Default `"± band"`. */
279
+ label?: string | undefined;
280
+ }
281
+ /**
282
+ * The outline of a band as an SVG path `d`: the upper edge left to right and the lower edge back,
283
+ * closed, once for every run of points whose x and both edges are finite. A run of one point has
284
+ * no area and draws nothing; a gap ends the run, so the band is not bridged across missing data.
285
+ *
286
+ * @param points - The series' points, in draw order.
287
+ * @param band - The edges, by point index. Missing entries count as gaps.
288
+ * @param xScale - The horizontal scale.
289
+ * @param yScale - The vertical scale.
290
+ * @returns The path, or `""` when there is nothing to fill.
291
+ */
292
+ export declare function bandPath(points: readonly {
293
+ x: number;
294
+ y: number;
295
+ }[], band: Pick<SeriesBand, "lower" | "upper">, xScale: Scale, yScale: Scale): string;
296
+ /**
297
+ * A value with its band as text: `3.2 ± 0.4` when the band is symmetric about the value, else
298
+ * `3.2 [2.8, 3.9]`.
299
+ *
300
+ * @param value - The series' value.
301
+ * @param bounds - The band's `[lower, upper]` there.
302
+ * @param format - Formats one number.
303
+ */
304
+ export declare function formatWithBand(value: number, bounds: readonly [number, number], format: (n: number) => string): string;
305
+ //#endregion
306
+ //#region src/interpolate.d.ts
307
+ /** Reading a series between its points. */
308
+ /**
309
+ * A series' value at `x`, linearly interpolated between the points either side, or `null`
310
+ * outside its range or across a gap.
311
+ *
312
+ * @param points - The series, in ascending `x`.
313
+ * @param x - Where.
314
+ * @returns The interpolated value, or `null`.
315
+ */
316
+ export declare function seriesValueAt(points: readonly {
317
+ x: number;
318
+ y: number;
319
+ }[], x: number): number | null;
320
+ //#endregion
261
321
  //#region src/interaction.d.ts
262
322
  /** An x range marked on the plot: a gap, a stretch out of tolerance, a region of interest. */
263
323
  interface Band {
@@ -290,6 +350,8 @@ interface ReadoutSeries {
290
350
  }[];
291
351
  /** Its colour. */
292
352
  colour: string;
353
+ /** Its error band: the readout then reads `value ± half-width`, or the value with its range. */
354
+ band?: SeriesBand | undefined;
293
355
  }
294
356
  /** The props `LineChart` and `LineProfile` share for interaction and marking. */
295
357
  interface InteractionProps {
@@ -331,7 +393,7 @@ export declare function Markers({ markers, xScale, area }: {
331
393
  * The pointer layer over the plot area: a crosshair and a value readout while hovering, the
332
394
  * external `cursor` otherwise, and clicks as picks.
333
395
  */
334
- export declare function PlotInteraction({ xScale, yScale, area, series, cursor, onHover, onPick, format }: {
396
+ export declare function PlotInteraction({ xScale, yScale, area, series, cursor, onHover, onPick, format, xFormat }: {
335
397
  xScale: Scale;
336
398
  yScale: Scale;
337
399
  area: PlotArea;
@@ -340,19 +402,9 @@ export declare function PlotInteraction({ xScale, yScale, area, series, cursor,
340
402
  onHover?: ((x: number | null) => void) | undefined;
341
403
  onPick?: ((x: number) => void) | undefined;
342
404
  format?: (value: number) => string;
405
+ /** Formats the x in the readout. Default: `format`. */
406
+ xFormat?: ((value: number) => string) | undefined;
343
407
  }): import("react").JSX.Element;
344
- /**
345
- * A series' value at `x`, linearly interpolated between the points either side, or `null`
346
- * outside its range or across a gap.
347
- *
348
- * @param points - The series, in ascending `x`.
349
- * @param x - Where.
350
- * @returns The interpolated value, or `null`.
351
- */
352
- export declare function seriesValueAt(points: readonly {
353
- x: number;
354
- y: number;
355
- }[], x: number): number | null;
356
408
  //#endregion
357
409
  //#region src/LineChart.d.ts
358
410
  /** One line of a {@link LineChart}. */
@@ -369,6 +421,15 @@ interface Series {
369
421
  }[];
370
422
  /** Any CSS colour. Omitted: {@link seriesColour} of the series' index. */
371
423
  colour?: string;
424
+ /**
425
+ * An error band around the line: `lower` and `upper` hold one value per point, by index (a
426
+ * mean ± σ, a confidence interval). It is drawn as a translucent area in the series colour
427
+ * under every line, shown in the legend, and read in the hover readout as `value ± half-width`
428
+ * (or the value with its range when the band is not symmetric). A point whose edges are
429
+ * missing or non-finite leaves a gap in the band. Unless `yDomain` is fixed, the y domain
430
+ * grows to hold the band.
431
+ */
432
+ band?: SeriesBand;
372
433
  }
373
434
  /** Props for {@link LineChart}. */
374
435
  interface LineChartProps extends InteractionProps {
@@ -384,7 +445,12 @@ interface LineChartProps extends InteractionProps {
384
445
  logY?: boolean;
385
446
  /** Fixed domains, for charts whose axes are known — ROC and PR are both `[0, 1]`. */
386
447
  xDomain?: [number, number];
387
- /** Fixed y domain. Omitted: the extent of every series' `y`. */
448
+ /**
449
+ * Writes the x tick labels and the x in the hover readout from the x value: a date from a
450
+ * timestamp, a unit. Omitted: the scale's own labels.
451
+ */
452
+ xFormat?: (x: number) => string;
453
+ /** Fixed y domain. Omitted: the extent of every series' `y` and band edges. */
388
454
  yDomain?: [number, number];
389
455
  /** Drawn behind the series, in plot pixels. A chance diagonal or a tolerance band uses this. */
390
456
  underlay?: (x: Scale, y: Scale) => ReactNode;
@@ -406,9 +472,248 @@ interface LineChartProps extends InteractionProps {
406
472
  * An SVG `role="img"` named by `label`, with the legend as real text under it. Series are
407
473
  * told apart by the legend's names, never by colour alone. `bands` and `markers` mark x
408
474
  * ranges and positions; `onHover` adds a crosshair and a value readout, `onPick` makes a
409
- * click report its x, and `cursor` draws an x chosen elsewhere.
475
+ * click report its x, and `cursor` draws an x chosen elsewhere. A series' `band` adds an error
476
+ * band, and `xFormat` writes the x labels.
410
477
  */
411
- export declare function LineChart({ series, label, xLabel, yLabel, logY, xDomain, yDomain, underlay, footer, showLegend, variant, className, height, bands, markers, cursor, onHover, onPick }: LineChartProps): import("react").JSX.Element;
478
+ export declare function LineChart({ series, label, xLabel, yLabel, logY, xDomain, yDomain, xFormat, underlay, footer, showLegend, variant, className, height, bands, markers, cursor, onHover, onPick }: LineChartProps): import("react").JSX.Element;
479
+ //#endregion
480
+ //#region src/colormap.d.ts
481
+ /**
482
+ * Colour maps for a magnitude: a residual's size, a per-cell error, a confidence, a validity
483
+ * fraction, or a signed quantity around zero.
484
+ *
485
+ * Only perceptually uniform maps ship, so equal steps in the data look like equal steps.
486
+ *
487
+ * Sequential, low to high:
488
+ * - `viridis` is the default on the chrome.
489
+ * - `cividis` is for when the map alone carries the finding and the reader's colour vision is
490
+ * unknown.
491
+ * - `magma` and `inferno` run from black to a pale yellow through purple and red or orange. They
492
+ * read well over a dark image, where `viridis`' dark end disappears.
493
+ *
494
+ * Diverging, for a signed value whose zero matters (a displacement toward or away from a
495
+ * centre, a difference between two runs):
496
+ * - `blueOrange` runs from a deep blue through a neutral light grey at the middle to a deep
497
+ * orange-brown. Both arms fall in lightness at the same rate and carry the same amount of
498
+ * colour, so +x and -x look equally strong, and its hues avoid the red-green axis. Centre it on zero with `symmetricDomain`.
499
+ *
500
+ * A continuous quality is a magnitude even when low values are "good": stepping it onto verdict
501
+ * colours (green / amber / red) claims a threshold judgement nobody made.
502
+ *
503
+ * The sequential anchors are the matplotlib maps sampled at nine evenly spaced points. Linear
504
+ * interpolation between them stays within a few units of the full 256-entry tables. The
505
+ * diverging map was constructed in OKLab (equal lightness and chroma steps along each arm,
506
+ * mirrored in lightness, kept inside sRGB) and sampled at seventeen points.
507
+ */
508
+ /** The shipped maps. */
509
+ type ColormapName = "viridis" | "cividis" | "magma" | "inferno" | "blueOrange";
510
+ /** The names of the shipped maps. */
511
+ export declare const COLORMAPS: readonly ColormapName[];
512
+ /** The maps that run through a neutral middle, for a signed value: use them over a domain centred on zero. */
513
+ export declare const DIVERGING_COLORMAPS: readonly ColormapName[];
514
+ /**
515
+ * Whether a map is diverging.
516
+ *
517
+ * @param name - The map.
518
+ * @returns `true` for a map meant for a signed value around zero.
519
+ */
520
+ export declare function isDivergingColormap(name: ColormapName): boolean;
521
+ /**
522
+ * A domain centred on zero that holds a given one: `[-m, m]` with `m` the largest absolute end.
523
+ * Feed it a diverging map so the middle colour means zero.
524
+ *
525
+ * @param domain - `[low, high]`, or the values to cover.
526
+ * @returns `[-m, m]`; `[-1, 1]` when no end is finite and non-zero.
527
+ */
528
+ export declare function symmetricDomain(domain: readonly number[]): [number, number];
529
+ /**
530
+ * The colour of `t` on a map.
531
+ *
532
+ * @param name - The map.
533
+ * @param t - Position in `[0, 1]`; clamped. A non-finite `t` gives the map's low end.
534
+ * @returns A CSS `rgb(r g b)` colour.
535
+ */
536
+ export declare function colormap(name: ColormapName, t: number): string;
537
+ /**
538
+ * The colour of `t` on a map, as integer channels.
539
+ *
540
+ * @param name - The map.
541
+ * @param t - Position in `[0, 1]`; clamped.
542
+ * @returns `[r, g, b]`, each 0–255.
543
+ */
544
+ export declare function colormapRgb(name: ColormapName, t: number): [number, number, number];
545
+ /**
546
+ * A value's colour on a map, over a domain.
547
+ *
548
+ * @param name - The map.
549
+ * @param value - The value.
550
+ * @param domain - `[low, high]`: low maps to the map's start. A reversed domain reverses the map.
551
+ * For a diverging map pass a domain centred on zero (`symmetricDomain`).
552
+ * @returns A CSS colour.
553
+ */
554
+ export declare function colormapValue(name: ColormapName, value: number, domain: readonly [number, number]): string;
555
+ /**
556
+ * A CSS `linear-gradient` of a map, for a legend bar.
557
+ *
558
+ * @param name - The map.
559
+ * @param direction - The gradient's direction. Defaults to `to right`.
560
+ * @returns A CSS `background-image` value.
561
+ */
562
+ export declare function colormapGradient(name: ColormapName, direction?: string): string;
563
+ //#endregion
564
+ //#region src/ScatterChart.d.ts
565
+ /** One point of a {@link ScatterChart}. */
566
+ interface ScatterPoint {
567
+ /** Horizontal position, in x domain units. A non-finite value skips the point. */
568
+ x: number;
569
+ /** Vertical position, in y domain units. A non-finite value skips the point. */
570
+ y: number;
571
+ /** What `colourBy` colours it by. A point without one is drawn in the muted tone. */
572
+ value?: number | undefined;
573
+ }
574
+ /** One group of points of a {@link ScatterChart}. */
575
+ interface ScatterSeries {
576
+ /** Legend text, and the React key — unique within one chart. */
577
+ name: string;
578
+ /** The points. Their index here is what hover and pick report. */
579
+ points: readonly ScatterPoint[];
580
+ /** Any CSS colour. Omitted: {@link seriesColour} of the series' index. Ignored with `colourBy`. */
581
+ colour?: string | undefined;
582
+ }
583
+ /** Colour every point by its `value` through a map. */
584
+ interface ScatterColourBy {
585
+ /** The map. A diverging map centres on zero by default. */
586
+ map: ColormapName;
587
+ /** The values at the map's ends. Omitted: the extent of the points' values. */
588
+ domain?: readonly [number, number] | undefined;
589
+ /** Centre the domain on zero. Defaults to `true` for a diverging map, `false` otherwise. */
590
+ symmetric?: boolean | undefined;
591
+ /** What the colour encodes, written beside the scale. Required: a map is never shown unlabelled. */
592
+ label: string;
593
+ /** The values' unit, written after the scale's numbers. */
594
+ unit?: string | undefined;
595
+ }
596
+ /** A rule across the plot at one x or y: a tolerance, a mean, an expected value. */
597
+ interface ScatterReferenceLine {
598
+ /** Which axis the value is on: `"y"` is a horizontal rule, `"x"` a vertical one. */
599
+ axis: "x" | "y";
600
+ /** Where, in that axis' domain units. A value outside the domain is not drawn. */
601
+ value: number;
602
+ /** Text at the rule's end. */
603
+ label?: string | undefined;
604
+ /** Its colour. Default `"muted"`. */
605
+ tone?: MeasureTone | undefined;
606
+ }
607
+ /** A point of a {@link ScatterChart}, as hover and pick report it. */
608
+ interface ScatterPick {
609
+ /** The name of its series. */
610
+ series: string;
611
+ /** Its index in that series' `points`. */
612
+ index: number;
613
+ /** Its x. */
614
+ x: number;
615
+ /** Its y. */
616
+ y: number;
617
+ /** Its value, when it has one. */
618
+ value?: number | undefined;
619
+ }
620
+ /** Props for {@link ScatterChart}. */
621
+ interface ScatterChartProps {
622
+ /** The groups of points, drawn in order — a later series paints over an earlier one. */
623
+ series: readonly ScatterSeries[];
624
+ /** Accessible name of the chart (the SVG's `aria-label`). Required. */
625
+ label: string;
626
+ /** x-axis title. */
627
+ xLabel?: string | undefined;
628
+ /** y-axis title. */
629
+ yLabel?: string | undefined;
630
+ /** Fixed x domain. Omitted: the extent of every series' `x`, with 4 % on each side. */
631
+ xDomain?: [number, number] | undefined;
632
+ /** Fixed y domain. Omitted: the extent of every series' `y`, with 4 % on each side. */
633
+ yDomain?: [number, number] | undefined;
634
+ /** Colour points by their `value`, with a legend of the scale in the footer. */
635
+ colourBy?: ScatterColourBy | undefined;
636
+ /** Rules across the plot, drawn behind the points. */
637
+ referenceLines?: readonly ScatterReferenceLine[] | undefined;
638
+ /** Marker diameter in CSS pixels at the chart's own scale. Default 4. */
639
+ markerSize?: number | undefined;
640
+ /** Drawn behind the points, in plot pixels. A tolerance region or a fitted curve uses this. */
641
+ underlay?: ((x: Scale, y: Scale) => ReactNode) | undefined;
642
+ /** The point to draw as highlighted, from outside the chart (a hovered table row). */
643
+ highlighted?: {
644
+ series: string;
645
+ index: number;
646
+ } | null | undefined;
647
+ /**
648
+ * Called with the point nearest the pointer (within 10 plot units), or `null` when none is.
649
+ * Draws a ring on it and a readout of its numbers.
650
+ */
651
+ onHover?: ((point: ScatterPick | null) => void) | undefined;
652
+ /** Called with the point under a click. Makes the plot area a pointer target. */
653
+ onPick?: ((point: ScatterPick) => void) | undefined;
654
+ /** Rendered under the legend, inside the `<figcaption>`. */
655
+ footer?: ReactNode;
656
+ /** Show the series legend row (without `colourBy`). Default `true`. */
657
+ showLegend?: boolean | undefined;
658
+ /** Where the chart is going (see {@link Variant}). Default `"panel"`. */
659
+ variant?: Variant | undefined;
660
+ /** Extra classes for the outer `<figure>`, merged with `cn`. */
661
+ className?: string | undefined;
662
+ /** For `variant="fluid"`: the chart's height in CSS pixels. Default 200. */
663
+ height?: number | undefined;
664
+ }
665
+ /**
666
+ * A scatter plot over a shared frame — residuals against position, one run against another.
667
+ *
668
+ * @remarks
669
+ * An SVG `role="img"` named by `label`, with the series legend (or, with `colourBy`, the colour
670
+ * scale) as real text under it. Series are told apart by the legend's names, never by colour
671
+ * alone. `referenceLines` mark a value on either axis; `onHover` rings the nearest point and
672
+ * reads its numbers, `onPick` reports a click's point, and `highlighted` rings one chosen
673
+ * elsewhere. Picking is by pointer, so the same points must be reachable from a table beside
674
+ * the chart. A point with a non-finite coordinate is skipped.
675
+ */
676
+ export declare function ScatterChart({ series, label, xLabel, yLabel, xDomain, yDomain, colourBy, referenceLines, markerSize, underlay, highlighted, onHover, onPick, footer, showLegend, variant, className, height }: ScatterChartProps): import("react").JSX.Element;
677
+ //#endregion
678
+ //#region src/scatter.d.ts
679
+ /**
680
+ * The arithmetic behind `ScatterChart`: which point is under the pointer, which colour step a
681
+ * value falls in, and the domain a colour scale covers.
682
+ *
683
+ * Pure: the component is a thin list of SVG elements over it.
684
+ */
685
+ /** The number of colour steps a value-coloured series is quantised into: one path each. */
686
+ export declare const SCATTER_COLOUR_STEPS = 24;
687
+ /**
688
+ * The projected point nearest to a position, within a radius.
689
+ *
690
+ * @param xy - Flat `[x0, y0, x1, y1, …]` in the plot's own units (viewBox units); a non-finite
691
+ * coordinate is skipped.
692
+ * @param x - The query's x.
693
+ * @param y - The query's y.
694
+ * @param radius - How far from a point the query still picks it.
695
+ * @returns The index of the nearest point (the lower index on a tie), or `-1`.
696
+ */
697
+ export declare function nearestProjected(xy: ArrayLike<number>, x: number, y: number, radius: number): number;
698
+ /**
699
+ * The colour step of a value.
700
+ *
701
+ * @param value - The point's value.
702
+ * @param domain - `[low, high]`: `low` maps to the first step.
703
+ * @param steps - How many steps. Defaults to `SCATTER_COLOUR_STEPS`.
704
+ * @returns An integer in `[0, steps - 1]`; `-1` for a non-finite value; a degenerate domain puts
705
+ * every value in step `0`.
706
+ */
707
+ export declare function colourStep(value: number, domain: readonly [number, number], steps?: number): number;
708
+ /**
709
+ * The domain a value colouring covers.
710
+ *
711
+ * @param values - Every point's value; non-finite ones are ignored.
712
+ * @param symmetric - Centre it on zero, for a diverging map.
713
+ * @param given - A domain the caller fixed. It wins, centred if `symmetric`.
714
+ * @returns `[low, high]`; `[0, 1]` when there is no finite value.
715
+ */
716
+ export declare function colourDomain(values: Iterable<number>, symmetric: boolean, given?: readonly [number, number]): [number, number];
412
717
  //#endregion
413
718
  //#region src/BarChart.d.ts
414
719
  /**
@@ -466,6 +771,21 @@ interface HistogramOptions extends InteractionProps {
466
771
  * draws its own). Omitted or non-finite: none. For other x positions use `markers`.
467
772
  */
468
773
  threshold?: number | undefined;
774
+ /**
775
+ * Makes `threshold` draggable: called with the new x, in data units and clamped to the
776
+ * domain, while the rule is dragged or stepped. The chart does not keep the value — move
777
+ * `threshold` to follow it. Needs a `threshold`. The rule becomes a focusable slider
778
+ * (Arrow keys step one bin, Page keys ten, Home and End go to the ends), and the SVG a
779
+ * `group` rather than an `img`.
780
+ */
781
+ onThresholdChange?: ((x: number) => void) | undefined;
782
+ /** The threshold slider's accessible name. Default "Threshold". */
783
+ thresholdLabel?: string | undefined;
784
+ /**
785
+ * Freezes a draggable threshold. A string is the reason, shown as the rule's tooltip
786
+ * (`"Locked by the saved model"`).
787
+ */
788
+ thresholdDisabled?: boolean | string | undefined;
469
789
  /** Counts span decades in a long-tailed distribution; a log axis keeps the tail visible. */
470
790
  logY?: boolean | undefined;
471
791
  /** Where the chart is going (see {@link Variant}). Default `"panel"`. */
@@ -508,7 +828,7 @@ type HistogramProps = HistogramOptions & (HistogramValues | HistogramCounts);
508
828
  * @remarks
509
829
  * An SVG `role="img"` named by `label`. `threshold` draws a dashed decision rule, `markers`
510
830
  * tick the x axis, `bands` shade x ranges, `onHover` adds a crosshair and the x under it,
511
- * `onPick` reports the x of a click, and `cursor` draws the bin containing an x chosen
831
+ * `onPick` reports the x of a click, `onThresholdChange` makes the threshold a draggable slider, and `cursor` draws the bin containing an x chosen
512
832
  * elsewhere in the selection colour (`--signal`) — no highlight when it lies outside the
513
833
  * domain. Empty data draws an empty frame. For two classes sharing a threshold use
514
834
  * {@link ScoreHistogram}.
@@ -613,61 +933,16 @@ interface LineProfileProps extends InteractionProps {
613
933
  */
614
934
  export declare function LineProfile({ series, edges, label, xLabel, yLabel, xDomain, yDomain, footer, showLegend, variant, className, height, bands, markers, cursor, onHover, onPick }: LineProfileProps): import("react").JSX.Element;
615
935
  //#endregion
616
- //#region src/colormap.d.ts
617
- /**
618
- * Sequential colour maps for a magnitude: a residual's size, a per-cell
619
- * error, a confidence, a validity fraction.
620
- *
621
- * Only perceptually uniform maps ship, so equal steps in the data look like equal steps.
622
- * - `viridis` is the default on the chrome.
623
- * - `cividis` is for when the map alone carries the finding and the reader's colour vision is
624
- * unknown.
625
- *
626
- * A continuous quality is a magnitude even when low values are "good": stepping it onto verdict
627
- * colours (green / amber / red) claims a threshold judgement nobody made.
628
- *
629
- * The anchors are matplotlib's maps sampled at nine evenly spaced points. Linear interpolation
630
- * between them stays within a few units of the full 256-entry tables.
631
- */
632
- /** The shipped maps. */
633
- type ColormapName = "viridis" | "cividis";
634
- /** The names of the shipped maps. */
635
- export declare const COLORMAPS: readonly ColormapName[];
636
- /**
637
- * The colour of `t` on a map.
638
- *
639
- * @param name - The map.
640
- * @param t - Position in `[0, 1]`; clamped. A non-finite `t` gives the map's low end.
641
- * @returns A CSS `rgb(r g b)` colour.
642
- */
643
- export declare function colormap(name: ColormapName, t: number): string;
644
- /**
645
- * The colour of `t` on a map, as integer channels.
646
- *
647
- * @param name - The map.
648
- * @param t - Position in `[0, 1]`; clamped.
649
- * @returns `[r, g, b]`, each 0–255.
650
- */
651
- export declare function colormapRgb(name: ColormapName, t: number): [number, number, number];
652
- /**
653
- * A value's colour on a map, over a domain.
654
- *
655
- * @param name - The map.
656
- * @param value - The value.
657
- * @param domain - `[low, high]`: low maps to the map's start. A reversed domain reverses the map.
658
- * @returns A CSS colour.
659
- */
660
- export declare function colormapValue(name: ColormapName, value: number, domain: readonly [number, number]): string;
661
- /**
662
- * A CSS `linear-gradient` of a map, for a legend bar.
663
- *
664
- * @param name - The map.
665
- * @param direction - The gradient's direction. Defaults to `to right`.
666
- * @returns A CSS `background-image` value.
667
- */
668
- export declare function colormapGradient(name: ColormapName, direction?: string): string;
669
- //#endregion
670
936
  //#region src/ColormapLegend.d.ts
937
+ /** A value marked on a {@link ColormapLegend}: a threshold, a cursor value, a reference. */
938
+ interface ColormapMarker {
939
+ /** Where, in the legend's value units. A value outside the domain is left out. */
940
+ value: number;
941
+ /** The marker's text. Default: the value, formatted with the legend's `format` and `unit`. */
942
+ label?: string | undefined;
943
+ }
944
+ /** Which end of a {@link ColormapLegend} the data runs past: `"high"` is `≥ max`, `"low"` is `≤ min`. */
945
+ type ColormapClipped = "high" | "low" | "both";
671
946
  /** Props of `ColormapLegend`. */
672
947
  interface ColormapLegendProps {
673
948
  /** The map. */
@@ -678,16 +953,57 @@ interface ColormapLegendProps {
678
953
  unit?: string | undefined;
679
954
  /** What the colour encodes, written before the bar ("Validity", "Edge error"). */
680
955
  label: string;
681
- /** Formats the end values. Defaults to at most 3 significant figures, without trailing zeros. */
956
+ /** Formats the end and tick values. Defaults to at most 3 significant figures, without trailing zeros. */
682
957
  format?: ((value: number) => string) | undefined;
683
- /** Merged onto the row with `cn`. */
958
+ /**
959
+ * How the bar runs. `horizontal` (the default) is one line, low to high; `vertical` is a
960
+ * column with the label above and the high end at the top, for the side of a map.
961
+ */
962
+ orientation?: "horizontal" | "vertical" | undefined;
963
+ /**
964
+ * Values to label along the bar: a list, or a rough count of round ones. Without it a
965
+ * `horizontal` legend labels its two ends in line with the bar and a `vertical` one labels
966
+ * its two ends (and zero, when `symmetric`). With it the values sit along the bar, at their
967
+ * position on the map; values outside `domain` are left out. A count also labels the two ends.
968
+ */
969
+ ticks?: number | readonly number[] | undefined;
970
+ /**
971
+ * Centre the scale on zero for a diverging map: `domain` is widened to `[-m, m]` with `m`
972
+ * its largest absolute end, so the middle colour is zero and the middle tick says so.
973
+ */
974
+ symmetric?: boolean | undefined;
975
+ /**
976
+ * Values to mark on the bar: a number, a `{ value, label? }`, or a list of either. Each is a
977
+ * tick across the bar with its text beside it (above a horizontal bar, to the right of the
978
+ * ticks on a vertical one): the label, or else the value with the unit. The text carries the
979
+ * meaning; the tick is decorative. A value outside `domain` is left out.
980
+ */
981
+ marker?: number | ColormapMarker | readonly (number | ColormapMarker)[] | undefined;
982
+ /**
983
+ * The scale saturates: the data runs past the end of `domain`. The end gets a cap (a small
984
+ * arrow in the end colour) and its value reads `≥ max` (`high`) or `≤ min` (`low`); `both`
985
+ * does both ends. The end value is labelled even when `ticks` leaves it out.
986
+ */
987
+ clipped?: ColormapClipped | undefined;
988
+ /** For `vertical`: the bar's length in CSS pixels. Defaults to 160. */
989
+ length?: number | undefined;
990
+ /** Merged onto the legend with `cn`. */
684
991
  className?: string | undefined;
685
992
  }
686
993
  /**
687
- * A gradient bar with its end values and unit, read as one line: "Edge error 0 [bar] 2.5 px".
688
- * The bar is decorative; the label and the end values carry the meaning as text.
994
+ * A gradient bar with its values and unit.
995
+ *
996
+ * - **Horizontal**: one line, "Edge error 0 [bar] 2.5 px". With `ticks` or `symmetric` the values
997
+ * sit under the bar at their position instead.
998
+ * - **Vertical**: the label above a column bar, the high end at the top, the values beside the
999
+ * bar at their position, and the unit after the label.
1000
+ *
1001
+ * `marker` ticks values on the bar (a threshold, the value under a cursor) and `clipped` says
1002
+ * the scale saturates at an end, with a cap and `≥` / `≤` on its value.
1003
+ *
1004
+ * The bar is decorative; the label, the values and the markers' text carry the meaning.
689
1005
  */
690
- export declare function ColormapLegend({ map, domain, unit, label, format, className }: ColormapLegendProps): import("react").JSX.Element;
1006
+ export declare function ColormapLegend({ map, domain, unit, label, format, orientation, ticks, symmetric, marker, clipped, length, className }: ColormapLegendProps): import("react").JSX.Element;
691
1007
  //#endregion
692
- export type { Band, BarRow, ColormapLegendProps, ColormapName, EdgeMark, FrameProps, HistogramCounts, HistogramOptions, HistogramProps, HistogramValues, InteractionProps, LegendItem, LegendProps, LineChartProps, LineProfileProps, Marker, PlotArea, ProfileSeries, ReadoutSeries, Scale, ScoreHistogramProps, Series, StackedBarsProps, Tick, Variant };
1008
+ export type { Band, BarRow, ColormapClipped, ColormapLegendProps, ColormapMarker, ColormapName, EdgeMark, FrameProps, HistogramCounts, HistogramOptions, HistogramProps, HistogramValues, InteractionProps, LegendItem, LegendProps, LineChartProps, LineProfileProps, Marker, PlotArea, ProfileSeries, ReadoutSeries, Scale, ScatterChartProps, ScatterColourBy, ScatterPick, ScatterPoint, ScatterReferenceLine, ScatterSeries, ScoreHistogramProps, Series, SeriesBand, StackedBarsProps, Tick, Variant };
693
1009
  //# sourceMappingURL=index.d.ts.map