@umriss-ui/charts 0.10.0 → 0.12.0

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/dist/index.d.ts CHANGED
@@ -1,26 +1,16 @@
1
1
  import { CSSProperties } from 'react';
2
2
  import { ReactNode } from 'react';
3
3
 
4
- /** Value access of a series. Compared by its source text, not its identity - an
5
- inline accessor is new on every render. Known limit: one that reads a
6
- changed closure variable under the same text is not run again; pass a new
7
- data reference then. A native or bound function is compared by identity. */
8
- export declare type Accessor<T> = (d: T, index: number) => number | null | undefined;
9
-
10
- /** A series drawn as a filled area between its values and a baseline, 0
11
- without one. Renders nothing itself: it registers with the surrounding
12
- `Chart`. With `stack`, areas stand on each other. */
13
- export declare function Area<T>(props: AreaProps<T>): null;
14
-
15
4
  /** The props of `Area`. */
16
5
  export declare interface AreaProps<T> {
17
- /** Upper edge; null/undefined/NaN/±Infinity means a gap.
6
+ /** Upper edge - a number field of the row or a function of it;
7
+ null/undefined/NaN/±Infinity means a gap.
18
8
  @remarks R-2.5 */
19
- accessor: Accessor<T>;
20
- /** Lower edge. In a `stack` the stack below is the lower edge, and this is
9
+ value: Value<T>;
10
+ /** Lower edge - a number field of the row or a function of it. In a `stack` the stack below is the lower edge, and this is
21
11
  not read.
22
12
  @default a fixed baseline at 0 */
23
- baseline?: Accessor<T>;
13
+ baseline?: Value<T>;
24
14
  /** Binding to an x axis.
25
15
  @remarks R-4.12 */
26
16
  xAxisId?: string;
@@ -34,10 +24,6 @@ export declare interface AreaProps<T> {
34
24
  unnamed series is a colour nobody can look up.
35
25
  @default "Series n", after its place in the chart */
36
26
  name?: string;
37
- /** Not drawn, not hit and not counted for its axes' extent - a fixed
38
- `domain` keeps the axis still. Its legend entry stays, drawn back.
39
- Controlled: the caller sets it, typically from `Legend onToggle`. */
40
- hidden?: boolean;
41
27
  /** The value as the tooltip writes it.
42
28
  @default the y axis' `tickFormat`, else the built-in number format */
43
29
  format?: (value: number) => string;
@@ -72,7 +58,7 @@ export declare interface AreaProps<T> {
72
58
  export declare interface AreaSeriesConfig<T = unknown> extends SeriesBase<T>, Stackable {
73
59
  kind: "area";
74
60
  /** Lower edge; without a value the fixed baseline 0. */
75
- baseline?: Accessor<T>;
61
+ baseline?: ValueFunction<T>;
76
62
  /** Opacity of the fill; the outline stays fully opaque. */
77
63
  fillOpacity: number;
78
64
  strokeWidth: number;
@@ -123,7 +109,9 @@ export declare interface AxisConfig<T = unknown> {
123
109
  id: string;
124
110
  orientation: AxisOrientation;
125
111
  position: AxisPosition;
126
- accessor: (d: T, index: number) => number;
112
+ /** Where a row lies along the axis; an x axis' only - along y the series
113
+ place their rows. */
114
+ accessor?: (d: T, index: number) => number;
127
115
  label?: string;
128
116
  tickCount?: number;
129
117
  tickFormat?: (v: number) => string;
@@ -147,9 +135,12 @@ export declare interface AxisConfig<T = unknown> {
147
135
  calendar?: readonly WorkingInterval[];
148
136
  /** y axes only: this axis' ticks on the first y axis' grid. */
149
137
  alignTicks?: boolean;
150
- /** x axes only: where wheel, drag, pinch and double click propose a
151
- domain. Without it the axis does not zoom. */
152
- onDomainChange?: (domain: [number, number]) => void;
138
+ /** x axes only: wheel, drag, pinch, double click and the zoom keys move
139
+ the span the chart's view holds for this axis (ADR-0047). */
140
+ zoomable?: boolean;
141
+ /** x axes only: the narrowest and the widest span zoom may reach.
142
+ @default at most the data's extent, at least three data steps */
143
+ zoomLimits?: ZoomLimits;
153
144
  }
154
145
 
155
146
  /** Whether an axis or a limit runs along x or along y. */
@@ -159,17 +150,15 @@ export declare type AxisOrientation = "x" | "y";
159
150
  `right` for y. */
160
151
  export declare type AxisPosition = "bottom" | "top" | "left" | "right";
161
152
 
162
- /** A series drawn as bars from 0 to its values, on the numeric x axis.
163
- Several bar series on one x axis stand side by side, or on each other with
164
- `stack`. Renders nothing itself: it registers with the surrounding
165
- `Chart`. */
166
- export declare function Bar<T>(props: BarProps<T>): null;
153
+ /** The span each zoomable x axis shows, by axis `id`, in the axis' units. */
154
+ export declare type AxisSpans = Readonly<Record<string, readonly [number, number]>>;
167
155
 
168
156
  /** The props of `Bar`. */
169
157
  export declare interface BarProps<T> {
170
- /** Height; null/undefined/NaN/±Infinity means a gap.
158
+ /** Height - a number field of the row or a function of it;
159
+ null/undefined/NaN/±Infinity means a gap.
171
160
  @remarks R-2.5 */
172
- accessor: Accessor<T>;
161
+ value: Value<T>;
173
162
  /** Binding to an x axis.
174
163
  @remarks R-4.12 */
175
164
  xAxisId?: string;
@@ -183,10 +172,6 @@ export declare interface BarProps<T> {
183
172
  unnamed series is a colour nobody can look up.
184
173
  @default "Series n", after its place in the chart */
185
174
  name?: string;
186
- /** Not drawn, not hit and not counted for its axes' extent - a fixed
187
- `domain` keeps the axis still. Its legend entry stays, drawn back.
188
- Controlled: the caller sets it, typically from `Legend onToggle`. */
189
- hidden?: boolean;
190
175
  /** The value as the tooltip writes it.
191
176
  @default the y axis' `tickFormat`, else the built-in number format */
192
177
  format?: (value: number) => string;
@@ -250,42 +235,37 @@ export declare interface BoxNumbers<V = number> {
250
235
  upperWhisker: V;
251
236
  }
252
237
 
253
- /** A series drawn as a box per x: median, quartiles and whiskers, optionally
254
- outliers, a mean and a notch. The caller brings every number - the library
255
- computes none. Renders nothing itself: it registers with the surrounding
256
- `Chart`. */
257
- export declare function BoxPlot<T>(props: BoxPlotProps<T>): null;
258
-
259
- /** The props of `BoxPlot`. */
238
+ /** The props of `BoxPlot`. Every number is a number field of the row or a
239
+ function of it; `outliers` a list field or a function. */
260
240
  export declare interface BoxPlotProps<T> {
261
241
  /** The line across the box; null/undefined/NaN/±Infinity means a gap - no
262
242
  box is drawn there, whatever the other numbers say.
263
243
  @remarks R-2.5 */
264
- median: Accessor<T>;
244
+ median: Value<T>;
265
245
  /** The box's lower edge. */
266
- lowerQuartile: Accessor<T>;
246
+ lowerQuartile: Value<T>;
267
247
  /** The box's upper edge. */
268
- upperQuartile: Accessor<T>;
248
+ upperQuartile: Value<T>;
269
249
  /** Where the lower whisker ends - the caller's rule, not the minimum. */
270
- lowerWhisker: Accessor<T>;
250
+ lowerWhisker: Value<T>;
271
251
  /** Where the upper whisker ends - the caller's rule, not the maximum. */
272
- upperWhisker: Accessor<T>;
252
+ upperWhisker: Value<T>;
273
253
  /** The values beyond the whiskers, per box: an array, empty or missing
274
254
  where there are none. Drawn with their box in its colour - one beyond
275
255
  three IQR of the box's own quartiles as a ring -, read in its tooltip
276
256
  and table row, never hit on their own (ADR-0040). */
277
- outliers?: ListAccessor<T>;
257
+ outliers?: ListValue<T>;
278
258
  /** The mean, drawn as a small ×: beside the median it shows a skew. */
279
- mean?: Accessor<T>;
259
+ mean?: Value<T>;
280
260
  /** The notch's lower bound - usually of a confidence interval of the
281
261
  median. Both bounds or neither: one alone warns in DEV and is not
282
262
  drawn. */
283
- notchLower?: Accessor<T>;
263
+ notchLower?: Value<T>;
284
264
  /** The notch's upper bound; see `notchLower`. */
285
- notchUpper?: Accessor<T>;
265
+ notchUpper?: Value<T>;
286
266
  /** How many values stand behind the box; read in the tooltip and the
287
267
  table, not drawn. */
288
- count?: Accessor<T>;
268
+ count?: Value<T>;
289
269
  /** Binding to an x axis.
290
270
  @remarks R-4.12 */
291
271
  xAxisId?: string;
@@ -298,9 +278,6 @@ export declare interface BoxPlotProps<T> {
298
278
  /** The name in legend and tooltip. Without one a warning stands in DEV.
299
279
  @default "Series n", after its place in the chart */
300
280
  name?: string;
301
- /** Not drawn, not hit and not counted for its axes' extent. Its legend
302
- entry stays, drawn back. Controlled, typically from `Legend onToggle`. */
303
- hidden?: boolean;
304
281
  /** Every number of the box as the tooltip and the table write it.
305
282
  @default the y axis' `tickFormat`, else the built-in number format */
306
283
  format?: (value: number) => string;
@@ -321,18 +298,18 @@ export declare interface BoxPlotProps<T> {
321
298
  chose - the library draws them and computes none. */
322
299
  export declare interface BoxSeriesConfig<T = unknown> extends SeriesBase<T> {
323
300
  kind: "box";
324
- lowerQuartile: Accessor<T>;
325
- upperQuartile: Accessor<T>;
326
- lowerWhisker: Accessor<T>;
327
- upperWhisker: Accessor<T>;
301
+ lowerQuartile: ValueFunction<T>;
302
+ upperQuartile: ValueFunction<T>;
303
+ lowerWhisker: ValueFunction<T>;
304
+ upperWhisker: ValueFunction<T>;
328
305
  /** The values beyond the whiskers, per box (ADR-0040). */
329
- outliers?: ListAccessor<T>;
330
- mean?: Accessor<T>;
306
+ outliers?: ListFunction<T>;
307
+ mean?: ValueFunction<T>;
331
308
  /** Both bounds or neither (CONTEXT.md: Notch). */
332
- notchLower?: Accessor<T>;
333
- notchUpper?: Accessor<T>;
309
+ notchLower?: ValueFunction<T>;
310
+ notchUpper?: ValueFunction<T>;
334
311
  /** How many values stand behind the box; no y value. */
335
- count?: Accessor<T>;
312
+ count?: ValueFunction<T>;
336
313
  /** Width as a fraction of the step; boxes and bars on one x axis share it. */
337
314
  boxWidth: number;
338
315
  }
@@ -349,10 +326,58 @@ export declare function calendarFrom(input: CalendarInput): WorkingCalendar;
349
326
  axis, or the calendar built from it. */
350
327
  export declare type CalendarInput = WorkingCalendar | readonly WorkingInterval[];
351
328
 
352
- /** The container of a chart: it holds the data, measures the plot area and
353
- draws on canvas whatever its children register - axes, series, limits,
354
- legend and tooltip. The order of the children is the drawing order. */
355
- export declare function Chart<T>(props: ChartProps<T>): ReactNode;
329
+ /** What `useChart` takes besides the rows: the view to start from and the
330
+ handler that hears every change of it. */
331
+ export declare interface ChartOptions {
332
+ /** The view to start from, and to go to whenever one differing in content
333
+ from the last is handed in - the same view again changes nothing, and
334
+ what it leaves out is reset; one the chart reported itself, handed back
335
+ late, is its own state coming back and not gone to - two charts in step
336
+ do not jump back mid-pan. The chart remembers none: where a view is kept
337
+ is the application's decision. */
338
+ initialView?: ChartView;
339
+ /** Every change of the view, once, always the whole view - the one to keep,
340
+ or to hand another chart as its `initialView`. A pan or zoom is reported
341
+ at most once per frame. Not called for the view the chart starts with. */
342
+ onViewChange?: (view: ChartView) => void;
343
+ }
344
+
345
+ /** What `useChart` hands back: the chart and its parts, typed at the row `Z`,
346
+ its view and the setters that change it. A series given `data` of its own
347
+ is typed by that `data` instead. */
348
+ export declare interface ChartParts<Z> {
349
+ /** The chart over the hook's rows. One per `useChart`: it holds the view,
350
+ and a second chart is a second call. */
351
+ Chart: (props: ChartProps) => ReactNode;
352
+ /** An x axis reads the rows of every series bound to it: the hook's, or
353
+ with `<XAxis<Row>>` those the series bring as their own `data`. */
354
+ XAxis: <T = Z>(props: XAxisProps<T>) => null;
355
+ YAxis: (props: YAxisProps) => null;
356
+ Line: <T = Z>(props: LineProps<T>) => null;
357
+ Area: <T = Z>(props: AreaProps<T>) => null;
358
+ Bar: <T = Z>(props: BarProps<T>) => null;
359
+ Scatter: <T = Z>(props: ScatterProps<T>) => null;
360
+ StateBand: <T = Z>(props: StateBandProps<T>) => null;
361
+ Matrix: <T = Z>(props: MatrixProps<T>) => null;
362
+ BoxPlot: <T = Z>(props: BoxPlotProps<T>) => null;
363
+ /** How the reader is looking at the chart. */
364
+ view: ChartView;
365
+ /** The span each zoomable x axis shows, by axis `id`; an axis absent shows
366
+ its own `domain`. */
367
+ domains: AxisSpans;
368
+ /** Puts a span in view on a zoomable x axis - a lone one is `"x"`; `null`
369
+ shows the axis' own `domain` again. */
370
+ setDomain: (axisId: string, span: readonly [number, number] | null) => void;
371
+ /** The hidden series, by `name`. */
372
+ hidden: readonly string[];
373
+ /** Hides the series `name`, or shows it where it is hidden - as a click on
374
+ its legend entry does. Hiding the last series visible shows all. */
375
+ toggleSeries: (name: string) => void;
376
+ /** Hides every series but `name`; all are shown where none carries it. */
377
+ showOnly: (name: string) => void;
378
+ /** Shows every series again. */
379
+ showAllSeries: () => void;
380
+ }
356
381
 
357
382
  /** Measurements of the instrumentation for the benchmark page.
358
383
  @remarks R-5.1 */
@@ -362,11 +387,9 @@ export declare interface ChartPerf {
362
387
  points: number;
363
388
  }
364
389
 
365
- /** The props of `Chart`. */
366
- export declare interface ChartProps<T> {
367
- /** Shared data basis (required); access only through accessors.
368
- @remarks R-2.4 */
369
- data: readonly T[];
390
+ /** The props of `Chart`. Its rows are not among them: `useChart(rows)` binds
391
+ them (ADR-0048). */
392
+ export declare interface ChartProps {
370
393
  /** Width in CSS pixels, or `"100%"` for the host's: the chart measures its
371
394
  host and follows it through a ResizeObserver.
372
395
  @default "100%" */
@@ -388,9 +411,15 @@ export declare interface ChartProps<T> {
388
411
  style?: CSSProperties;
389
412
  /** Shown in the middle of the plot area when no visible series has a point
390
413
  to show - no data, only gaps, or every series hidden. Axes and frame
391
- stay.
414
+ stay. Not while `loading`.
392
415
  @default the wording's `empty` */
393
416
  empty?: ReactNode;
417
+ /** The rows are on their way, as the table's `loading` says (ADR-0042). A
418
+ course already drawn stays: it dims after a moment and takes no pointer
419
+ until the answer is in. Where there is nothing to show, the empty
420
+ message waits. The plot is `aria-busy` meanwhile.
421
+ @default false */
422
+ loading?: boolean;
394
423
  /** The chart's words (ADR-0031); entries left out fall back to English.
395
424
  German: `GERMAN_CHARTS_WORDING` from `@umriss-ui/charts/wording/de`.
396
425
  @default DEFAULT_CHARTS_WORDING */
@@ -405,8 +434,9 @@ export declare interface ChartProps<T> {
405
434
  encoding?: "color" | "marks";
406
435
  /** Charts with the same id share the pointer's x position, in domain units:
407
436
  each draws its crosshair there, the tooltip stays with the chart under
408
- the pointer. Zoom is not shared - give every chart the same controlled
409
- `domain`. */
437
+ the pointer. Zoom is not shared this way: charts zoom together by
438
+ handing each other their view (`useChart`'s `initialView` and
439
+ `onViewChange`). */
410
440
  syncId?: string;
411
441
  /** Instrumentation for the benchmark page; not needed otherwise.
412
442
  @remarks R-5.1 */
@@ -448,6 +478,14 @@ export declare interface ChartsWording {
448
478
  walkHelp: string;
449
479
  /** The keys that zoom and pan it - only where the chart can be zoomed. */
450
480
  zoomHelp: string;
481
+ /** The keys of the legend's entries - only where it has one to press. */
482
+ legendHelp: string;
483
+ /** Read out where hiding would leave nothing to see, and every series is
484
+ shown instead. */
485
+ allShown: string;
486
+ /** The control over a zoomed plot that brings every zoomed axis back to
487
+ its own domain (component-view 04). */
488
+ showAll: string;
451
489
  /** The data table's disclosure key, closed and open (charts-alternatives
452
490
  C1). */
453
491
  showData: string;
@@ -479,13 +517,21 @@ export declare interface ChartsWording {
479
517
  downsampled: (readings: number) => string;
480
518
  }
481
519
 
482
- declare interface CommonProps<T> {
520
+ /** How a reader is looking at a chart. Whatever is at its default is absent. */
521
+ export declare interface ChartView {
522
+ /** The span each zoomable x axis shows, by axis `id` - a lone x axis is
523
+ `"x"`. An axis absent here shows its own `domain`. An id that names no
524
+ zoomable x axis falls out. */
525
+ domains?: AxisSpans;
526
+ /** The hidden series, by `name`; a series without one cannot be hidden. A
527
+ name no series carries falls out. */
528
+ hidden?: readonly string[];
529
+ }
530
+
531
+ declare interface CommonProps {
483
532
  /** Axis id, through which series bind themselves.
484
533
  @remarks R-4.12 */
485
534
  id?: string;
486
- /** Value access of this axis. Compared by its source text, as a series'
487
- accessor is (`Accessor`) - with the same closure limit. */
488
- accessor: (d: T, index: number) => number;
489
535
  /** Axis title. */
490
536
  label?: string;
491
537
  /** Target value; the 1-2-5 algorithm may deviate. */
@@ -513,8 +559,9 @@ export declare function ControlChart<T>(props: ControlChartProps<T>): ReactNode;
513
559
 
514
560
  /** The props of `ControlChart`. */
515
561
  export declare interface ControlChartProps<T> {
516
- /** The values of the chart. */
517
- accessor: Accessor<T>;
562
+ /** The values of the chart - a number field of its `data`'s rows or a
563
+ function of them. */
564
+ value: Value<T>;
518
565
  /** Required: the limits arise out of these values, not out of what happens to
519
566
  be visible. */
520
567
  data: readonly T[];
@@ -630,6 +677,27 @@ export declare const DEFAULT_GRADIENT: readonly string[];
630
677
  lengths are therefore parameters. */
631
678
  export declare const defaultRules: RuleOptions;
632
679
 
680
+ /** The views a component reported that may still come back, by their
681
+ content key - the chart's and the schedule's (ADR-0047), the table holding
682
+ a copy of its own. An application keeping the view hands
683
+ it back a frame or more late - by then a pan has moved on, and going to the
684
+ view handed in would jump back. So a view handed in that equals one
685
+ reported since the last one handed in, within a second, is the component's
686
+ own state coming back, not a view to go to. The echoes come in order: one drops
687
+ itself and every older report, a view from outside drops them all. The
688
+ second bounds the list where nothing is handed back, and lets such an
689
+ application still restore a view it kept. */
690
+ export declare class Echoes {
691
+ private reports;
692
+ /** Notes a view reported, by its key. */
693
+ reported(key: string): void;
694
+ /** Whether the view handed in is a report coming back. */
695
+ has(key: string): boolean;
696
+ /** Forgets what the view handed in answers. */
697
+ handed(key: string): void;
698
+ private at;
699
+ }
700
+
633
701
  /** One hour in milliseconds. */
634
702
  export declare const HOUR: number;
635
703
 
@@ -638,9 +706,12 @@ export declare const HOUR: number;
638
706
  export declare function invalidateTheme(): void;
639
707
 
640
708
  /** The legend of a chart: one entry per series, or per state of a state band.
641
- Hovering an entry highlights its series; with `onToggle` a click hides and
642
- shows it. */
643
- export declare function Legend({ placement, onToggle }: LegendProps): ReactNode;
709
+ Hovering an entry highlights its series; a click hides and shows it, a
710
+ state's entry the whole band - through the chart's view. A double click,
711
+ Alt+click or Shift+Enter shows only it, or all where it is the only one
712
+ visible. Nothing hides every series: what would shows all, and the live
713
+ region says so. */
714
+ export declare function Legend({ placement }: LegendProps): ReactNode;
644
715
 
645
716
  /** A `Legend` as the chart holds it once registered. */
646
717
  export declare interface LegendConfig {
@@ -652,10 +723,6 @@ export declare interface LegendProps {
652
723
  /** Which side of the plot area the legend stands on.
653
724
  @default "top" */
654
725
  placement?: "top" | "bottom";
655
- /** Called with an entry's name when it is clicked - the series' name, or a
656
- state's label. The caller flips `hidden` on the series it means. Without
657
- it the legend is not clickable. */
658
- onToggle?: (name: string) => void;
659
726
  }
660
727
 
661
728
  /** A bound: a value, a side and a severity. No more - a tolerance band is
@@ -779,10 +846,6 @@ export declare interface LimitSet {
779
846
  target?: number;
780
847
  }
781
848
 
782
- /** A series drawn as a line through its values; a gap breaks it. Renders
783
- nothing itself: it registers with the surrounding `Chart`. */
784
- export declare function Line<T>(props: LineProps<T>): null;
785
-
786
849
  /** The affine mapping from a domain onto a pixel range, and back; the scale
787
850
  every axis of the library uses. */
788
851
  export declare class LinearScale implements Scale {
@@ -799,9 +862,10 @@ export declare class LinearScale implements Scale {
799
862
 
800
863
  /** The props of `Line`. */
801
864
  export declare interface LineProps<T> {
802
- /** Y value; null/undefined/NaN/±Infinity means a gap.
865
+ /** Y value - a number field of the row or a function of it;
866
+ null/undefined/NaN/±Infinity means a gap.
803
867
  @remarks R-2.5 */
804
- accessor: Accessor<T>;
868
+ value: Value<T>;
805
869
  /** Binding to an x axis.
806
870
  @remarks R-4.12 */
807
871
  xAxisId?: string;
@@ -815,10 +879,6 @@ export declare interface LineProps<T> {
815
879
  unnamed series is a colour nobody can look up.
816
880
  @default "Series n", after its place in the chart */
817
881
  name?: string;
818
- /** Not drawn, not hit and not counted for its axes' extent - a fixed
819
- `domain` keeps the axis still. Its legend entry stays, drawn back.
820
- Controlled: the caller sets it, typically from `Legend onToggle`. */
821
- hidden?: boolean;
822
882
  /** The value as the tooltip writes it.
823
883
  @default the y axis' `tickFormat`, else the built-in number format */
824
884
  format?: (value: number) => string;
@@ -852,9 +912,18 @@ export declare interface LineSeriesConfig<T = unknown> extends SeriesBase<T> {
852
912
  step?: boolean;
853
913
  }
854
914
 
855
- /** A list per datum - a box's outliers (ADR-0040). null/undefined or an
915
+ /** The fields of a row whose value is a list of numbers, or absent. */
916
+ export declare type ListField<T> = NoInfer<{
917
+ [K in keyof T & string]-?: T[K] extends readonly number[] | null | undefined ? K : never;
918
+ }[keyof T & string]>;
919
+
920
+ /** A list computed from the row - a box's outliers (ADR-0040), the
921
+ function form of `ListValue`. null/undefined or an
856
922
  empty array is none; a value that is not finite is left out. */
857
- export declare type ListAccessor<T> = (d: T, index: number) => readonly number[] | null | undefined;
923
+ export declare type ListFunction<T> = (d: T, index: number) => readonly number[] | null | undefined;
924
+
925
+ /** A list read from the row: the name of a list field or a function. */
926
+ export declare type ListValue<T> = ListField<T> | ListFunction<T>;
858
927
 
859
928
  /** The local offset at an instant, as the shift of a grid that is to lie on
860
929
  local time: `wallClock = offset + k · step`. Taken at one instant, it holds
@@ -875,7 +944,7 @@ export declare interface MaterializedSeries {
875
944
  A fixed baseline needs no channel - it is a number.
876
945
  @remarks R-2.7 */
877
946
  y0: Float64Array | null;
878
- /** Value channel: the third value per point, which today only the matrix
947
+ /** Level channel: the third value per point, which today only the matrix
879
948
  needs. Named rather than overloading y0 - a property that only some kinds
880
949
  carry does not belong in the shared type with a comment (ADR-0011). null
881
950
  for every kind that does not use it. */
@@ -886,12 +955,6 @@ export declare interface MaterializedSeries {
886
955
  length: number;
887
956
  }
888
957
 
889
- /** A series drawn as a grid of coloured cells: the accessor gives the row,
890
- `value` the colour - by the limits of an assessment or across a gradient.
891
- A missing value is a hole, not a zero. Renders nothing itself: it registers
892
- with the surrounding `Chart`. */
893
- export declare function Matrix<T>(props: MatrixProps<T>): null;
894
-
895
958
  /** How a matrix colours its cells. Discretely by assessment - the same limits
896
959
  that colour a tile - or across a gradient. */
897
960
  export declare type MatrixColoring = {
@@ -912,11 +975,13 @@ export declare type MatrixColoring = {
912
975
 
913
976
  /** The props of `Matrix`. */
914
977
  export declare interface MatrixProps<T> {
915
- /** Row position on the y axis. */
916
- accessor: Accessor<T>;
917
- /** The value that decides the colour. */
918
- value: Accessor<T>;
919
- /** How the value colours a cell: by assessment against limits, or across
978
+ /** Row position on the y axis - a number field of the row or a function
979
+ of it, as every series' y position. */
980
+ value: Value<T>;
981
+ /** The level that decides the colour - a number field of the row or a
982
+ function of it. A missing level is a hole, not a zero. */
983
+ level: Value<T>;
984
+ /** How the level colours a cell: by assessment against limits, or across
920
985
  a gradient.
921
986
  @default { kind: "gradient", stops: DEFAULT_GRADIENT } */
922
987
  coloring?: MatrixColoring;
@@ -933,29 +998,30 @@ export declare interface MatrixProps<T> {
933
998
  unnamed series is a colour nobody can look up.
934
999
  @default "Series n", after its place in the chart */
935
1000
  name?: string;
936
- /** Not drawn, not hit and not counted for its axes' extent - a fixed
937
- `domain` keeps the axis still. Its legend entry stays, drawn back.
938
- Controlled: the caller sets it, typically from `Legend onToggle`. */
939
- hidden?: boolean;
940
- /** The value as the tooltip writes it. The y axis' `tickFormat` writes the
941
- row, not the value.
1001
+ /** The level as the tooltip writes it. The y axis' `tickFormat` writes the
1002
+ row, not the level.
942
1003
  @default the built-in number format */
943
1004
  format?: (value: number) => string;
944
1005
  }
945
1006
 
946
1007
  /** A `Matrix` as the chart holds it once registered: its base accessor is the
947
- row, `value` the colour. */
1008
+ row, `level` the colour. */
948
1009
  export declare interface MatrixSeriesConfig<T = unknown> extends SeriesBase<T> {
949
1010
  kind: "matrix";
950
- /** The value that decides the colour - the third channel (ADR-0011).
951
- The base accessor yields the row position, not this value. */
952
- value: Accessor<T>;
1011
+ /** The level that decides the colour - the third channel (ADR-0011).
1012
+ The base accessor yields the row position, not this level. */
1013
+ level: ValueFunction<T>;
953
1014
  coloring: MatrixColoring;
954
1015
  }
955
1016
 
956
1017
  /** One minute in milliseconds. */
957
1018
  export declare const MINUTE: number;
958
1019
 
1020
+ /** The fields of a row whose value is a number, or absent. */
1021
+ export declare type NumberField<T> = NoInfer<{
1022
+ [K in keyof T & string]-?: T[K] extends number | null | undefined ? K : never;
1023
+ }[keyof T & string]>;
1024
+
959
1025
  /** Space in CSS pixels on each side of a rectangle. */
960
1026
  export declare interface Padding {
961
1027
  top: number;
@@ -1157,15 +1223,12 @@ export declare interface Scale {
1157
1223
  ticks(n: number): number[];
1158
1224
  }
1159
1225
 
1160
- /** A series drawn as points only, one per value. Renders nothing itself: it
1161
- registers with the surrounding `Chart`. */
1162
- export declare function Scatter<T>(props: ScatterProps<T>): null;
1163
-
1164
1226
  /** The props of `Scatter`. */
1165
1227
  export declare interface ScatterProps<T> {
1166
- /** Y value; null/undefined/NaN/±Infinity means a gap.
1228
+ /** Y value - a number field of the row or a function of it;
1229
+ null/undefined/NaN/±Infinity means a gap.
1167
1230
  @remarks R-2.5 */
1168
- accessor: Accessor<T>;
1231
+ value: Value<T>;
1169
1232
  /** Binding to an x axis.
1170
1233
  @remarks R-4.12 */
1171
1234
  xAxisId?: string;
@@ -1179,10 +1242,6 @@ export declare interface ScatterProps<T> {
1179
1242
  unnamed series is a colour nobody can look up.
1180
1243
  @default "Series n", after its place in the chart */
1181
1244
  name?: string;
1182
- /** Not drawn, not hit and not counted for its axes' extent - a fixed
1183
- `domain` keeps the axis still. Its legend entry stays, drawn back.
1184
- Controlled: the caller sets it, typically from `Legend onToggle`. */
1185
- hidden?: boolean;
1186
1245
  /** The value as the tooltip writes it.
1187
1246
  @default the y axis' `tickFormat`, else the built-in number format */
1188
1247
  format?: (value: number) => string;
@@ -1210,7 +1269,7 @@ export declare const SECOND = 1000;
1210
1269
  export declare interface SeriesBase<T = unknown> {
1211
1270
  /** Y value; null/undefined/NaN/±Infinity means a gap.
1212
1271
  @remarks R-2.5 */
1213
- accessor: Accessor<T>;
1272
+ accessor: ValueFunction<T>;
1214
1273
  /** Series-own data; overrides the container data.
1215
1274
  @remarks R-2.4 */
1216
1275
  data?: readonly T[];
@@ -1225,8 +1284,6 @@ export declare interface SeriesBase<T = unknown> {
1225
1284
  For series that mean something rather than just being the next one - the
1226
1285
  violating points of a control chart, say. `color` beats it. */
1227
1286
  tone?: "ok" | "warning" | "alarm";
1228
- /** Not drawn, not hit, not in its axes' extent; its legend entry stays. */
1229
- hidden?: boolean;
1230
1287
  }
1231
1288
 
1232
1289
  /** Any registered series, told apart by `kind`. */
@@ -1258,20 +1315,13 @@ declare interface Stackable {
1258
1315
  normalize?: boolean;
1259
1316
  }
1260
1317
 
1261
- /** A band of states: each point's state holds from its x until the next
1262
- point's. The last one holds until the latest reading of the chart - the
1263
- last x of any visible series on the same x axis - and where the band itself
1264
- reports last, one median step of its own x values past its last point;
1265
- never beyond the x domain. A state is claimed for as long as it was
1266
- reported, not until the axis' rounded end. */
1267
- export declare function StateBand<T>(props: StateBandProps<T>): null;
1268
-
1269
1318
  /** The props of `StateBand`. */
1270
1319
  export declare interface StateBandProps<T> {
1271
- /** Index of the state in `states`; null/undefined/NaN/±Infinity is a gap -
1320
+ /** Index of the state in `states` - a number field of the row or a
1321
+ function of it; null/undefined/NaN/±Infinity is a gap -
1272
1322
  and a gap stays a hole, it gets no colour for "unknown". A colour would
1273
1323
  be a claim about the interval. */
1274
- accessor: Accessor<T>;
1324
+ value: Value<T>;
1275
1325
  /** The closed set of states, in the order of their codes. */
1276
1326
  states: readonly StateEntry[];
1277
1327
  /** Binding to an x axis.
@@ -1287,10 +1337,6 @@ export declare interface StateBandProps<T> {
1287
1337
  unnamed series is a colour nobody can look up.
1288
1338
  @default "Series n", after its place in the chart */
1289
1339
  name?: string;
1290
- /** Not drawn, not hit and not counted for its axes' extent - a fixed
1291
- `domain` keeps the axis still. Its legend entry stays, drawn back.
1292
- Controlled: the caller sets it, typically from `Legend onToggle`. */
1293
- hidden?: boolean;
1294
1340
  /** Lower edge of the lane in domain units of the y axis. */
1295
1341
  laneFrom?: number;
1296
1342
  /** Upper edge of the lane in domain units of the y axis. */
@@ -1363,11 +1409,11 @@ export declare interface TooltipPoint<T = unknown> {
1363
1409
  yValue: number;
1364
1410
  datum: T;
1365
1411
  index: number;
1366
- /** Only for the matrix: the value out of the value channel. It stands here and
1412
+ /** Only for the matrix: its level, out of the level channel. It stands here and
1367
1413
  not in yValue, because yValue is the position on the y axis - for a matrix
1368
1414
  therefore the row. Putting both into one field would be exactly the
1369
1415
  overloading ADR-0011 is written against. */
1370
- value?: number;
1416
+ level?: number;
1371
1417
  /** Only for state series: the section being pointed at.
1372
1418
  A duration does not stand here - it is the difference of two numbers the
1373
1419
  entry already carries, and formatting it would presuppose knowing what the
@@ -1378,7 +1424,7 @@ export declare interface TooltipPoint<T = unknown> {
1378
1424
  label: string;
1379
1425
  };
1380
1426
  /** Only for a box: its further numbers; yValue is its median. Fields of
1381
- their own for the reason `value` has one (ADR-0011). */
1427
+ their own for the reason `level` has one (ADR-0011). */
1382
1428
  box?: BoxNumbers & Partial<BoxExtras> & {
1383
1429
  /** As the caller gave them; only where the series has `outliers`. */
1384
1430
  outliers?: readonly number[];
@@ -1430,6 +1476,26 @@ export declare function toWorkingTime(wallClock: number, input: CalendarInput):
1430
1476
  itself is carried as a gap and is never drawn and never hit. */
1431
1477
  export declare function toWorkingTimeClamped(wallClock: number, input: CalendarInput): number;
1432
1478
 
1479
+ /** A chart over your rows: the parts it returns are typed at your row, so
1480
+ that a field name in `value` is checked by the compiler.
1481
+ @param rows The rows every series reads that brings no `data` of its own.
1482
+ @param options The view to start from and the handler of its changes.
1483
+ @returns `Chart`, `XAxis`, `YAxis` and every series kind - each keeps its
1484
+ identity over the renders -, the `view`, its `domains` and `hidden`, and
1485
+ the setters that change them. */
1486
+ export declare function useChart<Z>(rows: readonly Z[], options?: ChartOptions): ChartParts<Z>;
1487
+
1488
+ /** A value read from the row (ADR-0048): the name of a number field, compared
1489
+ by its name, or a function, compared by its source text (`ValueFunction`). */
1490
+ export declare type Value<T> = NumberField<T> | ValueFunction<T>;
1491
+
1492
+ /** A **value** computed from the row - the function form of `Value`.
1493
+ Compared by its source text, not its identity - an inline function is new
1494
+ on every render. Known limit: one that reads a
1495
+ changed closure variable under the same text is not run again; pass a new
1496
+ data reference then. A native or bound function is compared by identity. */
1497
+ export declare type ValueFunction<T> = (d: T, index: number) => number | null | undefined;
1498
+
1433
1499
  /** What a value is. Four outcomes, not three.
1434
1500
 
1435
1501
  `unknown` is an outcome of its own and not a `null` return: a `null`
@@ -1522,17 +1588,19 @@ export declare interface WorkingTimeTick {
1522
1588
  place the tick, the wall clock time to label it. */
1523
1589
  export declare function workingTimeTicks(input: CalendarInput, from: number, to: number, step: number, offset?: number): WorkingTimeTick[];
1524
1590
 
1525
- /** A horizontal axis: where a datum lies along x, its ticks, title and grid.
1526
- A chart may have several; series bind to one by its `id`. With `time` or a
1527
- `calendar` it reads instants, with `onDomainChange` it zooms. */
1528
- export declare function XAxis<T>(props: XAxisProps<T>): null;
1529
-
1530
1591
  /** The props of `XAxis`. */
1531
- export declare interface XAxisProps<T> extends CommonProps<T> {
1592
+ export declare interface XAxisProps<T> extends CommonProps {
1593
+ /** Where a row lies on this axis: a number field of the row, compared by
1594
+ its name, or a function of it, compared by its source text as a series'
1595
+ is (`ValueFunction`) - with the same closure limit. The axis reads the
1596
+ rows of every series bound to it; where those bring their own `data`, name
1597
+ their row: `<XAxis<HourCount> value="hour" />`. */
1598
+ value: NumberField<T> | ((d: T, index: number) => number);
1532
1599
  /** `"nice"` widens the data's extent to ticks - to named `ticks` where
1533
1600
  there are any, on a time axis to whole units of a step of hours or
1534
- longer -, `"data"` keeps it, a pair is fixed - the one a zoom passes
1535
- back. */
1601
+ longer -, `"data"` keeps it, a pair is fixed. On a `zoomable` axis it is
1602
+ the start: what the axis shows while the chart's view names no span for
1603
+ it. */
1536
1604
  domain?: "nice" | "data" | readonly [number, number];
1537
1605
  /** Which edge the axis stands at. A second x axis on the opposite edge is how
1538
1606
  a series counts in a unit of its own. */
@@ -1550,21 +1618,24 @@ export declare interface XAxisProps<T> extends CommonProps<T> {
1550
1618
  removed span gets a break mark. The scale stays affine; the mapping happens
1551
1619
  in materialisation (ADR-0001). */
1552
1620
  calendar?: readonly WorkingInterval[];
1553
- /** Zoom and pan, controlled: Ctrl or ⌘ with the wheel - and a pinch - zoom
1554
- around the pointer, a drag, a horizontal wheel or Shift with the wheel pan,
1555
- a double click proposes the whole data range. Each proposes a domain in
1556
- the axis' units and changes nothing; the caller passes it back as
1557
- `domain`, clamped as it likes. Without a handler the axis does not zoom,
1558
- and the plain wheel always scrolls the page. */
1559
- onDomainChange?: (domain: [number, number]) => void;
1621
+ /** Zoom and pan: Ctrl or ⌘ with the wheel - and a pinch - zoom around the
1622
+ pointer, a drag, a horizontal wheel or Shift with the wheel pan, a double
1623
+ click goes back to `domain`; with the focus on the chart, + and − zoom,
1624
+ Shift with ← or → pans and 0 goes back. The span shown is part of the
1625
+ chart's view, by this axis' `id` (`useChart`'s `initialView`,
1626
+ `onViewChange`, `setDomain`). The plain wheel always scrolls the page.
1627
+ @default false */
1628
+ zoomable?: boolean;
1629
+ /** The narrowest and the widest span zoom may reach, in the axis' units -
1630
+ milliseconds on a time axis.
1631
+ @default at most the data's extent or this axis' own `domain`, whichever
1632
+ is wider, at least three data steps */
1633
+ zoomLimits?: ZoomLimits;
1560
1634
  }
1561
1635
 
1562
- /** A vertical axis: the scale series draw their values on, its ticks, title
1563
- and grid. A chart may have several; series bind to one by its `id`. */
1564
- export declare function YAxis<T>(props: YAxisProps<T>): null;
1565
-
1566
- /** The props of `YAxis`. */
1567
- export declare interface YAxisProps<T> extends CommonProps<T> {
1636
+ /** The props of `YAxis`. It reads no value of its own: where a row lies
1637
+ along y is its series' `value`. */
1638
+ export declare interface YAxisProps extends CommonProps {
1568
1639
  /** As on the x axis, and `"visible"`: what the series show inside their x
1569
1640
  axis' domain - a zoomed hour gets the hour's range, not the week's -,
1570
1641
  widened to ticks as `"nice"` is. Where the x domain is not fixed that is
@@ -1591,4 +1662,11 @@ export declare interface Zone {
1591
1662
  reader cannot check it against a chart that does not show it. */
1592
1663
  export declare function zones(limits: ControlLimits, multiples?: readonly number[]): Zone[];
1593
1664
 
1665
+ /** The narrowest and the widest span zoom may reach, in the axis' units - the
1666
+ schedule's shape. */
1667
+ export declare interface ZoomLimits {
1668
+ readonly min: number;
1669
+ readonly max: number;
1670
+ }
1671
+
1594
1672
  export { }