@umriss-ui/charts 0.14.0 → 0.16.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/de.d.ts CHANGED
@@ -11,6 +11,12 @@ declare interface ChartsWording {
11
11
  visibleRange: (from: string, to: string) => string;
12
12
  /** The summary's lowest and highest value of one series in that stretch. */
13
13
  seriesExtent: (name: string, min: string, max: string) => string;
14
+ /** The summary's labelled limits, each with its value in its axis' format
15
+ (a band's two edges as one value). */
16
+ limitList: (limits: readonly {
17
+ name: string;
18
+ value: string;
19
+ }[]) => string;
14
20
  /** What is read after a key: the position, then each series with its value
15
21
  (and its own x where it stands on another x axis), the emphasised one
16
22
  first. */
@@ -26,6 +32,8 @@ declare interface ChartsWording {
26
32
  percent: (value: string) => string;
27
33
  /** The keys that walk the chart. */
28
34
  walkHelp: string;
35
+ /** The key that reports the Active point - only where `onSelect` is given. */
36
+ selectHelp: string;
29
37
  /** The keys that zoom and pan it - only where the chart can be zoomed. */
30
38
  zoomHelp: string;
31
39
  /** The keys of the legend's entries - only where it has one to press. */
package/dist/index.d.ts CHANGED
@@ -224,6 +224,43 @@ export declare interface BarSeriesConfig<T = unknown> extends SeriesBase<T>, Sta
224
224
  barWidth: number;
225
225
  }
226
226
 
227
+ /** A bin, the way it is drawn. */
228
+ export declare interface Bin {
229
+ /** Lower edge; the bin holds it. */
230
+ readonly from: number;
231
+ /** Upper edge; the bin holds it only if it is the last one. */
232
+ readonly to: number;
233
+ /** The middle, `(from + to) / 2` - the bar's x. */
234
+ readonly x: number;
235
+ /** How many values fall in it. */
236
+ readonly count: number;
237
+ }
238
+
239
+ /** Counts values into bins of equal width.
240
+
241
+ A value on an edge belongs to the bin that edge starts - `[from, to)` - but
242
+ the last bin is closed, so the greatest value of a domain is counted and not
243
+ lost. Values that are not finite (`NaN`, ±Infinity, `null`, `undefined`)
244
+ are skipped, as a gap is on a chart. Without values there are no bins; with
245
+ values there is at least one, even when they are all equal. */
246
+ export declare function bin(values: readonly (number | null | undefined)[], options?: BinOptions): Bin[];
247
+
248
+ export declare function bin<T>(rows: readonly T[], value: (row: T) => number | null | undefined, options?: BinOptions): Bin[];
249
+
250
+ /** The settings of `bin`. */
251
+ export declare interface BinOptions {
252
+ /** The width of a bin. Wins over `count`. Without a `domain` the edges are
253
+ multiples of it. */
254
+ readonly width?: number;
255
+ /** About how many bins: the width becomes the next 1-2-5 step, so the number
256
+ comes out near it and not exactly - with a `domain`, exactly.
257
+ @default 10 */
258
+ readonly count?: number;
259
+ /** The span the bins cover, the first edge on its start and the last on its
260
+ end. Values outside it are left out, not clamped into the end bins. */
261
+ readonly domain?: readonly [number, number];
262
+ }
263
+
227
264
  /** The named channels of a box: one number per point, NaN where the median
228
265
  is a gap; and its outliers (ADR-0040). */
229
266
  export declare interface BoxChannels extends BoxNumbers<Float64Array> {
@@ -349,7 +386,7 @@ export declare type CalendarInput = WorkingCalendar | readonly WorkingInterval[]
349
386
 
350
387
  /** What `useChart` takes besides the rows: the view to start from and the
351
388
  handler that hears every change of it. */
352
- export declare interface ChartOptions {
389
+ export declare interface ChartOptions<Z = unknown> {
353
390
  /** The view to start from, and to go to whenever one differing in content
354
391
  from the last is handed in - the same view again changes nothing, and
355
392
  what it leaves out is reset; one the chart reported itself, handed back
@@ -361,6 +398,13 @@ export declare interface ChartOptions {
361
398
  or to hand another chart as its `initialView`. A pan or zoom is reported
362
399
  at most once per frame. Not called for the view the chart starts with. */
363
400
  onViewChange?: (view: ChartView) => void;
401
+ /** The reader chose a point: a click on a hit (a tap too), or Enter on the
402
+ Active point - the same hit the tooltip's `render` receives. Once per
403
+ click; the end of a drag does not report, and the second click of a
404
+ double click does not either. The chart holds no selection and draws
405
+ none: what is chosen is the application's state. Needs a `<Tooltip>`,
406
+ which makes the hits; the hit does not travel over `syncId`. */
407
+ onSelect?: (hit: TooltipHit<Z>) => void;
364
408
  }
365
409
 
366
410
  /** What `useChart` hands back: the chart and its parts, typed at the row `Z`,
@@ -485,6 +529,12 @@ export declare interface ChartsWording {
485
529
  visibleRange: (from: string, to: string) => string;
486
530
  /** The summary's lowest and highest value of one series in that stretch. */
487
531
  seriesExtent: (name: string, min: string, max: string) => string;
532
+ /** The summary's labelled limits, each with its value in its axis' format
533
+ (a band's two edges as one value). */
534
+ limitList: (limits: readonly {
535
+ name: string;
536
+ value: string;
537
+ }[]) => string;
488
538
  /** What is read after a key: the position, then each series with its value
489
539
  (and its own x where it stands on another x axis), the emphasised one
490
540
  first. */
@@ -500,6 +550,8 @@ export declare interface ChartsWording {
500
550
  percent: (value: string) => string;
501
551
  /** The keys that walk the chart. */
502
552
  walkHelp: string;
553
+ /** The key that reports the Active point - only where `onSelect` is given. */
554
+ selectHelp: string;
503
555
  /** The keys that zoom and pan it - only where the chart can be zoomed. */
504
556
  zoomHelp: string;
505
557
  /** The keys of the legend's entries - only where it has one to press. */
@@ -1447,6 +1499,7 @@ export declare function Tooltip<T>(props: TooltipProps<T>): null;
1447
1499
  /** A `Tooltip` as the chart holds it once registered. */
1448
1500
  export declare interface TooltipConfig<T = unknown> {
1449
1501
  mode: "x" | "nearest";
1502
+ limits?: boolean;
1450
1503
  render?: (hit: TooltipHit<T>) => ReactNode;
1451
1504
  }
1452
1505
 
@@ -1500,6 +1553,12 @@ export declare interface TooltipPoint<T = unknown> {
1500
1553
  export declare interface TooltipProps<T> {
1501
1554
  /** "x": every series at the x position; "nearest": only the nearest point. */
1502
1555
  mode?: "x" | "nearest";
1556
+ /** Adds a row for every labelled `LimitLine` and `LimitBand` on the hit's y
1557
+ axis - its label and value in that axis' format - to the built-in
1558
+ tooltip, and the same to what a key reads out. Limits are not series and
1559
+ stay out of the tooltip unless asked for.
1560
+ @default false */
1561
+ limits?: boolean;
1503
1562
  /** Render prop for content of one's own. Compared by its source text, like
1504
1563
  `tickFormat` - with the same closure limit.
1505
1564
  @default the built-in tooltip */
@@ -1548,7 +1607,7 @@ export declare function toWorkingTimeClamped(wallClock: number, input: CalendarI
1548
1607
  @returns `Chart`, `XAxis`, `YAxis` and every series kind - each keeps its
1549
1608
  identity over the renders -, the `view`, its `domains` and `hidden`, and
1550
1609
  the setters that change them. */
1551
- export declare function useChart<Z>(rows: readonly Z[], options?: ChartOptions): ChartParts<Z>;
1610
+ export declare function useChart<Z>(rows: readonly Z[], options?: ChartOptions<Z>): ChartParts<Z>;
1552
1611
 
1553
1612
  /** A value read from the row (ADR-0048): the name of a number field, compared
1554
1613
  by its name, or a function, compared by its source text (`ValueFunction`). */
@@ -1,13 +1,16 @@
1
- const r = {
1
+ "use client";
2
+ const i = {
2
3
  roleDescription: "Diagramm",
3
4
  empty: "Keine Daten",
4
5
  seriesList: (e) => `${e.length === 1 ? "1 Serie" : `${e.length} Serien`}: ${e.join(", ")}.`,
5
6
  visibleRange: (e, n) => `Von ${e} bis ${n}.`,
6
7
  seriesExtent: (e, n, t) => `${e} von ${n} bis ${t}.`,
8
+ limitList: (e) => `Grenzen: ${e.map((n) => `${n.name} ${n.value}`).join(", ")}.`,
7
9
  readout: (e, n) => [`${e}.`, ...n.map((t) => `${t.name} ${t.value}${t.x === "" ? "" : ` bei ${t.x}`}.`)].join(" "),
8
10
  stackTotal: "Summe",
9
11
  percent: (e) => `${e} %`,
10
12
  walkHelp: "Pfeil links und rechts gehen durch die Werte, Pfeil hoch und runter wechseln die Serie, Pos1 und Ende springen zum ersten und letzten Wert, Escape hebt die Markierung auf.",
13
+ selectHelp: "Enter wählt den Punkt.",
11
14
  zoomHelp: "Plus und Minus zoomen, Umschalt mit Pfeil links oder rechts verschiebt, 0 kehrt zum eigenen Bereich der Achse zurück.",
12
15
  legendHelp: "In der Legende blendet Enter eine Serie aus oder ein, Umschalt+Enter zeigt nur sie.",
13
16
  allShown: "Sonst wäre nichts mehr zu sehen, darum werden alle Serien gezeigt.",
@@ -31,5 +34,5 @@ const r = {
31
34
  downsampled: (e) => `Ausgedünnt aus ${e.toLocaleString("de-DE")} Messwerten: erster, kleinster, größter und letzter Wert je Abschnitt.`
32
35
  };
33
36
  export {
34
- r as GERMAN_CHARTS_WORDING
37
+ i as GERMAN_CHARTS_WORDING
35
38
  };