@umriss-ui/charts 0.13.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. */
@@ -548,10 +569,22 @@ declare interface CommonProps {
548
569
  @default only on the first axis of its orientation
549
570
  @remarks R-4.15 */
550
571
  grid?: boolean;
551
- /** Fixed tick values instead of the 1-2-5 algorithm. For axes whose values are
552
- places and not numbers: the lanes of a state stack, the categories of a
553
- 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. */
554
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;
555
588
  }
556
589
 
557
590
  /** A control chart inside a `Chart`: the values as a line, the control limits
@@ -753,11 +786,12 @@ export declare interface LimitBandConfig extends LimitBase {
753
786
  /** The props of `LimitBand`: a `LimitLine`'s, with a range in place of
754
787
  `value`. */
755
788
  export declare interface LimitBandProps extends LimitCommonProps {
756
- /** Lower edge of the band, in domain units of its axis. */
757
- 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;
758
792
  /** Upper edge, in domain units of its axis. A band drawn backwards (`from` above `to`) is drawn between
759
793
  the two all the same - the pair is a range, not a direction. */
760
- to: number;
794
+ to: number | Date;
761
795
  }
762
796
 
763
797
  declare interface LimitBase {
@@ -825,8 +859,9 @@ export declare interface LimitLineConfig extends LimitBase {
825
859
 
826
860
  /** The props of `LimitLine`. */
827
861
  export declare interface LimitLineProps extends LimitCommonProps {
828
- /** Where the line lies, in domain units of its axis. */
829
- 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;
830
865
  }
831
866
 
832
867
  /** What a limit stands for. The difference is not cosmetic: a specification
@@ -978,9 +1013,12 @@ export declare type MatrixColoring = {
978
1013
 
979
1014
  /** The props of `Matrix`. */
980
1015
  export declare interface MatrixProps<T> {
981
- /** Row position on the y axis - a number field of the row or a function
982
- of it, as every series' y position. */
983
- 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);
984
1022
  /** The level that decides the colour - a number field of the row or a
985
1023
  function of it. A missing level is a hole, not a zero. */
986
1024
  level: Value<T>;
@@ -1008,7 +1046,9 @@ export declare interface MatrixProps<T> {
1008
1046
  }
1009
1047
 
1010
1048
  /** A `Matrix` as the chart holds it once registered: its base accessor is the
1011
- 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. */
1012
1052
  export declare interface MatrixSeriesConfig<T = unknown> extends SeriesBase<T> {
1013
1053
  kind: "matrix";
1014
1054
  /** The level that decides the colour - the third channel (ADR-0011).
@@ -1025,6 +1065,17 @@ export declare type NumberField<T> = NoInfer<{
1025
1065
  [K in keyof T & string]-?: T[K] extends number | null | undefined ? K : never;
1026
1066
  }[keyof T & string]>;
1027
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
+
1028
1079
  /** Space in CSS pixels on each side of a rectangle. */
1029
1080
  export declare interface Padding {
1030
1081
  top: number;
@@ -1054,8 +1105,8 @@ export declare const paretoDefaults: Omit<ParetoOptions, "remainderName">;
1054
1105
  export declare interface ParetoEntry {
1055
1106
  readonly name: string;
1056
1107
  readonly value: number;
1057
- /** Category and at the same time x value: category n lies at x = n
1058
- (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. */
1059
1110
  readonly index: number;
1060
1111
  /** Share of the total, 0…1. */
1061
1112
  readonly share: number;
@@ -1318,7 +1369,8 @@ declare interface Stackable {
1318
1369
  normalize?: boolean;
1319
1370
  }
1320
1371
 
1321
- /** 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`). */
1322
1374
  export declare interface StateBandProps<T> {
1323
1375
  /** Index of the state in `states` - a number field of the row or a
1324
1376
  function of it; null/undefined/NaN/±Infinity is a gap -
@@ -1340,9 +1392,16 @@ export declare interface StateBandProps<T> {
1340
1392
  unnamed series is a colour nobody can look up.
1341
1393
  @default "Series n", after its place in the chart */
1342
1394
  name?: string;
1343
- /** 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 */
1344
1402
  laneFrom?: number;
1345
- /** 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 */
1346
1405
  laneTo?: number;
1347
1406
  }
1348
1407
 
@@ -1359,6 +1418,9 @@ export declare interface StateSeriesConfig<T = unknown> extends SeriesBase<T> {
1359
1418
  /** The closed set of states. The accessor yields the index into it - a number,
1360
1419
  not a key (ADR-0007). */
1361
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;
1362
1424
  /** Lower edge of the lane in domain units of the y axis; without a value the
1363
1425
  beginning of the axis domain. */
1364
1426
  laneFrom?: number;
@@ -1593,28 +1655,38 @@ export declare function workingTimeTicks(input: CalendarInput, from: number, to:
1593
1655
 
1594
1656
  /** The props of `XAxis`. */
1595
1657
  export declare interface XAxisProps<T> extends CommonProps {
1596
- /** Where a row lies on this axis: a number field of the row, compared by
1597
- its name, or a function of it, compared by its source text as a series'
1598
- is (`ValueFunction`) - with the same closure limit. The axis reads the
1599
- 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
1600
1667
  their row: `<XAxis<HourCount> value="hour" />`. */
1601
- value: NumberField<T> | ((d: T, index: number) => number);
1668
+ value: AxisField<T> | ((d: T, index: number) => AxisValue);
1602
1669
  /** `"nice"` widens the data's extent to ticks - to named `ticks` where
1603
1670
  there are any, on a time axis to whole units of a step of hours or
1604
- longer -, `"data"` keeps it, a pair is fixed. On a `zoomable` axis it is
1605
- the start: what the axis shows while the chart's view names no span for
1606
- it. */
1607
- 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];
1608
1676
  /** Which edge the axis stands at. A second x axis on the opposite edge is how
1609
1677
  a series counts in a unit of its own. */
1610
1678
  position?: "bottom" | "top";
1611
- /** The values are instants (milliseconds since the epoch): ticks on local
1612
- boundaries from the minute to the month, labels by level in en-GB with a
1613
- 24-hour clock - `15:00`, `17 Mar`, `Mar 2026` - and the date on the first
1614
- tick and on the first of a new day (`17 Mar 00:00`); a day tick there
1615
- carries the year. The tooltip's x value carries the seconds where the
1616
- readings lie less than a minute apart. Another language is a `tickFormat`,
1617
- 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. */
1618
1690
  time?: boolean;
1619
1691
  /** Working calendar: the intervals in which time counts. With it the axis
1620
1692
  stands in working time - nights and weekends are out, and every
@@ -1637,7 +1709,9 @@ export declare interface XAxisProps<T> extends CommonProps {
1637
1709
  }
1638
1710
 
1639
1711
  /** The props of `YAxis`. It reads no value of its own: where a row lies
1640
- 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). */
1641
1715
  export declare interface YAxisProps extends CommonProps {
1642
1716
  /** As on the x axis, and `"visible"`: what the series show inside their x
1643
1717
  axis' domain - a zoomed hour gets the hour's range, not the week's -,