ml-time-graph 1.0.0 → 1.0.2

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,6 @@
1
- import { e as LegendOrientation, f as Renderer, M as Marker, d as LegendItem, b as LayoutResult, R as RenderOutput, t as theme } from './layout-Sc5UkC0r.js';
2
- import { V as LineVariant, h as AnySeries, ab as Threshold, Q as Highlight, J as Gap, O as GapsConfig, e as Annotation, f as AnnotationBandConfig, p as DrawCommand, ae as TimeScale, W as LinearScale, P as HatchVariant, H as FillSpec, a as AggregatedSeries, l as DataPoint, ag as TimeSeries } from './scale-Cbr0KpPz.js';
3
- export { A as AggregatedPoint, b as AggregationConfig, c as AggregationMode, g as AnnotationBandItem, m as DataPointRef, E as EnumMap, F as FillBound, y as FillDirectionType, z as FillRegion, G as FillSide, I as FillStyle, K as GapConfig, L as GapLabel, M as GapRegion, N as GapStyle, S as LineDashStyle, U as LineStyle, Y as MarkerStyle, $ as PointStyleType, a3 as SensorType, a4 as SeriesOverlay, a5 as SeriesOverlayKind, a6 as SeriesStyle, a7 as SeriesType, a8 as ShadowStyle, ac as ThresholdLabelConfig, ad as ThresholdLabelPosition } from './scale-Cbr0KpPz.js';
4
- export { L as LimitStatsPoint, M as MktPoint, S as StatsAggregatedPoint, a as StdDevPoint } from './aggregated_subtypes-DZNZyFTX.js';
1
+ import { e as LegendOrientation, f as Renderer, M as Marker, d as LegendItem, b as LayoutResult, R as RenderOutput, t as theme } from './layout-CkEYYdSw.js';
2
+ import { U as LineVariant, g as AnySeries, aa as Threshold, P as Highlight, I as Gap, N as GapsConfig, d as Annotation, e as AnnotationBandConfig, o as DrawCommand, ad as TimeScale, V as LinearScale, A as AggregatedPoint, O as HatchVariant, G as FillSpec, a as AggregatedSeries, k as DataPoint, af as TimeSeries } from './scale-O3OLrmn5.js';
3
+ export { b as AggregationConfig, c as AggregationMode, f as AnnotationBandItem, l as DataPointRef, E as EnumMap, F as FillBound, x as FillDirectionType, y as FillRegion, z as FillSide, H as FillStyle, J as GapConfig, K as GapLabel, L as GapRegion, M as GapStyle, R as LineDashStyle, T as LineStyle, X as MarkerStyle, _ as PointStyleType, a2 as SensorType, a3 as SeriesOverlay, a4 as SeriesOverlayKind, a5 as SeriesStyle, a6 as SeriesType, a7 as ShadowStyle, ab as ThresholdLabelConfig, ac as ThresholdLabelPosition } from './scale-O3OLrmn5.js';
5
4
 
6
5
  /*!
7
6
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
@@ -298,14 +297,16 @@ interface TooltipOptions {
298
297
  * position: absolute;
299
298
  * pointer-events: none;
300
299
  * padding: 6px 10px;
301
- * background: rgba(15, 23, 42, 0.92);
302
- * color: #fff;
300
+ * background: rgba(254, 243, 199, 0.92); / * sticky-note yellow * /
301
+ * color: #1e293b;
302
+ * border: 1px solid rgba(217, 119, 6, 0.35);
303
303
  * border-radius: 4px;
304
304
  * font-size: 12px;
305
305
  * transform: translate(8px, 8px);
306
+ * box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
306
307
  * }
307
- * .mlc-tooltip__time { opacity: 0.7; margin-bottom: 4px; }
308
- * .mlc-tooltip__name { opacity: 0.8; }
308
+ * .mlc-tooltip__time { opacity: 0.7; margin-bottom: 4px; font-weight: 600; }
309
+ * .mlc-tooltip__name { opacity: 0.85; }
309
310
  * ```
310
311
  */
311
312
  declare function attachTooltip(target: HTMLElement, chart: MLTimeGraph, options?: TooltipOptions): () => void;
@@ -353,6 +354,100 @@ interface MountOptions extends MLTimeGraphOptions {
353
354
  */
354
355
  declare function mount(target: HTMLElement | string, options?: MountOptions): MLTimeGraph;
355
356
 
357
+ /*!
358
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
359
+ * MIT with Attribution: free use incl. commercial requires visible credit to
360
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
361
+ */
362
+
363
+ /**
364
+ * Imperative builder for MLTimeGraph. Accumulate config via `setX` /
365
+ * `addX` methods, then materialise via `getSvg()` / `mount()` / `build()`.
366
+ */
367
+ declare class GraphBuilder {
368
+ private _opts;
369
+ private _series;
370
+ private _thresholds;
371
+ private _annotations;
372
+ private _highlights;
373
+ private _markers;
374
+ private _bands;
375
+ private _tooltip?;
376
+ /**
377
+ * @param width Chart width in px. Pass `0` to auto-detect from the
378
+ * target's `clientWidth` in {@link mount}.
379
+ * @param height Chart height in px.
380
+ */
381
+ constructor(width: number, height: number);
382
+ /** Override the chart's pixel dimensions after construction. */
383
+ setSize(width: number, height: number): this;
384
+ /** Override per-side pixel margins. */
385
+ setMargin(margin: Margin): this;
386
+ /** Locale for date/number formatting (e.g. 'de-DE'). */
387
+ setLocale(locale: string): this;
388
+ /** Set the entire axes block (x / left / right). Replaces previous. */
389
+ setAxes(axes: AxesConfig): this;
390
+ /** Patch just the X-axis config; leaves left/right untouched. */
391
+ setXAxis(config: XAxisConfig): this;
392
+ /** Patch just the left Y-axis. */
393
+ setLeftAxis(config: YAxisConfig): this;
394
+ /** Patch just the right Y-axis (`yAxisIndex: 1` series). */
395
+ setRightAxis(config: YAxisConfig): this;
396
+ /** Show / position / orient the integrated legend. */
397
+ setLegend(legend: LegendOptions): this;
398
+ /**
399
+ * Configure data-gap handling. Accepts either the legacy `Gap[]` or the
400
+ * new `GapsConfig` (`{ regions?, autoDetect?, minGapMs?, style? }`).
401
+ */
402
+ setGaps(gaps: Gap[] | GapsConfig): this;
403
+ /**
404
+ * Tooltip config. Only takes effect when {@link mount} is used — pure
405
+ * `getSvg()` output has nothing to hover over. Default `show: true`
406
+ * when called; pass an explicit `show: false` to keep the chart but
407
+ * skip the listener.
408
+ */
409
+ setTooltip(tooltip: TooltipOptions & {
410
+ show?: boolean;
411
+ }): this;
412
+ /** Append one series. */
413
+ addSeries(series: AnySeries): this;
414
+ /** Append multiple series at once. */
415
+ addSeriesAll(series: AnySeries[]): this;
416
+ /** Append one threshold (line + optional fill + label). */
417
+ addThreshold(threshold: Threshold): this;
418
+ /** Append multiple thresholds at once. */
419
+ addThresholds(thresholds: Threshold[]): this;
420
+ /** Append one annotation (line / arrow / rect / point / label). */
421
+ addAnnotation(annotation: Annotation): this;
422
+ /** Append multiple annotations at once. */
423
+ addAnnotations(annotations: Annotation[]): this;
424
+ /** Append one highlight (coloured time range behind the data). */
425
+ addHighlight(highlight: Highlight): this;
426
+ /** Append one marker (vertical pin at a timestamp). */
427
+ addMarker(marker: Marker): this;
428
+ /** Append one annotation band (horizontal strip below the chart). */
429
+ addAnnotationBand(band: AnnotationBandConfig): this;
430
+ /** Wipe a category of added items. Useful for re-building part of a chart. */
431
+ clear(category?: "series" | "thresholds" | "annotations" | "highlights" | "markers" | "bands"): this;
432
+ /** Compose the final MLTimeGraphOptions from current state. */
433
+ toOptions(): MLTimeGraphOptions;
434
+ /** Build the chart instance. Each call returns a fresh MLTimeGraph. */
435
+ build(): MLTimeGraph;
436
+ /**
437
+ * Render the chart and return the full `<svg ...>` string. Suitable for
438
+ * SSR (`fs.writeFileSync(...)`, response body) or for stamping into a
439
+ * DOM element via `el.innerHTML = builder.getSvg()`.
440
+ */
441
+ getSvg(): string;
442
+ /**
443
+ * Build the chart AND inject the SVG into a DOM element. Mirrors what
444
+ * `mount(target, options)` does for the imperative case. Returns the
445
+ * MLTimeGraph instance so the caller can do further work (tooltips,
446
+ * setData, etc.).
447
+ */
448
+ mount(target: HTMLElement | string): MLTimeGraph;
449
+ }
450
+
356
451
  /*!
357
452
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
358
453
  * MIT with Attribution: free use incl. commercial requires visible credit to
@@ -395,6 +490,46 @@ declare class SVGRenderer extends Renderer {
395
490
  _esc(s: string): string;
396
491
  }
397
492
 
493
+ /*!
494
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
495
+ * MIT with Attribution: free use incl. commercial requires visible credit to
496
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
497
+ */
498
+
499
+ /** Slot carrying a rolling Mean Kinetic Temperature value (USP <1079.2>). */
500
+ interface MktPoint extends AggregatedPoint {
501
+ /** Mean kinetic temperature for this slot. `null` = gap. */
502
+ mkt: number | null;
503
+ /** Delta vs the previous slot's MKT (optional). */
504
+ deltaMkt?: number | null;
505
+ }
506
+ /** Slot carrying the standard deviation of the samples in the window. */
507
+ interface StdDevPoint extends AggregatedPoint {
508
+ /** Standard deviation of the samples in this slot. `null` = gap. */
509
+ stdDev: number | null;
510
+ }
511
+ /**
512
+ * Slot carrying minutes-above-/below-limit statistics. At least one of
513
+ * `minutesAboveHigh` or `minutesBelowLow` must be set.
514
+ */
515
+ interface LimitStatsPoint extends AggregatedPoint {
516
+ /** Minutes above the upper limit in this slot. */
517
+ minutesAboveHigh?: number | null;
518
+ /** Minutes below the lower limit in this slot. */
519
+ minutesBelowLow?: number | null;
520
+ }
521
+ /**
522
+ * The "full-stats" aggregated slot — combines all three specialised
523
+ * subtypes via intersection. This is what `aggregateBySlot(data, mode,
524
+ * thresholds)` returns when thresholds are provided: per-slot MKT (USP
525
+ * <1079.2>), standard deviation, and out-of-bounds minute counters.
526
+ *
527
+ * Prefer this typed alias over plain `AggregatedPoint` whenever you
528
+ * downstream-consume `aggregateBySlot`'s output and want guaranteed access
529
+ * to the stat fields.
530
+ */
531
+ type StatsAggregatedPoint = MktPoint & StdDevPoint & LimitStatsPoint;
532
+
398
533
  /*!
399
534
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
400
535
  * MIT with Attribution: free use incl. commercial requires visible credit to
@@ -478,4 +613,4 @@ declare function getDefaultTheme(): Readonly<Theme>;
478
613
  */
479
614
  declare function resetDefaultTheme(): void;
480
615
 
481
- export { AggregatedSeries, Annotation, AnnotationBandConfig, AnySeries, type AxesConfig, type AxisLabelsStyle, type AxisStyle, DataPoint, type FillBetweenThresholdsInput, FillSpec, Gap, GapsConfig, type GridLineStyle, type GridStyle, HatchVariant, Highlight, type LegendOptions, type LegendPosition, MLTimeGraph, type MLTimeGraphOptions, type Margin, Marker, SVGRenderer, type Theme, Threshold, type TickConfig, TimeSeries, type TooltipOptions, type TooltipSample, type XAxisConfig, type YAxisConfig, attachTooltip, fillBetweenThresholds, getDefaultTheme, mount, parseAggregated, parseDataPoint, parseSeries, resetDefaultTheme, setDefaultTheme };
616
+ export { AggregatedPoint, AggregatedSeries, Annotation, AnnotationBandConfig, AnySeries, type AxesConfig, type AxisLabelsStyle, type AxisStyle, DataPoint, type FillBetweenThresholdsInput, FillSpec, Gap, GapsConfig, GraphBuilder, type GridLineStyle, type GridStyle, HatchVariant, Highlight, type LegendOptions, type LegendPosition, type LimitStatsPoint, MLTimeGraph, type MLTimeGraphOptions, type Margin, Marker, type MktPoint, SVGRenderer, type StatsAggregatedPoint, type StdDevPoint, type Theme, Threshold, type TickConfig, TimeSeries, type TooltipOptions, type TooltipSample, type XAxisConfig, type YAxisConfig, attachTooltip, fillBetweenThresholds, getDefaultTheme, mount, parseAggregated, parseDataPoint, parseSeries, resetDefaultTheme, setDefaultTheme };