@vitavision/charts 0.8.3 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md 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. */
@@ -190,13 +192,15 @@ interface FrameProps {
190
192
  * Renders a `<figure>` holding an SVG with `role="img"` named by `label`, and the `footer`
191
193
  * as its `<figcaption>`. `children` are drawn in viewBox units over the grid.
192
194
  */
193
- export declare function Frame({ xScale, yScale, xLabel, yLabel, xTicks, yTicks, children, label, footer, variant, className, size, figureRef }: FrameProps): import("react").JSX.Element;
195
+ export declare function Frame({ xScale, yScale, xLabel, yLabel, xTicks, yTicks, xFormat, children, label, footer, variant, className, size, figureRef }: FrameProps): import("react").JSX.Element;
194
196
  /** One entry of a {@link Legend}. */
195
197
  interface LegendItem {
196
198
  /** The series name, rendered as text — it is what a screen reader announces. */
197
199
  label: string;
198
200
  /** Any CSS colour: a `var(--series-n)` from {@link seriesColour}, or a verdict token. */
199
201
  colour: string;
202
+ /** The series has an error band: its swatch shows one, and this text follows the name (`±1σ`). */
203
+ band?: string | undefined;
200
204
  }
201
205
  /** Props for {@link Legend}. */
202
206
  interface LegendProps {
@@ -258,6 +262,56 @@ export declare const DEFECT_COLOUR = "var(--defect)";
258
262
  */
259
263
  export declare function seriesColour(index: number): string;
260
264
  //#endregion
265
+ //#region src/band.d.ts
266
+ /** A series' band: the values either side of its line, one per point, by index. */
267
+ interface SeriesBand {
268
+ /** The lower edge at each point. A non-finite value breaks the band there. */
269
+ lower: readonly number[];
270
+ /** The upper edge at each point. */
271
+ upper: readonly number[];
272
+ /** What the legend says after the series' name. Default `"± band"`. */
273
+ label?: string | undefined;
274
+ }
275
+ /**
276
+ * The outline of a band as an SVG path `d`: the upper edge left to right and the lower edge back,
277
+ * closed, once for every run of points whose x and both edges are finite. A run of one point has
278
+ * no area and draws nothing; a gap ends the run, so the band is not bridged across missing data.
279
+ *
280
+ * @param points - The series' points, in draw order.
281
+ * @param band - The edges, by point index. Missing entries count as gaps.
282
+ * @param xScale - The horizontal scale.
283
+ * @param yScale - The vertical scale.
284
+ * @returns The path, or `""` when there is nothing to fill.
285
+ */
286
+ export declare function bandPath(points: readonly {
287
+ x: number;
288
+ y: number;
289
+ }[], band: Pick<SeriesBand, "lower" | "upper">, xScale: Scale, yScale: Scale): string;
290
+ /**
291
+ * A value with its band as text: `3.2 ± 0.4` when the band is symmetric about the value, else
292
+ * `3.2 [2.8, 3.9]`.
293
+ *
294
+ * @param value - The series' value.
295
+ * @param bounds - The band's `[lower, upper]` there.
296
+ * @param format - Formats one number.
297
+ */
298
+ export declare function formatWithBand(value: number, bounds: readonly [number, number], format: (n: number) => string): string;
299
+ //#endregion
300
+ //#region src/interpolate.d.ts
301
+ /** Reading a series between its points. */
302
+ /**
303
+ * A series' value at `x`, linearly interpolated between the points either side, or `null`
304
+ * outside its range or across a gap.
305
+ *
306
+ * @param points - The series, in ascending `x`.
307
+ * @param x - Where.
308
+ * @returns The interpolated value, or `null`.
309
+ */
310
+ export declare function seriesValueAt(points: readonly {
311
+ x: number;
312
+ y: number;
313
+ }[], x: number): number | null;
314
+ //#endregion
261
315
  //#region src/interaction.d.ts
262
316
  /** An x range marked on the plot: a gap, a stretch out of tolerance, a region of interest. */
263
317
  interface Band {
@@ -290,6 +344,8 @@ interface ReadoutSeries {
290
344
  }[];
291
345
  /** Its colour. */
292
346
  colour: string;
347
+ /** Its error band: the readout then reads `value ± half-width`, or the value with its range. */
348
+ band?: SeriesBand | undefined;
293
349
  }
294
350
  /** The props `LineChart` and `LineProfile` share for interaction and marking. */
295
351
  interface InteractionProps {
@@ -331,7 +387,7 @@ export declare function Markers({ markers, xScale, area }: {
331
387
  * The pointer layer over the plot area: a crosshair and a value readout while hovering, the
332
388
  * external `cursor` otherwise, and clicks as picks.
333
389
  */
334
- export declare function PlotInteraction({ xScale, yScale, area, series, cursor, onHover, onPick, format }: {
390
+ export declare function PlotInteraction({ xScale, yScale, area, series, cursor, onHover, onPick, format, xFormat }: {
335
391
  xScale: Scale;
336
392
  yScale: Scale;
337
393
  area: PlotArea;
@@ -340,19 +396,9 @@ export declare function PlotInteraction({ xScale, yScale, area, series, cursor,
340
396
  onHover?: ((x: number | null) => void) | undefined;
341
397
  onPick?: ((x: number) => void) | undefined;
342
398
  format?: (value: number) => string;
399
+ /** Formats the x in the readout. Default: `format`. */
400
+ xFormat?: ((value: number) => string) | undefined;
343
401
  }): 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
402
  //#endregion
357
403
  //#region src/LineChart.d.ts
358
404
  /** One line of a {@link LineChart}. */
@@ -369,6 +415,15 @@ interface Series {
369
415
  }[];
370
416
  /** Any CSS colour. Omitted: {@link seriesColour} of the series' index. */
371
417
  colour?: string;
418
+ /**
419
+ * An error band around the line: `lower` and `upper` hold one value per point, by index (a
420
+ * mean ± σ, a confidence interval). It is drawn as a translucent area in the series colour
421
+ * under every line, shown in the legend, and read in the hover readout as `value ± half-width`
422
+ * (or the value with its range when the band is not symmetric). A point whose edges are
423
+ * missing or non-finite leaves a gap in the band. Unless `yDomain` is fixed, the y domain
424
+ * grows to hold the band.
425
+ */
426
+ band?: SeriesBand;
372
427
  }
373
428
  /** Props for {@link LineChart}. */
374
429
  interface LineChartProps extends InteractionProps {
@@ -384,7 +439,12 @@ interface LineChartProps extends InteractionProps {
384
439
  logY?: boolean;
385
440
  /** Fixed domains, for charts whose axes are known — ROC and PR are both `[0, 1]`. */
386
441
  xDomain?: [number, number];
387
- /** Fixed y domain. Omitted: the extent of every series' `y`. */
442
+ /**
443
+ * Writes the x tick labels and the x in the hover readout from the x value: a date from a
444
+ * timestamp, a unit. Omitted: the scale's own labels.
445
+ */
446
+ xFormat?: (x: number) => string;
447
+ /** Fixed y domain. Omitted: the extent of every series' `y` and band edges. */
388
448
  yDomain?: [number, number];
389
449
  /** Drawn behind the series, in plot pixels. A chance diagonal or a tolerance band uses this. */
390
450
  underlay?: (x: Scale, y: Scale) => ReactNode;
@@ -406,9 +466,248 @@ interface LineChartProps extends InteractionProps {
406
466
  * An SVG `role="img"` named by `label`, with the legend as real text under it. Series are
407
467
  * told apart by the legend's names, never by colour alone. `bands` and `markers` mark x
408
468
  * 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.
469
+ * click report its x, and `cursor` draws an x chosen elsewhere. A series' `band` adds an error
470
+ * band, and `xFormat` writes the x labels.
471
+ */
472
+ 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;
473
+ //#endregion
474
+ //#region src/colormap.d.ts
475
+ /**
476
+ * Colour maps for a magnitude: a residual's size, a per-cell error, a confidence, a validity
477
+ * fraction, or a signed quantity around zero.
478
+ *
479
+ * Only perceptually uniform maps ship, so equal steps in the data look like equal steps.
480
+ *
481
+ * Sequential, low to high:
482
+ * - `viridis` is the default on the chrome.
483
+ * - `cividis` is for when the map alone carries the finding and the reader's colour vision is
484
+ * unknown.
485
+ * - `magma` and `inferno` run from black to a pale yellow through purple and red or orange. They
486
+ * read well over a dark image, where `viridis`' dark end disappears.
487
+ *
488
+ * Diverging, for a signed value whose zero matters (a displacement toward or away from a
489
+ * centre, a difference between two runs):
490
+ * - `blueOrange` runs from a deep blue through a neutral light grey at the middle to a deep
491
+ * orange-brown. Both arms fall in lightness at the same rate and carry the same amount of
492
+ * colour, so +x and -x look equally strong, and its hues avoid the red-green axis. Centre it on zero with `symmetricDomain`.
493
+ *
494
+ * A continuous quality is a magnitude even when low values are "good": stepping it onto verdict
495
+ * colours (green / amber / red) claims a threshold judgement nobody made.
496
+ *
497
+ * The sequential anchors are the matplotlib maps sampled at nine evenly spaced points. Linear
498
+ * interpolation between them stays within a few units of the full 256-entry tables. The
499
+ * diverging map was constructed in OKLab (equal lightness and chroma steps along each arm,
500
+ * mirrored in lightness, kept inside sRGB) and sampled at seventeen points.
501
+ */
502
+ /** The shipped maps. */
503
+ type ColormapName = "viridis" | "cividis" | "magma" | "inferno" | "blueOrange";
504
+ /** The names of the shipped maps. */
505
+ export declare const COLORMAPS: readonly ColormapName[];
506
+ /** The maps that run through a neutral middle, for a signed value: use them over a domain centred on zero. */
507
+ export declare const DIVERGING_COLORMAPS: readonly ColormapName[];
508
+ /**
509
+ * Whether a map is diverging.
510
+ *
511
+ * @param name - The map.
512
+ * @returns `true` for a map meant for a signed value around zero.
513
+ */
514
+ export declare function isDivergingColormap(name: ColormapName): boolean;
515
+ /**
516
+ * A domain centred on zero that holds a given one: `[-m, m]` with `m` the largest absolute end.
517
+ * Feed it a diverging map so the middle colour means zero.
518
+ *
519
+ * @param domain - `[low, high]`, or the values to cover.
520
+ * @returns `[-m, m]`; `[-1, 1]` when no end is finite and non-zero.
521
+ */
522
+ export declare function symmetricDomain(domain: readonly number[]): [number, number];
523
+ /**
524
+ * The colour of `t` on a map.
525
+ *
526
+ * @param name - The map.
527
+ * @param t - Position in `[0, 1]`; clamped. A non-finite `t` gives the map's low end.
528
+ * @returns A CSS `rgb(r g b)` colour.
529
+ */
530
+ export declare function colormap(name: ColormapName, t: number): string;
531
+ /**
532
+ * The colour of `t` on a map, as integer channels.
533
+ *
534
+ * @param name - The map.
535
+ * @param t - Position in `[0, 1]`; clamped.
536
+ * @returns `[r, g, b]`, each 0–255.
537
+ */
538
+ export declare function colormapRgb(name: ColormapName, t: number): [number, number, number];
539
+ /**
540
+ * A value's colour on a map, over a domain.
541
+ *
542
+ * @param name - The map.
543
+ * @param value - The value.
544
+ * @param domain - `[low, high]`: low maps to the map's start. A reversed domain reverses the map.
545
+ * For a diverging map pass a domain centred on zero (`symmetricDomain`).
546
+ * @returns A CSS colour.
410
547
  */
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;
548
+ export declare function colormapValue(name: ColormapName, value: number, domain: readonly [number, number]): string;
549
+ /**
550
+ * A CSS `linear-gradient` of a map, for a legend bar.
551
+ *
552
+ * @param name - The map.
553
+ * @param direction - The gradient's direction. Defaults to `to right`.
554
+ * @returns A CSS `background-image` value.
555
+ */
556
+ export declare function colormapGradient(name: ColormapName, direction?: string): string;
557
+ //#endregion
558
+ //#region src/ScatterChart.d.ts
559
+ /** One point of a {@link ScatterChart}. */
560
+ interface ScatterPoint {
561
+ /** Horizontal position, in x domain units. A non-finite value skips the point. */
562
+ x: number;
563
+ /** Vertical position, in y domain units. A non-finite value skips the point. */
564
+ y: number;
565
+ /** What `colourBy` colours it by. A point without one is drawn in the muted tone. */
566
+ value?: number | undefined;
567
+ }
568
+ /** One group of points of a {@link ScatterChart}. */
569
+ interface ScatterSeries {
570
+ /** Legend text, and the React key — unique within one chart. */
571
+ name: string;
572
+ /** The points. Their index here is what hover and pick report. */
573
+ points: readonly ScatterPoint[];
574
+ /** Any CSS colour. Omitted: {@link seriesColour} of the series' index. Ignored with `colourBy`. */
575
+ colour?: string | undefined;
576
+ }
577
+ /** Colour every point by its `value` through a map. */
578
+ interface ScatterColourBy {
579
+ /** The map. A diverging map centres on zero by default. */
580
+ map: ColormapName;
581
+ /** The values at the map's ends. Omitted: the extent of the points' values. */
582
+ domain?: readonly [number, number] | undefined;
583
+ /** Centre the domain on zero. Defaults to `true` for a diverging map, `false` otherwise. */
584
+ symmetric?: boolean | undefined;
585
+ /** What the colour encodes, written beside the scale. Required: a map is never shown unlabelled. */
586
+ label: string;
587
+ /** The values' unit, written after the scale's numbers. */
588
+ unit?: string | undefined;
589
+ }
590
+ /** A rule across the plot at one x or y: a tolerance, a mean, an expected value. */
591
+ interface ScatterReferenceLine {
592
+ /** Which axis the value is on: `"y"` is a horizontal rule, `"x"` a vertical one. */
593
+ axis: "x" | "y";
594
+ /** Where, in that axis' domain units. A value outside the domain is not drawn. */
595
+ value: number;
596
+ /** Text at the rule's end. */
597
+ label?: string | undefined;
598
+ /** Its colour. Default `"muted"`. */
599
+ tone?: MeasureTone | undefined;
600
+ }
601
+ /** A point of a {@link ScatterChart}, as hover and pick report it. */
602
+ interface ScatterPick {
603
+ /** The name of its series. */
604
+ series: string;
605
+ /** Its index in that series' `points`. */
606
+ index: number;
607
+ /** Its x. */
608
+ x: number;
609
+ /** Its y. */
610
+ y: number;
611
+ /** Its value, when it has one. */
612
+ value?: number | undefined;
613
+ }
614
+ /** Props for {@link ScatterChart}. */
615
+ interface ScatterChartProps {
616
+ /** The groups of points, drawn in order — a later series paints over an earlier one. */
617
+ series: readonly ScatterSeries[];
618
+ /** Accessible name of the chart (the SVG's `aria-label`). Required. */
619
+ label: string;
620
+ /** x-axis title. */
621
+ xLabel?: string | undefined;
622
+ /** y-axis title. */
623
+ yLabel?: string | undefined;
624
+ /** Fixed x domain. Omitted: the extent of every series' `x`, with 4 % on each side. */
625
+ xDomain?: [number, number] | undefined;
626
+ /** Fixed y domain. Omitted: the extent of every series' `y`, with 4 % on each side. */
627
+ yDomain?: [number, number] | undefined;
628
+ /** Colour points by their `value`, with a legend of the scale in the footer. */
629
+ colourBy?: ScatterColourBy | undefined;
630
+ /** Rules across the plot, drawn behind the points. */
631
+ referenceLines?: readonly ScatterReferenceLine[] | undefined;
632
+ /** Marker diameter in CSS pixels at the chart's own scale. Default 4. */
633
+ markerSize?: number | undefined;
634
+ /** Drawn behind the points, in plot pixels. A tolerance region or a fitted curve uses this. */
635
+ underlay?: ((x: Scale, y: Scale) => ReactNode) | undefined;
636
+ /** The point to draw as highlighted, from outside the chart (a hovered table row). */
637
+ highlighted?: {
638
+ series: string;
639
+ index: number;
640
+ } | null | undefined;
641
+ /**
642
+ * Called with the point nearest the pointer (within 10 plot units), or `null` when none is.
643
+ * Draws a ring on it and a readout of its numbers.
644
+ */
645
+ onHover?: ((point: ScatterPick | null) => void) | undefined;
646
+ /** Called with the point under a click. Makes the plot area a pointer target. */
647
+ onPick?: ((point: ScatterPick) => void) | undefined;
648
+ /** Rendered under the legend, inside the `<figcaption>`. */
649
+ footer?: ReactNode;
650
+ /** Show the series legend row (without `colourBy`). Default `true`. */
651
+ showLegend?: boolean | undefined;
652
+ /** Where the chart is going (see {@link Variant}). Default `"panel"`. */
653
+ variant?: Variant | undefined;
654
+ /** Extra classes for the outer `<figure>`, merged with `cn`. */
655
+ className?: string | undefined;
656
+ /** For `variant="fluid"`: the chart's height in CSS pixels. Default 200. */
657
+ height?: number | undefined;
658
+ }
659
+ /**
660
+ * A scatter plot over a shared frame — residuals against position, one run against another.
661
+ *
662
+ * @remarks
663
+ * An SVG `role="img"` named by `label`, with the series legend (or, with `colourBy`, the colour
664
+ * scale) as real text under it. Series are told apart by the legend's names, never by colour
665
+ * alone. `referenceLines` mark a value on either axis; `onHover` rings the nearest point and
666
+ * reads its numbers, `onPick` reports a click's point, and `highlighted` rings one chosen
667
+ * elsewhere. Picking is by pointer, so the same points must be reachable from a table beside
668
+ * the chart. A point with a non-finite coordinate is skipped.
669
+ */
670
+ 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;
671
+ //#endregion
672
+ //#region src/scatter.d.ts
673
+ /**
674
+ * The arithmetic behind `ScatterChart`: which point is under the pointer, which colour step a
675
+ * value falls in, and the domain a colour scale covers.
676
+ *
677
+ * Pure: the component is a thin list of SVG elements over it.
678
+ */
679
+ /** The number of colour steps a value-coloured series is quantised into: one path each. */
680
+ export declare const SCATTER_COLOUR_STEPS = 24;
681
+ /**
682
+ * The projected point nearest to a position, within a radius.
683
+ *
684
+ * @param xy - Flat `[x0, y0, x1, y1, …]` in the plot's own units (viewBox units); a non-finite
685
+ * coordinate is skipped.
686
+ * @param x - The query's x.
687
+ * @param y - The query's y.
688
+ * @param radius - How far from a point the query still picks it.
689
+ * @returns The index of the nearest point (the lower index on a tie), or `-1`.
690
+ */
691
+ export declare function nearestProjected(xy: ArrayLike<number>, x: number, y: number, radius: number): number;
692
+ /**
693
+ * The colour step of a value.
694
+ *
695
+ * @param value - The point's value.
696
+ * @param domain - `[low, high]`: `low` maps to the first step.
697
+ * @param steps - How many steps. Defaults to `SCATTER_COLOUR_STEPS`.
698
+ * @returns An integer in `[0, steps - 1]`; `-1` for a non-finite value; a degenerate domain puts
699
+ * every value in step `0`.
700
+ */
701
+ export declare function colourStep(value: number, domain: readonly [number, number], steps?: number): number;
702
+ /**
703
+ * The domain a value colouring covers.
704
+ *
705
+ * @param values - Every point's value; non-finite ones are ignored.
706
+ * @param symmetric - Centre it on zero, for a diverging map.
707
+ * @param given - A domain the caller fixed. It wins, centred if `symmetric`.
708
+ * @returns `[low, high]`; `[0, 1]` when there is no finite value.
709
+ */
710
+ export declare function colourDomain(values: Iterable<number>, symmetric: boolean, given?: readonly [number, number]): [number, number];
412
711
  //#endregion
413
712
  //#region src/BarChart.d.ts
414
713
  /**
@@ -613,61 +912,16 @@ interface LineProfileProps extends InteractionProps {
613
912
  */
614
913
  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
914
  //#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
915
  //#region src/ColormapLegend.d.ts
916
+ /** A value marked on a {@link ColormapLegend}: a threshold, a cursor value, a reference. */
917
+ interface ColormapMarker {
918
+ /** Where, in the legend's value units. A value outside the domain is left out. */
919
+ value: number;
920
+ /** The marker's text. Default: the value, formatted with the legend's `format` and `unit`. */
921
+ label?: string | undefined;
922
+ }
923
+ /** Which end of a {@link ColormapLegend} the data runs past: `"high"` is `≥ max`, `"low"` is `≤ min`. */
924
+ type ColormapClipped = "high" | "low" | "both";
671
925
  /** Props of `ColormapLegend`. */
672
926
  interface ColormapLegendProps {
673
927
  /** The map. */
@@ -678,16 +932,57 @@ interface ColormapLegendProps {
678
932
  unit?: string | undefined;
679
933
  /** What the colour encodes, written before the bar ("Validity", "Edge error"). */
680
934
  label: string;
681
- /** Formats the end values. Defaults to at most 3 significant figures, without trailing zeros. */
935
+ /** Formats the end and tick values. Defaults to at most 3 significant figures, without trailing zeros. */
682
936
  format?: ((value: number) => string) | undefined;
683
- /** Merged onto the row with `cn`. */
937
+ /**
938
+ * How the bar runs. `horizontal` (the default) is one line, low to high; `vertical` is a
939
+ * column with the label above and the high end at the top, for the side of a map.
940
+ */
941
+ orientation?: "horizontal" | "vertical" | undefined;
942
+ /**
943
+ * Values to label along the bar: a list, or a rough count of round ones. Without it a
944
+ * `horizontal` legend labels its two ends in line with the bar and a `vertical` one labels
945
+ * its two ends (and zero, when `symmetric`). With it the values sit along the bar, at their
946
+ * position on the map; values outside `domain` are left out. A count also labels the two ends.
947
+ */
948
+ ticks?: number | readonly number[] | undefined;
949
+ /**
950
+ * Centre the scale on zero for a diverging map: `domain` is widened to `[-m, m]` with `m`
951
+ * its largest absolute end, so the middle colour is zero and the middle tick says so.
952
+ */
953
+ symmetric?: boolean | undefined;
954
+ /**
955
+ * Values to mark on the bar: a number, a `{ value, label? }`, or a list of either. Each is a
956
+ * tick across the bar with its text beside it (above a horizontal bar, to the right of the
957
+ * ticks on a vertical one): the label, or else the value with the unit. The text carries the
958
+ * meaning; the tick is decorative. A value outside `domain` is left out.
959
+ */
960
+ marker?: number | ColormapMarker | readonly (number | ColormapMarker)[] | undefined;
961
+ /**
962
+ * The scale saturates: the data runs past the end of `domain`. The end gets a cap (a small
963
+ * arrow in the end colour) and its value reads `≥ max` (`high`) or `≤ min` (`low`); `both`
964
+ * does both ends. The end value is labelled even when `ticks` leaves it out.
965
+ */
966
+ clipped?: ColormapClipped | undefined;
967
+ /** For `vertical`: the bar's length in CSS pixels. Defaults to 160. */
968
+ length?: number | undefined;
969
+ /** Merged onto the legend with `cn`. */
684
970
  className?: string | undefined;
685
971
  }
686
972
  /**
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.
973
+ * A gradient bar with its values and unit.
974
+ *
975
+ * - **Horizontal**: one line, "Edge error 0 [bar] 2.5 px". With `ticks` or `symmetric` the values
976
+ * sit under the bar at their position instead.
977
+ * - **Vertical**: the label above a column bar, the high end at the top, the values beside the
978
+ * bar at their position, and the unit after the label.
979
+ *
980
+ * `marker` ticks values on the bar (a threshold, the value under a cursor) and `clipped` says
981
+ * the scale saturates at an end, with a cap and `≥` / `≤` on its value.
982
+ *
983
+ * The bar is decorative; the label, the values and the markers' text carry the meaning.
689
984
  */
690
- export declare function ColormapLegend({ map, domain, unit, label, format, className }: ColormapLegendProps): import("react").JSX.Element;
985
+ export declare function ColormapLegend({ map, domain, unit, label, format, orientation, ticks, symmetric, marker, clipped, length, className }: ColormapLegendProps): import("react").JSX.Element;
691
986
  //#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 };
987
+ 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
988
  //# sourceMappingURL=index.d.ts.map