@photonviz/core 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -83,6 +83,82 @@ interface Bounds {
83
83
  /** RGBA in 0..1. */
84
84
  type Color = readonly [number, number, number, number];
85
85
 
86
+ type RGB = [number, number, number];
87
+ /**
88
+ * Built-in continuous colormaps.
89
+ *
90
+ * Sequential (`viridis`, `plasma`, `inferno`, `magma`, `cividis`, `turbo`,
91
+ * `grayscale`) run low → high and are the default for magnitude data.
92
+ * Diverging (`coolwarm`, `RdBu`, `BrBG`, `spectral`) have a neutral midpoint —
93
+ * pair them with a domain centred on the reference value (see
94
+ * {@link symmetricDomain}). Cyclic (`twilight`) wraps, for phase / angle data.
95
+ *
96
+ * `viridis`, `cividis` and `turbo` stay legible with common colour-vision
97
+ * deficiencies; `RdBu` and `BrBG` are the CVD-safe diverging choices.
98
+ */
99
+ type BuiltinColormapName = "viridis" | "plasma" | "inferno" | "magma" | "cividis" | "turbo" | "grayscale" | "coolwarm" | "RdBu" | "BrBG" | "spectral" | "twilight";
100
+ /**
101
+ * A colormap name. Built-ins autocomplete; any other string resolves through the
102
+ * registry, so `registerColormap("brand", […])` makes `"brand"` usable anywhere a
103
+ * colormap is accepted. Unknown names fall back to `viridis`.
104
+ */
105
+ type ColormapName = BuiltinColormapName | (string & {});
106
+ /** A colormap given inline: a name, or anchor colours interpolated evenly. */
107
+ type ColormapSpec = ColormapName | ReadonlyArray<RGB | string>;
108
+ /** Which family a colormap belongs to — drives colorbar defaults and doc hints. */
109
+ type ColormapKind = "sequential" | "diverging" | "cyclic";
110
+ /**
111
+ * A colormapped layer's scale, surfaced to the plot so it can draw a colorbar.
112
+ * Returned by `Layer.colorInfo()` / `Layer3D.colorInfo()`.
113
+ */
114
+ interface ColorInfo {
115
+ colormap: ColormapSpec;
116
+ /** The value range the colormap spans, after any auto-fit. */
117
+ domain: readonly [number, number];
118
+ /** Caption for the bar — usually the series name. */
119
+ label?: string;
120
+ }
121
+ /** Family of each built-in colormap. Custom ones default to `"sequential"`. */
122
+ declare const COLORMAP_KIND: Record<BuiltinColormapName, ColormapKind>;
123
+ /** Every registered colormap name (built-ins first, then anything registered). */
124
+ declare function colormapNames(): string[];
125
+ /**
126
+ * Register a custom colormap under `name`, so it can be used anywhere a
127
+ * colormap name is accepted — `plot.addHeatmap({ …, colormap: "brand" })`.
128
+ * Anchors are evenly spaced and linearly interpolated; pass `[r,g,b]` triples in
129
+ * 0..1 or CSS hex strings. Re-registering a name replaces it.
130
+ */
131
+ declare function registerColormap(name: string, stops: ReadonlyArray<RGB | string>): void;
132
+ /**
133
+ * The raw `256×3` (r,g,b in 0..1) lookup table for a colormap, cached per name.
134
+ * Hot loops (heatmap, colorBy, …) can index it directly — `j = ((clamp(t)*255)|0)*3`
135
+ * — to avoid a per-element closure call and tuple allocation.
136
+ */
137
+ declare function colormapLUT(spec?: ColormapSpec): Float32Array;
138
+ /**
139
+ * Returns a `(t in 0..1) => RGB` sampler (LUT-backed). Accepts a built-in or
140
+ * registered name, or inline anchor colours.
141
+ */
142
+ declare function colormap(spec?: ColormapSpec): (t: number) => RGB;
143
+ /**
144
+ * A sampler for a custom ramp given as anchor colours (evenly spaced, linearly
145
+ * interpolated). Accepts `[r,g,b]` triples in 0..1 or CSS hex strings.
146
+ */
147
+ declare function colormapFromStops(stops: ReadonlyArray<RGB | string>): (t: number) => RGB;
148
+ /** The reverse of a colormap — high values take the low end's colour. */
149
+ declare function reverseColormap(spec?: ColormapSpec): (t: number) => RGB;
150
+ /**
151
+ * Quantize a colormap into `steps` flat bands — useful when readers must match
152
+ * a colour back to a legend entry rather than judge a continuous shade.
153
+ */
154
+ declare function discreteColormap(spec: ColormapSpec, steps: number): (t: number) => RGB;
155
+ /**
156
+ * A domain centred on `center` (default 0) that covers `values` — what a
157
+ * diverging colormap needs so its neutral midpoint lands on the reference value
158
+ * instead of drifting with the data.
159
+ */
160
+ declare function symmetricDomain(values: ArrayLike<number>, center?: number): [number, number];
161
+
86
162
  /**
87
163
  * Shared data→clip transform used by every layer's vertex shader.
88
164
  *
@@ -128,6 +204,11 @@ interface Layer {
128
204
  x: Range;
129
205
  y: Range;
130
206
  } | null;
207
+ /**
208
+ * Colormap + value range, when this layer maps values to colours — the plot
209
+ * uses it to draw a colorbar. `null`/absent for solid-coloured layers.
210
+ */
211
+ colorInfo?(): ColorInfo | null;
131
212
  draw(state: DrawState): void;
132
213
  dispose(): void;
133
214
  }
@@ -460,17 +541,6 @@ declare class OhlcLayer implements Layer {
460
541
  dispose(): void;
461
542
  }
462
543
 
463
- type RGB = [number, number, number];
464
- type ColormapName = "viridis" | "plasma" | "coolwarm" | "grayscale";
465
- /**
466
- * The raw `256×3` (r,g,b in 0..1) lookup table for a colormap, cached per name.
467
- * Hot loops (heatmap, colorBy, …) can index it directly — `j = ((clamp(t)*255)|0)*3`
468
- * — to avoid a per-element closure call and tuple allocation.
469
- */
470
- declare function colormapLUT(name?: ColormapName): Float32Array;
471
- /** Returns a `(t in 0..1) => RGB` sampler for the named colormap (LUT-backed). */
472
- declare function colormap(name?: ColormapName): (t: number) => RGB;
473
-
474
544
  interface ContourOptions {
475
545
  /** Row-major grid values, length `cols * rows` (row 0 at the bottom). */
476
546
  values: ArrayLike<number>;
@@ -484,7 +554,9 @@ interface ContourOptions {
484
554
  levels?: number[] | number;
485
555
  /** Single line color; if omitted, levels are colored by a colormap. */
486
556
  color?: string | Color;
487
- colormap?: ColormapName;
557
+ colormap?: ColormapSpec;
558
+ /** Series name — used as the colorbar caption. */
559
+ name?: string;
488
560
  /** Buffer-usage hint; set `"dynamic"` when streaming via setData. Default `"static"`. */
489
561
  renderType?: RenderType;
490
562
  yAxis?: string;
@@ -505,6 +577,9 @@ declare class ContourLayer implements Layer {
505
577
  private rows;
506
578
  private levelsOpt;
507
579
  private cmap;
580
+ private cmapName;
581
+ private cInfo;
582
+ private label?;
508
583
  private fixedColor;
509
584
  private usage;
510
585
  constructor(gl: WebGL2RenderingContext, opts: ContourOptions);
@@ -512,6 +587,7 @@ declare class ContourLayer implements Layer {
512
587
  private build;
513
588
  /** Replace the scalar field and recompute the iso lines (for streaming). */
514
589
  setData(values: ArrayLike<number>, cols?: number, rows?: number): void;
590
+ colorInfo(): ColorInfo | null;
515
591
  bounds(): {
516
592
  x: Range;
517
593
  y: Range;
@@ -521,6 +597,7 @@ declare class ContourLayer implements Layer {
521
597
  }
522
598
 
523
599
  /** A per-point error, given as one value for all points or an array. */
600
+ /** A per-point error array, or one value applied to every point. */
524
601
  type ErrInput = ArrayLike<number> | number;
525
602
  interface ErrorBarOptions {
526
603
  x: ArrayLike<number>;
@@ -671,9 +748,11 @@ interface HeatmapOptions {
671
748
  x: Range;
672
749
  y: Range;
673
750
  };
674
- colormap?: ColormapName;
751
+ colormap?: ColormapSpec;
675
752
  /** Value range mapped to the colormap. Defaults to the data min/max. */
676
753
  domain?: Range;
754
+ /** Series name — used as the colorbar caption. */
755
+ name?: string;
677
756
  /** Bilinear filtering (default true) vs. hard cells. */
678
757
  smooth?: boolean;
679
758
  /** Buffer-usage hint; set `"dynamic"` when streaming via setData. Default `"static"`. */
@@ -696,11 +775,15 @@ declare class HeatmapLayer implements Layer {
696
775
  private fixedDomain;
697
776
  private cols;
698
777
  private rows;
778
+ private cmapName;
779
+ private cInfo;
780
+ private label?;
699
781
  constructor(gl: WebGL2RenderingContext, opts: HeatmapOptions);
700
782
  /** Bake a `cols*rows` value grid into the RGBA data texture via the colormap. */
701
783
  private uploadValues;
702
784
  /** Replace the value grid and re-bake the data texture (for streaming). */
703
785
  setData(values: ArrayLike<number>, cols?: number, rows?: number): void;
786
+ colorInfo(): ColorInfo | null;
704
787
  bounds(): {
705
788
  x: Range;
706
789
  y: Range;
@@ -714,9 +797,11 @@ interface HexbinOptions {
714
797
  y: ArrayLike<number>;
715
798
  /** Hex radius in data units. Defaults to ~1/30 of the x-extent. */
716
799
  radius?: number;
717
- colormap?: ColormapName;
800
+ colormap?: ColormapSpec;
718
801
  /** Count range mapped to the colormap. Defaults to [1, maxCount]. */
719
802
  domain?: Range;
803
+ /** Series name — used as the colorbar caption. */
804
+ name?: string;
720
805
  /** Buffer-usage hint; set `"dynamic"` when streaming via setData. Default `"static"`. */
721
806
  renderType?: RenderType;
722
807
  yAxis?: string;
@@ -738,12 +823,16 @@ declare class HexbinLayer implements Layer {
738
823
  private cmap;
739
824
  private explicitRadius;
740
825
  private domain;
826
+ private cmapName;
827
+ private cInfo;
828
+ private label?;
741
829
  private usage;
742
830
  constructor(gl: WebGL2RenderingContext, opts: HexbinOptions);
743
831
  /** Bin the points into hex cells; sets radius, refs, bounds and cell count. */
744
832
  private build;
745
833
  /** Replace the point arrays, re-bin and re-upload the cells (for streaming). */
746
834
  setData(x: ArrayLike<number>, y: ArrayLike<number>): void;
835
+ colorInfo(): ColorInfo | null;
747
836
  bounds(): {
748
837
  x: Range;
749
838
  y: Range;
@@ -856,6 +945,12 @@ interface LineOptions {
856
945
  * Default 4.
857
946
  */
858
947
  miterLimit?: number;
948
+ /**
949
+ * Dash pattern in CSS pixels, alternating on/off lengths (Canvas
950
+ * `setLineDash` semantics) — e.g. `[6, 4]`. Up to 8 entries. Dashing turns
951
+ * decimation off, since a dashed line is a low-point-count annotation.
952
+ */
953
+ dash?: number[];
859
954
  /**
860
955
  * Min/max decimate very large series to ~2 points per pixel column when
861
956
  * zoomed out (preserves peaks). Requires monotonic x; auto-detected. Default true.
@@ -888,6 +983,10 @@ declare class LineLayer implements Layer {
888
983
  private joinStyle;
889
984
  private miterLimit;
890
985
  private decimateOn;
986
+ /** Dash pattern in CSS px (empty = solid) and its period. */
987
+ private dash;
988
+ private dashPeriod;
989
+ private distBuf;
891
990
  private monotonic;
892
991
  private gpuDec;
893
992
  private step?;
@@ -937,7 +1036,7 @@ interface PatchesOptions {
937
1036
  /** Default fill for patches without their own `color`/`value`. */
938
1037
  color?: string | Color;
939
1038
  /** Color patches by `value` through this colormap (choropleth). */
940
- colormap?: ColormapName;
1039
+ colormap?: ColormapSpec;
941
1040
  /** Value range mapped to [0,1] for the colormap. Defaults to the data min/max. */
942
1041
  domain?: Range;
943
1042
  /** Fill opacity, 0..1. Default 1. */
@@ -971,12 +1070,15 @@ declare class PatchesLayer implements Layer {
971
1070
  private opacity;
972
1071
  private cmap;
973
1072
  private domainOpt;
1073
+ private cmapName;
1074
+ private cInfo;
974
1075
  private usage;
975
1076
  constructor(gl: WebGL2RenderingContext, opts: PatchesOptions);
976
1077
  /** Triangulate the patches and recompute refs/bounds/vertexCount into position/color arrays. */
977
1078
  private build;
978
1079
  /** Replace the patches and re-upload (for streaming). */
979
1080
  setData(patches: Patch[]): void;
1081
+ colorInfo(): ColorInfo | null;
980
1082
  bounds(): {
981
1083
  x: Range;
982
1084
  y: Range;
@@ -991,7 +1093,7 @@ interface PieOptions {
991
1093
  /** Explicit per-slice colors; falls back to `colormap`, then a default palette. */
992
1094
  colors?: (string | Color)[];
993
1095
  /** Color slices by index through this colormap instead of the palette. */
994
- colormap?: ColormapName;
1096
+ colormap?: ColormapSpec;
995
1097
  /** Center in data space. Default `[0, 0]`. */
996
1098
  center?: [number, number];
997
1099
  /** Outer radius in data units. Default `1`. */
@@ -1063,7 +1165,7 @@ interface QuiverOptions {
1063
1165
  /** Color each arrow by a value (default: its magnitude) through a colormap. */
1064
1166
  colorBy?: {
1065
1167
  values?: ArrayLike<number>;
1066
- colormap?: ColormapName;
1168
+ colormap?: ColormapSpec;
1067
1169
  domain?: Range;
1068
1170
  };
1069
1171
  /** Buffer-usage hint; set `"dynamic"` when streaming via setData. Default `"static"`. */
@@ -1089,6 +1191,8 @@ declare class QuiverLayer implements Layer {
1089
1191
  private useVertexColor;
1090
1192
  private explicitScale;
1091
1193
  private colorBy;
1194
+ private cInfo;
1195
+ private label?;
1092
1196
  private usage;
1093
1197
  private count;
1094
1198
  private xRef;
@@ -1101,6 +1205,7 @@ declare class QuiverLayer implements Layer {
1101
1205
  private build;
1102
1206
  /** Replace the data and re-upload (for streaming). */
1103
1207
  setData(x: ArrayLike<number>, y: ArrayLike<number>, u: ArrayLike<number>, v: ArrayLike<number>): void;
1208
+ colorInfo(): ColorInfo | null;
1104
1209
  bounds(): {
1105
1210
  x: Range;
1106
1211
  y: Range;
@@ -1117,6 +1222,16 @@ interface ScatterOptions {
1117
1222
  color?: string | Color;
1118
1223
  /** Marker diameter in CSS pixels. */
1119
1224
  size?: number;
1225
+ /**
1226
+ * Per-point diameter in CSS pixels — a bubble chart. Overrides {@link size}
1227
+ * wherever it is `> 0`; entries of `0` fall back to the uniform size.
1228
+ */
1229
+ sizes?: ArrayLike<number>;
1230
+ /**
1231
+ * Explicit per-point colors. Overrides {@link color}; ignored when
1232
+ * {@link colorBy} is set (that drives the same per-point buffer).
1233
+ */
1234
+ colors?: ReadonlyArray<string | Color>;
1120
1235
  /** Marker glyph. Default `"circle"`. */
1121
1236
  marker?: MarkerShape;
1122
1237
  name?: string;
@@ -1130,7 +1245,7 @@ interface ScatterOptions {
1130
1245
  /** Color each point by a value through a colormap. */
1131
1246
  colorBy?: {
1132
1247
  values: ArrayLike<number>;
1133
- colormap?: ColormapName;
1248
+ colormap?: ColormapSpec;
1134
1249
  /** Value range mapped to [0,1]. Defaults to the data min/max. */
1135
1250
  domain?: Range;
1136
1251
  };
@@ -1149,10 +1264,13 @@ declare class ScatterLayer implements Layer {
1149
1264
  private uniforms;
1150
1265
  private count;
1151
1266
  private size;
1267
+ /** Largest marker diameter in play, for the hover hit gate. */
1268
+ private maxSize;
1152
1269
  private marker;
1153
1270
  private usage;
1154
1271
  private color;
1155
1272
  private useVertexColor;
1273
+ private cInfo;
1156
1274
  private labels?;
1157
1275
  private xRef;
1158
1276
  private yRef;
@@ -1161,6 +1279,7 @@ declare class ScatterLayer implements Layer {
1161
1279
  private xBounds;
1162
1280
  private yBounds;
1163
1281
  constructor(gl: WebGL2RenderingContext, opts: ScatterOptions);
1282
+ colorInfo(): ColorInfo | null;
1164
1283
  bounds(): {
1165
1284
  x: Range;
1166
1285
  y: Range;
@@ -1399,6 +1518,40 @@ declare function downloadCanvas(canvas: HTMLCanvasElement, filename?: string, ty
1399
1518
  /** Copy a canvas to the clipboard as a PNG. Throws where the browser can't. */
1400
1519
  declare function copyCanvasToClipboard(canvas: HTMLCanvasElement): Promise<void>;
1401
1520
 
1521
+ interface ColorbarOptions {
1522
+ /** Which side of the plot region the bar sits on. Default `"right"`. */
1523
+ position?: "right" | "left";
1524
+ /** Caption above the bar. Defaults to the layer's `name`. */
1525
+ label?: string;
1526
+ /** Bar thickness in px. Default 12. */
1527
+ width?: number;
1528
+ /** Fraction of the plot height the bar spans, 0..1. Default 0.72. */
1529
+ heightFraction?: number;
1530
+ /** Target number of tick labels. Default 5. */
1531
+ ticks?: number;
1532
+ /** Formats a tick value. Defaults to a compact 3-significant-digit formatter. */
1533
+ format?: (value: number) => string;
1534
+ textColor?: string;
1535
+ borderColor?: string;
1536
+ font?: string;
1537
+ }
1538
+ /** Resolved chrome colours, so the bar can match either plot theme. */
1539
+ interface ColorbarTheme {
1540
+ text: string;
1541
+ border: string;
1542
+ font: string;
1543
+ }
1544
+ /**
1545
+ * A CSS `linear-gradient` for a colormap. `to top` puts the domain minimum at
1546
+ * the bottom, matching the tick labels drawn beside it.
1547
+ */
1548
+ declare function colormapGradient(spec: ColormapSpec, stops?: number): string;
1549
+ /**
1550
+ * Fill `host` with one bar per colour scale, stacked vertically inside
1551
+ * `regionHeight` px. Hides the host when there is nothing to show.
1552
+ */
1553
+ declare function renderColorbars(host: HTMLElement, infos: readonly ColorInfo[], opts: ColorbarOptions, theme: ColorbarTheme, regionHeight: number): void;
1554
+
1402
1555
  interface AxisScaleOptions {
1403
1556
  type?: ScaleType;
1404
1557
  /** Fixed domain. If omitted, the axis autoscales to the data. */
@@ -1422,6 +1575,11 @@ interface LegendOptions {
1422
1575
  border?: string;
1423
1576
  textColor?: string;
1424
1577
  font?: string;
1578
+ /**
1579
+ * Click a legend entry to show/hide its series (axes re-fit to what is left).
1580
+ * Entries are focusable and respond to Enter/Space. Default true.
1581
+ */
1582
+ interactive?: boolean;
1425
1583
  }
1426
1584
  interface YAxisOptions extends AxisConfig {
1427
1585
  type?: ScaleType;
@@ -1584,6 +1742,13 @@ interface PlotOptions {
1584
1742
  title?: string | PlotTitleOptions;
1585
1743
  /** Show a legend of named series. `true` uses defaults; pass an object to place/style it. */
1586
1744
  legend?: boolean | LegendOptions;
1745
+ /**
1746
+ * Show a colorbar for every layer that maps values to colours (heatmap,
1747
+ * hexbin, contour, choropleth patches, `colorBy` scatter/quiver). Enabled by
1748
+ * default — a colour scale nobody can read is not a scale. Pass `false` to
1749
+ * suppress it, or an object to place/style it.
1750
+ */
1751
+ colorbar?: boolean | ColorbarOptions;
1587
1752
  margin?: Partial<Layout["margin"]>;
1588
1753
  /** Enable wheel-zoom and drag interaction. Default true. */
1589
1754
  interactive?: boolean;
@@ -1699,10 +1864,19 @@ declare class Plot {
1699
1864
  private title;
1700
1865
  private legend;
1701
1866
  private legendDiv;
1867
+ private colorbar;
1868
+ private colorbarDiv;
1869
+ /** Ids of layers hidden via the legend / {@link setLayerVisible}. */
1870
+ private hidden;
1871
+ private visibilityCbs;
1702
1872
  constructor(container: HTMLElement, options?: PlotOptions);
1703
1873
  private makeCanvas;
1704
1874
  /** Margins grow to make room for extra y axes on each side. */
1705
1875
  private computeMargin;
1876
+ /** Colour scales reported by the layers, in draw order. */
1877
+ private colorInfos;
1878
+ /** Rebuild + place the colorbar stack in the reserved side margin. */
1879
+ private updateColorbars;
1706
1880
  private layout;
1707
1881
  /** Pixel x-position (and title x) for each y axis, by draw order per side. */
1708
1882
  private yAxisPositions;
@@ -1719,6 +1893,12 @@ declare class Plot {
1719
1893
  add<T extends Layer>(layer: T): T;
1720
1894
  /** The shared WebGL2 context, for constructing custom layers. */
1721
1895
  get context(): WebGL2RenderingContext;
1896
+ /**
1897
+ * The container this plot renders into (already `position: relative`), for
1898
+ * custom overlays — a chart-specific tooltip, a colorbar, a caption. Append
1899
+ * absolutely-positioned children with `zIndex >= 3` to sit above the canvases.
1900
+ */
1901
+ get element(): HTMLElement;
1722
1902
  /**
1723
1903
  * Convert a client (screen) coordinate to data space — the shared x and the
1724
1904
  * primary y. Returns null if the point is outside the plot region. Useful for
@@ -1883,6 +2063,14 @@ declare class Plot {
1883
2063
  render(): void;
1884
2064
  /** Named series that can appear in the legend: any layer exposing name + colorCss. */
1885
2065
  private legendEntries;
2066
+ /** Whether a layer is currently drawn (hidden layers also drop out of autoscale). */
2067
+ isLayerVisible(layer: Layer): boolean;
2068
+ /** Show or hide a layer, re-fitting the auto axes to what remains visible. */
2069
+ setLayerVisible(layer: Layer, visible: boolean): void;
2070
+ /** Flip a layer's visibility. Returns the new state. */
2071
+ toggleLayer(layer: Layer): boolean;
2072
+ /** Subscribe to show/hide changes (legend clicks included). Returns an unsubscribe fn. */
2073
+ onVisibilityChange(cb: (layer: Layer, visible: boolean) => void): () => void;
1886
2074
  /** Rebuild and position the legend overlay (or hide it). */
1887
2075
  private updateLegend;
1888
2076
  /** Draw all annotations, projected through the scales and clipped to the region. */
@@ -2125,12 +2313,7 @@ interface Bounds3 {
2125
2313
  y: Range;
2126
2314
  z: Range;
2127
2315
  }
2128
- /** A colormapped layer's scale, surfaced to {@link Plot3D} for a colorbar. */
2129
- interface ColorInfo {
2130
- colormap: ColormapName;
2131
- domain: Range;
2132
- label?: string;
2133
- }
2316
+
2134
2317
  /** A drawable in the 3D scene. Positions are in world space; Plot3D supplies the MVP. */
2135
2318
  interface Layer3D {
2136
2319
  readonly id: string;
@@ -2166,7 +2349,7 @@ interface Bar3DOptions {
2166
2349
  /** Color bars via a colormap (over `values`, default the heights). */
2167
2350
  colorBy?: {
2168
2351
  values?: ArrayLike<number>;
2169
- colormap?: ColormapName;
2352
+ colormap?: ColormapSpec;
2170
2353
  domain?: Range;
2171
2354
  };
2172
2355
  name?: string;
@@ -2211,6 +2394,77 @@ declare class Bar3DLayer implements Layer3D {
2211
2394
  dispose(): void;
2212
2395
  }
2213
2396
 
2397
+ /** One axis-aligned cuboid: a center plus a full size on each axis. */
2398
+ interface Box3D {
2399
+ /** Center (world space). */
2400
+ x: number;
2401
+ y: number;
2402
+ z: number;
2403
+ /** Full size along x / y / z. */
2404
+ w: number;
2405
+ h: number;
2406
+ d: number;
2407
+ /** Fill color; falls back to the layer default. */
2408
+ color?: string | Color;
2409
+ /** Hover tooltip text for this box. */
2410
+ label?: string;
2411
+ }
2412
+ interface Boxes3DOptions {
2413
+ boxes: Box3D[];
2414
+ /** Default fill for boxes without their own `color`. */
2415
+ color?: string | Color;
2416
+ /**
2417
+ * Fill opacity 0..1. Default 1. Values below 1 blend without depth sorting,
2418
+ * so overlapping translucent boxes can composite out of order.
2419
+ */
2420
+ opacity?: number;
2421
+ name?: string;
2422
+ /** Buffer-usage hint; set `"dynamic"` when streaming via setData. Default `"static"`. */
2423
+ renderType?: RenderType;
2424
+ }
2425
+ /**
2426
+ * Independently sized, lit cuboids drawn as one instanced call — voxels,
2427
+ * bounding boxes, 3D waterfalls, and the layer blocks of a model diagram.
2428
+ * Unlike {@link Bar3DLayer} every box carries its own center and 3-axis size.
2429
+ */
2430
+ declare class Boxes3DLayer implements Layer3D {
2431
+ readonly id: string;
2432
+ readonly name?: string;
2433
+ readonly colorCss: string;
2434
+ private gl;
2435
+ private program;
2436
+ private vao;
2437
+ private buffers;
2438
+ private instBuf;
2439
+ private uniforms;
2440
+ private count;
2441
+ private b3;
2442
+ private positions;
2443
+ private labels;
2444
+ private base;
2445
+ private opacity;
2446
+ private usage;
2447
+ private lightDir;
2448
+ private ambient;
2449
+ constructor(gl: WebGL2RenderingContext, opts: Boxes3DOptions);
2450
+ /** Pack the instance attributes, recompute bounds/pick data, and upload. */
2451
+ private build;
2452
+ /** Replace every box. Call `plot.refresh()` afterwards to re-fit + redraw. */
2453
+ setData(boxes: Box3D[]): void;
2454
+ bounds3(): Bounds3 | null;
2455
+ pickData(): {
2456
+ positions: Float32Array<ArrayBuffer>;
2457
+ label: (i: number) => string;
2458
+ } | {
2459
+ positions: Float32Array<ArrayBuffer>;
2460
+ label?: undefined;
2461
+ } | null;
2462
+ /** Set the light direction (world space) and ambient term (0..1). */
2463
+ setLight(dir: [number, number, number], ambient: number): void;
2464
+ draw(gl: WebGL2RenderingContext, mvp: Mat4): void;
2465
+ dispose(): void;
2466
+ }
2467
+
2214
2468
  interface Contour3DOptions {
2215
2469
  /** Row-major height grid, length `cols * rows`. */
2216
2470
  values: ArrayLike<number>;
@@ -2223,7 +2477,7 @@ interface Contour3DOptions {
2223
2477
  levels?: number[] | number;
2224
2478
  /** Single line color; if omitted, levels are colored by a colormap. */
2225
2479
  color?: string | Color;
2226
- colormap?: ColormapName;
2480
+ colormap?: ColormapSpec;
2227
2481
  name?: string;
2228
2482
  /** Buffer-usage hint; set `"dynamic"` when streaming via setData. Default `"static"`. */
2229
2483
  renderType?: RenderType;
@@ -2366,7 +2620,7 @@ interface PointCloudOptions {
2366
2620
  sizes?: ArrayLike<number>;
2367
2621
  colorBy?: {
2368
2622
  values: ArrayLike<number>;
2369
- colormap?: ColormapName;
2623
+ colormap?: ColormapSpec;
2370
2624
  domain?: Range;
2371
2625
  };
2372
2626
  /** Per-point tooltip text (parallel to x/y/z). */
@@ -2422,7 +2676,7 @@ interface Quiver3DOptions {
2422
2676
  color?: string | Color;
2423
2677
  /** Color arrows by magnitude via a colormap. */
2424
2678
  colorBy?: {
2425
- colormap?: ColormapName;
2679
+ colormap?: ColormapSpec;
2426
2680
  domain?: Range;
2427
2681
  };
2428
2682
  /** Arrowhead length as a fraction of the arrow. Default 0.28. */
@@ -2472,7 +2726,7 @@ interface SurfaceOptions {
2472
2726
  /** World extent of the grid footprint. Defaults to unit indices. */
2473
2727
  extentX?: Range;
2474
2728
  extentZ?: Range;
2475
- colormap?: ColormapName;
2729
+ colormap?: ColormapSpec;
2476
2730
  /** Series name (colorbar label / legend). */
2477
2731
  name?: string;
2478
2732
  /** Render the grid as a wireframe (lines) instead of a lit filled surface. */
@@ -2528,7 +2782,7 @@ interface VolumeOptions {
2528
2782
  y: Range;
2529
2783
  z: Range;
2530
2784
  };
2531
- colormap?: ColormapName;
2785
+ colormap?: ColormapSpec;
2532
2786
  /** Value range mapped to the colormap + opacity. Defaults to the data min/max. */
2533
2787
  domain?: Range;
2534
2788
  /** Overall opacity multiplier. Default 1. */
@@ -2603,9 +2857,43 @@ interface Plot3DOptions {
2603
2857
  downloadButton?: boolean;
2604
2858
  /** Draw grid lines on the back walls of the cube. Default true. */
2605
2859
  gridPlanes?: boolean;
2860
+ /**
2861
+ * How data extents map into the view cube. `"cube"` (default) stretches each
2862
+ * axis independently to fill it — best for surfaces, where relative shape
2863
+ * matters more than units. `"data"` uses one shared scale so proportions are
2864
+ * preserved: a long, thin scene stays long and thin.
2865
+ */
2866
+ aspectMode?: "cube" | "data";
2867
+ /** Draw the bounding box, tick marks and axis labels. Default true. */
2868
+ showAxes?: boolean;
2869
+ /**
2870
+ * Camera projection. `"perspective"` (default) is the natural choice for
2871
+ * surfaces and point clouds; `"orthographic"` removes the perspective divide,
2872
+ * so a long scene keeps a constant scale end-to-end — the right pick for
2873
+ * diagrams. `distance` then sets the visible half-height instead of the eye
2874
+ * distance. Volume raymarching assumes perspective and ignores this.
2875
+ */
2876
+ projection?: "perspective" | "orthographic";
2606
2877
  /** Auto-orbit the camera: `true` for a default speed, or radians/frame. Default off. */
2607
2878
  autoRotate?: boolean | number;
2608
2879
  }
2880
+ /** A text label pinned to a point in *data* space, re-projected every frame. */
2881
+ interface Label3D {
2882
+ x: number;
2883
+ y: number;
2884
+ z: number;
2885
+ text: string;
2886
+ color?: string;
2887
+ /** CSS `font` shorthand. Default `"11px system-ui, sans-serif"`. */
2888
+ font?: string;
2889
+ /** Screen-space nudge in CSS px, applied after projection. */
2890
+ dx?: number;
2891
+ dy?: number;
2892
+ /** Horizontal alignment about the projected point. Default `"center"`. */
2893
+ align?: CanvasTextAlign;
2894
+ /** Vertical alignment about the projected point. Default `"middle"`. */
2895
+ baseline?: CanvasTextBaseline;
2896
+ }
2609
2897
  /** A 3D scatter/surface plot with an orbit camera, axis ticks, and lighting. */
2610
2898
  declare class Plot3D {
2611
2899
  private container;
@@ -2632,9 +2920,14 @@ declare class Plot3D {
2632
2920
  private tickBuf;
2633
2921
  private tickCount;
2634
2922
  private labels;
2923
+ /** User labels anchored in data space (see {@link addLabel3D}). */
2924
+ private dataLabels;
2635
2925
  /** Tick positions in cube space [-1,1], per axis, for the grid planes. */
2636
2926
  private tickCube;
2637
2927
  private gridPlanes;
2928
+ private aspectMode;
2929
+ private showAxes;
2930
+ private projection;
2638
2931
  private gridVao;
2639
2932
  private gridBuf;
2640
2933
  /** Normalize params (world→cube: `cube = s*world + t`), for the volume camera. */
@@ -2670,6 +2963,8 @@ declare class Plot3D {
2670
2963
  addLine3D(opts: Line3DOptions): Line3DLayer;
2671
2964
  /** 3D bars (columns) on an x/z grid, lit and optionally colormapped. */
2672
2965
  addBar3D(opts: Bar3DOptions): Bar3DLayer;
2966
+ /** Independently sized lit cuboids (voxels, bounding boxes, model layer blocks). */
2967
+ addBoxes3D(opts: Boxes3DOptions): Boxes3DLayer;
2673
2968
  /** A 3D vector field (arrows), optionally colored by magnitude. */
2674
2969
  addQuiver3D(opts: Quiver3DOptions): Quiver3DLayer;
2675
2970
  /** 3D iso-height contour lines of a grid, stacked at their level heights. */
@@ -2678,6 +2973,14 @@ declare class Plot3D {
2678
2973
  addIsosurface(opts: IsosurfaceOptions): IsosurfaceLayer;
2679
2974
  /** Direct volume rendering (GPU raymarch) of a 3D scalar field. */
2680
2975
  addVolume(opts: VolumeOptions): VolumeLayer;
2976
+ /**
2977
+ * Pin a text label to a point in data space. It is re-projected every frame,
2978
+ * so it tracks the point as the camera orbits. Returns a disposer that removes
2979
+ * just this label.
2980
+ */
2981
+ addLabel3D(label: Label3D): () => void;
2982
+ /** Remove every data-space label. */
2983
+ clearLabels3D(): void;
2681
2984
  /** Update the light direction (azimuth/elevation, radians) and ambient (0..1). */
2682
2985
  setLight(params: {
2683
2986
  azimuth?: number;
@@ -2721,6 +3024,12 @@ declare class Plot3D {
2721
3024
  private updateLegend;
2722
3025
  /** DOM colorbar for the first colormapped layer (gradient + value range). */
2723
3026
  private updateColorbar;
3027
+ /**
3028
+ * Draw the user's data-space labels. Coordinates come out of the projection in
3029
+ * device px; we scale the context by dpr instead so the caller's `font` string
3030
+ * means CSS px, and outline each label so it stays readable over any fill.
3031
+ */
3032
+ private drawDataLabels;
2724
3033
  private drawLabels;
2725
3034
  private attachControls;
2726
3035
  private buildControls;
@@ -2835,6 +3144,126 @@ interface Density {
2835
3144
  */
2836
3145
  declare function kde(values: ArrayLike<number>, lo: number, hi: number, points?: number, bandwidth?: number): Density;
2837
3146
 
3147
+ /** Window (taper) applied to a frame before an FFT, to suppress spectral leakage. */
3148
+ type WindowName = "rectangular" | "hann" | "hamming" | "blackman" | "bartlett";
3149
+ /**
3150
+ * Sample a window function over `n` points.
3151
+ *
3152
+ * `hann` is the sane default; `hamming` trades a touch of leakage for a lower
3153
+ * first sidelobe; `blackman` suppresses sidelobes hardest at the cost of
3154
+ * resolution; `bartlett` (triangular) is cheap; `rectangular` is no window at
3155
+ * all — use it only when the frame already contains whole periods.
3156
+ */
3157
+ declare function windowFunction(name: WindowName, n: number): Float64Array;
3158
+ /** A one-sided power spectral density estimate. */
3159
+ interface Psd {
3160
+ /** Frequencies in Hz (or cycles/sample when `sampleRate` is 1). */
3161
+ frequencies: Float64Array;
3162
+ /** Power per bin, in units²/Hz. */
3163
+ power: Float64Array;
3164
+ }
3165
+ interface WelchOptions {
3166
+ /** Samples per segment (rounded down to a power of two). Default 256. */
3167
+ segment?: number;
3168
+ /** Overlap between segments, 0..1. Default 0.5. */
3169
+ overlap?: number;
3170
+ window?: WindowName;
3171
+ sampleRate?: number;
3172
+ }
3173
+ /**
3174
+ * Welch's method: average the periodograms of overlapping windowed segments.
3175
+ * Trades frequency resolution for a far lower-variance estimate than a single
3176
+ * FFT of the whole signal — the standard way to read a noisy spectrum.
3177
+ */
3178
+ declare function welch(signal: ArrayLike<number>, opts?: WelchOptions): Psd;
3179
+ /**
3180
+ * Savitzky–Golay smoothing: least-squares fit a polynomial over a sliding
3181
+ * window. Unlike a moving average it preserves peak height and width, which is
3182
+ * why spectroscopy and sensor pipelines reach for it.
3183
+ *
3184
+ * `window` must be odd (rounded up) and larger than `order`. Edges are handled
3185
+ * by clamping to the nearest sample.
3186
+ */
3187
+ declare function savitzkyGolay(values: ArrayLike<number>, window?: number, order?: number): Float64Array;
3188
+ /** A correlation sequence indexed by lag. */
3189
+ interface Correlation {
3190
+ /** Lags, from `-maxLag` to `+maxLag`. */
3191
+ lags: Int32Array;
3192
+ /** Correlation at each lag. */
3193
+ values: Float64Array;
3194
+ }
3195
+ /**
3196
+ * Cross-correlation of two series over ±`maxLag`. `normalize` (default true)
3197
+ * divides by the zero-lag autocorrelations, so the result is a correlation
3198
+ * coefficient in −1..1 and the peak lag reads directly as "b lags a by k".
3199
+ * Pass the same array twice for an autocorrelation.
3200
+ */
3201
+ declare function crossCorrelate(a: ArrayLike<number>, b: ArrayLike<number>, maxLag?: number, normalize?: boolean): Correlation;
3202
+
3203
+ /**
3204
+ * Fits and summaries that turn a scatter into a claim: a trend line with a
3205
+ * confidence band, a local-regression smoother, an ECDF, a correlation matrix.
3206
+ * Pure — every function takes arrays and returns arrays.
3207
+ */
3208
+ /** An ordinary-least-squares fit of `y = slope·x + intercept`. */
3209
+ interface LinearFit {
3210
+ slope: number;
3211
+ intercept: number;
3212
+ /** Coefficient of determination, 0..1. */
3213
+ r2: number;
3214
+ /** Standard error of the residuals. */
3215
+ stderr: number;
3216
+ /** Points used (non-finite pairs are skipped). */
3217
+ n: number;
3218
+ /** Evaluate the fit at an x. */
3219
+ predict(x: number): number;
3220
+ }
3221
+ /** Least-squares straight line through (x, y), skipping non-finite pairs. */
3222
+ declare function linearRegression(x: ArrayLike<number>, y: ArrayLike<number>): LinearFit;
3223
+ /** A smoothed curve sampled on a grid, optionally with a band around it. */
3224
+ interface Trend {
3225
+ x: Float64Array;
3226
+ y: Float64Array;
3227
+ /** Lower/upper band, when the caller asked for one. */
3228
+ lower?: Float64Array;
3229
+ upper?: Float64Array;
3230
+ }
3231
+ /**
3232
+ * Sample a linear fit across the data range, with an optional ±`k`·stderr band.
3233
+ * `points` controls the resolution (2 is enough for the line itself).
3234
+ */
3235
+ declare function linearTrend(x: ArrayLike<number>, y: ArrayLike<number>, opts?: {
3236
+ points?: number;
3237
+ band?: number;
3238
+ }): Trend;
3239
+ /**
3240
+ * LOESS: locally-weighted linear regression with a tricube kernel. `bandwidth`
3241
+ * is the fraction of points in each local neighbourhood (0..1, default 0.3) —
3242
+ * larger is smoother. Returns the fit sampled on a sorted grid, so it can be
3243
+ * drawn straight as a line.
3244
+ */
3245
+ declare function loess(x: ArrayLike<number>, y: ArrayLike<number>, opts?: {
3246
+ bandwidth?: number;
3247
+ points?: number;
3248
+ }): Trend;
3249
+ /** The empirical CDF as a step function: sorted values against their cumulative proportion. */
3250
+ declare function ecdf(values: ArrayLike<number>): {
3251
+ x: Float64Array;
3252
+ y: Float64Array;
3253
+ };
3254
+ /** Standardize to zero mean and unit variance (population sd). Non-finite entries pass through. */
3255
+ declare function zscore(values: ArrayLike<number>): Float64Array;
3256
+ /** Pearson correlation of two equal-length series (0 when either is constant). */
3257
+ declare function correlation(a: ArrayLike<number>, b: ArrayLike<number>): number;
3258
+ /**
3259
+ * Pearson correlation matrix of `columns`, row-major and `k×k`. Feed it straight
3260
+ * to `addHeatmap` with a diverging colormap and `symmetricDomain`.
3261
+ */
3262
+ declare function corrMatrix(columns: ReadonlyArray<ArrayLike<number>>): {
3263
+ values: Float64Array;
3264
+ size: number;
3265
+ };
3266
+
2838
3267
  /** Map a layer's {@link RenderType} to a WebGL buffer-usage hint (default STATIC_DRAW). */
2839
3268
  declare function bufferUsage(gl: WebGL2RenderingContext, renderType?: RenderType): number;
2840
3269
  /** Compile + link a vertex/fragment program. */
@@ -2951,6 +3380,49 @@ interface FibLevel {
2951
3380
  /** Fibonacci retracement price levels between a `high` and `low` (standard ratios). */
2952
3381
  declare function fibRetracements(high: number, low: number, ratios?: number[]): FibLevel[];
2953
3382
 
3383
+ /**
3384
+ * Commodity Channel Index: how far the typical price sits from its own moving
3385
+ * average, scaled by mean deviation. ±100 is the conventional band.
3386
+ */
3387
+ declare function cci(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period?: number): Float64Array;
3388
+ /**
3389
+ * Money Flow Index — RSI weighted by volume, so a move on thin volume counts
3390
+ * for less. 0..100, with 20/80 the usual oversold/overbought lines.
3391
+ */
3392
+ declare function mfi(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, volume: ArrayLike<number>, period?: number): Float64Array;
3393
+ /** Williams %R: where the close sits in the `period` high-low range, as −100..0. */
3394
+ declare function williamsR(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period?: number): Float64Array;
3395
+ /** Aroon: how recently the `period` high and low were set, plus their difference. */
3396
+ interface Aroon {
3397
+ up: Float64Array;
3398
+ down: Float64Array;
3399
+ oscillator: Float64Array;
3400
+ }
3401
+ /**
3402
+ * Aroon Up/Down — 100 means the extreme was set this bar, 0 means `period` bars
3403
+ * ago. The oscillator (up − down) reads as trend strength and direction.
3404
+ */
3405
+ declare function aroon(high: ArrayLike<number>, low: ArrayLike<number>, period?: number): Aroon;
3406
+ /** Donchian Channels: the rolling `period` high/low and their midline (turtle breakout bands). */
3407
+ declare function donchian(high: ArrayLike<number>, low: ArrayLike<number>, period?: number): Channel;
3408
+ /**
3409
+ * Parabolic SAR — the trailing stop-and-reverse dots. `step` is the
3410
+ * acceleration increment and `max` its ceiling (Wilder's 0.02 / 0.2).
3411
+ */
3412
+ declare function parabolicSar(high: ArrayLike<number>, low: ArrayLike<number>, step?: number, max?: number): Float64Array;
3413
+ /** Classic floor-trader pivot levels for the next session. */
3414
+ interface PivotLevels {
3415
+ pivot: number;
3416
+ r1: number;
3417
+ r2: number;
3418
+ r3: number;
3419
+ s1: number;
3420
+ s2: number;
3421
+ s3: number;
3422
+ }
3423
+ /** Pivot points from one session's high/low/close, for the session that follows. */
3424
+ declare function pivotPoints(high: number, low: number, close: number): PivotLevels;
3425
+
2954
3426
  /**
2955
3427
  * Chart-type transforms: turn raw OHLC(V) into the geometry a specialist finance
2956
3428
  * chart needs. Each returns plain arrays you render with existing layers
@@ -3043,6 +3515,39 @@ interface DepthCurves {
3043
3515
  * returns cumulative-volume step curves ready for two step-area layers.
3044
3516
  */
3045
3517
  declare function depth(bids: ArrayLike<readonly [number, number]>, asks: ArrayLike<readonly [number, number]>): DepthCurves;
3518
+ /** One resampled bar, with the timestamp of the bucket it covers. */
3519
+ interface ResampledOhlc extends OhlcArrays {
3520
+ /** Bucket start time (epoch ms). */
3521
+ time: Float64Array;
3522
+ /** Summed volume per bucket, when volume was supplied. */
3523
+ volume?: Float64Array;
3524
+ }
3525
+ /**
3526
+ * Roll bars up to a coarser timeframe — 1m candles into 1h, daily into weekly.
3527
+ * Buckets are aligned to multiples of `bucketMs` from the epoch, so the same
3528
+ * input always produces the same boundaries. Empty buckets are skipped rather
3529
+ * than filled, which is what a market calendar wants.
3530
+ */
3531
+ declare function resampleOhlc(time: ArrayLike<number>, ohlc: Ohlc, bucketMs: number, volume?: ArrayLike<number>): ResampledOhlc;
3532
+ /** An equity curve's underwater profile and its worst stretch. */
3533
+ interface Drawdown {
3534
+ /** Fractional drawdown from the running peak at each point (≤ 0). */
3535
+ values: Float64Array;
3536
+ /** Running peak equity. */
3537
+ peak: Float64Array;
3538
+ /** The deepest drawdown (a negative fraction, e.g. −0.32 for −32%). */
3539
+ maxDrawdown: number;
3540
+ /** Index where the max drawdown bottomed, or −1. */
3541
+ troughIndex: number;
3542
+ /** Index of the peak that drawdown fell from, or −1. */
3543
+ peakIndex: number;
3544
+ }
3545
+ /**
3546
+ * The underwater curve of an equity series: how far below its running high-water
3547
+ * mark the strategy sat at each point. Plot `values` as a filled area under zero
3548
+ * — the standard companion to an equity curve.
3549
+ */
3550
+ declare function drawdown(equity: ArrayLike<number>): Drawdown;
3046
3551
 
3047
3552
  /**
3048
3553
  * Convenience builders for specialist finance charts. Each takes a {@link Plot}
@@ -3133,6 +3638,32 @@ interface DepthHandle {
3133
3638
  }
3134
3639
  declare function addDepth(plot: Plot, opts: DepthOptions): DepthHandle;
3135
3640
 
3641
+ interface DrawdownOptions {
3642
+ /** Equity / NAV series. */
3643
+ equity: ArrayLike<number>;
3644
+ /** X positions (epoch ms or bar indices). Defaults to `0..n-1`. */
3645
+ x?: ArrayLike<number>;
3646
+ /** Plot as percentages rather than fractions. Default true. */
3647
+ percent?: boolean;
3648
+ color?: string;
3649
+ /** Mark the deepest point with a labelled annotation. Default true. */
3650
+ markMax?: boolean;
3651
+ name?: string;
3652
+ yAxis?: string;
3653
+ renderType?: RenderType;
3654
+ }
3655
+ interface DrawdownHandle {
3656
+ area: AreaLayer;
3657
+ /** The computed underwater curve and its worst stretch. */
3658
+ stats: Drawdown;
3659
+ }
3660
+ /**
3661
+ * The underwater curve: how far below its running high-water mark an equity
3662
+ * series sat, as a filled area hanging from zero. The companion pane to an
3663
+ * equity curve — the number that decides whether a strategy is survivable.
3664
+ */
3665
+ declare function addDrawdown(plot: Plot, opts: DrawdownOptions): DrawdownHandle;
3666
+
3136
3667
  /**
3137
3668
  * A tiny dependency-free CSV parser + typed-array column access — the common
3138
3669
  * "load a CSV and plot a column" path. Handles quoted fields, escaped quotes
@@ -3247,6 +3778,91 @@ declare function calibrationCurve(scores: ArrayLike<number>, labels: ArrayLike<n
3247
3778
  * through untouched and don't advance the average.
3248
3779
  */
3249
3780
  declare function emaSmooth(values: ArrayLike<number>, weight?: number): Float64Array;
3781
+ /** Mean squared error. */
3782
+ declare function mse(yTrue: ArrayLike<number>, yPred: ArrayLike<number>): number;
3783
+ /** Root mean squared error — the error in the target's own units. */
3784
+ declare function rmse(yTrue: ArrayLike<number>, yPred: ArrayLike<number>): number;
3785
+ /** Mean absolute error — less swayed by outliers than {@link rmse}. */
3786
+ declare function mae(yTrue: ArrayLike<number>, yPred: ArrayLike<number>): number;
3787
+ /**
3788
+ * Coefficient of determination: the fraction of variance the model explains.
3789
+ * 1 is perfect, 0 matches predicting the mean, negative is worse than that.
3790
+ */
3791
+ declare function r2(yTrue: ArrayLike<number>, yPred: ArrayLike<number>): number;
3792
+ /**
3793
+ * Binary log loss (cross-entropy) of predicted probabilities. Probabilities are
3794
+ * clipped away from 0/1 so a single confident mistake cannot return Infinity.
3795
+ */
3796
+ declare function logLoss(probs: ArrayLike<number>, labels: ArrayLike<number>, eps?: number): number;
3797
+ /** Brier score: mean squared error of predicted probabilities. Lower is better. */
3798
+ declare function brierScore(probs: ArrayLike<number>, labels: ArrayLike<number>): number;
3799
+ /** Precision / recall / F1 / support for one class. */
3800
+ interface ClassScore {
3801
+ label: number;
3802
+ precision: number;
3803
+ recall: number;
3804
+ f1: number;
3805
+ /** True instances of this class. */
3806
+ support: number;
3807
+ }
3808
+ /** A scikit-learn style classification report. */
3809
+ interface ClassificationReport {
3810
+ perClass: ClassScore[];
3811
+ accuracy: number;
3812
+ /** Unweighted mean over classes — every class counts the same. */
3813
+ macro: {
3814
+ precision: number;
3815
+ recall: number;
3816
+ f1: number;
3817
+ };
3818
+ /** Support-weighted mean — dominated by the common classes. */
3819
+ weighted: {
3820
+ precision: number;
3821
+ recall: number;
3822
+ f1: number;
3823
+ };
3824
+ }
3825
+ /**
3826
+ * Per-class precision, recall and F1 plus macro/weighted averages. A class the
3827
+ * model never predicts scores 0 precision rather than NaN, so the macro average
3828
+ * stays comparable across runs.
3829
+ */
3830
+ declare function classificationReport(yTrue: ArrayLike<number>, yPred: ArrayLike<number>, classes?: number): ClassificationReport;
3831
+ /** Cumulative gain / lift as a function of the fraction of the population targeted. */
3832
+ interface LiftCurve {
3833
+ /** Fraction of the population contacted, 0..1. */
3834
+ fraction: Float64Array;
3835
+ /** Fraction of all positives captured by then, 0..1 (the gain curve). */
3836
+ gain: Float64Array;
3837
+ /** gain ÷ fraction — how many times better than random. */
3838
+ lift: Float64Array;
3839
+ /** Positives in the data. */
3840
+ positives: number;
3841
+ }
3842
+ /**
3843
+ * Sort by descending score and walk down the list: the standard "if I contact
3844
+ * the top X%, what share of the buyers do I get?" curve that marketing and
3845
+ * churn models are judged on.
3846
+ */
3847
+ declare function liftCurve(scores: ArrayLike<number>, labels: ArrayLike<number>): LiftCurve;
3848
+ /** One class's ROC curve in a one-vs-rest decomposition. */
3849
+ interface MulticlassRoc {
3850
+ perClass: Array<{
3851
+ label: number;
3852
+ fpr: Float64Array;
3853
+ tpr: Float64Array;
3854
+ auc: number;
3855
+ }>;
3856
+ /** Unweighted mean of the per-class AUCs. */
3857
+ macroAuc: number;
3858
+ /** AUC of the pooled binarized problem — dominated by the common classes. */
3859
+ microAuc: number;
3860
+ }
3861
+ /**
3862
+ * One-vs-rest ROC for a multiclass problem. `scores` is row-major `n × classes`
3863
+ * (a probability per class per sample), `labels` the true class index.
3864
+ */
3865
+ declare function rocCurveOvR(scores: ArrayLike<number>, labels: ArrayLike<number>, classes: number): MulticlassRoc;
3250
3866
 
3251
3867
  /**
3252
3868
  * Pure, dependency-free dimensionality reduction for embedding projections.
@@ -3278,6 +3894,43 @@ declare function standardize(data: ArrayLike<number>, n: number, d: number): Flo
3278
3894
  */
3279
3895
  declare function pca(data: ArrayLike<number>, n: number, d: number, k?: number): PcaResult;
3280
3896
 
3897
+ /**
3898
+ * Categorical (qualitative) colour palettes — the discrete counterpart to the
3899
+ * continuous colormaps in `colormap.ts`. Series colours, class colours, treemap
3900
+ * cells and chord groups all draw from here so a page stays visually coherent.
3901
+ */
3902
+ /** Built-in qualitative palettes. */
3903
+ type BuiltinPaletteName = "tableau10" | "okabe-ito" | "set2" | "bright";
3904
+ /**
3905
+ * A palette name. Built-ins autocomplete; any other string resolves through the
3906
+ * registry, so `registerPalette("brand", […])` makes `"brand"` usable anywhere a
3907
+ * palette is accepted. Unknown names fall back to {@link DEFAULT_PALETTE}.
3908
+ */
3909
+ type PaletteName = BuiltinPaletteName | (string & {});
3910
+ /** A palette given inline: a registered name, or the colours themselves. */
3911
+ type PaletteSpec = PaletteName | readonly string[];
3912
+ /**
3913
+ * Colour-vision-deficiency safety, roughly:
3914
+ * - `okabe-ito` — designed to be distinguishable with any common CVD (8 colours)
3915
+ * - `tableau10` — the default; good separation for ≤10 series
3916
+ * - `set2` — muted pastels, best for large filled areas
3917
+ * - `bright` — high-chroma, best on dark backgrounds
3918
+ */
3919
+ declare const PALETTES: Record<string, readonly string[]>;
3920
+ /** The palette used when none is named. */
3921
+ declare const DEFAULT_PALETTE: readonly string[];
3922
+ /**
3923
+ * Register a custom palette under `name`, so it can be used anywhere a palette
3924
+ * name is accepted. Re-registering a name replaces it.
3925
+ */
3926
+ declare function registerPalette(name: string, colors: readonly string[]): void;
3927
+ /** Every registered palette name (built-ins first, then anything registered). */
3928
+ declare function paletteNames(): string[];
3929
+ /** Resolve a palette spec to its colours — a name, or the colours themselves. */
3930
+ declare function palette(spec?: PaletteSpec): readonly string[];
3931
+ /** The `index`-th colour of a palette, cycling once the palette is exhausted. */
3932
+ declare function paletteColor(index: number, spec?: PaletteSpec): string;
3933
+
3281
3934
  /**
3282
3935
  * Convenience builders for ML / deep-learning charts. Each takes a {@link Plot}
3283
3936
  * and composes existing layers (`addHeatmap`/`addLine`/`addScatter`/`addBar`/
@@ -3287,13 +3940,14 @@ declare function pca(data: ArrayLike<number>, n: number, d: number, k?: number):
3287
3940
  */
3288
3941
 
3289
3942
  /** tab10 categorical palette, cycled by class index. */
3943
+ /** Series/class colours for the ML builders. Aliases the shared {@link DEFAULT_PALETTE} (Tableau 10). */
3290
3944
  declare const ML_PALETTE: readonly string[];
3291
3945
  interface ConfusionMatrixOptions {
3292
3946
  yTrue: ArrayLike<number>;
3293
3947
  yPred: ArrayLike<number>;
3294
3948
  /** Number of classes; inferred from the labels when omitted. */
3295
3949
  classes?: number;
3296
- colormap?: ColormapName;
3950
+ colormap?: ColormapSpec;
3297
3951
  /** Shade by row-normalized recall instead of raw counts. Default false. */
3298
3952
  normalize?: boolean;
3299
3953
  /** Draw the value inside each cell. Default true. */
@@ -3366,8 +4020,8 @@ interface EmbeddingOptions {
3366
4020
  classNames?: string[];
3367
4021
  /** Continuous value per point → a single colormap series (ignored if `labels`). */
3368
4022
  colorBy?: ArrayLike<number>;
3369
- colormap?: ColormapName;
3370
- palette?: readonly string[];
4023
+ colormap?: ColormapSpec;
4024
+ palette?: PaletteSpec;
3371
4025
  size?: number;
3372
4026
  /** Per-point hover text (metadata). */
3373
4027
  text?: ArrayLike<string>;
@@ -3392,7 +4046,7 @@ interface DecisionBoundaryOptions {
3392
4046
  x: Range;
3393
4047
  y: Range;
3394
4048
  };
3395
- colormap?: ColormapName;
4049
+ colormap?: ColormapSpec;
3396
4050
  domain?: Range;
3397
4051
  /** Training points drawn over the field. */
3398
4052
  points?: {
@@ -3400,7 +4054,7 @@ interface DecisionBoundaryOptions {
3400
4054
  y: ArrayLike<number>;
3401
4055
  labels?: ArrayLike<number> | string[];
3402
4056
  classNames?: string[];
3403
- palette?: readonly string[];
4057
+ palette?: PaletteSpec;
3404
4058
  size?: number;
3405
4059
  };
3406
4060
  }
@@ -3435,7 +4089,7 @@ interface ShapBeeswarmOptions {
3435
4089
  names: string[];
3436
4090
  /** Feature values (same shape) → point color via a diverging colormap. */
3437
4091
  featureValues?: number[][];
3438
- colormap?: ColormapName;
4092
+ colormap?: ColormapSpec;
3439
4093
  size?: number;
3440
4094
  /** Vertical spread of each feature band, 0..1. Default 0.8. */
3441
4095
  spread?: number;
@@ -3475,7 +4129,7 @@ interface AttentionMapOptions {
3475
4129
  /** Required with a flat `weights`. */
3476
4130
  queries?: number;
3477
4131
  keys?: number;
3478
- colormap?: ColormapName;
4132
+ colormap?: ColormapSpec;
3479
4133
  /** Draw each weight in its cell (small maps only). Default false. */
3480
4134
  annotate?: boolean;
3481
4135
  }
@@ -3501,7 +4155,7 @@ interface TrainingCurvesOptions {
3501
4155
  /** Mark the best epoch of each series. */
3502
4156
  best?: "min" | "max";
3503
4157
  width?: number;
3504
- palette?: readonly string[];
4158
+ palette?: PaletteSpec;
3505
4159
  renderType?: RenderType;
3506
4160
  }
3507
4161
  interface TrainingCurvesHandle {
@@ -3525,7 +4179,7 @@ interface RidgelineOptions {
3525
4179
  points?: number;
3526
4180
  /** Ridge overlap, 0 = touching, 1 = one full row of overlap. Default 1. */
3527
4181
  overlap?: number;
3528
- palette?: readonly string[];
4182
+ palette?: PaletteSpec;
3529
4183
  /** Fill each ridge. Default true. */
3530
4184
  fill?: boolean;
3531
4185
  /** Shared x-range; inferred from the data when omitted. */
@@ -3551,6 +4205,502 @@ interface BeeswarmOptions {
3551
4205
  * local density. Pure — no RNG. Backs {@link addShapBeeswarm}.
3552
4206
  */
3553
4207
  declare function beeswarmLayout(x: ArrayLike<number>, opts?: BeeswarmOptions): number[];
4208
+ interface PredVsActualOptions {
4209
+ yTrue: ArrayLike<number>;
4210
+ yPred: ArrayLike<number>;
4211
+ color?: string;
4212
+ /** Colour of the y = x reference. */
4213
+ referenceColor?: string;
4214
+ size?: number;
4215
+ name?: string;
4216
+ renderType?: RenderType;
4217
+ }
4218
+ interface PredVsActualHandle {
4219
+ points: ScatterLayer;
4220
+ reference: LineLayer;
4221
+ r2: number;
4222
+ }
4223
+ /**
4224
+ * Predicted against actual, with the y = x line a perfect model would sit on.
4225
+ * The gap between the cloud and that line *is* the error, which is why this
4226
+ * reads better than a lone R² number.
4227
+ */
4228
+ declare function addPredVsActual(plot: Plot, opts: PredVsActualOptions): PredVsActualHandle;
4229
+ interface ResidualsOptions {
4230
+ yTrue: ArrayLike<number>;
4231
+ yPred: ArrayLike<number>;
4232
+ /** Plot residuals against `"predicted"` (default) or `"index"` (order in the data). */
4233
+ against?: "predicted" | "index";
4234
+ color?: string;
4235
+ size?: number;
4236
+ name?: string;
4237
+ renderType?: RenderType;
4238
+ }
4239
+ interface ResidualsHandle {
4240
+ points: ScatterLayer;
4241
+ zero: LineLayer;
4242
+ residuals: Float64Array;
4243
+ }
4244
+ /**
4245
+ * Residuals (actual − predicted) against the prediction or the sample order,
4246
+ * with a zero line. Structure here — a curve, a fan, a drift — means the model
4247
+ * is missing something, which no single score will tell you.
4248
+ */
4249
+ declare function addResiduals(plot: Plot, opts: ResidualsOptions): ResidualsHandle;
4250
+ interface LiftCurveOptions {
4251
+ scores: ArrayLike<number>;
4252
+ labels: ArrayLike<number>;
4253
+ /** `"gain"` (default) plots cumulative gain; `"lift"` plots the ratio over random. */
4254
+ mode?: "gain" | "lift";
4255
+ color?: string;
4256
+ /** Colour of the random-baseline reference. */
4257
+ baselineColor?: string;
4258
+ width?: number;
4259
+ name?: string;
4260
+ renderType?: RenderType;
4261
+ }
4262
+ interface LiftCurveHandle {
4263
+ line: LineLayer;
4264
+ baseline: LineLayer;
4265
+ positives: number;
4266
+ }
4267
+ /**
4268
+ * Cumulative gain (or lift) against the fraction of the population targeted,
4269
+ * with the random baseline for reference — how a churn or marketing model is
4270
+ * actually judged: "contact the top 20%, capture what share of the positives?"
4271
+ */
4272
+ declare function addLiftCurve(plot: Plot, opts: LiftCurveOptions): LiftCurveHandle;
4273
+ interface LearningCurveOptions {
4274
+ /** Training-set sizes the scores were measured at. */
4275
+ sizes: ArrayLike<number>;
4276
+ /** Mean training score per size. */
4277
+ train: ArrayLike<number>;
4278
+ /** Mean validation score per size. */
4279
+ validation: ArrayLike<number>;
4280
+ /** Optional ± spread per size (e.g. std across CV folds), drawn as bands. */
4281
+ trainStd?: ArrayLike<number>;
4282
+ validationStd?: ArrayLike<number>;
4283
+ trainColor?: string;
4284
+ validationColor?: string;
4285
+ width?: number;
4286
+ renderType?: RenderType;
4287
+ }
4288
+ interface LearningCurveHandle {
4289
+ train: LineLayer;
4290
+ validation: LineLayer;
4291
+ bands: AreaLayer[];
4292
+ }
4293
+ /**
4294
+ * Score against training-set size for train and validation, with optional
4295
+ * cross-validation spread bands. A gap that stays wide means variance (get more
4296
+ * data); two curves that meet low mean bias (get a bigger model).
4297
+ */
4298
+ declare function addLearningCurve(plot: Plot, opts: LearningCurveOptions): LearningCurveHandle;
4299
+
4300
+ /**
4301
+ * Model-architecture graphs: a framework-agnostic description of a neural
4302
+ * network's layers, adapters that build one from PyTorch / ONNX exports, and a
4303
+ * layered-DAG layout shared by the 2D and 3D renderers (`ml/model-chart.ts`).
4304
+ *
4305
+ * Everything here is pure (array in → array out) and unit-tested; nothing
4306
+ * touches WebGL or the DOM.
4307
+ */
4308
+
4309
+ /** One layer / op in a model graph. */
4310
+ interface ModelNode {
4311
+ /** Unique id — a module path (`features.0`), an fx node name, or a tensor name. */
4312
+ id: string;
4313
+ /** Display name. Defaults to `id`. */
4314
+ name?: string;
4315
+ /** Layer or op class: `"Conv2d"`, `"Linear"`, `"ReLU"`, `"Add"`, … */
4316
+ type: string;
4317
+ /** Output tensor shape with the batch dim dropped, e.g. `[64, 112, 112]`. */
4318
+ shape?: number[];
4319
+ /** Trainable parameter count. */
4320
+ params?: number;
4321
+ /** Multiply-accumulates / FLOPs, if known. */
4322
+ flops?: number;
4323
+ /** Block or stage the layer belongs to (`"layer1"`, `"encoder.3"`, …). */
4324
+ group?: string;
4325
+ }
4326
+ /** A directed connection (activation tensor) between two {@link ModelNode}s. */
4327
+ interface ModelEdge {
4328
+ from: string;
4329
+ to: string;
4330
+ label?: string;
4331
+ }
4332
+ /** A model architecture as a directed acyclic graph of layers. */
4333
+ interface ModelGraph {
4334
+ name?: string;
4335
+ nodes: ModelNode[];
4336
+ edges: ModelEdge[];
4337
+ }
4338
+ /** Coarse layer families, used to color a diagram consistently. */
4339
+ type LayerCategory = "input" | "conv" | "linear" | "norm" | "activation" | "pool" | "dropout" | "attention" | "embedding" | "recurrent" | "reshape" | "merge" | "output" | "other";
4340
+ /** Default category → color. Tuned to read on both dark and light backgrounds. */
4341
+ declare const LAYER_COLORS: Record<LayerCategory, string>;
4342
+ /** Classify a layer/op type string (`"Conv2d"`, `"aten::relu"`) into a family. */
4343
+ declare function layerCategory(type: string): LayerCategory;
4344
+ /** `9408` → `"9.4K"`, `2.5e7` → `"25M"`. Used for parameter / FLOP counts. */
4345
+ declare function formatCount(n: number): string;
4346
+ /** `[64, 112, 112]` → `"64×112×112"`; empty/absent → `""`. */
4347
+ declare function formatShape(shape?: number[]): string;
4348
+ /** A layer in a straight-line model; `id` is derived when omitted. */
4349
+ interface SequentialLayer extends Omit<ModelNode, "id"> {
4350
+ id?: string;
4351
+ }
4352
+ /**
4353
+ * Build a straight-line graph from an ordered layer list — the one-liner path
4354
+ * from `model.named_modules()` / `torchinfo.summary()`. Consecutive layers are
4355
+ * connected automatically.
4356
+ */
4357
+ declare function sequentialModel(layers: SequentialLayer[], name?: string): ModelGraph;
4358
+ /**
4359
+ * One node of a traced `torch.fx` graph. Produce it in Python with:
4360
+ *
4361
+ * ```python
4362
+ * gm = torch.fx.symbolic_trace(model)
4363
+ * [{"name": n.name, "op": n.op, "target": str(n.target),
4364
+ * "args": [a.name for a in n.all_input_nodes]} for n in gm.graph.nodes]
4365
+ * ```
4366
+ */
4367
+ interface TorchFxNode {
4368
+ name: string;
4369
+ /** `placeholder` | `call_module` | `call_function` | `call_method` | `get_attr` | `output`. */
4370
+ op: string;
4371
+ /** Module path or function name. */
4372
+ target?: string;
4373
+ /** Names of the input nodes (`[a.name for a in n.all_input_nodes]`). */
4374
+ args?: string[];
4375
+ /** `type(module).__name__` for `call_module` nodes — the nicest display type. */
4376
+ moduleType?: string;
4377
+ shape?: number[];
4378
+ params?: number;
4379
+ flops?: number;
4380
+ }
4381
+ /** Options shared by the graph adapters. */
4382
+ interface AdapterOptions {
4383
+ name?: string;
4384
+ /** fx ops to drop before building the graph. Default `["get_attr"]`. */
4385
+ skipOps?: string[];
4386
+ }
4387
+ /** Build a {@link ModelGraph} from traced `torch.fx` nodes (keeps skip connections). */
4388
+ declare function modelGraphFromTorchFx(nodes: TorchFxNode[], opts?: AdapterOptions): ModelGraph;
4389
+ /** A node of an ONNX graph, as produced by `MessageToDict(model.graph)`. */
4390
+ interface OnnxNode {
4391
+ name?: string;
4392
+ opType: string;
4393
+ input?: string[];
4394
+ output?: string[];
4395
+ }
4396
+ /** An ONNX graph dict: `MessageToDict(onnx.load(path).graph)`. */
4397
+ interface OnnxGraph {
4398
+ name?: string;
4399
+ node: OnnxNode[];
4400
+ input?: Array<{
4401
+ name: string;
4402
+ }>;
4403
+ output?: Array<{
4404
+ name: string;
4405
+ }>;
4406
+ /** Initializers (weights) — their names are excluded from the edge set. */
4407
+ initializer?: Array<{
4408
+ name: string;
4409
+ }>;
4410
+ }
4411
+ /** ONNX adapter options: tensor shapes are supplied separately (shape inference is optional in ONNX). */
4412
+ interface OnnxAdapterOptions extends AdapterOptions {
4413
+ /** Tensor name → shape (batch dim already dropped), for node output shapes. */
4414
+ shapes?: Record<string, number[]>;
4415
+ /** Tensor name → element count, to attribute weights to their consuming op. */
4416
+ paramCounts?: Record<string, number>;
4417
+ }
4418
+ /**
4419
+ * Build a {@link ModelGraph} from an ONNX graph dict — the framework-neutral
4420
+ * path (works for models exported from PyTorch, TensorFlow, JAX, sklearn…).
4421
+ * Edges are recovered by matching each node's inputs to the node that produced
4422
+ * them; weights (initializers) are folded into the consuming node's `params`.
4423
+ */
4424
+ declare function modelGraphFromOnnx(graph: OnnxGraph, opts?: OnnxAdapterOptions): ModelGraph;
4425
+ /** One layer of a Keras config (`json.loads(model.to_json())`). */
4426
+ interface KerasLayerConfig {
4427
+ class_name: string;
4428
+ name?: string;
4429
+ config?: Record<string, unknown>;
4430
+ /**
4431
+ * Functional-API wiring. Keras 2 nests `[["conv1", 0, 0, {}]]` and Keras 3
4432
+ * nests `keras_history` — both are handled by scanning for known layer names.
4433
+ */
4434
+ inbound_nodes?: unknown;
4435
+ }
4436
+ /** A Keras model config: `json.loads(model.to_json())`. */
4437
+ interface KerasModelConfig {
4438
+ /** `"Sequential"` | `"Functional"` | `"Model"`. */
4439
+ class_name?: string;
4440
+ config?: {
4441
+ name?: string;
4442
+ layers?: KerasLayerConfig[];
4443
+ };
4444
+ /** Some exports hoist the layer list to the top level. */
4445
+ layers?: KerasLayerConfig[];
4446
+ }
4447
+ /** Keras adapter options — output shapes come from `[l.output_shape for l in model.layers]`. */
4448
+ interface KerasAdapterOptions extends AdapterOptions {
4449
+ /** Layer name → output shape (batch dim already dropped). */
4450
+ shapes?: Record<string, number[]>;
4451
+ /** Layer name → parameter count (`l.count_params()`). */
4452
+ params?: Record<string, number>;
4453
+ }
4454
+ /**
4455
+ * Build a {@link ModelGraph} from a TensorFlow / Keras model config. Sequential
4456
+ * models chain in declaration order; functional models are wired from each
4457
+ * layer's `inbound_nodes`, so multi-input and residual topologies survive.
4458
+ */
4459
+ declare function modelGraphFromKeras(model: KerasModelConfig, opts?: KerasAdapterOptions): ModelGraph;
4460
+ /**
4461
+ * A scikit-learn estimator as a tree of steps. Leaves are estimators; `steps`
4462
+ * makes a composite — a `Pipeline` (`mode: "sequential"`) or a
4463
+ * `FeatureUnion` / `ColumnTransformer` (`mode: "parallel"`).
4464
+ */
4465
+ interface SklearnStep {
4466
+ /** Step name (`"scaler"`, `"clf"`, …). */
4467
+ name: string;
4468
+ /** Estimator class: `"StandardScaler"`, `"RandomForestClassifier"`, … */
4469
+ type: string;
4470
+ /** Child steps of a composite estimator. */
4471
+ steps?: SklearnStep[];
4472
+ /** How the children combine. Default `"sequential"`. */
4473
+ mode?: "sequential" | "parallel";
4474
+ /** Output feature count / shape, if known. */
4475
+ shape?: number[];
4476
+ /** Fitted parameter count, if known. */
4477
+ params?: number;
4478
+ /** Columns a `ColumnTransformer` branch operates on (shown in the label). */
4479
+ columns?: string[];
4480
+ }
4481
+ /**
4482
+ * Build a {@link ModelGraph} from a scikit-learn `Pipeline` /
4483
+ * `ColumnTransformer` / `FeatureUnion` tree: sequential steps chain, parallel
4484
+ * branches fan out from the previous step and fan back in to the next one.
4485
+ */
4486
+ declare function modelGraphFromSklearn(root: SklearnStep, opts?: AdapterOptions): ModelGraph;
4487
+ /** Options for {@link mlpModel}. */
4488
+ interface MlpOptions {
4489
+ /** Activation inserted between dense layers. Default `"ReLU"`; `""` omits it. */
4490
+ activation?: string;
4491
+ /** Activation after the final layer (`"Softmax"`, `"Sigmoid"`, …). */
4492
+ outputActivation?: string;
4493
+ name?: string;
4494
+ }
4495
+ /**
4496
+ * A dense feed-forward net from its layer sizes — the shape a scikit-learn
4497
+ * `MLPClassifier` reports as `[n_features, *hidden_layer_sizes, n_outputs]`.
4498
+ * Parameter counts are computed as `in × out + out`.
4499
+ */
4500
+ declare function mlpModel(layerSizes: number[], opts?: MlpOptions): ModelGraph;
4501
+ interface ModelLayoutOptions {
4502
+ /** Flow direction: `"vertical"` top→bottom (default) or `"horizontal"` left→right. */
4503
+ direction?: "vertical" | "horizontal";
4504
+ /** Box width in data units. Default 2.6. */
4505
+ nodeWidth?: number;
4506
+ /** Box height in data units. Default 0.9. */
4507
+ nodeHeight?: number;
4508
+ /** Gap between consecutive ranks. Default 0.7. */
4509
+ rankGap?: number;
4510
+ /** Gap between siblings inside a rank. Default 0.6. */
4511
+ nodeGap?: number;
4512
+ /**
4513
+ * Scale the box across the flow (width when vertical, height when horizontal)
4514
+ * by a metric, so heavy layers read as bigger. Default `"none"`.
4515
+ */
4516
+ sizeBy?: "none" | "params" | "flops";
4517
+ /** Multiplier range applied when `sizeBy` is set. Default `[0.55, 1.5]`. */
4518
+ sizeRange?: Range;
4519
+ /** Barycenter passes used to reduce edge crossings. Default 4. */
4520
+ sweeps?: number;
4521
+ }
4522
+ /** A laid-out layer box (center + size in data units). */
4523
+ interface ModelNodeBox {
4524
+ node: ModelNode;
4525
+ category: LayerCategory;
4526
+ color: string;
4527
+ /** Center. */
4528
+ x: number;
4529
+ y: number;
4530
+ /** Full size. */
4531
+ w: number;
4532
+ h: number;
4533
+ rank: number;
4534
+ /** Position within the rank, left→right (or top→bottom when horizontal). */
4535
+ order: number;
4536
+ }
4537
+ /** A routed connector: an orthogonal polyline from one box edge to another. */
4538
+ interface ModelEdgePath {
4539
+ from: string;
4540
+ to: string;
4541
+ label?: string;
4542
+ points: Array<{
4543
+ x: number;
4544
+ y: number;
4545
+ }>;
4546
+ }
4547
+ interface ModelLayoutResult {
4548
+ nodes: ModelNodeBox[];
4549
+ edges: ModelEdgePath[];
4550
+ extent: {
4551
+ x: Range;
4552
+ y: Range;
4553
+ };
4554
+ /** Depth of the DAG (number of ranks). */
4555
+ ranks: number;
4556
+ }
4557
+ /**
4558
+ * Lay a {@link ModelGraph} out as a layered DAG: longest-path ranks, barycenter
4559
+ * ordering to reduce crossings, then orthogonal edge routing. Edges that skip
4560
+ * more than one rank (residual connections) are routed through a bypass lane
4561
+ * beside the boxes so they don't cut across them.
4562
+ */
4563
+ declare function modelLayout(graph: ModelGraph, opts?: ModelLayoutOptions): ModelLayoutResult;
4564
+ interface ModelBoxSizing {
4565
+ /** Compression applied to each tensor dim before scaling. Default `"log"`. */
4566
+ sizeScale?: "log" | "sqrt" | "linear";
4567
+ /** Thickness of the widest layer along the flow axis (channels). Default 0.9. */
4568
+ maxThickness?: number;
4569
+ /** Height / lateral depth of the largest feature-map face. Default 2.2. */
4570
+ maxFace?: number;
4571
+ /** Floor (world units) applied to every axis so singleton dims stay visible. Default 0.08. */
4572
+ minSize?: number;
4573
+ }
4574
+ /** Size of one layer's cuboid: `[thickness (flow), height, depth (lateral)]`. */
4575
+ type BoxDims = [number, number, number];
4576
+ /**
4577
+ * Cuboid dimensions for every node, normalized together so the largest layer on
4578
+ * each axis hits its max — the classic "CNN funnel" where feature maps shrink
4579
+ * while channel depth grows.
4580
+ */
4581
+ declare function modelBoxDims(nodes: ModelNode[], opts?: ModelBoxSizing): BoxDims[];
4582
+
4583
+ /**
4584
+ * Model-architecture diagrams built on existing layers:
4585
+ *
4586
+ * - {@link addModelGraph} — a flat Netron-style DAG on a 2D {@link Plot}
4587
+ * (rounded boxes + orthogonal connectors, colored by layer family).
4588
+ * - {@link addModelGraph3D} — the "CNN explainer" view on a {@link Plot3D}:
4589
+ * one cuboid per layer, sized from its output tensor shape, chained along the
4590
+ * flow axis.
4591
+ *
4592
+ * Both consume the same {@link ModelGraph} and the same {@link modelLayout}, so a
4593
+ * PyTorch / ONNX export renders identically in either dimension.
4594
+ */
4595
+
4596
+ interface ModelGraphOptions extends ModelLayoutOptions {
4597
+ graph: ModelGraph;
4598
+ /** Per-category color overrides (merged over {@link LAYER_COLORS}). */
4599
+ colors?: Partial<Record<LayerCategory, string>>;
4600
+ /** Box corner radius in data units. Default 0.14. */
4601
+ cornerRadius?: number;
4602
+ /** Connector thickness in data units. Default 0.05. */
4603
+ edgeWidth?: number;
4604
+ edgeColor?: string;
4605
+ /** Arrowhead length in data units; 0 hides them. Default 0.18. */
4606
+ arrowSize?: number;
4607
+ /** Box fill opacity, 0..1. Default 0.9. */
4608
+ opacity?: number;
4609
+ /** What to write inside each box. Default `"full"`. */
4610
+ labels?: "none" | "name" | "full";
4611
+ labelColor?: string;
4612
+ labelFont?: string;
4613
+ subLabelColor?: string;
4614
+ subLabelFont?: string;
4615
+ /** Attach a hover tooltip with the layer's shape + parameter count. Default true. */
4616
+ tooltip?: boolean;
4617
+ /** Palette for the tooltip chrome. Default `"dark"`. */
4618
+ theme?: "light" | "dark";
4619
+ /** Blank the axes — a diagram has no meaningful coordinates. Default true. */
4620
+ hideAxes?: boolean;
4621
+ /** Legend name for the box layer. Omitted by default (diagrams use their own key). */
4622
+ name?: string;
4623
+ }
4624
+ interface ModelGraphHandle {
4625
+ /** The computed layout — box centers, sizes, ranks and routed edge paths. */
4626
+ layout: ModelLayoutResult;
4627
+ /** Layer holding the layer boxes. */
4628
+ nodes: PatchesLayer;
4629
+ /** Layer holding the connectors (drawn beneath the boxes). */
4630
+ edges: PatchesLayer;
4631
+ /** The box containing a data-space point, or null. */
4632
+ nodeAt(x: number, y: number): ModelNodeBox | null;
4633
+ /** Remove the labels and tooltip this builder added (layers are yours to remove). */
4634
+ destroy(): void;
4635
+ }
4636
+ /**
4637
+ * Draw a model architecture as a flat layered graph. Boxes are colored by layer
4638
+ * family, residual/skip connections route around the trunk, and each box shows
4639
+ * its type, name and output shape.
4640
+ *
4641
+ * Pair it with `new Plot(el, { equalAspect: true, hover: false })` — the diagram
4642
+ * is a schematic, so a square aspect and no series tooltip read best.
4643
+ */
4644
+ declare function addModelGraph(plot: Plot, opts: ModelGraphOptions): ModelGraphHandle;
4645
+ interface ModelGraph3DOptions extends ModelLayoutOptions, ModelBoxSizing {
4646
+ graph: ModelGraph;
4647
+ /** Per-category color overrides (merged over {@link LAYER_COLORS}). */
4648
+ colors?: Partial<Record<LayerCategory, string>>;
4649
+ /** Clear space between consecutive layer blocks along the flow axis. Default 1.1. */
4650
+ rankSpacing?: number;
4651
+ /** Lateral offset between branches that share a rank. Default 3. */
4652
+ branchSpacing?: number;
4653
+ /** Draw connectors between blocks. Default true. */
4654
+ connectors?: boolean;
4655
+ connectorColor?: string;
4656
+ /** Block opacity, 0..1. Default 1. */
4657
+ opacity?: number;
4658
+ /**
4659
+ * Text pinned above each block: `"name"` (default) the layer name, `"type"`
4660
+ * its class, `"full"` the name above and the output shape below, `"none"` to
4661
+ * rely on the hover tooltip alone.
4662
+ */
4663
+ labels?: "none" | "name" | "type" | "full";
4664
+ labelColor?: string;
4665
+ labelFont?: string;
4666
+ subLabelColor?: string;
4667
+ subLabelFont?: string;
4668
+ name?: string;
4669
+ }
4670
+ /** Where one layer's cuboid ended up, in world space. */
4671
+ interface ModelBlock {
4672
+ node: ModelNode;
4673
+ category: LayerCategory;
4674
+ /** Center. */
4675
+ x: number;
4676
+ y: number;
4677
+ z: number;
4678
+ /** Full size: `w` along the flow axis, `h` up, `d` lateral. */
4679
+ w: number;
4680
+ h: number;
4681
+ d: number;
4682
+ rank: number;
4683
+ }
4684
+ interface ModelGraph3DHandle {
4685
+ boxes: Boxes3DLayer;
4686
+ /** One polyline per drawn connector (empty when `connectors: false`). */
4687
+ connectors: Line3DLayer[];
4688
+ blocks: ModelBlock[];
4689
+ /** Remove the labels this builder pinned (the layers are yours to remove). */
4690
+ destroy(): void;
4691
+ }
4692
+ /**
4693
+ * Draw a model as a chain of cuboids sized from each layer's output tensor: the
4694
+ * visible face is the last two dims (H×W) and the thickness is everything before
4695
+ * them (channels) — so a CNN reads as feature maps shrinking while depth grows.
4696
+ * Blocks flow along +x, branches spread along z, and hovering one shows its
4697
+ * shape and parameter count.
4698
+ *
4699
+ * Build the plot with `new Plot3D(el, { aspectMode: "data", showAxes: false })`
4700
+ * — the default cube fit would stretch a long chain until the blocks lose their
4701
+ * proportions, and a diagram has no axes to label.
4702
+ */
4703
+ declare function addModelGraph3D(plot: Plot3D, opts: ModelGraph3DOptions): ModelGraph3DHandle;
3554
4704
 
3555
4705
  /**
3556
4706
  * Squarified treemap — a pure layout plus a {@link Plot} builder that composes
@@ -3581,6 +4731,7 @@ interface TreemapExtent {
3581
4731
  y: [number, number];
3582
4732
  }
3583
4733
  /** tab10-ish default palette, cycled by index for items without a color. */
4734
+ /** Cell colours when an item has no explicit `color`. Aliases the shared {@link DEFAULT_PALETTE} (Tableau 10). */
3584
4735
  declare const TREEMAP_PALETTE: readonly string[];
3585
4736
  /**
3586
4737
  * Squarified treemap layout: sizes rects ∝ `value`, packing them into `extent`
@@ -3592,7 +4743,7 @@ interface TreemapOptions {
3592
4743
  items: TreemapItem[];
3593
4744
  extent?: TreemapExtent;
3594
4745
  /** Palette cycled by index for items lacking a `color`. Defaults to {@link TREEMAP_PALETTE}. */
3595
- colors?: string[];
4746
+ colors?: PaletteSpec;
3596
4747
  opacity?: number;
3597
4748
  name?: string;
3598
4749
  renderType?: RenderType;
@@ -3638,6 +4789,7 @@ interface FunnelLayoutOptions {
3638
4789
  neck?: number;
3639
4790
  }
3640
4791
  /** tab10-ish default palette, cycled by index for stages without a color. */
4792
+ /** Stage colours when an item has no explicit `color`. Aliases the shared {@link DEFAULT_PALETTE} (Tableau 10). */
3641
4793
  declare const FUNNEL_PALETTE: readonly string[];
3642
4794
  /**
3643
4795
  * Funnel layout: centered trapezoids stacked top-to-bottom, each stage's top
@@ -3651,7 +4803,7 @@ interface FunnelOptions {
3651
4803
  height?: number;
3652
4804
  neck?: number;
3653
4805
  /** Palette cycled by index for stages lacking a `color`. Defaults to {@link FUNNEL_PALETTE}. */
3654
- colors?: string[];
4806
+ colors?: PaletteSpec;
3655
4807
  opacity?: number;
3656
4808
  name?: string;
3657
4809
  renderType?: RenderType;
@@ -3884,6 +5036,7 @@ declare function addSankey(plot: Plot, opts: SankeyOptions): PatchesLayer;
3884
5036
  */
3885
5037
 
3886
5038
  /** tab10-ish default palette, cycled by group index. */
5039
+ /** Group colours when none are supplied. Aliases the shared {@link DEFAULT_PALETTE} (Tableau 10). */
3887
5040
  declare const CHORD_PALETTE: readonly string[];
3888
5041
  /** A laid-out group arc as a closed ring of `x`/`y` (thin annular sector). */
3889
5042
  interface ChordGroupArc {
@@ -3930,7 +5083,7 @@ interface ChordOptions {
3930
5083
  /** Outer radius. Default 1. */
3931
5084
  radius?: number;
3932
5085
  /** Palette cycled by group index. Defaults to {@link CHORD_PALETTE}. */
3933
- colors?: string[];
5086
+ colors?: PaletteSpec;
3934
5087
  /** Ribbon fill opacity, 0..1. Default 0.65. */
3935
5088
  opacity?: number;
3936
5089
  name?: string;
@@ -3951,6 +5104,7 @@ declare function addChord(plot: Plot, opts: ChordOptions): PatchesLayer;
3951
5104
  */
3952
5105
 
3953
5106
  /** tab10-ish default palette, cycled by row index (or by `colorBy` band). */
5107
+ /** Line colours when rows are coloured by class. Aliases the shared {@link DEFAULT_PALETTE} (Tableau 10). */
3954
5108
  declare const PARALLEL_PALETTE: readonly string[];
3955
5109
  /** A laid-out axis: its dimension name, x position, and observed value range. */
3956
5110
  interface ParallelAxis {
@@ -4009,4 +5163,104 @@ declare function parseColor(input: string): [number, number, number, number];
4009
5163
  /** Normalized RGBA (0..1) back to a CSS `rgba(...)` string. */
4010
5164
  declare function toColorCss(c: readonly [number, number, number, number]): string;
4011
5165
 
4012
- export { type Adx, type Annotation, AreaLayer, type AreaOptions, type AreaSeries, type AttentionMapHandle, type AttentionMapOptions, Axis, type AxisConfig, type AxisFrame, type AxisScaleOptions, Bar3DLayer, type Bar3DOptions, BarLayer, type BarOptions, type BarSeries, type BeeswarmOptions, type BollingerBands, type BollingerHandle, type BollingerOptions, type Bounds, type Bounds3, type BoxGroup, BoxLayer, type BoxOptions, type BoxStats, type Brick, CHORD_PALETTE, type CSVOptions, type CalibrationCurve, type CalibrationHandle, type CalibrationOptions, type Candle, type CandlestickData, CandlestickLayer, type CandlestickOptions, CategoricalScale, type Channel, type ChordGroupArc, type ChordLayoutOptions, type ChordLayoutResult, type ChordOptions, type ChordRibbon, type Color, type ColorInfo, type ColormapName, type ConfusionMatrix, type ConfusionMatrixHandle, type ConfusionMatrixOptions, Contour3DLayer, type Contour3DOptions, ContourLayer, type ContourOptions, type DecisionBoundaryHandle, type DecisionBoundaryOptions, type Density, type DepthCurves, type DepthHandle, type DepthOptions, type Dim, type DrawState, type DrawTool, type EmbeddingHandle, type EmbeddingOptions, ErrorBarLayer, type ErrorBarOptions, type ExportOptions, FUNNEL_PALETTE, type FeatureImportanceHandle, type FeatureImportanceOptions, type FibLevel, type ForceLayoutOptions, type FunnelItem, type FunnelLayoutOptions, type FunnelOptions, type FunnelStage, type GaugeLayoutOptions, type GaugeOptions, type GaugeThreshold, type GraphInput, GraphLayer, type GraphOptions, type GroupedBarOptions, HeatmapLayer, type HeatmapOptions, type HeikinAshiOptions, HexbinLayer, type HexbinOptions, type Histogram, type HoverReadoutRow, type Ichimoku, ImageLayer, type ImageOptions, type ImageSource, type InteractionMode, IsosurfaceLayer, type IsosurfaceOptions, type Layer, type Layer3D, type Layout, type LegendOptions, Line3DLayer, type Line3DOptions, LineLayer, type LineOptions, LinearScale, LogScale, ML_PALETTE, type Macd, type MarkerShape, type Ohlc, type OhlcArrays, type OhlcInput, OhlcLayer, type OhlcOptions, OrdinalTimeScale, PARALLEL_PALETTE, type ParallelAxis, type ParallelHandle, type ParallelLayoutResult, type ParallelLine, type ParallelOptions, type PartialDependenceHandle, type PartialDependenceOptions, type Patch, PatchesLayer, type PatchesOptions, type PcaResult, type PfColumn, type PickMode, PieLayer, type PieOptions, Plot, Plot3D, type Plot3DOptions, type PlotOptions, type PlotTitleOptions, PointCloudLayer, type PointCloudOptions, type PolarLineOptions, type PolarOptions, PolarPlot, type PolarScatterOptions, type PolarSeries, type PrCurve, type PrCurveHandle, type PrCurveOptions, Quiver3DLayer, type Quiver3DOptions, QuiverLayer, type QuiverOptions, type RGB, type Range, type RenderType, type RenkoOptions, type ResolvedAxisStyle, type RidgeGroup, type RidgelineHandle, type RidgelineOptions, type Ring, type RocCurve, type RocCurveHandle, type RocCurveOptions, type SankeyLayoutOptions, type SankeyLayoutResult, type SankeyLink, type SankeyNode, type SankeyNodeRect, type SankeyOptions, type SankeyRibbon, type Scale, type ScaleType, ScatterLayer, type ScatterOptions, type ShapBeeswarmHandle, type ShapBeeswarmOptions, type Spectrogram, type StackedAreaOptions, type StackedBarOptions, StemLayer, type StemOptions, type Stochastic, type SunburstArc, type SunburstLayoutOptions, type SunburstNode, type SunburstOptions, type SuperTrend, SurfaceLayer, type SurfaceOptions, TRANSFORM_GLSL, TRANSFORM_UNIFORMS, TREEMAP_PALETTE, type Table, type Theme, type Tick, type TicksSpec, TimeScale, type ToolbarHost, type ToolbarTheme, type TrainingCurvesHandle, type TrainingCurvesOptions, type TrainingSeries, type TreemapCell, type TreemapExtent, type TreemapItem, type TreemapOptions, VolumeLayer, type VolumeOptions, type VolumeProfile, type VolumeProfileOptions, type YAxisOptions, addAttentionMap, addBollinger, addCalibration, addChord, addConfusionMatrix, addDecisionBoundary, addDepth, addEmbedding, addFeatureImportance, addFunnel, addGauge, addHeikinAshi, addParallelCoordinates, addPartialDependence, addPrCurve, addRenko, addRidgeline, addRocCurve, addSankey, addShapBeeswarm, addSunburst, addTrainingCurves, addTreemap, addVolumeProfile, adx, atr, autoTicks, beeswarmLayout, bollinger, boxStats, bufferUsage, calibrationCurve, canvasToBlob, chordLayout, colormap, colormapLUT, confusionMatrix, copyCanvasToClipboard, createProgram, createToolbar, darkTheme, defaultFormat, depth, downloadCanvas, earcut, ema, emaSmooth, fft, fibRetracements, firstFinite, forceLayout, funnelLayout, gaugeLayout, heikinAshi, histogram, ichimoku, kde, keltner, lightTheme, lineBreak, linkX, lttb, macd, makeScale, marchingCubes, obv, parallelLayout, parseCSV, parseColor, pca, pointAndFigure, prCurve, quantileSorted, renko, resolveAxisStyle, resolveTicks, rocCurve, rollingStd, rsi, sankeyLayout, setTransformUniforms, sma, spectrogram, standardize, stochastic, sunburstLayout, superTrend, toColorCss, treemapLayout, trueRange, uniformLocations, volumeProfile, vwap, withMinorTicks, wma };
5166
+ /**
5167
+ * Statistics chart builders — free functions that compose existing layers, the
5168
+ * same shape as the finance / diagram / ML packs.
5169
+ */
5170
+
5171
+ interface RegressionOptions {
5172
+ x: ArrayLike<number>;
5173
+ y: ArrayLike<number>;
5174
+ /** `"ols"` (default) fits a straight line; `"loess"` fits a local curve. */
5175
+ method?: "ols" | "loess";
5176
+ /**
5177
+ * Shade ±`band`·standard-error around an OLS fit (2 ≈ 95%). Ignored for
5178
+ * LOESS, which has no closed-form interval here. Default 0 (no band).
5179
+ */
5180
+ band?: number;
5181
+ /** LOESS neighbourhood as a fraction of the points, 0..1. Default 0.3. */
5182
+ bandwidth?: number;
5183
+ /** Samples along the fitted curve. Default 2 for OLS, 100 for LOESS. */
5184
+ points?: number;
5185
+ color?: string;
5186
+ bandColor?: string;
5187
+ width?: number;
5188
+ name?: string;
5189
+ yAxis?: string;
5190
+ renderType?: RenderType;
5191
+ }
5192
+ interface RegressionHandle {
5193
+ line: LineLayer;
5194
+ band?: AreaLayer;
5195
+ /** The OLS fit (slope/intercept/r²), or null for LOESS. */
5196
+ fit: LinearFit | null;
5197
+ }
5198
+ /**
5199
+ * A trend line over a scatter — least squares by default, with an optional
5200
+ * confidence band, or a LOESS curve when the relationship is not linear. The
5201
+ * series name carries r² so the chart states its own fit quality.
5202
+ */
5203
+ declare function addRegression(plot: Plot, opts: RegressionOptions): RegressionHandle;
5204
+ interface EcdfOptions {
5205
+ values: ArrayLike<number>;
5206
+ color?: string;
5207
+ width?: number;
5208
+ name?: string;
5209
+ yAxis?: string;
5210
+ renderType?: RenderType;
5211
+ }
5212
+ /**
5213
+ * The empirical CDF as a step line: the most honest way to compare two
5214
+ * distributions, since it involves no binning choice at all.
5215
+ */
5216
+ declare function addEcdf(plot: Plot, opts: EcdfOptions): LineLayer;
5217
+ interface CorrMatrixOptions {
5218
+ /** One array per variable. */
5219
+ columns: ReadonlyArray<ArrayLike<number>>;
5220
+ /** Variable names, used for the axis tick labels. */
5221
+ names?: string[];
5222
+ /** Defaults to a diverging map so ±1 read as opposites. */
5223
+ colormap?: ColormapSpec;
5224
+ /** Label the axes with `names`. Default true. */
5225
+ labelAxes?: boolean;
5226
+ name?: string;
5227
+ yAxis?: string;
5228
+ }
5229
+ interface CorrMatrixHandle {
5230
+ heatmap: HeatmapLayer;
5231
+ /** Row-major `k×k` correlations. */
5232
+ values: Float64Array;
5233
+ size: number;
5234
+ }
5235
+ /**
5236
+ * A correlation matrix as a heatmap, on a diverging colormap locked to ±1 so
5237
+ * that zero is the neutral colour and sign is readable at a glance.
5238
+ */
5239
+ declare function addCorrMatrix(plot: Plot, opts: CorrMatrixOptions): CorrMatrixHandle;
5240
+ interface PsdOptions {
5241
+ signal: ArrayLike<number>;
5242
+ sampleRate?: number;
5243
+ /** Samples per Welch segment. Default 256. */
5244
+ segment?: number;
5245
+ overlap?: number;
5246
+ window?: WindowName;
5247
+ /** Plot power in dB (10·log10). Default true — spectra span decades. */
5248
+ decibels?: boolean;
5249
+ color?: string;
5250
+ width?: number;
5251
+ name?: string;
5252
+ yAxis?: string;
5253
+ renderType?: RenderType;
5254
+ }
5255
+ interface PsdHandle {
5256
+ line: LineLayer;
5257
+ frequencies: Float64Array;
5258
+ power: Float64Array;
5259
+ }
5260
+ /**
5261
+ * Welch power spectral density as a line — averaged over overlapping windowed
5262
+ * segments, so a noisy signal gives a readable spectrum instead of grass.
5263
+ */
5264
+ declare function addPsd(plot: Plot, opts: PsdOptions): PsdHandle;
5265
+
5266
+ export { type AdapterOptions, type Adx, type Annotation, AreaLayer, type AreaOptions, type AreaSeries, type Aroon, type AttentionMapHandle, type AttentionMapOptions, Axis, type AxisConfig, type AxisFrame, type AxisScaleOptions, Bar3DLayer, type Bar3DOptions, BarLayer, type BarOptions, type BarSeries, type BeeswarmOptions, type BollingerBands, type BollingerHandle, type BollingerOptions, type Bounds, type Bounds3, type Box3D, type BoxDims, type BoxGroup, BoxLayer, type BoxOptions, type BoxStats, Boxes3DLayer, type Boxes3DOptions, type Brick, type BuiltinColormapName, type BuiltinPaletteName, CHORD_PALETTE, COLORMAP_KIND, type CSVOptions, type CalibrationCurve, type CalibrationHandle, type CalibrationOptions, type Candle, type CandlestickData, CandlestickLayer, type CandlestickOptions, CategoricalScale, type Channel, type ChordGroupArc, type ChordLayoutOptions, type ChordLayoutResult, type ChordOptions, type ChordRibbon, type ClassScore, type ClassificationReport, type Color, type ColorInfo, type ColorbarOptions, type ColorbarTheme, type ColormapKind, type ColormapName, type ColormapSpec, type ConfusionMatrix, type ConfusionMatrixHandle, type ConfusionMatrixOptions, Contour3DLayer, type Contour3DOptions, ContourLayer, type ContourOptions, type CorrMatrixHandle, type CorrMatrixOptions, type Correlation, DEFAULT_PALETTE, type DecisionBoundaryHandle, type DecisionBoundaryOptions, type Density, type DepthCurves, type DepthHandle, type DepthOptions, type Dim, type DrawState, type DrawTool, type Drawdown, type DrawdownHandle, type DrawdownOptions, type EcdfOptions, type EmbeddingHandle, type EmbeddingOptions, type ErrInput, type ErrorBarData, ErrorBarLayer, type ErrorBarOptions, type ExportOptions, FUNNEL_PALETTE, type FeatureImportanceHandle, type FeatureImportanceOptions, type FibLevel, type ForceLayoutOptions, type FunnelItem, type FunnelLayoutOptions, type FunnelOptions, type FunnelStage, type GaugeLayoutOptions, type GaugeOptions, type GaugeThreshold, type GraphData, type GraphInput, GraphLayer, type GraphOptions, type GroupedBarOptions, HeatmapLayer, type HeatmapOptions, type HeikinAshiOptions, HexbinLayer, type HexbinOptions, type Histogram, type HoverReadoutRow, type Ichimoku, ImageLayer, type ImageOptions, type ImageSource, type InteractionMode, IsosurfaceLayer, type IsosurfaceOptions, type KerasAdapterOptions, type KerasLayerConfig, type KerasModelConfig, LAYER_COLORS, type Label3D, type Layer, type Layer3D, type LayerCategory, type Layout, type LearningCurveHandle, type LearningCurveOptions, type LegendOptions, type LiftCurve, type LiftCurveHandle, type LiftCurveOptions, Line3DLayer, type Line3DOptions, type LineJoin, LineLayer, type LineOptions, type LinearFit, LinearScale, LogScale, ML_PALETTE, type Macd, type MarkerShape, type Mat4, type MlpOptions, type ModelBlock, type ModelBoxSizing, type ModelEdge, type ModelEdgePath, type ModelGraph, type ModelGraph3DHandle, type ModelGraph3DOptions, type ModelGraphHandle, type ModelGraphOptions, type ModelLayoutOptions, type ModelLayoutResult, type ModelNode, type ModelNodeBox, type MulticlassRoc, type Ohlc, type OhlcArrays, type OhlcInput, OhlcLayer, type OhlcOptions, type OnnxAdapterOptions, type OnnxGraph, type OnnxNode, OrdinalTimeScale, PALETTES, PARALLEL_PALETTE, type PaletteName, type PaletteSpec, type ParallelAxis, type ParallelHandle, type ParallelLayoutResult, type ParallelLine, type ParallelOptions, type PartialDependenceHandle, type PartialDependenceOptions, type Patch, PatchesLayer, type PatchesOptions, type PcaResult, type PfColumn, type PickMode, type Picked, PieLayer, type PieOptions, type PivotLevels, Plot, Plot3D, type Plot3DOptions, type PlotOptions, type PlotTitleOptions, PointCloudLayer, type PointCloudOptions, type PolarLineOptions, type PolarOptions, PolarPlot, type PolarScatterOptions, type PolarSeries, type PrCurve, type PrCurveHandle, type PrCurveOptions, type PredVsActualHandle, type PredVsActualOptions, type Psd, type PsdHandle, type PsdOptions, Quiver3DLayer, type Quiver3DOptions, QuiverLayer, type QuiverOptions, type RGB, type Range, type RegressionHandle, type RegressionOptions, type RenderType, type RenkoOptions, type ResampledOhlc, type ResidualsHandle, type ResidualsOptions, type ResolvedAxisStyle, type RidgeGroup, type RidgelineHandle, type RidgelineOptions, type Ring, type RocCurve, type RocCurveHandle, type RocCurveOptions, type SankeyLayoutOptions, type SankeyLayoutResult, type SankeyLink, type SankeyNode, type SankeyNodeRect, type SankeyOptions, type SankeyRibbon, type Scale, type ScaleType, ScatterLayer, type ScatterOptions, type SequentialLayer, type ShapBeeswarmHandle, type ShapBeeswarmOptions, type SklearnStep, type Spectrogram, type StackedAreaOptions, type StackedBarOptions, StemLayer, type StemOptions, type Stochastic, type SunburstArc, type SunburstLayoutOptions, type SunburstNode, type SunburstOptions, type SuperTrend, SurfaceLayer, type SurfaceOptions, TRANSFORM_GLSL, TRANSFORM_UNIFORMS, TREEMAP_PALETTE, type Table, type Theme, type Tick, type TicksSpec, TimeScale, type ToolbarHost, type ToolbarTheme, type TorchFxNode, type TrainingCurvesHandle, type TrainingCurvesOptions, type TrainingSeries, type TreemapCell, type TreemapExtent, type TreemapItem, type TreemapOptions, type Trend, VolumeLayer, type VolumeOptions, type VolumeProfile, type VolumeProfileOptions, type WelchOptions, type WindowName, type YAxisOptions, addAttentionMap, addBollinger, addCalibration, addChord, addConfusionMatrix, addCorrMatrix, addDecisionBoundary, addDepth, addDrawdown, addEcdf, addEmbedding, addFeatureImportance, addFunnel, addGauge, addHeikinAshi, addLearningCurve, addLiftCurve, addModelGraph, addModelGraph3D, addParallelCoordinates, addPartialDependence, addPrCurve, addPredVsActual, addPsd, addRegression, addRenko, addResiduals, addRidgeline, addRocCurve, addSankey, addShapBeeswarm, addSunburst, addTrainingCurves, addTreemap, addVolumeProfile, adx, aroon, atr, autoTicks, beeswarmLayout, bollinger, boxStats, brierScore, bufferUsage, calibrationCurve, canvasToBlob, cci, chordLayout, classificationReport, colormap, colormapFromStops, colormapGradient, colormapLUT, colormapNames, confusionMatrix, copyCanvasToClipboard, corrMatrix, correlation, createProgram, createToolbar, crossCorrelate, darkTheme, defaultFormat, depth, discreteColormap, donchian, downloadCanvas, drawdown, earcut, ecdf, ema, emaSmooth, fft, fibRetracements, firstFinite, forceLayout, formatCount, formatShape, funnelLayout, gaugeLayout, heikinAshi, histogram, ichimoku, kde, keltner, layerCategory, liftCurve, lightTheme, lineBreak, linearRegression, linearTrend, linkX, loess, logLoss, lttb, macd, mae, makeScale, marchingCubes, mfi, mlpModel, modelBoxDims, modelGraphFromKeras, modelGraphFromOnnx, modelGraphFromSklearn, modelGraphFromTorchFx, modelLayout, mse, obv, palette, paletteColor, paletteNames, parabolicSar, parallelLayout, parseCSV, parseColor, pca, pivotPoints, pointAndFigure, prCurve, quantileSorted, r2, registerColormap, registerPalette, renderColorbars, renko, resampleOhlc, resolveAxisStyle, resolveTicks, reverseColormap, rmse, rocCurve, rocCurveOvR, rollingStd, rsi, sankeyLayout, savitzkyGolay, sequentialModel, setTransformUniforms, sma, spectrogram, standardize, stochastic, sunburstLayout, superTrend, symmetricDomain, toColorCss, treemapLayout, trueRange, uniformLocations, volumeProfile, vwap, welch, williamsR, windowFunction, withMinorTicks, wma, zscore };