ml-time-graph 1.9.0 → 1.10.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/CHANGELOG.md +97 -0
- package/SKILLS.md +84 -3
- package/USAGE.md +14 -0
- package/dist/analyze/index.js +2 -2
- package/dist/index.d.ts +113 -17
- package/dist/index.js +16 -16
- package/dist/interaction/index.d.ts +1 -1
- package/dist/interaction/index.js +1 -1
- package/dist/internals.d.ts +146 -45
- package/dist/internals.js +21 -21
- package/dist/{slug-aDUz3wBN.d.ts → marker_renderer-D6rDW2Pe.d.ts} +71 -85
- package/dist/{scale-CQhADkWB.d.ts → scale-B3MhoTu1.d.ts} +183 -68
- package/package.json +1 -1
package/dist/internals.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { D as DrawCommand,
|
|
4
|
-
export {
|
|
1
|
+
import { d as Theme, i as RenderingContext, S as SeriesStyle, M as Marker, T as TextMetrics } from './marker_renderer-D6rDW2Pe.js';
|
|
2
|
+
export { j as Layout, k as LayoutConfig, b as LayoutResult, m as LegendConfig, a as LegendItem, L as LegendOrientation, R as Renderer, n as measureLegend, o as renderLegend, p as renderSeriesMarkers, h as slugify } from './marker_renderer-D6rDW2Pe.js';
|
|
3
|
+
import { D as DataPoint, a as DrawCommand, t as AggregatedPoint, H as HatchVariant, e as Threshold, L as LinearScale, g as Gap, T as TimeScale, R as RangeLabelPosition, f as Highlight, i as Annotation, z as AxisOrientation, A as AxisPosition, Y as MovingAverageType, a7 as Point, E as EnumMap, a8 as BandScale, S as SmoothingType, P as PointStyleType, J as FillSide, r as AnnotationBandItem, b as LineVariant, V as LineShape, F as FillSpec, U as GapStyle, l as TimeSeries } from './scale-B3MhoTu1.js';
|
|
4
|
+
export { a9 as BandScaleConfig, aa as CircleParams, ab as Dashstyle_t, ac as DomainScaleConfig, ad as DrawCircle, ae as DrawGap, af as DrawGapType_t, c as DrawGroup, ag as DrawLine, ah as DrawPath, ai as DrawRect, aj as DrawText, q as LabelAnchor, ak as LineParams, al as LinearScaleConfig, am as PathParams, an as RectParams, ao as Scale, ap as ScaleConfig, aq as TIME_INTERVALS, ar as TextParams, as as TimeScaleConfig, at as getHatch } from './scale-B3MhoTu1.js';
|
|
5
|
+
import { DataPoint as DataPoint$1 } from './analyze/index.js';
|
|
5
6
|
|
|
6
7
|
/*!
|
|
7
8
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
@@ -11,6 +12,79 @@ export { W as AxisOrientation, X as AxisPosition, Y as BandScaleConfig, Z as Cir
|
|
|
11
12
|
|
|
12
13
|
declare const theme: Theme;
|
|
13
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Render a line series split by a threshold value, allowing different styles
|
|
17
|
+
* for parts above and below that value.
|
|
18
|
+
*/
|
|
19
|
+
declare function renderSplitLine(run: DataPoint[], threshold: number, ctx: RenderingContext, styles: {
|
|
20
|
+
above?: SeriesStyle;
|
|
21
|
+
below?: SeriesStyle;
|
|
22
|
+
}): DrawCommand[];
|
|
23
|
+
|
|
24
|
+
/** Render segments as step-functions. */
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Punktfolge einer Treppe: vor jeden Punkt kommt die Ecke auf seiner X- und
|
|
28
|
+
* der vorigen Y-Hoehe. Steht hier und nicht nur in renderStep, weil
|
|
29
|
+
* MLTimeGraph seine Pfade selbst zusammenbaut und `style.line.shape: "step"`
|
|
30
|
+
* sonst wirkungslos bliebe -- so war es bis hierher.
|
|
31
|
+
*/
|
|
32
|
+
declare function toStepPoints(pts: {
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
}[]): {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
}[];
|
|
39
|
+
/**
|
|
40
|
+
* Dieselbe Treppe, aber im *Daten*raum: vor jeden Punkt kommt ein Punkt auf
|
|
41
|
+
* seiner Zeit und dem vorigen Wert. Erst damit wird die Stufe zu Daten, die
|
|
42
|
+
* jeder weitere Schritt -- Zonenteilung an einer Grenze, Flaeche unter der
|
|
43
|
+
* Kurve -- ohne eigenes Wissen ueber Treppen richtig behandelt.
|
|
44
|
+
*
|
|
45
|
+
* In Pixeln (toStepPoints) war die Stufe dafuer zu spaet: die Flaeche wurde
|
|
46
|
+
* aus den rohen Messwerten gebaut und lief als Rampe unter einer Treppe her,
|
|
47
|
+
* und eine Zonengrenze schnitt den senkrechten Sprung an der interpolierten
|
|
48
|
+
* Zeit statt am Zeitstempel des naechsten Wertes.
|
|
49
|
+
*/
|
|
50
|
+
declare function toStepData(data: DataPoint$1[]): DataPoint$1[];
|
|
51
|
+
|
|
52
|
+
/*!
|
|
53
|
+
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
54
|
+
* MIT with Attribution: free use incl. commercial requires visible credit to
|
|
55
|
+
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/** Render segments as continuous lines (standard or smoothed). */
|
|
59
|
+
declare function renderLine(segments: {
|
|
60
|
+
data: DataPoint[];
|
|
61
|
+
color?: string;
|
|
62
|
+
}[], ctx: RenderingContext, style: SeriesStyle): DrawCommand[];
|
|
63
|
+
declare function renderStep(segments: {
|
|
64
|
+
data: DataPoint[];
|
|
65
|
+
color?: string;
|
|
66
|
+
}[], ctx: RenderingContext, style: SeriesStyle): DrawCommand[];
|
|
67
|
+
/** Render segments as a filled area between two values (e.g. min/max band). */
|
|
68
|
+
declare function renderArea(segments: {
|
|
69
|
+
data: AggregatedPoint[];
|
|
70
|
+
color?: string;
|
|
71
|
+
}[], ctx: RenderingContext, style: SeriesStyle, yLow: (p: AggregatedPoint) => number, yHigh: (p: AggregatedPoint) => number): DrawCommand[];
|
|
72
|
+
/**
|
|
73
|
+
* Complex area renderer that splits a run by value boundaries (thresholds)
|
|
74
|
+
* and renders the resulting zones as separate filled areas.
|
|
75
|
+
*/
|
|
76
|
+
declare function renderZonedArea<T extends {
|
|
77
|
+
time: number;
|
|
78
|
+
}>(run: T[], ctx: RenderingContext, options: {
|
|
79
|
+
boundaries: number[];
|
|
80
|
+
yLow: (p: T) => number;
|
|
81
|
+
yHigh: (p: T) => number;
|
|
82
|
+
getValue: (p: T) => number;
|
|
83
|
+
interpolate: (p1: T, p2: T, t: number) => T;
|
|
84
|
+
getColor: (zoneIndex: number) => string | undefined;
|
|
85
|
+
getHatch?: (zoneIndex: number) => HatchVariant | undefined;
|
|
86
|
+
}, style?: SeriesStyle): DrawCommand[];
|
|
87
|
+
|
|
14
88
|
/*!
|
|
15
89
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
16
90
|
* MIT with Attribution: free use incl. commercial requires visible credit to
|
|
@@ -53,37 +127,6 @@ interface ThresholdRenderConfig {
|
|
|
53
127
|
/** Flat-list variant: lines / fills / labels in one array (legacy callers). */
|
|
54
128
|
declare function renderThresholds(config: ThresholdRenderConfig): DrawCommand[];
|
|
55
129
|
|
|
56
|
-
/*!
|
|
57
|
-
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
58
|
-
* MIT with Attribution: free use incl. commercial requires visible credit to
|
|
59
|
-
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
60
|
-
*/
|
|
61
|
-
/**
|
|
62
|
-
* Wo die Beschriftung eines Zeitbereichs sitzt — Highlight wie Datenluecke.
|
|
63
|
-
*
|
|
64
|
-
* Fuenf Werte, und die Unterscheidung ist der ganze Punkt:
|
|
65
|
-
*
|
|
66
|
-
* - `top` / `center` / `bottom` liegen INNERHALB der Zeichenflaeche. Sie
|
|
67
|
-
* brauchen keinen Rand und koennen die Kurve ueberdecken.
|
|
68
|
-
* - `above` / `below` liegen im Rand DES BILDES — oben ueber der Flaeche,
|
|
69
|
-
* unten unter der Zeitachse. Sie ueberdecken nie Daten, brauchen dafuer
|
|
70
|
-
* aber Platz: `margin.top` bzw. `margin.bottom`.
|
|
71
|
-
*
|
|
72
|
-
* `below` rechnet deshalb von der Gesamthoehe her, nicht von der Unterkante
|
|
73
|
-
* der Zeichenflaeche. Ohne diese Zahl gibt es keinen unteren Rand, in den die
|
|
74
|
-
* Schrift gehoeren koennte, und der Aufrufer bekaeme Text ausserhalb des SVG —
|
|
75
|
-
* sichtbar in keinem Betrachter, aber vorhanden in jeder Datei.
|
|
76
|
-
*
|
|
77
|
-
* `middle` ist der alte Name der Datenluecken fuer `center` und bleibt
|
|
78
|
-
* gueltig: Ein Name, der einmal in einer Datei stand, verschwindet nicht,
|
|
79
|
-
* weil zwei Bauteile sich auf eine gemeinsame Schreibweise einigen.
|
|
80
|
-
*
|
|
81
|
-
* Dieselben Zahlen stehen im Go-Port (pkg/renderer/range_label.go). Laufen sie
|
|
82
|
-
* auseinander, sitzt dieselbe Beschriftung im Browser und auf dem Server
|
|
83
|
-
* verschieden hoch.
|
|
84
|
-
*/
|
|
85
|
-
type RangeLabelPosition = "top" | "center" | "middle" | "bottom" | "above" | "below";
|
|
86
|
-
|
|
87
130
|
/*!
|
|
88
131
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
89
132
|
* MIT with Attribution: free use incl. commercial requires visible credit to
|
|
@@ -195,6 +238,11 @@ interface AnnotationRenderConfig {
|
|
|
195
238
|
timeScale: TimeScale;
|
|
196
239
|
/** Value scales per y-axis index (0 = left, 1 = right). */
|
|
197
240
|
valueScales: Map<number, LinearScale>;
|
|
241
|
+
/**
|
|
242
|
+
* Textbreiten. Nur damit kann eine Beschriftung am Rand ihre Ausrichtung
|
|
243
|
+
* nach innen kippen -- ohne sie bleibt es bei `middle`.
|
|
244
|
+
*/
|
|
245
|
+
metrics?: TextMetrics;
|
|
198
246
|
}
|
|
199
247
|
/**
|
|
200
248
|
* Render free-form annotations (arrow, line, rect, point, label) given in
|
|
@@ -273,6 +321,22 @@ interface TimeAxisConfig {
|
|
|
273
321
|
domain: [number, number];
|
|
274
322
|
/** Optional axis colours */
|
|
275
323
|
colors?: AxisColorspec;
|
|
324
|
+
/**
|
|
325
|
+
* Breite der Leinwand und Textmetrik -- beides zusammen haelt die erste und
|
|
326
|
+
* die letzte Beschriftung IN der Zeichenflaeche.
|
|
327
|
+
*
|
|
328
|
+
* Beide Angaben sind freiwillig: ohne sie bleibt es beim alten Verhalten,
|
|
329
|
+
* die Beschriftung mittig unter ihrem Strich. Mit ihnen ruecken die beiden
|
|
330
|
+
* Randbeschriftungen so weit nach innen, dass sie vollstaendig sichtbar sind.
|
|
331
|
+
*/
|
|
332
|
+
gesamtbreite?: number;
|
|
333
|
+
metrics?: TextMetrics;
|
|
334
|
+
/**
|
|
335
|
+
* Zwischenstriche je Hauptabstand (0 = keine). Ohne Beschriftung und halb so
|
|
336
|
+
* lang; gerechnet wird zwischen den PIXELpositionen der Hauptstriche, nicht
|
|
337
|
+
* im Kalender -- zwischen zwei Monatsstrichen liegt nicht "ein halber Monat".
|
|
338
|
+
*/
|
|
339
|
+
minorTicks?: number;
|
|
276
340
|
}
|
|
277
341
|
/** Tick information for time axis with computed pixel positions and labels. */
|
|
278
342
|
interface TickInfo {
|
|
@@ -303,6 +367,8 @@ declare class TimeAxis {
|
|
|
303
367
|
antiOverlap(ticks: TickInfo[]): TickInfo[];
|
|
304
368
|
/** Render axis baseline + tick marks as draw commands. */
|
|
305
369
|
render(): DrawCommand[];
|
|
370
|
+
/** Positionen der Zwischenstriche in Pixeln. */
|
|
371
|
+
generateMinorTicks(): number[];
|
|
306
372
|
}
|
|
307
373
|
|
|
308
374
|
/*!
|
|
@@ -322,9 +388,9 @@ interface ValueAxisConfig {
|
|
|
322
388
|
/** Pixel X-coordinate where axis is drawn */
|
|
323
389
|
x?: number;
|
|
324
390
|
/** Orientation: vertical (left/right) or horizontal (bottom) */
|
|
325
|
-
orientation?:
|
|
391
|
+
orientation?: AxisOrientation;
|
|
326
392
|
/** Position for vertical orientation */
|
|
327
|
-
position?:
|
|
393
|
+
position?: AxisPosition;
|
|
328
394
|
colors?: AxisColorspec;
|
|
329
395
|
/**
|
|
330
396
|
* Pixel positions (Y for vertical, X for horizontal) where a tick LABEL
|
|
@@ -335,6 +401,32 @@ interface ValueAxisConfig {
|
|
|
335
401
|
suppressLabelsNear?: number[];
|
|
336
402
|
/** Pixel tolerance for `suppressLabelsNear`. Default 8. */
|
|
337
403
|
suppressTolerancePx?: number;
|
|
404
|
+
/**
|
|
405
|
+
* Feste Strichwerte statt der automatischen Schrittweite.
|
|
406
|
+
*
|
|
407
|
+
* Dafuer gibt es einen Fall: eine Reihe mit `enumMap` -- Zustaende wie
|
|
408
|
+
* "Aus"/"An"/"Stoerung". Dort ist nicht die Schrittweite gefragt, sondern
|
|
409
|
+
* GENAU die vorhandenen Zustaende, jeder mit seinem Namen. Ohne das stuenden
|
|
410
|
+
* dort "0, 0.5, 1" und dazwischen Werte, die es nicht gibt.
|
|
411
|
+
*/
|
|
412
|
+
tickValues?: number[];
|
|
413
|
+
/**
|
|
414
|
+
* Zwischenstriche je Hauptabstand (0 = keine). Sie tragen keine
|
|
415
|
+
* Beschriftung und sind halb so lang -- ein Zwischenstrich, der aussieht wie
|
|
416
|
+
* ein Hauptstrich, ist eine Behauptung ueber die Skala, die nicht stimmt.
|
|
417
|
+
*/
|
|
418
|
+
minorTicks?: number;
|
|
419
|
+
/**
|
|
420
|
+
* Breite der Leinwand und Textmetrik -- beides zusammen haelt die
|
|
421
|
+
* Tick-Beschriftungen IN der Zeichenflaeche.
|
|
422
|
+
*
|
|
423
|
+
* Ohne sie bleibt es beim alten Verhalten. Mit ihnen rutscht eine
|
|
424
|
+
* Beschriftung, fuer die der Rand zu schmal bestellt ist, nach innen statt
|
|
425
|
+
* aus dem Bild: dort ueberdeckt sie etwas und ist zu sehen, draussen ist sie
|
|
426
|
+
* weg. Dieselbe Entscheidung wie bei den Schwellwert-Beschriftungen.
|
|
427
|
+
*/
|
|
428
|
+
gesamtbreite?: number;
|
|
429
|
+
metrics?: TextMetrics;
|
|
338
430
|
}
|
|
339
431
|
/** Tick information for value axis with computed positions and formatted labels. */
|
|
340
432
|
interface ValueTickInfo {
|
|
@@ -356,6 +448,8 @@ declare class ValueAxis {
|
|
|
356
448
|
get textSize(): number;
|
|
357
449
|
/** Generate nicely-spaced tick values. */
|
|
358
450
|
generateTicks(): ValueTickInfo[];
|
|
451
|
+
/** Positionen der Zwischenstriche in Pixeln. */
|
|
452
|
+
generateMinorTicks(): number[];
|
|
359
453
|
/** Render axis as draw commands. */
|
|
360
454
|
render(): DrawCommand[];
|
|
361
455
|
}
|
|
@@ -367,7 +461,7 @@ declare class ValueAxis {
|
|
|
367
461
|
*/
|
|
368
462
|
|
|
369
463
|
/** Moving average type */
|
|
370
|
-
type MovingAvgType =
|
|
464
|
+
type MovingAvgType = MovingAverageType;
|
|
371
465
|
interface MovingAvgConfig {
|
|
372
466
|
/** Data points */
|
|
373
467
|
data: DataPoint[];
|
|
@@ -477,8 +571,10 @@ interface LineSeriesConfig {
|
|
|
477
571
|
timeScale: TimeScale;
|
|
478
572
|
/** Value scale for Y-axis mapping */
|
|
479
573
|
valueScale: LinearScale;
|
|
480
|
-
/** Enable curve smoothing
|
|
574
|
+
/** Enable curve smoothing */
|
|
481
575
|
smoothing?: boolean;
|
|
576
|
+
/** Which spline when `smoothing` is on. Default `"catmull-rom"`. */
|
|
577
|
+
smoothingType?: SmoothingType;
|
|
482
578
|
/** Stroke color */
|
|
483
579
|
stroke?: string;
|
|
484
580
|
/** Stroke width in pixels */
|
|
@@ -557,7 +653,7 @@ interface BandSeriesConfig extends BaseConfig {
|
|
|
557
653
|
/** Fill color for the band */
|
|
558
654
|
fill?: string;
|
|
559
655
|
/** Hatch pattern for the band fill */
|
|
560
|
-
hatch?:
|
|
656
|
+
hatch?: HatchVariant;
|
|
561
657
|
/** Opacity based on count (0-1) */
|
|
562
658
|
countOpacity?: boolean;
|
|
563
659
|
/** Show average line inside band */
|
|
@@ -607,8 +703,10 @@ interface MinMaxAvgConfig {
|
|
|
607
703
|
fillToMin?: string;
|
|
608
704
|
/** Hatch pattern for fillToMin */
|
|
609
705
|
fillToMinHatch?: HatchVariant;
|
|
610
|
-
/**
|
|
706
|
+
/** Curve smoothing for the lines */
|
|
611
707
|
smoothing?: boolean;
|
|
708
|
+
/** Which spline when `smoothing` is on. Default `"catmull-rom"`. */
|
|
709
|
+
smoothingType?: SmoothingType;
|
|
612
710
|
/** Stroke width in px (default 2) */
|
|
613
711
|
strokeWidth?: number;
|
|
614
712
|
/** SVG id prefix for elements. Generated ids: `<id>-max`, `<id>-min`, `<id>-avg`, `<id>-fillToMax`, `<id>-fillToMin`. */
|
|
@@ -639,9 +737,9 @@ interface Zone {
|
|
|
639
737
|
/** Fill the area between the line and a threshold value, on one side. */
|
|
640
738
|
interface ZonedFill {
|
|
641
739
|
value: number;
|
|
642
|
-
side:
|
|
740
|
+
side: FillSide;
|
|
643
741
|
color: string;
|
|
644
|
-
hatch?:
|
|
742
|
+
hatch?: HatchVariant;
|
|
645
743
|
}
|
|
646
744
|
/** Configuration for rendering zoned line charts with per-segment colors and optional fills. */
|
|
647
745
|
interface ZonedLineConfig {
|
|
@@ -656,6 +754,8 @@ interface ZonedLineConfig {
|
|
|
656
754
|
fill?: ZonedFill;
|
|
657
755
|
strokeWidth?: number;
|
|
658
756
|
smoothing?: boolean;
|
|
757
|
+
/** Which spline when `smoothing` is on. Default `"catmull-rom"`. */
|
|
758
|
+
smoothingType?: SmoothingType;
|
|
659
759
|
/** Max time gap (ms) before the line breaks; 0 = off. */
|
|
660
760
|
gapThreshold?: number;
|
|
661
761
|
pointStyle?: PointStyleType;
|
|
@@ -856,7 +956,8 @@ interface ResolvedLine {
|
|
|
856
956
|
width: number;
|
|
857
957
|
style: LineVariant;
|
|
858
958
|
smoothing: boolean;
|
|
859
|
-
|
|
959
|
+
smoothingType?: SmoothingType;
|
|
960
|
+
shape: LineShape;
|
|
860
961
|
gapThreshold: number;
|
|
861
962
|
opacity: number;
|
|
862
963
|
}
|
|
@@ -906,4 +1007,4 @@ declare function resolveFill(series: TimeSeries): FillSpec | undefined;
|
|
|
906
1007
|
*/
|
|
907
1008
|
declare function resolveSeriesStyle(series: TimeSeries): ResolvedSeriesStyle;
|
|
908
1009
|
|
|
909
|
-
export { AnnotationBandSeries, type AnnotationRenderConfig, BandScale, BandSeries, type BandSeriesConfig, Clip, type ClipRegion, DrawCommand, EnumAxis, type EnumAxisConfig, EnumFormatter, type EnumFormatterOptions, type EnumTickInfo, Formatters, type GapRenderConfig, type GridConfig, type HighlightRenderConfig, LineSeries, type LineSeriesConfig, LinearScale, type MarkerRenderConfig, type MinMaxAvgConfig, MinMaxAvgSeries, MovingAvg, type MovingAvgConfig, type MovingAvgType, type ResolvedLine, type ResolvedMarker, type ResolvedSeriesStyle, type ResolvedShadow, type StatLabelPosition, StatsOverlay, type StatsOverlayConfig, StepSeries, type StepSeriesConfig, type ThresholdRenderConfig, type TickInfo, TimeAxis, type TimeAxisConfig, type TimeFormatOptions, TimeFormatter, TimeScale, ValueAxis, type ValueAxisConfig, type ValueFormatOptions, ValueFormatter, type ValueTickInfo, type Zone, type ZonedFill, type ZonedLineConfig, ZonedLineSeries, renderAnnotations, renderGaps, renderGrid, renderHighlights, renderMarkers, renderThresholds, resolveFill, resolveGap, resolveLines, resolveMarkers, resolveSeriesStyle, resolveShadow, theme };
|
|
1010
|
+
export { AnnotationBandSeries, type AnnotationRenderConfig, AxisOrientation, AxisPosition, BandScale, BandSeries, type BandSeriesConfig, Clip, type ClipRegion, DrawCommand, EnumAxis, type EnumAxisConfig, EnumFormatter, type EnumFormatterOptions, type EnumTickInfo, Formatters, type GapRenderConfig, type GridConfig, type HighlightRenderConfig, LineSeries, type LineSeriesConfig, LinearScale, type MarkerRenderConfig, type MinMaxAvgConfig, MinMaxAvgSeries, MovingAvg, type MovingAvgConfig, type MovingAvgType, type ResolvedLine, type ResolvedMarker, type ResolvedSeriesStyle, type ResolvedShadow, type StatLabelPosition, StatsOverlay, type StatsOverlayConfig, StepSeries, type StepSeriesConfig, type ThresholdRenderConfig, type TickInfo, TimeAxis, type TimeAxisConfig, type TimeFormatOptions, TimeFormatter, TimeScale, ValueAxis, type ValueAxisConfig, type ValueFormatOptions, ValueFormatter, type ValueTickInfo, type Zone, type ZonedFill, type ZonedLineConfig, ZonedLineSeries, renderAnnotations, renderArea, renderGaps, renderGrid, renderHighlights, renderLine, renderMarkers, renderSplitLine, renderStep, renderThresholds, renderZonedArea, resolveFill, resolveGap, resolveLines, resolveMarkers, resolveSeriesStyle, resolveShadow, theme, toStepData, toStepPoints };
|
package/dist/internals.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
var N=class{};var x=class{static interpolateDataPoint(a,e,t){return {time:a.time+Math.round(t*(e.time-a.time)),value:(a.value??0)+t*((e.value??0)-(a.value??0))}}static interpolateAggregatedPoint(a,e,t){let n=(o,r)=>o!==null&&r!==null?o+t*(r-o):null;return {time:a.time+t*(e.time-a.time),min:n(a.min,e.min),max:n(a.max,e.max),avg:n(a.avg,e.avg),count:Math.round(a.count+t*(e.count-a.count))}}static getRuns(a,e,t=0){let n=[...a].sort((l,i)=>l.time-i.time),o=[],r=[],s=null;for(let l of n){let i=e(l),m=t>0&&s&&l.time-s.time>t;(i||m)&&r.length&&(o.push(r),r=[]),i||r.push(l),s=l;}return r.length&&o.push(r),o}static splitByBoundaries(a,e,t,n){if(a.length===0)return [];if(e.length===0)return [{data:a,zoneIndex:0,zoneLow:Number.NEGATIVE_INFINITY}];let o=[...e].sort((m,u)=>m-u),r=[],s=m=>m<=0?Number.NEGATIVE_INFINITY:o[m-1],l=m=>{let u=0;for(let c=0;c<o.length&&m>=o[c];c++)u=c+1;return u},i=[a[0]];for(let m=1;m<a.length;m++){let u=a[m-1],c=a[m],d=t(u),p=t(c),f;p>d?f=o.filter(y=>y>d&&y<=p):p<d?f=o.filter(y=>y>=p&&y<d).reverse():f=[];let g=d;for(let y of f){let b=(y-d)/(p-d),S=n(u,c,b);i.push(S);let O=l((g+y)/2);r.push({data:i,zoneIndex:O,zoneLow:s(O)}),i=[S],g=y;}(f.length===0||f[f.length-1]!==p)&&i.push(c);}if(i.length>1){let m=t(i[0]),u=t(i[i.length-1]),c=l((m+u)/2);r.push({data:i,zoneIndex:c,zoneLow:s(c)});}return r}static splitByThreshold(a,e,t,n){let o=this.splitByBoundaries(a,[e],t,n),r={above:[],below:[]};for(let s of o)s.zoneIndex===0?r.below.push(s.data):r.above.push(s.data);return r}};var ue=class{static compute(a){let e=a.map(l=>l.value).filter(l=>l!==null).sort((l,i)=>l-i);if(e.length===0)return {min:NaN,max:NaN,avg:NaN,mean:NaN,median:NaN,stdDev:NaN,count:0};let t=e.length,n=e.reduce((l,i)=>l+i,0)/t,o=t%2===1?e[Math.floor(t/2)]:(e[t/2-1]+e[t/2])/2,r=e.reduce((l,i)=>l+Math.pow(i-n,2),0)/t,s=Math.sqrt(r);return {min:e[0],max:e[t-1],avg:n,mean:n,median:o,stdDev:s,count:t}}static computeInRange(a,e,t){let n=a.filter(o=>o.time>=e&&o.time<=t);return this.compute(n)}};var ce={fontFamily:"Liberation Sans, Arial, Helvetica, sans-serif",stroke:"#4285f4",strokeWidth:2,pointSize:4,pointThreshold:100,gapThreshold:0,fill:"none",hatch:null,bandFill:"#4285f4",bandOpacity:.6,bandAvgLine:"#e53e3e",minColor:"#3b82f6",maxColor:"#ef4444",avgColor:"#64748b",areaFillAlpha:"4285f433",axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:11,axisLabelColor:"#444",axisLabelSize:12,gridStroke:"#e2e8f0",gridStrokeWidth:1,gridOpacity:1,legendStroke:"#ccc",legendText:"#333",legendFont:11,annotationColor:"#334155",annotationWidth:1.5,annotationHead:9,annotationRadius:4,annotationFontSize:11,thresholdColor:"#666",thresholdLine:"dashed",thresholdFillOpacity:.12,thresholdFontSize:10,highlightColor:"#fbbf24",highlightOpacity:.2,highlightLabelColor:"#92400e",markerColor:"#f59e0b",markerSize:5,gapFill:"#fff",gapStroke:"#ccc",gapStrokeWidth:1,gapFontColor:"#999",gapFontSize:10,gapFillOpacity:.15,tooltipBg:"#fff",tooltipBorder:"#cbd5e1",tooltipText:"#1e293b",tooltipValue:"#3b82f6",tooltipCrosshair:"#94a3b8",tooltipSnapRadius:20,statsLineColor:"#94a3b8",statsLabelColor:"#64748b",minimapStroke:"#94a3b8",minimapBg:"#f8f9fa",minimapBrush:"#3b82f644",palette:["#4285f4","#ea4335","#22c55e","#fbbc05","#9334ea","#12b5e5","#fb923c","#6366f1"]};var ve={...ce};function C(){return ve}function ke(a){let e=a.trim();if(e.startsWith("#"))return e.length===9?e.slice(0,7):e.length===5?e.slice(0,4):e;if(e.toLowerCase().startsWith("rgba(")){let n=e.slice(5,e.lastIndexOf(")")).split(",");if(n.length===4)return `rgb(${n[0].trim()}, ${n[1].trim()}, ${n[2].trim()})`}return e}function we(a){let e=a.trim().toLowerCase();return e.startsWith("#")?e.length===9||e.length===5:e.startsWith("rgba(")||e.startsWith("hsla(")}function de(a,e="classic-diagonal",t="rgba(200, 220, 255, 0.3)",n,o=2){let r=n??ke(t),s=we(t)?"":' fill-opacity="0.3"';if(e==="none")return `
|
|
2
|
-
<pattern id="${
|
|
1
|
+
var Y=class{};var x=class{static interpolateDataPoint(i,e,t){return {time:i.time+Math.round(t*(e.time-i.time)),value:(i.value??0)+t*((e.value??0)-(i.value??0)),synthetic:true}}static interpolateAggregatedPoint(i,e,t){let n=(r,o)=>r!==null&&o!==null?r+t*(o-r):null;return {time:i.time+t*(e.time-i.time),min:n(i.min,e.min),max:n(i.max,e.max),avg:n(i.avg,e.avg),count:Math.round(i.count+t*(e.count-i.count))}}static getRuns(i,e,t=0){let n=[...i].sort((l,s)=>l.time-s.time),r=[],o=[],a=null;for(let l of n){let s=e(l),m=t>0&&a&&l.time-a.time>t;(s||m)&&o.length&&(r.push(o),o=[]),s||o.push(l),a=l;}return o.length&&r.push(o),r}static splitByBoundaries(i,e,t,n){if(i.length===0)return [];if(e.length===0)return [{data:i,zoneIndex:0,zoneLow:Number.NEGATIVE_INFINITY}];let r=[...e].sort((m,u)=>m-u),o=[],a=m=>m<=0?Number.NEGATIVE_INFINITY:r[m-1],l=m=>{let u=0;for(let c=0;c<r.length&&m>=r[c];c++)u=c+1;return u},s=[i[0]];for(let m=1;m<i.length;m++){let u=i[m-1],c=i[m],h=t(u),f=t(c),p;f>h?p=r.filter(g=>g>h&&g<=f):f<h?p=r.filter(g=>g>=f&&g<h).reverse():p=[];let y=h;for(let g of p){let b=(g-h)/(f-h),S=n(u,c,b);s.push(S);let w=l((y+g)/2);o.push({data:s,zoneIndex:w,zoneLow:a(w)}),s=[S],y=g;}(p.length===0||p[p.length-1]!==f)&&s.push(c);}if(s.length>1||i.length===1){let m=t(s[0]),u=t(s[s.length-1]),c=l((m+u)/2);o.push({data:s,zoneIndex:c,zoneLow:a(c)});}return o}static splitByThreshold(i,e,t,n){let r=this.splitByBoundaries(i,[e],t,n),o={above:[],below:[]};for(let a of r)a.zoneIndex===0?o.below.push(a.data):o.above.push(a.data);return o}};var pe=class{static compute(i){let e=i.map(l=>l.value).filter(l=>l!==null).sort((l,s)=>l-s);if(e.length===0)return {min:NaN,max:NaN,avg:NaN,mean:NaN,median:NaN,stdDev:NaN,count:0};let t=e.length,n=e.reduce((l,s)=>l+s,0)/t,r=t%2===1?e[Math.floor(t/2)]:(e[t/2-1]+e[t/2])/2,o=e.reduce((l,s)=>l+Math.pow(s-n,2),0)/t,a=Math.sqrt(o);return {min:e[0],max:e[t-1],avg:n,mean:n,median:r,stdDev:a,count:t}}static computeInRange(i,e,t){let n=i.filter(r=>r.time>=e&&r.time<=t);return this.compute(n)}};function Z(i){let e=[];for(let t of i)e.length===0?e.push(t):e.push({x:t.x,y:e[e.length-1].y},t);return e}function De(i){let e=[];for(let t of i)e.length>0&&e.push({...t,value:e[e.length-1].value}),e.push(t);return e}function D(i){return {id:i.id,line:{stroke:i.stroke??d.stroke,strokeWidth:i.strokeWidth??d.strokeWidth,smoothing:i.smoothing??false,smoothingType:i.smoothingType,dashed:i.dashed??false},fill:i.fill??d.areaFillAlpha,markers:{type:i.pointStyle??"none",size:i.pointSize??d.pointSize,stroke:i.stroke??d.stroke,fill:"#ffffff"},shadow:{color:i.shadowColor??"transparent",blur:i.shadowBlur??0,offsetX:i.shadowOffsetX??0,offsetY:i.shadowOffsetY??0}}}function _e(i,e,t,n){let r=x.splitByThreshold(i,e,a=>a.value,x.interpolateDataPoint),o=[];return n.below&&o.push(...v(r.below.map(a=>({data:a})),t,n.below)),n.above&&o.push(...v(r.above.map(a=>({data:a})),t,n.above)),o}function v(i,e,t){let n=[],r=D(t);for(let o=0;o<i.length;o++){let a=i[o];a.data.length>=2?n.push({type:"path",cssClass:"series-line",id:t.id?`${t.id}-line-${o}`:void 0,points:a.data.map(l=>({x:e.timeScale.map(l.time),y:e.valueScale.map(l.value)})),stroke:a.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:r.line.smoothing,dashed:r.line.dashed,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur,shadowOffsetX:r.shadow.offsetX,shadowOffsetY:r.shadow.offsetY,fill:"none"}):a.data.length===1&&n.push({type:"circle",id:t.id?`${t.id}-dot-${o}`:void 0,cx:e.timeScale.map(a.data[0].time),cy:e.valueScale.map(a.data[0].value),r:Math.max(r.markers.size,r.line.strokeWidth),fill:a.color??r.line.stroke,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur});}return n}function X(i,e,t){let n=[],r=D(t);for(let o=0;o<i.length;o++){let a=i[o];if(a.data.length<2)continue;let l=Z(a.data.map(s=>({x:e.timeScale.map(s.time),y:e.valueScale.map(s.value)})));n.push({type:"path",cssClass:"series-line",id:t.id?`${t.id}-line-${o}`:void 0,points:l,stroke:a.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:false,fill:"none"});}return n}function $e(i,e,t,n,r){let o=[],a=D(t);for(let l=0;l<i.length;l++){let s=i[l];if(s.data.length<2)continue;let m=s.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(n(c))})),u=s.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(r(c))})).reverse();o.push({type:"path",cssClass:"series-fill",id:t.id?`${t.id}-fill-${l}`:void 0,points:[...m,...u],fill:s.color??a.fill,hatch:t.hatch,stroke:"none"});}return o}function E(i,e,t,n){if(i.length<2)return [];let r=x.splitByBoundaries(i,t.boundaries,t.getValue,t.interpolate),o=[];for(let a=0;a<r.length;a++){let l=r[a];if(l.data.length<2)continue;let s=t.getColor(l.zoneIndex);if(!s)continue;let m=l.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yLow(c))})),u=l.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yHigh(c))})).reverse();o.push({type:"path",cssClass:"series-fill",id:n?.id?`${n.id}-fill-${a}`:void 0,points:[...m,...u],fill:s,hatch:t.getHatch?.(l.zoneIndex),stroke:"none"});}return o}function R(i,e,t,n){let r=D(t);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let a=0;a<i.length;a++){let l=i[a],s=e.timeScale.map(l.time),m=e.valueScale.map(l.value),u=n(l),c=t.pointStroke??u,h=t.pointFill??u,f=t.pointStrokeWidth??1.5,p=t.id?`${t.id}-marker-${a}`:void 0;U(o,p,r.markers.type,s,m,r.markers.size,c,h,f);}return o}function U(i,e,t,n,r,o,a,l,s){let m=u=>e===void 0?void 0:`${e}-${u}`;switch(t){case "circle":i.push({type:"circle",cx:n,cy:r,r:o,fill:l,stroke:a,strokeWidth:s,id:e});break;case "square":i.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:l,stroke:a,strokeWidth:s,id:e});break;case "cross":i.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:a,strokeWidth:s,id:e},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:a,strokeWidth:s,id:m(2)});break;case "diamond":i.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r},{x:n,y:r+o},{x:n-o,y:r}],closed:true,fill:l,stroke:a,strokeWidth:s,id:e});break;case "triangle":i.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r+o},{x:n-o,y:r+o}],closed:true,fill:l,stroke:a,strokeWidth:s,id:e});break;case "star":{let u=[];for(let c=0;c<10;c++){let h=c%2===0?o:o*.5,f=Math.PI/2*3+c*Math.PI/5;u.push({x:n+h*Math.cos(f),y:r+h*Math.sin(f)});}i.push({type:"path",points:u,closed:true,fill:l,stroke:a,strokeWidth:s,id:e});break}case "arrow":i.push({type:"path",points:[{x:n-o,y:r+o},{x:n,y:r-o},{x:n+o,y:r+o}],stroke:a,strokeWidth:s,fill:"none",id:e});break;case "plus":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:a,strokeWidth:s,id:e},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:a,strokeWidth:s,id:m(2)});break;case "triangle-down":i.push({type:"path",points:[{x:n,y:r+o},{x:n+o,y:r-o},{x:n-o,y:r-o}],closed:true,fill:l,stroke:a,strokeWidth:s,id:e});break;case "hexagon":{let u=[];for(let c=0;c<6;c++){let h=c*(Math.PI/3);u.push({x:n+o*Math.cos(h),y:r+o*Math.sin(h)});}i.push({type:"path",points:u,closed:true,fill:l,stroke:a,strokeWidth:s,id:e});break}case "hourglass":i.push({type:"path",points:[{x:n-o,y:r-o},{x:n+o,y:r-o},{x:n-o,y:r+o},{x:n+o,y:r+o}],closed:true,fill:l,stroke:a,strokeWidth:s,id:e});break;case "line-horizontal":i.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:a,strokeWidth:s,id:e});break;default:i.push({type:"circle",cx:n,cy:r,r:o,fill:l,stroke:a,strokeWidth:s,id:e});}}var Pe=[[32,126,"278,278,355,556,556,889,667,191,333,333,389,584,278,333,278,278,556,556,556,556,556,556,556,556,556,556,278,278,584,584,584,556,1015,667,667,722,722,667,611,778,722,278,500,667,556,833,722,778,667,778,722,667,611,722,667,944,667,667,611,278,278,278,469,556,333,556,556,500,556,556,278,556,556,222,222,500,222,833,556,556,556,556,333,500,278,556,500,722,500,500,500,334,260,334,584"],[160,255,"278,333,556,556,556,556,260,556,333,737,370,556,584,333,737,552,400,549,333,333,333,576,537,333,333,333,365,556,834,834,834,611,667,667,667,667,667,667,1000,722,667,667,667,667,278,278,278,278,722,722,778,778,778,778,778,584,778,722,722,722,722,667,667,611,556,556,556,556,556,556,889,500,556,556,556,556,278,278,278,278,556,556,556,556,556,556,556,549,611,556,556,556,556,500,556,500"]],fe=.6,Fe=(()=>{let i=new Map;for(let[e,,t]of Pe){let n=t.split(",");for(let r=0;r<n.length;r++)i.set(e+r,Number(n[r])/1e3);}return i})();function ge(i){return Fe.get(i)??fe}var q=(i,e)=>{let t=0;for(let n of i)t+=ge(n.codePointAt(0)??0);return t*e};var ye={fontFamily:"Liberation Sans, Arial, Helvetica, sans-serif",stroke:"#4285f4",strokeWidth:2,pointSize:4,pointThreshold:100,gapThreshold:0,fill:"none",hatch:null,bandFill:"#4285f4",bandOpacity:.6,bandAvgLine:"#e53e3e",minColor:"#3b82f6",maxColor:"#ef4444",avgColor:"#64748b",areaFillAlpha:"4285f433",axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:11,axisLabelColor:"#444",axisLabelSize:12,gridStroke:"#e2e8f0",gridStrokeWidth:1,gridOpacity:1,legendStroke:"#ccc",legendText:"#333",legendFont:11,annotationColor:"#334155",annotationWidth:1.5,annotationHead:9,annotationRadius:4,annotationFontSize:11,markerFontSize:11,statFontSize:10,tooltipTimeFontSize:10,tooltipValueFontSize:11,thresholdColor:"#666",thresholdLine:"dashed",thresholdFillOpacity:.12,thresholdFontSize:10,highlightColor:"#fbbf24",highlightOpacity:.2,highlightLabelColor:"#92400e",markerColor:"#f59e0b",markerSize:5,gapFill:"#fff",gapStroke:"#ccc",gapStrokeWidth:1,gapFontColor:"#999",gapFontSize:10,gapFillOpacity:.15,tooltipBg:"#fff",tooltipBorder:"#cbd5e1",tooltipText:"#1e293b",tooltipValue:"#3b82f6",tooltipCrosshair:"#94a3b8",tooltipSnapRadius:20,statsLineColor:"#94a3b8",statsLabelColor:"#64748b",minimapStroke:"#94a3b8",minimapBg:"#f8f9fa",minimapBrush:"#3b82f644",palette:["#4285f4","#ea4335","#22c55e","#fbbc05","#9334ea","#12b5e5","#fb923c","#6366f1"]};var Ae={...ye};function M(){return Ae}function Re(i){let e=i.trim();if(e.startsWith("#"))return e.length===9?e.slice(0,7):e.length===5?e.slice(0,4):e;if(e.toLowerCase().startsWith("rgba(")){let n=e.slice(5,e.lastIndexOf(")")).split(",");if(n.length===4)return `rgb(${n[0].trim()}, ${n[1].trim()}, ${n[2].trim()})`}return e}function We(i){let e=i.trim().toLowerCase();return e.startsWith("#")?e.length===9||e.length===5:e.startsWith("rgba(")||e.startsWith("hsla(")}function be(i,e="classic-diagonal",t="rgba(200, 220, 255, 0.3)",n,r=2){let o=n??Re(t),a=We(t)?"":' fill-opacity="0.3"';if(e==="none")return `
|
|
2
|
+
<pattern id="${i}" width="10" height="10" patternUnits="userSpaceOnUse">
|
|
3
3
|
<rect width="10" height="10" fill="${t}" />
|
|
4
4
|
</pattern>
|
|
5
|
-
`.trim();let l=12,
|
|
6
|
-
<line x1="0" y1="0" x2="0" y2="${
|
|
7
|
-
<line x1="0" y1="0" x2="${l}" y2="0" stroke="${
|
|
8
|
-
`;break;case "dots":
|
|
9
|
-
<path d="M 0 ${
|
|
10
|
-
`;break;case "dashed":
|
|
11
|
-
<path d="M 0 0 L ${l/2} ${
|
|
12
|
-
`;break;case "brick":l=20,
|
|
13
|
-
<path d="M 0 ${
|
|
14
|
-
`;break;case "double-stripe":l=16,
|
|
15
|
-
<line x1="0" y1="0" x2="0" y2="${
|
|
16
|
-
<line x1="${l/2}" y1="0" x2="${l/2}" y2="${
|
|
17
|
-
`;break;case "honeycomb":l=18,
|
|
18
|
-
<path d="M 0 0 L ${l/2} 5 L ${l} 0 M 0 16 L ${l/2} 11 L ${l} 16 M 0 16 L 0 32 M ${l/2} 5 L ${l/2} 11 M ${l} 16 L ${l} 32 M 0 32 L ${l/2} 27 L ${l} 32 M ${l/2} 27 L ${l/2} 32" fill="none" stroke="${
|
|
19
|
-
`;break}let c=`<rect width="${l}" height="${
|
|
20
|
-
<pattern id="${
|
|
5
|
+
`.trim();let l=12,s=12,m="rotate(0)",u="";switch(e){case "classic-diagonal":m="rotate(45)",u=`<line x1="0" y1="0" x2="0" y2="${s}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />`;break;case "dense-steep":l=6,s=6,m="rotate(30)",u=`<line x1="0" y1="0" x2="0" y2="${s}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />`;break;case "crosshatch":l=14,s=14,m="rotate(45)",u=`
|
|
6
|
+
<line x1="0" y1="0" x2="0" y2="${s}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />
|
|
7
|
+
<line x1="0" y1="0" x2="${l}" y2="0" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />
|
|
8
|
+
`;break;case "dots":u=`<circle cx="${l/2}" cy="${s/2}" r="${r*1.2}" fill="${o}" />`;break;case "waves":l=16,s=16,u=`
|
|
9
|
+
<path d="M 0 ${s/2} Q ${l/4} 0, ${l/2} ${s/2} T ${l} ${s/2}" fill="none" stroke="${o}" stroke-width="${r}" stroke-linecap="round" />
|
|
10
|
+
`;break;case "dashed":m="rotate(45)",u=`<line x1="0" y1="0" x2="0" y2="${s}" stroke="${o}" stroke-width="${r}" stroke-dasharray="3,3" />`;break;case "herringbone":l=16,s=16,u=`
|
|
11
|
+
<path d="M 0 0 L ${l/2} ${s/2} L 0 ${s} M ${l} 0 L ${l/2} ${s/2} L ${l} ${s}" fill="none" stroke="${o}" stroke-width="${r}" stroke-linejoin="round" stroke-linecap="round" />
|
|
12
|
+
`;break;case "brick":l=20,s=20,u=`
|
|
13
|
+
<path d="M 0 ${s/2} L ${l} ${s/2} M 0 ${s} L ${l} ${s} M ${l/2} 0 L ${l/2} ${s/2} M 0 ${s/2} L 0 ${s}" fill="none" stroke="${o}" stroke-width="${r}" />
|
|
14
|
+
`;break;case "double-stripe":l=16,s=16,m="rotate(45)",u=`
|
|
15
|
+
<line x1="0" y1="0" x2="0" y2="${s}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />
|
|
16
|
+
<line x1="${l/2}" y1="0" x2="${l/2}" y2="${s}" stroke="${o}" stroke-width="${r/2}" stroke-linecap="square" />
|
|
17
|
+
`;break;case "honeycomb":l=18,s=32,u=`
|
|
18
|
+
<path d="M 0 0 L ${l/2} 5 L ${l} 0 M 0 16 L ${l/2} 11 L ${l} 16 M 0 16 L 0 32 M ${l/2} 5 L ${l/2} 11 M ${l} 16 L ${l} 32 M 0 32 L ${l/2} 27 L ${l} 32 M ${l/2} 27 L ${l/2} 32" fill="none" stroke="${o}" stroke-width="${r}" stroke-linejoin="round" stroke-linecap="round" />
|
|
19
|
+
`;break}let c=`<rect width="${l}" height="${s}" fill="${t}"${a} />`;return `
|
|
20
|
+
<pattern id="${i}" width="${l}" height="${s}" patternTransform="${m}" patternUnits="userSpaceOnUse">
|
|
21
21
|
${c}
|
|
22
22
|
${u}
|
|
23
23
|
</pattern>
|
|
24
|
-
`.trim()}var h=new Proxy({},{get:(a,e)=>C()[e],has:(a,e)=>e in C(),ownKeys:()=>Reflect.ownKeys(C()),getOwnPropertyDescriptor:(a,e)=>Reflect.getOwnPropertyDescriptor(C(),e)});function H(a){return {id:a.id,line:{stroke:a.stroke??h.stroke,strokeWidth:a.strokeWidth??h.strokeWidth,smoothing:a.smoothing??false,dashed:a.dashed??false},fill:a.fill??h.areaFillAlpha,markers:{type:a.pointStyle??"none",size:a.pointSize??h.pointSize,stroke:a.stroke??h.stroke,fill:"#ffffff"},shadow:{color:a.shadowColor??"transparent",blur:a.shadowBlur??0,offsetX:a.shadowOffsetX??0,offsetY:a.shadowOffsetY??0}}}function w(a,e,t){let n=[],o=a.reduce((s,l)=>s+l.data.length,0),r=H(t);for(let s=0;s<a.length;s++){let l=a[s];l.data.length>=2?n.push({type:"path",cssClass:"series-line",id:t.id?`${t.id}-line-${s}`:void 0,points:l.data.map(i=>({x:e.timeScale.map(i.time),y:e.valueScale.map(i.value)})),stroke:l.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:r.line.smoothing,dashed:r.line.dashed,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur,shadowOffsetX:r.shadow.offsetX,shadowOffsetY:r.shadow.offsetY,fill:"none"}):l.data.length===1&&o===1&&n.push({type:"circle",cx:e.timeScale.map(l.data[0].time),cy:e.valueScale.map(l.data[0].value),r:Math.max(r.markers.size,r.line.strokeWidth),fill:l.color??r.line.stroke,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur});}return n}function he(a){let e=[];for(let t of a)e.length===0?e.push(t):e.push({x:t.x,y:e[e.length-1].y},t);return e}function Ce(a){let e=[];for(let t of a)e.length>0&&e.push({...t,value:e[e.length-1].value}),e.push(t);return e}function z(a,e,t){let n=[],o=H(t);for(let r=0;r<a.length;r++){let s=a[r];if(s.data.length<2)continue;let l=he(s.data.map(i=>({x:e.timeScale.map(i.time),y:e.valueScale.map(i.value)})));n.push({type:"path",cssClass:"series-line",id:t.id?`${t.id}-line-${r}`:void 0,points:l,stroke:s.color??o.line.stroke,strokeWidth:o.line.strokeWidth,smoothing:false,fill:"none"});}return n}function Te(a,e,t,n,o){let r=[],s=H(t);for(let l=0;l<a.length;l++){let i=a[l];if(i.data.length<2)continue;let m=i.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(n(c))})),u=i.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(o(c))})).reverse();r.push({type:"path",cssClass:"series-fill",id:t.id?`${t.id}-fill-${l}`:void 0,points:[...m,...u],fill:i.color??s.fill,hatch:t.hatch,stroke:"none"});}return r}function B(a,e,t,n){if(a.length<2)return [];let o=x.splitByBoundaries(a,t.boundaries,t.getValue,t.interpolate),r=[];for(let s=0;s<o.length;s++){let l=o[s];if(l.data.length<2)continue;let i=t.getColor(l.zoneIndex);if(!i)continue;let m=l.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yLow(c))})),u=l.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yHigh(c))})).reverse();r.push({type:"path",cssClass:"series-fill",id:n?.id?`${n.id}-fill-${s}`:void 0,points:[...m,...u],fill:i,hatch:t.getHatch?.(l.zoneIndex),stroke:"none"});}return r}function Le(a,e,t,n){let o=x.splitByThreshold(a,e,s=>s.value,x.interpolateDataPoint),r=[];return n.below&&r.push(...w(o.below.map(s=>({data:s})),t,n.below)),n.above&&r.push(...w(o.above.map(s=>({data:s})),t,n.above)),r}function $(a,e,t,n){let o=H(t);if(!o.markers.type||o.markers.type==="none")return [];let r=[];for(let s=0;s<a.length;s++){let l=a[s],i=e.timeScale.map(l.time),m=e.valueScale.map(l.value),u=n(l),c=t.pointStroke??u,d=t.pointFill??u,p=t.pointStrokeWidth??1.5,f=t.id?`${t.id}-marker-${s}`:void 0;G(r,f,o.markers.type,i,m,o.markers.size,c,d,p);}return r}function G(a,e,t,n,o,r,s,l,i){switch(t){case "circle":a.push({type:"circle",cx:n,cy:o,r,fill:l,stroke:s,strokeWidth:i,id:e});break;case "square":a.push({type:"rect",x:n-r,y:o-r,w:r*2,h:r*2,fill:l,stroke:s,strokeWidth:i,id:e});break;case "cross":a.push({type:"line",x1:n-r,y1:o-r,x2:n+r,y2:o+r,stroke:s,strokeWidth:i,id:e},{type:"line",x1:n-r,y1:o+r,x2:n+r,y2:o-r,stroke:s,strokeWidth:i,id:e});break;case "diamond":a.push({type:"path",points:[{x:n,y:o-r},{x:n+r,y:o},{x:n,y:o+r},{x:n-r,y:o}],closed:true,fill:l,stroke:s,strokeWidth:i,id:e});break;case "triangle":a.push({type:"path",points:[{x:n,y:o-r},{x:n+r,y:o+r},{x:n-r,y:o+r}],closed:true,fill:l,stroke:s,strokeWidth:i,id:e});break;case "star":{let m=[];for(let u=0;u<10;u++){let c=u%2===0?r:r*.5,d=Math.PI/2*3+u*Math.PI/5;m.push({x:n+c*Math.cos(d),y:o+c*Math.sin(d)});}a.push({type:"path",points:m,closed:true,fill:l,stroke:s,strokeWidth:i,id:e});break}case "arrow":a.push({type:"path",points:[{x:n-r,y:o+r},{x:n,y:o-r},{x:n+r,y:o+r}],stroke:s,strokeWidth:i,fill:"none",id:e});break;case "plus":a.push({type:"line",x1:n-r,y1:o,x2:n+r,y2:o,stroke:s,strokeWidth:i,id:e},{type:"line",x1:n,y1:o-r,x2:n,y2:o+r,stroke:s,strokeWidth:i,id:e});break;case "triangle-down":a.push({type:"path",points:[{x:n,y:o+r},{x:n+r,y:o-r},{x:n-r,y:o-r}],closed:true,fill:l,stroke:s,strokeWidth:i,id:e});break;case "hexagon":{let m=[];for(let u=0;u<6;u++){let c=u*(Math.PI/3);m.push({x:n+r*Math.cos(c),y:o+r*Math.sin(c)});}a.push({type:"path",points:m,closed:true,fill:l,stroke:s,strokeWidth:i,id:e});break}case "hourglass":a.push({type:"path",points:[{x:n-r,y:o-r},{x:n+r,y:o-r},{x:n-r,y:o+r},{x:n+r,y:o+r}],closed:true,fill:l,stroke:s,strokeWidth:i,id:e});break;case "line-horizontal":a.push({type:"line",x1:n-r,y1:o,x2:n+r,y2:o,stroke:s,strokeWidth:i,id:e});break;default:a.push({type:"circle",cx:n,cy:o,r,fill:l,stroke:s,strokeWidth:i,id:e});}}var T=12,V=8,Z=20,De=11,Y=18,X=a=>[...a].length*De*.6;function Me(a,e="vertical"){if(e==="horizontal"){let n=0;for(let o of a)n+=T+V+X(o.name)+Y;return {width:Math.max(0,n-Y),height:Z}}let t=0;for(let n of a)t=Math.max(t,X(n.name));return {width:T+V+t,height:a.length*Z}}function _e(a){let{items:e,x:t,y:n,orientation:o="vertical"}=a,r=[],s=t;return e.forEach((l,i)=>{let m=o==="horizontal"?s:t,u=o==="horizontal"?n:n+i*Z;r.push({type:"rect",x:m,y:u,w:T,h:T,fill:l.color,stroke:h.legendStroke,strokeWidth:1},{type:"text",content:l.name,x:m+T+V,y:u+T-2,fontSize:h.legendFont,fill:h.legendText}),o==="horizontal"&&(s+=T+V+X(l.name)+Y);}),{type:"group",cssClass:"chart-legend",commands:r}}function $e(a){let{xTicks:e,yTicks:t,xRange:n,yRange:o,stroke:r=h.gridStroke,strokeWidth:s=h.gridStrokeWidth,dashed:l=false,opacity:i=h.gridOpacity}=a,m=[];if(t)for(let u of t)m.push({type:"line",x1:n[0],y1:u,x2:n[1],y2:u,stroke:r,strokeWidth:s,dashed:l,opacity:i});if(e)for(let u of e)m.push({type:"line",x1:u,y1:o[0],x2:u,y2:o[1],stroke:r,strokeWidth:s,dashed:l,opacity:i});return m}var pe=new Map;function Pe(a,e){return `${a}|${JSON.stringify(e??{})}`}function P(a,e){let t=Pe(a,e),n=pe.get(t);return n||(n=new Intl.DateTimeFormat(a,e),pe.set(t,n)),n}var L=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[n,o]=this.#e,[r,s]=this.#t;return o===n?r:r+(t-n)/(o-n)*(s-r)}invert(e){let[t,n]=this.#e,[o,r]=this.#t;return r===o?t:t+(e-o)/(r-o)*(n-t)}domain(){return [...this.#e]}range(){return [...this.#t]}},v=[{label:"second",ms:1e3},{label:"2_seconds",ms:2e3},{label:"5_seconds",ms:5e3},{label:"10_seconds",ms:1e4},{label:"30_seconds",ms:3e4},{label:"minute",ms:6e4},{label:"5_minutes",ms:3e5},{label:"15_minutes",ms:9e5},{label:"30_minutes",ms:18e5},{label:"hour",ms:36e5},{label:"3_hours",ms:108e5},{label:"6_hours",ms:216e5},{label:"day",ms:864e5},{label:"week",ms:6048e5},{label:"month",ms:2592e6},{label:"3_months",ms:7776e6},{label:"6_months",ms:15552e6},{label:"year",ms:31536e6},{label:"2_years",ms:63072e6},{label:"5_years",ms:15768e7}],R=class{#e;#t;#n;constructor(e){this.#e=new L({domain:e.domain,range:e.range}),this.#t=e.locale||(typeof navigator<"u"?navigator.language:"en-US"),this.#n=e.timeZone;}map(e){return this.#e.map(Number(e))}invert(e){return this.#e.invert(e)}domain(){return this.#e.domain()}range(){return this.#e.range()}get timeZone(){return this.#n}get locale(){return this.#t}tickInterval(e,t=3,n=12){let[o,r]=this.#e.domain(),s=r-o;if(s<=0)return {interval:v[0].ms};let l=s/e,i=v[0].ms;for(let c of v)if(c.ms>=l){i=c.ms;break}let m=i,u=Math.round(s/m);for(;u>n&&m<v[v.length-1].ms;){let c=v.findIndex(d=>d.ms===m);m=v[Math.min(c+1,v.length-1)].ms,u=Math.round(s/m);}for(;u<t&&m>v[0].ms;){let c=v.findIndex(d=>d.ms===m);m=v[Math.max(c-1,0)].ms,u=Math.round(s/m);}return {interval:m}}ticks(e){let t=e?.minTicks??5,n=e?.maxTicks??12,{interval:o}=this.tickInterval((t+n)/2,t,n),[r,s]=this.#e.domain(),l=[],i=Math.ceil(r/o)*o;for(let m=i;m<=s;m+=o)l.push(m);return l}format(e,t){let n=this.#n?{...t,timeZone:this.#n}:t;return P(this.#t,n).format(new Date(e))}},F=class{#e;#t;#n;#r;constructor(e){this.#e=[...e.domain],this.#t=[...e.range],this.#n=e.paddingInner??.1,this.#r=e.paddingOuter??.05;}get step(){let[e,t]=this.#t,n=this.#e.length;return n<=1?Math.abs(t-e):Math.abs(t-e)*(1-this.#r*2)/n+Math.abs(t-e)*this.#n*2/n}get bandwidth(){let[e,t]=this.#t,n=this.#e.length;if(n<=1)return Math.abs(t-e)*(1-this.#r*2);let o=this.#r*2*Math.abs(t-e);return (Math.abs(t-e)-o)/n*(1-this.#n)}map(e){let t=this.#e.findIndex(c=>String(c)===String(e));if(t===-1)return this.#t[0];let[n,o]=this.#t,r=this.#e.length;if(r<=1)return (n+o)/2;let s=this.#r*2*Math.abs(o-n),l=Math.abs(o-n)-s,i=o>=n?1:-1,m=l/r;return n+this.#r*Math.abs(o-n)*i+t*m}invert(e){let t=0,n=1/0;for(let o=0;o<this.#e.length;o++){let r=this.map(this.#e[o]),s=Math.abs(e-r);s<n&&(n=s,t=o);}return this.#e[t]}domain(){return this.#e.length===0?["",""]:[this.#e[0],this.#e[this.#e.length-1]]}range(){return [...this.#t]}positions(){let e=new Map;for(let t of this.#e)e.set(t,this.map(t));return e}};function Re(a){return a==="dotted"?{dash:"dotted"}:a==="dashed"?{dash:"dashed"}:{}}function Fe(a){let{thresholds:e,valueScale:t,xRange:n}=a,[o,r]=n,[s,l]=t.range(),i=Math.min(s,l),m=Math.max(s,l),u=[],c=[];for(let d of e){let p=d.color??h.thresholdColor,f=t.map(d.value);d.fill==="above"?u.push({type:"rect",x:o,y:i,w:r-o,h:Math.max(0,f-i),fill:p,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0}):d.fill==="below"&&u.push({type:"rect",x:o,y:f,w:r-o,h:Math.max(0,m-f),fill:p,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0});let g=d.line??h.thresholdLine;if(g!=="none"){let y=Re(g),b={type:"line",x1:o,y1:f,x2:r,y2:f,stroke:p,strokeWidth:1,...y,id:d.id?`${d.id}-line`:void 0};d.shadowColor&&(b.shadowColor=d.shadowColor,b.shadowBlur=d.shadowBlur??4,b.shadowOffsetX=d.shadowOffsetX??0,b.shadowOffsetY=d.shadowOffsetY??2),u.push(b);}if(d.label!==void 0&&d.label!==null&&d.label!==false){let y=typeof d.label=="object"?d.label:void 0,b=typeof d.label=="string"?d.label:y?.text??d.name,S=y?.position??"right";c.push({...We(b,S,o,r,f,p,y),id:d.id?`${d.id}-label`:void 0});}}return {inside:u,labels:c}}function Ae(a){let e=Fe(a);return [...e.inside,...e.labels]}function We(a,e,t,n,o,r,s){let l=(t+n)/2,i={type:"text",content:a,fontSize:h.thresholdFontSize,fill:r},m=s?{...s.rotate!==void 0&&{rotate:s.rotate},...s.textBaseline!==void 0&&{textBaseline:s.textBaseline}}:{};switch(e){case "left":return {...i,...m,x:t+4,y:o-4,anchor:"start"};case "above":return {...i,...m,x:l,y:o-6,anchor:"middle"};case "below":return {...i,...m,x:l,y:o+14,anchor:"middle"};case "center":return {...i,...m,x:l,y:o-4,anchor:"middle"};case "outside-left":return {...i,...m,x:t-6,y:o+3,anchor:"end",textBaseline:m.textBaseline??"middle"};case "outside-right":return {...i,...m,x:n+6,y:o+3,anchor:"start",textBaseline:m.textBaseline??"middle"};default:return {...i,...m,x:n-4,y:o-4,anchor:"end"}}}function fe(a,e,t,n){switch(a){case "above":return e-5;case "below":return n!==void 0?n-5:t+14;case "center":case "middle":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function E(a){let{ranges:e,timeScale:t,yRange:n,height:o}=a,[r,s]=n,l=[];for(let i of e){let m=t.map(i.startTime),u=t.map(i.endTime);if(i.fill!==void 0&&l.push({type:"rect",x:m,y:r,w:u-m,h:s-r,fill:i.fill,hatch:i.hatch,opacity:i.opacity}),i.edges)for(let c of [m,u])l.push({type:"line",x1:c,y1:r,x2:c,y2:s,stroke:i.edges.stroke,strokeWidth:i.edges.strokeWidth,dash:"dashed"});i.label&&l.push({type:"text",content:i.label,x:(m+u)/2,y:fe(i.labelPosition??"middle",r,s,o),anchor:"middle",fontSize:i.fontSize,fill:i.labelColor,rotate:i.rotate});}return l}function je(a){let{gaps:e,timeScale:t,yRange:n,height:o,fill:r=h.gapFill,hatch:s,fillOpacity:l=h.gapFillOpacity??.15,stroke:i=h.gapStroke,strokeWidth:m=h.gapStrokeWidth,dashed:u=true,fontSize:c=h.gapFontSize,fontFill:d=h.gapFontColor,labelBaseline:p="middle",labelRotate:f}=a;return E({timeScale:t,yRange:n,height:o,ranges:e.map(g=>{let y=g.style??"dashed_border",b=y==="filled"||y==="dashed_border",S=y==="dashed_border"&&u!==false;return {startTime:g.startTime,endTime:g.endTime,...b&&{fill:g.fill??r,hatch:g.hatch??s,opacity:g.fillOpacity??l},...S&&{edges:{stroke:i,strokeWidth:m}},label:g.label,labelPosition:g.labelBaseline??p,labelColor:d,fontSize:c,rotate:g.rotate??f}})})}function Oe(a){let{markers:e,timeScale:t,valueScale:n,yRange:o=[0,300]}=a,[r,s]=o,l=[];for(let i of e){let m=t.map(i.time),u=i.color??h.markerColor,c=i.pointStyle??(i.value!==void 0?"circle":"none"),d=i.lineStyle??"full";if(i.value!==void 0){let p=n.map(i.value);if(d==="to-value"?l.push({type:"line",x1:m,y1:s,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="to-top"?l.push({type:"line",x1:m,y1:r,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="full"&&l.push({type:"line",x1:m,y1:r,x2:m,y2:s,stroke:u,strokeWidth:1}),c!=="none"&&G(l,void 0,c,m,p,h.markerSize,u,u,1.5),i.label){let f=d==="to-value"?p-10:r-6;l.push({type:"text",content:i.label,x:m,y:f,anchor:"middle",fontSize:11,fill:u});}}else d!=="none"&&l.push({type:"line",x1:m,y1:r,x2:m,y2:s,stroke:u,strokeWidth:1}),i.label&&l.push({type:"text",content:i.label,x:m,y:r-6,anchor:"middle",fontSize:11,fill:u});}return l}function Ie(a){let{highlights:e,timeScale:t,yRange:n,height:o}=a;return E({timeScale:t,yRange:n,height:o,ranges:e.map(r=>({startTime:r.startTime,endTime:r.endTime,fill:r.color??h.highlightColor,opacity:r.opacity??h.highlightOpacity,label:r.label,labelPosition:r.labelPosition??"top",labelColor:r.color??h.highlightLabelColor,fontSize:h.annotationFontSize,rotate:r.rotate}))})}function U(a){return a&&a.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function He(a){let{annotations:e,timeScale:t,valueScales:n}=a,o=[],r=s=>{let l=n.get(s.axis??0)??n.values().next().value;return {x:t.map(s.time),y:l?l.map(s.value):0}};for(let s of e){let l=[],i=m=>l.push(m);switch(s.type){case "line":{let m=r(s.from),u=r(s.to);i({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:s.color??h.annotationColor,strokeWidth:s.width??h.annotationWidth,dash:s.dash});break}case "arrow":{let m=r(s.from),u=r(s.to),c=s.color??h.annotationColor,d=s.headSize??h.annotationHead;i({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:c,strokeWidth:s.width??h.annotationWidth});let p=Math.hypot(u.x-m.x,u.y-m.y)||1,f=(u.x-m.x)/p,g=(u.y-m.y)/p,y=u.x-f*d,b=u.y-g*d;i({type:"path",points:[{x:u.x,y:u.y},{x:y-g*d*.5,y:b+f*d*.5},{x:y+g*d*.5,y:b-f*d*.5}],fill:c,stroke:"none"});break}case "rect":{let m=r(s.from),u=r(s.to);i({type:"rect",x:Math.min(m.x,u.x),y:Math.min(m.y,u.y),w:Math.abs(u.x-m.x),h:Math.abs(u.y-m.y),fill:s.fill??"none",hatch:s.hatch,stroke:s.stroke,opacity:s.opacity});break}case "point":{let m=r(s.at),u=s.color??"#334155",c=s.radius??h.annotationRadius,d=s.shape??"circle";d==="circle"?i({type:"circle",cx:m.x,cy:m.y,r:c,fill:u}):d==="square"?i({type:"rect",x:m.x-c,y:m.y-c,w:c*2,h:c*2,fill:u}):(i({type:"line",x1:m.x-c,y1:m.y-c,x2:m.x+c,y2:m.y+c,stroke:u,strokeWidth:1.5}),i({type:"line",x1:m.x-c,y1:m.y+c,x2:m.x+c,y2:m.y-c,stroke:u,strokeWidth:1.5}));break}case "label":{let m=r(s.at);i({type:"text",content:s.text,x:m.x+(s.dx??0),y:m.y+(s.dy??0),anchor:s.anchor??"middle",fontSize:h.annotationFontSize,fill:s.color??h.annotationColor,rotate:s.rotate});break}}if(s.id&&l.length>0){let m=U(s.id);o.push({type:"group",cssClass:`annotation annotation--${m}`,commands:l});}else o.push(...l);}return o}var q=class a{_config;constructor(e){this._config=e;}compute(){let{width:e,height:t,margin:n}=this._config;return {totalWidth:e,totalHeight:t,chartWidth:e-n.left-n.right,chartHeight:t-n.top-n.bottom,chartX:n.left,chartY:n.top,margin:n}}static default(e=800,t=400){return new a({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};var K=class{#e;constructor(){this.#e=[];}add(e){this.#e.push(e);}clear(){this.#e=[];}isInside(e,t){return this.#e.length===0?true:this.#e.some(n=>e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height)}toSVGClipPath(e="clip"){if(this.#e.length===0)return "";let t=this.#e.map(n=>`<rect x="${n.x}" y="${n.y}" width="${n.width}" height="${n.height}" />`).join(`
|
|
24
|
+
`.trim()}var d=new Proxy({},{get:(i,e)=>M()[e],has:(i,e)=>e in M(),ownKeys:()=>Reflect.ownKeys(M()),getOwnPropertyDescriptor:(i,e)=>Reflect.getOwnPropertyDescriptor(M(),e)});var L=12,z=8,K=20,je=11,V=18,J=(i,e)=>e(i,je);function xe(i,e,t){let n=l=>L+z+J(l.name,e);if(t===void 0){let l=i.reduce((s,m)=>s+n(m)+V,0)-V;return [{items:i,breite:Math.max(0,l)}]}let r=[],o=[],a=0;for(let l of i){let s=n(l),m=o.length===0?s:a+V+s;o.length>0&&m>t?(r.push({items:o,breite:a}),o=[l],a=s):(o=[...o,l],a=m);}return o.length>0&&r.push({items:o,breite:a}),r}function Ie(i,e="vertical",t=q,n){if(e==="horizontal"){let o=xe(i,t,n);return {width:o.reduce((a,l)=>Math.max(a,l.breite),0),height:o.length*K}}let r=0;for(let o of i)r=Math.max(r,J(o.name,t));return {width:L+z+r,height:i.length*K}}function Oe(i){let{items:e,x:t,y:n,orientation:r="vertical",metrics:o=q,maxBreite:a}=i,l=[],s=r==="horizontal"?xe(e,o,a):e.map(u=>({items:[u],breite:0})),m=new Map;return s.forEach((u,c)=>{let h=t;for(let f of u.items)m.set(f,{x:h,y:n+c*K}),h+=L+z+J(f.name,o)+V;}),e.forEach(u=>{let c=m.get(u)??{x:t,y:n},h=c.x,f=c.y;l.push({type:"rect",x:h,y:f,w:L,h:L,fill:u.color,stroke:d.legendStroke,strokeWidth:1},{type:"text",content:u.name,x:h+L+z,y:f+L-2,fontSize:d.legendFont,fill:d.legendText});}),{type:"group",cssClass:"chart-legend",commands:l}}function He(i){let{xTicks:e,yTicks:t,xRange:n,yRange:r,stroke:o=d.gridStroke,strokeWidth:a=d.gridStrokeWidth,dashed:l=false,opacity:s=d.gridOpacity}=i,m=[];if(t)for(let u of t)m.push({type:"line",x1:n[0],y1:u,x2:n[1],y2:u,stroke:o,strokeWidth:a,dashed:l,opacity:s});if(e)for(let u of e)m.push({type:"line",x1:u,y1:r[0],x2:u,y2:r[1],stroke:o,strokeWidth:a,dashed:l,opacity:s});return m}var Se=new Map;function Be(i,e){return `${i}|${JSON.stringify(e??{})}`}function W(i,e){let t=Be(i,e),n=Se.get(t);return n||(n=new Intl.DateTimeFormat(i,e),Se.set(t,n)),n}var _=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[n,r]=this.#e,[o,a]=this.#t;return r===n?o:o+(t-n)/(r-n)*(a-o)}invert(e){let[t,n]=this.#e,[r,o]=this.#t;return o===r?t:t+(e-r)/(o-r)*(n-t)}domain(){return [...this.#e]}range(){return [...this.#t]}},T=[{label:"second",ms:1e3},{label:"2_seconds",ms:2e3},{label:"5_seconds",ms:5e3},{label:"10_seconds",ms:1e4},{label:"30_seconds",ms:3e4},{label:"minute",ms:6e4},{label:"5_minutes",ms:3e5},{label:"15_minutes",ms:9e5},{label:"30_minutes",ms:18e5},{label:"hour",ms:36e5},{label:"3_hours",ms:108e5},{label:"6_hours",ms:216e5},{label:"day",ms:864e5},{label:"week",ms:6048e5},{label:"month",ms:2592e6},{label:"3_months",ms:7776e6},{label:"6_months",ms:15552e6},{label:"year",ms:31536e6},{label:"2_years",ms:63072e6},{label:"5_years",ms:15768e7}],j=class{#e;#t;#n;constructor(e){this.#e=new _({domain:e.domain,range:e.range}),this.#t=e.locale||(typeof navigator<"u"?navigator.language:"en-US"),this.#n=e.timeZone;}map(e){return this.#e.map(Number(e))}invert(e){return this.#e.invert(e)}domain(){return this.#e.domain()}range(){return this.#e.range()}get timeZone(){return this.#n}get locale(){return this.#t}tickInterval(e,t=3,n=12){let[r,o]=this.#e.domain(),a=o-r;if(a<=0)return {interval:T[0].ms};let l=a/e,s=T[0].ms;for(let c of T)if(c.ms>=l){s=c.ms;break}let m=s,u=Math.round(a/m);for(;u>n&&m<T[T.length-1].ms;){let c=T.findIndex(h=>h.ms===m);m=T[Math.min(c+1,T.length-1)].ms,u=Math.round(a/m);}for(;u<t&&m>T[0].ms;){let c=T.findIndex(h=>h.ms===m);m=T[Math.max(c-1,0)].ms,u=Math.round(a/m);}return {interval:m}}ticks(e){let t=e?.minTicks??5,n=e?.maxTicks??12,{interval:r}=this.tickInterval((t+n)/2,t,n),[o,a]=this.#e.domain(),l=[],s=Math.ceil(o/r)*r;for(let m=s;m<=a;m+=r)l.push(m);return l}format(e,t){let n=this.#n?{...t,timeZone:this.#n}:t;return W(this.#t,n).format(new Date(e))}},I=class{#e;#t;#n;#r;constructor(e){this.#e=[...e.domain],this.#t=[...e.range],this.#n=e.paddingInner??.1,this.#r=e.paddingOuter??.05;}get step(){let[e,t]=this.#t,n=this.#e.length;return n<=1?Math.abs(t-e):Math.abs(t-e)*(1-this.#r*2)/n+Math.abs(t-e)*this.#n*2/n}get bandwidth(){let[e,t]=this.#t,n=this.#e.length;if(n<=1)return Math.abs(t-e)*(1-this.#r*2);let r=this.#r*2*Math.abs(t-e);return (Math.abs(t-e)-r)/n*(1-this.#n)}map(e){let t=this.#e.findIndex(c=>String(c)===String(e));if(t===-1)return this.#t[0];let[n,r]=this.#t,o=this.#e.length;if(o<=1)return (n+r)/2;let a=this.#r*2*Math.abs(r-n),l=Math.abs(r-n)-a,s=r>=n?1:-1,m=l/o;return n+this.#r*Math.abs(r-n)*s+t*m}invert(e){let t=0,n=1/0;for(let r=0;r<this.#e.length;r++){let o=this.map(this.#e[r]),a=Math.abs(e-o);a<n&&(n=a,t=r);}return this.#e[t]}domain(){return this.#e.length===0?["",""]:[this.#e[0],this.#e[this.#e.length-1]]}range(){return [...this.#t]}positions(){let e=new Map;for(let t of this.#e)e.set(t,this.map(t));return e}};function Ee(i){return i==="dotted"?{dash:"dotted"}:i==="dashed"?{dash:"dashed"}:{}}function Ve(i){let{thresholds:e,valueScale:t,xRange:n}=i,[r,o]=n,[a,l]=t.range(),s=Math.min(a,l),m=Math.max(a,l),u=[],c=[];for(let h of e){let f=h.color??d.thresholdColor,p=t.map(h.value);h.fill==="above"?u.push({type:"rect",x:r,y:s,w:o-r,h:Math.max(0,p-s),fill:f,hatch:h.fillHatch,opacity:h.fillOpacity??.12,id:h.id?`${h.id}-fill`:void 0}):h.fill==="below"&&u.push({type:"rect",x:r,y:p,w:o-r,h:Math.max(0,m-p),fill:f,hatch:h.fillHatch,opacity:h.fillOpacity??.12,id:h.id?`${h.id}-fill`:void 0});let y=h.line??d.thresholdLine;if(y!=="none"){let w=Ee(y),k={type:"line",x1:r,y1:p,x2:o,y2:p,stroke:f,strokeWidth:1,...w,id:h.id?`${h.id}-line`:void 0};h.shadowColor&&(k.shadowColor=h.shadowColor,k.shadowBlur=h.shadowBlur??4,k.shadowOffsetX=h.shadowOffsetX??0,k.shadowOffsetY=h.shadowOffsetY??2),u.push(k);}let[g,b]=t.domain();if(h.value>=Math.min(g,b)&&h.value<=Math.max(g,b)&&h.label!==void 0&&h.label!==null&&h.label!==false){let w=typeof h.label=="object"?h.label:void 0,k=typeof h.label=="string"?h.label:w?.text??h.name,B=w?.position??"right",de=Ge(k,B,r,o,p,f,w);c.push({...de,y:Ne(de.y,Math.min(a,l),Math.max(a,l),d.thresholdFontSize),id:h.id?`${h.id}-label`:void 0});}}return {inside:u,labels:c}}function ze(i){let e=Ve(i);return [...e.inside,...e.labels]}function Ne(i,e,t,n){return Math.max(e+n,Math.min(t-n/2,i))}function Ge(i,e,t,n,r,o,a){let l=(t+n)/2,s={type:"text",content:i,fontSize:d.thresholdFontSize,fill:o},m=a?{...a.rotate!==void 0&&{rotate:a.rotate},...a.textBaseline!==void 0&&{textBaseline:a.textBaseline}}:{};switch(e){case "left":return {...s,...m,x:t+4,y:r-4,anchor:"start"};case "above":return {...s,...m,x:l,y:r-6,anchor:"middle"};case "below":return {...s,...m,x:l,y:r+14,anchor:"middle"};case "center":return {...s,...m,x:l,y:r-4,anchor:"middle"};case "outside-left":return {...s,...m,x:t-6,y:r+3,anchor:"end",textBaseline:m.textBaseline??"middle"};case "outside-right":return {...s,...m,x:n+6,y:r+3,anchor:"start",textBaseline:m.textBaseline??"middle"};default:return {...s,...m,x:n-4,y:r-4,anchor:"end"}}}function ke(i,e,t,n){switch(i){case "above":return e-5;case "below":return n!==void 0?n-5:t+14;case "center":case "middle":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function N(i){let{ranges:e,timeScale:t,yRange:n,height:r}=i,[o,a]=n,l=[],[s,m]=t.range(),u=Math.min(s,m),c=Math.max(s,m),h=f=>Math.max(u,Math.min(c,f));for(let f of e){let p=h(t.map(f.startTime)),y=h(t.map(f.endTime));if(f.fill!==void 0&&l.push({type:"rect",x:p,y:o,w:y-p,h:a-o,fill:f.fill,hatch:f.hatch,opacity:f.opacity}),f.edges)for(let g of [p,y])l.push({type:"line",x1:g,y1:o,x2:g,y2:a,stroke:f.edges.stroke,strokeWidth:f.edges.strokeWidth,dash:"dashed"});f.label&&l.push({type:"text",content:f.label,x:(p+y)/2,y:ke(f.labelPosition??"middle",o,a,r),anchor:"middle",fontSize:f.fontSize,fill:f.labelColor,rotate:f.rotate});}return l}function Ye(i){let{gaps:e,timeScale:t,yRange:n,height:r,fill:o=d.gapFill,hatch:a,fillOpacity:l=d.gapFillOpacity??.15,stroke:s=d.gapStroke,strokeWidth:m=d.gapStrokeWidth,dashed:u=true,fontSize:c=d.gapFontSize,fontFill:h=d.gapFontColor,labelBaseline:f="middle",labelRotate:p}=i;return N({timeScale:t,yRange:n,height:r,ranges:e.map(y=>{let g=y.style??"dashed_border",b=g==="filled"||g==="dashed_border",S=g==="dashed_border"&&u!==false;return {startTime:y.startTime,endTime:y.endTime,...b&&{fill:y.fill??o,hatch:y.hatch??a,opacity:y.fillOpacity??l},...S&&{edges:{stroke:s,strokeWidth:m}},label:y.label,labelPosition:y.labelBaseline??f,labelColor:h,fontSize:c,rotate:y.rotate??p}})})}function Ze(i){let{markers:e,timeScale:t,valueScale:n,yRange:r=[0,300]}=i,[o,a]=r,l=[];for(let s of e){let m=t.map(s.time),u=s.color??d.markerColor,c=s.pointStyle??(s.value!==void 0?"circle":"none"),h=s.lineStyle??"full";if(s.value!==void 0){let f=n.map(s.value);if(h==="to-value"?l.push({type:"line",x1:m,y1:a,x2:m,y2:f,stroke:u,strokeWidth:1,dashed:true}):h==="to-top"?l.push({type:"line",x1:m,y1:o,x2:m,y2:f,stroke:u,strokeWidth:1,dashed:true}):h==="full"&&l.push({type:"line",x1:m,y1:o,x2:m,y2:a,stroke:u,strokeWidth:1}),c!=="none"&&U(l,void 0,c,m,f,d.markerSize,u,u,1.5),s.label){let p=h==="to-value"?f-10:o-6;l.push({type:"text",content:s.label,x:m,y:p,anchor:"middle",fontSize:d.markerFontSize,fill:u});}}else h!=="none"&&l.push({type:"line",x1:m,y1:o,x2:m,y2:a,stroke:u,strokeWidth:1}),s.label&&l.push({type:"text",content:s.label,x:m,y:o-6,anchor:"middle",fontSize:d.markerFontSize,fill:u});}return l}function Xe(i){let{highlights:e,timeScale:t,yRange:n,height:r}=i;return N({timeScale:t,yRange:n,height:r,ranges:e.map(o=>({startTime:o.startTime,endTime:o.endTime,fill:o.color??d.highlightColor,opacity:o.opacity??d.highlightOpacity,label:o.label,labelPosition:o.labelPosition??"top",labelColor:o.color??d.highlightLabelColor,fontSize:d.annotationFontSize,rotate:o.rotate}))})}function Q(i){return i&&i.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function Ue(i){let{annotations:e,timeScale:t,valueScales:n}=i,r=[],o=a=>{let l=n.get(a.axis??0)??n.values().next().value;return {x:t.map(a.time),y:l?l.map(a.value):0}};for(let a of e){let l=[],s=m=>l.push(m);switch(a.type){case "line":{let m=o(a.from),u=o(a.to);s({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:a.color??d.annotationColor,strokeWidth:a.width??d.annotationWidth,dash:a.dash});break}case "arrow":{let m=o(a.from),u=o(a.to),c=a.color??d.annotationColor,h=a.headSize??d.annotationHead;s({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:c,strokeWidth:a.width??d.annotationWidth});let f=Math.hypot(u.x-m.x,u.y-m.y)||1,p=(u.x-m.x)/f,y=(u.y-m.y)/f,g=u.x-p*h,b=u.y-y*h;s({type:"path",points:[{x:u.x,y:u.y},{x:g-y*h*.5,y:b+p*h*.5},{x:g+y*h*.5,y:b-p*h*.5}],fill:c,stroke:"none"});break}case "rect":{let m=o(a.from),u=o(a.to);s({type:"rect",x:Math.min(m.x,u.x),y:Math.min(m.y,u.y),w:Math.abs(u.x-m.x),h:Math.abs(u.y-m.y),fill:a.fill??"none",hatch:a.hatch,stroke:a.stroke,opacity:a.opacity});break}case "point":{let m=o(a.at),u=a.color??"#334155",c=a.radius??d.annotationRadius,h=a.shape??"circle";h==="circle"?s({type:"circle",cx:m.x,cy:m.y,r:c,fill:u}):h==="square"?s({type:"rect",x:m.x-c,y:m.y-c,w:c*2,h:c*2,fill:u}):(s({type:"line",x1:m.x-c,y1:m.y-c,x2:m.x+c,y2:m.y+c,stroke:u,strokeWidth:1.5}),s({type:"line",x1:m.x-c,y1:m.y+c,x2:m.x+c,y2:m.y-c,stroke:u,strokeWidth:1.5}));break}case "label":{let m=o(a.at);s({type:"text",content:a.text,x:m.x+(a.dx??0),y:m.y+(a.dy??0),anchor:a.anchor??qe(m.x+(a.dx??0),a.text,i),fontSize:d.annotationFontSize,fill:a.color??d.annotationColor,rotate:a.rotate});break}}if(a.id&&l.length>0){let m=Q(a.id);r.push({type:"group",cssClass:`annotation annotation--${m}`,commands:l});}else r.push(...l);}return r}function qe(i,e,t){let{metrics:n,timeScale:r}=t;if(!n)return "middle";let[o,a]=r.range(),l=n(e,d.annotationFontSize)/2;return i-l<o?"start":i+l>a?"end":"middle"}var ee=class i{_config;constructor(e){this._config=e;}compute(){let{width:e,height:t,margin:n}=this._config;return {totalWidth:e,totalHeight:t,chartWidth:e-n.left-n.right,chartHeight:t-n.top-n.bottom,chartX:n.left,chartY:n.top,margin:n}}static default(e=800,t=400){return new i({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};var te=class{#e;constructor(){this.#e=[];}add(e){this.#e.push(e);}clear(){this.#e=[];}isInside(e,t){return this.#e.length===0?true:this.#e.some(n=>e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height)}toSVGClipPath(e="clip"){if(this.#e.length===0)return "";let t=this.#e.map(n=>`<rect x="${n.x}" y="${n.y}" width="${n.width}" height="${n.height}" />`).join(`
|
|
25
25
|
`);return `<clipPath id="${e}">
|
|
26
26
|
${t}
|
|
27
|
-
</clipPath>`}get regions(){return [...this.#e]}};var A={axisColor:h.axisColor,tickColor:h.tickColor,textColor:h.textColor,textSize:h.textSize},W=class{#e;#t;constructor(e){this.#e=new R({domain:e.domain,range:e.xRange,locale:e.locale,timeZone:e.timeZone}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??A).axisColor}get tickColor(){return (this.#t.colors??A).tickColor}get textColor(){return (this.#t.colors??A).textColor}get textSize(){return (this.#t.colors??A).textSize}generateTicks(){let e=this.#t.minTicks??5,t=this.#t.maxTicks??12,o=this.#e.ticks({minTicks:e,maxTicks:t}).map(r=>({time:r,x:this.#e.map(r),label:this.tickLabel(r)}));return this.antiOverlap(o)}tickLabel(e){if(this.#t.format)return this.#t.format(new Date(e));let t=this.#t.minTicks??5,n=this.#t.maxTicks??12,{interval:o}=this.#e.tickInterval((t+n)/2,t,n),r={};return o<6e4?(r.hour="2-digit",r.minute="2-digit",r.second="2-digit"):o<36e5||o<864e5?(r.hour="2-digit",r.minute="2-digit"):o<31536e6?(r.day="numeric",r.month="short",o>=2592e6&&(r.day=void 0,r.month="long")):(r.year="numeric",o<2*31536e6&&(r.month="short")),this.#e.format(e,r)}antiOverlap(e){if(e.length<=1)return e;let t=60,n=[e[0]];for(let o=1;o<e.length;o++){let r=n[n.length-1].x;Math.abs(e[o].x-r)>=t&&n.push(e[o]);}return n}render(){let e=this.generateTicks(),t=this.#t.colors??A,n=this.#t.y??0,o=[],[r,s]=this.#e.range();o.push({type:"line",x1:r,y1:n,x2:s,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let l of e)o.push({type:"line",x1:l.x,y1:n,x2:l.x,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),o.push({type:"text",content:l.label,x:l.x,y:n+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return o}};var j={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function Be(a){return Math.abs(a)>=1e6?`${(a/1e6).toFixed(1)}M`:Math.abs(a)>=1e3?`${(a/1e3).toFixed(1)}k`:Number.isInteger(a)?String(a):a.toFixed(1)}function Ve(a){let e=new Array(a.length).fill(false),t=0;for(;t<a.length;){let n=t;for(;n+1<a.length&&a[n+1].label===a[t].label;)n++;for(let o=t+1;o<n;o++)e[o]=true;t=n+1;}return e}var J=class{#e;#t;constructor(e){this.#e=new L({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??j).axisColor}get tickColor(){return (this.#t.colors??j).tickColor}get textColor(){return (this.#t.colors??j).textColor}get textSize(){return (this.#t.colors??j).textSize}generateTicks(){let e=this.#t.format??Be,t=this.#t.ticks&&this.#t.ticks>0?this.#t.ticks:6,[n,o]=this.#e.domain(),r=Math.min(n,o),s=Math.max(n,o),l=s-r;if(l===0)return [{value:n,position:this.#e.map(n),label:e(n)}];let i=l/t,m=Math.pow(10,Math.floor(Math.log10(i))),u=i/m,c;if(u<=1.5?c=m:u<=3?c=2*m:u<=7?c=5*m:c=10*m,c<=0||!Number.isFinite(c))return [{value:n,position:this.#e.map(n),label:e(n)}];let d=[],p=Math.ceil(r/c)*c;for(let f=p;f<=s;f+=c)d.push({value:f,position:this.#e.map(f),label:e(f)});return d}render(){let e=this.generateTicks(),t=this.#t.colors??j,n=this.#t.x??0,o=this.#t.orientation??"vertical",r=this.#t.position??"left",s=this.#t.suppressLabelsNear??[],l=this.#t.suppressTolerancePx??8,i=u=>s.some(c=>Math.abs(c-u)<=l),m=[];if(o==="vertical"){let[u,c]=this.#e.range();m.push({type:"line",x1:n,y1:u,x2:n,y2:c,stroke:t.axisColor,strokeWidth:t.axisWidth});let d=Ve(e);e.forEach((p,f)=>{let g=i(p.position),y=d[f]?{opacity:0}:{};r==="left"?(m.push({type:"line",x1:n-4,y1:p.position,x2:n,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||m.push({type:"text",content:p.label,x:n-8,y:p.position+4,anchor:"end",fontSize:11,fill:t.textColor,...y})):(m.push({type:"line",x1:n,y1:p.position,x2:n+4,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||m.push({type:"text",content:p.label,x:n+8,y:p.position+4,anchor:"start",fontSize:11,fill:t.textColor,...y}));});}else {let[u,c]=this.#e.range();m.push({type:"line",x1:u,y1:n,x2:c,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let d of e)m.push({type:"line",x1:d.position,y1:n,x2:d.position,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),m.push({type:"text",content:d.label,x:d.position,y:n+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}return m}};var Q=class a{#e;#t;#n;#r;#a;#o;#i;constructor(e){this.#e=[...e.data].sort((t,n)=>t.time-n.time),this.#t=e.windowSize,this.#n=e.type??"simple",this.#r=e.timeScale,this.#a=e.valueScale,this.#o=e.stroke??"#e53e3e",this.#i=e.strokeWidth??2;}static simple(e,t){let n=[...e].filter(r=>r.value!==null).sort((r,s)=>r.time-s.time),o=[];for(let r=0;r<n.length;r++){let s=Math.max(0,r-t+1),l=n.slice(s,r+1),i=l.reduce((m,u)=>m+u.value,0)/l.length;o.push({time:n[r].time,value:i});}return o}static exponential(e,t){let n=[...e].filter(l=>l.value!==null).sort((l,i)=>l.time-i.time);if(n.length===0)return [];let o=2/(t+1),r=[],s=n[0].value;r.push({time:n[0].time,value:s});for(let l=1;l<n.length;l++)s=n[l].value*o+s*(1-o),r.push({time:n[l].time,value:s});return r}points(){return (this.#n==="exponential"?a.exponential(this.#e,this.#t):a.simple(this.#e,this.#t)).map(t=>({x:this.#r.map(t.time),y:this.#a.map(t.value)}))}render(){let e=this.points();return e.length<2?e.map(t=>({type:"circle",cx:t.x,cy:t.y,r:this.#i,fill:this.#o})):[{type:"path",points:e,smoothing:true,stroke:this.#o,strokeWidth:this.#i}]}};var ee=class{#e;#t;#n;constructor(e){let t=Object.keys(e.enumMap).map(Number).sort((n,o)=>n-o).map(String);this.#t=t,this.#e=new F({domain:t,range:e.range}),this.#n=e;}get scale(){return this.#e}generateTicks(){let{enumMap:e,showLabels:t=true,autoColor:n=true,gapValues:o}=this.#n,r=new Set(o??[]);return this.#t.map((s,l)=>{let i=Number(s),m=t?e[i]??String(i):String(i),u=this.#e.map(i),c=n?h.palette[l%h.palette.length]:void 0;return {value:i,label:m,y:u,color:c,isGap:r.has(i)}})}colorFor(e){let t=this.#t.indexOf(String(e));if(!(t===-1||!(this.#n.autoColor??true)))return h.palette[t%h.palette.length]}render(){let e=this.generateTicks(),t=this.#n.x??0,n=[];for(let o of e)o.isGap||n.push({type:"text",content:o.label,x:t,y:o.y+4,anchor:"end",fontSize:11,fill:o.color??h.textColor});return n}map(e){return this.#e.map(e)}isGap(e){return new Set(this.#n.gapValues??[]).has(e)}};var k=class a{#e;#t;static uidcnt=0;#n;constructor(e,t=[]){this.#e=e.id??"series-"+ ++a.uidcnt,this.#t=e.timeScale,this.#n=t;}get id(){return this.#e}get timeScale(){return this.#t}get data(){return this.#n}};var te=class extends k{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale;return this.data.filter(t=>t.value!==null).map(t=>({x:this.timeScale.map(t.time),y:e.map(t.value),time:t.time})).sort((t,n)=>t.x-n.x)}render(){let e=this.#e,t={smoothing:e.smoothing??false,stroke:e.stroke??h.stroke,strokeWidth:e.strokeWidth??h.strokeWidth,dashed:e.dashed??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??h.pointSize,shadowColor:e.shadowColor,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY},n=e.pointThreshold??h.pointThreshold,o=e.gapThreshold??h.gapThreshold,r=e.id,s=x.getRuns(this.data,c=>c.value===null,o),l=s.reduce((c,d)=>c+d.length,0);if(l===0)return [];let i={timeScale:this.timeScale,valueScale:e.valueScale},m=s.map(c=>({data:c})),u=[];if(u.push(...w(m,i,{...t,id:r?`${r}-line`:void 0})),t.pointStyle&&t.pointStyle!=="none"&&l<=n)for(let c of s)u.push(...$(c,i,{...t,id:r?`${r}-marker`:void 0},()=>t.stroke));return u}};var ne=class extends k{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale,t=[...this.data].filter(o=>o.value!==null).sort((o,r)=>o.time-r.time),n=[];for(let o=0;o<t.length;o++){let r=this.timeScale.map(t[o].time),s=e.map(t[o].value);o===0?n.push({x:r,y:s}):n.push({x:r,y:n[n.length-1].y},{x:r,y:s});}return n}render(){let e=x.getRuns(this.data,o=>o.value===null);if(e.length===0)return [];let t={timeScale:this.timeScale,valueScale:this.#e.valueScale},n=e.map(o=>({data:o}));return z(n,t,{stroke:this.#e.stroke??h.stroke,strokeWidth:this.#e.strokeWidth??h.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var re=class extends k{#e;constructor(e){super(e,e.data),this.#e=e;}opacity(e){if(!(this.#e.countOpacity??false))return .6;let t=0;for(let n of this.data)n.count>t&&(t=n.count);return t===0?.2:.2+.8*e/t}render(){let e=this.#e,t=e.fill??h.bandFill,n=e.hatch,o=e.avgLine??false,r=e.avgLineColor??h.bandAvgLine,s=e.bandWidth??10,l=[];for(let i of this.data){if(i.min===null||i.max===null)continue;let m=this.timeScale.map(i.time),u=e.valueScale.map(i.max),c=e.valueScale.map(i.min),d=s,p=this.data.indexOf(i);if(l.push({type:"rect",x:m-d/2,y:u,w:d,h:c-u,fill:t,hatch:n,opacity:this.opacity(i.count),id:this.id?`${this.id}-slot-${p}`:void 0}),o&&i.avg!==null){let f=e.valueScale.map(i.avg);l.push({type:"line",x1:m-d/2,y1:f,x2:m+d/2,y2:f,stroke:r,strokeWidth:1,id:this.id?`${this.id}-avg-${p}`:void 0});}}return l}};var oe=class extends k{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??h.minColor,n=e.maxColor??h.maxColor,o=e.avgColor??h.avgColor,r=e.avgDashed??true,s=e.smoothing??false,l=e.strokeWidth??h.strokeWidth,i=x.getRuns(this.data,p=>p.min===null||p.max===null||p.avg===null);if(i.length===0)return [];let m={timeScale:this.timeScale,valueScale:e.valueScale},u=[];i.forEach((p,f)=>{p.length<2||(e.fillToMax&&u.push(...B(p,m,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.max,getValue:g=>g.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMax,getHatch:()=>e.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${f}`:void 0})),e.fillToMin&&u.push(...B(p,m,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.min,getValue:g=>g.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMin,getHatch:()=>e.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${f}`:void 0})));});let c=i.filter(p=>p.length>=2),d=p=>c.map(f=>({data:f.map(g=>({time:g.time,value:p(g)}))}));return u.push(...w(d(p=>p.max),m,{stroke:n,strokeWidth:l,smoothing:s,id:this.id?`${this.id}-max`:void 0}),...w(d(p=>p.min),m,{stroke:t,strokeWidth:l,smoothing:s,id:this.id?`${this.id}-min`:void 0}),...w(d(p=>p.avg),m,{stroke:o,strokeWidth:l,smoothing:s,dashed:r,id:this.id?`${this.id}-avg`:void 0})),u}};var ie=class extends k{#e;#t;constructor(e){super(e,e.data),this.#e=e,this.#t=[...e.zones??[]].sort((t,n)=>t.value-n.value);}#n(e){return e===0?this.#e.baseColor??h.stroke:this.#t[e-1].color}render(){let e=this.#e,t=e.baseColor??h.stroke,n={stroke:t,strokeWidth:e.strokeWidth??h.strokeWidth,smoothing:e.smoothing??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??h.pointSize},o=e.gapThreshold??h.gapThreshold,r=e.pointThreshold??h.pointThreshold,s=x.getRuns(this.data,u=>u.value===null,o),l=s.reduce((u,c)=>u+c.length,0);if(l===0)return [];let i={timeScale:this.timeScale,valueScale:e.valueScale},m=[];for(let u of s){if(u.length<2)continue;if(e.fill){let f=e.fill.value,g=x.splitByBoundaries(u,[f],b=>b.value,x.interpolateDataPoint),y=e.valueScale.map(f);for(let b=0;b<g.length;b++){let S=g[b];if(S.data.length<2)continue;let O=S.zoneIndex>0;if(e.fill.side==="above"===O){let I=S.data.map(me=>({x:this.timeScale.map(me.time),y:e.valueScale.map(me.value)}));m.push({type:"path",cssClass:"series-fill",id:this.id?`${this.id}-fill-${b}`:void 0,points:[...I,{x:I[I.length-1].x,y},{x:I[0].x,y}],fill:e.fill.color,hatch:e.fill.hatch,stroke:"none"});}}}let c=this.#t.map(f=>f.value),p=x.splitByBoundaries(u,c,f=>f.value,x.interpolateDataPoint).map(f=>({data:f.data,color:this.#n(f.zoneIndex)}));m.push(...w(p,i,{...n,id:this.id?`${this.id}-line`:void 0})),n.pointStyle&&n.pointStyle!=="none"&&l<=r&&m.push(...$(u,i,{...n,id:this.id?`${this.id}-marker`:void 0},f=>{let g=t;for(let y of this.#t)f.value>=y.value&&(g=y.color);return g}));}return m}};var Ee=1,ae=class{#e;constructor(e,t,n,o){this.#e={...e,xRange:t,y:n,height:o};}render(){let{items:e,timeScale:t,background:n,hatch:o,showAxis:r,xRange:s,y:l,height:i}=this.#e,m=[];n&&m.push({type:"rect",x:s[0],y:l,w:s[1]-s[0],h:i,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let u of e){let c=t.map(u.startTime),d=t.map(u.endTime);if(d<s[0]||c>s[1])continue;let p=Math.max(s[0],Math.min(s[1],c)),f=Math.max(s[0],Math.min(s[1],d)),g=Math.max(f-p,Ee);p+g>s[1]&&(p=Math.max(s[0],s[1]-g));let y=p+g/2;if(m.push({type:"rect",x:p,y:l,w:g,h:i,hatch:u.hatch??o,fill:u.fill??"#6b728044",stroke:u.stroke,strokeWidth:u.strokeWidth??0,title:u.title}),u.label){let b=u.labelFontSize??10;m.push({type:"text",content:u.label,x:y,y:this.#t(u.labelBaseline,b),anchor:"middle",fontSize:b,fill:u.labelFill??"#333"});}}if(r){let u=new W({domain:t.domain(),xRange:s,y:l+i+4});m.push({type:"group",cssClass:"annotation-band-axis",commands:u.render()});}return m}#t(e,t){let{y:n,height:o}=this.#e;switch(e){case "top":return n+t*.9;case "bottom":return n+o-t*.25;default:return n+o/2+t*.35}}};var se=class{#e;constructor(e){this.#e=e;}render(){let{data:e,valueScale:t,xRange:n,showMin:o=false,showMax:r=false,showAvg:s=true,showMedian:l=false,labelPosition:i="end",lineColor:m=h.statsLineColor,labelColor:u=h.statsLabelColor}=this.#e,c=ue.compute(e),d=[{name:"min",value:c.min,enabled:o},{name:"max",value:c.max,enabled:r},{name:"avg",value:c.avg,enabled:s},{name:"median",value:c.median,enabled:l}],p=[],[f,g]=n;for(let y of d.filter(b=>b.enabled)){let b=t.map(y.value);p.push({type:"line",x1:f,y1:b,x2:g,y2:b,stroke:m,strokeWidth:1});let S=`${y.name}: ${y.value.toFixed(1)}`;(i==="start"||i==="both")&&p.push({type:"text",content:S,x:f+4,y:b-4,anchor:"start",fontSize:10,fill:u}),(i==="end"||i==="both")&&p.push({type:"text",content:S,x:g-4,y:b-4,anchor:"end",fontSize:10,fill:u}),i==="center"&&p.push({type:"text",content:S,x:(f+g)/2,y:b-4,anchor:"middle",fontSize:10,fill:u});}return p}};var D=class{#e;#t;#n;constructor(e){this.#e=e?.locale||(typeof navigator<"u"?navigator.language:"en-US"),this.#t=e?.fallbackLocales??["en-US"],this.#n=e?.autoFormat??true;}format(e,t,n){try{let o=this.#n&&n?this.#r(e,n,t):t;return P(this.#e,o).format(new Date(e))}catch{for(let o of this.#t)try{return P(o,t).format(new Date(e))}catch{}return new Date(e).toISOString()}}formatRange(e,t){let n=this.format(e),o=this.format(t);return `${n} \u2014 ${o}`}#r(e,t,n){let o=Math.abs(e-t),r=864e5,s=36e5,l=6e4,i={};return o<l?(i.second="2-digit",i.minute="2-digit",i.hour="2-digit"):o<s?(i.minute="2-digit",i.hour="2-digit"):o<r?(i.hour="2-digit",i.minute="2-digit"):o<7*r?(i.weekday="short",i.day="numeric"):o<365*r?(i.month="short",i.day="numeric"):(i.month="short",i.year="numeric"),{...n,...i}}};var M=class a{#e;#t;_compact;#n;constructor(e){this.#e=e?.unit??"",this.#t=e?.decimals??1,this._compact=e?.compact??false,this.#n=e?.custom;}format(e){if(this.#n)return this.#n(e);let t;return this._compact&&Math.abs(e)>=1e6?t=`${(e/1e6).toFixed(this.#t)}M`:this._compact&&Math.abs(e)>=1e3?t=`${(e/1e3).toFixed(this.#t)}k`:t=e.toFixed(this.#t),this.#e?`${t}${this.#e}`:t}formatRange(e,t){return `${this.format(e)} \u2014 ${this.format(t)}`}static unit(e,t=1){return new a({unit:e,decimals:t})}static temperature(e="\xB0C"){return new a({unit:e,decimals:1})}static percentage(){return new a({unit:"%",decimals:0})}};var _=class a{#e;#t;#n;constructor(e){this.#e=e?.map??{},this.#t=e?.fallback??(t=>String(t)),this.#n=e?.showValue??false;}format(e){let t=this.#e[e]??this.#t(e);return this.#n?`(${e}) ${t}`:t}has(e){return e in this.#e}labels(){return Object.values(this.#e)}values(){return Object.keys(this.#e).map(Number)}static fromLabels(e,t=false){let n={};return e.forEach((o,r)=>{n[r]=o;}),new a({map:n,showValue:t})}};var Ne={time:new D,value:new M,enum:new _};function le(a,e){let t=C();return {color:a.color??t.stroke,width:a.width??t.strokeWidth,style:a.style??"solid",smoothing:a.smoothing??false,shape:a.shape??(e.seriesType==="step"?"step":"line"),gapThreshold:a.gapThreshold??t.gapThreshold,opacity:a.opacity??1}}function ge(a){let e=a.style?.line;return e===false?[]:e===void 0?[le({},a)]:Array.isArray(e)?e.map(t=>le(t,a)):[le(e,a)]}function ye(a){let e=a.style?.markers;if(!e?.type||e.type==="none")return;let t=C(),o=(a.style?.line&&!Array.isArray(a.style.line)?a.style.line.color:void 0)??t.stroke;return {type:e.type,size:e.size??t.pointSize,stroke:e.stroke??o,fill:e.fill??"#ffffff",strokeWidth:e.strokeWidth??1,threshold:e.threshold}}function be(a){let e=a.style?.shadow;if(!(!e?.color||e.color==="transparent"||e.color==="none"))return {color:e.color,blur:e.blur??4,offsetX:e.offsetX??0,offsetY:e.offsetY??0}}function xe(a){return a.style?.gap}function Se(a){return a.style?.fill}function ze(a){return {lines:ge(a),fill:Se(a),markers:ye(a),shadow:be(a),gap:xe(a),id:a.style?.id??a.id}}/*!
|
|
27
|
+
</clipPath>`}get regions(){return [...this.#e]}};function G(i,e){if(e<=0||i.length<2)return [];let t=[];for(let n=0;n<i.length-1;n++){let r=i[n],o=i[n+1];for(let a=1;a<=e;a++)t.push(r+(o-r)*a/(e+1));}return t}var O={axisColor:d.axisColor,tickColor:d.tickColor,textColor:d.textColor,textSize:d.textSize},H=class{#e;#t;constructor(e){this.#e=new j({domain:e.domain,range:e.xRange,locale:e.locale,timeZone:e.timeZone}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??O).axisColor}get tickColor(){return (this.#t.colors??O).tickColor}get textColor(){return (this.#t.colors??O).textColor}get textSize(){return (this.#t.colors??O).textSize}generateTicks(){let e=this.#t.minTicks??5,t=this.#t.maxTicks??12,r=this.#e.ticks({minTicks:e,maxTicks:t}).map(o=>({time:o,x:this.#e.map(o),label:this.tickLabel(o)}));return this.antiOverlap(r)}tickLabel(e){if(this.#t.format)return this.#t.format(new Date(e));let t=this.#t.minTicks??5,n=this.#t.maxTicks??12,{interval:r}=this.#e.tickInterval((t+n)/2,t,n),o={};return r<6e4?(o.hour="2-digit",o.minute="2-digit",o.second="2-digit"):r<36e5||r<864e5?(o.hour="2-digit",o.minute="2-digit"):r<31536e6?(o.day="numeric",o.month="short",r>=2592e6&&(o.day=void 0,o.month="long")):(o.year="numeric",r<2*31536e6&&(o.month="short")),this.#e.format(e,o)}antiOverlap(e){if(e.length<=1)return e;let t=60,n=[e[0]];for(let r=1;r<e.length;r++){let o=n[n.length-1].x;Math.abs(e[r].x-o)>=t&&n.push(e[r]);}return n}render(){let e=this.generateTicks(),t=this.#t.colors??O,n=this.#t.y??0,r=[],[o,a]=this.#e.range();r.push({type:"line",x1:o,y1:n,x2:a,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let l of this.generateMinorTicks())r.push({type:"line",x1:l,y1:n,x2:l,y2:n+3,stroke:t.tickColor,strokeWidth:t.axisWidth});for(let l of e)r.push({type:"line",x1:l.x,y1:n,x2:l.x,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),r.push({type:"text",content:l.label,x:this.#n(l.x,l.label,t.textSize),y:n+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return r}generateMinorTicks(){return G(this.generateTicks().map(e=>e.x),this.#t.minorTicks??0)}#n(e,t,n){let r=this.#t.gesamtbreite,o=this.#t.metrics;if(r===void 0||o===void 0)return e;let a=o(t,n)/2;return Math.max(a+2,Math.min(r-a-2,e))}};var $={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function ve(i){return Math.abs(i)>=1e6?`${(i/1e6).toFixed(1)}M`:Math.abs(i)>=1e3?`${(i/1e3).toFixed(1)}k`:Number.isInteger(i)?String(i):i.toFixed(1)}function Ke(i){let e=new Array(i.length).fill(false),t=0;for(;t<i.length;){let n=t;for(;n+1<i.length&&i[n+1].label===i[t].label;)n++;for(let r=t+1;r<n;r++)e[r]=true;t=n+1;}return e}var ne=class{#e;#t;constructor(e){this.#e=new _({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??$).axisColor}get tickColor(){return (this.#t.colors??$).tickColor}get textColor(){return (this.#t.colors??$).textColor}get textSize(){return (this.#t.colors??$).textSize}generateTicks(){let e=this.#t.tickValues;if(e&&e.length>0){let y=this.#t.format??ve;return e.map(g=>({value:g,position:this.#e.map(g),label:y(g)}))}let t=this.#t.format??ve,n=this.#t.ticks&&this.#t.ticks>0?this.#t.ticks:6,[r,o]=this.#e.domain(),a=Math.min(r,o),l=Math.max(r,o),s=l-a;if(s===0)return [{value:r,position:this.#e.map(r),label:t(r)}];let m=s/n,u=Math.pow(10,Math.floor(Math.log10(m))),c=m/u,h;if(c<=1.5?h=u:c<=3?h=2*u:c<=7?h=5*u:h=10*u,h<=0||!Number.isFinite(h))return [{value:r,position:this.#e.map(r),label:t(r)}];let f=[],p=Math.ceil(a/h)*h;for(let y=p;y<=l;y+=h)f.push({value:y,position:this.#e.map(y),label:t(y)});return f}generateMinorTicks(){return G(this.generateTicks().map(e=>e.position),this.#t.minorTicks??0)}render(){let e=this.generateTicks(),t=this.#t.colors??$,n=this.#t.x??0,r=this.#t.orientation??"vertical",o=this.#t.position??"left",a=this.#t.suppressLabelsNear??[],l=this.#t.suppressTolerancePx??8,s=c=>a.some(h=>Math.abs(h-c)<=l),m=[];if(r==="vertical"){let[c,h]=this.#e.range();m.push({type:"line",x1:n,y1:c,x2:n,y2:h,stroke:t.axisColor,strokeWidth:t.axisWidth});let f=Ke(e);e.forEach((p,y)=>{let g=s(p.position),b=f[y]?{opacity:0}:{};o==="left"?(m.push({type:"line",x1:n-4,y1:p.position,x2:n,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||m.push({type:"text",content:p.label,x:this.#n(n-8,p.label,"end"),y:p.position+4,anchor:"end",fontSize:t.textSize,fill:t.textColor,...b})):(m.push({type:"line",x1:n,y1:p.position,x2:n+4,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||m.push({type:"text",content:p.label,x:this.#n(n+8,p.label,"start"),y:p.position+4,anchor:"start",fontSize:t.textSize,fill:t.textColor,...b}));});}else {let[c,h]=this.#e.range();m.push({type:"line",x1:c,y1:n,x2:h,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let f of e)m.push({type:"line",x1:f.position,y1:n,x2:f.position,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),m.push({type:"text",content:f.label,x:f.position,y:n+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}let u=(this.#t.orientation??"vertical")==="vertical";for(let c of this.generateMinorTicks())m.push(u?{type:"line",x1:o==="right"?n:n-2,y1:c,x2:o==="right"?n+2:n,y2:c,stroke:t.tickColor,strokeWidth:t.axisWidth}:{type:"line",x1:c,y1:n,x2:c,y2:n+3,stroke:t.tickColor,strokeWidth:t.axisWidth});return m}#n(e,t,n){let r=this.#t.gesamtbreite,o=this.#t.metrics;if(r===void 0||o===void 0)return e;let a=o(t,(this.#t.colors??$).textSize);return n==="end"?Math.max(a+2,Math.min(r-2,e)):Math.min(r-a-2,Math.max(2,e))}};var re=class i{#e;#t;#n;#r;#a;#o;#i;constructor(e){this.#e=[...e.data].sort((t,n)=>t.time-n.time),this.#t=e.windowSize,this.#n=e.type??"simple",this.#r=e.timeScale,this.#a=e.valueScale,this.#o=e.stroke??"#e53e3e",this.#i=e.strokeWidth??2;}static simple(e,t){let n=[...e].filter(o=>o.value!==null).sort((o,a)=>o.time-a.time),r=[];for(let o=0;o<n.length;o++){let a=Math.max(0,o-t+1),l=n.slice(a,o+1),s=l.reduce((m,u)=>m+u.value,0)/l.length;r.push({time:n[o].time,value:s});}return r}static exponential(e,t){let n=[...e].filter(l=>l.value!==null).sort((l,s)=>l.time-s.time);if(n.length===0)return [];let r=2/(t+1),o=[],a=n[0].value;o.push({time:n[0].time,value:a});for(let l=1;l<n.length;l++)a=n[l].value*r+a*(1-r),o.push({time:n[l].time,value:a});return o}points(){return (this.#n==="exponential"?i.exponential(this.#e,this.#t):i.simple(this.#e,this.#t)).map(t=>({x:this.#r.map(t.time),y:this.#a.map(t.value)}))}render(){let e=this.points();return e.length<2?e.map(t=>({type:"circle",cx:t.x,cy:t.y,r:this.#i,fill:this.#o})):[{type:"path",points:e,smoothing:true,stroke:this.#o,strokeWidth:this.#i}]}};var oe=class{#e;#t;#n;constructor(e){let t=Object.keys(e.enumMap).map(Number).sort((n,r)=>n-r).map(String);this.#t=t,this.#e=new I({domain:t,range:e.range}),this.#n=e;}get scale(){return this.#e}generateTicks(){let{enumMap:e,showLabels:t=true,autoColor:n=true,gapValues:r}=this.#n,o=new Set(r??[]);return this.#t.map((a,l)=>{let s=Number(a),m=t?e[s]??String(s):String(s),u=this.#e.map(s),c=n?d.palette[l%d.palette.length]:void 0;return {value:s,label:m,y:u,color:c,isGap:o.has(s)}})}colorFor(e){let t=this.#t.indexOf(String(e));if(!(t===-1||!(this.#n.autoColor??true)))return d.palette[t%d.palette.length]}render(){let e=this.generateTicks(),t=this.#n.x??0,n=[];for(let r of e)r.isGap||n.push({type:"text",content:r.label,x:t,y:r.y+4,anchor:"end",fontSize:d.textSize,fill:r.color??d.textColor});return n}map(e){return this.#e.map(e)}isGap(e){return new Set(this.#n.gapValues??[]).has(e)}};var C=class i{#e;#t;static uidcnt=0;#n;constructor(e,t=[]){this.#e=e.id??"series-"+ ++i.uidcnt,this.#t=e.timeScale,this.#n=t;}get id(){return this.#e}get timeScale(){return this.#t}get data(){return this.#n}};var ie=class extends C{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale;return this.data.filter(t=>t.value!==null).map(t=>({x:this.timeScale.map(t.time),y:e.map(t.value),time:t.time})).sort((t,n)=>t.x-n.x)}render(){let e=this.#e,t={smoothing:e.smoothing??false,smoothingType:e.smoothingType,stroke:e.stroke??d.stroke,strokeWidth:e.strokeWidth??d.strokeWidth,dashed:e.dashed??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??d.pointSize,shadowColor:e.shadowColor,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY},n=e.pointThreshold??d.pointThreshold,r=e.gapThreshold??d.gapThreshold,o=e.id,a=x.getRuns(this.data,c=>c.value===null,r),l=a.reduce((c,h)=>c+h.length,0);if(l===0)return [];let s={timeScale:this.timeScale,valueScale:e.valueScale},m=a.map(c=>({data:c})),u=[];if(u.push(...v(m,s,{...t,id:o?`${o}-line`:void 0})),t.pointStyle&&t.pointStyle!=="none"&&l<=n)for(let c of a)u.push(...R(c,s,{...t,id:o?`${o}-marker`:void 0},()=>t.stroke));return u}};var ae=class extends C{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale,t=[...this.data].filter(r=>r.value!==null).sort((r,o)=>r.time-o.time),n=[];for(let r=0;r<t.length;r++){let o=this.timeScale.map(t[r].time),a=e.map(t[r].value);r===0?n.push({x:o,y:a}):n.push({x:o,y:n[n.length-1].y},{x:o,y:a});}return n}render(){let e=x.getRuns(this.data,r=>r.value===null);if(e.length===0)return [];let t={timeScale:this.timeScale,valueScale:this.#e.valueScale},n=e.map(r=>({data:r}));return X(n,t,{stroke:this.#e.stroke??d.stroke,strokeWidth:this.#e.strokeWidth??d.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var se=class extends C{#e;constructor(e){super(e,e.data),this.#e=e;}opacity(e){if(!(this.#e.countOpacity??false))return .6;let t=0;for(let n of this.data)n.count>t&&(t=n.count);return t===0?.2:.2+.8*e/t}render(){let e=this.#e,t=e.fill??d.bandFill,n=e.hatch,r=e.avgLine??false,o=e.avgLineColor??d.bandAvgLine,a=e.bandWidth??10,l=[];for(let s of this.data){if(s.min===null||s.max===null)continue;let m=this.timeScale.map(s.time),u=e.valueScale.map(s.max),c=e.valueScale.map(s.min),h=a,f=this.data.indexOf(s);if(l.push({type:"rect",x:m-h/2,y:u,w:h,h:c-u,fill:t,hatch:n,opacity:this.opacity(s.count),id:this.id?`${this.id}-slot-${f}`:void 0}),r&&s.avg!==null){let p=e.valueScale.map(s.avg);l.push({type:"line",x1:m-h/2,y1:p,x2:m+h/2,y2:p,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${f}`:void 0});}}return l}};var le=class extends C{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??d.minColor,n=e.maxColor??d.maxColor,r=e.avgColor??d.avgColor,o=e.avgDashed??true,a=e.smoothing??false,l=e.smoothingType,s=e.strokeWidth??d.strokeWidth,m=x.getRuns(this.data,p=>p.min===null||p.max===null||p.avg===null);if(m.length===0)return [];let u={timeScale:this.timeScale,valueScale:e.valueScale},c=[];m.forEach((p,y)=>{p.length<2||(e.fillToMax&&c.push(...E(p,u,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.max,getValue:g=>g.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMax,getHatch:()=>e.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${y}`:void 0})),e.fillToMin&&c.push(...E(p,u,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.min,getValue:g=>g.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMin,getHatch:()=>e.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${y}`:void 0})));});let h=m.filter(p=>p.length>=2),f=p=>h.map(y=>({data:y.map(g=>({time:g.time,value:p(g)}))}));return c.push(...v(f(p=>p.max),u,{stroke:n,strokeWidth:s,smoothing:a,smoothingType:l,id:this.id?`${this.id}-max`:void 0}),...v(f(p=>p.min),u,{stroke:t,strokeWidth:s,smoothing:a,id:this.id?`${this.id}-min`:void 0}),...v(f(p=>p.avg),u,{stroke:r,strokeWidth:s,smoothing:a,dashed:o,id:this.id?`${this.id}-avg`:void 0})),c}};var me=class extends C{#e;#t;constructor(e){super(e,e.data),this.#e=e,this.#t=[...e.zones??[]].sort((t,n)=>t.value-n.value);}#n(e){return e===0?this.#e.baseColor??d.stroke:this.#t[e-1].color}render(){let e=this.#e,t=e.baseColor??d.stroke,n={stroke:t,strokeWidth:e.strokeWidth??d.strokeWidth,smoothing:e.smoothing??false,smoothingType:e.smoothingType,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??d.pointSize},r=e.gapThreshold??d.gapThreshold,o=e.pointThreshold??d.pointThreshold,a=x.getRuns(this.data,u=>u.value===null,r),l=a.reduce((u,c)=>u+c.length,0);if(l===0)return [];let s={timeScale:this.timeScale,valueScale:e.valueScale},m=[];for(let u of a){if(u.length<2)continue;if(e.fill){let p=e.fill.value,y=x.splitByBoundaries(u,[p],b=>b.value,x.interpolateDataPoint),g=e.valueScale.map(p);for(let b=0;b<y.length;b++){let S=y[b];if(S.data.length<2)continue;let w=S.zoneIndex>0;if(e.fill.side==="above"===w){let k=S.data.map(B=>({x:this.timeScale.map(B.time),y:e.valueScale.map(B.value)}));m.push({type:"path",cssClass:"series-fill",id:this.id?`${this.id}-fill-${b}`:void 0,points:[...k,{x:k[k.length-1].x,y:g},{x:k[0].x,y:g}],fill:e.fill.color,hatch:e.fill.hatch,stroke:"none"});}}}let c=this.#t.map(p=>p.value),f=x.splitByBoundaries(u,c,p=>p.value,x.interpolateDataPoint).map(p=>({data:p.data,color:this.#n(p.zoneIndex)}));m.push(...v(f,s,{...n,id:this.id?`${this.id}-line`:void 0})),n.pointStyle&&n.pointStyle!=="none"&&l<=o&&m.push(...R(u,s,{...n,id:this.id?`${this.id}-marker`:void 0},p=>{let y=t;for(let g of this.#t)p.value>=g.value&&(y=g.color);return y}));}return m}};var Je=1,ue=class{#e;constructor(e,t,n,r){this.#e={...e,xRange:t,y:n,height:r};}render(){let{items:e,timeScale:t,background:n,hatch:r,showAxis:o,xRange:a,y:l,height:s}=this.#e,m=[];n&&m.push({type:"rect",x:a[0],y:l,w:a[1]-a[0],h:s,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let u of e){let c=t.map(u.startTime),h=t.map(u.endTime);if(h<a[0]||c>a[1])continue;let f=Math.max(a[0],Math.min(a[1],c)),p=Math.max(a[0],Math.min(a[1],h)),y=Math.max(p-f,Je);f+y>a[1]&&(f=Math.max(a[0],a[1]-y));let g=f+y/2;if(m.push({type:"rect",x:f,y:l,w:y,h:s,hatch:u.hatch??r,fill:u.fill??"#6b728044",stroke:u.stroke,strokeWidth:u.strokeWidth??0,title:u.title}),u.label){let b=u.labelFontSize??10;m.push({type:"text",content:u.label,x:g,y:this.#t(u.labelBaseline,b),anchor:"middle",fontSize:b,fill:u.labelFill??"#333"});}}if(o){let u=new H({domain:t.domain(),xRange:a,y:l+s+4});m.push({type:"group",cssClass:"annotation-band-axis",commands:u.render()});}return m}#t(e,t){let{y:n,height:r}=this.#e;switch(e){case "top":return n+t*.9;case "bottom":return n+r-t*.25;default:return n+r/2+t*.35}}};var ce=class{#e;constructor(e){this.#e=e;}render(){let{data:e,valueScale:t,xRange:n,showMin:r=false,showMax:o=false,showAvg:a=true,showMedian:l=false,labelPosition:s="end",lineColor:m=d.statsLineColor,labelColor:u=d.statsLabelColor}=this.#e,c=pe.compute(e),h=[{name:"min",value:c.min,enabled:r},{name:"max",value:c.max,enabled:o},{name:"avg",value:c.avg,enabled:a},{name:"median",value:c.median,enabled:l}],f=[],[p,y]=n;for(let g of h.filter(b=>b.enabled)){let b=t.map(g.value);f.push({type:"line",x1:p,y1:b,x2:y,y2:b,stroke:m,strokeWidth:1});let S=`${g.name}: ${g.value.toFixed(1)}`;(s==="start"||s==="both")&&f.push({type:"text",content:S,x:p+4,y:b-4,anchor:"start",fontSize:d.statFontSize,fill:u}),(s==="end"||s==="both")&&f.push({type:"text",content:S,x:y-4,y:b-4,anchor:"end",fontSize:d.statFontSize,fill:u}),s==="center"&&f.push({type:"text",content:S,x:(p+y)/2,y:b-4,anchor:"middle",fontSize:d.statFontSize,fill:u});}return f}};var P=class{#e;#t;#n;constructor(e){this.#e=e?.locale||(typeof navigator<"u"?navigator.language:"en-US"),this.#t=e?.fallbackLocales??["en-US"],this.#n=e?.autoFormat??true;}format(e,t,n){try{let r=this.#n&&n?this.#r(e,n,t):t;return W(this.#e,r).format(new Date(e))}catch{for(let r of this.#t)try{return W(r,t).format(new Date(e))}catch{}return new Date(e).toISOString()}}formatRange(e,t){let n=this.format(e),r=this.format(t);return `${n} \u2014 ${r}`}#r(e,t,n){let r=Math.abs(e-t),o=864e5,a=36e5,l=6e4,s={};return r<l?(s.second="2-digit",s.minute="2-digit",s.hour="2-digit"):r<a?(s.minute="2-digit",s.hour="2-digit"):r<o?(s.hour="2-digit",s.minute="2-digit"):r<7*o?(s.weekday="short",s.day="numeric"):r<365*o?(s.month="short",s.day="numeric"):(s.month="short",s.year="numeric"),{...n,...s}}};var F=class i{#e;#t;_compact;#n;constructor(e){this.#e=e?.unit??"",this.#t=e?.decimals??1,this._compact=e?.compact??false,this.#n=e?.custom;}format(e){if(this.#n)return this.#n(e);let t;return this._compact&&Math.abs(e)>=1e6?t=`${(e/1e6).toFixed(this.#t)}M`:this._compact&&Math.abs(e)>=1e3?t=`${(e/1e3).toFixed(this.#t)}k`:t=e.toFixed(this.#t),this.#e?`${t}${this.#e}`:t}formatRange(e,t){return `${this.format(e)} \u2014 ${this.format(t)}`}static unit(e,t=1){return new i({unit:e,decimals:t})}static temperature(e="\xB0C"){return new i({unit:e,decimals:1})}static percentage(){return new i({unit:"%",decimals:0})}};var A=class i{#e;#t;#n;constructor(e){this.#e=e?.map??{},this.#t=e?.fallback??(t=>String(t)),this.#n=e?.showValue??false;}format(e){let t=this.#e[e]??this.#t(e);return this.#n?`(${e}) ${t}`:t}has(e){return e in this.#e}labels(){return Object.values(this.#e)}values(){return Object.keys(this.#e).map(Number)}static fromLabels(e,t=false){let n={};return e.forEach((r,o)=>{n[o]=r;}),new i({map:n,showValue:t})}};var Qe={time:new P,value:new F,enum:new A};function he(i,e){let t=M();return {color:i.color??t.stroke,width:i.width??t.strokeWidth,style:i.style??"solid",smoothing:i.smoothing??false,smoothingType:i.smoothingType,shape:i.shape??(e.seriesType==="step"?"step":"line"),gapThreshold:i.gapThreshold??t.gapThreshold,opacity:i.opacity??1}}function Te(i){let e=i.style?.line;return e===false?[]:e===void 0?[he({},i)]:Array.isArray(e)?e.map(t=>he(t,i)):[he(e,i)]}function Ce(i){let e=i.style?.markers;if(!e?.type||e.type==="none")return;let t=M(),r=(i.style?.line&&!Array.isArray(i.style.line)?i.style.line.color:void 0)??t.stroke;return {type:e.type,size:e.size??t.pointSize,stroke:e.stroke??r,fill:e.fill??"#ffffff",strokeWidth:e.strokeWidth??1,threshold:e.threshold}}function we(i){let e=i.style?.shadow;if(!(!e?.color||e.color==="transparent"||e.color==="none"))return {color:e.color,blur:e.blur??4,offsetX:e.offsetX??0,offsetY:e.offsetY??0}}function Me(i){return i.style?.gap}function Le(i){return i.style?.fill}function et(i){return {lines:Te(i),fill:Le(i),markers:Ce(i),shadow:we(i),gap:Me(i),id:i.style?.id??i.id}}/*!
|
|
28
28
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
29
29
|
* MIT with Attribution: free use incl. commercial requires visible credit to
|
|
30
30
|
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
@@ -43,4 +43,4 @@ var N=class{};var x=class{static interpolateDataPoint(a,e,t){return {time:a.time
|
|
|
43
43
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
44
44
|
* MIT with Attribution: free use incl. commercial must have visible credit to
|
|
45
45
|
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
46
|
-
*/export{
|
|
46
|
+
*/export{ue as AnnotationBandSeries,I as BandScale,se as BandSeries,te as Clip,oe as EnumAxis,A as EnumFormatter,Qe as Formatters,ee as Layout,ie as LineSeries,_ as LinearScale,le as MinMaxAvgSeries,re as MovingAvg,Y as Renderer,ce as StatsOverlay,ae as StepSeries,T as TIME_INTERVALS,H as TimeAxis,P as TimeFormatter,j as TimeScale,ne as ValueAxis,F as ValueFormatter,me as ZonedLineSeries,be as getHatch,Ie as measureLegend,Ue as renderAnnotations,$e as renderArea,Ye as renderGaps,He as renderGrid,Xe as renderHighlights,Oe as renderLegend,v as renderLine,Ze as renderMarkers,R as renderSeriesMarkers,_e as renderSplitLine,X as renderStep,ze as renderThresholds,E as renderZonedArea,Le as resolveFill,Me as resolveGap,Te as resolveLines,Ce as resolveMarkers,et as resolveSeriesStyle,we as resolveShadow,Q as slugify,d as theme,De as toStepData,Z as toStepPoints};
|