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.
@@ -0,0 +1,734 @@
1
+ import { a as DrawCommand, b as LineVariant, P as PointStyleType, c as DrawGroup, M as MarkerLineStyle, G as GridLayer, A as AxisPosition, d as AnySeries, e as Threshold, H as Highlight, f as Gap, g as GapsConfig, h as Annotation, i as AnnotationBandConfig, T as TimeScale, L as LinearScale, S as SmoothingType, j as HatchVariant, D as DataPoint } from './scale-DQ-IdB6t.js';
2
+
3
+ /** Output format type for the renderer (SVG string, Canvas, or nothing). */
4
+ type RenderType = "svg" | "canvas" | "none";
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
+ /** Renderer-Output */
13
+ interface RenderOutput {
14
+ type: RenderType;
15
+ content: string;
16
+ }
17
+
18
+ /*!
19
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
20
+ * MIT with Attribution: free use incl. commercial requires visible credit to
21
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
22
+ */
23
+
24
+ /**
25
+ * Abstract renderer — the chart logic never knows rendering details. It emits
26
+ * `DrawCommand[]`, a renderer turns those into output.
27
+ *
28
+ * The shipped {@link SVGRenderer} produces a DOM-free SVG string (works in the
29
+ * browser and on the server). For DOM-specific behaviour, extend SVGRenderer.
30
+ */
31
+ declare abstract class Renderer {
32
+ abstract render(commands: DrawCommand[]): RenderOutput;
33
+ }
34
+
35
+ /*!
36
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
37
+ * MIT with Attribution: free use incl. commercial requires visible credit to
38
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
39
+ */
40
+ /**
41
+ * Central defaults for the entire library.
42
+ * Override individual values or mutate `theme` to restyle the chart globally.
43
+ */
44
+ declare const theme: {
45
+ /**
46
+ * Schriftstapel fuer jeden Text im Diagramm.
47
+ *
48
+ * Metrikkompatibel gewaehlt, nicht nach Aussehen: Liberation Sans hat
49
+ * dieselben Vorschubbreiten wie Arial. Linux landet auf Liberation, Windows
50
+ * und macOS auf Arial bzw. Helvetica -- die Beschriftungen brauchen ueberall
51
+ * denselben Platz. DejaVu Sans waere deutlich breiter.
52
+ */
53
+ readonly fontFamily: "Liberation Sans, Arial, Helvetica, sans-serif";
54
+ /** Default stroke color for series lines */
55
+ readonly stroke: "#4285f4";
56
+ /** Default line width in pixels */
57
+ readonly strokeWidth: 2;
58
+ /** Default point marker size (radius / half-width) */
59
+ readonly pointSize: 4;
60
+ /** Max data points before point markers are suppressed */
61
+ readonly pointThreshold: 100;
62
+ /** Default max time gap (ms) before the line breaks; 0 = off */
63
+ readonly gapThreshold: 0;
64
+ /** Default series type */
65
+ readonly fill: "none";
66
+ readonly hatch: null;
67
+ /** Default band fill color */
68
+ readonly bandFill: "#4285f4";
69
+ /** Default band opacity (when countOpacity is disabled) */
70
+ readonly bandOpacity: 0.6;
71
+ /** Default avg line color for bands */
72
+ readonly bandAvgLine: "#e53e3e";
73
+ /** Default min color for minmaxavg series */
74
+ readonly minColor: "#3b82f6";
75
+ /** Default max color for minmaxavg series */
76
+ readonly maxColor: "#ef4444";
77
+ /** Default avg color for minmaxavg series */
78
+ readonly avgColor: "#64748b";
79
+ /** Area fill alpha suffix (hex) for zoned areas — default 20% opacity */
80
+ readonly areaFillAlpha: "4285f433";
81
+ /** Default axis baseline color */
82
+ readonly axisColor: "#ccc";
83
+ /** Default tick mark color */
84
+ readonly tickColor: "#ddd";
85
+ /** Default axis label text color */
86
+ readonly textColor: "#777";
87
+ /** Default axis text size (axis labels, tick labels) */
88
+ readonly textSize: 11;
89
+ /** Axis label (rotated title next to axis) fill color */
90
+ readonly axisLabelColor: "#444";
91
+ /** Axis label font size */
92
+ readonly axisLabelSize: 12;
93
+ /** Default grid line stroke */
94
+ readonly gridStroke: "#e2e8f0";
95
+ /** Default grid line stroke width */
96
+ readonly gridStrokeWidth: 1;
97
+ /** Default grid opacity */
98
+ readonly gridOpacity: 1;
99
+ /** Legend swatch stroke */
100
+ readonly legendStroke: "#ccc";
101
+ /** Legend text fill */
102
+ readonly legendText: "#333";
103
+ /** Legend font size */
104
+ readonly legendFont: 11;
105
+ /** Default annotation color */
106
+ readonly annotationColor: "#334155";
107
+ /** Default annotation line width */
108
+ readonly annotationWidth: 1.5;
109
+ /** Default annotation arrow head size */
110
+ readonly annotationHead: 9;
111
+ /** Default annotation point radius */
112
+ readonly annotationRadius: 4;
113
+ /** Default annotation text font size */
114
+ readonly annotationFontSize: 11;
115
+ /**
116
+ * Schriftgroesse der Marker-Beschriftung.
117
+ *
118
+ * Stand bis 1.10.0 als feste 11 im Renderer -- wer das Theme umstellte,
119
+ * bekam ueberall groessere Schrift, nur an den Markern nicht.
120
+ */
121
+ readonly markerFontSize: 11;
122
+ /**
123
+ * Schriftgroesse der Beschriftungen an statistischen Overlays
124
+ * (Mittelwert, MKT, Grenzlinien). Stand bis 1.10.0 als feste 10 im Renderer.
125
+ */
126
+ readonly statFontSize: 10;
127
+ /** Schriftgroessen im eingebauten Tooltip: Zeit und Wert. */
128
+ readonly tooltipTimeFontSize: 10;
129
+ readonly tooltipValueFontSize: 11;
130
+ /** Default threshold line color */
131
+ readonly thresholdColor: "#666";
132
+ /** Default threshold line style */
133
+ readonly thresholdLine: "dashed";
134
+ /** Default threshold fill opacity */
135
+ readonly thresholdFillOpacity: 0.12;
136
+ /** Default threshold label font size */
137
+ readonly thresholdFontSize: 10;
138
+ /** Default highlight fill color */
139
+ readonly highlightColor: "#fbbf24";
140
+ /** Default highlight box opacity */
141
+ readonly highlightOpacity: 0.2;
142
+ /** Default highlight label text color */
143
+ readonly highlightLabelColor: "#92400e";
144
+ /** Default marker color */
145
+ readonly markerColor: "#f59e0b";
146
+ /** Default marker point size (cross / circle radius) */
147
+ readonly markerSize: 5;
148
+ /** Gap region background fill */
149
+ readonly gapFill: "#fff";
150
+ /** Gap border stroke */
151
+ readonly gapStroke: "#ccc";
152
+ /** Gap border stroke width */
153
+ readonly gapStrokeWidth: 1;
154
+ /** Gap label text color */
155
+ readonly gapFontColor: "#999";
156
+ /** Gap label font size */
157
+ readonly gapFontSize: 10;
158
+ readonly gapFillOpacity: 0.15;
159
+ /** Tooltip box background */
160
+ readonly tooltipBg: "#fff";
161
+ /** Tooltip border */
162
+ readonly tooltipBorder: "#cbd5e1";
163
+ /** Tooltip text color */
164
+ readonly tooltipText: "#1e293b";
165
+ /** Tooltip value label color */
166
+ readonly tooltipValue: "#3b82f6";
167
+ /** Tooltip crosshair stroke */
168
+ readonly tooltipCrosshair: "#94a3b8";
169
+ /** Tooltip snap radius in pixels */
170
+ readonly tooltipSnapRadius: 20;
171
+ /** Stats overlay line color */
172
+ readonly statsLineColor: "#94a3b8";
173
+ /** Stats label color */
174
+ readonly statsLabelColor: "#64748b";
175
+ /** Minimap overview line stroke */
176
+ readonly minimapStroke: "#94a3b8";
177
+ /** Minimap background */
178
+ readonly minimapBg: "#f8f9fa";
179
+ /** Minimap brush (viewport) fill */
180
+ readonly minimapBrush: "#3b82f644";
181
+ /** Default colour palette for enum categories and multi-series. */
182
+ readonly palette: readonly ["#4285f4", "#ea4335", "#22c55e", "#fbbc05", "#9334ea", "#12b5e5", "#fb923c", "#6366f1"];
183
+ };
184
+
185
+ /*!
186
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
187
+ * MIT with Attribution: free use incl. commercial requires visible credit to
188
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
189
+ */
190
+
191
+ /** The Theme type — same shape as the immutable BUILTIN_DEFAULTS object. */
192
+ type Theme = typeof theme;
193
+ /**
194
+ * Apply a partial override on top of the current global default theme.
195
+ * Merged shallowly — nested objects (e.g. {@link Theme.palette}) are replaced
196
+ * wholesale, not deep-merged.
197
+ *
198
+ * @example
199
+ * setDefaultTheme({ stroke: '#0f172a', gridStroke: '#f1f5f9' });
200
+ * new MLTimeGraph({ ... }); // picks up the new defaults
201
+ */
202
+ declare function setDefaultTheme(partial: Partial<Theme>): void;
203
+ /**
204
+ * Read the current global default theme (a snapshot — mutating the result
205
+ * does NOT affect future reads).
206
+ */
207
+ declare function getDefaultTheme(): Readonly<Theme>;
208
+ /**
209
+ * Restore the global default theme to the library's built-in values
210
+ * (`BUILTIN_DEFAULTS` from {@link ./defaults.ts}). Useful in test
211
+ * `afterEach` hooks and when you want to undo a previous `setDefaultTheme`.
212
+ */
213
+ declare function resetDefaultTheme(): void;
214
+
215
+ /**
216
+ * Misst die Breite eines Textes in Pixeln.
217
+ *
218
+ * Die Bibliothek misst nicht selbst -- sie rendert DOM-frei, und ein Aufruf
219
+ * beim Benutzer haette das BILD davon abhaengig gemacht, WER misst: Canvas
220
+ * `measureText` im Browser und freetype im Go-Port stimmen nicht aufs Pixel
221
+ * ueberein, und die Zusage lautet, dass dasselbe JSON dasselbe Bild ergibt.
222
+ *
223
+ * Deshalb liegt die Vorgabe BEI (`liberationMetrics`), und der Callback ist die
224
+ * Ausnahme fuer den, der sie bewusst verlaesst.
225
+ */
226
+ type TextMetrics = (text: string, fontSize: number) => number;
227
+ /**
228
+ * Die mitgelieferte Metrik: Vorschubbreiten von Liberation Sans.
229
+ *
230
+ * Gilt fuer den ganzen Vorgabe-Stapel `Liberation Sans, Arial, Helvetica` --
231
+ * die drei sind metrikkompatibel, deshalb wurde er so gewaehlt (1.9.0). Die
232
+ * Tabelle stimmt also auch dort, wo Liberation Sans nicht installiert ist.
233
+ *
234
+ * Was sie nicht kennt (Griechisch, Kyrillisch, CJK), bekommt 0,6 em -- die
235
+ * Schaetzung, die bis 1.10.0 fuer alles galt.
236
+ */
237
+ declare const liberationMetrics: TextMetrics;
238
+ /**
239
+ * Die alte Schaetzung: 0,6 em je Zeichen.
240
+ *
241
+ * Steht hier, weil sie zwei Zwecke hat -- der Rueckfall fuer unbekannte
242
+ * Zeichen rechnet damit, und wer die Bilder von vor 1.10.0 reproduzieren muss,
243
+ * reicht sie als `textMetrics` herein. Genau sie war bis zu ±60 % daneben:
244
+ * "i" ist 0,222 em breit, "W" 0,944.
245
+ */
246
+ declare const estimateMetrics: TextMetrics;
247
+
248
+ /*!
249
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
250
+ * MIT with Attribution: free use incl. commercial requires visible credit to
251
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
252
+ */
253
+
254
+ /** Single legend entry with series name and color swatch. */
255
+ interface LegendItem {
256
+ name: string;
257
+ color: string;
258
+ /**
259
+ * The series' line variant, for a caller drawing its own legend: the swatch
260
+ * has to show the same dashes as the curve it names, or it is wrong the moment
261
+ * two series differ by anything but colour — a black-and-white print.
262
+ * Undefined for a series with several lines (no single answer) or none.
263
+ * Turn it into SVG attributes with `getLineStyle()`.
264
+ */
265
+ line?: LineVariant;
266
+ /**
267
+ * The marker shape — but only when markers are actually drawn. A series with
268
+ * `markers.threshold` hides them above that many samples, and a symbol in the
269
+ * legend that is missing from the chart states something untrue.
270
+ * Draw it with `drawMarker()`.
271
+ */
272
+ marker?: Exclude<PointStyleType, "none">;
273
+ }
274
+ /** Layout direction for legend items. */
275
+ type LegendOrientation = "vertical" | "horizontal";
276
+ /** Configuration for legend rendering including items, position, and orientation. */
277
+ interface LegendConfig {
278
+ items: LegendItem[];
279
+ /** Top-left pixel position. */
280
+ x: number;
281
+ y: number;
282
+ /** Stack items vertically (default) or lay them in a row. */
283
+ orientation?: LegendOrientation;
284
+ /** Textbreiten; Vorgabe ist die mitgelieferte Tabelle (Liberation Sans). */
285
+ metrics?: TextMetrics;
286
+ /** Hoechstbreite einer waagerechten Zeile; darueber wird umgebrochen. */
287
+ maxBreite?: number;
288
+ /** Feld hinter der Legende -- Hintergrund und Rahmen. Ohne Angabe keines. */
289
+ box?: LegendBox;
290
+ }
291
+ /** Estimated pixel size of the legend box (for layout reservation). */
292
+ declare function measureLegend(items: LegendItem[], orientation?: LegendOrientation, metrics?: TextMetrics, maxBreite?: number): {
293
+ width: number;
294
+ height: number;
295
+ };
296
+ /** Render a legend (swatch + label per item) as a single group of commands. */
297
+ declare function renderLegend(config: LegendConfig): DrawGroup;
298
+
299
+ /** Vertical marker on the chart: point circle, full-height line, or label at a specific time. */
300
+ interface Marker {
301
+ time: number;
302
+ value?: number;
303
+ label?: string;
304
+ color?: string;
305
+ pointStyle?: PointStyleType;
306
+ lineStyle?: MarkerLineStyle;
307
+ seriesIndex?: number;
308
+ }
309
+
310
+ /*!
311
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
312
+ * MIT with Attribution: free use incl. commercial requires visible credit to
313
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
314
+ */
315
+
316
+ /** Tick density / sizing for one axis. */
317
+ interface TickConfig {
318
+ /** Target number of major (labelled) ticks. */
319
+ major?: number;
320
+ /** How many minor ticks to place between two major ticks. Default 0 = off. */
321
+ minor?: number;
322
+ /** Tick mark length in px. */
323
+ size?: number;
324
+ }
325
+ /** Grid line styling for one tick level. `false` disables that grid level. */
326
+ interface GridLineStyle {
327
+ color?: string;
328
+ width?: number;
329
+ style?: LineVariant;
330
+ opacity?: number;
331
+ }
332
+ /**
333
+ * Per-axis grid configuration. Each tick level (major / minor) can be styled
334
+ * independently or disabled. Defaults: major grid shown with theme colours,
335
+ * minor grid off.
336
+ */
337
+ interface GridStyle {
338
+ major?: GridLineStyle | false;
339
+ /**
340
+ * Zwischengitter -- die Linien zwischen den Hauptlinien.
341
+ *
342
+ * Wieviele es sind, sagt `ticks.minor`; steht dort nichts, ist EINE je
343
+ * Hauptabstand gemeint. Ohne eigene `opacity` sind sie halb so kraeftig wie
344
+ * das Hauptgitter: ein Zwischengitter in voller Staerke macht aus der
345
+ * Orientierung ein zweites Raster.
346
+ *
347
+ * **Eine Angabe gilt fuer beide Richtungen.** Wie beim Hauptgitter gewinnt
348
+ * `axes.x.grid.minor`, sonst `axes.left.grid.minor` -- ein Gitter mit zwei
349
+ * Stilen waere zwei Gitter.
350
+ */
351
+ minor?: GridLineStyle | false;
352
+ /**
353
+ * Wann das Gitter gezeichnet wird.
354
+ *
355
+ * `'front'` (Vorgabe) heisst: NACH den Serien -- eine Flaeche bis zur
356
+ * Grundlinie verdeckt es dann nicht, und die Linien des Gitters liegen
357
+ * sichtbar ueber der Kurve. Marker, Annotationen und Beschriftungen kommen
358
+ * trotzdem darueber.
359
+ *
360
+ * `'back'` zeichnet es als ERSTES, noch vor Highlights und Schwellenwerten.
361
+ * Das ist die Wahl, wenn eine deckende Flaeche das Gitter verschlucken SOLL
362
+ * -- oder wenn ein feines Raster hinter den Daten genuegt.
363
+ *
364
+ * Eine Angabe gilt fuer das ganze Gitter; wie beim Stil gewinnt `axes.x`
365
+ * vor `axes.left`.
366
+ */
367
+ layer?: GridLayer;
368
+ }
369
+ /** Axis baseline + tick marks styling. */
370
+ interface AxisStyle {
371
+ color?: string;
372
+ width?: number;
373
+ }
374
+ /** Tick / axis-label text styling. */
375
+ interface AxisLabelsStyle {
376
+ color?: string;
377
+ fontSize?: number;
378
+ }
379
+ /** Configuration for one Y-axis (left or right). */
380
+ interface YAxisConfig {
381
+ /** Position is 'left' or 'right' to determine placement side. Defaults to 'left'. */
382
+ position?: AxisPosition;
383
+ /** Optional explicit horizontal pixel offset from chart edge (defaults to index * 50px). */
384
+ offset?: number;
385
+ /** Rotated label drawn next to the axis. */
386
+ label?: string;
387
+ /** Override the value domain. `'auto'` lets the chart compute it from data. */
388
+ domain?: [number, number] | "auto";
389
+ /**
390
+ * Extra room above and below the data, **in pixels**. Ignored when `domain`
391
+ * is set explicitly — then you decide the range.
392
+ *
393
+ * The computed domain ends exactly at the smallest and largest reading, and
394
+ * the plot is clipped to its rectangle. A line of width 10 at the maximum
395
+ * therefore loses half its stroke, and a marker half its disc. That is right
396
+ * for the *value* and wrong for the *picture*.
397
+ *
398
+ * Pixels rather than a share of the range: the cause is in pixels
399
+ * (`style.line.width`, `markers.size`), and the same number then works for a
400
+ * series in °C and one in kW. A rule of thumb is half the widest stroke plus
401
+ * a little — `padding: 8` covers a 10 px line and a size-6 marker.
402
+ *
403
+ * ```ts
404
+ * axes: { left: { padding: 8 } }
405
+ * axes: { left: { padding: { top: 24, bottom: 4 } } } // room for a label
406
+ * ```
407
+ */
408
+ padding?: number | {
409
+ top?: number;
410
+ bottom?: number;
411
+ };
412
+ /** Format a tick value into its label text. */
413
+ format?: (value: number) => string;
414
+ /** Tick density / sizing. */
415
+ ticks?: TickConfig;
416
+ /** Per-tick-level grid styling. */
417
+ grid?: GridStyle;
418
+ /** Axis baseline + tick marks styling. */
419
+ axis?: AxisStyle;
420
+ /** Tick label text styling. */
421
+ labels?: AxisLabelsStyle;
422
+ }
423
+ /** Configuration for the X (time) axis. */
424
+ interface XAxisConfig {
425
+ /** Label drawn below the axis. */
426
+ label?: string;
427
+ /** Override the time domain. `'auto'` lets the chart compute it from data. */
428
+ domain?: [number, number] | "auto";
429
+ /** Custom formatter for tick labels (called with a `Date`). */
430
+ format?: (d: Date) => string;
431
+ /** Tick density / sizing. */
432
+ ticks?: TickConfig;
433
+ /** Per-tick-level grid styling. */
434
+ grid?: GridStyle;
435
+ /** Axis baseline + tick marks styling. */
436
+ axis?: AxisStyle;
437
+ /** Tick label text styling. */
438
+ labels?: AxisLabelsStyle;
439
+ }
440
+ /**
441
+ * Top-level axes container on {@link MLTimeGraphOptions}.
442
+ * `left` and `right` correspond to `yAxisIndex: 0` and `yAxisIndex: 1` series.
443
+ * Additional axes can be defined in the `y` array, with indices mapping to series via `yAxisIndex`.
444
+ */
445
+ interface AxesConfig {
446
+ x?: XAxisConfig;
447
+ left?: YAxisConfig;
448
+ right?: YAxisConfig;
449
+ /** Y specifies an arbitrary number of vertical axes, each mapped by its slice index. */
450
+ y?: YAxisConfig[];
451
+ }
452
+
453
+ /*!
454
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
455
+ * MIT with Attribution: free use incl. commercial requires visible credit to
456
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
457
+ */
458
+
459
+ /** Chart margins in pixels. */
460
+ interface Margin {
461
+ top: number;
462
+ right: number;
463
+ bottom: number;
464
+ left: number;
465
+ }
466
+ /** Legend placement position — inside or outside the chart area. */
467
+ type LegendPosition = "inside-right" | "inside-left" | "outside-right" | "outside-left"
468
+ /**
469
+ * Ueber bzw. unter der Zeichenflaeche, waagerecht und ueber mehrere Zeilen
470
+ * umgebrochen. Bis 1.10.0 gab es beides nicht, und zwar aus einem Grund: Ohne
471
+ * echte Textbreiten laesst sich nicht ausrechnen, wieviele Eintraege in eine
472
+ * Zeile passen und wieviel Hoehe zu reservieren ist.
473
+ */
474
+ | "above" | "below" | "separate";
475
+ /**
476
+ * Ein Feld hinter der Legende: Hintergrund und Rahmen.
477
+ *
478
+ * Gedacht fuer `inside-left` / `inside-right`. Dort liegt die Legende ueber den
479
+ * Daten, und ueber einer dichten Kurve oder einer gefuellten Flaeche ist sie
480
+ * schwer zu lesen -- genau dann traegt ein ruhiges Feld darunter.
481
+ *
482
+ * Wie beim Gitter entsteht es nur, wenn eines VERLANGT ist: `box: {}` genuegt
483
+ * und nimmt die Vorgaben.
484
+ */
485
+ interface LegendBox {
486
+ /** Fuellfarbe (Vorgabe `#ffffff`). */
487
+ fill?: string;
488
+ /** Rahmenfarbe (Vorgabe `#cccccc`). `'none'` laesst den Rahmen weg. */
489
+ stroke?: string;
490
+ /** Rahmenstaerke in px (Vorgabe 1). */
491
+ strokeWidth?: number;
492
+ /** Abstand zwischen Feldrand und Eintraegen in px (Vorgabe 6). */
493
+ padding?: number;
494
+ /**
495
+ * Deckkraft des Feldes (Vorgabe 0,85).
496
+ *
497
+ * Nicht 1: unter einer Legende im Bild liegen Daten, und die sollen
498
+ * durchscheinen duerfen. Wer sie ganz verdecken will, setzt 1.
499
+ */
500
+ opacity?: number;
501
+ }
502
+ interface LegendOptions {
503
+ /** Show the legend (default false). */
504
+ show?: boolean;
505
+ /** Placement (default 'inside-right'). 'separate' draws nothing — read chart.legendItems() and render your own. */
506
+ position?: LegendPosition;
507
+ /** Item layout direction (default 'vertical'). */
508
+ orientation?: LegendOrientation;
509
+ /**
510
+ * Hintergrund und Rahmen hinter der Legende. Ohne Angabe gibt es keines --
511
+ * so sah jede Legende vor 1.11.0 aus.
512
+ */
513
+ box?: LegendBox;
514
+ }
515
+ interface MLTimeGraphOptions {
516
+ /**
517
+ * Womit Textbreiten gerechnet werden (Legende, Achsentitel, Raender).
518
+ *
519
+ * Vorgabe ist `liberationMetrics` -- die mitgelieferte Vorschubtabelle des
520
+ * Stapels `Liberation Sans, Arial, Helvetica`. Sie liegt BEI, statt gemessen
521
+ * zu werden: eine Messung im Browser (Canvas `measureText`) und eine im
522
+ * Go-Port stimmen nicht aufs Pixel ueberein, und dann haengt das Bild davon
523
+ * ab, wer es zeichnet.
524
+ *
525
+ * Eigene Schrift? Dann entweder die Tabelle dafuer erzeugen
526
+ * (`node scripts/gen-text-metrics.mjs --font deine.ttf`) oder hier messen --
527
+ * etwa ueber Canvas im Browser. Mit dem zweiten Weg verlaesst du die
528
+ * Paritaet zwischen den beiden Bibliotheken, und zwar bewusst: eine Funktion
529
+ * steht in keinem JSON, der Go-Port kann sie nicht nachbilden.
530
+ */
531
+ textMetrics?: TextMetrics;
532
+ /** Chart dimensions */
533
+ width?: number;
534
+ height?: number;
535
+ /** Margins */
536
+ margin?: Margin;
537
+ /** Renderer (injected) */
538
+ renderer?: Renderer;
539
+ /** Time series data (raw or aggregated min/max/avg) */
540
+ series?: AnySeries[];
541
+ /**
542
+ * Clip series drawing to the plot area (default `true`).
543
+ *
544
+ * It matters only when data lies outside the axis domain — which happens as soon as you
545
+ * fix `axes.x.domain` and hand over a reading from just outside the window, so the curve
546
+ * runs to the edge instead of starting in mid-air. Without clipping, line and markers
547
+ * paint over the axis labels.
548
+ *
549
+ * Turn it off if you deliberately want a series to reach beyond the plot, or if the
550
+ * clip costs you: every clipped group gets a `clip-path`, and a browser may promote each
551
+ * to its own layer. With a handful of series that is nothing; with dozens on a slow
552
+ * machine it can be worth measuring.
553
+ */
554
+ clipSeries?: boolean;
555
+ /** Locale for i18n (e.g. 'de-DE') */
556
+ locale?: string;
557
+ /**
558
+ * IANA time zone for the time axis, e.g. `'Europe/Berlin'` or `'UTC'`.
559
+ *
560
+ * Unset means the machine's zone — the behaviour up to 1.8.1, kept so that
561
+ * nothing changes for callers who never thought about it. But a browser sits
562
+ * in the reader's zone and a server almost always in UTC, so the *same* JSON
563
+ * labelled the same reading with different times depending on where it was
564
+ * drawn. That is the opposite of what a DOM-free renderer is for; set this
565
+ * whenever a chart is produced in one place and read in another.
566
+ *
567
+ * The tick *positions* never depended on it — they are epoch arithmetic. Only
568
+ * the labels do.
569
+ */
570
+ timeZone?: string;
571
+ /**
572
+ * Font for every text in the chart, written into the SVG as `font-family`.
573
+ *
574
+ * Unset means the default stack below. Why name one at all: the SVG says
575
+ * nothing about fonts today, so a viewer picks its own, and the same chart
576
+ * has different label widths in a browser, in an email client and in a
577
+ * rasteriser. Naming a stack removes that variance.
578
+ *
579
+ * The default is chosen for **metric compatibility**, not looks: Liberation
580
+ * Sans was designed with the same advance widths as Arial, so Linux lands on
581
+ * Liberation, Windows and macOS on Arial or Helvetica, and the labels occupy
582
+ * the same space. A stack with DejaVu Sans would not do that — it is
583
+ * noticeably wider, and labels would collide differently.
584
+ *
585
+ * A CSS stack *is* "use it if installed, otherwise ours" — no extra
586
+ * mechanism needed.
587
+ *
588
+ * Note that the library never **measures** text (it renders DOM-free), so
589
+ * this does not change the layout: anchors and `text-anchor` stay where they
590
+ * are. It changes what the viewer draws. A much wider house font will
591
+ * therefore collide differently; that is on you.
592
+ */
593
+ fontFamily?: string;
594
+ /** Integrated legend configuration */
595
+ legend?: LegendOptions;
596
+ /** Markers */
597
+ markers?: Marker[];
598
+ /** Threshold bands / lines / fills drawn behind the series */
599
+ thresholds?: Threshold[];
600
+ /** Highlighted time regions drawn behind the series */
601
+ highlights?: Highlight[];
602
+ /**
603
+ * Data-gap configuration. Two equivalent forms:
604
+ * - `Gap[]` — legacy: array of region objects with flat
605
+ * fill/hatch/labelBaseline/rotate fields.
606
+ * - {@link GapsConfig} — new (preferred): `{ regions?, autoDetect?,
607
+ * minGapMs?, style? }`, where `style` provides
608
+ * per-region fallbacks and `autoDetect` (TODO)
609
+ * will derive gaps from time spacing in
610
+ * Phase 3+. For now: typed but not yet acted on.
611
+ */
612
+ gaps?: Gap[] | GapsConfig;
613
+ /** Free-form overlays (arrow, line, rect, point, label) in data coordinates */
614
+ annotations?: Annotation[];
615
+ /** Horizontal annotation bands below the chart (colored time ranges + labels) */
616
+ annotationBands?: AnnotationBandConfig[];
617
+ /**
618
+ * First-class axes configuration: per-axis `label`, `format`, `ticks`, `grid`,
619
+ * `axis`, `labels` (see USAGE.md, "Axes").
620
+ */
621
+ axes?: AxesConfig;
622
+ }
623
+
624
+ /*!
625
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
626
+ * MIT with Attribution: free use incl. commercial requires visible credit to
627
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
628
+ */
629
+ /** Layout configuration: dimensions, margins, and padding for the chart. */
630
+ interface LayoutConfig {
631
+ /** Total dimensions */
632
+ width: number;
633
+ height: number;
634
+ /** Margins (in pixels) */
635
+ margin: {
636
+ top: number;
637
+ right: number;
638
+ bottom: number;
639
+ left: number;
640
+ };
641
+ }
642
+ /** Computed layout result with chart area dimensions and offsets. */
643
+ interface LayoutResult {
644
+ /** Total width */
645
+ totalWidth: number;
646
+ /** Total height */
647
+ totalHeight: number;
648
+ /** Chart content area width (excluding margins) */
649
+ chartWidth: number;
650
+ /** Chart content area height (excluding margins) */
651
+ chartHeight: number;
652
+ /** Pixel X offset of chart area */
653
+ chartX: number;
654
+ /** Pixel Y offset of chart area */
655
+ chartY: number;
656
+ /** Margins used */
657
+ margin: LayoutConfig["margin"];
658
+ }
659
+ declare class Layout {
660
+ readonly _config: LayoutConfig;
661
+ constructor(config: LayoutConfig);
662
+ /** Calculate layout dimensions */
663
+ compute(): LayoutResult;
664
+ /** Default layout for standard charts */
665
+ static default(width?: number, height?: number): Layout;
666
+ }
667
+
668
+ /*!
669
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
670
+ * MIT with Attribution: free use incl. commercial requires visible credit to
671
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
672
+ */
673
+ /**
674
+ * Turn a free-form name into an ASCII slug usable as an `id`/CSS-class
675
+ * suffix. Lowercased, non-alphanumeric runs collapsed to `-`, accents
676
+ * stripped, trimmed, capped at 50 chars. Empty input → `'unnamed'`.
677
+ *
678
+ * slugify('Temperatur (°C)') → 'temperatur-c'
679
+ * slugify('Signal A') → 'signal-a'
680
+ * slugify(' ') → 'unnamed'
681
+ */
682
+ declare function slugify(s: string | undefined | null): string;
683
+
684
+ /**
685
+ * Flat style configuration for series rendering.
686
+ * All fields are optional — defaults are applied internally via `resolveStyle()`.
687
+ */
688
+ interface SeriesStyle {
689
+ /** Stroke color. */
690
+ stroke?: string;
691
+ /** Stroke width in pixels. */
692
+ strokeWidth?: number;
693
+ /** Enable curve smoothing. */
694
+ smoothing?: boolean;
695
+ /** Which spline when `smoothing` is on. Default `"catmull-rom"`. */
696
+ smoothingType?: SmoothingType;
697
+ /** Enable dashed line style. */
698
+ dashed?: boolean;
699
+ /** Fill colour (hex, rgba, or `url(#gradient-id)`). */
700
+ fill?: string;
701
+ /** Hatch pattern for fill (default: none). */
702
+ hatch?: HatchVariant;
703
+ /** Data-point marker style. */
704
+ pointStyle?: PointStyleType;
705
+ /** Marker size (radius or half-width). */
706
+ pointSize?: number;
707
+ /** Marker outline colour. Default: same as the line's stroke (per-point). */
708
+ pointStroke?: string;
709
+ /** Marker fill colour. Default: same as the line's stroke. */
710
+ pointFill?: string;
711
+ /** Marker outline width. Default: 1.5. */
712
+ pointStrokeWidth?: number;
713
+ /** Shadow color. */
714
+ shadowColor?: string;
715
+ /** Shadow blur in pixels. */
716
+ shadowBlur?: number;
717
+ /** Shadow X offset. */
718
+ shadowOffsetX?: number;
719
+ /** Shadow Y offset. */
720
+ shadowOffsetY?: number;
721
+ /** SVG id prefix for all elements generated by this style. */
722
+ id?: string;
723
+ }
724
+ interface RenderingContext {
725
+ timeScale: TimeScale;
726
+ valueScale: LinearScale;
727
+ }
728
+
729
+ /** Render point markers for segments. */
730
+ declare function renderMarkers(points: DataPoint[], ctx: RenderingContext, style: SeriesStyle, getColor: (p: DataPoint) => string): DrawCommand[];
731
+ declare function drawMarker(// NOSONAR
732
+ commands: DrawCommand[], id: string | undefined, shape: Exclude<PointStyleType, "none">, x: number, y: number, size: number, stroke: string, fill: string, sw: number): void;
733
+
734
+ export { type AxesConfig as A, type GridLineStyle as G, type LegendItem as L, type MLTimeGraphOptions as M, Renderer as R, type SeriesStyle as S, type TextMetrics as T, type XAxisConfig as X, type YAxisConfig as Y, type LayoutResult as a, type Margin as b, type LegendOptions as c, type LegendPosition as d, type LegendOrientation as e, type Marker as f, type RenderOutput as g, type AxisLabelsStyle as h, type AxisStyle as i, type GridStyle as j, type Theme as k, type TickConfig as l, drawMarker as m, estimateMetrics as n, getDefaultTheme as o, liberationMetrics as p, slugify as q, resetDefaultTheme as r, setDefaultTheme as s, type RenderingContext as t, Layout as u, type LayoutConfig as v, type LegendConfig as w, measureLegend as x, renderLegend as y, renderMarkers as z };