ml-time-graph 1.16.0 → 1.17.1

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.
@@ -385,6 +385,132 @@ type GapParams = Omit<DrawGap, "type">;
385
385
  */
386
386
  type RangeLabelPosition = "top" | "center" | "middle" | "bottom" | "above" | "below";
387
387
 
388
+ /** Base scale interface – maps data values to pixel coordinates */
389
+ interface ScaleConfig {
390
+ /** Pixel range (output domain). Defaults to [0, width] or [0, height] */
391
+ range: [number, number];
392
+ }
393
+ interface Scale {
394
+ /** Map a data value to a pixel coordinate */
395
+ map(value: unknown): number;
396
+ /** Map a pixel coordinate back to a data value */
397
+ invert(pixel: number): unknown;
398
+ /** Get the data domain */
399
+ domain(): [unknown, unknown];
400
+ /** Get the pixel range */
401
+ range(): [number, number];
402
+ }
403
+ /** Scale with explicit data domain and pixel range. */
404
+ interface DomainScaleConfig extends ScaleConfig {
405
+ domain: [unknown, unknown];
406
+ }
407
+ /** Configuration for linear value-to-pixel mapping. */
408
+ interface LinearScaleConfig {
409
+ domain: [number, number];
410
+ range: [number, number];
411
+ }
412
+ /** Maps numeric data values to pixel coordinates using linear interpolation. */
413
+ declare class LinearScale implements Scale {
414
+ #private;
415
+ constructor(config: LinearScaleConfig);
416
+ map(value: unknown): number;
417
+ invert(pixel: number): number;
418
+ domain(): [number, number];
419
+ range(): [number, number];
420
+ }
421
+ /** Nice time intervals for tick placement (milliseconds) */
422
+ declare const TIME_INTERVALS: {
423
+ label: string;
424
+ ms: number;
425
+ }[];
426
+ /** Configuration for time-to-pixel mapping. */
427
+ interface TimeScaleConfig {
428
+ domain: [number, number];
429
+ range: [number, number];
430
+ /** Locale for i18n formatting (default: 'en-US') */
431
+ locale?: string;
432
+ /** IANA-Zone fuer die Beschriftung; ohne sie die Zone der Maschine. */
433
+ timeZone?: string;
434
+ }
435
+ /** Maps timestamps (ms) to pixel coordinates with automatic tick interval selection. */
436
+ declare class TimeScale implements Scale {
437
+ #private;
438
+ constructor(config: TimeScaleConfig);
439
+ map(value: unknown): number;
440
+ invert(pixel: number): number;
441
+ domain(): [number, number];
442
+ range(): [number, number];
443
+ get timeZone(): string | undefined;
444
+ get locale(): string;
445
+ /**
446
+ * Pick the "nicest" time interval that yields roughly `targetTicks` ticks
447
+ * across the visible range. Clamps to minTicks / maxTicks bounds.
448
+ */
449
+ tickInterval(targetTicks: number, minTicks?: number, maxTicks?: number): {
450
+ interval: number;
451
+ };
452
+ /**
453
+ * Generate tick positions (timestamps) across the domain.
454
+ */
455
+ ticks(opts?: {
456
+ minTicks?: number;
457
+ maxTicks?: number;
458
+ }): number[];
459
+ /** Format a timestamp using Intl.DateTimeFormat */
460
+ format(timestamp: number, formatOpts?: Intl.DateTimeFormatOptions): string;
461
+ }
462
+ /** Configuration for band (categorical) scale. */
463
+ interface BandScaleConfig {
464
+ /** Discrete categories (strings or numbers) */
465
+ domain: string[];
466
+ range: [number, number];
467
+ /** Padding fraction inside the band area (0-1, default 0.1) */
468
+ paddingInner?: number;
469
+ /** Padding fraction outside the band area (0-1, default 0.05) */
470
+ paddingOuter?: number;
471
+ }
472
+ /** Scale for discrete (categorical) axes — maps category indices to pixel positions. */
473
+ declare class BandScale implements Scale {
474
+ #private;
475
+ constructor(config: BandScaleConfig);
476
+ /** Get the pixel width of each band (including padding) */
477
+ get step(): number;
478
+ /** Get the pixel width of each band's content area */
479
+ get bandwidth(): number;
480
+ map(value: unknown): number;
481
+ invert(pixel: number): string;
482
+ domain(): [string, string];
483
+ range(): [number, number];
484
+ /** Get all band positions */
485
+ positions(): Map<string, number>;
486
+ }
487
+
488
+ /*!
489
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
490
+ * MIT with Attribution: free use incl. commercial requires visible credit to
491
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
492
+ */
493
+
494
+ /** Die Bedingung an einer Region. */
495
+ interface FillWhere {
496
+ /**
497
+ * Abstand in der Einheit der Reihen. STRENG groesser: genau `exceeds`
498
+ * auseinander gilt als einig -- daher nicht `minDelta`.
499
+ */
500
+ exceeds: number;
501
+ /**
502
+ * `'both'` (Vorgabe): |to − from| > exceeds. `'above'`: `to` liegt mehr als
503
+ * `exceeds` ueber `from`. `'below'`: mehr als `exceeds` darunter.
504
+ */
505
+ side?: "both" | "above" | "below";
506
+ /**
507
+ * Hoechstes Alter eines Messwerts in ms. Ist der letzte Wert einer Kante
508
+ * aelter, gibt es dort keine Aussage und keine Flaeche -- wie bei holdAlign.
509
+ * Ohne Angabe: keine Grenze.
510
+ */
511
+ maxAgeMs?: number;
512
+ }
513
+
388
514
  /*!
389
515
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
390
516
  * MIT with Attribution: free use incl. commercial requires visible credit to
@@ -421,10 +547,7 @@ type FillBound = "series" | "chartTop" | "chartBottom" | {
421
547
  | {
422
548
  series: string;
423
549
  };
424
- /**
425
- * A fill region. `from` and `to` define the Y interval; the X range is always
426
- * the series itself.
427
- */
550
+
428
551
  interface FillRegion {
429
552
  /** Lower bound. Default `'chartBottom'`. */
430
553
  from?: FillBound;
@@ -445,6 +568,13 @@ interface FillRegion {
445
568
  * high / highwarn and each fills only its own value range.
446
569
  */
447
570
  outer?: FillBound;
571
+ /**
572
+ * Nur dort fuellen, wo die beiden Kanten weiter als `exceeds` auseinander
573
+ * liegen -- etwa zwei Fuehler, die dasselbe messen sollen. Entschieden an
574
+ * den Messwerten (linear verbunden, Treppe gehalten), gezeichnet zwischen
575
+ * den gezeichneten Kurven. Siehe {@link FillWhere}.
576
+ */
577
+ where?: FillWhere;
448
578
  }
449
579
  /**
450
580
  * Top-level fill spec on a series style. Either a single fill (covers from
@@ -559,12 +689,61 @@ interface GapRegion {
559
689
  label?: string;
560
690
  style?: GapStyle;
561
691
  }
692
+ /**
693
+ * Datenausfall am Ende -- `gaps.atEnd` (I-20261007-05).
694
+ *
695
+ * Ein verstummtes Geraet ist im Monitoring die wichtigste Nachricht, und eine
696
+ * Linie, die einfach endet, sagt sie nicht. Liegt der letzte Messwert einer
697
+ * Reihe mehr als `afterMs` vor `now`, entsteht eine Lueckenregion vom letzten
698
+ * Wert bis `now` -- gezeichnet wie jede andere Luecke.
699
+ */
700
+ interface GapsAtEnd {
701
+ /**
702
+ * Ab wann es ein Ausfall ist, in ms. Streng groesser: genau `afterMs` alt
703
+ * ist noch keiner. Dieselbe Schwelle, an der ein "keine Daten"-Ereignis
704
+ * oeffnet -- Bild und Ereignis sollen uebereinstimmen.
705
+ */
706
+ afterMs: number;
707
+ /**
708
+ * "Jetzt" in ms. Die Bibliothek liest keine Uhr: Bildschirm, PDF und Test
709
+ * sollen dasselbe zeigen. Vorgabe: das Ende der Zeitachse.
710
+ */
711
+ now?: number;
712
+ /**
713
+ * Der Text. Als Zeichenkette mit Platzhaltern -- `{since}` (Uhrzeit des
714
+ * letzten Werts im Zeitformat des Diagramms, mit Datum, wenn er an einem
715
+ * anderen Tag lag als `now`) und `{duration}` (`45 min`, `3 h 12 min`,
716
+ * `2 d 4 h`) -- oder als Funktion (nur TypeScript; JSON kennt keine).
717
+ * Ohne Angabe kein Text: die Bibliothek baut keinen Satz in einer Sprache ein.
718
+ */
719
+ label?: string | ((sinceMs: number, durationMs: number) => string);
720
+ /**
721
+ * Darstellung. Vorgabe: schraffiert, mit gestrichelten Kanten, die
722
+ * Beschriftung dreht sich, wenn sie nicht hineinpasst. `gaps.style` gilt
723
+ * hier NICHT -- der Ausfall am Ende hat sein eigenes Aussehen.
724
+ */
725
+ style?: GapStyle;
726
+ }
727
+ /** Je Reihe: `series.gaps`. */
728
+ interface SeriesGaps {
729
+ /**
730
+ * `false`: diese Reihe bekommt keine Flaeche am Ende -- fuer Melder, die
731
+ * absichtlich schweigen (Tuerkontakt, meldet nur bei Aenderung).
732
+ * `{ afterMs }`: eigene Schwelle statt der des Diagramms (Fuehler
733
+ * verschiedener Geraete in einem Bild).
734
+ */
735
+ atEnd?: false | {
736
+ afterMs: number;
737
+ };
738
+ }
562
739
  /** Top-level gap configuration on `MLTimeGraphOptions`. */
563
740
  interface GapsConfig {
564
741
  autoDetect?: boolean;
565
742
  minGapMs?: number;
566
743
  regions?: GapRegion[];
567
744
  style?: GapStyle;
745
+ /** Datenausfall am Ende sichtbar machen -- siehe {@link GapsAtEnd}. */
746
+ atEnd?: GapsAtEnd;
568
747
  }
569
748
 
570
749
  /*!
@@ -743,6 +922,10 @@ interface TimeSeries {
743
922
  * Art der Messgroesse. Der Daten-Adapter (`parseJSON`) liest sie und legt
744
923
  * sie ab; auf das BILD wirkt sie nicht -- die Darstellung bestimmen `style`
745
924
  * und `showAs`. Vorgabe: 'numeric'.
925
+ *
926
+ * @deprecated Has no effect on the chart (B-20260922-04). For a state
927
+ * series use `enumMap` -- it labels the axis with the state names. Will be
928
+ * removed before 2.0.
746
929
  */
747
930
  sensorType?: SensorType;
748
931
  enumMap?: EnumMap;
@@ -764,6 +947,8 @@ interface TimeSeries {
764
947
  colorByThresholds?: string[];
765
948
  /** Optional SVG id prefix for series elements. */
766
949
  id?: string;
950
+ /** Luecken je Reihe -- etwa `atEnd: false` fuer einen Melder, der absichtlich schweigt. */
951
+ gaps?: SeriesGaps;
767
952
  }
768
953
  /** Aggregated series: min/max/avg per slot. */
769
954
  interface AggregatedSeries {
@@ -814,6 +999,12 @@ interface Gap {
814
999
  labelBaseline?: RangeLabelPosition;
815
1000
  /** Drehung in Grad, oder "auto": drehen, wenn der Text nicht hineinpasst. */
816
1001
  rotate?: number | "auto";
1002
+ /**
1003
+ * How the gap is drawn. `"label"` is deprecated (B-20261006-01) and will
1004
+ * be removed before 2.0: it is not a look of its own but the absence of
1005
+ * one -- use `"empty"` with `label`. The structured form
1006
+ * (`gaps: { regions, style: { display } }`) never had it.
1007
+ */
817
1008
  style?: DrawGapType_t;
818
1009
  }
819
1010
  /** Configuration for gap rendering (manual or auto-detected) */
@@ -1023,104 +1214,4 @@ interface AnnotationBandConfig {
1023
1214
  items: AnnotationBandItem[];
1024
1215
  }
1025
1216
 
1026
- /** Base scale interface – maps data values to pixel coordinates */
1027
- interface ScaleConfig {
1028
- /** Pixel range (output domain). Defaults to [0, width] or [0, height] */
1029
- range: [number, number];
1030
- }
1031
- interface Scale {
1032
- /** Map a data value to a pixel coordinate */
1033
- map(value: unknown): number;
1034
- /** Map a pixel coordinate back to a data value */
1035
- invert(pixel: number): unknown;
1036
- /** Get the data domain */
1037
- domain(): [unknown, unknown];
1038
- /** Get the pixel range */
1039
- range(): [number, number];
1040
- }
1041
- /** Scale with explicit data domain and pixel range. */
1042
- interface DomainScaleConfig extends ScaleConfig {
1043
- domain: [unknown, unknown];
1044
- }
1045
- /** Configuration for linear value-to-pixel mapping. */
1046
- interface LinearScaleConfig {
1047
- domain: [number, number];
1048
- range: [number, number];
1049
- }
1050
- /** Maps numeric data values to pixel coordinates using linear interpolation. */
1051
- declare class LinearScale implements Scale {
1052
- #private;
1053
- constructor(config: LinearScaleConfig);
1054
- map(value: unknown): number;
1055
- invert(pixel: number): number;
1056
- domain(): [number, number];
1057
- range(): [number, number];
1058
- }
1059
- /** Nice time intervals for tick placement (milliseconds) */
1060
- declare const TIME_INTERVALS: {
1061
- label: string;
1062
- ms: number;
1063
- }[];
1064
- /** Configuration for time-to-pixel mapping. */
1065
- interface TimeScaleConfig {
1066
- domain: [number, number];
1067
- range: [number, number];
1068
- /** Locale for i18n formatting (default: 'en-US') */
1069
- locale?: string;
1070
- /** IANA-Zone fuer die Beschriftung; ohne sie die Zone der Maschine. */
1071
- timeZone?: string;
1072
- }
1073
- /** Maps timestamps (ms) to pixel coordinates with automatic tick interval selection. */
1074
- declare class TimeScale implements Scale {
1075
- #private;
1076
- constructor(config: TimeScaleConfig);
1077
- map(value: unknown): number;
1078
- invert(pixel: number): number;
1079
- domain(): [number, number];
1080
- range(): [number, number];
1081
- get timeZone(): string | undefined;
1082
- get locale(): string;
1083
- /**
1084
- * Pick the "nicest" time interval that yields roughly `targetTicks` ticks
1085
- * across the visible range. Clamps to minTicks / maxTicks bounds.
1086
- */
1087
- tickInterval(targetTicks: number, minTicks?: number, maxTicks?: number): {
1088
- interval: number;
1089
- };
1090
- /**
1091
- * Generate tick positions (timestamps) across the domain.
1092
- */
1093
- ticks(opts?: {
1094
- minTicks?: number;
1095
- maxTicks?: number;
1096
- }): number[];
1097
- /** Format a timestamp using Intl.DateTimeFormat */
1098
- format(timestamp: number, formatOpts?: Intl.DateTimeFormatOptions): string;
1099
- }
1100
- /** Configuration for band (categorical) scale. */
1101
- interface BandScaleConfig {
1102
- /** Discrete categories (strings or numbers) */
1103
- domain: string[];
1104
- range: [number, number];
1105
- /** Padding fraction inside the band area (0-1, default 0.1) */
1106
- paddingInner?: number;
1107
- /** Padding fraction outside the band area (0-1, default 0.05) */
1108
- paddingOuter?: number;
1109
- }
1110
- /** Scale for discrete (categorical) axes — maps category indices to pixel positions. */
1111
- declare class BandScale implements Scale {
1112
- #private;
1113
- constructor(config: BandScaleConfig);
1114
- /** Get the pixel width of each band (including padding) */
1115
- get step(): number;
1116
- /** Get the pixel width of each band's content area */
1117
- get bandwidth(): number;
1118
- map(value: unknown): number;
1119
- invert(pixel: number): string;
1120
- domain(): [string, string];
1121
- range(): [number, number];
1122
- /** Get all band positions */
1123
- positions(): Map<string, number>;
1124
- }
1125
-
1126
- export { type SeriesOverlay as $, type AxisPosition as A, type DataPointRef as B, type FillBound as C, type DataPoint as D, type EnumMap as E, type FillSpec as F, type GridLayer as G, type Highlight as H, type FillRegion as I, type FillSide as J, type FillStyle as K, LinearScale as L, type MarkerLineStyle as M, type GapConfig as N, type GapLabel as O, type PointStyleType as P, type GapRegion as Q, type RangeLabelPosition as R, type SmoothingType as S, TimeScale as T, type GapStyle as U, type LineShape as V, type LineStyle as W, type MarkerStyle as X, type MovingAverageType as Y, type SVGLineStyle as Z, type SensorType as _, type DrawCommand as a, type SeriesOverlayKind as a0, type SeriesType as a1, type ShadowStyle as a2, type SolidDashStyle as a3, type ThresholdLabelConfig as a4, getLineStyle as a5, resolveDash as a6, type GapBand as a7, type LineParams as a8, type PathParams as a9, type RectParams as aa, type CircleParams as ab, type TextParams as ac, type GapParams as ad, type Point as ae, BandScale as af, type BandScaleConfig as ag, type Dashstyle_t as ah, type DomainScaleConfig as ai, type DrawCircle as aj, type DrawGap as ak, type DrawGapType_t$1 as al, type DrawLine as am, type DrawPath as an, type DrawRect as ao, type DrawText as ap, type LinearScaleConfig as aq, type Scale as ar, type ScaleConfig as as, TIME_INTERVALS as at, type TimeScaleConfig as au, getHatch as av, type LineDashStyle as b, type LineVariant as c, type DrawGroup as d, type AnySeries as e, type Threshold as f, type Gap as g, type GapsConfig as h, type Annotation as i, type AnnotationBandConfig as j, type HatchVariant as k, type SeriesStyle as l, type TimeSeries as m, type ThresholdFill as n, type ThresholdLabelPosition as o, type AnnotationPointShape as p, type LabelAnchor as q, type AnnotationBandItem as r, type TextBaseline as s, type AggregatedPoint as t, type AggregatedSeries as u, type AggregatedShowAs as v, type AggregationConfig as w, type AggregationMode as x, type AnnotationKind as y, type AxisOrientation as z };
1217
+ export { type SVGLineStyle as $, type AxisPosition as A, type DataPointRef as B, type FillBound as C, type DataPoint as D, type EnumMap as E, type FillSpec as F, type GridLayer as G, type Highlight as H, type FillRegion as I, type FillSide as J, type FillStyle as K, LinearScale as L, type MarkerLineStyle as M, type FillWhere as N, type GapConfig as O, type PointStyleType as P, type GapLabel as Q, type RangeLabelPosition as R, type SmoothingType as S, TimeScale as T, type GapRegion as U, type GapStyle as V, type GapsAtEnd as W, type LineShape as X, type LineStyle as Y, type MarkerStyle as Z, type MovingAverageType as _, type DrawCommand as a, type SensorType as a0, type SeriesGaps as a1, type SeriesOverlay as a2, type SeriesOverlayKind as a3, type SeriesType as a4, type ShadowStyle as a5, type SolidDashStyle as a6, type ThresholdLabelConfig as a7, getLineStyle as a8, resolveDash as a9, type GapBand as aa, type LineParams as ab, type PathParams as ac, type RectParams as ad, type CircleParams as ae, type TextParams as af, type GapParams as ag, type Point as ah, BandScale as ai, type BandScaleConfig as aj, type Dashstyle_t as ak, type DomainScaleConfig as al, type DrawCircle as am, type DrawGap as an, type DrawGapType_t$1 as ao, type DrawLine as ap, type DrawPath as aq, type DrawRect as ar, type DrawText as as, type LinearScaleConfig as at, type Scale as au, type ScaleConfig as av, TIME_INTERVALS as aw, type TimeScaleConfig as ax, getHatch as ay, type LineDashStyle as b, type LineVariant as c, type DrawGroup as d, type AnySeries as e, type Threshold as f, type Gap as g, type GapsConfig as h, type Annotation as i, type AnnotationBandConfig as j, type HatchVariant as k, type SeriesStyle as l, type TimeSeries as m, type ThresholdFill as n, type ThresholdLabelPosition as o, type AnnotationPointShape as p, type LabelAnchor as q, type AnnotationBandItem as r, type TextBaseline as s, type AggregatedPoint as t, type AggregatedSeries as u, type AggregatedShowAs as v, type AggregationConfig as w, type AggregationMode as x, type AnnotationKind as y, type AxisOrientation as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ml-time-graph",
3
- "version": "1.16.0",
3
+ "version": "1.17.1",
4
4
  "description": "TypeScript library for time-series charts with rich contextual annotation — telemetry, sensors, metrics, logs, finance. DOM-free SVG output, identical in the browser and on the server.",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",