ml-time-graph 1.9.1 → 1.11.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
@@ -1,238 +1,7 @@
1
- import { L as LegendOrientation, R as Renderer, M as Marker, a as LegendItem, b as LayoutResult, c as RenderOutput } from './slug-aDUz3wBN.js';
2
- export { T as Theme, d as drawMarker, g as getDefaultTheme, r as resetDefaultTheme, s as setDefaultTheme, e as slugify } from './slug-aDUz3wBN.js';
3
- import { L as LineVariant, A as AnySeries, T as Threshold, H as Highlight, G as Gap, a as GapsConfig, b as Annotation, c as AnnotationBandConfig, D as DrawCommand, d as TimeScale, e as LinearScale, S as SeriesStyle, F as FillSpec, f as TimeSeries, g as HatchVariant, h as ThresholdLabelPosition, P as PointStyleType, i as AnnotationBandItem, j as AggregatedPoint, k as AggregatedSeries, l as DataPoint } from './scale-CQhADkWB.js';
4
- export { m as AggregationConfig, n as AggregationMode, o as DataPointRef, E as EnumMap, p as FillBound, q as FillDirectionType, r as FillRegion, s as FillSide, t as FillStyle, u as GapConfig, v as GapLabel, w as GapRegion, x as GapStyle, y as LineDashStyle, z as LineStyle, M as MarkerStyle, B as SVGLineStyle, C as SensorType, I as SeriesOverlay, J as SeriesOverlayKind, K as SeriesType, N as ShadowStyle, O as ThresholdLabelConfig, Q as getLineStyle, R as resolveDash } from './scale-CQhADkWB.js';
5
-
6
- /*!
7
- * MLTimeGraph — Copyright (c) 2026 Michael Lechner
8
- * MIT with Attribution: free use incl. commercial requires visible credit to
9
- * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
10
- */
11
-
12
- /** Tick density / sizing for one axis. */
13
- interface TickConfig {
14
- /** Target number of major (labelled) ticks. */
15
- major?: number;
16
- /** How many minor ticks to place between two major ticks. Default 0 = off. */
17
- minor?: number;
18
- /** Tick mark length in px. */
19
- size?: number;
20
- }
21
- /** Grid line styling for one tick level. `false` disables that grid level. */
22
- interface GridLineStyle {
23
- color?: string;
24
- width?: number;
25
- style?: LineVariant;
26
- opacity?: number;
27
- }
28
- /**
29
- * Per-axis grid configuration. Each tick level (major / minor) can be styled
30
- * independently or disabled. Defaults: major grid shown with theme colours,
31
- * minor grid off.
32
- */
33
- interface GridStyle {
34
- major?: GridLineStyle | false;
35
- minor?: GridLineStyle | false;
36
- }
37
- /** Axis baseline + tick marks styling. */
38
- interface AxisStyle {
39
- color?: string;
40
- width?: number;
41
- }
42
- /** Tick / axis-label text styling. */
43
- interface AxisLabelsStyle {
44
- color?: string;
45
- fontSize?: number;
46
- }
47
- /** Configuration for one Y-axis (left or right). */
48
- interface YAxisConfig {
49
- /** Position is 'left' or 'right' to determine placement side. Defaults to 'left'. */
50
- position?: "left" | "right";
51
- /** Optional explicit horizontal pixel offset from chart edge (defaults to index * 50px). */
52
- offset?: number;
53
- /** Rotated label drawn next to the axis. */
54
- label?: string;
55
- /** Override the value domain. `'auto'` lets the chart compute it from data. */
56
- domain?: [number, number] | "auto";
57
- /**
58
- * Extra room above and below the data, **in pixels**. Ignored when `domain`
59
- * is set explicitly — then you decide the range.
60
- *
61
- * The computed domain ends exactly at the smallest and largest reading, and
62
- * the plot is clipped to its rectangle. A line of width 10 at the maximum
63
- * therefore loses half its stroke, and a marker half its disc. That is right
64
- * for the *value* and wrong for the *picture*.
65
- *
66
- * Pixels rather than a share of the range: the cause is in pixels
67
- * (`style.line.width`, `markers.size`), and the same number then works for a
68
- * series in °C and one in kW. A rule of thumb is half the widest stroke plus
69
- * a little — `padding: 8` covers a 10 px line and a size-6 marker.
70
- *
71
- * ```ts
72
- * axes: { left: { padding: 8 } }
73
- * axes: { left: { padding: { top: 24, bottom: 4 } } } // room for a label
74
- * ```
75
- */
76
- padding?: number | {
77
- top?: number;
78
- bottom?: number;
79
- };
80
- /** Format a tick value into its label text. */
81
- format?: (value: number) => string;
82
- /** Tick density / sizing. */
83
- ticks?: TickConfig;
84
- /** Per-tick-level grid styling. */
85
- grid?: GridStyle;
86
- /** Axis baseline + tick marks styling. */
87
- axis?: AxisStyle;
88
- /** Tick label text styling. */
89
- labels?: AxisLabelsStyle;
90
- }
91
- /** Configuration for the X (time) axis. */
92
- interface XAxisConfig {
93
- /** Label drawn below the axis. */
94
- label?: string;
95
- /** Override the time domain. `'auto'` lets the chart compute it from data. */
96
- domain?: [number, number] | "auto";
97
- /** Custom formatter for tick labels (called with a `Date`). */
98
- format?: (d: Date) => string;
99
- /** Tick density / sizing. */
100
- ticks?: TickConfig;
101
- /** Per-tick-level grid styling. */
102
- grid?: GridStyle;
103
- /** Axis baseline + tick marks styling. */
104
- axis?: AxisStyle;
105
- /** Tick label text styling. */
106
- labels?: AxisLabelsStyle;
107
- }
108
- /**
109
- * Top-level axes container on {@link MLTimeGraphOptions}.
110
- * `left` and `right` correspond to `yAxisIndex: 0` and `yAxisIndex: 1` series.
111
- * Additional axes can be defined in the `y` array, with indices mapping to series via `yAxisIndex`.
112
- */
113
- interface AxesConfig {
114
- x?: XAxisConfig;
115
- left?: YAxisConfig;
116
- right?: YAxisConfig;
117
- /** Y specifies an arbitrary number of vertical axes, each mapped by its slice index. */
118
- y?: YAxisConfig[];
119
- }
120
-
121
- /*!
122
- * MLTimeGraph — Copyright (c) 2026 Michael Lechner
123
- * MIT with Attribution: free use incl. commercial requires visible credit to
124
- * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
125
- */
126
-
127
- /** Chart margins in pixels. */
128
- interface Margin {
129
- top: number;
130
- right: number;
131
- bottom: number;
132
- left: number;
133
- }
134
- /** Legend placement position — inside or outside the chart area. */
135
- type LegendPosition = "inside-right" | "inside-left" | "outside-right" | "outside-left" | "separate";
136
- interface LegendOptions {
137
- /** Show the legend (default false). */
138
- show?: boolean;
139
- /** Placement (default 'inside-right'). 'separate' draws nothing — read chart.legendItems() and render your own. */
140
- position?: LegendPosition;
141
- /** Item layout direction (default 'vertical'). */
142
- orientation?: LegendOrientation;
143
- }
144
- interface MLTimeGraphOptions {
145
- /** Chart dimensions */
146
- width?: number;
147
- height?: number;
148
- /** Margins */
149
- margin?: Margin;
150
- /** Renderer (injected) */
151
- renderer?: Renderer;
152
- /** Time series data (raw or aggregated min/max/avg) */
153
- series?: AnySeries[];
154
- /**
155
- * Clip series drawing to the plot area (default `true`).
156
- *
157
- * It matters only when data lies outside the axis domain — which happens as soon as you
158
- * fix `axes.x.domain` and hand over a reading from just outside the window, so the curve
159
- * runs to the edge instead of starting in mid-air. Without clipping, line and markers
160
- * paint over the axis labels.
161
- *
162
- * Turn it off if you deliberately want a series to reach beyond the plot, or if the
163
- * clip costs you: every clipped group gets a `clip-path`, and a browser may promote each
164
- * to its own layer. With a handful of series that is nothing; with dozens on a slow
165
- * machine it can be worth measuring.
166
- */
167
- clipSeries?: boolean;
168
- /** Locale for i18n (e.g. 'de-DE') */
169
- locale?: string;
170
- /**
171
- * IANA time zone for the time axis, e.g. `'Europe/Berlin'` or `'UTC'`.
172
- *
173
- * Unset means the machine's zone — the behaviour up to 1.8.1, kept so that
174
- * nothing changes for callers who never thought about it. But a browser sits
175
- * in the reader's zone and a server almost always in UTC, so the *same* JSON
176
- * labelled the same reading with different times depending on where it was
177
- * drawn. That is the opposite of what a DOM-free renderer is for; set this
178
- * whenever a chart is produced in one place and read in another.
179
- *
180
- * The tick *positions* never depended on it — they are epoch arithmetic. Only
181
- * the labels do.
182
- */
183
- timeZone?: string;
184
- /**
185
- * Font for every text in the chart, written into the SVG as `font-family`.
186
- *
187
- * Unset means the default stack below. Why name one at all: the SVG says
188
- * nothing about fonts today, so a viewer picks its own, and the same chart
189
- * has different label widths in a browser, in an email client and in a
190
- * rasteriser. Naming a stack removes that variance.
191
- *
192
- * The default is chosen for **metric compatibility**, not looks: Liberation
193
- * Sans was designed with the same advance widths as Arial, so Linux lands on
194
- * Liberation, Windows and macOS on Arial or Helvetica, and the labels occupy
195
- * the same space. A stack with DejaVu Sans would not do that — it is
196
- * noticeably wider, and labels would collide differently.
197
- *
198
- * A CSS stack *is* "use it if installed, otherwise ours" — no extra
199
- * mechanism needed.
200
- *
201
- * Note that the library never **measures** text (it renders DOM-free), so
202
- * this does not change the layout: anchors and `text-anchor` stay where they
203
- * are. It changes what the viewer draws. A much wider house font will
204
- * therefore collide differently; that is on you.
205
- */
206
- fontFamily?: string;
207
- /** Integrated legend configuration */
208
- legend?: LegendOptions;
209
- /** Markers */
210
- markers?: Marker[];
211
- /** Threshold bands / lines / fills drawn behind the series */
212
- thresholds?: Threshold[];
213
- /** Highlighted time regions drawn behind the series */
214
- highlights?: Highlight[];
215
- /**
216
- * Data-gap configuration. Two equivalent forms:
217
- * - `Gap[]` — legacy: array of region objects with flat
218
- * fill/hatch/labelBaseline/rotate fields.
219
- * - {@link GapsConfig} — new (preferred): `{ regions?, autoDetect?,
220
- * minGapMs?, style? }`, where `style` provides
221
- * per-region fallbacks and `autoDetect` (TODO)
222
- * will derive gaps from time spacing in
223
- * Phase 3+. For now: typed but not yet acted on.
224
- */
225
- gaps?: Gap[] | GapsConfig;
226
- /** Free-form overlays (arrow, line, rect, point, label) in data coordinates */
227
- annotations?: Annotation[];
228
- /** Horizontal annotation bands below the chart (colored time ranges + labels) */
229
- annotationBands?: AnnotationBandConfig[];
230
- /**
231
- * First-class axes configuration: per-axis `label`, `format`, `ticks`, `grid`,
232
- * `axis`, `labels` (see USAGE.md, "Axes").
233
- */
234
- axes?: AxesConfig;
235
- }
1
+ import { M as MLTimeGraphOptions, L as LegendItem, R as Renderer, a as LayoutResult, b as Margin, A as AxesConfig, X as XAxisConfig, Y as YAxisConfig, c as LegendOptions, d as LegendPosition, e as LegendOrientation, f as Marker, g as RenderOutput } from './marker_renderer-CiccLy7h.js';
2
+ export { h as AxisLabelsStyle, i as AxisStyle, G as GridLineStyle, j as GridStyle, T as TextMetrics, k as Theme, l as TickConfig, m as drawMarker, n as estimateMetrics, o as getDefaultTheme, p as liberationMetrics, r as resetDefaultTheme, s as setDefaultTheme, q as slugify } from './marker_renderer-CiccLy7h.js';
3
+ import { d as AnySeries, h as Annotation, a as DrawCommand, T as TimeScale, L as LinearScale, f as Gap, g as GapsConfig, e as Threshold, H as Highlight, i as AnnotationBandConfig, k as SeriesStyle, b as LineVariant, S as SmoothingType, F as FillSpec, l as TimeSeries, m as LineDashStyle, n as ThresholdFill, j as HatchVariant, o as ThresholdLabelPosition, P as PointStyleType, M as MarkerLineStyle, R as RangeLabelPosition, p as AnnotationPointShape, q as LabelAnchor, r as AnnotationBandItem, s as TextBaseline, t as AggregatedPoint, u as AggregatedSeries, D as DataPoint } from './scale-DQ-IdB6t.js';
4
+ export { v as AggregatedShowAs, w as AggregationConfig, x as AggregationMode, y as AnnotationKind, z as AxisOrientation, A as AxisPosition, B as DataPointRef, E as EnumMap, C as FillBound, I as FillRegion, J as FillSide, K as FillStyle, N as GapConfig, O as GapLabel, Q as GapRegion, U as GapStyle, G as GridLayer, V as LineShape, W as LineStyle, X as MarkerStyle, Y as MovingAverageType, Z as SVGLineStyle, _ as SensorType, $ as SeriesOverlay, a0 as SeriesOverlayKind, a1 as SeriesType, a2 as ShadowStyle, a3 as SolidDashStyle, a4 as ThresholdLabelConfig, a5 as getLineStyle, a6 as resolveDash } from './scale-DQ-IdB6t.js';
236
5
 
237
6
  /*!
238
7
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
@@ -247,6 +16,12 @@ declare class MLTimeGraph {
247
16
  private readonly _timeZone?;
248
17
  private readonly _fontFamily?;
249
18
  private readonly _legend?;
19
+ /**
20
+ * Womit Textbreiten gerechnet werden. Vorgabe ist die mitgelieferte Tabelle,
21
+ * nicht eine Messung beim Aufrufer -- sonst haengt das Bild davon ab, WER
22
+ * misst, und die Zusage "dasselbe JSON, dasselbe Bild" faellt.
23
+ */
24
+ private readonly _textMetrics;
250
25
  /** Serien auf die Zeichenflaeche beschneiden (Vorgabe: ja) — siehe options.ts. */
251
26
  private readonly _clipSeries;
252
27
  private readonly _markers;
@@ -298,6 +73,37 @@ declare class MLTimeGraph {
298
73
  private _renderSeries;
299
74
  private _interpolateValue;
300
75
  legendItems(): LegendItem[];
76
+ /**
77
+ * Die Farbe einer Reihe ohne eigene Angabe.
78
+ *
79
+ * Bis 1.10.0 nahm die TS-Seite hier `theme.stroke` -- fuer JEDE Reihe
80
+ * dieselbe. Fuenf Reihen ohne Farbangabe waren fuenf blaue Linien, und die
81
+ * Legende zeigte fuenfmal dasselbe Kaestchen.
82
+ *
83
+ * Der Go-Port nimmt seit jeher `theme.Palette[i]`. Die Paritaet hat das nie
84
+ * gesehen, weil KEINE Vorlage zwei Reihen ohne Farbe hat -- und bei einer
85
+ * einzigen sind beide gleich, denn palette[0] IST theme.stroke. Wieder: was
86
+ * keine Vorlage zeigt, prueft nichts (edge_serien_ohne_farbe).
87
+ */
88
+ private _palettenFarbe;
89
+ /**
90
+ * Die Zustaende der Reihen an EINER Achse, aufsteigend -- oder undefined,
91
+ * wenn keine Reihe dort eine `enumMap` hat.
92
+ *
93
+ * Mehrere Reihen auf derselben Achse duerfen verschiedene Karten mitbringen;
94
+ * zusammengelegt wird die Vereinigung, damit kein Zustand ohne Strich bleibt.
95
+ */
96
+ private _zustaendeVon;
97
+ /**
98
+ * Beschriftung eines Zustands; unbekannte Werte behalten ihre Zahl.
99
+ *
100
+ * Nennen zwei Reihen denselben Wert verschieden -- eine Pumpe "Running", ein
101
+ * Ventil "Open" --, gewinnt die ERSTE. Das ist keine Loesung des Konflikts,
102
+ * sondern eine feste Regel dafuer: eine Achse hat EIN Vokabular, und wer zwei
103
+ * braucht, braucht zwei Achsen. Vorher gewann die zuletzt genannte Reihe, und
104
+ * die Achse trug eine Mischung aus beiden.
105
+ */
106
+ private _zustandName;
301
107
  private _legendItems;
302
108
  get renderer(): Renderer | undefined;
303
109
  get layout(): LayoutResult;
@@ -578,8 +384,16 @@ declare class TimeSeriesBuilder {
578
384
  setStyle(style: SeriesStyle): this;
579
385
  /** Shortcut to apply custom stroke styling (color, width, dash style). */
580
386
  setLineStyle(color: string, width: number, style?: LineVariant): this;
581
- /** Configures spline interpolation (smoothing) on the series path. */
582
- setSmoothing(smooth: boolean): this;
387
+ /**
388
+ * Configures spline interpolation (smoothing) on the series path.
389
+ *
390
+ * The second argument picks the spline. Leave it out for Catmull-Rom, the
391
+ * default: soft, but it overshoots. `'monotone'` never leaves the span
392
+ * between two readings — the right choice for anything with a ceiling, such
393
+ * as humidity at 100 %. `'akima'` stays flat ahead of an edge instead of
394
+ * swinging up to meet it.
395
+ */
396
+ setSmoothing(smooth: boolean, type?: SmoothingType): this;
583
397
  /** Assigns the area fill specification. */
584
398
  setFill(fill: FillSpec): this;
585
399
  /** Sets a custom identifier for the series path. */
@@ -605,9 +419,9 @@ declare class ThresholdBuilder {
605
419
  /** Sets the threshold boundary color. */
606
420
  setColor(color: string): this;
607
421
  /** Configures the line type (solid, dashed, dotted, none). */
608
- setLine(style: "solid" | "dashed" | "dotted" | "none"): this;
422
+ setLine(style: LineDashStyle): this;
609
423
  /** Configures half-plane fills (above, below, none) and opacity. */
610
- setFill(fillType: "above" | "below" | "none", opacity: number): this;
424
+ setFill(fillType: ThresholdFill, opacity: number): this;
611
425
  /** Configures a hatch pattern style for the fill. */
612
426
  setFillHatch(hatch: HatchVariant): this;
613
427
  /** Configures the labels parameters. */
@@ -639,7 +453,7 @@ declare class MarkerBuilder {
639
453
  /** Sets the shape of the point marker (circle, square, cross, star, arrow, none). */
640
454
  setPointStyle(style: PointStyleType): this;
641
455
  /** Sets the type of vertical projection line (full, to-value, to-top, none). */
642
- setLineStyle(style: "full" | "to-value" | "to-top" | "none"): this;
456
+ setLineStyle(style: MarkerLineStyle): this;
643
457
  /** Targets a specific series by index for interpolation. */
644
458
  setSeriesIndex(idx: number): this;
645
459
  /** Compiles and returns the Marker object. */
@@ -665,7 +479,7 @@ declare class HighlightBuilder {
665
479
  /** Sets the opacity. */
666
480
  setOpacity(opacity: number): this;
667
481
  /** Sets the label alignment (top, center, bottom, above, below). */
668
- setLabelPosition(pos: "top" | "center" | "bottom" | "above" | "below"): this;
482
+ setLabelPosition(pos: RangeLabelPosition): this;
669
483
  /** Sets the text rotation in degrees. */
670
484
  setRotate(rotate: number): this;
671
485
  /** Compiles and returns the Highlight object. */
@@ -713,11 +527,11 @@ declare class AnnotationBuilder {
713
527
  /** Sets the point radius (point only). */
714
528
  setRadius(radius: number): this;
715
529
  /** Sets the point shape (point only). */
716
- setShape(shape: "circle" | "square" | "cross"): this;
530
+ setShape(shape: AnnotationPointShape): this;
717
531
  /** Sets the label text (label only). */
718
532
  setText(text: string): this;
719
533
  /** Sets the text anchor (label only). */
720
- setAnchor(anchor: "start" | "middle" | "end"): this;
534
+ setAnchor(anchor: LabelAnchor): this;
721
535
  /** Sets the horizontal offset (label only). */
722
536
  setDx(dx: number): this;
723
537
  /** Sets the vertical offset (label only). */
@@ -772,7 +586,7 @@ declare class AnnotationBandItemBuilder {
772
586
  /** Sets the border stroke width. */
773
587
  setStrokeWidth(w: number): this;
774
588
  /** Sets the text label and optional label formatting fields. */
775
- setLabel(lbl: string, fontSize?: number, fill?: string, baseline?: "top" | "middle" | "bottom"): this;
589
+ setLabel(lbl: string, fontSize?: number, fill?: string, baseline?: TextBaseline): this;
776
590
  /** Compiles and returns the AnnotationBandItem object. */
777
591
  build(): AnnotationBandItem;
778
592
  }
@@ -1047,6 +861,6 @@ declare function mergeOptions(...layers: (OptionsLayer | undefined)[]): MLTimeGr
1047
861
  * Monate spaeter eine Datei aus einem Stapel von Berichten in der Hand haelt,
1048
862
  * kann sonst nicht feststellen, welcher Stand sie gezeichnet hat.
1049
863
  */
1050
- declare const VERSION = "1.9.1";
864
+ declare const VERSION = "1.11.0";
1051
865
 
1052
- export { AggregatedPoint, AggregatedSeries, Annotation, AnnotationBandBuilder, AnnotationBandConfig, AnnotationBandItem, AnnotationBandItemBuilder, AnnotationBuilder, AnySeries, type AxesConfig, type AxisLabelsStyle, type AxisStyle, DataPoint, DrawCommand, type FieldAccessor, type FillBetweenThresholdsInput, FillSpec, Gap, GapsConfig, GraphBuilder, type GridLineStyle, type GridStyle, HatchVariant, Highlight, HighlightBuilder, LegendItem, type LegendOptions, LegendOrientation, type LegendPosition, type LimitStatsPoint, LineVariant, MLTimeGraph, type MLTimeGraphOptions, type Margin, Marker, MarkerBuilder, type MktPoint, type OptionsLayer, PointStyleType, SVGRenderer, SeriesStyle, type StatsAggregatedPoint, type StdDevPoint, Threshold, ThresholdBuilder, ThresholdLabelPosition, type TickConfig, type TimeInput, TimeSeries, TimeSeriesBuilder, type ToDataPointsSpec, type TooltipOptions, type TooltipSample, VERSION, type XAxisConfig, type YAxisConfig, attachTooltip, fillBetweenThresholds, mergeOptions, mount, parseAggregated, parseDataPoint, parseSeries, toDataPoints, toSeries };
866
+ export { AggregatedPoint, AggregatedSeries, Annotation, AnnotationBandBuilder, AnnotationBandConfig, AnnotationBandItem, AnnotationBandItemBuilder, AnnotationBuilder, AnnotationPointShape, AnySeries, AxesConfig, DataPoint, DrawCommand, type FieldAccessor, type FillBetweenThresholdsInput, FillSpec, Gap, GapsConfig, GraphBuilder, HatchVariant, Highlight, HighlightBuilder, LabelAnchor, LegendItem, LegendOptions, LegendOrientation, LegendPosition, type LimitStatsPoint, LineDashStyle, LineVariant, MLTimeGraph, MLTimeGraphOptions, Margin, Marker, MarkerBuilder, MarkerLineStyle, type MktPoint, type OptionsLayer, PointStyleType, RangeLabelPosition, SVGRenderer, SeriesStyle, SmoothingType, type StatsAggregatedPoint, type StdDevPoint, TextBaseline, Threshold, ThresholdBuilder, ThresholdFill, ThresholdLabelPosition, type TimeInput, TimeSeries, TimeSeriesBuilder, type ToDataPointsSpec, type TooltipOptions, type TooltipSample, VERSION, XAxisConfig, YAxisConfig, attachTooltip, fillBetweenThresholds, mergeOptions, mount, parseAggregated, parseDataPoint, parseSeries, toDataPoints, toSeries };