@umriss-ui/charts 0.43.0 → 0.45.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
@@ -38,6 +38,12 @@ declare interface ChartsWording {
38
38
  walkHelp: string;
39
39
  /** The key that reports the Active point - only where `onSelect` is given. */
40
40
  selectHelp: string;
41
+ /** Said when the keyboard sets the start of a range; the x value is written in the axis' format. */
42
+ rangeStarted: (from: string) => string;
43
+ /** Said when the keyboard sets the end of a range. */
44
+ rangeMade: (from: string, to: string) => string;
45
+ /** The key that marks a range - only where `onRange` is given and a tooltip stands. */
46
+ rangeHelp: string;
41
47
  /** The keys that zoom and pan it - only where the chart can be zoomed. */
42
48
  zoomHelp: string;
43
49
  /** The keys of the legend's entries - only where it has one to press. */
package/dist/index.d.ts CHANGED
@@ -375,7 +375,7 @@ export declare type CalendarInput = WorkingCalendar | readonly WorkingInterval[]
375
375
 
376
376
  /** What `useChart` takes besides the rows: the view to start from and the
377
377
  handler that hears every change of it. */
378
- export declare interface ChartOptions<Z = unknown> {
378
+ export declare interface ChartOptions<Z = unknown, V extends number | string = number> {
379
379
  /** The view to start from, read once when the hook first runs; a different
380
380
  value on a later render is ignored, as React ignores a changed
381
381
  `defaultValue`. To go to a view later, call `setView`. The chart
@@ -393,6 +393,14 @@ export declare interface ChartOptions<Z = unknown> {
393
393
  none: what is chosen is the application's state. Needs a `<Tooltip>`,
394
394
  which makes the hits; the hit does not travel over `syncId`. */
395
395
  onSelect?: (hit: TooltipHit<Z>) => void;
396
+ /** The reader marked a stretch of an x axis: Alt with a drag where the chart
397
+ zooms, a plain drag where it does not. Called once, on release - once per
398
+ x axis -, with `from` not after `to`, in the axis' own values: numbers, milliseconds on a time axis, wall-clock instants on a calendar axis, and on a category axis the first and last category covered, as strings - say so in the handler's parameter, `ChartRange<string>`. A band
399
+ covers the stretch while the pointer is down; the chart keeps no range and
400
+ draws none afterwards, and it does not travel over `syncId`. A press that
401
+ travels 4 px or less is a click and reaches `onSelect`; Escape and a
402
+ cancelled pointer report nothing. */
403
+ onRange?: (range: ChartRange<V>) => void;
396
404
  }
397
405
 
398
406
  /** What `useChart` hands back: the chart and its parts, typed at the row `Z`,
@@ -435,6 +443,15 @@ export declare interface ChartParts<Z> {
435
443
  showOnly: (name: string) => void;
436
444
  /** Shows every series again. */
437
445
  showAllSeries: () => void;
446
+ /** A PNG of the chart as it stands: the plot with its grid, series and
447
+ limits, the axes with ticks, labels and titles, and the legend, on the
448
+ chart's own ground in the colour scheme in use, at the chart's size on
449
+ screen and at least twice its CSS pixels. Not in it: the tooltip, the
450
+ crosshair and hover marks, the "Show all" button, the data key and
451
+ its table, the screen-reader texts, and any title. Where the picture goes
452
+ - a download, the clipboard, an upload - is the application's. Rejects
453
+ with an `Error` when the chart is not on screen or has no size. */
454
+ toPng: () => Promise<Blob>;
438
455
  }
439
456
 
440
457
  /** Measurements of the instrumentation for the benchmark page. */
@@ -463,10 +480,6 @@ export declare interface ChartProps extends Omit<HTMLAttributes<HTMLDivElement>,
463
480
  height?: number;
464
481
  /** Outer spacing of the plot area in CSS pixels. */
465
482
  padding?: number | Partial<Padding>;
466
- /** Accessible name of the plot. Without a name, `aria-label` or
467
- `aria-labelledby`, the chart warns in development.
468
- @deprecated since 0.43 - use `aria-label`. */
469
- ariaLabel?: string;
470
483
  /** Goes to the root element, as it does everywhere in this workspace. */
471
484
  className?: string;
472
485
  /** Goes to the root element, after the chart's own styles: a `height` or
@@ -491,6 +504,16 @@ export declare interface ChartProps extends Omit<HTMLAttributes<HTMLDivElement>,
491
504
  axis or series. German: `GERMAN_CHARTS_WORDING` from `@umriss-ui/charts/wording/de`.
492
505
  @default DEFAULT_CHARTS_WORDING */
493
506
  wording?: Partial<ChartsWording>;
507
+ /** An IANA time zone (`"Europe/Berlin"`) for every time axis of the chart, a
508
+ calendar axis included: ticks stand on its hours and midnights, and the
509
+ labels, tooltip, readout, data table and summary write its time, in the
510
+ wording's `locale`. Where the reader's zone is another, the axis title
511
+ ends in the zone's name (after mount). An hour a clock change doubles is
512
+ ticked twice and its labels carry the offset; the hour it removes has
513
+ no tick. A name Intl does not know throws its `RangeError`. An
514
+ application on `@umriss-ui/core` passes `useFormats().timeZone`.
515
+ @default the reader's zone */
516
+ timeZone?: string;
494
517
  /** How series are told apart. `"color"`: by their colour.
495
518
  `"marks"`: by a dash and a marker shape as well - a line, an area and a
496
519
  scatter -, and by a hatch - a bar, a state, a matrix cell, a limit band -,
@@ -513,6 +536,16 @@ export declare interface ChartProps extends Omit<HTMLAttributes<HTMLDivElement>,
513
536
  children?: ReactNode;
514
537
  }
515
538
 
539
+ /** A stretch of an x axis the reader marked (`onRange`): `from` is not after
540
+ `to`, both in the axis' own values - numbers on a numeric or time axis
541
+ (milliseconds). A caller that reads numbers takes the default and needs no
542
+ cast; `V` is what a category axis widens it to. */
543
+ export declare interface ChartRange<V extends number | string = number> {
544
+ axisId: string;
545
+ from: V;
546
+ to: V;
547
+ }
548
+
516
549
  /** Everything the charts put out as text. */
517
550
  export declare interface ChartsWording {
518
551
  /** The BCP 47 tag every number and every date or time label of the chart is
@@ -553,6 +586,12 @@ export declare interface ChartsWording {
553
586
  walkHelp: string;
554
587
  /** The key that reports the Active point - only where `onSelect` is given. */
555
588
  selectHelp: string;
589
+ /** Said when the keyboard sets the start of a range; the x value is written in the axis' format. */
590
+ rangeStarted: (from: string) => string;
591
+ /** Said when the keyboard sets the end of a range. */
592
+ rangeMade: (from: string, to: string) => string;
593
+ /** The key that marks a range - only where `onRange` is given and a tooltip stands. */
594
+ rangeHelp: string;
556
595
  /** The keys that zoom and pan it - only where the chart can be zoomed. */
557
596
  zoomHelp: string;
558
597
  /** The keys of the legend's entries - only where it has one to press. */
@@ -760,6 +799,9 @@ export declare const DEFAULT_GRADIENT: readonly string[];
760
799
  /** One hour in milliseconds. */
761
800
  export declare const HOUR: number;
762
801
 
802
+ /** Does the clock show this instant's time twice? */
803
+ export declare function inDoubledHour(t: number, zone?: string): boolean;
804
+
763
805
  /** Explicit invalidation: devalue the cache, every living chart reads anew and
764
806
  redraws. */
765
807
  export declare function invalidateTheme(): void;
@@ -984,8 +1026,9 @@ export declare type ListValue<T> = ListField<T> | ListFunction<T>;
984
1026
 
985
1027
  /** The local offset at an instant, as the shift of a grid that is to lie on
986
1028
  local time: `wallClock = offset + k · step`. Taken at one instant, it holds
987
- for a grid up to the next clock change. */
988
- export declare function localOffset(instant: number): number;
1029
+ for a grid up to the next clock change. With a `timeZone` (an IANA name)
1030
+ the zone's offset, else the reader's. */
1031
+ export declare function localOffset(instant: number, timeZone?: string): number;
989
1032
 
990
1033
  /** Materialised series: the draw loop works only on this.
991
1034
  Gaps (null/undefined/NaN/±Infinity out of the accessor) are encoded as NaN. */
@@ -1516,7 +1559,7 @@ export declare function toWorkingTimeClamped(wallClock: number, input: CalendarI
1516
1559
  @returns `Chart`, `XAxis`, `YAxis` and every series kind - each keeps its
1517
1560
  identity over the renders -, the `view`, its `domains` and `hidden`, and
1518
1561
  the setters that change them. */
1519
- export declare function useChart<Z>(rows: readonly Z[], options?: ChartOptions<Z>): ChartParts<Z>;
1562
+ export declare function useChart<Z, V extends number | string = number>(rows: readonly Z[], options?: ChartOptions<Z, V>): ChartParts<Z>;
1520
1563
 
1521
1564
  /** A value read from the row (ADR-0048): the name of a number field, compared
1522
1565
  by its name, or a function, compared by its source text (`ValueFunction`). */
@@ -1529,8 +1572,8 @@ export declare type ValueFormat = ((value: number) => string) | NumberOptions;
1529
1572
  /** A **value** computed from the row - the function form of `Value`.
1530
1573
  Compared by its source text, not its identity - an inline function is new
1531
1574
  on every render. Known limit: one that reads a
1532
- changed closure variable under the same text is not run again; pass a new
1533
- data reference then. A native or bound function is compared by identity. */
1575
+ changed closure variable under the same text is not run again, and DEV warns;
1576
+ carry the value in the rows, or give the series a `key` that changes with it. A native or bound function is compared by identity. */
1534
1577
  export declare type ValueFunction<T> = (d: T, index: number) => number | null | undefined;
1535
1578
 
1536
1579
  /** What a value is. Four outcomes, not three.
@@ -1610,9 +1653,14 @@ export declare interface WorkingTimeTick {
1610
1653
  the beginning of the next - the earlier one stays: two labels on the same
1611
1654
  pixel would be one too many.
1612
1655
 
1656
+ With a `timeZone` the grid is the zone's, and `offset` is not read: a step
1657
+ of whole days stands on the zone's midnights, a shorter one on its whole
1658
+ multiples in real time - none in the hour a clock change removes, two in
1659
+ the one it doubles.
1660
+
1613
1661
  Both times come back, because the axis needs both: the working time to
1614
1662
  place the tick, the wall clock time to label it. */
1615
- export declare function workingTimeTicks(input: CalendarInput, from: number, to: number, step: number, offset?: number): WorkingTimeTick[];
1663
+ export declare function workingTimeTicks(input: CalendarInput, from: number, to: number, step: number, offset?: number, timeZone?: string): WorkingTimeTick[];
1616
1664
 
1617
1665
  /** The props of `XAxis`. */
1618
1666
  export declare interface XAxisProps<T> extends CommonProps {
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- const i = {
2
+ const r = {
3
3
  locale: "de-DE",
4
4
  roleDescription: "Diagramm",
5
5
  empty: "Keine Daten",
@@ -12,6 +12,9 @@ const i = {
12
12
  percent: (e) => `${e} %`,
13
13
  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.",
14
14
  selectHelp: "Enter wählt den Punkt.",
15
+ rangeStarted: (e) => `Bereich ab ${e} begonnen.`,
16
+ rangeMade: (e, n) => `Bereich von ${e} bis ${n}.`,
17
+ rangeHelp: "Leertaste setzt Anfang und Ende eines Bereichs, Escape bricht ab.",
15
18
  zoomHelp: "Plus und Minus zoomen, Umschalt mit Pfeil links oder rechts verschiebt, 0 kehrt zum eigenen Bereich der Achse zurück.",
16
19
  legendHelp: "In der Legende blendet Enter eine Serie aus oder ein, Umschalt+Enter zeigt nur sie.",
17
20
  allShown: "Sonst wäre nichts mehr zu sehen, darum werden alle Serien gezeigt.",
@@ -35,5 +38,5 @@ const i = {
35
38
  downsampled: (e) => `Ausgedünnt aus ${e.toLocaleString("de-DE")} Messwerten: erster, kleinster, größter und letzter Wert je Abschnitt.`
36
39
  };
37
40
  export {
38
- i as GERMAN_CHARTS_WORDING
41
+ r as GERMAN_CHARTS_WORDING
39
42
  };