@umriss-ui/charts 0.12.0 → 0.14.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
@@ -110,8 +110,9 @@ export declare interface AxisConfig<T = unknown> {
110
110
  orientation: AxisOrientation;
111
111
  position: AxisPosition;
112
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;
113
+ place their rows. A number is a position or an instant, a string a
114
+ category, a `Date` an instant (ADR-0052). */
115
+ accessor?: (d: T, index: number) => AxisValue;
115
116
  label?: string;
116
117
  tickCount?: number;
117
118
  tickFormat?: (v: number) => string;
@@ -122,12 +123,17 @@ export declare interface AxisConfig<T = unknown> {
122
123
  @default only the first registered axis per orientation
123
124
  @remarks R-4.15 */
124
125
  grid?: boolean;
125
- /** Fixed tick values instead of the 1-2-5 algorithm. For axes whose values are
126
- not numbers but places: the lanes of a state stack, the categories of a
127
- Pareto. */
126
+ /** Fixed tick values instead of the 1-2-5 algorithm, on a numeric axis: an
127
+ hour axis' named hours, a lane grid. */
128
128
  ticks?: readonly number[];
129
- /** The values are instants in milliseconds: ticks on local boundaries,
130
- labels by level. A calendar implies it. */
129
+ /** The categories of the axis, in their order: the list is the order and
130
+ the extent, and makes the axis a category axis (ADR-0052). */
131
+ categories?: readonly string[];
132
+ /** What is written for a category, wherever it is written. */
133
+ categoryLabel?: (category: string) => string;
134
+ /** The values are instants - milliseconds, and where this is said ISO 8601
135
+ strings as well: ticks on local boundaries, labels by level. A calendar
136
+ implies it, and so do rows that bring a `Date` (ADR-0052). */
131
137
  time?: boolean;
132
138
  /** Working calendar: the intervals in which time counts. With it,
133
139
  materialisation maps wall clock time onto working time before the scale
@@ -143,6 +149,13 @@ export declare interface AxisConfig<T = unknown> {
143
149
  zoomLimits?: ZoomLimits;
144
150
  }
145
151
 
152
+ /** The fields of a row an axis can read - or, with `V`, those that hold only
153
+ some of what an axis reads: a matrix' row is a position or a category,
154
+ never an instant. */
155
+ export declare type AxisField<T, V = AxisValue> = NoInfer<{
156
+ [K in keyof T & string]-?: T[K] extends V ? K : never;
157
+ }[keyof T & string]>;
158
+
146
159
  /** Whether an axis or a limit runs along x or along y. */
147
160
  export declare type AxisOrientation = "x" | "y";
148
161
 
@@ -153,6 +166,14 @@ export declare type AxisPosition = "bottom" | "top" | "left" | "right";
153
166
  /** The span each zoomable x axis shows, by axis `id`, in the axis' units. */
154
167
  export declare type AxisSpans = Readonly<Record<string, readonly [number, number]>>;
155
168
 
169
+ /** What an axis reads from a row (ADR-0052): a number - a position, or an
170
+ instant on a time axis -, a string, which is a category, or a `Date`,
171
+ which is an instant. The type of the value decides what kind the axis is,
172
+ never its content: `"2024"` is a category, `2024` a number. On an axis
173
+ that says `time` a string is an ISO 8601 instant. null/undefined is no
174
+ place. */
175
+ export declare type AxisValue = number | string | Date | null | undefined;
176
+
156
177
  /** The props of `Bar`. */
157
178
  export declare interface BarProps<T> {
158
179
  /** Height - a number field of the row or a function of it;
@@ -357,7 +378,7 @@ export declare interface ChartParts<Z> {
357
378
  Area: <T = Z>(props: AreaProps<T>) => null;
358
379
  Bar: <T = Z>(props: BarProps<T>) => null;
359
380
  Scatter: <T = Z>(props: ScatterProps<T>) => null;
360
- StateBand: <T = Z>(props: StateBandProps<T>) => null;
381
+ StateBand: <T = Z>(props: StateBandProps<T> & OneLane) => null;
361
382
  Matrix: <T = Z>(props: MatrixProps<T>) => null;
362
383
  BoxPlot: <T = Z>(props: BoxPlotProps<T>) => null;
363
384
  /** How the reader is looking at the chart. */
@@ -394,9 +415,12 @@ export declare interface ChartProps {
394
415
  host and follows it through a ResizeObserver.
395
416
  @default "100%" */
396
417
  width?: number | "100%";
397
- /** Height in CSS pixels. Unlike the width, the chart does not take its
398
- host's.
399
- @default 300 */
418
+ /** Height in CSS pixels, fixed. Left out, the chart fills its frame - a
419
+ stretched grid cell, a card the grid stretches, a container of definite
420
+ height - and never goes below 300 px, which is also its height in a
421
+ frame without one. A different floor goes through `style`'s `minHeight`
422
+ (ADR-0050).
423
+ @default fills the frame, at least 300 px */
400
424
  height?: number;
401
425
  /** Outer spacing of the plot area in CSS pixels. */
402
426
  padding?: number | Partial<Padding>;
@@ -405,9 +429,9 @@ export declare interface ChartProps {
405
429
  ariaLabel?: string;
406
430
  /** Goes to the root element, as it does everywhere in this workspace. */
407
431
  className?: string;
408
- /** Goes to the root element. The plot area is measured, never styled from
409
- here: a height set past the component is a height the scene does not know
410
- about. */
432
+ /** Goes to the root element, after the chart's own styles: a `height` or
433
+ `minHeight` set here wins. The plot area is observed in both directions
434
+ and the scene follows it. */
411
435
  style?: CSSProperties;
412
436
  /** Shown in the middle of the plot area when no visible series has a point
413
437
  to show - no data, only gaps, or every series hidden. Axes and frame
@@ -545,10 +569,22 @@ declare interface CommonProps {
545
569
  @default only on the first axis of its orientation
546
570
  @remarks R-4.15 */
547
571
  grid?: boolean;
548
- /** Fixed tick values instead of the 1-2-5 algorithm. For axes whose values are
549
- places and not numbers: the lanes of a state stack, the categories of a
550
- Pareto. */
572
+ /** Fixed tick values instead of the 1-2-5 algorithm, on a numeric axis: an
573
+ hour axis' named hours, a lane grid. An axis that reads categories needs
574
+ none - every category has its tick. */
551
575
  ticks?: readonly number[];
576
+ /** The categories of the axis, in their order. Without it they stand in
577
+ the order the rows first bring them. With it the list is the order and
578
+ the extent: a category no row carries keeps its empty place, and a row
579
+ whose category is not listed is not drawn - DEV names it. It makes the
580
+ axis a category axis whatever the rows hold (ADR-0052). */
581
+ categories?: readonly string[];
582
+ /** What is written for a category - under its tick, in the tooltip, the
583
+ readout and the data table - where the rows hold a key and not a name.
584
+ Two categories may share a label and keep two places. Compared by its
585
+ source text, as `tickFormat` is.
586
+ @default the category itself */
587
+ categoryLabel?: (category: string) => string;
552
588
  }
553
589
 
554
590
  /** A control chart inside a `Chart`: the values as a line, the control limits
@@ -750,11 +786,12 @@ export declare interface LimitBandConfig extends LimitBase {
750
786
  /** The props of `LimitBand`: a `LimitLine`'s, with a range in place of
751
787
  `value`. */
752
788
  export declare interface LimitBandProps extends LimitCommonProps {
753
- /** Lower edge of the band, in domain units of its axis. */
754
- from: number;
789
+ /** Lower edge of the band, in domain units of its axis; along a time axis
790
+ an instant, in milliseconds or as a `Date`. */
791
+ from: number | Date;
755
792
  /** Upper edge, in domain units of its axis. A band drawn backwards (`from` above `to`) is drawn between
756
793
  the two all the same - the pair is a range, not a direction. */
757
- to: number;
794
+ to: number | Date;
758
795
  }
759
796
 
760
797
  declare interface LimitBase {
@@ -822,8 +859,9 @@ export declare interface LimitLineConfig extends LimitBase {
822
859
 
823
860
  /** The props of `LimitLine`. */
824
861
  export declare interface LimitLineProps extends LimitCommonProps {
825
- /** Where the line lies, in domain units of its axis. */
826
- value: number;
862
+ /** Where the line lies, in domain units of its axis; along a time axis
863
+ an instant, in milliseconds or as a `Date`. */
864
+ value: number | Date;
827
865
  }
828
866
 
829
867
  /** What a limit stands for. The difference is not cosmetic: a specification
@@ -975,9 +1013,12 @@ export declare type MatrixColoring = {
975
1013
 
976
1014
  /** The props of `Matrix`. */
977
1015
  export declare interface MatrixProps<T> {
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>;
1016
+ /** The row on the y axis - a field of the data's row or a function of it.
1017
+ A number is a position, as every series' y is; a string is a category:
1018
+ the y axis then has a named row per distinct one, the first at the top,
1019
+ in the order the data bring them or the y axis' `categories`
1020
+ (ADR-0052). Never an instant: a `Date` is refused. */
1021
+ value: AxisField<T, number | string | null | undefined> | ((d: T, index: number) => number | string | null | undefined);
981
1022
  /** The level that decides the colour - a number field of the row or a
982
1023
  function of it. A missing level is a hole, not a zero. */
983
1024
  level: Value<T>;
@@ -1005,7 +1046,9 @@ export declare interface MatrixProps<T> {
1005
1046
  }
1006
1047
 
1007
1048
  /** A `Matrix` as the chart holds it once registered: its base accessor is the
1008
- row, `level` the colour. */
1049
+ row, `level` the colour. The row may be named: where the accessor yields a
1050
+ string, materialisation gives it its category's place (ADR-0052) - the one
1051
+ series kind whose base accessor reads more than a number. */
1009
1052
  export declare interface MatrixSeriesConfig<T = unknown> extends SeriesBase<T> {
1010
1053
  kind: "matrix";
1011
1054
  /** The level that decides the colour - the third channel (ADR-0011).
@@ -1022,6 +1065,17 @@ export declare type NumberField<T> = NoInfer<{
1022
1065
  [K in keyof T & string]-?: T[K] extends number | null | undefined ? K : never;
1023
1066
  }[keyof T & string]>;
1024
1067
 
1068
+ /** A lane is named or given by its edges: the compiler refuses both at once.
1069
+ Beside the props and not in them, so that `StateBandProps` stays an
1070
+ interface another can extend. */
1071
+ export declare type OneLane = {
1072
+ lane: string;
1073
+ laneFrom?: undefined;
1074
+ laneTo?: undefined;
1075
+ } | {
1076
+ lane?: undefined;
1077
+ };
1078
+
1025
1079
  /** Space in CSS pixels on each side of a rectangle. */
1026
1080
  export declare interface Padding {
1027
1081
  top: number;
@@ -1051,8 +1105,8 @@ export declare const paretoDefaults: Omit<ParetoOptions, "remainderName">;
1051
1105
  export declare interface ParetoEntry {
1052
1106
  readonly name: string;
1053
1107
  readonly value: number;
1054
- /** Category and at the same time x value: category n lies at x = n
1055
- (ADR-0002). */
1108
+ /** The entry's rank from 0, in the order drawn - its place on an x axis
1109
+ that reads `name`, and an x value for one that reads numbers. */
1056
1110
  readonly index: number;
1057
1111
  /** Share of the total, 0…1. */
1058
1112
  readonly share: number;
@@ -1315,7 +1369,8 @@ declare interface Stackable {
1315
1369
  normalize?: boolean;
1316
1370
  }
1317
1371
 
1318
- /** The props of `StateBand`. */
1372
+ /** The props of `StateBand`. Its lane is named, or given by its two edges -
1373
+ one way or the other (`OneLane`). */
1319
1374
  export declare interface StateBandProps<T> {
1320
1375
  /** Index of the state in `states` - a number field of the row or a
1321
1376
  function of it; null/undefined/NaN/±Infinity is a gap -
@@ -1337,9 +1392,16 @@ export declare interface StateBandProps<T> {
1337
1392
  unnamed series is a colour nobody can look up.
1338
1393
  @default "Series n", after its place in the chart */
1339
1394
  name?: string;
1340
- /** Lower edge of the lane in domain units of the y axis. */
1395
+ /** The lane by its name: a category of the y axis, whose place the band
1396
+ takes, as wide as a bar is. The y axis then lists a lane per name, the
1397
+ first at the top, in the bands' order or its own `categories`
1398
+ (ADR-0052). Not together with `laneFrom` or `laneTo`. */
1399
+ lane?: string;
1400
+ /** Lower edge of the lane in domain units of a numeric y axis.
1401
+ @default the beginning of the axis' domain */
1341
1402
  laneFrom?: number;
1342
- /** Upper edge of the lane in domain units of the y axis. */
1403
+ /** Upper edge of the lane in domain units of a numeric y axis.
1404
+ @default the end of the axis' domain */
1343
1405
  laneTo?: number;
1344
1406
  }
1345
1407
 
@@ -1356,6 +1418,9 @@ export declare interface StateSeriesConfig<T = unknown> extends SeriesBase<T> {
1356
1418
  /** The closed set of states. The accessor yields the index into it - a number,
1357
1419
  not a key (ADR-0007). */
1358
1420
  states: readonly StateEntry[];
1421
+ /** The lane by its name: a category of the y axis, whose place the band
1422
+ takes (ADR-0052). */
1423
+ lane?: string;
1359
1424
  /** Lower edge of the lane in domain units of the y axis; without a value the
1360
1425
  beginning of the axis domain. */
1361
1426
  laneFrom?: number;
@@ -1590,28 +1655,38 @@ export declare function workingTimeTicks(input: CalendarInput, from: number, to:
1590
1655
 
1591
1656
  /** The props of `XAxis`. */
1592
1657
  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
1658
+ /** Where a row lies on this axis: a field of the row, compared by its
1659
+ name, or a function of it, compared by its source text as a series' is
1660
+ (`ValueFunction`) - with the same closure limit. A number is a position,
1661
+ a `Date` an instant, a string a category: every distinct one gets a
1662
+ place of its own, in the order the rows bring them, a tick and its name
1663
+ as the label (ADR-0052). The type decides, never the content - `"2024"`
1664
+ is a category, `2024` a number - and a row without a value has no
1665
+ place. The axis reads the rows
1666
+ of every series bound to it; where those bring their own `data`, name
1597
1667
  their row: `<XAxis<HourCount> value="hour" />`. */
1598
- value: NumberField<T> | ((d: T, index: number) => number);
1668
+ value: AxisField<T> | ((d: T, index: number) => AxisValue);
1599
1669
  /** `"nice"` widens the data's extent to ticks - to named `ticks` where
1600
1670
  there are any, on a time axis to whole units of a step of hours or
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. */
1604
- domain?: "nice" | "data" | readonly [number, number];
1671
+ longer -, `"data"` keeps it, a pair is fixed: numbers, on a time axis
1672
+ milliseconds or two `Date`s, on a category axis places. On a `zoomable`
1673
+ axis it is the start: what the axis shows while the chart's view names
1674
+ no span for it. */
1675
+ domain?: "nice" | "data" | readonly [number, number] | readonly [Date, Date];
1605
1676
  /** Which edge the axis stands at. A second x axis on the opposite edge is how
1606
1677
  a series counts in a unit of its own. */
1607
1678
  position?: "bottom" | "top";
1608
- /** The values are instants (milliseconds since the epoch): ticks on local
1609
- boundaries from the minute to the month, labels by level in en-GB with a
1610
- 24-hour clock - `15:00`, `17 Mar`, `Mar 2026` - and the date on the first
1611
- tick and on the first of a new day (`17 Mar 00:00`); a day tick there
1612
- carries the year. The tooltip's x value carries the seconds where the
1613
- readings lie less than a minute apart. Another language is a `tickFormat`,
1614
- which is handed the instant. `calendar` implies it. */
1679
+ /** The values are instants: milliseconds since the epoch, or with `time`
1680
+ said ISO 8601 strings as an API sends them, read by the platform's rule -
1681
+ a date with a time and no offset is local time, a date alone is UTC; a
1682
+ string that is none is not drawn. Rows that hold a `Date` put the axis
1683
+ in time without `time`. Ticks on local boundaries from the minute to the
1684
+ month, labels by level in en-GB with a 24-hour clock - `15:00`, `17 Mar`,
1685
+ `Mar 2026` - and the date on the first tick and on the first of a new
1686
+ day (`17 Mar 00:00`); a day tick there carries the year. The tooltip's x
1687
+ value carries the seconds where the readings lie less than a minute
1688
+ apart. Another language is a `tickFormat`, which is handed the instant
1689
+ in milliseconds. `calendar` implies it. */
1615
1690
  time?: boolean;
1616
1691
  /** Working calendar: the intervals in which time counts. With it the axis
1617
1692
  stands in working time - nights and weekends are out, and every
@@ -1634,7 +1709,9 @@ export declare interface XAxisProps<T> extends CommonProps {
1634
1709
  }
1635
1710
 
1636
1711
  /** The props of `YAxis`. It reads no value of its own: where a row lies
1637
- along y is its series' `value`. */
1712
+ along y is its series' `value`. It has categories where a `Matrix` reads
1713
+ its rows from a string or a `StateBand` names its `lane`; the first stands
1714
+ at the top (ADR-0052). */
1638
1715
  export declare interface YAxisProps extends CommonProps {
1639
1716
  /** As on the x axis, and `"visible"`: what the series show inside their x
1640
1717
  axis' domain - a zoomed hour gets the hour's range, not the week's -,