ml-time-graph 1.0.2 → 1.0.5
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/README.de.md +12 -0
- package/README.md +12 -0
- package/dist/index.d.ts +211 -9
- package/dist/index.js +43 -43
- package/dist/interaction/index.d.ts +1 -1
- package/dist/internals.d.ts +4 -4
- package/dist/internals.js +1 -1
- package/dist/{layout-CkEYYdSw.d.ts → layout-BOYtrsZa.d.ts} +1 -1
- package/dist/{scale-O3OLrmn5.d.ts → scale-BRE_QhbZ.d.ts} +1 -0
- package/package.json +1 -1
package/README.de.md
CHANGED
|
@@ -80,6 +80,18 @@ Demo-Galerie zu sehen (`pnpm dev`).
|
|
|
80
80
|
|
|
81
81
|
---
|
|
82
82
|
|
|
83
|
+
## 🔄 Go-Port & 1:1 Rendering-Parität
|
|
84
|
+
|
|
85
|
+
Benötigst du serverseitiges Rendering der exakt gleichen Charts? Es gibt einen 1:1 Go-Port dieser Engine unter **[gitlab.com/mlc0911/mlctimegraph/go-time-graph](https://gitlab.com/mlc0911/mlctimegraph/go-time-graph)**.
|
|
86
|
+
|
|
87
|
+
Sowohl die TypeScript- als auch die Go-Bibliothek:
|
|
88
|
+
- Verarbeiten das **exakt gleiche JSON-Konfigurationsschema**.
|
|
89
|
+
- Generieren **identische SVG-Strukturen und Layoutberechnungen**.
|
|
90
|
+
- Unterstützen **mehrere Y-Achsen** auf der linken und rechten Seite (jede weitere Achse wird automatisch um `50px` horizontal versetzt, um Überlappungen zu vermeiden).
|
|
91
|
+
- Werden kontinuierlich über gemeinsame Test-Fixtures auf Layout-Parität geprüft.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
83
95
|
## Warum schon wieder eine neue Library?
|
|
84
96
|
|
|
85
97
|
Alle Libraries, die ich in der Vergangenheit professionell genutzt habe, haben
|
package/README.md
CHANGED
|
@@ -80,6 +80,18 @@ library, all live in the demo gallery (`pnpm dev`).
|
|
|
80
80
|
|
|
81
81
|
---
|
|
82
82
|
|
|
83
|
+
## 🔄 Go Port & 1:1 Rendering Parity
|
|
84
|
+
|
|
85
|
+
Need server-side rendering of the exact same charts? There is a 1:1 Go port of this engine available at **[gitlab.com/mlc0911/mlctimegraph/go-time-graph](https://gitlab.com/mlc0911/mlctimegraph/go-time-graph)**.
|
|
86
|
+
|
|
87
|
+
Both the TypeScript and Go libraries:
|
|
88
|
+
- Process the **exact same JSON configuration schema**.
|
|
89
|
+
- Generate **identical SVG structures and layout calculations**.
|
|
90
|
+
- Support **multiple Y-axes** on both left and right sides (each additional axis is automatically offset horizontally by `50px` to prevent overlaps).
|
|
91
|
+
- Are continuously tested for rendering parity using shared test fixtures.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
83
95
|
## Why another chart library?
|
|
84
96
|
|
|
85
97
|
Every charting library I relied on professionally eventually switched its license
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { e as LegendOrientation, f as Renderer, M as Marker, d as LegendItem, b as LayoutResult, R as RenderOutput, t as theme } from './layout-
|
|
2
|
-
import { U as LineVariant, g as AnySeries, aa as Threshold, P as Highlight, I as Gap, N as GapsConfig, d as Annotation, e as AnnotationBandConfig, o as DrawCommand, ad as TimeScale, V as LinearScale,
|
|
3
|
-
export { b as AggregationConfig, c as AggregationMode,
|
|
1
|
+
import { e as LegendOrientation, f as Renderer, M as Marker, d as LegendItem, b as LayoutResult, R as RenderOutput, t as theme } from './layout-BOYtrsZa.js';
|
|
2
|
+
import { U as LineVariant, g as AnySeries, aa as Threshold, P as Highlight, I as Gap, N as GapsConfig, d as Annotation, e as AnnotationBandConfig, o as DrawCommand, ad as TimeScale, V as LinearScale, O as HatchVariant, f as AnnotationBandItem, _ as PointStyleType, ac as ThresholdLabelPosition, a5 as SeriesStyle, G as FillSpec, af as TimeSeries, A as AggregatedPoint, a as AggregatedSeries, k as DataPoint } from './scale-BRE_QhbZ.js';
|
|
3
|
+
export { b as AggregationConfig, c as AggregationMode, l as DataPointRef, E as EnumMap, F as FillBound, x as FillDirectionType, y as FillRegion, z as FillSide, H as FillStyle, J as GapConfig, K as GapLabel, L as GapRegion, M as GapStyle, R as LineDashStyle, T as LineStyle, X as MarkerStyle, a2 as SensorType, a3 as SeriesOverlay, a4 as SeriesOverlayKind, a6 as SeriesType, a7 as ShadowStyle, ab as ThresholdLabelConfig } from './scale-BRE_QhbZ.js';
|
|
4
4
|
|
|
5
5
|
/*!
|
|
6
6
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
@@ -45,6 +45,8 @@ interface AxisLabelsStyle {
|
|
|
45
45
|
}
|
|
46
46
|
/** Configuration for one Y-axis (left or right). */
|
|
47
47
|
interface YAxisConfig {
|
|
48
|
+
/** Position is 'left' or 'right' to determine placement side. Defaults to 'left'. */
|
|
49
|
+
position?: "left" | "right";
|
|
48
50
|
/** Rotated label drawn next to the axis. */
|
|
49
51
|
label?: string;
|
|
50
52
|
/** Override the value domain. `'auto'` lets the chart compute it from data. */
|
|
@@ -85,6 +87,8 @@ interface AxesConfig {
|
|
|
85
87
|
x?: XAxisConfig;
|
|
86
88
|
left?: YAxisConfig;
|
|
87
89
|
right?: YAxisConfig;
|
|
90
|
+
/** Y specifies an arbitrary number of vertical axes, each mapped by its slice index. */
|
|
91
|
+
y?: YAxisConfig[];
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
/*!
|
|
@@ -374,15 +378,23 @@ declare class GraphBuilder {
|
|
|
374
378
|
private _bands;
|
|
375
379
|
private _tooltip?;
|
|
376
380
|
/**
|
|
377
|
-
* @param width Chart width in px. Pass `0` to auto-detect from the
|
|
381
|
+
* @param width Chart width in px. Pass `0` or omit to auto-detect from the
|
|
378
382
|
* target's `clientWidth` in {@link mount}.
|
|
379
383
|
* @param height Chart height in px.
|
|
380
384
|
*/
|
|
381
|
-
constructor(width
|
|
382
|
-
/**
|
|
385
|
+
constructor(width?: number, height?: number);
|
|
386
|
+
/** Set the chart's pixel width. */
|
|
387
|
+
setWidth(width: number): this;
|
|
388
|
+
/** Set the chart's pixel height. */
|
|
389
|
+
setHeight(height: number): this;
|
|
390
|
+
/** Override the chart's pixel dimensions. */
|
|
383
391
|
setSize(width: number, height: number): this;
|
|
384
|
-
/**
|
|
392
|
+
/**
|
|
393
|
+
* Override per-side pixel margins.
|
|
394
|
+
* Can be passed as a full `Margin` object or four number arguments: `top, right, bottom, left`.
|
|
395
|
+
*/
|
|
385
396
|
setMargin(margin: Margin): this;
|
|
397
|
+
setMargin(top: number, right: number, bottom: number, left: number): this;
|
|
386
398
|
/** Locale for date/number formatting (e.g. 'de-DE'). */
|
|
387
399
|
setLocale(locale: string): this;
|
|
388
400
|
/** Set the entire axes block (x / left / right). Replaces previous. */
|
|
@@ -393,8 +405,14 @@ declare class GraphBuilder {
|
|
|
393
405
|
setLeftAxis(config: YAxisConfig): this;
|
|
394
406
|
/** Patch just the right Y-axis (`yAxisIndex: 1` series). */
|
|
395
407
|
setRightAxis(config: YAxisConfig): this;
|
|
396
|
-
/**
|
|
408
|
+
/** Patch a specific Y-axis configuration by index. */
|
|
409
|
+
setYAxis(index: number, config: YAxisConfig): this;
|
|
410
|
+
/**
|
|
411
|
+
* Show / position / orient the integrated legend.
|
|
412
|
+
* Can be passed as a full `LegendOptions` object or three arguments: `show, position, orientation`.
|
|
413
|
+
*/
|
|
397
414
|
setLegend(legend: LegendOptions): this;
|
|
415
|
+
setLegend(show: boolean, position?: LegendPosition, orientation?: LegendOrientation): this;
|
|
398
416
|
/**
|
|
399
417
|
* Configure data-gap handling. Accepts either the legacy `Gap[]` or the
|
|
400
418
|
* new `GapsConfig` (`{ regions?, autoDetect?, minGapMs?, style? }`).
|
|
@@ -447,6 +465,190 @@ declare class GraphBuilder {
|
|
|
447
465
|
*/
|
|
448
466
|
mount(target: HTMLElement | string): MLTimeGraph;
|
|
449
467
|
}
|
|
468
|
+
/**
|
|
469
|
+
* TimeSeriesBuilder simplifies constructing raw TimeSeries datasets.
|
|
470
|
+
*/
|
|
471
|
+
declare class TimeSeriesBuilder {
|
|
472
|
+
private _series;
|
|
473
|
+
constructor(name: string);
|
|
474
|
+
/** Appends a value-point to the series. */
|
|
475
|
+
addPoint(time: number, value: number | null): this;
|
|
476
|
+
/** Appends an array of data points directly to the series. */
|
|
477
|
+
addPoints(points: Array<{
|
|
478
|
+
time: number;
|
|
479
|
+
value: number | null;
|
|
480
|
+
}>): this;
|
|
481
|
+
/** Appends parallel arrays of timestamps and values to the series. */
|
|
482
|
+
addFloats(times: number[], values: Array<number | null>): this;
|
|
483
|
+
/** Appends a null point (signaling gaps/offline state). */
|
|
484
|
+
addNullPoint(time: number): this;
|
|
485
|
+
/** Assigns the visual styles configuration. */
|
|
486
|
+
setStyle(style: SeriesStyle): this;
|
|
487
|
+
/** Shortcut to apply custom stroke styling (color, width, dash style). */
|
|
488
|
+
setLineStyle(color: string, width: number, style?: LineVariant): this;
|
|
489
|
+
/** Configures spline interpolation (smoothing) on the series path. */
|
|
490
|
+
setSmoothing(smooth: boolean): this;
|
|
491
|
+
/** Assigns the area fill specification. */
|
|
492
|
+
setFill(fill: FillSpec): this;
|
|
493
|
+
/** Sets a custom identifier for the series path. */
|
|
494
|
+
setID(id: string): this;
|
|
495
|
+
/** Sets named thresholds to split and color the line segment. */
|
|
496
|
+
setColorByThresholds(thresholdNames: string[]): this;
|
|
497
|
+
/** Compiles and returns the TimeSeries object. */
|
|
498
|
+
build(): TimeSeries;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* ThresholdBuilder simplifies constructing value boundaries.
|
|
502
|
+
*/
|
|
503
|
+
declare class ThresholdBuilder {
|
|
504
|
+
private _threshold;
|
|
505
|
+
constructor(name: string, value: number);
|
|
506
|
+
/** Sets the threshold boundary color. */
|
|
507
|
+
setColor(color: string): this;
|
|
508
|
+
/** Configures the line type (solid, dashed, dotted, none). */
|
|
509
|
+
setLine(style: "solid" | "dashed" | "dotted" | "none"): this;
|
|
510
|
+
/** Configures half-plane fills (above, below, none) and opacity. */
|
|
511
|
+
setFill(fillType: "above" | "below" | "none", opacity: number): this;
|
|
512
|
+
/** Configures a hatch pattern style for the fill. */
|
|
513
|
+
setFillHatch(hatch: HatchVariant): this;
|
|
514
|
+
/** Configures the labels parameters. */
|
|
515
|
+
setLabel(text: string, position?: ThresholdLabelPosition): this;
|
|
516
|
+
/** Configures a unique ID for referencing the threshold. */
|
|
517
|
+
setID(id: string): this;
|
|
518
|
+
/** Compiles and returns the Threshold object. */
|
|
519
|
+
build(): Threshold;
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* MarkerBuilder simplifies constructing vertical pins/markers.
|
|
523
|
+
*/
|
|
524
|
+
declare class MarkerBuilder {
|
|
525
|
+
private _marker;
|
|
526
|
+
constructor(time: number);
|
|
527
|
+
/** Sets the marker value (for point markers). */
|
|
528
|
+
setValue(v: number): this;
|
|
529
|
+
/** Sets the text label. */
|
|
530
|
+
setLabel(lbl: string): this;
|
|
531
|
+
/** Sets the marker color. */
|
|
532
|
+
setColor(color: string): this;
|
|
533
|
+
/** Sets the shape of the point marker (circle, square, cross, star, arrow, none). */
|
|
534
|
+
setPointStyle(style: PointStyleType): this;
|
|
535
|
+
/** Sets the type of vertical projection line (full, to-value, to-top, none). */
|
|
536
|
+
setLineStyle(style: "full" | "to-value" | "to-top" | "none"): this;
|
|
537
|
+
/** Targets a specific series by index for interpolation. */
|
|
538
|
+
setSeriesIndex(idx: number): this;
|
|
539
|
+
/** Compiles and returns the Marker object. */
|
|
540
|
+
build(): Marker;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* HighlightBuilder simplifies constructing highlighted time bands.
|
|
544
|
+
*/
|
|
545
|
+
declare class HighlightBuilder {
|
|
546
|
+
private _highlight;
|
|
547
|
+
constructor(startTime: number, endTime: number);
|
|
548
|
+
/** Sets the text label. */
|
|
549
|
+
setLabel(lbl: string): this;
|
|
550
|
+
/** Sets the background color. */
|
|
551
|
+
setColor(color: string): this;
|
|
552
|
+
/** Sets the opacity. */
|
|
553
|
+
setOpacity(opacity: number): this;
|
|
554
|
+
/** Sets the label alignment (top, center, bottom, above, below). */
|
|
555
|
+
setLabelPosition(pos: "top" | "center" | "bottom" | "above" | "below"): this;
|
|
556
|
+
/** Sets the text rotation in degrees. */
|
|
557
|
+
setRotate(rotate: number): this;
|
|
558
|
+
/** Compiles and returns the Highlight object. */
|
|
559
|
+
build(): Highlight;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* AnnotationBuilder simplifies constructing free-form annotations.
|
|
563
|
+
*/
|
|
564
|
+
declare class AnnotationBuilder {
|
|
565
|
+
private _ann;
|
|
566
|
+
constructor(typ: "line" | "arrow" | "rect" | "point" | "label");
|
|
567
|
+
/** Sets a unique identifier. */
|
|
568
|
+
setID(id: string): this;
|
|
569
|
+
/** Sets the title (used for legend / toggles, not drawn). */
|
|
570
|
+
setTitle(title: string): this;
|
|
571
|
+
/** Sets the start point coordinate reference. */
|
|
572
|
+
setFrom(time: number, value: number, axis?: number): this;
|
|
573
|
+
/** Sets the end point coordinate reference. */
|
|
574
|
+
setTo(time: number, value: number, axis?: number): this;
|
|
575
|
+
/** Sets the coordinate reference position (for point/label). */
|
|
576
|
+
setAt(time: number, value: number, axis?: number): this;
|
|
577
|
+
/** Sets the primary stroke/text color. */
|
|
578
|
+
setColor(color: string): this;
|
|
579
|
+
/** Sets the stroke width. */
|
|
580
|
+
setWidth(w: number): this;
|
|
581
|
+
/** Sets the dash pattern ("dashed" | "dotted"). */
|
|
582
|
+
setDash(dash: "dashed" | "dotted"): this;
|
|
583
|
+
/** Sets the arrowhead size (arrow only). */
|
|
584
|
+
setHeadSize(size: number): this;
|
|
585
|
+
/** Sets the fill color. */
|
|
586
|
+
setFill(fill: string): this;
|
|
587
|
+
/** Sets the hatch pattern variant. */
|
|
588
|
+
setHatch(hatch: HatchVariant): this;
|
|
589
|
+
/** Sets the stroke color. */
|
|
590
|
+
setStroke(stroke: string): this;
|
|
591
|
+
/** Sets the opacity. */
|
|
592
|
+
setOpacity(opacity: number): this;
|
|
593
|
+
/** Sets the point radius (point only). */
|
|
594
|
+
setRadius(radius: number): this;
|
|
595
|
+
/** Sets the point shape (point only). */
|
|
596
|
+
setShape(shape: "circle" | "square" | "cross"): this;
|
|
597
|
+
/** Sets the label text (label only). */
|
|
598
|
+
setText(text: string): this;
|
|
599
|
+
/** Sets the text anchor (label only). */
|
|
600
|
+
setAnchor(anchor: "start" | "middle" | "end"): this;
|
|
601
|
+
/** Sets the horizontal offset (label only). */
|
|
602
|
+
setDx(dx: number): this;
|
|
603
|
+
/** Sets the vertical offset (label only). */
|
|
604
|
+
setDy(dy: number): this;
|
|
605
|
+
/** Sets the label rotation in degrees (label only). */
|
|
606
|
+
setRotate(rotate: number): this;
|
|
607
|
+
/** Compiles and returns the Annotation object. */
|
|
608
|
+
build(): Annotation;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* AnnotationBandBuilder simplifies constructing annotation bands below the chart.
|
|
612
|
+
*/
|
|
613
|
+
declare class AnnotationBandBuilder {
|
|
614
|
+
private _band;
|
|
615
|
+
constructor(name: string);
|
|
616
|
+
/** Sets the band height in pixels. */
|
|
617
|
+
setHeight(h: number): this;
|
|
618
|
+
/** Sets the vertical spacing between bands. */
|
|
619
|
+
setSpacing(s: number): this;
|
|
620
|
+
/** Sets a default hatch pattern variant for all items in the band. */
|
|
621
|
+
setHatch(hatch: HatchVariant): this;
|
|
622
|
+
/** Sets whether to draw a time axis under the band. */
|
|
623
|
+
setShowAxis(show: boolean): this;
|
|
624
|
+
/** Sets whether the band is listed in the chart legend. */
|
|
625
|
+
setShowInLegend(show: boolean): this;
|
|
626
|
+
/** Sets the background color of the band. */
|
|
627
|
+
setBackground(bg: string): this;
|
|
628
|
+
/** Adds an event range/item to the band. */
|
|
629
|
+
addItem(item: AnnotationBandItem): this;
|
|
630
|
+
/** Compiles and returns the AnnotationBandConfig object. */
|
|
631
|
+
build(): AnnotationBandConfig;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* AnnotationBandItemBuilder simplifies constructing annotation band event ranges.
|
|
635
|
+
*/
|
|
636
|
+
declare class AnnotationBandItemBuilder {
|
|
637
|
+
private _item;
|
|
638
|
+
constructor(startTime: number, endTime: number);
|
|
639
|
+
/** Sets the fill color. */
|
|
640
|
+
setFill(fill: string): this;
|
|
641
|
+
/** Sets the hatch pattern variant. */
|
|
642
|
+
setHatch(hatch: HatchVariant): this;
|
|
643
|
+
/** Sets the border stroke color. */
|
|
644
|
+
setStroke(stroke: string): this;
|
|
645
|
+
/** Sets the border stroke width. */
|
|
646
|
+
setStrokeWidth(w: number): this;
|
|
647
|
+
/** Sets the text label and optional label formatting fields. */
|
|
648
|
+
setLabel(lbl: string, fontSize?: number, fill?: string, baseline?: 'top' | 'middle' | 'bottom'): this;
|
|
649
|
+
/** Compiles and returns the AnnotationBandItem object. */
|
|
650
|
+
build(): AnnotationBandItem;
|
|
651
|
+
}
|
|
450
652
|
|
|
451
653
|
/*!
|
|
452
654
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
@@ -613,4 +815,4 @@ declare function getDefaultTheme(): Readonly<Theme>;
|
|
|
613
815
|
*/
|
|
614
816
|
declare function resetDefaultTheme(): void;
|
|
615
817
|
|
|
616
|
-
export { AggregatedPoint, AggregatedSeries, Annotation, AnnotationBandConfig, AnySeries, type AxesConfig, type AxisLabelsStyle, type AxisStyle, DataPoint, type FillBetweenThresholdsInput, FillSpec, Gap, GapsConfig, GraphBuilder, type GridLineStyle, type GridStyle, HatchVariant, Highlight, type LegendOptions, type LegendPosition, type LimitStatsPoint, MLTimeGraph, type MLTimeGraphOptions, type Margin, Marker, type MktPoint, SVGRenderer, type StatsAggregatedPoint, type StdDevPoint, type Theme, Threshold, type TickConfig, TimeSeries, type TooltipOptions, type TooltipSample, type XAxisConfig, type YAxisConfig, attachTooltip, fillBetweenThresholds, getDefaultTheme, mount, parseAggregated, parseDataPoint, parseSeries, resetDefaultTheme, setDefaultTheme };
|
|
818
|
+
export { AggregatedPoint, AggregatedSeries, Annotation, AnnotationBandBuilder, AnnotationBandConfig, AnnotationBandItem, AnnotationBandItemBuilder, AnnotationBuilder, AnySeries, type AxesConfig, type AxisLabelsStyle, type AxisStyle, DataPoint, type FillBetweenThresholdsInput, FillSpec, Gap, GapsConfig, GraphBuilder, type GridLineStyle, type GridStyle, HatchVariant, Highlight, HighlightBuilder, type LegendOptions, type LegendPosition, type LimitStatsPoint, MLTimeGraph, type MLTimeGraphOptions, type Margin, Marker, MarkerBuilder, type MktPoint, PointStyleType, SVGRenderer, SeriesStyle, type StatsAggregatedPoint, type StdDevPoint, type Theme, Threshold, ThresholdBuilder, ThresholdLabelPosition, type TickConfig, TimeSeries, TimeSeriesBuilder, type TooltipOptions, type TooltipSample, type XAxisConfig, type YAxisConfig, attachTooltip, fillBetweenThresholds, getDefaultTheme, mount, parseAggregated, parseDataPoint, parseSeries, resetDefaultTheme, setDefaultTheme };
|
package/dist/index.js
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
var
|
|
2
|
-
<pattern id="${
|
|
3
|
-
<rect width="10" height="10" fill="${
|
|
1
|
+
var nt=class r{_config;constructor(t){this._config=t;}compute(){let{width:t,height:e,margin:n}=this._config;return {totalWidth:t,totalHeight:e,chartWidth:t-n.left-n.right,chartHeight:e-n.top-n.bottom,chartX:n.left,chartY:n.top,margin:n}}static default(t=800,e=400){return new r({width:t,height:e,margin:{top:20,right:20,bottom:40,left:60}})}};function it(r){return r&&r.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}var U=class{#t;#e;constructor(t){this.#t=[...t.domain],this.#e=[...t.range];}map(t){let e=Number(t),[n,s]=this.#t,[i,o]=this.#e;return s===n?i:i+(e-n)/(s-n)*(o-i)}invert(t){let[e,n]=this.#t,[s,i]=this.#e;return i===s?e:e+(t-s)/(i-s)*(n-e)}domain(){return [...this.#t]}range(){return [...this.#e]}},G=[{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{#t;#e;constructor(t){this.#t=new U({domain:t.domain,range:t.range}),this.#e=t.locale||(typeof navigator<"u"?navigator.language:"en-US");}map(t){return this.#t.map(Number(t))}invert(t){return this.#t.invert(t)}domain(){return this.#t.domain()}range(){return this.#t.range()}get locale(){return this.#e}tickInterval(t,e=3,n=12){let[s,i]=this.#t.domain(),o=i-s;if(o<=0)return {interval:G[0].ms};let a=o/t,l=G[0].ms;for(let u of G)if(u.ms>=a){l=u.ms;break}let h=l,d=Math.round(o/h);for(;d>n&&h<G[G.length-1].ms;){let u=G.findIndex(m=>m.ms===h);h=G[Math.min(u+1,G.length-1)].ms,d=Math.round(o/h);}for(;d<e&&h>G[0].ms;){let u=G.findIndex(m=>m.ms===h);h=G[Math.max(u-1,0)].ms,d=Math.round(o/h);}return {interval:h}}ticks(t){let e=t?.minTicks??5,n=t?.maxTicks??12,{interval:s}=this.tickInterval((e+n)/2,e,n),[i,o]=this.#t.domain(),a=[],l=Math.ceil(i/s)*s;for(let h=l;h<=o;h+=s)a.push(h);return a}format(t,e){return new Intl.DateTimeFormat(this.#e,e).format(new Date(t))}};var c={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"]};function St(r,t="classic-diagonal",e="rgba(200, 220, 255, 0.3)",n="#4D88FF",s=2){if(t==="none")return `
|
|
2
|
+
<pattern id="${r}" width="10" height="10" patternUnits="userSpaceOnUse">
|
|
3
|
+
<rect width="10" height="10" fill="${e}" />
|
|
4
4
|
</pattern>
|
|
5
|
-
`.trim();let
|
|
6
|
-
<line x1="0" y1="0" x2="0" y2="${
|
|
7
|
-
<line x1="0" y1="0" x2="${
|
|
8
|
-
`;break;case "dots":
|
|
9
|
-
<path d="M 0 ${
|
|
10
|
-
fill="none" stroke="${
|
|
11
|
-
`;break;case "dashed":
|
|
12
|
-
<path d="M 0 0 L ${
|
|
13
|
-
fill="none" stroke="${
|
|
14
|
-
`;break;case "brick":
|
|
15
|
-
<path d="M 0 ${
|
|
16
|
-
fill="none" stroke="${
|
|
17
|
-
`;break;case "double-stripe":
|
|
18
|
-
<line x1="0" y1="0" x2="0" y2="${
|
|
19
|
-
<line x1="${
|
|
20
|
-
`;break;case "honeycomb":
|
|
21
|
-
<path d="M 0 0 L ${
|
|
22
|
-
fill="none" stroke="${
|
|
23
|
-
`;break}let h=`<rect width="${
|
|
24
|
-
<pattern id="${
|
|
5
|
+
`.trim();let i=12,o=12,a="rotate(0)",l="";switch(t){case "classic-diagonal":i=12,o=12,a="rotate(45)",l=`<line x1="0" y1="0" x2="0" y2="${o}" stroke="${n}" stroke-width="${s}" stroke-linecap="square" />`;break;case "dense-steep":i=6,o=6,a="rotate(30)",l=`<line x1="0" y1="0" x2="0" y2="${o}" stroke="${n}" stroke-width="${s}" stroke-linecap="square" />`;break;case "crosshatch":i=14,o=14,a="rotate(45)",l=`
|
|
6
|
+
<line x1="0" y1="0" x2="0" y2="${o}" stroke="${n}" stroke-width="${s}" stroke-linecap="square" />
|
|
7
|
+
<line x1="0" y1="0" x2="${i}" y2="0" stroke="${n}" stroke-width="${s}" stroke-linecap="square" />
|
|
8
|
+
`;break;case "dots":i=12,o=12,l=`<circle cx="${i/2}" cy="${o/2}" r="${s*1.2}" fill="${n}" />`;break;case "waves":i=16,o=16,l=`
|
|
9
|
+
<path d="M 0 ${o/2} Q ${i/4} 0, ${i/2} ${o/2} T ${i} ${o/2}"
|
|
10
|
+
fill="none" stroke="${n}" stroke-width="${s}" stroke-linecap="round" />
|
|
11
|
+
`;break;case "dashed":i=12,o=12,a="rotate(45)",l=`<line x1="0" y1="0" x2="0" y2="${o}" stroke="${n}" stroke-width="${s}" stroke-dasharray="3,3" />`;break;case "herringbone":i=16,o=16,l=`
|
|
12
|
+
<path d="M 0 0 L ${i/2} ${o/2} L 0 ${o} M ${i} 0 L ${i/2} ${o/2} L ${i} ${o}"
|
|
13
|
+
fill="none" stroke="${n}" stroke-width="${s}" stroke-linejoin="round" stroke-linecap="round" />
|
|
14
|
+
`;break;case "brick":i=20,o=20,l=`
|
|
15
|
+
<path d="M 0 ${o/2} L ${i} ${o/2} M 0 ${o} L ${i} ${o} M ${i/2} 0 L ${i/2} ${o/2} M 0 ${o/2} L 0 ${o}"
|
|
16
|
+
fill="none" stroke="${n}" stroke-width="${s}" />
|
|
17
|
+
`;break;case "double-stripe":i=16,o=16,a="rotate(45)",l=`
|
|
18
|
+
<line x1="0" y1="0" x2="0" y2="${o}" stroke="${n}" stroke-width="${s}" stroke-linecap="square" />
|
|
19
|
+
<line x1="${i/2}" y1="0" x2="${i/2}" y2="${o}" stroke="${n}" stroke-width="${s/2}" stroke-linecap="square" />
|
|
20
|
+
`;break;case "honeycomb":i=18,o=32,l=`
|
|
21
|
+
<path d="M 0 0 L ${i/2} 5 L ${i} 0 M 0 16 L ${i/2} 11 L ${i} 16 M 0 16 L 0 32 M ${i/2} 5 L ${i/2} 11 M ${i} 16 L ${i} 32 M 0 32 L ${i/2} 27 L ${i} 32 M ${i/2} 27 L ${i/2} 32"
|
|
22
|
+
fill="none" stroke="${n}" stroke-width="${s}" stroke-linejoin="round" stroke-linecap="round" />
|
|
23
|
+
`;break}let h=`<rect width="${i}" height="${o}" fill="${e}" />`;return `
|
|
24
|
+
<pattern id="${r}" width="${i}" height="${o}" patternTransform="${a}" patternUnits="userSpaceOnUse">
|
|
25
25
|
${h}
|
|
26
26
|
${l}
|
|
27
27
|
</pattern>
|
|
28
|
-
`.trim()}function Te(o,e=2){let t=e;switch(o){case "dotted":return {strokeDasharray:`0, ${t*2}`,strokeLinecap:"round"};case "sparse-dots":return {strokeDasharray:`0, ${t*4}`,strokeLinecap:"round"};case "dashed":return {strokeDasharray:`${t*3}, ${t*2}`,strokeLinecap:"butt"};case "long-dash":return {strokeDasharray:`${t*6}, ${t*3}`,strokeLinecap:"butt"};case "dense-dash":return {strokeDasharray:`${t*1.5}, ${t*1.5}`,strokeLinecap:"butt"};case "dash-dot":return {strokeDasharray:`${t*4}, ${t*2}, 0, ${t*2}`,strokeLinecap:"round"};case "dash-dot-dot":return {strokeDasharray:`${t*5}, ${t*2}, 0, ${t*2}, 0, ${t*2}`,strokeLinecap:"round"};case "loose-dash":return {strokeDasharray:`${t*3}, ${t*4}`,strokeLinecap:"butt"};default:return {strokeDasharray:"none",strokeLinecap:"butt"}}}var ie={axisColor:c.axisColor,tickColor:c.tickColor,textColor:c.textColor,textSize:c.textSize},Q=class{#e;#t;constructor(e){this.#e=new Z({domain:e.domain,range:e.xRange,locale:e.locale}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??ie).axisColor}get tickColor(){return (this.#t.colors??ie).tickColor}get textColor(){return (this.#t.colors??ie).textColor}get textSize(){return (this.#t.colors??ie).textSize}generateTicks(){let e=this.#t.minTicks??5,t=this.#t.maxTicks??12,r=this.#e.ticks({minTicks:e,maxTicks:t}).map(n=>({time:n,x:this.#e.map(n),label:this.tickLabel(n)}));return this.antiOverlap(r)}tickLabel(e){if(this.#t.format)return this.#t.format(new Date(e));let t=this.#t.minTicks??5,i=this.#t.maxTicks??12,{interval:r}=this.#e.tickInterval((t+i)/2,t,i),n={};return r<6e4?(n.hour="2-digit",n.minute="2-digit",n.second="2-digit"):r<36e5||r<864e5?(n.hour="2-digit",n.minute="2-digit"):r<31536e6?(n.day="numeric",n.month="short",r>=2592e6&&(n.day=void 0,n.month="long")):(n.year="numeric",r<2*31536e6&&(n.month="short")),this.#e.format(e,n)}antiOverlap(e){if(e.length<=1)return e;let t=60,i=[e[0]];for(let r=1;r<e.length;r++){let n=i[i.length-1].x;Math.abs(e[r].x-n)>=t&&i.push(e[r]);}return i}render(){let e=this.generateTicks(),t=this.#t.colors??ie,i=this.#t.y??0,r=[],[n]=this.#e.range();r.push({type:"line",x1:n,y1:i,x2:e[e.length-1]?.x??n,y2:i,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let s of e)r.push({type:"line",x1:s.x,y1:i,x2:s.x,y2:i+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),r.push({type:"text",content:s.label,x:s.x,y:i+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return r}};var oe={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function Ke(o){return Math.abs(o)>=1e6?`${(o/1e6).toFixed(1)}M`:Math.abs(o)>=1e3?`${(o/1e3).toFixed(1)}k`:Number.isInteger(o)?String(o):o.toFixed(1)}var ae=class{#e;#t;constructor(e){this.#e=new X({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??oe).axisColor}get tickColor(){return (this.#t.colors??oe).tickColor}get textColor(){return (this.#t.colors??oe).textColor}get textSize(){return (this.#t.colors??oe).textSize}generateTicks(){let e=this.#t.format??Ke,t=6,[i,r]=this.#e.domain(),n=r-i;if(n===0)return [{value:i,position:this.#e.map(i),label:e(i)}];let s=n/t,a=Math.pow(10,Math.floor(Math.log10(s))),l=s/a,h;l<=1.5?h=a:l<=3?h=2*a:l<=7?h=5*a:h=10*a;let m=[],u=Math.ceil(i/h)*h;for(let d=u;d<=r;d+=h)m.push({value:d,position:this.#e.map(d),label:e(d)});return m}render(){let e=this.generateTicks(),t=this.#t.colors??oe,i=this.#t.x??0,r=this.#t.orientation??"vertical",n=this.#t.position??"left",s=this.#t.suppressLabelsNear??[],a=this.#t.suppressTolerancePx??8,l=m=>s.some(u=>Math.abs(u-m)<=a),h=[];if(r==="vertical"){let[m,u]=this.#e.range();h.push({type:"line",x1:i,y1:m,x2:i,y2:u,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let d of e){let g=l(d.position);n==="left"?(h.push({type:"line",x1:i-4,y1:d.position,x2:i,y2:d.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||h.push({type:"text",content:d.label,x:i-8,y:d.position+4,anchor:"end",fontSize:11,fill:t.textColor})):(h.push({type:"line",x1:i,y1:d.position,x2:i+4,y2:d.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||h.push({type:"text",content:d.label,x:i+8,y:d.position+4,anchor:"start",fontSize:11,fill:t.textColor}));}}else {let[m,u]=this.#e.range();h.push({type:"line",x1:m,y1:i,x2:u,y2:i,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let d of e)h.push({type:"line",x1:d.position,y1:i,x2:d.position,y2:i+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),h.push({type:"text",content:d.label,x:d.position,y:i+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}return h}};var B=class{static interpolateDataPoint(o,e,t){return {time:o.time+t*(e.time-o.time),value:(o.value??0)+t*((e.value??0)-(o.value??0))}}static interpolateAggregatedPoint(o,e,t){let i=(r,n)=>r!==null&&n!==null?r+t*(n-r):null;return {time:o.time+t*(e.time-o.time),min:i(o.min,e.min),max:i(o.max,e.max),avg:i(o.avg,e.avg),count:Math.round(o.count+t*(e.count-o.count))}}static getRuns(o,e,t=0){let i=[...o].sort((a,l)=>a.time-l.time),r=[],n=[],s=null;for(let a of i){let l=e(a),h=t>0&&s&&a.time-s.time>t;(l||h)&&n.length&&(r.push(n),n=[]),l||n.push(a),s=a;}return n.length&&r.push(n),r}static splitByBoundaries(o,e,t,i){if(o.length===0)return [];if(e.length===0)return [{data:o,zoneIndex:0}];let r=[...e].sort((l,h)=>l-h),n=[],s=l=>{let h=0;for(let m=0;m<r.length&&l>=r[m];m++)h=m+1;return h},a=[o[0]];for(let l=1;l<o.length;l++){let h=o[l-1],m=o[l],u=t(h),d=t(m),g;d>u?g=r.filter(f=>f>u&&f<=d):d<u?g=r.filter(f=>f>=d&&f<u).reverse():g=[];for(let f of g){let x=(f-u)/(d-u),b=i(h,m,x);a.push(b),n.push({data:a,zoneIndex:s((u+f)/2)}),a=[b];}a.push(m);}if(a.length>0){let l=t(a[0]),h=t(a[a.length-1]);n.push({data:a,zoneIndex:s((l+h)/2)});}return n}static splitByThreshold(o,e,t,i){let r=this.splitByBoundaries(o,[e],t,i),n={above:[],below:[]};for(let s of r)s.zoneIndex===0?n.below.push(s.data):n.above.push(s.data);return n}};function $e(o,e=6e4){if(o.length<2)return [];let t=[...o].sort((r,n)=>r.time-n.time),i=[];for(let r=1;r<t.length;r++)t[r].time-t[r-1].time>e&&i.push({startTime:t[r-1].time,endTime:t[r].time});return i}function Ze(o,e=83144){let t=e/8.314,i=0,r=0;for(let s of o)s!==null&&(i+=Math.exp(-t/(s+273.15)),r++);if(r===0)return null;let n=i/r;return t/-Math.log(n)-273.15}function Me(o,e,t=83144){let i=new Array(o.length),r=0;for(let n=0;n<o.length;n++){let s=o[n].time,a=s-e;for(;r<n&&o[r].time<a;)r++;let l=o.slice(r,n+1).map(m=>m.value),h=Ze(l,t);i[n]={time:s,value:h,synthetic:true};}return i}function Qe(o){let e=0,t=0;for(let n of o)n!==null&&(e+=n,t++);if(t===0)return null;let i=e/t,r=0;for(let n of o){if(n===null)continue;let s=n-i;r+=s*s;}return Math.sqrt(r/t)}function Je(o){let e=0,t=0;for(let n of o)n!==null&&(e+=n,t++);if(t<2)return null;let i=e/t,r=0;for(let n of o){if(n===null)continue;let s=n-i;r+=s*s;}return Math.sqrt(r/(t-1))}function Ae(o,e,t=false){let i=new Array(o.length),r=0,n=t?Je:Qe;for(let s=0;s<o.length;s++){let a=o[s].time,l=a-e;for(;r<s&&o[r].time<l;)r++;let h=o.slice(r,s+1).map(u=>u.value),m=n(h);i[s]={time:a,value:m,synthetic:true};}return i}function De(o){return {id:o.id,line:{stroke:o.stroke??c.stroke,strokeWidth:o.strokeWidth??c.strokeWidth,smoothing:o.smoothing??false,dashed:o.dashed??false},fill:o.fill??c.areaFillAlpha,markers:{type:o.pointStyle??"none",size:o.pointSize??c.pointSize,stroke:o.stroke??c.stroke,fill:"#ffffff"},shadow:{color:o.shadowColor??"transparent",blur:o.shadowBlur??0,offsetX:o.shadowOffsetX??0,offsetY:o.shadowOffsetY??0}}}function le(o,e,t){let i=[],r=o.reduce((s,a)=>s+a.data.length,0),n=De(t);for(let s=0;s<o.length;s++){let a=o[s];a.data.length>=2?i.push({type:"path",id:t.id?`${t.id}-line-${s}`:void 0,points:a.data.map(l=>({x:e.timeScale.map(l.time),y:e.valueScale.map(l.value)})),stroke:a.color??n.line.stroke,strokeWidth:n.line.strokeWidth,smoothing:n.line.smoothing,dashed:n.line.dashed,shadowColor:n.shadow.color,shadowBlur:n.shadow.blur,shadowOffsetX:n.shadow.offsetX,shadowOffsetY:n.shadow.offsetY,fill:"none"}):a.data.length===1&&r===1&&i.push({type:"circle",cx:e.timeScale.map(a.data[0].time),cy:e.valueScale.map(a.data[0].value),r:Math.max(n.markers.size,n.line.strokeWidth),fill:a.color??n.line.stroke,shadowColor:n.shadow.color,shadowBlur:n.shadow.blur});}return i}function ye(o,e,t,i){if(o.length<2)return [];let r=B.splitByBoundaries(o,t.boundaries,t.getValue,t.interpolate),n=[];for(let s=0;s<r.length;s++){let a=r[s];if(a.data.length<2)continue;let l=t.getColor(a.zoneIndex);if(!l)continue;let h=a.data.map(u=>({x:e.timeScale.map(u.time),y:e.valueScale.map(t.yLow(u))})),m=a.data.map(u=>({x:e.timeScale.map(u.time),y:e.valueScale.map(t.yHigh(u))})).reverse();n.push({type:"path",id:i?.id?`${i.id}-fill-${s}`:void 0,points:[...h,...m],fill:l,hatch:t.getHatch?.(a.zoneIndex),stroke:"none"});}return n}function Le(o,e,t,i){let r=De(t);if(!r.markers.type||r.markers.type==="none")return [];let n=[];for(let s=0;s<o.length;s++){let a=o[s],l=e.timeScale.map(a.time),h=e.valueScale.map(a.value),m=i(a),u=t.pointStroke??m,d=t.pointFill??m,g=t.pointStrokeWidth??1.5,f=t.id?`${t.id}-marker-${s}`:void 0;et(n,f,r.markers.type,l,h,r.markers.size,u,d,g);}return n}function et(o,e,t,i,r,n,s,a,l){switch(t){case "circle":o.push({type:"circle",cx:i,cy:r,r:n,fill:a,stroke:s,strokeWidth:l,id:e});break;case "square":o.push({type:"rect",x:i-n,y:r-n,w:n*2,h:n*2,fill:a,stroke:s,strokeWidth:l,id:e});break;case "cross":o.push({type:"line",x1:i-n,y1:r-n,x2:i+n,y2:r+n,stroke:s,strokeWidth:l,id:e}),o.push({type:"line",x1:i-n,y1:r+n,x2:i+n,y2:r-n,stroke:s,strokeWidth:l,id:e});break;case "diamond":o.push({type:"path",points:[{x:i,y:r-n},{x:i+n,y:r},{x:i,y:r+n},{x:i-n,y:r}],fill:a,stroke:s,strokeWidth:l,id:e});break;case "triangle":o.push({type:"path",points:[{x:i,y:r-n},{x:i+n,y:r+n},{x:i-n,y:r+n}],fill:a,stroke:s,strokeWidth:l,id:e});break;case "star":{let h=[];for(let m=0;m<10;m++){let u=m%2===0?n:n*.5,d=Math.PI/2*3+m*Math.PI/5;h.push({x:i+u*Math.cos(d),y:r+u*Math.sin(d)});}o.push({type:"path",points:h,fill:a,stroke:s,strokeWidth:l,id:e});break}case "arrow":o.push({type:"path",points:[{x:i-n,y:r+n},{x:i,y:r-n},{x:i+n,y:r+n}],stroke:s,strokeWidth:l,fill:"none",id:e});break;default:o.push({type:"circle",cx:i,cy:r,r:n,fill:a,stroke:s,strokeWidth:l,id:e});}}var J=class o{#e;#t;static uidcnt=0;#n;constructor(e,t=[]){this.#e=e.id??"id"+Date.now+ ++o.uidcnt,this.#t=e.timeScale,this.#n=t;}get id(){return this.#e}get timeScale(){return this.#t}get data(){return this.#n}};var he=class extends J{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??c.minColor,i=e.maxColor??c.maxColor,r=e.avgColor??c.avgColor,n=e.avgDashed??true,s=e.smoothing??false,a=e.strokeWidth??c.strokeWidth,l=B.getRuns(this.data,u=>u.min===null||u.max===null||u.avg===null);if(l.length===0)return [];let h={timeScale:this.timeScale,valueScale:e.valueScale},m=[];for(let u of l)u.length<2||(e.fillToMax&&m.push(...ye(u,h,{boundaries:[],yLow:d=>d.avg,yHigh:d=>d.max,getValue:d=>d.avg,interpolate:B.interpolateAggregatedPoint,getColor:()=>e.fillToMax,getHatch:()=>e.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax`:void 0})),e.fillToMin&&m.push(...ye(u,h,{boundaries:[],yLow:d=>d.avg,yHigh:d=>d.min,getValue:d=>d.avg,interpolate:B.interpolateAggregatedPoint,getColor:()=>e.fillToMin,getHatch:()=>e.fillToMinHatch},{id:this.id?`${this.id}-fillToMin`:void 0})),m.push(...le([{data:u.map(d=>({time:d.time,value:d.max}))}],h,{stroke:i,strokeWidth:a,smoothing:s,id:this.id?`${this.id}-max`:void 0}),...le([{data:u.map(d=>({time:d.time,value:d.min}))}],h,{stroke:t,strokeWidth:a,smoothing:s,id:this.id?`${this.id}-min`:void 0}),...le([{data:u.map(d=>({time:d.time,value:d.avg}))}],h,{stroke:r,strokeWidth:a,smoothing:s,dashed:n,id:this.id?`${this.id}-avg`:void 0})));return m}};var me=class extends J{#e;constructor(e){super(e,e.data),this.#e=e;}opacity(e){if(!(this.#e.countOpacity??false))return .6;let t=Math.max(...this.data.map(i=>i.count));return t===0?.2:.2+.8*e/t}render(){let e=this.#e,t=e.fill??c.bandFill,i=e.hatch,r=e.avgLine??false,n=e.avgLineColor??c.bandAvgLine,s=e.bandWidth??10,a=[];for(let l of this.data){if(l.min===null||l.max===null)continue;let h=this.timeScale.map(l.time),m=e.valueScale.map(l.max),u=e.valueScale.map(l.min),d=s,g=this.data.indexOf(l);if(a.push({type:"rect",x:h-d/2,y:m,w:d,h:u-m,fill:t,hatch:i,opacity:this.opacity(l.count),id:this.id?`${this.id}-slot-${g}`:void 0}),r&&l.avg!==null){let f=e.valueScale.map(l.avg);a.push({type:"line",x1:h-d/2,y1:f,x2:h+d/2,y2:f,stroke:n,strokeWidth:1,id:this.id?`${this.id}-avg-${g}`:void 0});}}return a}};function tt(o){return o==="dotted"?{dash:"dotted"}:o==="dashed"?{dash:"dashed"}:{}}function Pe(o){let{thresholds:e,valueScale:t,xRange:i}=o,[r,n]=i,[s,a]=t.range(),l=Math.min(s,a),h=Math.max(s,a),m=[],u=[];for(let d of e){let g=d.color??c.thresholdColor,f=t.map(d.value);d.fill==="above"?m.push({type:"rect",x:r,y:l,w:n-r,h:Math.max(0,f-l),fill:g,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0}):d.fill==="below"&&m.push({type:"rect",x:r,y:f,w:n-r,h:Math.max(0,h-f),fill:g,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0});let x=d.line??c.thresholdLine;if(x!=="none"){let b=tt(x),k={type:"line",x1:r,y1:f,x2:n,y2:f,stroke:g,strokeWidth:1,...b,id:d.id?`${d.id}-line`:void 0};d.shadowColor&&(k.shadowColor=d.shadowColor,k.shadowBlur=d.shadowBlur??4,k.shadowOffsetX=d.shadowOffsetX??0,k.shadowOffsetY=d.shadowOffsetY??2),m.push(k);}if(d.label!==false){let b=d.label&&typeof d.label=="object"?d.label:void 0,k=typeof d.label=="string"?d.label:b?.text??d.name,v=b?.position??"right";u.push({...nt(k,v,r,n,f,g,b),id:d.id?`${d.id}-label`:void 0});}}return {inside:m,labels:u}}function nt(o,e,t,i,r,n,s){let a=(t+i)/2,l={type:"text",content:o,fontSize:c.thresholdFontSize,fill:n},h=s?{...s.rotate!==void 0&&{rotate:s.rotate},...s.textBaseline!==void 0&&{textBaseline:s.textBaseline}}:{};switch(e){case "left":return {...l,...h,x:t+4,y:r-4,anchor:"start"};case "above":return {...l,...h,x:a,y:r-6,anchor:"middle"};case "below":return {...l,...h,x:a,y:r+14,anchor:"middle"};case "center":return {...l,...h,x:a,y:r-4,anchor:"middle"};case "outside-left":return {...l,...h,x:t-6,y:r+3,anchor:"end",textBaseline:h.textBaseline??"middle"};case "outside-right":return {...l,...h,x:i+6,y:r+3,anchor:"start",textBaseline:h.textBaseline??"middle"};default:return {...l,...h,x:i-4,y:r-4,anchor:"end"}}}function Be(o){let{gaps:e,timeScale:t,yRange:i,fill:r=c.gapFill,hatch:n,fillOpacity:s=c.gapFillOpacity,stroke:a=c.gapStroke,strokeWidth:l=c.gapStrokeWidth,dashed:h=true,fontSize:m=c.gapFontSize,fontFill:u=c.gapFontColor,labelBaseline:d="middle",labelRotate:g}=o,[f,x]=i,b=[];for(let k of e){let v=t.map(k.startTime),H=t.map(k.endTime),A=k.fill??r,j=k.hatch??n,F=k.fillOpacity??s,W=k.label??"",O=k.rotate??g,M=k.labelBaseline??d;if(k.style==="dashed_border"||!k.style?b.push({type:"rect",x:v,y:f,w:H-v,h:x-f,fill:A,hatch:j,opacity:F,stroke:a,strokeWidth:l,dashed:h}):k.style==="empty"&&b.push({type:"rect",x:v,y:f,w:H-v,h:x-f,fill:A,hatch:j,opacity:F}),W){let y=it(f,x,M),_=M==="above"?"top":M==="below"?"bottom":"middle";b.push({type:"text",content:W,x:(v+H)/2,y,anchor:"middle",fontSize:m,fill:u,textBaseline:_,rotate:O});}}return b}function it(o,e,t){switch(t){case "above":return o-12;case "below":return e+4;default:return (o+e)/2}}var de=class{#e;constructor(e,t,i,r){this.#e={...e,xRange:t,y:i,height:r};}render(){let{items:e,timeScale:t,background:i,hatch:r,showAxis:n,xRange:s,y:a,height:l}=this.#e,h=[];i&&h.push({type:"rect",x:s[0],y:a,w:s[1]-s[0],h:l,fill:i,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let m of e){let u=t.map(m.startTime),d=t.map(m.endTime);d-u<1||(h.push({type:"rect",x:u,y:a,w:d-u,h:l,hatch:m.hatch??r,fill:m.fill??"#6b728044",stroke:m.stroke,strokeWidth:m.strokeWidth??0}),m.label&&h.push({type:"text",content:m.label,x:(u+d)/2,y:this.#t(m.labelBaseline),anchor:"middle",fontSize:m.labelFontSize??10,fill:m.labelFill??"#333",textBaseline:m.labelBaseline??"middle"}));}if(n){let m=new Q({domain:t.domain(),xRange:s,y:a+l+4});h.push({type:"group",cssClass:"annotation-band-axis",commands:m.render()});}return h}#t(e){let{y:t,height:i}=this.#e;switch(e){case "top":return t+1;case "bottom":return t+i-1;default:return t+i/2}}};function Fe(o){let{highlights:e,timeScale:t,yRange:i,height:r}=o,[n,s]=i,a=[];for(let l of e){let h=t.map(l.startTime),m=t.map(l.endTime);a.push({type:"rect",x:h,y:n,w:m-h,h:s-n,fill:l.color??c.highlightColor,opacity:l.opacity??c.highlightOpacity}),l.label&&a.push({type:"text",content:l.label,x:(h+m)/2,y:ot(l.labelPosition??"top",n,s,r),anchor:"middle",fontSize:c.annotationFontSize,fill:l.color??c.highlightLabelColor});}return a}function ot(o,e,t,i){switch(o){case "above":return e-5;case "below":return i!==void 0?i-5:t+14;case "center":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function We(o){let{markers:e,timeScale:t,valueScale:i,yRange:r=[0,300]}=o,[n,s]=r,a=[];for(let l of e){let h=t.map(l.time),m=l.color??c.markerColor,u=l.pointStyle??(l.value!==void 0?"circle":"none"),d=l.lineStyle??"full";if(l.value!==void 0){let g=i.map(l.value);if(d==="to-value"?a.push({type:"line",x1:h,y1:s,x2:h,y2:g,stroke:m,strokeWidth:1,dashed:true}):d==="to-top"?a.push({type:"line",x1:h,y1:n,x2:h,y2:g,stroke:m,strokeWidth:1,dashed:true}):d==="full"&&a.push({type:"line",x1:h,y1:n,x2:h,y2:s,stroke:m,strokeWidth:1}),u!=="none"&&rt(a,h,g,m,u),l.label){let f=d==="to-value"?g-10:n-6;a.push({type:"text",content:l.label,x:h,y:f,anchor:"middle",fontSize:11,fill:m});}}else a.push({type:"line",x1:h,y1:n,x2:h,y2:s,stroke:m,strokeWidth:1}),l.label&&a.push({type:"text",content:l.label,x:h,y:n-6,anchor:"middle",fontSize:11,fill:m});}return a}function rt(o,e,t,i,r){let n=c.markerSize;switch(r){case "circle":o.push({type:"circle",cx:e,cy:t,r:n,fill:i});break;case "square":o.push({type:"rect",x:e-n,y:t-n,w:n*2,h:n*2,fill:i});break;case "cross":o.push({type:"line",x1:e-n,y1:t-n,x2:e+n,y2:t+n,stroke:i,strokeWidth:2}),o.push({type:"line",x1:e-n,y1:t+n,x2:e+n,y2:t-n,stroke:i,strokeWidth:2});break;case "arrow":o.push({type:"path",points:[{x:e-n,y:t+n},{x:e,y:t-n},{x:e+n,y:t+n}],stroke:i,strokeWidth:2,fill:"none"});break;case "diamond":o.push({type:"path",points:[{x:e,y:t-n},{x:e+n,y:t},{x:e,y:t+n},{x:e-n,y:t}],fill:i,stroke:"none"});break;case "triangle":o.push({type:"path",points:[{x:e,y:t-n},{x:e+n,y:t+n},{x:e-n,y:t+n}],fill:i,stroke:"none"});break;case "star":{let s=[],a=n*.4;for(let l=0;l<10;l++){let h=l%2===0?n:a,m=Math.PI/2*3+l*Math.PI/5;s.push({x:e+h*Math.cos(m),y:t+h*Math.sin(m)});}o.push({type:"path",points:s,fill:i,stroke:"none"});break}case "plus":o.push({type:"line",x1:e-n,y1:t,x2:e+n,y2:t,stroke:i,strokeWidth:2}),o.push({type:"line",x1:e,y1:t-n,x2:e,y2:t+n,stroke:i,strokeWidth:2});break;case "triangle-down":o.push({type:"path",points:[{x:e,y:t+n},{x:e+n,y:t-n},{x:e-n,y:t-n}],fill:i,stroke:"none"});break;case "hexagon":{let s=[];for(let a=0;a<6;a++){let l=a*(Math.PI/3);s.push({x:e+n*Math.cos(l),y:t+n*Math.sin(l)});}o.push({type:"path",points:s,fill:i,stroke:"none"});break}case "hourglass":o.push({type:"path",points:[{x:e-n,y:t-n},{x:e+n,y:t-n},{x:e-n,y:t+n},{x:e+n,y:t+n}],fill:i,stroke:"none"});break;case "line-horizontal":o.push({type:"line",x1:e-n,y1:t,x2:e+n,y2:t,stroke:i,strokeWidth:2});break}}function Oe(o){let{annotations:e,timeScale:t,valueScales:i}=o,r=[],n=s=>{let a=i.get(s.axis??0)??i.values().next().value;return {x:t.map(s.time),y:a?a.map(s.value):0}};for(let s of e){let a=[],l=h=>a.push(h);switch(s.type){case "line":{let h=n(s.from),m=n(s.to);l({type:"line",x1:h.x,y1:h.y,x2:m.x,y2:m.y,stroke:s.color??c.annotationColor,strokeWidth:s.width??c.annotationWidth,dash:s.dash});break}case "arrow":{let h=n(s.from),m=n(s.to),u=s.color??c.annotationColor,d=s.headSize??c.annotationHead;l({type:"line",x1:h.x,y1:h.y,x2:m.x,y2:m.y,stroke:u,strokeWidth:s.width??c.annotationWidth});let g=Math.hypot(m.x-h.x,m.y-h.y)||1,f=(m.x-h.x)/g,x=(m.y-h.y)/g,b=m.x-f*d,k=m.y-x*d;l({type:"path",points:[{x:m.x,y:m.y},{x:b-x*d*.5,y:k+f*d*.5},{x:b+x*d*.5,y:k-f*d*.5}],fill:u,stroke:"none"});break}case "rect":{let h=n(s.from),m=n(s.to);l({type:"rect",x:Math.min(h.x,m.x),y:Math.min(h.y,m.y),w:Math.abs(m.x-h.x),h:Math.abs(m.y-h.y),fill:s.fill??"none",stroke:s.stroke,opacity:s.opacity});break}case "point":{let h=n(s.at),m=s.color??"#334155",u=s.radius??c.annotationRadius,d=s.shape??"circle";d==="circle"?l({type:"circle",cx:h.x,cy:h.y,r:u,fill:m}):d==="square"?l({type:"rect",x:h.x-u,y:h.y-u,w:u*2,h:u*2,fill:m}):(l({type:"line",x1:h.x-u,y1:h.y-u,x2:h.x+u,y2:h.y+u,stroke:m,strokeWidth:1.5}),l({type:"line",x1:h.x-u,y1:h.y+u,x2:h.x+u,y2:h.y-u,stroke:m,strokeWidth:1.5}));break}case "label":{let h=n(s.at);l({type:"text",content:s.text,x:h.x+(s.dx??0),y:h.y+(s.dy??0),anchor:s.anchor??"middle",fontSize:c.annotationFontSize,fill:s.color??c.annotationColor,rotate:s.rotate});break}}if(s.id&&a.length>0){let h=ne(s.id);r.push({type:"group",cssClass:`annotation annotation--${h}`,commands:a});}else r.push(...a);}return r}var q=12,ue=8,xe=20,st=11,be=18,Se=o=>o.length*st*.6;function Re(o,e="vertical"){if(e==="horizontal"){let i=0;for(let r of o)i+=q+ue+Se(r.name)+be;return {width:Math.max(0,i-be),height:xe}}let t=0;for(let i of o)t=Math.max(t,Se(i.name));return {width:q+ue+t,height:o.length*xe}}function je(o){let{items:e,x:t,y:i,orientation:r="vertical"}=o,n=[],s=t;return e.forEach((a,l)=>{let h=r==="horizontal"?s:t,m=r==="horizontal"?i:i+l*xe;n.push({type:"rect",x:h,y:m,w:q,h:q,fill:a.color,stroke:c.legendStroke,strokeWidth:1}),n.push({type:"text",content:a.name,x:h+q+ue,y:m+q-2,fontSize:c.legendFont,fill:c.legendText}),r==="horizontal"&&(s+=q+ue+Se(a.name)+be);}),{type:"group",cssClass:"chart-legend",commands:n}}function He(o){let{xTicks:e,yTicks:t,xRange:i,yRange:r,stroke:n=c.gridStroke,strokeWidth:s=c.gridStrokeWidth,dashed:a=false,opacity:l=c.gridOpacity}=o,h=[];if(t)for(let m of t)h.push({type:"line",x1:i[0],y1:m,x2:i[1],y2:m,stroke:n,strokeWidth:s,dashed:a,opacity:l});if(e)for(let m of e)h.push({type:"line",x1:m,y1:r[0],x2:m,y2:r[1],stroke:n,strokeWidth:s,dashed:a,opacity:l});return h}function Ie(o,e,t){let i=o??e;if(i==="series")return null;if(i==="chartTop")return t.chartTop;if(i==="chartBottom")return t.chartBottom;if(typeof i=="object"&&"threshold"in i){let r=t.thresholds.get(i.threshold);if(!r)throw new Error(`fillSpec region references unknown threshold '${i.threshold}'`);return t.valueScale.map(r.value)}return typeof i=="object"&&"value"in i?t.valueScale.map(i.value):null}function at(o){return typeof o=="string"?{color:o}:{color:o.color,hatch:o.hatch}}function Ge(o,e,t){let i=Ie(o.from,"chartBottom",e),r=Ie(o.to,"series",e),{color:n,hatch:s}=at(o.fill),a={type:"path",fill:n,hatch:s,stroke:"none",...e.idPrefix&&{id:`${e.idPrefix}-fill-r${t}`}};if(i!==null&&r!==null){let d=e.timeScale.range(),g=d[0],f=d[1],x=Math.min(i,r),b=Math.max(i,r);return [{...a,points:[{x:g,y:x},{x:f,y:x},{x:f,y:b},{x:g,y:b}]}]}let l=i??r,h=[],m=lt(o,e);if(m===null){let d=e.valueScale.domain();m=(i??r)===e.chartBottom?d[0]:d[1];}let u=Ee(o.outer,e);for(let d of e.runs){if(d.length<2)continue;let g=B.splitByThreshold(d,m,x=>x.value??m,B.interpolateDataPoint),f=o.side==="above"?g.above:o.side==="below"?g.below:[...g.above,...g.below];if(u!==null&&o.side){let x=o.side==="above"?"below":"above";f=f.flatMap(b=>{if(b.length<2)return [];let k=B.splitByThreshold(b,u,v=>v.value??u,B.interpolateDataPoint);return x==="above"?k.above:k.below});}for(let x of f){if(x.length<2)continue;let b=x.map(v=>({x:e.timeScale.map(v.time),y:e.valueScale.map(v.value)})),k=[...b].reverse().map(v=>({x:v.x,y:l}));h.push({...a,smoothing:e.smoothing,smoothCount:b.length,points:[...b,...k]});}}return h}function lt(o,e){let t=o.from==="series"?o.to:o.from;return Ee(t,e)}function Ee(o,e){return o===void 0||o==="series"||o==="chartTop"||o==="chartBottom"?null:typeof o=="object"&&"threshold"in o?e.thresholds.get(o.threshold)?.value??null:typeof o=="object"&&"value"in o?o.value:null}function ze(o,e){if(typeof o=="string"||!("regions"in o))return Ge({fill:o},e,0);let t=[];return o.regions.forEach((i,r)=>{t.push(...Ge(i,e,r));}),t}function Ne(o,e){let t=new Array(o.length),i=0;for(let r=0;r<o.length;r++){let n=o[r].time,s=n-e;for(;i<r&&o[i].time<s;)i++;let a=0,l=0;for(let h=i;h<=r;h++){let m=o[h].value;m!==null&&(a+=m,l++);}t[r]={time:n,value:l===0?null:a/l,synthetic:true};}return t}function Ye(o){let e=o.style?.line,t=e&&!Array.isArray(e)?e:void 0;return {color:t?.color??c.stroke,width:t?.width??c.strokeWidth,dash:t?.style,smoothing:t?.smoothing??false}}function Ve(o,e,t,i){let r=o.filter(l=>l.value!==null);if(r.length<2)return [];let n=r.map(l=>({x:e.timeScale.map(l.time),y:e.valueScale.map(l.value)})),s=Ye(t);return [{type:"path",id:e.idPrefix?`${e.idPrefix}-overlay-${i}`:`overlay-${i}`,points:n,stroke:s.color,strokeWidth:s.width,smoothing:s.smoothing,dash:s.dash,fill:"none"}]}function Xe(o,e){switch(o.kind){case "movingAverage":{o.type;let t=Ne(e.data,o.window);return Ve(t,e,o,"movingAvg")}case "movingMkt":{let t=Me(e.data,o.window,o.activationEnergy);return Ve(t,e,o,"movingMkt")}case "limits":{let t=[],i=e.timeScale.range(),r=i[0],n=i[1],s=Ye(o),a=s.color,l=s.width,h=s.dash??"dashed",m=e.idPrefix?`${e.idPrefix}-`:"";return o.high!==void 0&&t.push({type:"line",id:`${m}overlay-limit-high`,x1:r,y1:e.valueScale.map(o.high),x2:n,y2:e.valueScale.map(o.high),stroke:a,strokeWidth:l,dash:h}),o.low!==void 0&&t.push({type:"line",id:`${m}overlay-limit-low`,x1:r,y1:e.valueScale.map(o.low),x2:n,y2:e.valueScale.map(o.low),stroke:a,strokeWidth:l,dash:h}),t}case "stdDevBand":{let t=o.multiplier??1,i=Ne(e.data,o.window),r=Ae(e.data,o.window),n=[],s=[];for(let x=0;x<i.length;x++){let b=i[x].value,k=r[x].value;if(b===null||k===null)continue;let v=e.timeScale.map(i[x].time);n.push({x:v,y:e.valueScale.map(b+t*k)}),s.push({x:v,y:e.valueScale.map(b-t*k)});}if(n.length<2)return [];let a=e.idPrefix?`${e.idPrefix}-`:"",l=[],m=(typeof o.style?.fill=="string"||o.style?.fill&&!("regions"in o.style.fill)?o.style.fill:void 0)??"#94a3b833",{color:u,hatch:d}=ht(m);l.push({type:"path",id:`${a}overlay-stdDevBand`,points:[...n,...[...s].reverse()],fill:u,hatch:d,stroke:"none"});let g=o.style?.line,f=g&&!Array.isArray(g)?g:void 0;if(f){let x=i.filter(b=>b.value!==null).map(b=>({x:e.timeScale.map(b.time),y:e.valueScale.map(b.value)}));x.length>=2&&l.push({type:"path",id:`${a}overlay-stdDevBand-mean`,points:x,stroke:f.color??c.stroke,strokeWidth:f.width??1.5,smoothing:f.smoothing,dash:f.style,fill:"none"});}return l}}}function ht(o){return typeof o=="string"?{color:o}:{color:o.color,hatch:o.hatch}}function mt(o){if(!o)return {gaps:[],autoDetect:false,minGapMs:6e4};if(Array.isArray(o))return {gaps:o,autoDetect:false,minGapMs:6e4};let e=o.regions??[],t=o.style;return {gaps:e.map(r=>{let n={...t,...r.style},s=n.fill,a,l;return typeof s=="string"?a=s:s&&(a=s.color,l=s.hatch),{startTime:r.startTime,endTime:r.endTime,label:r.label,fill:a,hatch:l,fillOpacity:n.opacity,labelBaseline:n.label?.baseline,rotate:n.label?.rotate,style:n.display==="filled"||n.display==="bridge_line"?void 0:n.display}}),autoDetect:o.autoDetect??false,minGapMs:o.minGapMs??6e4}}function ce(o){return "showAs"in o&&!!o.showAs}var U=class{_layout;_renderer;_locale;_legend;_markers;_thresholds;_highlights;_gaps;_gapsAutoDetect;_gapsMinGapMs;_annotations;_annotationBands;_disabledAnnotations=new Set;_annotationSeq=0;_axes;_series;_annotationBandHeight=0;_timeScale;_valueScales=new Map;constructor(e={}){this._layout=new te({width:e.width??800,height:e.height??400,margin:e.margin??{top:20,right:20,bottom:40,left:60}}).compute(),this._renderer=e.renderer,this._locale=e.locale,this._legend=e.legend,this._markers=e.markers??[],this._thresholds=e.thresholds??[],this._highlights=e.highlights??[];let t=mt(e.gaps);this._gaps=t.gaps,this._gapsAutoDetect=t.autoDetect,this._gapsMinGapMs=t.minGapMs,this._annotations=e.annotations??[],this._annotationBands=e.annotationBands??[],this._axes=e.axes,this._series=[],e.series&&this.setData(e.series);}getWidth(){return this._layout.totalWidth}getHeight(){return this._layout.totalHeight+this._annotationBandTotalHeight()}get series(){return this._series}_annotationBandTotalHeight(){let e=0;for(let t of this._annotationBands){let i=t.height??12,r=t.spacing??0;(t.showAxis??false)&&(e+=26+r),e+=i+r;}return e}setData(e){this._series=e.filter(t=>Array.isArray(t.data));}addAnnotation(e){let t=e.id??`anno-${++this._annotationSeq}`;return this._annotations.push({...e,id:t}),t}removeAnnotation(e){let t=this._annotations.length;return this._annotations=this._annotations.filter(i=>i.id!==e),this._disabledAnnotations.delete(e),this._annotations.length<t}setAnnotations(e){this._annotations=[...e],this._disabledAnnotations.clear();}clearAnnotations(){this._annotations=[],this._disabledAnnotations.clear();}getAnnotations(){return this._annotations}disableAnnotation(e){this._disabledAnnotations.add(e);}enableAnnotation(e){this._disabledAnnotations.delete(e);}_axisIndexOf(e){return e.yAxisIndex??0}_timesOf(e){return e.data.map(t=>t.time)}_valuesOf(e){if(ce(e)){let t=[];for(let i of e.data)i.min!==null&&t.push(i.min),i.max!==null&&t.push(i.max);return t}return e.data.map(t=>t.value).filter(t=>t!==null)}renderCommands(){if(this._series.length===0)return [];let e=this._legendItems(),t=(this._legend?.show??false)&&e.length>0,i=this._legend?.position??"inside-right",r=this._legend?.orientation??"vertical",n=t?Re(e,r):{width:0},s=this._layout;if(t&&(i==="outside-right"||i==="outside-left")){let p=n.width+16,S={...this._layout.margin};i==="outside-right"?S.right+=p:S.left+=p,s=new te({width:this._layout.totalWidth,height:this._layout.totalHeight,margin:S}).compute();}let{chartX:a,chartY:l,chartWidth:h,chartHeight:m}=s,u=[a,a+h],d=[l,l+m],g=[];for(let p of this._series)p.data.sort((S,w)=>S.time-w.time);let f=new Map,x=1/0,b=-1/0,k=false;for(let p of this._series){let S=this._axisIndexOf(p),w=f.get(S);w?w.push(p):f.set(S,[p]);for(let C of this._timesOf(p))C<x&&(x=C),C>b&&(b=C),k=true;}if(!k)return [];let v=this._axes?.x?.domain,H=v&&v!=="auto"?v:[x,b];this._timeScale=new Z({domain:H,range:u,locale:this._locale});let A=p=>({axisColor:p?.color??c.axisColor,tickColor:p?.color??c.tickColor,textColor:c.textColor,textSize:c.textSize,axisWidth:p?.width}),j=new Q({domain:H,xRange:u,y:l+m,locale:this._locale,format:this._axes?.x?.format,maxTicks:this._axes?.x?.ticks?.major,colors:A(this._axes?.x?.axis)});this._valueScales.clear();let F=Array.from(f.keys()).sort((p,S)=>p-S),W;for(let p of F){let S=f.get(p),w=1/0,C=-1/0,$=false;for(let V of S)for(let se of this._valuesOf(V))se<w&&(w=se),se>C&&(C=se),$=true;if(!$)continue;let R=p===0?this._axes?.left:this._axes?.right,ee=R?.domain,K=ee&&ee!=="auto"?ee:[w,C],ve=new X({domain:K,range:[l+m,l]});this._valueScales.set(p,ve);let _e=this._thresholds.filter(V=>(V.axisIndex??0)===p&&V.label!==false&&V.value>=Math.min(K[0],K[1])&&V.value<=Math.max(K[0],K[1])).map(V=>ve.map(V.value)),Ce=new ae({domain:K,range:[l+m,l],x:p===0?a:a+h,position:p===0?"left":"right",format:R?.format,ticks:R?.ticks?.major,colors:A(R?.axis),suppressLabelsNear:_e.length?_e:void 0});p===0&&(W=Ce),g.push({type:"group",cssClass:`value-axis ${p===0?"left":"right"}`,commands:Ce.render()});}let O=this._valueScales.get(0)??this._valueScales.get(F[0]);g.push({type:"group",cssClass:"time-axis",commands:j.render()});let M=null,y=this._axes?.x?.grid?.major,_=this._axes?.left?.grid?.major;if(y!==void 0||_!==void 0){let p=y!==false,S=_!==false&&!!W,w=p?j.generateTicks().map($=>$.x):void 0,C=S?W.generateTicks().map($=>$.position):void 0;if(w||C){let $=(y&&typeof y=="object"?y:void 0)??(_&&typeof _=="object"?_:void 0);M={type:"group",cssClass:"chart-grid",commands:He({xTicks:w,yTicks:C,xRange:u,yRange:d,stroke:$?.color,opacity:$?.opacity,dashed:$?.style==="dashed"})};}}if(this._highlights.length>0&&g.push({type:"group",cssClass:"highlights",commands:Fe({highlights:this._highlights,timeScale:this._timeScale,yRange:d,height:s.totalHeight})}),this._thresholds.length>0&&O){let p=[],S=[];for(let w of this._thresholds){let C=w.id??ne(w.name),$=this._valueScales.get(w.axisIndex??0)??O,R=Pe({thresholds:[w],valueScale:$,xRange:u});R.inside.length&&p.push({type:"group",cssClass:`threshold threshold--${C}`,id:`threshold-${C}`,commands:R.inside}),R.labels.length&&S.push({type:"group",cssClass:`threshold-label threshold-label--${C}`,commands:R.labels});}p.length&&g.push({type:"group",cssClass:"thresholds",commands:p,clipRect:{x:a,y:l,w:h,h:m}}),S.length&&g.push({type:"group",cssClass:"threshold-labels",commands:S});}let T=this._gaps;if(this._gapsAutoDetect){let p=[];for(let S of this._series)ce(S)||p.push(...$e(S.data,this._gapsMinGapMs));p.length>0&&(T=[...this._gaps,...p]);}T.length>0&&g.push({type:"group",cssClass:"gaps",commands:Be({gaps:T,timeScale:this._timeScale,yRange:d})});let D=new Map(this._thresholds.map(p=>[p.name,p]));for(let p of this._series){if(p.data.length===0)continue;let S=this._valueScales.get(this._axisIndexOf(p));if(!S)continue;let w=p.id??ne(p.name);g.push({type:"group",cssClass:`series series--${w}`,id:`series-${w}`,commands:this._renderSeries(p,S,D)});}M&&g.push(M);let L=this._markers.map(p=>({...p}));for(let p of L)if(p.value===void 0&&(p.lineStyle==="to-value"||p.lineStyle==="to-top")){let S=this._series[p.seriesIndex??0];S&&!ce(S)&&S.data.length>=2&&(p.value=this._interpolateValue(p.time,S.data));}L.length>0&&O&&g.push({type:"group",cssClass:"markers",commands:We({markers:L,timeScale:this._timeScale,valueScale:O,yRange:d})});let G=this._annotations.filter(p=>!p.id||!this._disabledAnnotations.has(p.id));if(G.length>0&&g.push({type:"group",cssClass:"annotations",commands:Oe({annotations:G,timeScale:this._timeScale,valueScales:this._valueScales})}),this._annotationBands.length>0){let p=l+m+this._layout.margin.bottom,S=0;this._annotationBands.forEach(w=>{let C=w.height??12,$=w.spacing??0,R=p+S;(w.showAxis??false)&&(S+=26+$),S+=C+$,g.push({type:"group",cssClass:"annotation-band",commands:new de({name:w.name,showAxis:w.showAxis??false,items:w.items,timeScale:this._timeScale,background:w.background,hatch:w.hatch},[a,a+h],R,C).render()});});}if(t&&i!=="separate"){let p,S;i==="inside-right"?(p=a+h-n.width-8,S=l+8):i==="inside-left"?(p=a+8,S=l+8):i==="outside-right"?(p=a+h+16,S=l):(p=8,S=l),g.push(je({items:e,x:p,y:S,orientation:r}));}let E=this._axes?.left?.label,z=this._axes?.right?.label,P=this._axes?.x?.label;if(E||z||P){let p=[],S=l+m/2,w=this._axes?.left?.labels,C=this._axes?.right?.labels,$=this._axes?.x?.labels;E&&p.push({type:"text",content:E,x:14,y:S,anchor:"middle",fontSize:w?.fontSize??c.axisLabelSize,fill:w?.color??c.axisLabelColor,rotate:-90}),z&&p.push({type:"text",content:z,x:s.totalWidth-14,y:S,anchor:"middle",fontSize:C?.fontSize??c.axisLabelSize,fill:C?.color??c.axisLabelColor,rotate:90}),P&&p.push({type:"text",content:P,x:a+h/2,y:s.totalHeight-6,anchor:"middle",fontSize:$?.fontSize??c.axisLabelSize,fill:$?.color??c.axisLabelColor}),p.length&&g.push({type:"group",cssClass:"axis-labels",commands:p});}return g}_renderSeries(e,t,i){let r=this._timeScale,n={timeScale:r,valueScale:t};if(ce(e)){let y=e.style?.line&&!Array.isArray(e.style.line)?e.style.line:void 0,_=typeof e.style?.fill=="string"?e.style.fill:void 0;return e.showAs==="minmaxavg"?new he({data:e.data,timeScale:r,valueScale:t,minColor:e.minColor,maxColor:e.maxColor,avgColor:e.avgColor,avgDashed:e.avgDashed,fillToMax:e.fillToMax,fillToMaxHatch:e.fillToMaxHatch,fillToMin:e.fillToMin,fillToMinHatch:e.fillToMinHatch,smoothing:y?.smoothing,strokeWidth:y?.width,id:e.id}).render():new me({data:e.data,timeScale:r,valueScale:t,fill:_??y?.color,avgLine:e.avgLine,countOpacity:e.countOpacity,id:e.id}).render()}let s=e,a=e.style?.line&&!Array.isArray(e.style.line)?e.style.line:void 0,l=a?.gapThreshold??c.gapThreshold,h=B.getRuns(e.data,y=>y.value===null,l),m=h.reduce((y,_)=>y+_.length,0);if(m===0)return [];let u=[],d=e.style?.markers,g=e.style?.shadow,f={stroke:a?.color??c.stroke,strokeWidth:a?.width??c.strokeWidth,smoothing:a?.smoothing,dashed:a?.style==="dashed",pointStyle:d?.type,pointSize:d?.size,pointStroke:d?.stroke,pointFill:d?.fill,pointStrokeWidth:d?.strokeWidth,shadowColor:g?.color,shadowBlur:g?.blur,shadowOffsetX:g?.offsetX,shadowOffsetY:g?.offsetY,id:e.id},x=e.style?.line,b=x&&!Array.isArray(x)?x:void 0,k=b?.color,v=b?.width,H=b?.style,A=b?.smoothing,j=e.style?.fill;if(j!==void 0){let y=t.range(),_=Math.min(y[0],y[1]),T=Math.max(y[0],y[1]);u.push(...ze(j,{runs:h,timeScale:r,valueScale:t,thresholds:i,chartTop:_,chartBottom:T,smoothing:a?.smoothing,idPrefix:e.id}));}let F=s.colorByThresholds??[],W=F.map(y=>i.get(y)).filter(y=>!!y).map(y=>y.value).sort((y,_)=>y-_),O=(y,_)=>{let T=f.stroke;for(let D of _){let L=i.get(D);L&&y>=L.value&&(T=L.color??T);}return T};for(let y of h){if(y.length<2)continue;let _=B.splitByBoundaries(y,W,T=>T.value,B.interpolateDataPoint);for(let T=0;T<_.length;T++){let D=_[T];if(D.data.length<2)continue;let L=(D.data[0].value+D.data[D.data.length-1].value)/2,G=s.id,E=D.data.map(P=>({x:r.map(P.time),y:t.map(P.value)})),z=G?`${G}-line-${T}`:void 0;x===false||(x&&Array.isArray(x)?x.forEach((P,p)=>{u.push({type:"path",id:z?`${z}-${p}`:void 0,points:E,stroke:P.color??O(L,F),strokeWidth:P.width??f.strokeWidth,smoothing:P.smoothing??f.smoothing,dash:P.style,opacity:P.opacity,fill:"none",shadowColor:f.shadowColor,shadowBlur:f.shadowBlur,shadowOffsetX:f.shadowOffsetX,shadowOffsetY:f.shadowOffsetY});}):u.push({type:"path",id:z,points:E,stroke:k??O(L,F),strokeWidth:v??f.strokeWidth,smoothing:A??f.smoothing,dash:H,fill:"none",shadowColor:f.shadowColor,shadowBlur:f.shadowBlur,shadowOffsetX:f.shadowOffsetX,shadowOffsetY:f.shadowOffsetY}));}f.pointStyle&&f.pointStyle!=="none"&&m<=(d?.threshold??c.pointThreshold)&&u.push(...Le(y,n,f,T=>O(T.value,F)));}let M=e.overlays;if(M&&M.length>0){let y=t.range(),_={data:e.data,timeScale:r,valueScale:t,chartTop:Math.min(y[0],y[1]),chartBottom:Math.max(y[0],y[1]),idPrefix:e.id};for(let T of M)u.push(...Xe(T,_));}if(e.style?.gap&&h.length>1){let y=t.range(),_=Math.min(y[0],y[1]),T=Math.max(y[0],y[1]),D=e.style.gap,L=D.fill,G,E;typeof L=="string"?G=L:L&&(G=L.color,E=L.hatch);let z=D.opacity??.15,P=D.bridge;for(let p=1;p<h.length;p++){let S=h[p-1][h[p-1].length-1],w=h[p][0],C=r.map(S.time),$=r.map(w.time);if(D.display==="bridge_line"){if(S.value===null||w.value===null)continue;let R=t.map(S.value),ee=t.map(w.value);u.push({type:"line",x1:C,y1:R,x2:$,y2:ee,stroke:P?.color??(typeof e.style?.line=="object"&&!Array.isArray(e.style.line)?e.style.line.color:void 0)??c.stroke,strokeWidth:P?.width??1.5,dash:P?.style??"dotted"});}else G!==void 0?u.push({type:"rect",x:C,y:_,w:$-C,h:T-_,fill:G,hatch:E,opacity:z,stroke:"none"}):D.display!=="empty"&&u.push({type:"rect",x:C,y:_,w:$-C,h:T-_,stroke:c.gapStroke,strokeWidth:1,dashed:true,fill:"none"});}}return u}_interpolateValue(e,t){for(let i=1;i<t.length;i++){let r=t[i-1],n=t[i];if(!(r.value===null||n.value===null)&&e>=r.time&&e<=n.time){let s=(e-r.time)/(n.time-r.time);return r.value+s*(n.value-r.value)}}}legendItems(){return this._legendItems()}_legendItems(){return this._series.map(e=>{let t=e.style?.line&&!Array.isArray(e.style.line)?e.style.line:void 0;return {name:e.name,color:t?.color??c.stroke}})}get renderer(){return this._renderer}get layout(){return this._layout}get timeScale(){return this._timeScale}get valueScales(){return this._valueScales}invertTime(e){return this._timeScale?this._timeScale.invert(e):0}invertValue(e,t=0){let i=this._valueScales.get(t);return i?i.invert(e):0}project(e,t,i=0){let r=this._timeScale?this._timeScale.map(e):0,n=this._valueScales.get(i);return {x:r,y:n?n.map(t):0}}};var pe=class{};var N=1e3,Y=class extends pe{#e="100%";#t="100%";#n=new Map;#i=new Map;#o=new Map;constructor(e){super(),e?.width!==void 0&&(this.#e=e.width),e?.height!==void 0&&(this.#t=e.height);}render(e){this.#n.clear(),this.#i.clear(),this.#o.clear();let t=e.map(l=>this._toSVG(l)).join(`
|
|
29
|
-
`),
|
|
30
|
-
${
|
|
28
|
+
`.trim()}function Ht(r,t=2){let e=t;switch(r){case "dotted":return {strokeDasharray:`0, ${e*2}`,strokeLinecap:"round"};case "sparse-dots":return {strokeDasharray:`0, ${e*4}`,strokeLinecap:"round"};case "dashed":return {strokeDasharray:`${e*3}, ${e*2}`,strokeLinecap:"butt"};case "long-dash":return {strokeDasharray:`${e*6}, ${e*3}`,strokeLinecap:"butt"};case "dense-dash":return {strokeDasharray:`${e*1.5}, ${e*1.5}`,strokeLinecap:"butt"};case "dash-dot":return {strokeDasharray:`${e*4}, ${e*2}, 0, ${e*2}`,strokeLinecap:"round"};case "dash-dot-dot":return {strokeDasharray:`${e*5}, ${e*2}, 0, ${e*2}, 0, ${e*2}`,strokeLinecap:"round"};case "loose-dash":return {strokeDasharray:`${e*3}, ${e*4}`,strokeLinecap:"butt"};default:return {strokeDasharray:"none",strokeLinecap:"butt"}}}var rt={axisColor:c.axisColor,tickColor:c.tickColor,textColor:c.textColor,textSize:c.textSize},tt=class{#t;#e;constructor(t){this.#t=new J({domain:t.domain,range:t.xRange,locale:t.locale}),this.#e=t;}get scale(){return this.#t}get axisColor(){return (this.#e.colors??rt).axisColor}get tickColor(){return (this.#e.colors??rt).tickColor}get textColor(){return (this.#e.colors??rt).textColor}get textSize(){return (this.#e.colors??rt).textSize}generateTicks(){let t=this.#e.minTicks??5,e=this.#e.maxTicks??12,s=this.#t.ticks({minTicks:t,maxTicks:e}).map(i=>({time:i,x:this.#t.map(i),label:this.tickLabel(i)}));return this.antiOverlap(s)}tickLabel(t){if(this.#e.format)return this.#e.format(new Date(t));let e=this.#e.minTicks??5,n=this.#e.maxTicks??12,{interval:s}=this.#t.tickInterval((e+n)/2,e,n),i={};return s<6e4?(i.hour="2-digit",i.minute="2-digit",i.second="2-digit"):s<36e5||s<864e5?(i.hour="2-digit",i.minute="2-digit"):s<31536e6?(i.day="numeric",i.month="short",s>=2592e6&&(i.day=void 0,i.month="long")):(i.year="numeric",s<2*31536e6&&(i.month="short")),this.#t.format(t,i)}antiOverlap(t){if(t.length<=1)return t;let e=60,n=[t[0]];for(let s=1;s<t.length;s++){let i=n[n.length-1].x;Math.abs(t[s].x-i)>=e&&n.push(t[s]);}return n}render(){let t=this.generateTicks(),e=this.#e.colors??rt,n=this.#e.y??0,s=[],[i]=this.#t.range();s.push({type:"line",x1:i,y1:n,x2:t[t.length-1]?.x??i,y2:n,stroke:e.axisColor,strokeWidth:e.axisWidth});for(let o of t)s.push({type:"line",x1:o.x,y1:n,x2:o.x,y2:n+6,stroke:e.tickColor,strokeWidth:e.axisWidth}),s.push({type:"text",content:o.label,x:o.x,y:n+e.textSize+6,anchor:"middle",fontSize:e.textSize,fill:e.textColor});return s}};var st={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function ae(r){return Math.abs(r)>=1e6?`${(r/1e6).toFixed(1)}M`:Math.abs(r)>=1e3?`${(r/1e3).toFixed(1)}k`:Number.isInteger(r)?String(r):r.toFixed(1)}var lt=class{#t;#e;constructor(t){this.#t=new U({domain:t.domain,range:t.range}),this.#e=t;}get scale(){return this.#t}get axisColor(){return (this.#e.colors??st).axisColor}get tickColor(){return (this.#e.colors??st).tickColor}get textColor(){return (this.#e.colors??st).textColor}get textSize(){return (this.#e.colors??st).textSize}generateTicks(){let t=this.#e.format??ae,e=6,[n,s]=this.#t.domain(),i=s-n;if(i===0)return [{value:n,position:this.#t.map(n),label:t(n)}];let o=i/e,a=Math.pow(10,Math.floor(Math.log10(o))),l=o/a,h;l<=1.5?h=a:l<=3?h=2*a:l<=7?h=5*a:h=10*a;let d=[],u=Math.ceil(n/h)*h;for(let m=u;m<=s;m+=h)d.push({value:m,position:this.#t.map(m),label:t(m)});return d}render(){let t=this.generateTicks(),e=this.#e.colors??st,n=this.#e.x??0,s=this.#e.orientation??"vertical",i=this.#e.position??"left",o=this.#e.suppressLabelsNear??[],a=this.#e.suppressTolerancePx??8,l=d=>o.some(u=>Math.abs(u-d)<=a),h=[];if(s==="vertical"){let[d,u]=this.#t.range();h.push({type:"line",x1:n,y1:d,x2:n,y2:u,stroke:e.axisColor,strokeWidth:e.axisWidth});for(let m of t){let g=l(m.position);i==="left"?(h.push({type:"line",x1:n-4,y1:m.position,x2:n,y2:m.position,stroke:e.tickColor,strokeWidth:e.axisWidth}),g||h.push({type:"text",content:m.label,x:n-8,y:m.position+4,anchor:"end",fontSize:11,fill:e.textColor})):(h.push({type:"line",x1:n,y1:m.position,x2:n+4,y2:m.position,stroke:e.tickColor,strokeWidth:e.axisWidth}),g||h.push({type:"text",content:m.label,x:n+8,y:m.position+4,anchor:"start",fontSize:11,fill:e.textColor}));}}else {let[d,u]=this.#t.range();h.push({type:"line",x1:d,y1:n,x2:u,y2:n,stroke:e.axisColor,strokeWidth:e.axisWidth});for(let m of t)h.push({type:"line",x1:m.position,y1:n,x2:m.position,y2:n+6,stroke:e.tickColor,strokeWidth:e.axisWidth}),h.push({type:"text",content:m.label,x:m.position,y:n+18,anchor:"middle",fontSize:e.textSize,fill:e.textColor});}return h}};var F=class{static interpolateDataPoint(r,t,e){return {time:r.time+e*(t.time-r.time),value:(r.value??0)+e*((t.value??0)-(r.value??0))}}static interpolateAggregatedPoint(r,t,e){let n=(s,i)=>s!==null&&i!==null?s+e*(i-s):null;return {time:r.time+e*(t.time-r.time),min:n(r.min,t.min),max:n(r.max,t.max),avg:n(r.avg,t.avg),count:Math.round(r.count+e*(t.count-r.count))}}static getRuns(r,t,e=0){let n=[...r].sort((a,l)=>a.time-l.time),s=[],i=[],o=null;for(let a of n){let l=t(a),h=e>0&&o&&a.time-o.time>e;(l||h)&&i.length&&(s.push(i),i=[]),l||i.push(a),o=a;}return i.length&&s.push(i),s}static splitByBoundaries(r,t,e,n){if(r.length===0)return [];if(t.length===0)return [{data:r,zoneIndex:0}];let s=[...t].sort((l,h)=>l-h),i=[],o=l=>{let h=0;for(let d=0;d<s.length&&l>=s[d];d++)h=d+1;return h},a=[r[0]];for(let l=1;l<r.length;l++){let h=r[l-1],d=r[l],u=e(h),m=e(d),g;m>u?g=s.filter(p=>p>u&&p<=m):m<u?g=s.filter(p=>p>=m&&p<u).reverse():g=[];for(let p of g){let b=(p-u)/(m-u),S=n(h,d,b);a.push(S),i.push({data:a,zoneIndex:o((u+p)/2)}),a=[S];}a.push(d);}if(a.length>0){let l=e(a[0]),h=e(a[a.length-1]);i.push({data:a,zoneIndex:o((l+h)/2)});}return i}static splitByThreshold(r,t,e,n){let s=this.splitByBoundaries(r,[t],e,n),i={above:[],below:[]};for(let o of s)o.zoneIndex===0?i.below.push(o.data):i.above.push(o.data);return i}};function Ot(r,t=6e4){if(r.length<2)return [];let e=[...r].sort((s,i)=>s.time-i.time),n=[];for(let s=1;s<e.length;s++)e[s].time-e[s-1].time>t&&n.push({startTime:e[s-1].time,endTime:e[s].time});return n}function le(r,t=83144){let e=t/8.314,n=0,s=0;for(let o of r)o!==null&&(n+=Math.exp(-e/(o+273.15)),s++);if(s===0)return null;let i=n/s;return e/-Math.log(i)-273.15}function jt(r,t,e=83144){let n=new Array(r.length),s=0;for(let i=0;i<r.length;i++){let o=r[i].time,a=o-t;for(;s<i&&r[s].time<a;)s++;let l=r.slice(s,i+1).map(d=>d.value),h=le(l,e);n[i]={time:o,value:h,synthetic:true};}return n}function he(r){let t=0,e=0;for(let i of r)i!==null&&(t+=i,e++);if(e===0)return null;let n=t/e,s=0;for(let i of r){if(i===null)continue;let o=i-n;s+=o*o;}return Math.sqrt(s/e)}function de(r){let t=0,e=0;for(let i of r)i!==null&&(t+=i,e++);if(e<2)return null;let n=t/e,s=0;for(let i of r){if(i===null)continue;let o=i-n;s+=o*o;}return Math.sqrt(s/(e-1))}function It(r,t,e=false){let n=new Array(r.length),s=0,i=e?de:he;for(let o=0;o<r.length;o++){let a=r[o].time,l=a-t;for(;s<o&&r[s].time<l;)s++;let h=r.slice(s,o+1).map(u=>u.value),d=i(h);n[o]={time:a,value:d,synthetic:true};}return n}function Gt(r){return {id:r.id,line:{stroke:r.stroke??c.stroke,strokeWidth:r.strokeWidth??c.strokeWidth,smoothing:r.smoothing??false,dashed:r.dashed??false},fill:r.fill??c.areaFillAlpha,markers:{type:r.pointStyle??"none",size:r.pointSize??c.pointSize,stroke:r.stroke??c.stroke,fill:"#ffffff"},shadow:{color:r.shadowColor??"transparent",blur:r.shadowBlur??0,offsetX:r.shadowOffsetX??0,offsetY:r.shadowOffsetY??0}}}function ht(r,t,e){let n=[],s=r.reduce((o,a)=>o+a.data.length,0),i=Gt(e);for(let o=0;o<r.length;o++){let a=r[o];a.data.length>=2?n.push({type:"path",id:e.id?`${e.id}-line-${o}`:void 0,points:a.data.map(l=>({x:t.timeScale.map(l.time),y:t.valueScale.map(l.value)})),stroke:a.color??i.line.stroke,strokeWidth:i.line.strokeWidth,smoothing:i.line.smoothing,dashed:i.line.dashed,shadowColor:i.shadow.color,shadowBlur:i.shadow.blur,shadowOffsetX:i.shadow.offsetX,shadowOffsetY:i.shadow.offsetY,fill:"none"}):a.data.length===1&&s===1&&n.push({type:"circle",cx:t.timeScale.map(a.data[0].time),cy:t.valueScale.map(a.data[0].value),r:Math.max(i.markers.size,i.line.strokeWidth),fill:a.color??i.line.stroke,shadowColor:i.shadow.color,shadowBlur:i.shadow.blur});}return n}function kt(r,t,e,n){if(r.length<2)return [];let s=F.splitByBoundaries(r,e.boundaries,e.getValue,e.interpolate),i=[];for(let o=0;o<s.length;o++){let a=s[o];if(a.data.length<2)continue;let l=e.getColor(a.zoneIndex);if(!l)continue;let h=a.data.map(u=>({x:t.timeScale.map(u.time),y:t.valueScale.map(e.yLow(u))})),d=a.data.map(u=>({x:t.timeScale.map(u.time),y:t.valueScale.map(e.yHigh(u))})).reverse();i.push({type:"path",id:n?.id?`${n.id}-fill-${o}`:void 0,points:[...h,...d],fill:l,hatch:e.getHatch?.(a.zoneIndex),stroke:"none"});}return i}function Et(r,t,e,n){let s=Gt(e);if(!s.markers.type||s.markers.type==="none")return [];let i=[];for(let o=0;o<r.length;o++){let a=r[o],l=t.timeScale.map(a.time),h=t.valueScale.map(a.value),d=n(a),u=e.pointStroke??d,m=e.pointFill??d,g=e.pointStrokeWidth??1.5,p=e.id?`${e.id}-marker-${o}`:void 0;me(i,p,s.markers.type,l,h,s.markers.size,u,m,g);}return i}function me(r,t,e,n,s,i,o,a,l){switch(e){case "circle":r.push({type:"circle",cx:n,cy:s,r:i,fill:a,stroke:o,strokeWidth:l,id:t});break;case "square":r.push({type:"rect",x:n-i,y:s-i,w:i*2,h:i*2,fill:a,stroke:o,strokeWidth:l,id:t});break;case "cross":r.push({type:"line",x1:n-i,y1:s-i,x2:n+i,y2:s+i,stroke:o,strokeWidth:l,id:t}),r.push({type:"line",x1:n-i,y1:s+i,x2:n+i,y2:s-i,stroke:o,strokeWidth:l,id:t});break;case "diamond":r.push({type:"path",points:[{x:n,y:s-i},{x:n+i,y:s},{x:n,y:s+i},{x:n-i,y:s}],fill:a,stroke:o,strokeWidth:l,id:t});break;case "triangle":r.push({type:"path",points:[{x:n,y:s-i},{x:n+i,y:s+i},{x:n-i,y:s+i}],fill:a,stroke:o,strokeWidth:l,id:t});break;case "star":{let h=[];for(let d=0;d<10;d++){let u=d%2===0?i:i*.5,m=Math.PI/2*3+d*Math.PI/5;h.push({x:n+u*Math.cos(m),y:s+u*Math.sin(m)});}r.push({type:"path",points:h,fill:a,stroke:o,strokeWidth:l,id:t});break}case "arrow":r.push({type:"path",points:[{x:n-i,y:s+i},{x:n,y:s-i},{x:n+i,y:s+i}],stroke:o,strokeWidth:l,fill:"none",id:t});break;default:r.push({type:"circle",cx:n,cy:s,r:i,fill:a,stroke:o,strokeWidth:l,id:t});}}var et=class r{#t;#e;static uidcnt=0;#n;constructor(t,e=[]){this.#t=t.id??"id"+Date.now+ ++r.uidcnt,this.#e=t.timeScale,this.#n=e;}get id(){return this.#t}get timeScale(){return this.#e}get data(){return this.#n}};var dt=class extends et{#t;constructor(t){super(t,t.data),this.#t=t;}render(){let t=this.#t,e=t.minColor??c.minColor,n=t.maxColor??c.maxColor,s=t.avgColor??c.avgColor,i=t.avgDashed??true,o=t.smoothing??false,a=t.strokeWidth??c.strokeWidth,l=F.getRuns(this.data,u=>u.min===null||u.max===null||u.avg===null);if(l.length===0)return [];let h={timeScale:this.timeScale,valueScale:t.valueScale},d=[];for(let u of l)u.length<2||(t.fillToMax&&d.push(...kt(u,h,{boundaries:[],yLow:m=>m.avg,yHigh:m=>m.max,getValue:m=>m.avg,interpolate:F.interpolateAggregatedPoint,getColor:()=>t.fillToMax,getHatch:()=>t.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax`:void 0})),t.fillToMin&&d.push(...kt(u,h,{boundaries:[],yLow:m=>m.avg,yHigh:m=>m.min,getValue:m=>m.avg,interpolate:F.interpolateAggregatedPoint,getColor:()=>t.fillToMin,getHatch:()=>t.fillToMinHatch},{id:this.id?`${this.id}-fillToMin`:void 0})),d.push(...ht([{data:u.map(m=>({time:m.time,value:m.max}))}],h,{stroke:n,strokeWidth:a,smoothing:o,id:this.id?`${this.id}-max`:void 0}),...ht([{data:u.map(m=>({time:m.time,value:m.min}))}],h,{stroke:e,strokeWidth:a,smoothing:o,id:this.id?`${this.id}-min`:void 0}),...ht([{data:u.map(m=>({time:m.time,value:m.avg}))}],h,{stroke:s,strokeWidth:a,smoothing:o,dashed:i,id:this.id?`${this.id}-avg`:void 0})));return d}};var mt=class extends et{#t;constructor(t){super(t,t.data),this.#t=t;}opacity(t){if(!(this.#t.countOpacity??false))return .6;let e=Math.max(...this.data.map(n=>n.count));return e===0?.2:.2+.8*t/e}render(){let t=this.#t,e=t.fill??c.bandFill,n=t.hatch,s=t.avgLine??false,i=t.avgLineColor??c.bandAvgLine,o=t.bandWidth??10,a=[];for(let l of this.data){if(l.min===null||l.max===null)continue;let h=this.timeScale.map(l.time),d=t.valueScale.map(l.max),u=t.valueScale.map(l.min),m=o,g=this.data.indexOf(l);if(a.push({type:"rect",x:h-m/2,y:d,w:m,h:u-d,fill:e,hatch:n,opacity:this.opacity(l.count),id:this.id?`${this.id}-slot-${g}`:void 0}),s&&l.avg!==null){let p=t.valueScale.map(l.avg);a.push({type:"line",x1:h-m/2,y1:p,x2:h+m/2,y2:p,stroke:i,strokeWidth:1,id:this.id?`${this.id}-avg-${g}`:void 0});}}return a}};function ue(r){return r==="dotted"?{dash:"dotted"}:r==="dashed"?{dash:"dashed"}:{}}function Vt(r){let{thresholds:t,valueScale:e,xRange:n}=r,[s,i]=n,[o,a]=e.range(),l=Math.min(o,a),h=Math.max(o,a),d=[],u=[];for(let m of t){let g=m.color??c.thresholdColor,p=e.map(m.value);m.fill==="above"?d.push({type:"rect",x:s,y:l,w:i-s,h:Math.max(0,p-l),fill:g,hatch:m.fillHatch,opacity:m.fillOpacity??.12,id:m.id?`${m.id}-fill`:void 0}):m.fill==="below"&&d.push({type:"rect",x:s,y:p,w:i-s,h:Math.max(0,h-p),fill:g,hatch:m.fillHatch,opacity:m.fillOpacity??.12,id:m.id?`${m.id}-fill`:void 0});let b=m.line??c.thresholdLine;if(b!=="none"){let S=ue(b),k={type:"line",x1:s,y1:p,x2:i,y2:p,stroke:g,strokeWidth:1,...S,id:m.id?`${m.id}-line`:void 0};m.shadowColor&&(k.shadowColor=m.shadowColor,k.shadowBlur=m.shadowBlur??4,k.shadowOffsetX=m.shadowOffsetX??0,k.shadowOffsetY=m.shadowOffsetY??2),d.push(k);}if(m.label!==false){let S=m.label&&typeof m.label=="object"?m.label:void 0,k=typeof m.label=="string"?m.label:S?.text??m.name,w=S?.position??"right";u.push({...ce(k,w,s,i,p,g,S),id:m.id?`${m.id}-label`:void 0});}}return {inside:d,labels:u}}function ce(r,t,e,n,s,i,o){let a=(e+n)/2,l={type:"text",content:r,fontSize:c.thresholdFontSize,fill:i},h=o?{...o.rotate!==void 0&&{rotate:o.rotate},...o.textBaseline!==void 0&&{textBaseline:o.textBaseline}}:{};switch(t){case "left":return {...l,...h,x:e+4,y:s-4,anchor:"start"};case "above":return {...l,...h,x:a,y:s-6,anchor:"middle"};case "below":return {...l,...h,x:a,y:s+14,anchor:"middle"};case "center":return {...l,...h,x:a,y:s-4,anchor:"middle"};case "outside-left":return {...l,...h,x:e-6,y:s+3,anchor:"end",textBaseline:h.textBaseline??"middle"};case "outside-right":return {...l,...h,x:n+6,y:s+3,anchor:"start",textBaseline:h.textBaseline??"middle"};default:return {...l,...h,x:n-4,y:s-4,anchor:"end"}}}function zt(r){let{gaps:t,timeScale:e,yRange:n,fill:s=c.gapFill,hatch:i,fillOpacity:o=c.gapFillOpacity,stroke:a=c.gapStroke,strokeWidth:l=c.gapStrokeWidth,dashed:h=true,fontSize:d=c.gapFontSize,fontFill:u=c.gapFontColor,labelBaseline:m="middle",labelRotate:g}=r,[p,b]=n,S=[];for(let k of t){let w=e.map(k.startTime),O=e.map(k.endTime),L=k.fill??s,H=k.hatch??i,W=k.fillOpacity??o,R=k.label??"",j=k.rotate??g,$=k.labelBaseline??m;if(k.style==="dashed_border"||!k.style?S.push({type:"rect",x:w,y:p,w:O-w,h:b-p,fill:L,hatch:H,opacity:W,stroke:a,strokeWidth:l,dashed:h}):k.style==="empty"&&S.push({type:"rect",x:w,y:p,w:O-w,h:b-p,fill:L,hatch:H,opacity:W}),R){let y=pe(p,b,$),v=$==="above"?"top":$==="below"?"bottom":"middle";S.push({type:"text",content:R,x:(w+O)/2,y,anchor:"middle",fontSize:d,fill:u,textBaseline:v,rotate:j});}}return S}function pe(r,t,e){switch(e){case "above":return r-12;case "below":return t+4;default:return (r+t)/2}}var ut=class{#t;constructor(t,e,n,s){this.#t={...t,xRange:e,y:n,height:s};}render(){let{items:t,timeScale:e,background:n,hatch:s,showAxis:i,xRange:o,y:a,height:l}=this.#t,h=[];n&&h.push({type:"rect",x:o[0],y:a,w:o[1]-o[0],h:l,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let d of t){let u=e.map(d.startTime),m=e.map(d.endTime);m-u<1||(h.push({type:"rect",x:u,y:a,w:m-u,h:l,hatch:d.hatch??s,fill:d.fill??"#6b728044",stroke:d.stroke,strokeWidth:d.strokeWidth??0}),d.label&&h.push({type:"text",content:d.label,x:(u+m)/2,y:this.#e(d.labelBaseline),anchor:"middle",fontSize:d.labelFontSize??10,fill:d.labelFill??"#333",textBaseline:d.labelBaseline??"middle"}));}if(i){let d=new tt({domain:e.domain(),xRange:o,y:a+l+4});h.push({type:"group",cssClass:"annotation-band-axis",commands:d.render()});}return h}#e(t){let{y:e,height:n}=this.#t;switch(t){case "top":return e+1;case "bottom":return e+n-1;default:return e+n/2}}};function Nt(r){let{highlights:t,timeScale:e,yRange:n,height:s}=r,[i,o]=n,a=[];for(let l of t){let h=e.map(l.startTime),d=e.map(l.endTime);a.push({type:"rect",x:h,y:i,w:d-h,h:o-i,fill:l.color??c.highlightColor,opacity:l.opacity??c.highlightOpacity}),l.label&&a.push({type:"text",content:l.label,x:(h+d)/2,y:fe(l.labelPosition??"top",i,o,s),anchor:"middle",fontSize:c.annotationFontSize,fill:l.color??c.highlightLabelColor,rotate:l.rotate});}return a}function fe(r,t,e,n){switch(r){case "above":return t-5;case "below":return n!==void 0?n-5:e+14;case "center":return (t+e)/2+4;case "bottom":return e-6;default:return t+14}}function Yt(r){let{markers:t,timeScale:e,valueScale:n,yRange:s=[0,300]}=r,[i,o]=s,a=[];for(let l of t){let h=e.map(l.time),d=l.color??c.markerColor,u=l.pointStyle??(l.value!==void 0?"circle":"none"),m=l.lineStyle??"full";if(l.value!==void 0){let g=n.map(l.value);if(m==="to-value"?a.push({type:"line",x1:h,y1:o,x2:h,y2:g,stroke:d,strokeWidth:1,dashed:true}):m==="to-top"?a.push({type:"line",x1:h,y1:i,x2:h,y2:g,stroke:d,strokeWidth:1,dashed:true}):m==="full"&&a.push({type:"line",x1:h,y1:i,x2:h,y2:o,stroke:d,strokeWidth:1}),u!=="none"&&ge(a,h,g,d,u),l.label){let p=m==="to-value"?g-10:i-6;a.push({type:"text",content:l.label,x:h,y:p,anchor:"middle",fontSize:11,fill:d});}}else a.push({type:"line",x1:h,y1:i,x2:h,y2:o,stroke:d,strokeWidth:1}),l.label&&a.push({type:"text",content:l.label,x:h,y:i-6,anchor:"middle",fontSize:11,fill:d});}return a}function ge(r,t,e,n,s){let i=c.markerSize;switch(s){case "circle":r.push({type:"circle",cx:t,cy:e,r:i,fill:n});break;case "square":r.push({type:"rect",x:t-i,y:e-i,w:i*2,h:i*2,fill:n});break;case "cross":r.push({type:"line",x1:t-i,y1:e-i,x2:t+i,y2:e+i,stroke:n,strokeWidth:2}),r.push({type:"line",x1:t-i,y1:e+i,x2:t+i,y2:e-i,stroke:n,strokeWidth:2});break;case "arrow":r.push({type:"path",points:[{x:t-i,y:e+i},{x:t,y:e-i},{x:t+i,y:e+i}],stroke:n,strokeWidth:2,fill:"none"});break;case "diamond":r.push({type:"path",points:[{x:t,y:e-i},{x:t+i,y:e},{x:t,y:e+i},{x:t-i,y:e}],fill:n,stroke:"none"});break;case "triangle":r.push({type:"path",points:[{x:t,y:e-i},{x:t+i,y:e+i},{x:t-i,y:e+i}],fill:n,stroke:"none"});break;case "star":{let o=[],a=i*.4;for(let l=0;l<10;l++){let h=l%2===0?i:a,d=Math.PI/2*3+l*Math.PI/5;o.push({x:t+h*Math.cos(d),y:e+h*Math.sin(d)});}r.push({type:"path",points:o,fill:n,stroke:"none"});break}case "plus":r.push({type:"line",x1:t-i,y1:e,x2:t+i,y2:e,stroke:n,strokeWidth:2}),r.push({type:"line",x1:t,y1:e-i,x2:t,y2:e+i,stroke:n,strokeWidth:2});break;case "triangle-down":r.push({type:"path",points:[{x:t,y:e+i},{x:t+i,y:e-i},{x:t-i,y:e-i}],fill:n,stroke:"none"});break;case "hexagon":{let o=[];for(let a=0;a<6;a++){let l=a*(Math.PI/3);o.push({x:t+i*Math.cos(l),y:e+i*Math.sin(l)});}r.push({type:"path",points:o,fill:n,stroke:"none"});break}case "hourglass":r.push({type:"path",points:[{x:t-i,y:e-i},{x:t+i,y:e-i},{x:t-i,y:e+i},{x:t+i,y:e+i}],fill:n,stroke:"none"});break;case "line-horizontal":r.push({type:"line",x1:t-i,y1:e,x2:t+i,y2:e,stroke:n,strokeWidth:2});break}}function Xt(r){let{annotations:t,timeScale:e,valueScales:n}=r,s=[],i=o=>{let a=n.get(o.axis??0)??n.values().next().value;return {x:e.map(o.time),y:a?a.map(o.value):0}};for(let o of t){let a=[],l=h=>a.push(h);switch(o.type){case "line":{let h=i(o.from),d=i(o.to);l({type:"line",x1:h.x,y1:h.y,x2:d.x,y2:d.y,stroke:o.color??c.annotationColor,strokeWidth:o.width??c.annotationWidth,dash:o.dash});break}case "arrow":{let h=i(o.from),d=i(o.to),u=o.color??c.annotationColor,m=o.headSize??c.annotationHead;l({type:"line",x1:h.x,y1:h.y,x2:d.x,y2:d.y,stroke:u,strokeWidth:o.width??c.annotationWidth});let g=Math.hypot(d.x-h.x,d.y-h.y)||1,p=(d.x-h.x)/g,b=(d.y-h.y)/g,S=d.x-p*m,k=d.y-b*m;l({type:"path",points:[{x:d.x,y:d.y},{x:S-b*m*.5,y:k+p*m*.5},{x:S+b*m*.5,y:k-p*m*.5}],fill:u,stroke:"none"});break}case "rect":{let h=i(o.from),d=i(o.to);l({type:"rect",x:Math.min(h.x,d.x),y:Math.min(h.y,d.y),w:Math.abs(d.x-h.x),h:Math.abs(d.y-h.y),fill:o.fill??"none",stroke:o.stroke,opacity:o.opacity});break}case "point":{let h=i(o.at),d=o.color??"#334155",u=o.radius??c.annotationRadius,m=o.shape??"circle";m==="circle"?l({type:"circle",cx:h.x,cy:h.y,r:u,fill:d}):m==="square"?l({type:"rect",x:h.x-u,y:h.y-u,w:u*2,h:u*2,fill:d}):(l({type:"line",x1:h.x-u,y1:h.y-u,x2:h.x+u,y2:h.y+u,stroke:d,strokeWidth:1.5}),l({type:"line",x1:h.x-u,y1:h.y+u,x2:h.x+u,y2:h.y-u,stroke:d,strokeWidth:1.5}));break}case "label":{let h=i(o.at);l({type:"text",content:o.text,x:h.x+(o.dx??0),y:h.y+(o.dy??0),anchor:o.anchor??"middle",fontSize:c.annotationFontSize,fill:o.color??c.annotationColor,rotate:o.rotate});break}}if(o.id&&a.length>0){let h=it(o.id);s.push({type:"group",cssClass:`annotation annotation--${h}`,commands:a});}else s.push(...a);}return s}var K=12,ct=8,_t=20,ye=11,wt=18,vt=r=>r.length*ye*.6;function qt(r,t="vertical"){if(t==="horizontal"){let n=0;for(let s of r)n+=K+ct+vt(s.name)+wt;return {width:Math.max(0,n-wt),height:_t}}let e=0;for(let n of r)e=Math.max(e,vt(n.name));return {width:K+ct+e,height:r.length*_t}}function Ut(r){let{items:t,x:e,y:n,orientation:s="vertical"}=r,i=[],o=e;return t.forEach((a,l)=>{let h=s==="horizontal"?o:e,d=s==="horizontal"?n:n+l*_t;i.push({type:"rect",x:h,y:d,w:K,h:K,fill:a.color,stroke:c.legendStroke,strokeWidth:1}),i.push({type:"text",content:a.name,x:h+K+ct,y:d+K-2,fontSize:c.legendFont,fill:c.legendText}),s==="horizontal"&&(o+=K+ct+vt(a.name)+wt);}),{type:"group",cssClass:"chart-legend",commands:i}}function Kt(r){let{xTicks:t,yTicks:e,xRange:n,yRange:s,stroke:i=c.gridStroke,strokeWidth:o=c.gridStrokeWidth,dashed:a=false,opacity:l=c.gridOpacity}=r,h=[];if(e)for(let d of e)h.push({type:"line",x1:n[0],y1:d,x2:n[1],y2:d,stroke:i,strokeWidth:o,dashed:a,opacity:l});if(t)for(let d of t)h.push({type:"line",x1:d,y1:s[0],x2:d,y2:s[1],stroke:i,strokeWidth:o,dashed:a,opacity:l});return h}function Zt(r,t,e){let n=r??t;if(n==="series")return null;if(n==="chartTop")return e.chartTop;if(n==="chartBottom")return e.chartBottom;if(typeof n=="object"&&"threshold"in n){let s=e.thresholds.get(n.threshold);if(!s)throw new Error(`fillSpec region references unknown threshold '${n.threshold}'`);return e.valueScale.map(s.value)}return typeof n=="object"&&"value"in n?e.valueScale.map(n.value):null}function be(r){return typeof r=="string"?{color:r}:{color:r.color,hatch:r.hatch}}function Qt(r,t,e){let n=Zt(r.from,"chartBottom",t),s=Zt(r.to,"series",t),{color:i,hatch:o}=be(r.fill),a={type:"path",fill:i,hatch:o,stroke:"none",...t.idPrefix&&{id:`${t.idPrefix}-fill-r${e}`}};if(n!==null&&s!==null){let m=t.timeScale.range(),g=m[0],p=m[1],b=Math.min(n,s),S=Math.max(n,s);return [{...a,points:[{x:g,y:b},{x:p,y:b},{x:p,y:S},{x:g,y:S}]}]}let l=n??s,h=[],d=xe(r,t);if(d===null){let m=t.valueScale.domain();d=(n??s)===t.chartBottom?m[0]:m[1];}let u=Jt(r.outer,t);for(let m of t.runs){if(m.length<2)continue;let g=F.splitByThreshold(m,d,b=>b.value??d,F.interpolateDataPoint),p=r.side==="above"?g.above:r.side==="below"?g.below:[...g.above,...g.below];if(u!==null&&r.side){let b=r.side==="above"?"below":"above";p=p.flatMap(S=>{if(S.length<2)return [];let k=F.splitByThreshold(S,u,w=>w.value??u,F.interpolateDataPoint);return b==="above"?k.above:k.below});}for(let b of p){if(b.length<2)continue;let S=b.map(w=>({x:t.timeScale.map(w.time),y:t.valueScale.map(w.value)})),k=[...S].reverse().map(w=>({x:w.x,y:l}));h.push({...a,smoothing:t.smoothing,smoothCount:S.length,points:[...S,...k]});}}return h}function xe(r,t){let e=r.from==="series"?r.to:r.from;return Jt(e,t)}function Jt(r,t){return r===void 0||r==="series"||r==="chartTop"||r==="chartBottom"?null:typeof r=="object"&&"threshold"in r?t.thresholds.get(r.threshold)?.value??null:typeof r=="object"&&"value"in r?r.value:null}function te(r,t){if(typeof r=="string"||!("regions"in r))return Qt({fill:r},t,0);let e=[];return r.regions.forEach((n,s)=>{e.push(...Qt(n,t,s));}),e}function ee(r,t){let e=new Array(r.length),n=0;for(let s=0;s<r.length;s++){let i=r[s].time,o=i-t;for(;n<s&&r[n].time<o;)n++;let a=0,l=0;for(let h=n;h<=s;h++){let d=r[h].value;d!==null&&(a+=d,l++);}e[s]={time:i,value:l===0?null:a/l,synthetic:true};}return e}function ie(r){let t=r.style?.line,e=t&&!Array.isArray(t)?t:void 0;return {color:e?.color??c.stroke,width:e?.width??c.strokeWidth,dash:e?.style,smoothing:e?.smoothing??false}}function ne(r,t,e,n){let s=r.filter(l=>l.value!==null);if(s.length<2)return [];let i=s.map(l=>({x:t.timeScale.map(l.time),y:t.valueScale.map(l.value)})),o=ie(e);return [{type:"path",id:t.idPrefix?`${t.idPrefix}-overlay-${n}`:`overlay-${n}`,points:i,stroke:o.color,strokeWidth:o.width,smoothing:o.smoothing,dash:o.dash,fill:"none"}]}function re(r,t){switch(r.kind){case "movingAverage":{r.type;let e=ee(t.data,r.window);return ne(e,t,r,"movingAvg")}case "movingMkt":{let e=jt(t.data,r.window,r.activationEnergy);return ne(e,t,r,"movingMkt")}case "limits":{let e=[],n=t.timeScale.range(),s=n[0],i=n[1],o=ie(r),a=o.color,l=o.width,h=o.dash??"dashed",d=t.idPrefix?`${t.idPrefix}-`:"";return r.high!==void 0&&e.push({type:"line",id:`${d}overlay-limit-high`,x1:s,y1:t.valueScale.map(r.high),x2:i,y2:t.valueScale.map(r.high),stroke:a,strokeWidth:l,dash:h}),r.low!==void 0&&e.push({type:"line",id:`${d}overlay-limit-low`,x1:s,y1:t.valueScale.map(r.low),x2:i,y2:t.valueScale.map(r.low),stroke:a,strokeWidth:l,dash:h}),e}case "stdDevBand":{let e=r.multiplier??1,n=ee(t.data,r.window),s=It(t.data,r.window),i=[],o=[];for(let b=0;b<n.length;b++){let S=n[b].value,k=s[b].value;if(S===null||k===null)continue;let w=t.timeScale.map(n[b].time);i.push({x:w,y:t.valueScale.map(S+e*k)}),o.push({x:w,y:t.valueScale.map(S-e*k)});}if(i.length<2)return [];let a=t.idPrefix?`${t.idPrefix}-`:"",l=[],d=(typeof r.style?.fill=="string"||r.style?.fill&&!("regions"in r.style.fill)?r.style.fill:void 0)??"#94a3b833",{color:u,hatch:m}=Se(d);l.push({type:"path",id:`${a}overlay-stdDevBand`,points:[...i,...[...o].reverse()],fill:u,hatch:m,stroke:"none"});let g=r.style?.line,p=g&&!Array.isArray(g)?g:void 0;if(p){let b=n.filter(S=>S.value!==null).map(S=>({x:t.timeScale.map(S.time),y:t.valueScale.map(S.value)}));b.length>=2&&l.push({type:"path",id:`${a}overlay-stdDevBand-mean`,points:b,stroke:p.color??c.stroke,strokeWidth:p.width??1.5,smoothing:p.smoothing,dash:p.style,fill:"none"});}return l}}}function Se(r){return typeof r=="string"?{color:r}:{color:r.color,hatch:r.hatch}}function ke(r){if(!r)return {gaps:[],autoDetect:false,minGapMs:6e4};if(Array.isArray(r))return {gaps:r,autoDetect:false,minGapMs:6e4};let t=r.regions??[],e=r.style;return {gaps:t.map(s=>{let i={...e,...s.style},o=i.fill,a,l;return typeof o=="string"?a=o:o&&(a=o.color,l=o.hatch),{startTime:s.startTime,endTime:s.endTime,label:s.label,fill:a,hatch:l,fillOpacity:i.opacity,labelBaseline:i.label?.baseline,rotate:i.label?.rotate,style:i.display==="filled"||i.display==="bridge_line"?void 0:i.display}}),autoDetect:r.autoDetect??false,minGapMs:r.minGapMs??6e4}}function pt(r){return "showAs"in r&&!!r.showAs}var Z=class{_layout;_renderer;_locale;_legend;_markers;_thresholds;_highlights;_gaps;_gapsAutoDetect;_gapsMinGapMs;_annotations;_annotationBands;_disabledAnnotations=new Set;_annotationSeq=0;_axes;_series;_annotationBandHeight=0;_timeScale;_valueScales=new Map;constructor(t={}){this._layout=new nt({width:t.width??800,height:t.height??400,margin:t.margin??{top:20,right:20,bottom:40,left:60}}).compute(),this._renderer=t.renderer,this._locale=t.locale,this._legend=t.legend,this._markers=t.markers??[],this._thresholds=t.thresholds??[],this._highlights=t.highlights??[];let e=ke(t.gaps);this._gaps=e.gaps,this._gapsAutoDetect=e.autoDetect,this._gapsMinGapMs=e.minGapMs,this._annotations=t.annotations??[],this._annotationBands=t.annotationBands??[],this._axes=t.axes,this._series=[],t.series&&this.setData(t.series);}getWidth(){return this._layout.totalWidth}getHeight(){return this._layout.totalHeight+this._annotationBandTotalHeight()}get series(){return this._series}_annotationBandTotalHeight(){let t=0;for(let e of this._annotationBands){let n=e.height??12,s=e.spacing??0;(e.showAxis??false)&&(t+=26+s),t+=n+s;}return t}setData(t){this._series=t.filter(e=>Array.isArray(e.data));}addAnnotation(t){let e=t.id??`anno-${++this._annotationSeq}`;return this._annotations.push({...t,id:e}),e}removeAnnotation(t){let e=this._annotations.length;return this._annotations=this._annotations.filter(n=>n.id!==t),this._disabledAnnotations.delete(t),this._annotations.length<e}setAnnotations(t){this._annotations=[...t],this._disabledAnnotations.clear();}clearAnnotations(){this._annotations=[],this._disabledAnnotations.clear();}getAnnotations(){return this._annotations}disableAnnotation(t){this._disabledAnnotations.add(t);}enableAnnotation(t){this._disabledAnnotations.delete(t);}_axisIndexOf(t){return t.yAxisIndex??0}_timesOf(t){return t.data.map(e=>e.time)}_valuesOf(t){if(pt(t)){let e=[];for(let n of t.data)n.min!==null&&e.push(n.min),n.max!==null&&e.push(n.max);return e}return t.data.map(e=>e.value).filter(e=>e!==null)}renderCommands(){if(this._series.length===0)return [];let t=this._legendItems(),e=(this._legend?.show??false)&&t.length>0,n=this._legend?.position??"inside-right",s=this._legend?.orientation??"vertical",i=e?qt(t,s):{width:0},o=this._layout;if(e&&(n==="outside-right"||n==="outside-left")){let f=i.width+16,x={...this._layout.margin};n==="outside-right"?x.right+=f:x.left+=f,o=new nt({width:this._layout.totalWidth,height:this._layout.totalHeight,margin:x}).compute();}let{chartX:a,chartY:l,chartWidth:h,chartHeight:d}=o,u=[a,a+h],m=[l,l+d],g=[];for(let f of this._series)f.data.sort((x,_)=>x.time-_.time);let p=new Map,b=1/0,S=-1/0,k=false;for(let f of this._series){let x=this._axisIndexOf(f),_=p.get(x);_?_.push(f):p.set(x,[f]);for(let T of this._timesOf(f))T<b&&(b=T),T>S&&(S=T),k=true;}if(!k)return [];let w=this._axes?.x?.domain,O=w&&w!=="auto"?w:[b,S];this._timeScale=new J({domain:O,range:u,locale:this._locale});let L=f=>({axisColor:f?.color??c.axisColor,tickColor:f?.color??c.tickColor,textColor:c.textColor,textSize:c.textSize,axisWidth:f?.width}),H=new tt({domain:O,xRange:u,y:l+d,locale:this._locale,format:this._axes?.x?.format,maxTicks:this._axes?.x?.ticks?.major,colors:L(this._axes?.x?.axis)});this._valueScales.clear();let W=Array.from(p.keys()).sort((f,x)=>f-x),R,j=0,$=0;for(let f of W){let x=p.get(f),_=1/0,T=-1/0,M=false;for(let Y of x)for(let at of this._valuesOf(Y))at<_&&(_=at),at>T&&(T=at),M=true;if(!M)continue;let B;this._axes?.y&&this._axes.y.length>f?B=this._axes.y[f]:f===0?B=this._axes?.left:f===1&&(B=this._axes?.right);let yt=B?.domain,Q=yt&&yt!=="auto"?yt:[_,T],Ft=new U({domain:Q,range:[l+d,l]});this._valueScales.set(f,Ft);let Wt=this._thresholds.filter(Y=>(Y.axisIndex??0)===f&&Y.label!==false&&Y.value>=Math.min(Q[0],Q[1])&&Y.value<=Math.max(Q[0],Q[1])).map(Y=>Ft.map(Y.value)),bt=B?.position??(f===0?"left":"right"),xt;bt==="right"?(xt=a+h+$*50,$++):(xt=a-j*50,j++);let Rt=new lt({domain:Q,range:[l+d,l],x:xt,position:bt,format:B?.format,ticks:B?.ticks?.major,colors:L(B?.axis),suppressLabelsNear:Wt.length?Wt:void 0});f===0&&(R=Rt),g.push({type:"group",cssClass:`value-axis ${bt}`,commands:Rt.render()});}let y=this._valueScales.get(0)??this._valueScales.get(W[0]);g.push({type:"group",cssClass:"time-axis",commands:H.render()});let v=null,C=this._axes?.x?.grid?.major,A=this._axes?.left?.grid?.major;if(C!==void 0||A!==void 0){let f=C!==false,x=A!==false&&!!R,_=f?H.generateTicks().map(M=>M.x):void 0,T=x?R.generateTicks().map(M=>M.position):void 0;if(_||T){let M=(C&&typeof C=="object"?C:void 0)??(A&&typeof A=="object"?A:void 0);v={type:"group",cssClass:"chart-grid",commands:Kt({xTicks:_,yTicks:T,xRange:u,yRange:m,stroke:M?.color,opacity:M?.opacity,dashed:M?.style==="dashed"})};}}if(this._highlights.length>0&&g.push({type:"group",cssClass:"highlights",commands:Nt({highlights:this._highlights,timeScale:this._timeScale,yRange:m,height:o.totalHeight})}),this._thresholds.length>0&&y){let f=[],x=[];for(let _ of this._thresholds){let T=_.id??it(_.name),M=this._valueScales.get(_.axisIndex??0)??y,B=Vt({thresholds:[_],valueScale:M,xRange:u});B.inside.length&&f.push({type:"group",cssClass:`threshold threshold--${T}`,id:`threshold-${T}`,commands:B.inside}),B.labels.length&&x.push({type:"group",cssClass:`threshold-label threshold-label--${T}`,commands:B.labels});}f.length&&g.push({type:"group",cssClass:"thresholds",commands:f,clipRect:{x:a,y:l,w:h,h:d}}),x.length&&g.push({type:"group",cssClass:"threshold-labels",commands:x});}let D=this._gaps;if(this._gapsAutoDetect){let f=[];for(let x of this._series)pt(x)||f.push(...Ot(x.data,this._gapsMinGapMs));f.length>0&&(D=[...this._gaps,...f]);}D.length>0&&g.push({type:"group",cssClass:"gaps",commands:zt({gaps:D,timeScale:this._timeScale,yRange:m})});let E=new Map(this._thresholds.map(f=>[f.name,f]));for(let f of this._series){if(f.data.length===0)continue;let x=this._valueScales.get(this._axisIndexOf(f));if(!x)continue;let _=f.id??it(f.name);g.push({type:"group",cssClass:`series series--${_}`,id:`series-${_}`,commands:this._renderSeries(f,x,E)});}v&&g.push(v);let V=this._markers.map(f=>({...f}));for(let f of V)if(f.value===void 0&&(f.lineStyle==="to-value"||f.lineStyle==="to-top")){let x=this._series[f.seriesIndex??0];x&&!pt(x)&&x.data.length>=2&&(f.value=this._interpolateValue(f.time,x.data));}V.length>0&&y&&g.push({type:"group",cssClass:"markers",commands:Yt({markers:V,timeScale:this._timeScale,valueScale:y,yRange:m})});let N=this._annotations.filter(f=>!f.id||!this._disabledAnnotations.has(f.id));if(N.length>0&&g.push({type:"group",cssClass:"annotations",commands:Xt({annotations:N,timeScale:this._timeScale,valueScales:this._valueScales})}),this._annotationBands.length>0){let f=l+d+this._layout.margin.bottom,x=0;this._annotationBands.forEach(_=>{let T=_.height??12,M=_.spacing??0,B=f+x;(_.showAxis??false)&&(x+=26+M),x+=T+M,g.push({type:"group",cssClass:"annotation-band",commands:new ut({name:_.name,showAxis:_.showAxis??false,items:_.items,timeScale:this._timeScale,background:_.background,hatch:_.hatch},[a,a+h],B,T).render()});});}if(e&&n!=="separate"){let f,x;n==="inside-right"?(f=a+h-i.width-8,x=l+8):n==="inside-left"?(f=a+8,x=l+8):n==="outside-right"?(f=a+h+16,x=l):(f=8,x=l),g.push(Ut({items:t,x:f,y:x,orientation:s}));}let P=this._axes?.left?.label,I=this._axes?.right?.label,q=this._axes?.x?.label;if(P||I||q){let f=[],x=l+d/2,_=this._axes?.left?.labels,T=this._axes?.right?.labels,M=this._axes?.x?.labels;P&&f.push({type:"text",content:P,x:14,y:x,anchor:"middle",fontSize:_?.fontSize??c.axisLabelSize,fill:_?.color??c.axisLabelColor,rotate:-90}),I&&f.push({type:"text",content:I,x:o.totalWidth-14,y:x,anchor:"middle",fontSize:T?.fontSize??c.axisLabelSize,fill:T?.color??c.axisLabelColor,rotate:90}),q&&f.push({type:"text",content:q,x:a+h/2,y:o.totalHeight-6,anchor:"middle",fontSize:M?.fontSize??c.axisLabelSize,fill:M?.color??c.axisLabelColor}),f.length&&g.push({type:"group",cssClass:"axis-labels",commands:f});}return g}_renderSeries(t,e,n){let s=this._timeScale,i={timeScale:s,valueScale:e};if(pt(t)){let y=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,v=typeof t.style?.fill=="string"?t.style.fill:void 0;return t.showAs==="minmaxavg"?new dt({data:t.data,timeScale:s,valueScale:e,minColor:t.minColor,maxColor:t.maxColor,avgColor:t.avgColor,avgDashed:t.avgDashed,fillToMax:t.fillToMax,fillToMaxHatch:t.fillToMaxHatch,fillToMin:t.fillToMin,fillToMinHatch:t.fillToMinHatch,smoothing:y?.smoothing,strokeWidth:y?.width,id:t.id}).render():new mt({data:t.data,timeScale:s,valueScale:e,fill:v??y?.color,avgLine:t.avgLine,countOpacity:t.countOpacity,id:t.id}).render()}let o=t,a=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0,l=a?.gapThreshold??c.gapThreshold,h=F.getRuns(t.data,y=>y.value===null,l),d=h.reduce((y,v)=>y+v.length,0);if(d===0)return [];let u=[],m=t.style?.markers,g=t.style?.shadow,p={stroke:a?.color??c.stroke,strokeWidth:a?.width??c.strokeWidth,smoothing:a?.smoothing,dashed:a?.style==="dashed",pointStyle:m?.type,pointSize:m?.size,pointStroke:m?.stroke,pointFill:m?.fill,pointStrokeWidth:m?.strokeWidth,shadowColor:g?.color,shadowBlur:g?.blur,shadowOffsetX:g?.offsetX,shadowOffsetY:g?.offsetY,id:t.id},b=t.style?.line,S=b&&!Array.isArray(b)?b:void 0,k=S?.color,w=S?.width,O=S?.style,L=S?.smoothing,H=t.style?.fill;if(H!==void 0){let y=e.range(),v=Math.min(y[0],y[1]),C=Math.max(y[0],y[1]);u.push(...te(H,{runs:h,timeScale:s,valueScale:e,thresholds:n,chartTop:v,chartBottom:C,smoothing:a?.smoothing,idPrefix:t.id}));}let W=o.colorByThresholds??[],R=W.map(y=>n.get(y)).filter(y=>!!y).map(y=>y.value).sort((y,v)=>y-v),j=(y,v)=>{let C=p.stroke;for(let A of v){let D=n.get(A);D&&y>=D.value&&(C=D.color??C);}return C};for(let y of h){if(y.length<2)continue;let v=F.splitByBoundaries(y,R,C=>C.value,F.interpolateDataPoint);for(let C=0;C<v.length;C++){let A=v[C];if(A.data.length<2)continue;let D=(A.data[0].value+A.data[A.data.length-1].value)/2,E=o.id,V=A.data.map(P=>({x:s.map(P.time),y:e.map(P.value)})),N=E?`${E}-line-${C}`:void 0;b===false||(b&&Array.isArray(b)?b.forEach((P,I)=>{u.push({type:"path",id:N?`${N}-${I}`:void 0,points:V,stroke:P.color??j(D,W),strokeWidth:P.width??p.strokeWidth,smoothing:P.smoothing??p.smoothing,dash:P.style,opacity:P.opacity,fill:"none",shadowColor:p.shadowColor,shadowBlur:p.shadowBlur,shadowOffsetX:p.shadowOffsetX,shadowOffsetY:p.shadowOffsetY});}):u.push({type:"path",id:N,points:V,stroke:k??j(D,W),strokeWidth:w??p.strokeWidth,smoothing:L??p.smoothing,dash:O,fill:"none",shadowColor:p.shadowColor,shadowBlur:p.shadowBlur,shadowOffsetX:p.shadowOffsetX,shadowOffsetY:p.shadowOffsetY}));}p.pointStyle&&p.pointStyle!=="none"&&d<=(m?.threshold??c.pointThreshold)&&u.push(...Et(y,i,p,C=>j(C.value,W)));}let $=t.overlays;if($&&$.length>0){let y=e.range(),v={data:t.data,timeScale:s,valueScale:e,chartTop:Math.min(y[0],y[1]),chartBottom:Math.max(y[0],y[1]),idPrefix:t.id};for(let C of $)u.push(...re(C,v));}if(t.style?.gap&&h.length>1){let y=e.range(),v=Math.min(y[0],y[1]),C=Math.max(y[0],y[1]),A=t.style.gap,D=A.fill,E,V;typeof D=="string"?E=D:D&&(E=D.color,V=D.hatch);let N=A.opacity??.15,P=A.bridge;for(let I=1;I<h.length;I++){let q=h[I-1][h[I-1].length-1],f=h[I][0],x=s.map(q.time),_=s.map(f.time);if(A.display==="bridge_line"){if(q.value===null||f.value===null)continue;let T=e.map(q.value),M=e.map(f.value);u.push({type:"line",x1:x,y1:T,x2:_,y2:M,stroke:P?.color??(typeof t.style?.line=="object"&&!Array.isArray(t.style.line)?t.style.line.color:void 0)??c.stroke,strokeWidth:P?.width??1.5,dash:P?.style??"dotted"});}else E!==void 0?u.push({type:"rect",x,y:v,w:_-x,h:C-v,fill:E,hatch:V,opacity:N,stroke:"none"}):A.display!=="empty"&&u.push({type:"rect",x,y:v,w:_-x,h:C-v,stroke:c.gapStroke,strokeWidth:1,dashed:true,fill:"none"});}}return u}_interpolateValue(t,e){for(let n=1;n<e.length;n++){let s=e[n-1],i=e[n];if(!(s.value===null||i.value===null)&&t>=s.time&&t<=i.time){let o=(t-s.time)/(i.time-s.time);return s.value+o*(i.value-s.value)}}}legendItems(){return this._legendItems()}_legendItems(){return this._series.map(t=>{let e=t.style?.line&&!Array.isArray(t.style.line)?t.style.line:void 0;return {name:t.name,color:e?.color??c.stroke}})}get renderer(){return this._renderer}get layout(){return this._layout}get timeScale(){return this._timeScale}get valueScales(){return this._valueScales}invertTime(t){return this._timeScale?this._timeScale.invert(t):0}invertValue(t,e=0){let n=this._valueScales.get(e);return n?n.invert(t):0}project(t,e,n=0){let s=this._timeScale?this._timeScale.map(t):0,i=this._valueScales.get(n);return {x:s,y:i?i.map(e):0}}};var ft=class{};var z=1e3,X=class extends ft{#t="100%";#e="100%";#n=new Map;#i=new Map;#r=new Map;constructor(t){super(),t?.width!==void 0&&(this.#t=t.width),t?.height!==void 0&&(this.#e=t.height);}render(t){this.#n.clear(),this.#i.clear(),this.#r.clear();let e=t.map(l=>this._toSVG(l)).join(`
|
|
29
|
+
`),n="",s=[];for(let[,l]of this.#n)s.push(l);for(let[,l]of this.#i)s.push(l);for(let[,l]of this.#r)s.push(l);s.length>0&&(n=` <defs>
|
|
30
|
+
${s.join(`
|
|
31
31
|
`)}
|
|
32
32
|
</defs>
|
|
33
|
-
`);let
|
|
34
|
-
${
|
|
35
|
-
</svg>`}}_toSVG(
|
|
36
|
-
<feDropShadow dx="${
|
|
37
|
-
</filter>`;return this.#n.set(
|
|
38
|
-
<rect x="${
|
|
39
|
-
</clipPath>`);}#h(
|
|
40
|
-
`);return `<linearGradient id="${
|
|
41
|
-
${
|
|
33
|
+
`);let i=typeof this.#t=="number"?`${this.#t}`:this.#t,o=typeof this.#e=="number"?`${this.#e}`:this.#e,a=typeof this.#t=="number"&&typeof this.#e=="number"?` viewBox="0 0 ${this.#t} ${this.#e}"`:"";return {type:"svg",content:`<svg xmlns="http://www.w3.org/2000/svg" width="${i}" height="${o}"${a}>
|
|
34
|
+
${n} ${e}
|
|
35
|
+
</svg>`}}_toSVG(t){switch(t.type){case "path":return this._path(t);case "line":return this._line(t);case "rect":return this._rect(t);case "circle":return this._circle(t);case "text":return this.#h(t);case "gradient":return this._gradient(t);case "gap":return this._gap(t);case "group":return this._group(t)}}#a(t,e,n){if(t.length===0)return "";if(!e||t.length<3)return t.map((a,l)=>`${l===0?"M":"L"}${a.x},${a.y}`).join(" ");let s=n!=null&&n<t.length?Math.max(n,2):t.length,i=a=>Math.round(a*100)/100,o=`M${t[0].x},${t[0].y}`;for(let a=0;a<s-1;a++){let l=t[a-1]??t[a],h=t[a],d=t[a+1],u=t[a+2]&&a+2<s?t[a+2]:d,m=i(h.x+(d.x-l.x)/6),g=i(h.y+(d.y-l.y)/6),p=i(d.x-(u.x-h.x)/6),b=i(d.y-(u.y-h.y)/6);(m=(m*z|0)/z,g=(g*z|0)/z,p=(p*z|0)/z,b=(b*z|0)/z),o+=` C${m},${g} ${p},${b} ${d.x},${d.y}`;}for(let a=s;a<t.length;a++)o+=` L${t[a].x},${t[a].y}`;return o}_hatchPattern(t,e){let n=`hatch-${t}-${this._hatchIndex++}`;if(this.#r.has(n))return n;let s=St(n,t,e??"rgba(200,220,255,0.3)");return this.#r.set(n,s),n}_hatchIndex=0;_path(t){let e=this.#a(t.points,t.smoothing,t.smoothCount),n=[];if(t.hatch){let o=this._hatchPattern(t.hatch,t.fill);n.push(`fill="url(#${o})"`);}else n.push(`fill="${t.fill?this._esc(t.fill):"none"}"`);t.stroke&&n.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&n.push(`stroke-width="${t.strokeWidth}"`);let s=this.#o(t.dash,t.dashed,t.strokeWidth);s&&(n.push(`stroke-dasharray="${s.strokeDasharray}"`),s.strokeLinecap&&n.push(`stroke-linecap="${s.strokeLinecap}"`)),t.opacity!==void 0&&n.push(`opacity="${t.opacity}"`),t.id&&n.push(`id="${this._esc(t.id)}"`);let i=this.#s(t);return i&&n.push(`filter="url(#${i})"`),`<path d="${e}" ${n.join(" ")} />`}_line(t){let e=[];t.stroke&&e.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&e.push(`stroke-width="${t.strokeWidth}"`);let n=this.#o(t.dash,t.dashed,t.strokeWidth);n&&(e.push(`stroke-dasharray="${n.strokeDasharray}"`),n.strokeLinecap&&e.push(`stroke-linecap="${n.strokeLinecap}"`)),t.opacity!==void 0&&e.push(`opacity="${t.opacity}"`),t.id&&e.push(`id="${this._esc(t.id)}"`);let s=this.#s(t);return s&&e.push(`filter="url(#${s})"`),`<line x1="${t.x1}" y1="${t.y1}" x2="${t.x2}" y2="${t.y2}" ${e.join(" ")} />`}_rect(t){let e=[];if(t.hatch){let s=this._hatchPattern(t.hatch,t.fill);e.push(`fill="url(#${s})"`);}else t.fill!==void 0&&e.push(`fill="${this._esc(t.fill)}"`);t.stroke&&e.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&e.push(`stroke-width="${t.strokeWidth}"`),t.opacity!==void 0&&e.push(`opacity="${t.opacity}"`),t.dashed&&e.push('stroke-dasharray="4,4"'),t.id&&e.push(`id="${this._esc(t.id)}"`);let n=this.#s(t);return n&&e.push(`filter="url(#${n})"`),`<rect x="${t.x}" y="${t.y}" width="${t.w}" height="${t.h}" ${e.join(" ")} />`}_circle(t){let e=[];if(t.hatch){let s=this._hatchPattern(t.hatch,t.fill);e.push(`fill="url(#${s})"`);}else t.fill&&e.push(`fill="${this._esc(t.fill)}"`);t.stroke&&e.push(`stroke="${this._esc(t.stroke)}"`),t.strokeWidth&&e.push(`stroke-width="${t.strokeWidth}"`),t.id&&e.push(`id="${this._esc(t.id)}"`);let n=this.#s(t);return n&&e.push(`filter="url(#${n})"`),`<circle cx="${t.cx}" cy="${t.cy}" r="${t.r}" ${e.join(" ")} />`}#o(t,e,n){return t==="dashed"||!t&&e?{strokeDasharray:"4,4"}:t==="dotted"?{strokeDasharray:"2,4"}:!t||t==="solid"?null:Ht(t,n??2)}#s(t){if(!t.shadowColor)return null;let e=t.shadowBlur??0,n=t.shadowOffsetX??0,s=t.shadowOffsetY??0;if(!e&&!n&&!s)return null;let i=`shadow_${e}_${n}_${s}`;if(this.#n.has(i))return i;let o=`<filter id="${i}" x="-50%" y="-50%" width="200%" height="200%">
|
|
36
|
+
<feDropShadow dx="${n}" dy="${s}" stdDeviation="${e/2}" flood-color="${this._esc(t.shadowColor)}" />
|
|
37
|
+
</filter>`;return this.#n.set(i,o),i}#l(t,e,n,s,i){this.#i.has(t)||this.#i.set(t,`<clipPath id="${t}">
|
|
38
|
+
<rect x="${e}" y="${n}" width="${s}" height="${i}" />
|
|
39
|
+
</clipPath>`);}#h(t){let e=[];return t.anchor&&e.push(`text-anchor="${t.anchor}"`),t.fontSize&&e.push(`font-size="${t.fontSize}"`),t.fontFamily&&e.push(`font-family="${this._esc(t.fontFamily)}"`),t.fill&&e.push(`fill="${this._esc(t.fill)}"`),t.rotate&&e.push(`transform="rotate(${t.rotate} ${t.x} ${t.y})"`),t.textBaseline&&e.push(`textBaseline="${t.textBaseline}"`),t.id&&e.push(`id="${this._esc(t.id)}"`),`<text x="${t.x}" y="${t.y}" ${e.join(" ")}>${this._esc(t.content)}</text>`}_gradient(t){let e=`grad-${Math.random().toString(36).slice(2,8)}`,n=t.stops.map(s=>` <stop offset="${s.offset}" stop-color="${this._esc(s.color)}" />`).join(`
|
|
40
|
+
`);return `<linearGradient id="${e}" gradientUnits="userSpaceOnUse">
|
|
41
|
+
${n}
|
|
42
42
|
</linearGradient>
|
|
43
|
-
<path d="${
|
|
44
|
-
<rect x="${
|
|
45
|
-
<text x="${
|
|
46
|
-
</g>`:`<rect x="${
|
|
43
|
+
<path d="${t.points.map(s=>`${s.x},${s.y}`).join(" ")}" fill="url(#${e})" />`}_gap(t){if(t.style==="empty")return "";let e=[`stroke="${this._esc("#999")}"`,'stroke-dasharray="4,4"','fill="none"'];return t.style==="label"&&t.label?`<g class="gap">
|
|
44
|
+
<rect x="${t.x1}" y="${t.y1}" width="${t.x2-t.x1}" height="${t.y2-t.y1}" ${e.join(" ")} />
|
|
45
|
+
<text x="${t.x1}" y="${t.y1-4}" fill="#999" font-size="10">${this._esc(t.label)}</text>
|
|
46
|
+
</g>`:`<rect x="${t.x1}" y="${t.y1}" width="${t.x2-t.x1}" height="${t.y2-t.y1}" ${e.join(" ")} />`}_group(t){t.clipRect&&this.#l("clip-plot",t.clipRect.x,t.clipRect.y,t.clipRect.w,t.clipRect.h);let e=t.commands.map(a=>` ${this._toSVG(a).replace(/\n {3}/g,`
|
|
47
47
|
`)}`).join(`
|
|
48
|
-
`),
|
|
49
|
-
${
|
|
50
|
-
</g>`}_esc(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}};var qe="http://www.w3.org/2000/svg";function dt(o){let e=o.style?.line;return e&&!Array.isArray(e)&&e.color?e.color:c.stroke}function Ue(o){return o.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e])}function ut(o){if(o.length===0)return "";let e=new Date(o[0].time).toLocaleString(),t=o.map(i=>`<div><span class="mlc-tooltip__name">${Ue(i.series.name)}:</span> ${i.value.toFixed(2)}</div>`);return `<div class="mlc-tooltip__time">${Ue(e)}</div>${t.join("")}`}function ct(o,e){if(o.length===0)return;let t=0,i=o.length-1;for(;t<i;){let s=t+i>>1;o[s].time<e?t=s+1:i=s;}let r=o[Math.max(0,t-1)],n=o[t];return Math.abs(r.time-e)<=Math.abs(n.time-e)?r:n}function pt(o){return "value"in o?o.value:o.avg}function re(o,e,t={}){let i=o.querySelector("svg");if(!i)throw new Error("attachTooltip: target has no <svg> child (did you mount the chart first?)");let r=t.format??ut,n=t.snapRadius??1/0,s=t.className??"mlc-tooltip",a=t.showPicks??true,l=t.pickRadius??5,h=t.picksClassName??"mlc-tooltip-picks",m=document.createElement("div");m.className=s,m.style.position="absolute",m.style.pointerEvents="none",m.style.display="none",getComputedStyle(o).position==="static"&&(o.style.position="relative"),o.appendChild(m);let u=null;a&&(u=document.createElementNS(qe,"g"),u.setAttribute("class",h),u.setAttribute("pointer-events","none"),i.appendChild(u));let d=()=>{u&&u.replaceChildren();},g=e.series.map((k,v)=>({data:k.data.map(A=>({time:A.time,value:pt(A)})).filter(A=>A.value!==null).sort((A,j)=>A.time-j.time),series:k,index:v})),f=k=>{let v=i.getBoundingClientRect(),H=e.getWidth?.()??v.width,A=(k.clientX-v.left)*H/Math.max(1,v.width);e.getHeight?.()??v.height;let F=e.invertTime(A);if(!Number.isFinite(F)){m.style.display="none";return}let W=[];for(let M of g){let y=ct(M.data,F);if(!y)continue;let _=e.project(y.time,y.value,M.series.yAxisIndex??0).x,T=e.project(y.time,y.value,M.series.yAxisIndex??0).y;Math.abs(_-A)>n||W.push({seriesIndex:M.index,series:M.series,time:y.time,value:y.value,x:_,y:T});}if(W.length===0){m.style.display="none",d();return}m.innerHTML=r(W);let O=o.getBoundingClientRect();if(m.style.left=`${k.clientX-O.left}px`,m.style.top=`${k.clientY-O.top}px`,m.style.display="",u){u.replaceChildren();for(let M of W){let y=document.createElementNS(qe,"circle");y.setAttribute("cx",String(M.x)),y.setAttribute("cy",String(M.y)),y.setAttribute("r",String(l)),y.setAttribute("fill","#ffffff"),y.setAttribute("stroke",dt(M.series)),y.setAttribute("stroke-width","2"),y.setAttribute("class",`${h}__dot`),u.appendChild(y);}}},x=()=>{m.style.display="none",d();};i.addEventListener("mousemove",f),i.addEventListener("mouseleave",x);let b=false;return ()=>{b||(b=true,i.removeEventListener("mousemove",f),i.removeEventListener("mouseleave",x),m.remove(),u&&u.remove());}}function ft(o,e={}){let t=typeof o=="string"?document.querySelector(o):o;if(!t)throw new Error(`mount: target ${typeof o=="string"?`'${o}'`:""} not found`);let{tooltip:i,...r}=e,n=r.width??t.clientWidth??800,s=r.height??350,a=new U({...r,width:n,height:s}),{content:l}=new Y().render(a.renderCommands());t.innerHTML=l;let h=t.querySelector("svg");return h&&(h.setAttribute("viewBox",`0 0 ${n} ${a.getHeight()}`),h.setAttribute("width","100%"),h.setAttribute("height",String(a.getHeight()))),i?.show&&re(t,a,i),a}var ke=class{_opts;_series=[];_thresholds=[];_annotations=[];_highlights=[];_markers=[];_bands=[];_tooltip;constructor(e,t){this._opts={width:e,height:t};}setSize(e,t){return this._opts.width=e,this._opts.height=t,this}setMargin(e){return this._opts.margin=e,this}setLocale(e){return this._opts.locale=e,this}setAxes(e){return this._opts.axes=e,this}setXAxis(e){return this._opts.axes={...this._opts.axes,x:{...this._opts.axes?.x,...e}},this}setLeftAxis(e){return this._opts.axes={...this._opts.axes,left:{...this._opts.axes?.left,...e}},this}setRightAxis(e){return this._opts.axes={...this._opts.axes,right:{...this._opts.axes?.right,...e}},this}setLegend(e){return this._opts.legend=e,this}setGaps(e){return this._opts.gaps=e,this}setTooltip(e){return this._tooltip={show:true,...e},this}addSeries(e){return this._series.push(e),this}addSeriesAll(e){return this._series.push(...e),this}addThreshold(e){return this._thresholds.push(e),this}addThresholds(e){return this._thresholds.push(...e),this}addAnnotation(e){return this._annotations.push(e),this}addAnnotations(e){return this._annotations.push(...e),this}addHighlight(e){return this._highlights.push(e),this}addMarker(e){return this._markers.push(e),this}addAnnotationBand(e){return this._bands.push(e),this}clear(e){return (!e||e==="series")&&(this._series=[]),(!e||e==="thresholds")&&(this._thresholds=[]),(!e||e==="annotations")&&(this._annotations=[]),(!e||e==="highlights")&&(this._highlights=[]),(!e||e==="markers")&&(this._markers=[]),(!e||e==="bands")&&(this._bands=[]),this}toOptions(){return {...this._opts,series:this._series.length?this._series:this._opts.series,thresholds:this._thresholds.length?this._thresholds:this._opts.thresholds,annotations:this._annotations.length?this._annotations:this._opts.annotations,highlights:this._highlights.length?this._highlights:this._opts.highlights,markers:this._markers.length?this._markers:this._opts.markers,annotationBands:this._bands.length?this._bands:this._opts.annotationBands}}build(){return new U(this.toOptions())}getSvg(){let e=this.build(),{content:t}=new Y().render(e.renderCommands());return t}mount(e){let t=typeof e=="string"?document.querySelector(e):e;if(!t)throw new Error(`GraphBuilder.mount: target ${typeof e=="string"?`'${e}'`:""} not found`);this._opts.width||(this._opts.width=t.clientWidth||800);let i=this.build(),{content:r}=new Y().render(i.renderCommands());t.innerHTML=r;let n=t.querySelector("svg");if(n){let s=this._opts.width??800;n.setAttribute("viewBox",`0 0 ${s} ${i.getHeight()}`),n.setAttribute("width","100%"),n.setAttribute("height",String(i.getHeight()));}return this._tooltip?.show&&re(t,i,this._tooltip),i}};function gt(o){let{thresholds:e,colors:t,hatches:i}=o;if(t.length!==e.length+1)throw new Error(`fillBetweenThresholds: expected ${e.length+1} colors for ${e.length} thresholds, got ${t.length}`);if(i!==void 0&&i.length!==t.length)throw new Error(`fillBetweenThresholds: hatches length (${i.length}) must equal colors length (${t.length})`);return {regions:t.map((n,s)=>{let a=i?.[s],l=a?{color:n,hatch:a}:n;return s===0?{to:{threshold:e[0]},fill:l}:s===t.length-1?{from:{threshold:e[e.length-1]},fill:l}:{from:{threshold:e[s-1]},to:{threshold:e[s]},fill:l}})}}function we(o){if(!o||typeof o!="object")throw new Error("DataPoint: object expected");let{time:e,value:t,annotation:i}=o;if(typeof e!="number"||isNaN(e))throw new Error(`DataPoint: invalid time=${e}`);if(t!==null&&(typeof t!="number"||isNaN(t)))throw new Error(`DataPoint: invalid value=${t}`);return {time:e,value:t,annotation:i&&typeof i=="string"?i:void 0}}function yt(o){if(Array.isArray(o))return o.map(we);if(o&&typeof o=="object"){let e=o,t=e.name,i=e.data,r=e.sensorType,n=e.enumMap,s=e.color,a=e.lineWidth,l=e.smoothing,h=e.seriesType;if(!t||!t.length)throw new Error("Series: name required");if(!Array.isArray(i))throw new Error("Series: data must be an array");let m=s!==void 0||a!==void 0||l!==void 0?{color:s,width:a,smoothing:l}:void 0;return {name:t,data:i.map(we),sensorType:r??"numeric",enumMap:n,seriesType:h,...m&&{style:{line:m}}}}throw new Error("parseSeries: object or DataPoint[] expected")}function xt(o){if(!o||typeof o!="object")throw new Error("parseAggregated: object expected");let e=o,t=e.name,i=e.data,r=e.showAs,n=e.avgLine,s=e.countOpacity,a=e.color;if(!t||!t.length)throw new Error("AggregatedSeries: name required");if(!Array.isArray(i))throw new Error("AggregatedSeries: data must be an array");return {name:t,data:bt(i),showAs:r,avgLine:n,countOpacity:s,...a!==void 0&&{style:{line:{color:a},fill:a}}}}function bt(o){let e=t=>typeof t=="number"?t:null;return o.map(t=>{let i=t;return {time:i.time??0,min:e(i.min),max:e(i.max),avg:e(i.avg),count:typeof i.count=="number"?i.count:0}})}var fe={...c};function St(o){fe={...fe,...o};}function kt(){return fe}function wt(){fe={...c};}/*!
|
|
48
|
+
`),n=t.cssClass?` class="${this._esc(t.cssClass)}"`:"",s=t.id?` id="${this._esc(t.id)}"`:"",i=t.plotClipId||(t.clipRect?"clip-plot":null),o=i?` clip-path="url(#${this._esc(i)})"`:"";return `<g${n}${s}${o}>
|
|
49
|
+
${e}
|
|
50
|
+
</g>`}_esc(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}};var se="http://www.w3.org/2000/svg";function _e(r){let t=r.style?.line;return t&&!Array.isArray(t)&&t.color?t.color:c.stroke}function oe(r){return r.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}function we(r){if(r.length===0)return "";let t=new Date(r[0].time).toLocaleString(),e=r.map(n=>`<div><span class="mlc-tooltip__name">${oe(n.series.name)}:</span> ${n.value.toFixed(2)}</div>`);return `<div class="mlc-tooltip__time">${oe(t)}</div>${e.join("")}`}function ve(r,t){if(r.length===0)return;let e=0,n=r.length-1;for(;e<n;){let o=e+n>>1;r[o].time<t?e=o+1:n=o;}let s=r[Math.max(0,e-1)],i=r[e];return Math.abs(s.time-t)<=Math.abs(i.time-t)?s:i}function Ce(r){return "value"in r?r.value:r.avg}function ot(r,t,e={}){let n=r.querySelector("svg");if(!n)throw new Error("attachTooltip: target has no <svg> child (did you mount the chart first?)");let s=e.format??we,i=e.snapRadius??1/0,o=e.className??"mlc-tooltip",a=e.showPicks??true,l=e.pickRadius??5,h=e.picksClassName??"mlc-tooltip-picks",d=document.createElement("div");d.className=o,d.style.position="absolute",d.style.pointerEvents="none",d.style.display="none",getComputedStyle(r).position==="static"&&(r.style.position="relative"),r.appendChild(d);let u=null;a&&(u=document.createElementNS(se,"g"),u.setAttribute("class",h),u.setAttribute("pointer-events","none"),n.appendChild(u));let m=()=>{u&&u.replaceChildren();},g=t.series.map((k,w)=>({data:k.data.map(L=>({time:L.time,value:Ce(L)})).filter(L=>L.value!==null).sort((L,H)=>L.time-H.time),series:k,index:w})),p=k=>{let w=n.getBoundingClientRect(),O=t.getWidth?.()??w.width,L=(k.clientX-w.left)*O/Math.max(1,w.width);t.getHeight?.()??w.height;let W=t.invertTime(L);if(!Number.isFinite(W)){d.style.display="none";return}let R=[];for(let $ of g){let y=ve($.data,W);if(!y)continue;let v=t.project(y.time,y.value,$.series.yAxisIndex??0).x,C=t.project(y.time,y.value,$.series.yAxisIndex??0).y;Math.abs(v-L)>i||R.push({seriesIndex:$.index,series:$.series,time:y.time,value:y.value,x:v,y:C});}if(R.length===0){d.style.display="none",m();return}d.innerHTML=s(R);let j=r.getBoundingClientRect();if(d.style.left=`${k.clientX-j.left}px`,d.style.top=`${k.clientY-j.top}px`,d.style.display="",u){u.replaceChildren();for(let $ of R){let y=document.createElementNS(se,"circle");y.setAttribute("cx",String($.x)),y.setAttribute("cy",String($.y)),y.setAttribute("r",String(l)),y.setAttribute("fill","#ffffff"),y.setAttribute("stroke",_e($.series)),y.setAttribute("stroke-width","2"),y.setAttribute("class",`${h}__dot`),u.appendChild(y);}}},b=()=>{d.style.display="none",m();};n.addEventListener("mousemove",p),n.addEventListener("mouseleave",b);let S=false;return ()=>{S||(S=true,n.removeEventListener("mousemove",p),n.removeEventListener("mouseleave",b),d.remove(),u&&u.remove());}}function Te(r,t={}){let e=typeof r=="string"?document.querySelector(r):r;if(!e)throw new Error(`mount: target ${typeof r=="string"?`'${r}'`:""} not found`);let{tooltip:n,...s}=t,i=s.width??e.clientWidth??800,o=s.height??350,a=new Z({...s,width:i,height:o}),{content:l}=new X().render(a.renderCommands());e.innerHTML=l;let h=e.querySelector("svg");return h&&(h.setAttribute("viewBox",`0 0 ${i} ${a.getHeight()}`),h.setAttribute("width","100%"),h.setAttribute("height",String(a.getHeight()))),n?.show&&ot(e,a,n),a}var Ct=class{_opts;_series=[];_thresholds=[];_annotations=[];_highlights=[];_markers=[];_bands=[];_tooltip;constructor(t,e){this._opts={},t!==void 0&&(this._opts.width=t),e!==void 0&&(this._opts.height=e);}setWidth(t){return this._opts.width=t,this}setHeight(t){return this._opts.height=t,this}setSize(t,e){return this._opts.width=t,this._opts.height=e,this}setMargin(t,e,n,s){return typeof t=="object"?this._opts.margin=t:this._opts.margin={top:t,right:e??0,bottom:n??0,left:s??0},this}setLocale(t){return this._opts.locale=t,this}setAxes(t){return this._opts.axes=t,this}setXAxis(t){return this._opts.axes={...this._opts.axes,x:{...this._opts.axes?.x,...t}},this}setLeftAxis(t){return this._opts.axes={...this._opts.axes,left:{...this._opts.axes?.left,...t}},this}setRightAxis(t){return this._opts.axes={...this._opts.axes,right:{...this._opts.axes?.right,...t}},this}setYAxis(t,e){this._opts.axes||(this._opts.axes={}),this._opts.axes.y||(this._opts.axes.y=[]);let n=[...this._opts.axes.y];for(;n.length<=t;)n.push({});return n[t]={...n[t],...e},this._opts.axes.y=n,this}setLegend(t,e,n){return typeof t=="object"?this._opts.legend=t:this._opts.legend={show:t,position:e,orientation:n},this}setGaps(t){return this._opts.gaps=t,this}setTooltip(t){return this._tooltip={show:true,...t},this}addSeries(t){return this._series.push(t),this}addSeriesAll(t){return this._series.push(...t),this}addThreshold(t){return this._thresholds.push(t),this}addThresholds(t){return this._thresholds.push(...t),this}addAnnotation(t){return this._annotations.push(t),this}addAnnotations(t){return this._annotations.push(...t),this}addHighlight(t){return this._highlights.push(t),this}addMarker(t){return this._markers.push(t),this}addAnnotationBand(t){return this._bands.push(t),this}clear(t){return (!t||t==="series")&&(this._series=[]),(!t||t==="thresholds")&&(this._thresholds=[]),(!t||t==="annotations")&&(this._annotations=[]),(!t||t==="highlights")&&(this._highlights=[]),(!t||t==="markers")&&(this._markers=[]),(!t||t==="bands")&&(this._bands=[]),this}toOptions(){return {...this._opts,series:this._series.length?this._series:this._opts.series,thresholds:this._thresholds.length?this._thresholds:this._opts.thresholds,annotations:this._annotations.length?this._annotations:this._opts.annotations,highlights:this._highlights.length?this._highlights:this._opts.highlights,markers:this._markers.length?this._markers:this._opts.markers,annotationBands:this._bands.length?this._bands:this._opts.annotationBands}}build(){return new Z(this.toOptions())}getSvg(){let t=this.build(),{content:e}=new X().render(t.renderCommands());return e}mount(t){let e=typeof t=="string"?document.querySelector(t):t;if(!e)throw new Error(`GraphBuilder.mount: target ${typeof t=="string"?`'${t}'`:""} not found`);this._opts.width||(this._opts.width=e.clientWidth||800);let n=this.build(),{content:s}=new X().render(n.renderCommands());e.innerHTML=s;let i=e.querySelector("svg");if(i){let o=this._opts.width??800;i.setAttribute("viewBox",`0 0 ${o} ${n.getHeight()}`),i.setAttribute("width","100%"),i.setAttribute("height",String(n.getHeight()));}return this._tooltip?.show&&ot(e,n,this._tooltip),n}},Tt=class{_series;constructor(t){this._series={name:t,data:[]};}addPoint(t,e){return this._series.data.push({time:t,value:e}),this}addPoints(t){return this._series.data.push(...t),this}addFloats(t,e){let n=Math.min(t.length,e.length);for(let s=0;s<n;s++)this._series.data.push({time:t[s],value:e[s]});return this}addNullPoint(t){return this._series.data.push({time:t,value:null}),this}setStyle(t){return this._series.style=t,this}setLineStyle(t,e,n){return this._series.style||(this._series.style={}),this._series.style.line={color:t,width:e,style:n},this}setSmoothing(t){return this._series.style||(this._series.style={}),!this._series.style.line||typeof this._series.style.line=="boolean"?this._series.style.line={smoothing:t}:Array.isArray(this._series.style.line)?this._series.style.line.length===0?this._series.style.line=[{smoothing:t}]:this._series.style.line[0].smoothing=t:this._series.style.line.smoothing=t,this}setFill(t){return this._series.style||(this._series.style={}),this._series.style.fill=t,this}setID(t){return this._series.id=t,this}setColorByThresholds(t){return this._series.colorByThresholds=t,this}build(){return this._series}},$t=class{_threshold;constructor(t,e){this._threshold={name:t,value:e};}setColor(t){return this._threshold.color=t,this}setLine(t){return this._threshold.line=t,this}setFill(t,e){return this._threshold.fill=t,this._threshold.fillOpacity=e,this}setFillHatch(t){return this._threshold.fillHatch=t,this}setLabel(t,e){return this._threshold.label={text:t,position:e},this}setID(t){return this._threshold.id=t,this}build(){return this._threshold}},At=class{_marker;constructor(t){this._marker={time:t};}setValue(t){return this._marker.value=t,this}setLabel(t){return this._marker.label=t,this}setColor(t){return this._marker.color=t,this}setPointStyle(t){return this._marker.pointStyle=t,this}setLineStyle(t){return t==="none"?delete this._marker.lineStyle:this._marker.lineStyle=t,this}setSeriesIndex(t){return this._marker.seriesIndex=t,this}build(){return this._marker}},Mt=class{_highlight;constructor(t,e){this._highlight={startTime:t,endTime:e};}setLabel(t){return this._highlight.label=t,this}setColor(t){return this._highlight.color=t,this}setOpacity(t){return this._highlight.opacity=t,this}setLabelPosition(t){return this._highlight.labelPosition=t,this}setRotate(t){return this._highlight.rotate=t,this}build(){return this._highlight}},Lt=class{_ann;constructor(t){this._ann={type:t};}setID(t){return this._ann.id=t,this}setTitle(t){return this._ann.title=t,this}setFrom(t,e,n){return this._ann.from={time:t,value:e,axis:n},this}setTo(t,e,n){return this._ann.to={time:t,value:e,axis:n},this}setAt(t,e,n){return this._ann.at={time:t,value:e,axis:n},this}setColor(t){return this._ann.color=t,this}setWidth(t){return this._ann.width=t,this}setDash(t){return this._ann.dash=t,this}setHeadSize(t){return this._ann.headSize=t,this}setFill(t){return this._ann.fill=t,this}setHatch(t){return this._ann.hatch=t,this}setStroke(t){return this._ann.stroke=t,this}setOpacity(t){return this._ann.opacity=t,this}setRadius(t){return this._ann.radius=t,this}setShape(t){return this._ann.shape=t,this}setText(t){return this._ann.text=t,this}setAnchor(t){return this._ann.anchor=t,this}setDx(t){return this._ann.dx=t,this}setDy(t){return this._ann.dy=t,this}setRotate(t){return this._ann.rotate=t,this}build(){return this._ann}},Dt=class{_band;constructor(t){this._band={name:t,items:[]};}setHeight(t){return this._band.height=t,this}setSpacing(t){return this._band.spacing=t,this}setHatch(t){return this._band.hatch=t,this}setShowAxis(t){return this._band.showAxis=t,this}setShowInLegend(t){return this._band.showInLegend=t,this}setBackground(t){return this._band.background=t,this}addItem(t){return this._band.items.push(t),this}build(){return this._band}},Pt=class{_item;constructor(t,e){this._item={startTime:t,endTime:e};}setFill(t){return this._item.fill=t,this}setHatch(t){return this._item.hatch=t,this}setStroke(t){return this._item.stroke=t,this}setStrokeWidth(t){return this._item.strokeWidth=t,this}setLabel(t,e,n,s){return this._item.label=t,e!==void 0&&(this._item.labelFontSize=e),n!==void 0&&(this._item.labelFill=n),s!==void 0&&(this._item.labelBaseline=s),this}build(){return this._item}};function $e(r){let{thresholds:t,colors:e,hatches:n}=r;if(e.length!==t.length+1)throw new Error(`fillBetweenThresholds: expected ${t.length+1} colors for ${t.length} thresholds, got ${e.length}`);if(n!==void 0&&n.length!==e.length)throw new Error(`fillBetweenThresholds: hatches length (${n.length}) must equal colors length (${e.length})`);return {regions:e.map((i,o)=>{let a=n?.[o],l=a?{color:i,hatch:a}:i;return o===0?{to:{threshold:t[0]},fill:l}:o===e.length-1?{from:{threshold:t[t.length-1]},fill:l}:{from:{threshold:t[o-1]},to:{threshold:t[o]},fill:l}})}}function Bt(r){if(!r||typeof r!="object")throw new Error("DataPoint: object expected");let{time:t,value:e,annotation:n}=r;if(typeof t!="number"||isNaN(t))throw new Error(`DataPoint: invalid time=${t}`);if(e!==null&&(typeof e!="number"||isNaN(e)))throw new Error(`DataPoint: invalid value=${e}`);return {time:t,value:e,annotation:n&&typeof n=="string"?n:void 0}}function Ae(r){if(Array.isArray(r))return r.map(Bt);if(r&&typeof r=="object"){let t=r,e=t.name,n=t.data,s=t.sensorType,i=t.enumMap,o=t.color,a=t.lineWidth,l=t.smoothing,h=t.seriesType;if(!e||!e.length)throw new Error("Series: name required");if(!Array.isArray(n))throw new Error("Series: data must be an array");let d=o!==void 0||a!==void 0||l!==void 0?{color:o,width:a,smoothing:l}:void 0;return {name:e,data:n.map(Bt),sensorType:s??"numeric",enumMap:i,seriesType:h,...d&&{style:{line:d}}}}throw new Error("parseSeries: object or DataPoint[] expected")}function Me(r){if(!r||typeof r!="object")throw new Error("parseAggregated: object expected");let t=r,e=t.name,n=t.data,s=t.showAs,i=t.avgLine,o=t.countOpacity,a=t.color;if(!e||!e.length)throw new Error("AggregatedSeries: name required");if(!Array.isArray(n))throw new Error("AggregatedSeries: data must be an array");return {name:e,data:Le(n),showAs:s,avgLine:i,countOpacity:o,...a!==void 0&&{style:{line:{color:a},fill:a}}}}function Le(r){let t=e=>typeof e=="number"?e:null;return r.map(e=>{let n=e;return {time:n.time??0,min:t(n.min),max:t(n.max),avg:t(n.avg),count:typeof n.count=="number"?n.count:0}})}var gt={...c};function De(r){gt={...gt,...r};}function Pe(){return gt}function Be(){gt={...c};}/*!
|
|
51
51
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
52
52
|
* MIT with Attribution: free use incl. commercial requires visible credit to
|
|
53
53
|
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
@@ -66,4 +66,4 @@ ${t}
|
|
|
66
66
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
67
67
|
* MIT with Attribution: free use incl. commercial must have visible credit to
|
|
68
68
|
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
69
|
-
*/export{
|
|
69
|
+
*/export{Dt as AnnotationBandBuilder,Pt as AnnotationBandItemBuilder,Lt as AnnotationBuilder,Ct as GraphBuilder,Mt as HighlightBuilder,Z as MLTimeGraph,At as MarkerBuilder,X as SVGRenderer,$t as ThresholdBuilder,Tt as TimeSeriesBuilder,ot as attachTooltip,$e as fillBetweenThresholds,Pe as getDefaultTheme,Te as mount,Me as parseAggregated,Bt as parseDataPoint,Ae as parseSeries,Be as resetDefaultTheme,De as setDefaultTheme};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { k as DataPoint, o as DrawCommand, ad as TimeScale, V as LinearScale } from '../scale-
|
|
1
|
+
import { k as DataPoint, o as DrawCommand, ad as TimeScale, V as LinearScale } from '../scale-BRE_QhbZ.js';
|
|
2
2
|
|
|
3
3
|
/*!
|
|
4
4
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
package/dist/internals.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { M as Marker } from './layout-
|
|
2
|
-
export { L as Layout, a as LayoutConfig, b as LayoutResult, c as LegendConfig, d as LegendItem, e as LegendOrientation, f as Renderer, m as measureLegend, r as renderLegend, t as theme } from './layout-
|
|
3
|
-
import { A as AggregatedPoint, ad as TimeScale, V as LinearScale, _ as PointStyleType, o as DrawCommand, k as DataPoint, aa as Threshold, I as Gap, O as HatchVariant, P as Highlight, d as Annotation, E as EnumMap, B as BandScale, Z as Point, f as AnnotationBandItem, U as LineVariant, G as FillSpec, M as GapStyle, af as TimeSeries } from './scale-
|
|
4
|
-
export { h as AxisOrientation, i as AxisPosition, j as BandScaleConfig, C as CircleParams, D as Dashstyle_t, m as DomainScaleConfig, n as DrawCircle, p as DrawGap, q as DrawGapType_t, r as DrawGradient, s as DrawGroup, t as DrawLine, u as DrawPath, v as DrawRect, w as DrawText, Q as LabelAnchor, S as LineParams, W as LinearScaleConfig, Y as PathParams, $ as RectParams, a0 as Scale, a1 as ScaleConfig, a8 as TIME_INTERVALS, a9 as TextParams, ae as TimeScaleConfig, ag as getHatch } from './scale-
|
|
1
|
+
import { M as Marker } from './layout-BOYtrsZa.js';
|
|
2
|
+
export { L as Layout, a as LayoutConfig, b as LayoutResult, c as LegendConfig, d as LegendItem, e as LegendOrientation, f as Renderer, m as measureLegend, r as renderLegend, t as theme } from './layout-BOYtrsZa.js';
|
|
3
|
+
import { A as AggregatedPoint, ad as TimeScale, V as LinearScale, _ as PointStyleType, o as DrawCommand, k as DataPoint, aa as Threshold, I as Gap, O as HatchVariant, P as Highlight, d as Annotation, E as EnumMap, B as BandScale, Z as Point, f as AnnotationBandItem, U as LineVariant, G as FillSpec, M as GapStyle, af as TimeSeries } from './scale-BRE_QhbZ.js';
|
|
4
|
+
export { h as AxisOrientation, i as AxisPosition, j as BandScaleConfig, C as CircleParams, D as Dashstyle_t, m as DomainScaleConfig, n as DrawCircle, p as DrawGap, q as DrawGapType_t, r as DrawGradient, s as DrawGroup, t as DrawLine, u as DrawPath, v as DrawRect, w as DrawText, Q as LabelAnchor, S as LineParams, W as LinearScaleConfig, Y as PathParams, $ as RectParams, a0 as Scale, a1 as ScaleConfig, a8 as TIME_INTERVALS, a9 as TextParams, ae as TimeScaleConfig, ag as getHatch } from './scale-BRE_QhbZ.js';
|
|
5
5
|
|
|
6
6
|
/*!
|
|
7
7
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
package/dist/internals.js
CHANGED
|
@@ -25,7 +25,7 @@ var E=class{};var x=class{static interpolateDataPoint(a,e,t){return {time:a.time
|
|
|
25
25
|
${l}
|
|
26
26
|
${s}
|
|
27
27
|
</pattern>
|
|
28
|
-
`.trim()}function I(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 r=[],o=a.reduce((i,m)=>i+m.data.length,0),n=I(t);for(let i=0;i<a.length;i++){let m=a[i];m.data.length>=2?r.push({type:"path",id:t.id?`${t.id}-line-${i}`:void 0,points:m.data.map(s=>({x:e.timeScale.map(s.time),y:e.valueScale.map(s.value)})),stroke:m.color??n.line.stroke,strokeWidth:n.line.strokeWidth,smoothing:n.line.smoothing,dashed:n.line.dashed,shadowColor:n.shadow.color,shadowBlur:n.shadow.blur,shadowOffsetX:n.shadow.offsetX,shadowOffsetY:n.shadow.offsetY,fill:"none"}):m.data.length===1&&o===1&&r.push({type:"circle",cx:e.timeScale.map(m.data[0].time),cy:e.valueScale.map(m.data[0].value),r:Math.max(n.markers.size,n.line.strokeWidth),fill:m.color??n.line.stroke,shadowColor:n.shadow.color,shadowBlur:n.shadow.blur});}return r}function V(a,e,t){let r=[],o=I(t);for(let n=0;n<a.length;n++){let i=a[n];if(i.data.length<2)continue;let m=[];for(let s=0;s<i.data.length;s++){let l=e.timeScale.map(i.data[s].time),u=e.valueScale.map(i.data[s].value);s===0?m.push({x:l,y:u}):(m.push({x:l,y:m[m.length-1].y}),m.push({x:l,y:u}));}r.push({type:"path",id:t.id?`${t.id}-line-${n}`:void 0,points:m,stroke:i.color??o.line.stroke,strokeWidth:o.line.strokeWidth,smoothing:false,fill:"none"});}return r}function xe(a,e,t,r,o){let n=[],i=I(t);for(let m=0;m<a.length;m++){let s=a[m];if(s.data.length<2)continue;let l=s.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(r(d))})),u=s.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(o(d))})).reverse();n.push({type:"path",id:t.id?`${t.id}-fill-${m}`:void 0,points:[...l,...u],fill:s.color??i.fill,hatch:t.hatch,stroke:"none"});}return n}function B(a,e,t,r){if(a.length<2)return [];let o=x.splitByBoundaries(a,t.boundaries,t.getValue,t.interpolate),n=[];for(let i=0;i<o.length;i++){let m=o[i];if(m.data.length<2)continue;let s=t.getColor(m.zoneIndex);if(!s)continue;let l=m.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(t.yLow(d))})),u=m.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(t.yHigh(d))})).reverse();n.push({type:"path",id:r?.id?`${r.id}-fill-${i}`:void 0,points:[...l,...u],fill:s,hatch:t.getHatch?.(m.zoneIndex),stroke:"none"});}return n}function Se(a,e,t,r){let o=x.splitByThreshold(a,e,i=>i.value,x.interpolateDataPoint),n=[];return r.below&&n.push(...w(o.below.map(i=>({data:i})),t,r.below)),r.above&&n.push(...w(o.above.map(i=>({data:i})),t,r.above)),n}function P(a,e,t,r){let o=I(t);if(!o.markers.type||o.markers.type==="none")return [];let n=[];for(let i=0;i<a.length;i++){let m=a[i],s=e.timeScale.map(m.time),l=e.valueScale.map(m.value),u=r(m),d=t.pointStroke??u,c=t.pointFill??u,g=t.pointStrokeWidth??1.5,p=t.id?`${t.id}-marker-${i}`:void 0;ke(n,p,o.markers.type,s,l,o.markers.size,d,c,g);}return n}function ke(a,e,t,r,o,n,i,m,s){switch(t){case "circle":a.push({type:"circle",cx:r,cy:o,r:n,fill:m,stroke:i,strokeWidth:s,id:e});break;case "square":a.push({type:"rect",x:r-n,y:o-n,w:n*2,h:n*2,fill:m,stroke:i,strokeWidth:s,id:e});break;case "cross":a.push({type:"line",x1:r-n,y1:o-n,x2:r+n,y2:o+n,stroke:i,strokeWidth:s,id:e}),a.push({type:"line",x1:r-n,y1:o+n,x2:r+n,y2:o-n,stroke:i,strokeWidth:s,id:e});break;case "diamond":a.push({type:"path",points:[{x:r,y:o-n},{x:r+n,y:o},{x:r,y:o+n},{x:r-n,y:o}],fill:m,stroke:i,strokeWidth:s,id:e});break;case "triangle":a.push({type:"path",points:[{x:r,y:o-n},{x:r+n,y:o+n},{x:r-n,y:o+n}],fill:m,stroke:i,strokeWidth:s,id:e});break;case "star":{let l=[];for(let u=0;u<10;u++){let d=u%2===0?n:n*.5,c=Math.PI/2*3+u*Math.PI/5;l.push({x:r+d*Math.cos(c),y:o+d*Math.sin(c)});}a.push({type:"path",points:l,fill:m,stroke:i,strokeWidth:s,id:e});break}case "arrow":a.push({type:"path",points:[{x:r-n,y:o+n},{x:r,y:o-n},{x:r+n,y:o+n}],stroke:i,strokeWidth:s,fill:"none",id:e});break;default:a.push({type:"circle",cx:r,cy:o,r:n,fill:m,stroke:i,strokeWidth:s,id:e});}}var T=12,H=8,N=20,ve=11,G=18,Y=a=>a.length*ve*.6;function we(a,e="vertical"){if(e==="horizontal"){let r=0;for(let o of a)r+=T+H+Y(o.name)+G;return {width:Math.max(0,r-G),height:N}}let t=0;for(let r of a)t=Math.max(t,Y(r.name));return {width:T+H+t,height:a.length*N}}function Ce(a){let{items:e,x:t,y:r,orientation:o="vertical"}=a,n=[],i=t;return e.forEach((m,s)=>{let l=o==="horizontal"?i:t,u=o==="horizontal"?r:r+s*N;n.push({type:"rect",x:l,y:u,w:T,h:T,fill:m.color,stroke:h.legendStroke,strokeWidth:1}),n.push({type:"text",content:m.name,x:l+T+H,y:u+T-2,fontSize:h.legendFont,fill:h.legendText}),o==="horizontal"&&(i+=T+H+Y(m.name)+G);}),{type:"group",cssClass:"chart-legend",commands:n}}function Te(a){let{xTicks:e,yTicks:t,xRange:r,yRange:o,stroke:n=h.gridStroke,strokeWidth:i=h.gridStrokeWidth,dashed:m=false,opacity:s=h.gridOpacity}=a,l=[];if(t)for(let u of t)l.push({type:"line",x1:r[0],y1:u,x2:r[1],y2:u,stroke:n,strokeWidth:i,dashed:m,opacity:s});if(e)for(let u of e)l.push({type:"line",x1:u,y1:o[0],x2:u,y2:o[1],stroke:n,strokeWidth:i,dashed:m,opacity:s});return l}var L=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[r,o]=this.#e,[n,i]=this.#t;return o===r?n:n+(t-r)/(o-r)*(i-n)}invert(e){let[t,r]=this.#e,[o,n]=this.#t;return n===o?t:t+(e-o)/(n-o)*(r-t)}domain(){return [...this.#e]}range(){return [...this.#t]}},k=[{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;constructor(e){this.#e=new L({domain:e.domain,range:e.range}),this.#t=e.locale||(typeof navigator<"u"?navigator.language:"en-US");}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 locale(){return this.#t}tickInterval(e,t=3,r=12){let[o,n]=this.#e.domain(),i=n-o;if(i<=0)return {interval:k[0].ms};let m=i/e,s=k[0].ms;for(let d of k)if(d.ms>=m){s=d.ms;break}let l=s,u=Math.round(i/l);for(;u>r&&l<k[k.length-1].ms;){let d=k.findIndex(c=>c.ms===l);l=k[Math.min(d+1,k.length-1)].ms,u=Math.round(i/l);}for(;u<t&&l>k[0].ms;){let d=k.findIndex(c=>c.ms===l);l=k[Math.max(d-1,0)].ms,u=Math.round(i/l);}return {interval:l}}ticks(e){let t=e?.minTicks??5,r=e?.maxTicks??12,{interval:o}=this.tickInterval((t+r)/2,t,r),[n,i]=this.#e.domain(),m=[],s=Math.ceil(n/o)*o;for(let l=s;l<=i;l+=o)m.push(l);return m}format(e,t){return new Intl.DateTimeFormat(this.#t,t).format(new Date(e))}},W=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,r=this.#e.length;return r<=1?Math.abs(t-e):Math.abs(t-e)*(1-this.#r*2)/r+Math.abs(t-e)*this.#n*2/r}get bandwidth(){let[e,t]=this.#t,r=this.#e.length;if(r<=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)/r*(1-this.#n)}map(e){let t=this.#e.findIndex(d=>String(d)===String(e));if(t===-1)return this.#t[0];let[r,o]=this.#t,n=this.#e.length;if(n<=1)return (r+o)/2;let i=this.#r*2*Math.abs(o-r),m=Math.abs(o-r)-i,s=o>=r?1:-1,l=m/n;return r+this.#r*Math.abs(o-r)*s+t*l}invert(e){let t=0,r=1/0;for(let o=0;o<this.#e.length;o++){let n=this.map(this.#e[o]),i=Math.abs(e-n);i<r&&(r=i,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 Le(a){return a==="dotted"?{dash:"dotted"}:a==="dashed"?{dash:"dashed"}:{}}function Me(a){let{thresholds:e,valueScale:t,xRange:r}=a,[o,n]=r,[i,m]=t.range(),s=Math.min(i,m),l=Math.max(i,m),u=[],d=[];for(let c of e){let g=c.color??h.thresholdColor,p=t.map(c.value);c.fill==="above"?u.push({type:"rect",x:o,y:s,w:n-o,h:Math.max(0,p-s),fill:g,hatch:c.fillHatch,opacity:c.fillOpacity??.12,id:c.id?`${c.id}-fill`:void 0}):c.fill==="below"&&u.push({type:"rect",x:o,y:p,w:n-o,h:Math.max(0,l-p),fill:g,hatch:c.fillHatch,opacity:c.fillOpacity??.12,id:c.id?`${c.id}-fill`:void 0});let b=c.line??h.thresholdLine;if(b!=="none"){let y=Le(b),f={type:"line",x1:o,y1:p,x2:n,y2:p,stroke:g,strokeWidth:1,...y,id:c.id?`${c.id}-line`:void 0};c.shadowColor&&(f.shadowColor=c.shadowColor,f.shadowBlur=c.shadowBlur??4,f.shadowOffsetX=c.shadowOffsetX??0,f.shadowOffsetY=c.shadowOffsetY??2),u.push(f);}if(c.label!==false){let y=c.label&&typeof c.label=="object"?c.label:void 0,f=typeof c.label=="string"?c.label:y?.text??c.name,S=y?.position??"right";d.push({..._e(f,S,o,n,p,g,y),id:c.id?`${c.id}-label`:void 0});}}return {inside:u,labels:d}}function De(a){let e=Me(a);return [...e.inside,...e.labels]}function _e(a,e,t,r,o,n,i){let m=(t+r)/2,s={type:"text",content:a,fontSize:h.thresholdFontSize,fill:n},l=i?{...i.rotate!==void 0&&{rotate:i.rotate},...i.textBaseline!==void 0&&{textBaseline:i.textBaseline}}:{};switch(e){case "left":return {...s,...l,x:t+4,y:o-4,anchor:"start"};case "above":return {...s,...l,x:m,y:o-6,anchor:"middle"};case "below":return {...s,...l,x:m,y:o+14,anchor:"middle"};case "center":return {...s,...l,x:m,y:o-4,anchor:"middle"};case "outside-left":return {...s,...l,x:t-6,y:o+3,anchor:"end",textBaseline:l.textBaseline??"middle"};case "outside-right":return {...s,...l,x:r+6,y:o+3,anchor:"start",textBaseline:l.textBaseline??"middle"};default:return {...s,...l,x:r-4,y:o-4,anchor:"end"}}}function $e(a){let{gaps:e,timeScale:t,yRange:r,fill:o=h.gapFill,hatch:n,fillOpacity:i=h.gapFillOpacity??.15,stroke:m=h.gapStroke,strokeWidth:s=h.gapStrokeWidth,dashed:l=true,fontSize:u=h.gapFontSize,fontFill:d=h.gapFontColor,labelBaseline:c="middle",labelRotate:g}=a,[p,b]=r,y=[];for(let f of e){let S=t.map(f.startTime),$=t.map(f.endTime),C=f.fill??o,F=f.hatch??n,se=f.fillOpacity??i,le=f.label??"",ge=f.rotate??g,z=f.labelBaseline??c;if(f.style==="dashed_border"||!f.style?y.push({type:"rect",x:S,y:p,w:$-S,h:b-p,fill:C,hatch:F,opacity:se,stroke:m,strokeWidth:s,dashed:l}):f.style==="empty"&&y.push({type:"rect",x:S,y:p,w:$-S,h:b-p,fill:C,hatch:F,opacity:se}),le){let ye=Fe(p,b,z),be=z==="above"?"top":z==="below"?"bottom":"middle";y.push({type:"text",content:le,x:(S+$)/2,y:ye,anchor:"middle",fontSize:u,fill:d,textBaseline:be,rotate:ge});}}return y}function Fe(a,e,t){switch(t){case "above":return a-12;case "below":return e+4;default:return (a+e)/2}}function Pe(a){let{markers:e,timeScale:t,valueScale:r,yRange:o=[0,300]}=a,[n,i]=o,m=[];for(let s of e){let l=t.map(s.time),u=s.color??h.markerColor,d=s.pointStyle??(s.value!==void 0?"circle":"none"),c=s.lineStyle??"full";if(s.value!==void 0){let g=r.map(s.value);if(c==="to-value"?m.push({type:"line",x1:l,y1:i,x2:l,y2:g,stroke:u,strokeWidth:1,dashed:true}):c==="to-top"?m.push({type:"line",x1:l,y1:n,x2:l,y2:g,stroke:u,strokeWidth:1,dashed:true}):c==="full"&&m.push({type:"line",x1:l,y1:n,x2:l,y2:i,stroke:u,strokeWidth:1}),d!=="none"&&Re(m,l,g,u,d),s.label){let p=c==="to-value"?g-10:n-6;m.push({type:"text",content:s.label,x:l,y:p,anchor:"middle",fontSize:11,fill:u});}}else m.push({type:"line",x1:l,y1:n,x2:l,y2:i,stroke:u,strokeWidth:1}),s.label&&m.push({type:"text",content:s.label,x:l,y:n-6,anchor:"middle",fontSize:11,fill:u});}return m}function Re(a,e,t,r,o){let n=h.markerSize;switch(o){case "circle":a.push({type:"circle",cx:e,cy:t,r:n,fill:r});break;case "square":a.push({type:"rect",x:e-n,y:t-n,w:n*2,h:n*2,fill:r});break;case "cross":a.push({type:"line",x1:e-n,y1:t-n,x2:e+n,y2:t+n,stroke:r,strokeWidth:2}),a.push({type:"line",x1:e-n,y1:t+n,x2:e+n,y2:t-n,stroke:r,strokeWidth:2});break;case "arrow":a.push({type:"path",points:[{x:e-n,y:t+n},{x:e,y:t-n},{x:e+n,y:t+n}],stroke:r,strokeWidth:2,fill:"none"});break;case "diamond":a.push({type:"path",points:[{x:e,y:t-n},{x:e+n,y:t},{x:e,y:t+n},{x:e-n,y:t}],fill:r,stroke:"none"});break;case "triangle":a.push({type:"path",points:[{x:e,y:t-n},{x:e+n,y:t+n},{x:e-n,y:t+n}],fill:r,stroke:"none"});break;case "star":{let i=[],m=n*.4;for(let s=0;s<10;s++){let l=s%2===0?n:m,u=Math.PI/2*3+s*Math.PI/5;i.push({x:e+l*Math.cos(u),y:t+l*Math.sin(u)});}a.push({type:"path",points:i,fill:r,stroke:"none"});break}case "plus":a.push({type:"line",x1:e-n,y1:t,x2:e+n,y2:t,stroke:r,strokeWidth:2}),a.push({type:"line",x1:e,y1:t-n,x2:e,y2:t+n,stroke:r,strokeWidth:2});break;case "triangle-down":a.push({type:"path",points:[{x:e,y:t+n},{x:e+n,y:t-n},{x:e-n,y:t-n}],fill:r,stroke:"none"});break;case "hexagon":{let i=[];for(let m=0;m<6;m++){let s=m*(Math.PI/3);i.push({x:e+n*Math.cos(s),y:t+n*Math.sin(s)});}a.push({type:"path",points:i,fill:r,stroke:"none"});break}case "hourglass":a.push({type:"path",points:[{x:e-n,y:t-n},{x:e+n,y:t-n},{x:e-n,y:t+n},{x:e+n,y:t+n}],fill:r,stroke:"none"});break;case "line-horizontal":a.push({type:"line",x1:e-n,y1:t,x2:e+n,y2:t,stroke:r,strokeWidth:2});break}}function We(a){let{highlights:e,timeScale:t,yRange:r,height:o}=a,[n,i]=r,m=[];for(let s of e){let l=t.map(s.startTime),u=t.map(s.endTime);m.push({type:"rect",x:l,y:n,w:u-l,h:i-n,fill:s.color??h.highlightColor,opacity:s.opacity??h.highlightOpacity}),s.label&&m.push({type:"text",content:s.label,x:(l+u)/2,y:Ae(s.labelPosition??"top",n,i,o),anchor:"middle",fontSize:h.annotationFontSize,fill:s.color??h.highlightLabelColor});}return m}function Ae(a,e,t,r){switch(a){case "above":return e-5;case "below":return r!==void 0?r-5:t+14;case "center":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function X(a){return a&&a.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function Oe(a){let{annotations:e,timeScale:t,valueScales:r}=a,o=[],n=i=>{let m=r.get(i.axis??0)??r.values().next().value;return {x:t.map(i.time),y:m?m.map(i.value):0}};for(let i of e){let m=[],s=l=>m.push(l);switch(i.type){case "line":{let l=n(i.from),u=n(i.to);s({type:"line",x1:l.x,y1:l.y,x2:u.x,y2:u.y,stroke:i.color??h.annotationColor,strokeWidth:i.width??h.annotationWidth,dash:i.dash});break}case "arrow":{let l=n(i.from),u=n(i.to),d=i.color??h.annotationColor,c=i.headSize??h.annotationHead;s({type:"line",x1:l.x,y1:l.y,x2:u.x,y2:u.y,stroke:d,strokeWidth:i.width??h.annotationWidth});let g=Math.hypot(u.x-l.x,u.y-l.y)||1,p=(u.x-l.x)/g,b=(u.y-l.y)/g,y=u.x-p*c,f=u.y-b*c;s({type:"path",points:[{x:u.x,y:u.y},{x:y-b*c*.5,y:f+p*c*.5},{x:y+b*c*.5,y:f-p*c*.5}],fill:d,stroke:"none"});break}case "rect":{let l=n(i.from),u=n(i.to);s({type:"rect",x:Math.min(l.x,u.x),y:Math.min(l.y,u.y),w:Math.abs(u.x-l.x),h:Math.abs(u.y-l.y),fill:i.fill??"none",stroke:i.stroke,opacity:i.opacity});break}case "point":{let l=n(i.at),u=i.color??"#334155",d=i.radius??h.annotationRadius,c=i.shape??"circle";c==="circle"?s({type:"circle",cx:l.x,cy:l.y,r:d,fill:u}):c==="square"?s({type:"rect",x:l.x-d,y:l.y-d,w:d*2,h:d*2,fill:u}):(s({type:"line",x1:l.x-d,y1:l.y-d,x2:l.x+d,y2:l.y+d,stroke:u,strokeWidth:1.5}),s({type:"line",x1:l.x-d,y1:l.y+d,x2:l.x+d,y2:l.y-d,stroke:u,strokeWidth:1.5}));break}case "label":{let l=n(i.at);s({type:"text",content:i.text,x:l.x+(i.dx??0),y:l.y+(i.dy??0),anchor:i.anchor??"middle",fontSize:h.annotationFontSize,fill:i.color??h.annotationColor,rotate:i.rotate});break}}if(i.id&&m.length>0){let l=X(i.id);o.push({type:"group",cssClass:`annotation annotation--${l}`,commands:m});}else o.push(...m);}return o}var U=class a{_config;constructor(e){this._config=e;}compute(){let{width:e,height:t,margin:r}=this._config;return {totalWidth:e,totalHeight:t,chartWidth:e-r.left-r.right,chartHeight:t-r.top-r.bottom,chartX:r.left,chartY:r.top,margin:r}}static default(e=800,t=400){return new a({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};var Z=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(r=>e>=r.x&&e<=r.x+r.width&&t>=r.y&&t<=r.y+r.height)}toSVGClipPath(e="clip"){if(this.#e.length===0)return "";let t=this.#e.map(r=>`<rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" />`).join(`
|
|
28
|
+
`.trim()}function I(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 r=[],o=a.reduce((i,m)=>i+m.data.length,0),n=I(t);for(let i=0;i<a.length;i++){let m=a[i];m.data.length>=2?r.push({type:"path",id:t.id?`${t.id}-line-${i}`:void 0,points:m.data.map(s=>({x:e.timeScale.map(s.time),y:e.valueScale.map(s.value)})),stroke:m.color??n.line.stroke,strokeWidth:n.line.strokeWidth,smoothing:n.line.smoothing,dashed:n.line.dashed,shadowColor:n.shadow.color,shadowBlur:n.shadow.blur,shadowOffsetX:n.shadow.offsetX,shadowOffsetY:n.shadow.offsetY,fill:"none"}):m.data.length===1&&o===1&&r.push({type:"circle",cx:e.timeScale.map(m.data[0].time),cy:e.valueScale.map(m.data[0].value),r:Math.max(n.markers.size,n.line.strokeWidth),fill:m.color??n.line.stroke,shadowColor:n.shadow.color,shadowBlur:n.shadow.blur});}return r}function V(a,e,t){let r=[],o=I(t);for(let n=0;n<a.length;n++){let i=a[n];if(i.data.length<2)continue;let m=[];for(let s=0;s<i.data.length;s++){let l=e.timeScale.map(i.data[s].time),u=e.valueScale.map(i.data[s].value);s===0?m.push({x:l,y:u}):(m.push({x:l,y:m[m.length-1].y}),m.push({x:l,y:u}));}r.push({type:"path",id:t.id?`${t.id}-line-${n}`:void 0,points:m,stroke:i.color??o.line.stroke,strokeWidth:o.line.strokeWidth,smoothing:false,fill:"none"});}return r}function xe(a,e,t,r,o){let n=[],i=I(t);for(let m=0;m<a.length;m++){let s=a[m];if(s.data.length<2)continue;let l=s.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(r(d))})),u=s.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(o(d))})).reverse();n.push({type:"path",id:t.id?`${t.id}-fill-${m}`:void 0,points:[...l,...u],fill:s.color??i.fill,hatch:t.hatch,stroke:"none"});}return n}function B(a,e,t,r){if(a.length<2)return [];let o=x.splitByBoundaries(a,t.boundaries,t.getValue,t.interpolate),n=[];for(let i=0;i<o.length;i++){let m=o[i];if(m.data.length<2)continue;let s=t.getColor(m.zoneIndex);if(!s)continue;let l=m.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(t.yLow(d))})),u=m.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(t.yHigh(d))})).reverse();n.push({type:"path",id:r?.id?`${r.id}-fill-${i}`:void 0,points:[...l,...u],fill:s,hatch:t.getHatch?.(m.zoneIndex),stroke:"none"});}return n}function Se(a,e,t,r){let o=x.splitByThreshold(a,e,i=>i.value,x.interpolateDataPoint),n=[];return r.below&&n.push(...w(o.below.map(i=>({data:i})),t,r.below)),r.above&&n.push(...w(o.above.map(i=>({data:i})),t,r.above)),n}function P(a,e,t,r){let o=I(t);if(!o.markers.type||o.markers.type==="none")return [];let n=[];for(let i=0;i<a.length;i++){let m=a[i],s=e.timeScale.map(m.time),l=e.valueScale.map(m.value),u=r(m),d=t.pointStroke??u,c=t.pointFill??u,g=t.pointStrokeWidth??1.5,p=t.id?`${t.id}-marker-${i}`:void 0;ke(n,p,o.markers.type,s,l,o.markers.size,d,c,g);}return n}function ke(a,e,t,r,o,n,i,m,s){switch(t){case "circle":a.push({type:"circle",cx:r,cy:o,r:n,fill:m,stroke:i,strokeWidth:s,id:e});break;case "square":a.push({type:"rect",x:r-n,y:o-n,w:n*2,h:n*2,fill:m,stroke:i,strokeWidth:s,id:e});break;case "cross":a.push({type:"line",x1:r-n,y1:o-n,x2:r+n,y2:o+n,stroke:i,strokeWidth:s,id:e}),a.push({type:"line",x1:r-n,y1:o+n,x2:r+n,y2:o-n,stroke:i,strokeWidth:s,id:e});break;case "diamond":a.push({type:"path",points:[{x:r,y:o-n},{x:r+n,y:o},{x:r,y:o+n},{x:r-n,y:o}],fill:m,stroke:i,strokeWidth:s,id:e});break;case "triangle":a.push({type:"path",points:[{x:r,y:o-n},{x:r+n,y:o+n},{x:r-n,y:o+n}],fill:m,stroke:i,strokeWidth:s,id:e});break;case "star":{let l=[];for(let u=0;u<10;u++){let d=u%2===0?n:n*.5,c=Math.PI/2*3+u*Math.PI/5;l.push({x:r+d*Math.cos(c),y:o+d*Math.sin(c)});}a.push({type:"path",points:l,fill:m,stroke:i,strokeWidth:s,id:e});break}case "arrow":a.push({type:"path",points:[{x:r-n,y:o+n},{x:r,y:o-n},{x:r+n,y:o+n}],stroke:i,strokeWidth:s,fill:"none",id:e});break;default:a.push({type:"circle",cx:r,cy:o,r:n,fill:m,stroke:i,strokeWidth:s,id:e});}}var T=12,H=8,N=20,ve=11,G=18,Y=a=>a.length*ve*.6;function we(a,e="vertical"){if(e==="horizontal"){let r=0;for(let o of a)r+=T+H+Y(o.name)+G;return {width:Math.max(0,r-G),height:N}}let t=0;for(let r of a)t=Math.max(t,Y(r.name));return {width:T+H+t,height:a.length*N}}function Ce(a){let{items:e,x:t,y:r,orientation:o="vertical"}=a,n=[],i=t;return e.forEach((m,s)=>{let l=o==="horizontal"?i:t,u=o==="horizontal"?r:r+s*N;n.push({type:"rect",x:l,y:u,w:T,h:T,fill:m.color,stroke:h.legendStroke,strokeWidth:1}),n.push({type:"text",content:m.name,x:l+T+H,y:u+T-2,fontSize:h.legendFont,fill:h.legendText}),o==="horizontal"&&(i+=T+H+Y(m.name)+G);}),{type:"group",cssClass:"chart-legend",commands:n}}function Te(a){let{xTicks:e,yTicks:t,xRange:r,yRange:o,stroke:n=h.gridStroke,strokeWidth:i=h.gridStrokeWidth,dashed:m=false,opacity:s=h.gridOpacity}=a,l=[];if(t)for(let u of t)l.push({type:"line",x1:r[0],y1:u,x2:r[1],y2:u,stroke:n,strokeWidth:i,dashed:m,opacity:s});if(e)for(let u of e)l.push({type:"line",x1:u,y1:o[0],x2:u,y2:o[1],stroke:n,strokeWidth:i,dashed:m,opacity:s});return l}var L=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[r,o]=this.#e,[n,i]=this.#t;return o===r?n:n+(t-r)/(o-r)*(i-n)}invert(e){let[t,r]=this.#e,[o,n]=this.#t;return n===o?t:t+(e-o)/(n-o)*(r-t)}domain(){return [...this.#e]}range(){return [...this.#t]}},k=[{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;constructor(e){this.#e=new L({domain:e.domain,range:e.range}),this.#t=e.locale||(typeof navigator<"u"?navigator.language:"en-US");}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 locale(){return this.#t}tickInterval(e,t=3,r=12){let[o,n]=this.#e.domain(),i=n-o;if(i<=0)return {interval:k[0].ms};let m=i/e,s=k[0].ms;for(let d of k)if(d.ms>=m){s=d.ms;break}let l=s,u=Math.round(i/l);for(;u>r&&l<k[k.length-1].ms;){let d=k.findIndex(c=>c.ms===l);l=k[Math.min(d+1,k.length-1)].ms,u=Math.round(i/l);}for(;u<t&&l>k[0].ms;){let d=k.findIndex(c=>c.ms===l);l=k[Math.max(d-1,0)].ms,u=Math.round(i/l);}return {interval:l}}ticks(e){let t=e?.minTicks??5,r=e?.maxTicks??12,{interval:o}=this.tickInterval((t+r)/2,t,r),[n,i]=this.#e.domain(),m=[],s=Math.ceil(n/o)*o;for(let l=s;l<=i;l+=o)m.push(l);return m}format(e,t){return new Intl.DateTimeFormat(this.#t,t).format(new Date(e))}},W=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,r=this.#e.length;return r<=1?Math.abs(t-e):Math.abs(t-e)*(1-this.#r*2)/r+Math.abs(t-e)*this.#n*2/r}get bandwidth(){let[e,t]=this.#t,r=this.#e.length;if(r<=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)/r*(1-this.#n)}map(e){let t=this.#e.findIndex(d=>String(d)===String(e));if(t===-1)return this.#t[0];let[r,o]=this.#t,n=this.#e.length;if(n<=1)return (r+o)/2;let i=this.#r*2*Math.abs(o-r),m=Math.abs(o-r)-i,s=o>=r?1:-1,l=m/n;return r+this.#r*Math.abs(o-r)*s+t*l}invert(e){let t=0,r=1/0;for(let o=0;o<this.#e.length;o++){let n=this.map(this.#e[o]),i=Math.abs(e-n);i<r&&(r=i,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 Le(a){return a==="dotted"?{dash:"dotted"}:a==="dashed"?{dash:"dashed"}:{}}function Me(a){let{thresholds:e,valueScale:t,xRange:r}=a,[o,n]=r,[i,m]=t.range(),s=Math.min(i,m),l=Math.max(i,m),u=[],d=[];for(let c of e){let g=c.color??h.thresholdColor,p=t.map(c.value);c.fill==="above"?u.push({type:"rect",x:o,y:s,w:n-o,h:Math.max(0,p-s),fill:g,hatch:c.fillHatch,opacity:c.fillOpacity??.12,id:c.id?`${c.id}-fill`:void 0}):c.fill==="below"&&u.push({type:"rect",x:o,y:p,w:n-o,h:Math.max(0,l-p),fill:g,hatch:c.fillHatch,opacity:c.fillOpacity??.12,id:c.id?`${c.id}-fill`:void 0});let b=c.line??h.thresholdLine;if(b!=="none"){let y=Le(b),f={type:"line",x1:o,y1:p,x2:n,y2:p,stroke:g,strokeWidth:1,...y,id:c.id?`${c.id}-line`:void 0};c.shadowColor&&(f.shadowColor=c.shadowColor,f.shadowBlur=c.shadowBlur??4,f.shadowOffsetX=c.shadowOffsetX??0,f.shadowOffsetY=c.shadowOffsetY??2),u.push(f);}if(c.label!==false){let y=c.label&&typeof c.label=="object"?c.label:void 0,f=typeof c.label=="string"?c.label:y?.text??c.name,S=y?.position??"right";d.push({..._e(f,S,o,n,p,g,y),id:c.id?`${c.id}-label`:void 0});}}return {inside:u,labels:d}}function De(a){let e=Me(a);return [...e.inside,...e.labels]}function _e(a,e,t,r,o,n,i){let m=(t+r)/2,s={type:"text",content:a,fontSize:h.thresholdFontSize,fill:n},l=i?{...i.rotate!==void 0&&{rotate:i.rotate},...i.textBaseline!==void 0&&{textBaseline:i.textBaseline}}:{};switch(e){case "left":return {...s,...l,x:t+4,y:o-4,anchor:"start"};case "above":return {...s,...l,x:m,y:o-6,anchor:"middle"};case "below":return {...s,...l,x:m,y:o+14,anchor:"middle"};case "center":return {...s,...l,x:m,y:o-4,anchor:"middle"};case "outside-left":return {...s,...l,x:t-6,y:o+3,anchor:"end",textBaseline:l.textBaseline??"middle"};case "outside-right":return {...s,...l,x:r+6,y:o+3,anchor:"start",textBaseline:l.textBaseline??"middle"};default:return {...s,...l,x:r-4,y:o-4,anchor:"end"}}}function $e(a){let{gaps:e,timeScale:t,yRange:r,fill:o=h.gapFill,hatch:n,fillOpacity:i=h.gapFillOpacity??.15,stroke:m=h.gapStroke,strokeWidth:s=h.gapStrokeWidth,dashed:l=true,fontSize:u=h.gapFontSize,fontFill:d=h.gapFontColor,labelBaseline:c="middle",labelRotate:g}=a,[p,b]=r,y=[];for(let f of e){let S=t.map(f.startTime),$=t.map(f.endTime),C=f.fill??o,F=f.hatch??n,se=f.fillOpacity??i,le=f.label??"",ge=f.rotate??g,z=f.labelBaseline??c;if(f.style==="dashed_border"||!f.style?y.push({type:"rect",x:S,y:p,w:$-S,h:b-p,fill:C,hatch:F,opacity:se,stroke:m,strokeWidth:s,dashed:l}):f.style==="empty"&&y.push({type:"rect",x:S,y:p,w:$-S,h:b-p,fill:C,hatch:F,opacity:se}),le){let ye=Fe(p,b,z),be=z==="above"?"top":z==="below"?"bottom":"middle";y.push({type:"text",content:le,x:(S+$)/2,y:ye,anchor:"middle",fontSize:u,fill:d,textBaseline:be,rotate:ge});}}return y}function Fe(a,e,t){switch(t){case "above":return a-12;case "below":return e+4;default:return (a+e)/2}}function Pe(a){let{markers:e,timeScale:t,valueScale:r,yRange:o=[0,300]}=a,[n,i]=o,m=[];for(let s of e){let l=t.map(s.time),u=s.color??h.markerColor,d=s.pointStyle??(s.value!==void 0?"circle":"none"),c=s.lineStyle??"full";if(s.value!==void 0){let g=r.map(s.value);if(c==="to-value"?m.push({type:"line",x1:l,y1:i,x2:l,y2:g,stroke:u,strokeWidth:1,dashed:true}):c==="to-top"?m.push({type:"line",x1:l,y1:n,x2:l,y2:g,stroke:u,strokeWidth:1,dashed:true}):c==="full"&&m.push({type:"line",x1:l,y1:n,x2:l,y2:i,stroke:u,strokeWidth:1}),d!=="none"&&Re(m,l,g,u,d),s.label){let p=c==="to-value"?g-10:n-6;m.push({type:"text",content:s.label,x:l,y:p,anchor:"middle",fontSize:11,fill:u});}}else m.push({type:"line",x1:l,y1:n,x2:l,y2:i,stroke:u,strokeWidth:1}),s.label&&m.push({type:"text",content:s.label,x:l,y:n-6,anchor:"middle",fontSize:11,fill:u});}return m}function Re(a,e,t,r,o){let n=h.markerSize;switch(o){case "circle":a.push({type:"circle",cx:e,cy:t,r:n,fill:r});break;case "square":a.push({type:"rect",x:e-n,y:t-n,w:n*2,h:n*2,fill:r});break;case "cross":a.push({type:"line",x1:e-n,y1:t-n,x2:e+n,y2:t+n,stroke:r,strokeWidth:2}),a.push({type:"line",x1:e-n,y1:t+n,x2:e+n,y2:t-n,stroke:r,strokeWidth:2});break;case "arrow":a.push({type:"path",points:[{x:e-n,y:t+n},{x:e,y:t-n},{x:e+n,y:t+n}],stroke:r,strokeWidth:2,fill:"none"});break;case "diamond":a.push({type:"path",points:[{x:e,y:t-n},{x:e+n,y:t},{x:e,y:t+n},{x:e-n,y:t}],fill:r,stroke:"none"});break;case "triangle":a.push({type:"path",points:[{x:e,y:t-n},{x:e+n,y:t+n},{x:e-n,y:t+n}],fill:r,stroke:"none"});break;case "star":{let i=[],m=n*.4;for(let s=0;s<10;s++){let l=s%2===0?n:m,u=Math.PI/2*3+s*Math.PI/5;i.push({x:e+l*Math.cos(u),y:t+l*Math.sin(u)});}a.push({type:"path",points:i,fill:r,stroke:"none"});break}case "plus":a.push({type:"line",x1:e-n,y1:t,x2:e+n,y2:t,stroke:r,strokeWidth:2}),a.push({type:"line",x1:e,y1:t-n,x2:e,y2:t+n,stroke:r,strokeWidth:2});break;case "triangle-down":a.push({type:"path",points:[{x:e,y:t+n},{x:e+n,y:t-n},{x:e-n,y:t-n}],fill:r,stroke:"none"});break;case "hexagon":{let i=[];for(let m=0;m<6;m++){let s=m*(Math.PI/3);i.push({x:e+n*Math.cos(s),y:t+n*Math.sin(s)});}a.push({type:"path",points:i,fill:r,stroke:"none"});break}case "hourglass":a.push({type:"path",points:[{x:e-n,y:t-n},{x:e+n,y:t-n},{x:e-n,y:t+n},{x:e+n,y:t+n}],fill:r,stroke:"none"});break;case "line-horizontal":a.push({type:"line",x1:e-n,y1:t,x2:e+n,y2:t,stroke:r,strokeWidth:2});break}}function We(a){let{highlights:e,timeScale:t,yRange:r,height:o}=a,[n,i]=r,m=[];for(let s of e){let l=t.map(s.startTime),u=t.map(s.endTime);m.push({type:"rect",x:l,y:n,w:u-l,h:i-n,fill:s.color??h.highlightColor,opacity:s.opacity??h.highlightOpacity}),s.label&&m.push({type:"text",content:s.label,x:(l+u)/2,y:Ae(s.labelPosition??"top",n,i,o),anchor:"middle",fontSize:h.annotationFontSize,fill:s.color??h.highlightLabelColor,rotate:s.rotate});}return m}function Ae(a,e,t,r){switch(a){case "above":return e-5;case "below":return r!==void 0?r-5:t+14;case "center":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function X(a){return a&&a.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function Oe(a){let{annotations:e,timeScale:t,valueScales:r}=a,o=[],n=i=>{let m=r.get(i.axis??0)??r.values().next().value;return {x:t.map(i.time),y:m?m.map(i.value):0}};for(let i of e){let m=[],s=l=>m.push(l);switch(i.type){case "line":{let l=n(i.from),u=n(i.to);s({type:"line",x1:l.x,y1:l.y,x2:u.x,y2:u.y,stroke:i.color??h.annotationColor,strokeWidth:i.width??h.annotationWidth,dash:i.dash});break}case "arrow":{let l=n(i.from),u=n(i.to),d=i.color??h.annotationColor,c=i.headSize??h.annotationHead;s({type:"line",x1:l.x,y1:l.y,x2:u.x,y2:u.y,stroke:d,strokeWidth:i.width??h.annotationWidth});let g=Math.hypot(u.x-l.x,u.y-l.y)||1,p=(u.x-l.x)/g,b=(u.y-l.y)/g,y=u.x-p*c,f=u.y-b*c;s({type:"path",points:[{x:u.x,y:u.y},{x:y-b*c*.5,y:f+p*c*.5},{x:y+b*c*.5,y:f-p*c*.5}],fill:d,stroke:"none"});break}case "rect":{let l=n(i.from),u=n(i.to);s({type:"rect",x:Math.min(l.x,u.x),y:Math.min(l.y,u.y),w:Math.abs(u.x-l.x),h:Math.abs(u.y-l.y),fill:i.fill??"none",stroke:i.stroke,opacity:i.opacity});break}case "point":{let l=n(i.at),u=i.color??"#334155",d=i.radius??h.annotationRadius,c=i.shape??"circle";c==="circle"?s({type:"circle",cx:l.x,cy:l.y,r:d,fill:u}):c==="square"?s({type:"rect",x:l.x-d,y:l.y-d,w:d*2,h:d*2,fill:u}):(s({type:"line",x1:l.x-d,y1:l.y-d,x2:l.x+d,y2:l.y+d,stroke:u,strokeWidth:1.5}),s({type:"line",x1:l.x-d,y1:l.y+d,x2:l.x+d,y2:l.y-d,stroke:u,strokeWidth:1.5}));break}case "label":{let l=n(i.at);s({type:"text",content:i.text,x:l.x+(i.dx??0),y:l.y+(i.dy??0),anchor:i.anchor??"middle",fontSize:h.annotationFontSize,fill:i.color??h.annotationColor,rotate:i.rotate});break}}if(i.id&&m.length>0){let l=X(i.id);o.push({type:"group",cssClass:`annotation annotation--${l}`,commands:m});}else o.push(...m);}return o}var U=class a{_config;constructor(e){this._config=e;}compute(){let{width:e,height:t,margin:r}=this._config;return {totalWidth:e,totalHeight:t,chartWidth:e-r.left-r.right,chartHeight:t-r.top-r.bottom,chartX:r.left,chartY:r.top,margin:r}}static default(e=800,t=400){return new a({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};var Z=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(r=>e>=r.x&&e<=r.x+r.width&&t>=r.y&&t<=r.y+r.height)}toSVGClipPath(e="clip"){if(this.#e.length===0)return "";let t=this.#e.map(r=>`<rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" />`).join(`
|
|
29
29
|
`);return `<clipPath id="${e}">
|
|
30
30
|
${t}
|
|
31
31
|
</clipPath>`}get regions(){return [...this.#e]}};var A={axisColor:h.axisColor,tickColor:h.tickColor,textColor:h.textColor,textSize:h.textSize},O=class{#e;#t;constructor(e){this.#e=new R({domain:e.domain,range:e.xRange,locale:e.locale}),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(n=>({time:n,x:this.#e.map(n),label:this.tickLabel(n)}));return this.antiOverlap(o)}tickLabel(e){if(this.#t.format)return this.#t.format(new Date(e));let t=this.#t.minTicks??5,r=this.#t.maxTicks??12,{interval:o}=this.#e.tickInterval((t+r)/2,t,r),n={};return o<6e4?(n.hour="2-digit",n.minute="2-digit",n.second="2-digit"):o<36e5||o<864e5?(n.hour="2-digit",n.minute="2-digit"):o<31536e6?(n.day="numeric",n.month="short",o>=2592e6&&(n.day=void 0,n.month="long")):(n.year="numeric",o<2*31536e6&&(n.month="short")),this.#e.format(e,n)}antiOverlap(e){if(e.length<=1)return e;let t=60,r=[e[0]];for(let o=1;o<e.length;o++){let n=r[r.length-1].x;Math.abs(e[o].x-n)>=t&&r.push(e[o]);}return r}render(){let e=this.generateTicks(),t=this.#t.colors??A,r=this.#t.y??0,o=[],[n]=this.#e.range();o.push({type:"line",x1:n,y1:r,x2:e[e.length-1]?.x??n,y2:r,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let i of e)o.push({type:"line",x1:i.x,y1:r,x2:i.x,y2:r+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),o.push({type:"text",content:i.label,x:i.x,y:r+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return o}};var j={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function je(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)}var q=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??je,t=6,[r,o]=this.#e.domain(),n=o-r;if(n===0)return [{value:r,position:this.#e.map(r),label:e(r)}];let i=n/t,m=Math.pow(10,Math.floor(Math.log10(i))),s=i/m,l;s<=1.5?l=m:s<=3?l=2*m:s<=7?l=5*m:l=10*m;let u=[],d=Math.ceil(r/l)*l;for(let c=d;c<=o;c+=l)u.push({value:c,position:this.#e.map(c),label:e(c)});return u}render(){let e=this.generateTicks(),t=this.#t.colors??j,r=this.#t.x??0,o=this.#t.orientation??"vertical",n=this.#t.position??"left",i=this.#t.suppressLabelsNear??[],m=this.#t.suppressTolerancePx??8,s=u=>i.some(d=>Math.abs(d-u)<=m),l=[];if(o==="vertical"){let[u,d]=this.#e.range();l.push({type:"line",x1:r,y1:u,x2:r,y2:d,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let c of e){let g=s(c.position);n==="left"?(l.push({type:"line",x1:r-4,y1:c.position,x2:r,y2:c.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||l.push({type:"text",content:c.label,x:r-8,y:c.position+4,anchor:"end",fontSize:11,fill:t.textColor})):(l.push({type:"line",x1:r,y1:c.position,x2:r+4,y2:c.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||l.push({type:"text",content:c.label,x:r+8,y:c.position+4,anchor:"start",fontSize:11,fill:t.textColor}));}}else {let[u,d]=this.#e.range();l.push({type:"line",x1:u,y1:r,x2:d,y2:r,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let c of e)l.push({type:"line",x1:c.position,y1:r,x2:c.position,y2:r+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),l.push({type:"text",content:c.label,x:c.position,y:r+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}return l}};var K=class{#e;#t;#n;constructor(e){let t=Object.keys(e.enumMap).map(Number).sort((r,o)=>r-o).map(String);this.#t=t,this.#e=new W({domain:t,range:e.range}),this.#n=e;}get scale(){return this.#e}generateTicks(){let{enumMap:e,showLabels:t=true,autoColor:r=true,gapValues:o}=this.#n,n=new Set(o??[]);return this.#t.map((i,m)=>{let s=Number(i),l=t?e[s]??String(s):String(s),u=this.#e.map(s),d=r?h.palette[m%h.palette.length]:void 0;return {value:s,label:l,y:u,color:d,isGap:n.has(s)}})}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,r=[];for(let o of e)o.isGap||r.push({type:"text",content:o.label,x:t,y:o.y+4,anchor:"end",fontSize:11,fill:o.color??h.textColor});return r}map(e){return this.#e.map(e)}isGap(e){return new Set(this.#n.gapValues??[]).has(e)}};var v=class a{#e;#t;static uidcnt=0;#n;constructor(e,t=[]){this.#e=e.id??"id"+Date.now+ ++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 Q=class extends v{#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,r)=>t.x-r.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},r=e.pointThreshold??h.pointThreshold,o=e.gapThreshold??h.gapThreshold,n=e.id,i=x.getRuns(this.data,d=>d.value===null,o),m=i.reduce((d,c)=>d+c.length,0);if(m===0)return [];let s={timeScale:this.timeScale,valueScale:e.valueScale},l=i.map(d=>({data:d})),u=[];if(u.push(...w(l,s,{...t,id:n?`${n}-line`:void 0})),t.pointStyle&&t.pointStyle!=="none"&&m<=r)for(let d of i)u.push(...P(d,s,{...t,id:n?`${n}-marker`:void 0},()=>t.stroke));return u}};var J=class extends v{#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,n)=>o.time-n.time),r=[];for(let o=0;o<t.length;o++){let n=this.timeScale.map(t[o].time),i=e.map(t[o].value);o===0?r.push({x:n,y:i}):(r.push({x:n,y:r[r.length-1].y}),r.push({x:n,y:i}));}return r}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},r=e.map(o=>({data:o}));return V(r,t,{stroke:this.#e.stroke??h.stroke,strokeWidth:this.#e.strokeWidth??h.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var ee=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}opacity(e){if(!(this.#e.countOpacity??false))return .6;let t=Math.max(...this.data.map(r=>r.count));return t===0?.2:.2+.8*e/t}render(){let e=this.#e,t=e.fill??h.bandFill,r=e.hatch,o=e.avgLine??false,n=e.avgLineColor??h.bandAvgLine,i=e.bandWidth??10,m=[];for(let s of this.data){if(s.min===null||s.max===null)continue;let l=this.timeScale.map(s.time),u=e.valueScale.map(s.max),d=e.valueScale.map(s.min),c=i,g=this.data.indexOf(s);if(m.push({type:"rect",x:l-c/2,y:u,w:c,h:d-u,fill:t,hatch:r,opacity:this.opacity(s.count),id:this.id?`${this.id}-slot-${g}`:void 0}),o&&s.avg!==null){let p=e.valueScale.map(s.avg);m.push({type:"line",x1:l-c/2,y1:p,x2:l+c/2,y2:p,stroke:n,strokeWidth:1,id:this.id?`${this.id}-avg-${g}`:void 0});}}return m}};var te=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??h.minColor,r=e.maxColor??h.maxColor,o=e.avgColor??h.avgColor,n=e.avgDashed??true,i=e.smoothing??false,m=e.strokeWidth??h.strokeWidth,s=x.getRuns(this.data,d=>d.min===null||d.max===null||d.avg===null);if(s.length===0)return [];let l={timeScale:this.timeScale,valueScale:e.valueScale},u=[];for(let d of s)d.length<2||(e.fillToMax&&u.push(...B(d,l,{boundaries:[],yLow:c=>c.avg,yHigh:c=>c.max,getValue:c=>c.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMax,getHatch:()=>e.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax`:void 0})),e.fillToMin&&u.push(...B(d,l,{boundaries:[],yLow:c=>c.avg,yHigh:c=>c.min,getValue:c=>c.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMin,getHatch:()=>e.fillToMinHatch},{id:this.id?`${this.id}-fillToMin`:void 0})),u.push(...w([{data:d.map(c=>({time:c.time,value:c.max}))}],l,{stroke:r,strokeWidth:m,smoothing:i,id:this.id?`${this.id}-max`:void 0}),...w([{data:d.map(c=>({time:c.time,value:c.min}))}],l,{stroke:t,strokeWidth:m,smoothing:i,id:this.id?`${this.id}-min`:void 0}),...w([{data:d.map(c=>({time:c.time,value:c.avg}))}],l,{stroke:o,strokeWidth:m,smoothing:i,dashed:n,id:this.id?`${this.id}-avg`:void 0})));return u}};var ne=class extends v{#e;#t;constructor(e){super(e,e.data),this.#e=e,this.#t=[...e.zones??[]].sort((t,r)=>t.value-r.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,r={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,n=e.pointThreshold??h.pointThreshold,i=x.getRuns(this.data,u=>u.value===null,o),m=i.reduce((u,d)=>u+d.length,0);if(m===0)return [];let s={timeScale:this.timeScale,valueScale:e.valueScale},l=[];for(let u of i){if(u.length<2)continue;if(e.fill){let p=e.fill.value,b=x.splitByBoundaries(u,[p],f=>f.value,x.interpolateDataPoint),y=e.valueScale.map(p);for(let f=0;f<b.length;f++){let S=b[f],$=(S.data[0].value+S.data[S.data.length-1].value)/2;if(e.fill.side==="above"==$>=p){let C=S.data.map(F=>({x:this.timeScale.map(F.time),y:e.valueScale.map(F.value)}));l.push({type:"path",id:this.id?`${this.id}-fill-${f}`:void 0,points:[...C,{x:C[C.length-1].x,y},{x:C[0].x,y}],fill:e.fill.color,hatch:e.fill.hatch,stroke:"none"});}}}let d=this.#t.map(p=>p.value),g=x.splitByBoundaries(u,d,p=>p.value,x.interpolateDataPoint).map(p=>({data:p.data,color:this.#n(p.zoneIndex)}));l.push(...w(g,s,{...r,id:this.id?`${this.id}-line`:void 0})),r.pointStyle&&r.pointStyle!=="none"&&m<=n&&l.push(...P(u,s,{...r,id:this.id?`${this.id}-marker`:void 0},p=>{let b=t;for(let y of this.#t)p.value>=y.value&&(b=y.color);return b}));}return l}};var re=class{#e;constructor(e,t,r,o){this.#e={...e,xRange:t,y:r,height:o};}render(){let{items:e,timeScale:t,background:r,hatch:o,showAxis:n,xRange:i,y:m,height:s}=this.#e,l=[];r&&l.push({type:"rect",x:i[0],y:m,w:i[1]-i[0],h:s,fill:r,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let u of e){let d=t.map(u.startTime),c=t.map(u.endTime);c-d<1||(l.push({type:"rect",x:d,y:m,w:c-d,h:s,hatch:u.hatch??o,fill:u.fill??"#6b728044",stroke:u.stroke,strokeWidth:u.strokeWidth??0}),u.label&&l.push({type:"text",content:u.label,x:(d+c)/2,y:this.#t(u.labelBaseline),anchor:"middle",fontSize:u.labelFontSize??10,fill:u.labelFill??"#333",textBaseline:u.labelBaseline??"middle"}));}if(n){let u=new O({domain:t.domain(),xRange:i,y:m+s+4});l.push({type:"group",cssClass:"annotation-band-axis",commands:u.render()});}return l}#t(e){let{y:t,height:r}=this.#e;switch(e){case "top":return t+1;case "bottom":return t+r-1;default:return t+r/2}}};var oe=class{#e;constructor(e){this.#e=e;}render(){let{data:e,valueScale:t,xRange:r,showMin:o=false,showMax:n=false,showAvg:i=true,showMedian:m=false,labelPosition:s="end",lineColor:l=h.statsLineColor,labelColor:u=h.statsLabelColor}=this.#e,d=me.compute(e),c=[{name:"min",value:d.min,enabled:o},{name:"max",value:d.max,enabled:n},{name:"avg",value:d.avg,enabled:i},{name:"median",value:d.median,enabled:m}],g=[],[p,b]=r;for(let y of c.filter(f=>f.enabled)){let f=t.map(y.value);g.push({type:"line",x1:p,y1:f,x2:b,y2:f,stroke:l,strokeWidth:1});let S=`${y.name}: ${y.value.toFixed(1)}`;(s==="start"||s==="both")&&g.push({type:"text",content:S,x:p+4,y:f-4,anchor:"start",fontSize:10,fill:u}),(s==="end"||s==="both")&&g.push({type:"text",content:S,x:b-4,y:f-4,anchor:"end",fontSize:10,fill:u}),s==="center"&&g.push({type:"text",content:S,x:(p+b)/2,y:f-4,anchor:"middle",fontSize:10,fill:u});}return g}};var M=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,r){try{let o=this.#n&&r?this.#r(e,r,t):t;return new Intl.DateTimeFormat(this.#e,o).format(new Date(e))}catch{for(let o of this.#t)try{return new Intl.DateTimeFormat(o,t).format(new Date(e))}catch{}return new Date(e).toISOString()}}formatRange(e,t){let r=this.format(e),o=this.format(t);return `${r} \u2014 ${o}`}#r(e,t,r){let o=Math.abs(e-t),n=864e5,i=36e5,m=6e4,s={};return o<m?(s.second="2-digit",s.minute="2-digit",s.hour="2-digit"):o<i?(s.minute="2-digit",s.hour="2-digit"):o<n?(s.hour="2-digit",s.minute="2-digit"):o<7*n?(s.weekday="short",s.day="numeric"):o<365*n?(s.month="short",s.day="numeric"):(s.month="short",s.year="numeric"),{...r,...s}}};var D=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 r={};return e.forEach((o,n)=>{r[n]=o;}),new a({map:r,showValue:t})}};var Ie={time:new M,value:new D,enum:new _};var Be={...h};function ie(){return Be}function ae(a,e){let t=ie();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 ce(a){let e=a.style?.line;return e===false?[]:e===void 0?[ae({},a)]:Array.isArray(e)?e.map(t=>ae(t,a)):[ae(e,a)]}function de(a){let e=a.style?.markers;if(!e?.type||e.type==="none")return;let t=ie(),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 he(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 pe(a){return a.style?.gap}function fe(a){return a.style?.fill}function He(a){return {lines:ce(a),fill:fe(a),markers:de(a),shadow:he(a),gap:pe(a),id:a.style?.id??a.id}}/*!
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as DrawCommand, s as DrawGroup, _ as PointStyleType } from './scale-
|
|
1
|
+
import { o as DrawCommand, s as DrawGroup, _ as PointStyleType } from './scale-BRE_QhbZ.js';
|
|
2
2
|
|
|
3
3
|
/** Output format type for the renderer (SVG string, Canvas, or nothing). */
|
|
4
4
|
type RenderType = 'svg' | 'canvas' | 'none';
|
|
@@ -626,6 +626,7 @@ interface Highlight {
|
|
|
626
626
|
* (in the top margin / below the x-axis) so it never overlaps the data.
|
|
627
627
|
*/
|
|
628
628
|
labelPosition?: "top" | "center" | "bottom" | "above" | "below";
|
|
629
|
+
rotate?: number;
|
|
629
630
|
}
|
|
630
631
|
/** A point in data coordinates. `axis` selects the y-scale (0 = left, 1 = right). */
|
|
631
632
|
interface DataPointRef {
|
package/package.json
CHANGED