ml-time-graph 1.15.0 → 1.17.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,7 +1,7 @@
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-C5rNViFi.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-C5rNViFi.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-CDPJGYpZ.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-CDPJGYpZ.js';
1
+ import { M as MLTimeGraphOptions, L as LegendItem, R as Renderer, a as LayoutResult, b as Margin, Y as YAxisConfig, A as AxesConfig, X as XAxisConfig, c as LegendOptions, d as LegendPosition, e as LegendOrientation, f as Marker, g as RenderOutput } from './marker_renderer-BsiVseet.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-BsiVseet.js';
3
+ import { e as AnySeries, i as Annotation, a as DrawCommand, T as TimeScale, L as LinearScale, g as Gap, h as GapsConfig, f as Threshold, H as Highlight, j as AnnotationBandConfig, l as SeriesStyle, c as LineVariant, S as SmoothingType, F as FillSpec, m as TimeSeries, b as LineDashStyle, n as ThresholdFill, k 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 './types-DdltSMkw.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 FillWhere, O as GapConfig, Q as GapLabel, U as GapRegion, V as GapStyle, W as GapsAtEnd, G as GridLayer, X as LineShape, Y as LineStyle, Z as MarkerStyle, _ as MovingAverageType, $ as SVGLineStyle, a0 as SensorType, a1 as SeriesGaps, a2 as SeriesOverlay, a3 as SeriesOverlayKind, a4 as SeriesType, a5 as ShadowStyle, a6 as SolidDashStyle, a7 as ThresholdLabelConfig, a8 as getLineStyle, a9 as resolveDash } from './types-DdltSMkw.js';
5
5
 
6
6
  /*!
7
7
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
@@ -95,6 +95,7 @@ interface PointsAtOptions {
95
95
 
96
96
  declare class MLTimeGraph {
97
97
  private readonly _layout;
98
+ private readonly _idPraefix?;
98
99
  private readonly _renderer?;
99
100
  private readonly _locale?;
100
101
  private readonly _timeZone?;
@@ -106,6 +107,8 @@ declare class MLTimeGraph {
106
107
  * misst, und die Zusage "dasselbe JSON, dasselbe Bild" faellt.
107
108
  */
108
109
  private readonly _textMetrics;
110
+ /** Das eigene Schema dieses Diagramms (Option `theme`), ueber dem globalen. */
111
+ private readonly _theme?;
109
112
  /** Was die Overlays beim letzten renderCommands berechnet haben, je Reihe. */
110
113
  private readonly _overlayWerte;
111
114
  /** Serien auf die Zeichenflaeche beschneiden (Vorgabe: ja) — siehe options.ts. */
@@ -117,6 +120,7 @@ declare class MLTimeGraph {
117
120
  private readonly _gapsBand?;
118
121
  private readonly _gapsAutoDetect;
119
122
  private readonly _gapsMinGapMs;
123
+ private readonly _gapsAtEnd?;
120
124
  private _annotations;
121
125
  private readonly _annotationBands;
122
126
  private readonly _disabledAnnotations;
@@ -165,8 +169,12 @@ declare class MLTimeGraph {
165
169
  private _layoutMitLegende;
166
170
  /**
167
171
  * Compute the chart's renderer-agnostic draw commands.
172
+ *
173
+ * Mit dem eigenen Schema (Option `theme`), falls gesetzt -- wie alle
174
+ * oeffentlichen Wege, die Schemawerte lesen (legendItems, layout, pointsAt).
168
175
  */
169
176
  renderCommands(): DrawCommand[];
177
+ private _zeichne;
170
178
  /** Build the draw commands for a single series based on its type. */
171
179
  /**
172
180
  * Wie die Linie einer skalaren Reihe gezeichnet wird: ihr Grund-Eintrag,
@@ -180,6 +188,7 @@ declare class MLTimeGraph {
180
188
  private _renderSeries;
181
189
  private _interpolateValue;
182
190
  legendItems(): LegendItem[];
191
+ private _legendeneintraege;
183
192
  /**
184
193
  * Die Farbe einer Reihe ohne eigene Angabe.
185
194
  *
@@ -222,6 +231,14 @@ declare class MLTimeGraph {
222
231
  * when they have none) -- `hidden` and `pointsAt` cannot tell them apart.
223
232
  */
224
233
  warnings(): string[];
234
+ /**
235
+ * `where` an einer Flaeche entscheidet an den Messwerten. Ist eine der
236
+ * beiden Kurven mit catmull-rom oder akima geglaettet, kann sie ueber die
237
+ * Messwerte hinausschwingen -- dann trifft die Flaeche die Linie am Rand des
238
+ * Fensters nicht genau. 'monotone' schwingt nicht ueber. Gegenstueck:
239
+ * ueberschwinger in go-time-graph/pkg/chart/warnings.go.
240
+ */
241
+ private _ueberschwinger;
225
242
  /**
226
243
  * The points under the pointer at (x, y), in SVG pixels -- for a tooltip
227
244
  * that gets data instead of HTML. Valid after `renderCommands()`, like
@@ -234,6 +251,7 @@ declare class MLTimeGraph {
234
251
  * area there is nothing. Same rules in the Go port (`PointsAt`).
235
252
  */
236
253
  pointsAt(x: number, y: number, options?: PointsAtOptions): PointAt[];
254
+ private _punkteAm;
237
255
  invertTime(x: number): number;
238
256
  invertValue(y: number, axisIndex?: number): number;
239
257
  project(time: number, value: number, axisIndex?: number): {
@@ -276,20 +294,65 @@ declare function autoMargin(options: MLTimeGraphOptions, opts?: AutoMarginOption
276
294
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
277
295
  */
278
296
 
279
- /** A single sample at the cursor's X position — one per series. */
297
+ /** One series as far as the axis assignment cares. Give `min`/`max`, or `data`. */
298
+ interface AxisGroupInput {
299
+ /** The unit -- series with different units never share an axis. */
300
+ unit: string;
301
+ min?: number;
302
+ max?: number;
303
+ /** Instead of min/max: the readings (nulls are skipped). */
304
+ data?: ReadonlyArray<{
305
+ value?: number | null;
306
+ }>;
307
+ }
308
+ interface AxisGroups {
309
+ /** Per input, in input order: its axis (0 = first axis) -- use as `yAxisIndex`. */
310
+ indices: number[];
311
+ /** One entry per axis, for `axes.y`: the unit as label, first left, the others right. */
312
+ axes: YAxisConfig[];
313
+ }
314
+ /**
315
+ * Suggest which series share a value axis: same unit AND nearby ranges -- a
316
+ * gap larger than the larger range gets its own axis. Input order is kept, so
317
+ * axes do not jump when a series is added; a series without values joins the
318
+ * first axis of its unit. A pure function: nothing is applied to a chart.
319
+ *
320
+ * ```ts
321
+ * const { indices, axes } = axisGroups(series.map((s) => ({ unit: s.unit, data: s.data })));
322
+ * new MLTimeGraph({ series: series.map((s, i) => ({ ...s, yAxisIndex: indices[i] })), axes: { y: axes } });
323
+ * ```
324
+ */
325
+ declare function axisGroups(items: ReadonlyArray<AxisGroupInput>): AxisGroups;
326
+
327
+ /*!
328
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
329
+ * MIT with Attribution: free use incl. commercial requires visible credit to
330
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
331
+ */
332
+
333
+ /**
334
+ * A single sample at the cursor — one per series, found by `chart.pointsAt`:
335
+ * the value the drawn line shows there (a step line holds its last value).
336
+ */
280
337
  interface TooltipSample {
281
338
  /** Index of the series in the chart's `series[]`. */
282
339
  seriesIndex: number;
283
340
  /** The series itself (for `.name`, `.style.line.color`, etc.). */
284
341
  series: AnySeries;
285
- /** Timestamp of the closest sample to the cursor (ms). */
342
+ /** Time of the MEASUREMENT (ms) — for a held value, when it was measured. */
286
343
  time: number;
287
344
  /** Numeric value of the sample. For aggregated series this is the `avg`. */
288
345
  value: number;
289
- /** Pixel X of the sample in the rendered SVG. */
346
+ /** Pixel X of the sample in the rendered SVG (on the line). */
290
347
  x: number;
291
348
  /** Pixel Y of the sample in the rendered SVG. */
292
349
  y: number;
350
+ /** The value was measured before the cursor and is carried forward. */
351
+ held?: boolean;
352
+ /** The value as the axis writes it (enum state, axis `format`). */
353
+ label?: string;
354
+ /** Everything `pointsAt` knows about the hit (colour, overlay, bucket …). */
355
+ point: PointAt;
293
356
  }
294
357
  /** Configuration for the DOM-attached tooltip helper. */
295
358
  interface TooltipOptions {
@@ -301,13 +364,20 @@ interface TooltipOptions {
301
364
  * `innerHTML`. If not given, a sensible default is used (time header
302
365
  * + one row per series with `name: value`).
303
366
  */
304
- format?: (samples: TooltipSample[]) => string;
367
+ format?: (samples: TooltipSample[], cursor: {
368
+ time: number;
369
+ }) => string;
305
370
  /**
306
- * Maximum cursor-to-sample distance in pixels for a sample to count.
307
- * Default: `Infinity` (always snap to the nearest sample of each
308
- * series, regardless of distance).
371
+ * Maximum cursor-to-sample distance in pixels for a sample to count
372
+ * (mode `'nearest'`). Default: `Infinity` (always the nearest sample of
373
+ * each series, regardless of distance).
309
374
  */
310
375
  snapRadius?: number;
376
+ /**
377
+ * Passed on to `chart.pointsAt`: `mode`, `modes`, `maxAgeMs`, `overlays`,
378
+ * `hidden`. A step line holds its value by default.
379
+ */
380
+ points?: Omit<PointsAtOptions, "radius">;
311
381
  /** CSS class for the tooltip `<div>`. Default: `'mlc-tooltip'`. */
312
382
  className?: string;
313
383
  /**
@@ -322,10 +392,15 @@ interface TooltipOptions {
322
392
  }
323
393
  /**
324
394
  * Attach an interactive tooltip to a rendered chart. Listens to mousemove
325
- * on the chart's `<svg>` element, snaps each series to its nearest sample
326
- * at the cursor's X position, and renders the result via the `format`
395
+ * on the chart's `<svg>` element, asks `chart.pointsAt` for the value each
396
+ * series' line shows at the cursor, and renders the result via the `format`
327
397
  * callback into a positioned `<div>`.
328
398
  *
399
+ * Until 1.15.0 this helper searched the nearest sample in time by itself --
400
+ * on a step line that is the wrong value (a door open from minute 10 to 40
401
+ * read "closed" at minute 38). Now it goes through `pointsAt`, the same rules
402
+ * as any own tooltip.
403
+ *
329
404
  * Returns a cleanup function that removes the listeners and the tooltip
330
405
  * element. Idempotent — calling cleanup twice is a no-op.
331
406
  *
@@ -393,6 +468,55 @@ interface MountOptions extends MLTimeGraphOptions {
393
468
  */
394
469
  declare function mount(target: HTMLElement | string, options?: MountOptions): MLTimeGraph;
395
470
 
471
+ /*!
472
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
473
+ * MIT with Attribution: free use incl. commercial requires visible credit to
474
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
475
+ */
476
+ /** Das Noetigste eines SVG-Elements -- ein echtes `SVGSVGElement` passt. */
477
+ interface SvgFuerZeiger {
478
+ getScreenCTM?(): {
479
+ a: number;
480
+ b: number;
481
+ c: number;
482
+ d: number;
483
+ e: number;
484
+ f: number;
485
+ inverse(): {
486
+ a: number;
487
+ b: number;
488
+ c: number;
489
+ d: number;
490
+ e: number;
491
+ f: number;
492
+ };
493
+ } | null;
494
+ getBoundingClientRect(): {
495
+ left: number;
496
+ top: number;
497
+ width: number;
498
+ height: number;
499
+ };
500
+ viewBox?: {
501
+ baseVal: {
502
+ x: number;
503
+ y: number;
504
+ width: number;
505
+ height: number;
506
+ } | null;
507
+ };
508
+ }
509
+ /**
510
+ * The pointer position in the SVG's own coordinates -- the pixels that
511
+ * `pointsAt`, `invertTime` and `plotRect` speak. Correct at any scaling,
512
+ * `viewBox` and CSS transform (via `getScreenCTM()`); without a screen
513
+ * matrix (not laid out yet) it falls back to `viewBox` and the element's box.
514
+ */
515
+ declare function zeigerImSvg(svg: SvgFuerZeiger, clientX: number, clientY: number): {
516
+ x: number;
517
+ y: number;
518
+ };
519
+
396
520
  /*!
397
521
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
398
522
  * MIT with Attribution: free use incl. commercial requires visible credit to
@@ -757,6 +881,13 @@ declare class SVGRenderer extends Renderer {
757
881
  height?: number | string;
758
882
  /** Optional solid background colour, drawn as a full-size rect (e.g. "white"). */
759
883
  background?: string;
884
+ /**
885
+ * Prefix for the ids this renderer writes into `<defs>` (clip paths, hatch
886
+ * patterns, shadows). Pass the chart's `idPrefix` so two charts on one page
887
+ * share no id at all. Identical charts would otherwise both write
888
+ * `clip-plot-<hash>`.
889
+ */
890
+ idPrefix?: string;
760
891
  });
761
892
  /** Set a solid background colour, drawn as a full-size rect behind the chart. */
762
893
  setBackgroundColor(color: string): void;
@@ -1014,6 +1145,6 @@ declare function mergeOptions(...layers: (OptionsLayer | undefined)[]): MLTimeGr
1014
1145
  * Monate spaeter eine Datei aus einem Stapel von Berichten in der Hand haelt,
1015
1146
  * kann sonst nicht feststellen, welcher Stand sie gezeichnet hat.
1016
1147
  */
1017
- declare const VERSION = "1.15.0";
1148
+ declare const VERSION = "1.17.0";
1018
1149
 
1019
- export { AggregatedPoint, AggregatedSeries, Annotation, AnnotationBandBuilder, AnnotationBandConfig, AnnotationBandItem, AnnotationBandItemBuilder, AnnotationBuilder, AnnotationPointShape, AnySeries, type AutoMarginOptions, 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, type PointAt, PointStyleType, type PointsAtOptions, 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, autoMargin, fillBetweenThresholds, mergeOptions, mount, parseAggregated, parseDataPoint, parseSeries, toDataPoints, toSeries };
1150
+ export { AggregatedPoint, AggregatedSeries, Annotation, AnnotationBandBuilder, AnnotationBandConfig, AnnotationBandItem, AnnotationBandItemBuilder, AnnotationBuilder, AnnotationPointShape, AnySeries, type AutoMarginOptions, AxesConfig, type AxisGroupInput, type AxisGroups, 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, type PointAt, PointStyleType, type PointsAtOptions, 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, autoMargin, axisGroups, fillBetweenThresholds, mergeOptions, mount, parseAggregated, parseDataPoint, parseSeries, toDataPoints, toSeries, zeigerImSvg };