@photonviz/core 0.3.1 → 0.4.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/README.md +21 -7
- package/dist/index.d.ts +1078 -3
- package/dist/index.js +2421 -43
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1380,6 +1380,25 @@ interface PlotTitleOptions {
|
|
|
1380
1380
|
align?: "left" | "center" | "right";
|
|
1381
1381
|
}
|
|
1382
1382
|
|
|
1383
|
+
/**
|
|
1384
|
+
* Shared image-export helpers used by Plot / Plot3D / PolarPlot. Each plot
|
|
1385
|
+
* composites its layers into a single 2D canvas, then these turn that canvas into
|
|
1386
|
+
* a data URL / Blob / download / clipboard image.
|
|
1387
|
+
*/
|
|
1388
|
+
/** Options accepted by the export methods. */
|
|
1389
|
+
interface ExportOptions {
|
|
1390
|
+
/** Fill color behind the plot (default the theme page color; `"transparent"` keeps alpha). */
|
|
1391
|
+
background?: string;
|
|
1392
|
+
/** Encoder quality 0..1 for lossy types (`image/jpeg`, `image/webp`). */
|
|
1393
|
+
quality?: number;
|
|
1394
|
+
}
|
|
1395
|
+
/** Turn a canvas into a `Blob` (default PNG). */
|
|
1396
|
+
declare function canvasToBlob(canvas: HTMLCanvasElement, type?: string, quality?: number): Promise<Blob | null>;
|
|
1397
|
+
/** Download a canvas as an image file (PNG by default). */
|
|
1398
|
+
declare function downloadCanvas(canvas: HTMLCanvasElement, filename?: string, type?: string, quality?: number): Promise<void>;
|
|
1399
|
+
/** Copy a canvas to the clipboard as a PNG. Throws where the browser can't. */
|
|
1400
|
+
declare function copyCanvasToClipboard(canvas: HTMLCanvasElement): Promise<void>;
|
|
1401
|
+
|
|
1383
1402
|
interface AxisScaleOptions {
|
|
1384
1403
|
type?: ScaleType;
|
|
1385
1404
|
/** Fixed domain. If omitted, the axis autoscales to the data. */
|
|
@@ -1469,7 +1488,10 @@ interface GraphInput extends Omit<GraphOptions, "x" | "y"> {
|
|
|
1469
1488
|
/**
|
|
1470
1489
|
* A Canvas2D overlay marker drawn above the data, projected through the scales:
|
|
1471
1490
|
* a full-width/height guide line (`span`), a shaded range (`band`), a rectangle
|
|
1472
|
-
* (`box`),
|
|
1491
|
+
* (`box`), text (`label`), an arbitrary segment (`line` — trendlines), a segment
|
|
1492
|
+
* extended past its end (`ray`), or Fibonacci retracement levels (`fib`). `yAxis`
|
|
1493
|
+
* targets a secondary axis where relevant. All coordinates are in data space, so
|
|
1494
|
+
* annotations pan and zoom with the chart.
|
|
1473
1495
|
*/
|
|
1474
1496
|
type Annotation = {
|
|
1475
1497
|
type: "span";
|
|
@@ -1492,6 +1514,7 @@ type Annotation = {
|
|
|
1492
1514
|
y: Range;
|
|
1493
1515
|
color?: string;
|
|
1494
1516
|
border?: string;
|
|
1517
|
+
label?: string;
|
|
1495
1518
|
yAxis?: string;
|
|
1496
1519
|
} | {
|
|
1497
1520
|
type: "label";
|
|
@@ -1502,7 +1525,42 @@ type Annotation = {
|
|
|
1502
1525
|
font?: string;
|
|
1503
1526
|
align?: "left" | "center" | "right";
|
|
1504
1527
|
yAxis?: string;
|
|
1528
|
+
} | {
|
|
1529
|
+
type: "line";
|
|
1530
|
+
x0: number;
|
|
1531
|
+
y0: number;
|
|
1532
|
+
x1: number;
|
|
1533
|
+
y1: number;
|
|
1534
|
+
color?: string;
|
|
1535
|
+
width?: number;
|
|
1536
|
+
dash?: number[];
|
|
1537
|
+
label?: string;
|
|
1538
|
+
yAxis?: string;
|
|
1539
|
+
} | {
|
|
1540
|
+
type: "ray";
|
|
1541
|
+
x0: number;
|
|
1542
|
+
y0: number;
|
|
1543
|
+
x1: number;
|
|
1544
|
+
y1: number;
|
|
1545
|
+
color?: string;
|
|
1546
|
+
width?: number;
|
|
1547
|
+
dash?: number[];
|
|
1548
|
+
label?: string;
|
|
1549
|
+
yAxis?: string;
|
|
1550
|
+
} | {
|
|
1551
|
+
type: "fib";
|
|
1552
|
+
x0: number;
|
|
1553
|
+
x1: number;
|
|
1554
|
+
high: number;
|
|
1555
|
+
low: number;
|
|
1556
|
+
ratios?: number[];
|
|
1557
|
+
color?: string;
|
|
1558
|
+
fill?: boolean;
|
|
1559
|
+
label?: string;
|
|
1560
|
+
yAxis?: string;
|
|
1505
1561
|
};
|
|
1562
|
+
/** An interactive drawing tool: click-drag on the plot to place the shape. */
|
|
1563
|
+
type DrawTool = "trendline" | "hline" | "ray" | "fib" | "rect";
|
|
1506
1564
|
/** One line of the hover tooltip header, produced by {@link PlotOptions.hoverReadout}. */
|
|
1507
1565
|
interface HoverReadoutRow {
|
|
1508
1566
|
label: string;
|
|
@@ -1531,6 +1589,10 @@ interface PlotOptions {
|
|
|
1531
1589
|
interactive?: boolean;
|
|
1532
1590
|
/** Show the built-in toolbar (home + pan/box/X/Y zoom modes). Default true. */
|
|
1533
1591
|
showToolbar?: boolean;
|
|
1592
|
+
/** Add drawing tools (trendline / horizontal / ray / Fibonacci / rectangle) to the toolbar. Default false. */
|
|
1593
|
+
drawingTools?: boolean;
|
|
1594
|
+
/** Accessible label for the chart (sets `role="img"` + `aria-label`). Auto-summarized if omitted. */
|
|
1595
|
+
ariaLabel?: string;
|
|
1534
1596
|
/** Initial interaction mode. Default `"pan"`. */
|
|
1535
1597
|
mode?: InteractionMode;
|
|
1536
1598
|
/** Enable hover crosshair + tooltip. Default true. */
|
|
@@ -1578,6 +1640,7 @@ interface PlotOptions {
|
|
|
1578
1640
|
*/
|
|
1579
1641
|
declare class Plot {
|
|
1580
1642
|
private container;
|
|
1643
|
+
private ariaLabel?;
|
|
1581
1644
|
private gridCanvas;
|
|
1582
1645
|
private dataCanvas;
|
|
1583
1646
|
private axisCanvas;
|
|
@@ -1619,6 +1682,13 @@ declare class Plot {
|
|
|
1619
1682
|
private lastEmittedX;
|
|
1620
1683
|
private lastEmittedCursor;
|
|
1621
1684
|
private linkedCursorX;
|
|
1685
|
+
private drawTool;
|
|
1686
|
+
private drawings;
|
|
1687
|
+
private pendingDrawing;
|
|
1688
|
+
private drawToolCbs;
|
|
1689
|
+
private hoverDrawing;
|
|
1690
|
+
private selectedDrawing;
|
|
1691
|
+
private drawMenu;
|
|
1622
1692
|
private tooltip;
|
|
1623
1693
|
/** A point clicked to pin its details, until another click clears it. */
|
|
1624
1694
|
private selected;
|
|
@@ -1637,8 +1707,13 @@ declare class Plot {
|
|
|
1637
1707
|
/** Pixel x-position (and title x) for each y axis, by draw order per side. */
|
|
1638
1708
|
private yAxisPositions;
|
|
1639
1709
|
private register;
|
|
1710
|
+
/** Set the chart's accessible label (`aria-label`). Pass `undefined` to auto-summarize. */
|
|
1711
|
+
setAriaLabel(text: string | undefined): void;
|
|
1712
|
+
/** A one-line text summary of the chart (title + series), for a11y / tooltips. */
|
|
1713
|
+
describe(): string;
|
|
1714
|
+
private updateAria;
|
|
1640
1715
|
/**
|
|
1641
|
-
* Register a layer built outside core (
|
|
1716
|
+
* Register a layer built outside core (a custom WebGL2 `Layer`). Use with
|
|
1642
1717
|
* {@link context} to construct the layer against this plot's WebGL2 context.
|
|
1643
1718
|
*/
|
|
1644
1719
|
add<T extends Layer>(layer: T): T;
|
|
@@ -1700,6 +1775,41 @@ declare class Plot {
|
|
|
1700
1775
|
addAnnotation(a: Annotation): () => void;
|
|
1701
1776
|
/** Remove all annotations. */
|
|
1702
1777
|
clearAnnotations(): void;
|
|
1778
|
+
/** Activate a drawing tool (click-drag on the plot to place), or `null` to stop drawing. */
|
|
1779
|
+
setDrawTool(tool: DrawTool | null): void;
|
|
1780
|
+
/** The active drawing tool, or `null`. */
|
|
1781
|
+
getDrawTool(): DrawTool | null;
|
|
1782
|
+
/** Subscribe to draw-tool changes (used by the toolbar). Returns an unsubscribe fn. */
|
|
1783
|
+
onDrawToolChange(cb: (t: DrawTool | null) => void): () => void;
|
|
1784
|
+
/** Add a drawing programmatically (same shapes the tools produce). */
|
|
1785
|
+
addDrawing(a: Annotation): void;
|
|
1786
|
+
/** All user drawings (trendlines, fib levels, …). */
|
|
1787
|
+
getDrawings(): Annotation[];
|
|
1788
|
+
/** Remove every user drawing. */
|
|
1789
|
+
clearDrawings(): void;
|
|
1790
|
+
/** Canvas-space pixel → data coordinates on the x + primary y scale. */
|
|
1791
|
+
private dataAtPx;
|
|
1792
|
+
/** Build the annotation for a draw tool from its start + current data points. */
|
|
1793
|
+
private buildDrawing;
|
|
1794
|
+
private drawingYScale;
|
|
1795
|
+
/** Editable handle points (data space) for a drawing; `[]` if it has none. */
|
|
1796
|
+
private drawingHandlePts;
|
|
1797
|
+
/** Move handle `i` of a drawing to a new data-space point (all editable types). */
|
|
1798
|
+
private setDrawingHandle;
|
|
1799
|
+
/** Translate a whole drawing by a data-space delta (drag the body). */
|
|
1800
|
+
private translateDrawing;
|
|
1801
|
+
/** Cursor→drawing distance in px (segment for line/ray, edges for box/fib, the line for span). */
|
|
1802
|
+
private drawingBodyDist;
|
|
1803
|
+
/** Topmost drawing under the cursor and its handle (handle −1 = body, index −1 = none). */
|
|
1804
|
+
private hitDrawing;
|
|
1805
|
+
private removeDrawing;
|
|
1806
|
+
private hideDrawMenu;
|
|
1807
|
+
/** Right-click context menu for a drawing: rename, recolor, delete. */
|
|
1808
|
+
private showDrawMenu;
|
|
1809
|
+
/** Recolor a drawing: a box keeps its translucent fill + opaque border; others take the color directly. */
|
|
1810
|
+
private recolorDrawing;
|
|
1811
|
+
/** Prompt for a label on a drawing (double-click / context menu). */
|
|
1812
|
+
private renameDrawing;
|
|
1703
1813
|
/** Compute an STFT of `signal` and render it as a heatmap (time × frequency). */
|
|
1704
1814
|
addHeatmapSpectrogram(signal: ArrayLike<number>, opts?: {
|
|
1705
1815
|
fftSize?: number;
|
|
@@ -1748,6 +1858,20 @@ declare class Plot {
|
|
|
1748
1858
|
onModeChange(cb: (mode: InteractionMode) => void): void;
|
|
1749
1859
|
/** Reset to the home view: explicit domains restored, auto axes re-fit to data. */
|
|
1750
1860
|
home(): void;
|
|
1861
|
+
/**
|
|
1862
|
+
* Composite this plot's layers (grid → data → axes/labels) into a single 2D
|
|
1863
|
+
* canvas at device resolution. `background` fills behind the plot (default the
|
|
1864
|
+
* theme's page color; pass `"transparent"` to keep alpha).
|
|
1865
|
+
*/
|
|
1866
|
+
private compositeCanvas;
|
|
1867
|
+
/** Export the current view as a data URL (default PNG). */
|
|
1868
|
+
toDataURL(type?: string, opts?: ExportOptions): string;
|
|
1869
|
+
/** Export the current view as a `Blob` (default PNG). */
|
|
1870
|
+
toBlob(type?: string, opts?: ExportOptions): Promise<Blob | null>;
|
|
1871
|
+
/** Download the current view as an image (PNG by default). */
|
|
1872
|
+
downloadImage(filename?: string, type?: string, opts?: ExportOptions): Promise<void>;
|
|
1873
|
+
/** Copy the current view to the clipboard as a PNG. Throws if the browser can't. */
|
|
1874
|
+
copyToClipboard(opts?: ExportOptions): Promise<void>;
|
|
1751
1875
|
/** Re-fit auto axes to the data: x over all series, each y axis over its own series. */
|
|
1752
1876
|
autoscale(): void;
|
|
1753
1877
|
destroy(): void;
|
|
@@ -1823,6 +1947,15 @@ interface ToolbarHost {
|
|
|
1823
1947
|
getMode(): InteractionMode;
|
|
1824
1948
|
home(): void;
|
|
1825
1949
|
onModeChange(cb: (mode: InteractionMode) => void): void;
|
|
1950
|
+
/** Optional: download the current view as a PNG. Adds a toolbar button when present. */
|
|
1951
|
+
download?(): void;
|
|
1952
|
+
/** Optional: interactive drawing tools. Adds a tool group (trendline / hline / ray / fib / rect / clear) when present. */
|
|
1953
|
+
drawTools?: {
|
|
1954
|
+
set(tool: string | null): void;
|
|
1955
|
+
get(): string | null;
|
|
1956
|
+
clear(): void;
|
|
1957
|
+
onChange(cb: (tool: string | null) => void): void;
|
|
1958
|
+
};
|
|
1826
1959
|
}
|
|
1827
1960
|
interface ToolbarTheme {
|
|
1828
1961
|
bg: string;
|
|
@@ -1952,6 +2085,16 @@ declare class PolarPlot {
|
|
|
1952
2085
|
getRotation(): number;
|
|
1953
2086
|
/** Set the rotation offset (radians, CCW) and redraw. */
|
|
1954
2087
|
setRotation(rad: number): void;
|
|
2088
|
+
/** Composite grid → data → overlay into one canvas at device resolution. */
|
|
2089
|
+
private compositeCanvas;
|
|
2090
|
+
/** Export the current view as a data URL (default PNG). */
|
|
2091
|
+
toDataURL(type?: string, opts?: ExportOptions): string;
|
|
2092
|
+
/** Export the current view as a `Blob` (default PNG). */
|
|
2093
|
+
toBlob(type?: string, opts?: ExportOptions): Promise<Blob | null>;
|
|
2094
|
+
/** Download the current view as an image (PNG by default). */
|
|
2095
|
+
downloadImage(filename?: string, type?: string, opts?: ExportOptions): Promise<void>;
|
|
2096
|
+
/** Copy the current view to the clipboard as a PNG. */
|
|
2097
|
+
copyToClipboard(opts?: ExportOptions): Promise<void>;
|
|
1955
2098
|
destroy(): void;
|
|
1956
2099
|
private resize;
|
|
1957
2100
|
requestRender(): void;
|
|
@@ -2456,6 +2599,8 @@ interface Plot3DOptions {
|
|
|
2456
2599
|
hover?: boolean;
|
|
2457
2600
|
/** Show a reset-view (home) button. Default true. */
|
|
2458
2601
|
resetButton?: boolean;
|
|
2602
|
+
/** Show a download-PNG button. Default true. */
|
|
2603
|
+
downloadButton?: boolean;
|
|
2459
2604
|
/** Draw grid lines on the back walls of the cube. Default true. */
|
|
2460
2605
|
gridPlanes?: boolean;
|
|
2461
2606
|
/** Auto-orbit the camera: `true` for a default speed, or radians/frame. Default off. */
|
|
@@ -2509,6 +2654,7 @@ declare class Plot3D {
|
|
|
2509
2654
|
private colorbarDiv;
|
|
2510
2655
|
private tooltip;
|
|
2511
2656
|
private resetBtn;
|
|
2657
|
+
private downloadBtn;
|
|
2512
2658
|
private hoverEnabled;
|
|
2513
2659
|
/** Screen position (device px) of the picked point, for the highlight ring. */
|
|
2514
2660
|
private hoverHit;
|
|
@@ -2551,6 +2697,16 @@ declare class Plot3D {
|
|
|
2551
2697
|
removeLayer(layer: Layer3D): void;
|
|
2552
2698
|
/** Re-fit the axes to the data and redraw — call after a layer's `setData(...)`. */
|
|
2553
2699
|
refresh(): void;
|
|
2700
|
+
/** Copy the current 3D frame (already composited on one canvas) into a fresh canvas. */
|
|
2701
|
+
private compositeCanvas;
|
|
2702
|
+
/** Export the current view as a data URL (default PNG). */
|
|
2703
|
+
toDataURL(type?: string, opts?: ExportOptions): string;
|
|
2704
|
+
/** Export the current view as a `Blob` (default PNG). */
|
|
2705
|
+
toBlob(type?: string, opts?: ExportOptions): Promise<Blob | null>;
|
|
2706
|
+
/** Download the current view as an image (PNG by default). */
|
|
2707
|
+
downloadImage(filename?: string, type?: string, opts?: ExportOptions): Promise<void>;
|
|
2708
|
+
/** Copy the current view to the clipboard as a PNG. */
|
|
2709
|
+
copyToClipboard(opts?: ExportOptions): Promise<void>;
|
|
2554
2710
|
destroy(): void;
|
|
2555
2711
|
private recompute;
|
|
2556
2712
|
/** Build tick-mark line geometry + tick/title labels from the data bounds. */
|
|
@@ -2746,6 +2902,54 @@ declare function trueRange(high: ArrayLike<number>, low: ArrayLike<number>, clos
|
|
|
2746
2902
|
declare function atr(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period?: number): Float64Array;
|
|
2747
2903
|
/** Index of the first non-NaN value (−1 if all NaN). Handy for trimming warm-up. */
|
|
2748
2904
|
declare function firstFinite(values: ArrayLike<number>): number;
|
|
2905
|
+
interface Stochastic {
|
|
2906
|
+
k: Float64Array;
|
|
2907
|
+
d: Float64Array;
|
|
2908
|
+
}
|
|
2909
|
+
/** Stochastic oscillator: %K over `kPeriod`, %D = SMA(%K, dPeriod). Values 0..100. */
|
|
2910
|
+
declare function stochastic(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, kPeriod?: number, dPeriod?: number): Stochastic;
|
|
2911
|
+
interface Channel {
|
|
2912
|
+
middle: Float64Array;
|
|
2913
|
+
upper: Float64Array;
|
|
2914
|
+
lower: Float64Array;
|
|
2915
|
+
}
|
|
2916
|
+
/** Keltner Channels: EMA(period) ± mult·ATR(atrPeriod). */
|
|
2917
|
+
declare function keltner(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period?: number, mult?: number, atrPeriod?: number): Channel;
|
|
2918
|
+
/** On-Balance Volume — a running signed volume total (no warm-up). */
|
|
2919
|
+
declare function obv(close: ArrayLike<number>, volume: ArrayLike<number>): Float64Array;
|
|
2920
|
+
interface Ichimoku {
|
|
2921
|
+
conversion: Float64Array;
|
|
2922
|
+
base: Float64Array;
|
|
2923
|
+
spanA: Float64Array;
|
|
2924
|
+
spanB: Float64Array;
|
|
2925
|
+
}
|
|
2926
|
+
/**
|
|
2927
|
+
* Ichimoku lines (conversion/base/spanA/spanB). Spans are returned **unshifted**
|
|
2928
|
+
* (traditional charts project the cloud forward by `basePeriod` bars).
|
|
2929
|
+
*/
|
|
2930
|
+
declare function ichimoku(high: ArrayLike<number>, low: ArrayLike<number>, convPeriod?: number, basePeriod?: number, spanBPeriod?: number): Ichimoku;
|
|
2931
|
+
interface Adx {
|
|
2932
|
+
adx: Float64Array;
|
|
2933
|
+
plusDI: Float64Array;
|
|
2934
|
+
minusDI: Float64Array;
|
|
2935
|
+
}
|
|
2936
|
+
/** Wilder's ADX (+DI / −DI / ADX) over `period` (default 14). */
|
|
2937
|
+
declare function adx(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period?: number): Adx;
|
|
2938
|
+
interface SuperTrend {
|
|
2939
|
+
trend: Float64Array;
|
|
2940
|
+
direction: Float64Array;
|
|
2941
|
+
}
|
|
2942
|
+
/**
|
|
2943
|
+
* SuperTrend (ATR bands with trend-following flip). `trend` is the line; `direction`
|
|
2944
|
+
* is +1 (up / support below price) or −1 (down / resistance above price).
|
|
2945
|
+
*/
|
|
2946
|
+
declare function superTrend(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period?: number, mult?: number): SuperTrend;
|
|
2947
|
+
interface FibLevel {
|
|
2948
|
+
ratio: number;
|
|
2949
|
+
price: number;
|
|
2950
|
+
}
|
|
2951
|
+
/** Fibonacci retracement price levels between a `high` and `low` (standard ratios). */
|
|
2952
|
+
declare function fibRetracements(high: number, low: number, ratios?: number[]): FibLevel[];
|
|
2749
2953
|
|
|
2750
2954
|
/**
|
|
2751
2955
|
* Chart-type transforms: turn raw OHLC(V) into the geometry a specialist finance
|
|
@@ -2929,9 +3133,880 @@ interface DepthHandle {
|
|
|
2929
3133
|
}
|
|
2930
3134
|
declare function addDepth(plot: Plot, opts: DepthOptions): DepthHandle;
|
|
2931
3135
|
|
|
3136
|
+
/**
|
|
3137
|
+
* A tiny dependency-free CSV parser + typed-array column access — the common
|
|
3138
|
+
* "load a CSV and plot a column" path. Handles quoted fields, escaped quotes
|
|
3139
|
+
* (`""`), and `\n` / `\r\n` line endings.
|
|
3140
|
+
*/
|
|
3141
|
+
interface CSVOptions {
|
|
3142
|
+
/** Field delimiter. Default `","`. */
|
|
3143
|
+
delimiter?: string;
|
|
3144
|
+
/** Treat the first row as headers. Default `true`. */
|
|
3145
|
+
header?: boolean;
|
|
3146
|
+
/** Drop blank lines. Default `true`. */
|
|
3147
|
+
skipEmpty?: boolean;
|
|
3148
|
+
}
|
|
3149
|
+
/** A parsed CSV: header names + string rows, with typed column accessors. */
|
|
3150
|
+
interface Table {
|
|
3151
|
+
headers: string[];
|
|
3152
|
+
rows: string[][];
|
|
3153
|
+
/** Number of data rows. */
|
|
3154
|
+
readonly length: number;
|
|
3155
|
+
/** A column's raw string values (by name or index). */
|
|
3156
|
+
column(name: string | number): string[];
|
|
3157
|
+
/** A column parsed to a `Float64Array` (non-numeric cells become `NaN`). */
|
|
3158
|
+
numeric(name: string | number): Float64Array;
|
|
3159
|
+
}
|
|
3160
|
+
/** Parse CSV text into a {@link Table}. */
|
|
3161
|
+
declare function parseCSV(text: string, opts?: CSVOptions): Table;
|
|
3162
|
+
|
|
3163
|
+
/**
|
|
3164
|
+
* Largest-Triangle-Three-Buckets (LTTB) downsampling — reduce a series to
|
|
3165
|
+
* `threshold` points while preserving its visual shape (peaks/troughs), the
|
|
3166
|
+
* standard technique for plotting very long line series. First and last points
|
|
3167
|
+
* are always kept.
|
|
3168
|
+
*/
|
|
3169
|
+
declare function lttb(x: ArrayLike<number>, y: ArrayLike<number>, threshold: number): {
|
|
3170
|
+
x: Float64Array;
|
|
3171
|
+
y: Float64Array;
|
|
3172
|
+
};
|
|
3173
|
+
|
|
3174
|
+
/**
|
|
3175
|
+
* Pure ML classification-evaluation metrics: confusion matrix, ROC + AUC,
|
|
3176
|
+
* precision–recall + average precision, calibration (reliability) + ECE, plus
|
|
3177
|
+
* TensorBoard-style EMA smoothing for training curves. All array→struct, zero
|
|
3178
|
+
* deps, unit-tested. Import from `@photonviz/core`; the `addX` builders in
|
|
3179
|
+
* `ml/charts.ts` render these onto a {@link Plot}.
|
|
3180
|
+
*/
|
|
3181
|
+
/** A confusion matrix: raw counts plus a row-normalized (recall) view. */
|
|
3182
|
+
interface ConfusionMatrix {
|
|
3183
|
+
/** Row-major counts, length `classes*classes`; row = true label, col = predicted. */
|
|
3184
|
+
counts: Float64Array;
|
|
3185
|
+
/** Row-normalized: every row sums to 1 (a row with no support stays all-zero). */
|
|
3186
|
+
normalized: Float64Array;
|
|
3187
|
+
/** Per-true-class support (row totals). */
|
|
3188
|
+
support: Float64Array;
|
|
3189
|
+
classes: number;
|
|
3190
|
+
}
|
|
3191
|
+
/**
|
|
3192
|
+
* Confusion matrix of integer class labels. `classes` defaults to
|
|
3193
|
+
* `max(label) + 1`; out-of-range labels are ignored.
|
|
3194
|
+
*/
|
|
3195
|
+
declare function confusionMatrix(yTrue: ArrayLike<number>, yPred: ArrayLike<number>, classes?: number): ConfusionMatrix;
|
|
3196
|
+
/** A receiver-operating-characteristic curve and its area. */
|
|
3197
|
+
interface RocCurve {
|
|
3198
|
+
/** False-positive rate (x), starting at 0. */
|
|
3199
|
+
fpr: Float64Array;
|
|
3200
|
+
/** True-positive rate (y), starting at 0. */
|
|
3201
|
+
tpr: Float64Array;
|
|
3202
|
+
/** Score threshold at each vertex (`+Inf` for the origin). */
|
|
3203
|
+
thresholds: Float64Array;
|
|
3204
|
+
/** Area under the curve (`NaN` when a class is absent). */
|
|
3205
|
+
auc: number;
|
|
3206
|
+
}
|
|
3207
|
+
/**
|
|
3208
|
+
* ROC curve for binary `labels` (0/1) ranked by `scores` (higher = more positive).
|
|
3209
|
+
* Ties at equal scores are collapsed to a single vertex; AUC by the trapezoid rule.
|
|
3210
|
+
*/
|
|
3211
|
+
declare function rocCurve(scores: ArrayLike<number>, labels: ArrayLike<number>): RocCurve;
|
|
3212
|
+
/** A precision–recall curve and its average precision. */
|
|
3213
|
+
interface PrCurve {
|
|
3214
|
+
/** Recall (x), starting at 0. */
|
|
3215
|
+
recall: Float64Array;
|
|
3216
|
+
/** Precision (y), starting at 1. */
|
|
3217
|
+
precision: Float64Array;
|
|
3218
|
+
/** Score threshold at each vertex (`+Inf` for the leading point). */
|
|
3219
|
+
thresholds: Float64Array;
|
|
3220
|
+
/** Average precision — Σ (Rₙ − Rₙ₋₁)·Pₙ (`NaN` with no positives). */
|
|
3221
|
+
ap: number;
|
|
3222
|
+
/** Positive base rate (a no-skill classifier's precision). */
|
|
3223
|
+
baseline: number;
|
|
3224
|
+
}
|
|
3225
|
+
/** Precision–recall curve for binary `labels` (0/1) ranked by `scores`. */
|
|
3226
|
+
declare function prCurve(scores: ArrayLike<number>, labels: ArrayLike<number>): PrCurve;
|
|
3227
|
+
/** A reliability diagram: predicted confidence vs. observed frequency, per bin. */
|
|
3228
|
+
interface CalibrationCurve {
|
|
3229
|
+
/** Mean predicted probability in each bin (`NaN` if empty). */
|
|
3230
|
+
meanPredicted: Float64Array;
|
|
3231
|
+
/** Observed positive fraction in each bin (`NaN` if empty). */
|
|
3232
|
+
fractionPositive: Float64Array;
|
|
3233
|
+
/** Sample count per bin. */
|
|
3234
|
+
binCount: Float64Array;
|
|
3235
|
+
/** Expected Calibration Error — Σ (nᵦ/N)·|accᵦ − confᵦ|. */
|
|
3236
|
+
ece: number;
|
|
3237
|
+
}
|
|
3238
|
+
/**
|
|
3239
|
+
* Reliability diagram of predicted probabilities `scores` (in [0,1]) against
|
|
3240
|
+
* binary `labels`, using `bins` equal-width confidence buckets. Empty bins are
|
|
3241
|
+
* `NaN` (skip them when plotting).
|
|
3242
|
+
*/
|
|
3243
|
+
declare function calibrationCurve(scores: ArrayLike<number>, labels: ArrayLike<number>, bins?: number): CalibrationCurve;
|
|
3244
|
+
/**
|
|
3245
|
+
* TensorBoard-style debiased EMA smoothing of a noisy training curve. `weight`
|
|
3246
|
+
* in [0,1) is the momentum (0 = raw, →1 = very smooth). Non-finite inputs pass
|
|
3247
|
+
* through untouched and don't advance the average.
|
|
3248
|
+
*/
|
|
3249
|
+
declare function emaSmooth(values: ArrayLike<number>, weight?: number): Float64Array;
|
|
3250
|
+
|
|
3251
|
+
/**
|
|
3252
|
+
* Pure, dependency-free dimensionality reduction for embedding projections.
|
|
3253
|
+
* {@link pca} projects an `n×d` matrix onto its top-`k` principal components via
|
|
3254
|
+
* covariance power-iteration with deflation — deterministic (no RNG), so tests
|
|
3255
|
+
* and re-renders are stable. Pair with {@link addEmbedding}. For t-SNE/UMAP,
|
|
3256
|
+
* feed precomputed 2-D coordinates straight into the builder.
|
|
3257
|
+
*/
|
|
3258
|
+
/** The result of {@link pca}: projected scores + the components they project onto. */
|
|
3259
|
+
interface PcaResult {
|
|
3260
|
+
/** Projected coordinates, row-major `n×k`. */
|
|
3261
|
+
scores: Float64Array;
|
|
3262
|
+
/** Principal-component directions, row-major `k×d` (unit vectors). */
|
|
3263
|
+
components: Float64Array;
|
|
3264
|
+
/** Explained-variance ratio per component, length `k`. */
|
|
3265
|
+
explained: Float64Array;
|
|
3266
|
+
/** Per-column mean subtracted before projection, length `d`. */
|
|
3267
|
+
mean: Float64Array;
|
|
3268
|
+
n: number;
|
|
3269
|
+
d: number;
|
|
3270
|
+
k: number;
|
|
3271
|
+
}
|
|
3272
|
+
/** Z-score each of the `d` columns of a row-major `n×d` matrix (unit variance). */
|
|
3273
|
+
declare function standardize(data: ArrayLike<number>, n: number, d: number): Float64Array;
|
|
3274
|
+
/**
|
|
3275
|
+
* Principal component analysis of a row-major `n×d` matrix, projected to `k`
|
|
3276
|
+
* dims (default 2). Centers columns, forms the `d×d` covariance, then extracts
|
|
3277
|
+
* the top-`k` eigenvectors by power iteration + deflation. Deterministic.
|
|
3278
|
+
*/
|
|
3279
|
+
declare function pca(data: ArrayLike<number>, n: number, d: number, k?: number): PcaResult;
|
|
3280
|
+
|
|
3281
|
+
/**
|
|
3282
|
+
* Convenience builders for ML / deep-learning charts. Each takes a {@link Plot}
|
|
3283
|
+
* and composes existing layers (`addHeatmap`/`addLine`/`addScatter`/`addBar`/
|
|
3284
|
+
* `addArea`) from the pure metrics in `ml/metrics.ts` and reducers in
|
|
3285
|
+
* `ml/reduce.ts` — the same free-function style as the finance builders. No new
|
|
3286
|
+
* WebGL layers. Import from `@photonviz/core`.
|
|
3287
|
+
*/
|
|
3288
|
+
|
|
3289
|
+
/** tab10 categorical palette, cycled by class index. */
|
|
3290
|
+
declare const ML_PALETTE: readonly string[];
|
|
3291
|
+
interface ConfusionMatrixOptions {
|
|
3292
|
+
yTrue: ArrayLike<number>;
|
|
3293
|
+
yPred: ArrayLike<number>;
|
|
3294
|
+
/** Number of classes; inferred from the labels when omitted. */
|
|
3295
|
+
classes?: number;
|
|
3296
|
+
colormap?: ColormapName;
|
|
3297
|
+
/** Shade by row-normalized recall instead of raw counts. Default false. */
|
|
3298
|
+
normalize?: boolean;
|
|
3299
|
+
/** Draw the value inside each cell. Default true. */
|
|
3300
|
+
annotate?: boolean;
|
|
3301
|
+
}
|
|
3302
|
+
interface ConfusionMatrixHandle {
|
|
3303
|
+
heatmap: HeatmapLayer;
|
|
3304
|
+
classes: number;
|
|
3305
|
+
}
|
|
3306
|
+
/**
|
|
3307
|
+
* Confusion matrix as a heatmap with the true class 0 at the **top** (sklearn
|
|
3308
|
+
* orientation) and per-cell value labels. Give the {@link Plot} `[0,classes]`
|
|
3309
|
+
* axes; set categorical ticks for class names.
|
|
3310
|
+
*/
|
|
3311
|
+
declare function addConfusionMatrix(plot: Plot, opts: ConfusionMatrixOptions): ConfusionMatrixHandle;
|
|
3312
|
+
interface RocCurveOptions {
|
|
3313
|
+
scores: ArrayLike<number>;
|
|
3314
|
+
labels: ArrayLike<number>;
|
|
3315
|
+
color?: string;
|
|
3316
|
+
/** Shade the area under the curve. Default false. */
|
|
3317
|
+
fill?: boolean;
|
|
3318
|
+
/** Draw the y=x chance diagonal. Default true. */
|
|
3319
|
+
showChance?: boolean;
|
|
3320
|
+
name?: string;
|
|
3321
|
+
}
|
|
3322
|
+
interface RocCurveHandle {
|
|
3323
|
+
line: LineLayer;
|
|
3324
|
+
area?: AreaLayer;
|
|
3325
|
+
auc: number;
|
|
3326
|
+
}
|
|
3327
|
+
/** ROC curve (FPR→TPR) with the chance diagonal and AUC in the series name. */
|
|
3328
|
+
declare function addRocCurve(plot: Plot, opts: RocCurveOptions): RocCurveHandle;
|
|
3329
|
+
interface PrCurveOptions {
|
|
3330
|
+
scores: ArrayLike<number>;
|
|
3331
|
+
labels: ArrayLike<number>;
|
|
3332
|
+
color?: string;
|
|
3333
|
+
fill?: boolean;
|
|
3334
|
+
/** Draw the no-skill baseline at the positive base rate. Default true. */
|
|
3335
|
+
showBaseline?: boolean;
|
|
3336
|
+
name?: string;
|
|
3337
|
+
}
|
|
3338
|
+
interface PrCurveHandle {
|
|
3339
|
+
line: LineLayer;
|
|
3340
|
+
area?: AreaLayer;
|
|
3341
|
+
ap: number;
|
|
3342
|
+
}
|
|
3343
|
+
/** Precision–recall curve with the no-skill baseline and AP in the series name. */
|
|
3344
|
+
declare function addPrCurve(plot: Plot, opts: PrCurveOptions): PrCurveHandle;
|
|
3345
|
+
interface CalibrationOptions {
|
|
3346
|
+
scores: ArrayLike<number>;
|
|
3347
|
+
labels: ArrayLike<number>;
|
|
3348
|
+
bins?: number;
|
|
3349
|
+
color?: string;
|
|
3350
|
+
name?: string;
|
|
3351
|
+
}
|
|
3352
|
+
interface CalibrationHandle {
|
|
3353
|
+
line: LineLayer;
|
|
3354
|
+
points: ScatterLayer;
|
|
3355
|
+
ece: number;
|
|
3356
|
+
}
|
|
3357
|
+
/** Reliability diagram: mean predicted probability vs. observed frequency + the perfect diagonal. */
|
|
3358
|
+
declare function addCalibration(plot: Plot, opts: CalibrationOptions): CalibrationHandle;
|
|
3359
|
+
interface EmbeddingOptions {
|
|
3360
|
+
/** 2-D coordinates (t-SNE/UMAP/PCA output). */
|
|
3361
|
+
x: ArrayLike<number>;
|
|
3362
|
+
y: ArrayLike<number>;
|
|
3363
|
+
/** Categorical class per point → one colored, legend-named series each. */
|
|
3364
|
+
labels?: ArrayLike<number> | string[];
|
|
3365
|
+
/** Names indexed by numeric label. */
|
|
3366
|
+
classNames?: string[];
|
|
3367
|
+
/** Continuous value per point → a single colormap series (ignored if `labels`). */
|
|
3368
|
+
colorBy?: ArrayLike<number>;
|
|
3369
|
+
colormap?: ColormapName;
|
|
3370
|
+
palette?: readonly string[];
|
|
3371
|
+
size?: number;
|
|
3372
|
+
/** Per-point hover text (metadata). */
|
|
3373
|
+
text?: ArrayLike<string>;
|
|
3374
|
+
name?: string;
|
|
3375
|
+
renderType?: RenderType;
|
|
3376
|
+
}
|
|
3377
|
+
interface EmbeddingHandle {
|
|
3378
|
+
layers: ScatterLayer[];
|
|
3379
|
+
}
|
|
3380
|
+
/**
|
|
3381
|
+
* Embedding scatter — one colored series per class when `labels` are given (a
|
|
3382
|
+
* legend-ready projector), a single colormap series for a continuous `colorBy`,
|
|
3383
|
+
* or a plain scatter otherwise. Use `pick: "xy"` on the {@link Plot} for hover.
|
|
3384
|
+
*/
|
|
3385
|
+
declare function addEmbedding(plot: Plot, opts: EmbeddingOptions): EmbeddingHandle;
|
|
3386
|
+
interface DecisionBoundaryOptions {
|
|
3387
|
+
/** Row-major grid of predicted class / probability, row 0 at the bottom. */
|
|
3388
|
+
values: ArrayLike<number>;
|
|
3389
|
+
cols: number;
|
|
3390
|
+
rows: number;
|
|
3391
|
+
extent: {
|
|
3392
|
+
x: Range;
|
|
3393
|
+
y: Range;
|
|
3394
|
+
};
|
|
3395
|
+
colormap?: ColormapName;
|
|
3396
|
+
domain?: Range;
|
|
3397
|
+
/** Training points drawn over the field. */
|
|
3398
|
+
points?: {
|
|
3399
|
+
x: ArrayLike<number>;
|
|
3400
|
+
y: ArrayLike<number>;
|
|
3401
|
+
labels?: ArrayLike<number> | string[];
|
|
3402
|
+
classNames?: string[];
|
|
3403
|
+
palette?: readonly string[];
|
|
3404
|
+
size?: number;
|
|
3405
|
+
};
|
|
3406
|
+
}
|
|
3407
|
+
interface DecisionBoundaryHandle {
|
|
3408
|
+
heatmap: HeatmapLayer;
|
|
3409
|
+
points: ScatterLayer[];
|
|
3410
|
+
}
|
|
3411
|
+
/** A decision-boundary field (heatmap) with the training points scattered on top. */
|
|
3412
|
+
declare function addDecisionBoundary(plot: Plot, opts: DecisionBoundaryOptions): DecisionBoundaryHandle;
|
|
3413
|
+
interface FeatureImportanceOptions {
|
|
3414
|
+
names: string[];
|
|
3415
|
+
values: ArrayLike<number>;
|
|
3416
|
+
color?: string;
|
|
3417
|
+
/** Sort by descending magnitude. Default true. */
|
|
3418
|
+
sort?: boolean;
|
|
3419
|
+
/** Keep only the top-N features. */
|
|
3420
|
+
top?: number;
|
|
3421
|
+
/** Label each bar with its feature name (inside the plot). Default true. */
|
|
3422
|
+
annotate?: boolean;
|
|
3423
|
+
name?: string;
|
|
3424
|
+
renderType?: RenderType;
|
|
3425
|
+
}
|
|
3426
|
+
interface FeatureImportanceHandle {
|
|
3427
|
+
bars: BarLayer;
|
|
3428
|
+
order: number[];
|
|
3429
|
+
}
|
|
3430
|
+
/** Feature importance as sorted horizontal bars (most important on top). */
|
|
3431
|
+
declare function addFeatureImportance(plot: Plot, opts: FeatureImportanceOptions): FeatureImportanceHandle;
|
|
3432
|
+
interface ShapBeeswarmOptions {
|
|
3433
|
+
/** SHAP values per feature: `values[f]` is the row across all samples. */
|
|
3434
|
+
values: number[][];
|
|
3435
|
+
names: string[];
|
|
3436
|
+
/** Feature values (same shape) → point color via a diverging colormap. */
|
|
3437
|
+
featureValues?: number[][];
|
|
3438
|
+
colormap?: ColormapName;
|
|
3439
|
+
size?: number;
|
|
3440
|
+
/** Vertical spread of each feature band, 0..1. Default 0.8. */
|
|
3441
|
+
spread?: number;
|
|
3442
|
+
name?: string;
|
|
3443
|
+
}
|
|
3444
|
+
interface ShapBeeswarmHandle {
|
|
3445
|
+
scatter: ScatterLayer;
|
|
3446
|
+
order: number[];
|
|
3447
|
+
}
|
|
3448
|
+
/**
|
|
3449
|
+
* SHAP beeswarm — features stacked by mean |SHAP| (most important on top), each
|
|
3450
|
+
* a horizontal swarm of per-sample points jittered by density and colored by the
|
|
3451
|
+
* feature's value (low→high). A single scatter for one shared colorbar.
|
|
3452
|
+
*/
|
|
3453
|
+
declare function addShapBeeswarm(plot: Plot, opts: ShapBeeswarmOptions): ShapBeeswarmHandle;
|
|
3454
|
+
interface PartialDependenceOptions {
|
|
3455
|
+
x: ArrayLike<number>;
|
|
3456
|
+
/** Mean prediction over the grid. */
|
|
3457
|
+
pd: ArrayLike<number>;
|
|
3458
|
+
/** Optional per-instance ICE curves, each parallel to `x`. */
|
|
3459
|
+
ice?: number[][];
|
|
3460
|
+
color?: string;
|
|
3461
|
+
iceColor?: string;
|
|
3462
|
+
width?: number;
|
|
3463
|
+
name?: string;
|
|
3464
|
+
renderType?: RenderType;
|
|
3465
|
+
}
|
|
3466
|
+
interface PartialDependenceHandle {
|
|
3467
|
+
pd: LineLayer;
|
|
3468
|
+
ice: LineLayer[];
|
|
3469
|
+
}
|
|
3470
|
+
/** Partial-dependence line with faint ICE curves behind it. */
|
|
3471
|
+
declare function addPartialDependence(plot: Plot, opts: PartialDependenceOptions): PartialDependenceHandle;
|
|
3472
|
+
interface AttentionMapOptions {
|
|
3473
|
+
/** Attention weights, query×key: a flat row-major array or a 2-D array. */
|
|
3474
|
+
weights: ArrayLike<number> | number[][];
|
|
3475
|
+
/** Required with a flat `weights`. */
|
|
3476
|
+
queries?: number;
|
|
3477
|
+
keys?: number;
|
|
3478
|
+
colormap?: ColormapName;
|
|
3479
|
+
/** Draw each weight in its cell (small maps only). Default false. */
|
|
3480
|
+
annotate?: boolean;
|
|
3481
|
+
}
|
|
3482
|
+
interface AttentionMapHandle {
|
|
3483
|
+
heatmap: HeatmapLayer;
|
|
3484
|
+
queries: number;
|
|
3485
|
+
keys: number;
|
|
3486
|
+
}
|
|
3487
|
+
/** Transformer attention as a heatmap with query 0 at the top, key 0 at the left. */
|
|
3488
|
+
declare function addAttentionMap(plot: Plot, opts: AttentionMapOptions): AttentionMapHandle;
|
|
3489
|
+
interface TrainingSeries {
|
|
3490
|
+
name?: string;
|
|
3491
|
+
x?: ArrayLike<number>;
|
|
3492
|
+
y: ArrayLike<number>;
|
|
3493
|
+
color?: string;
|
|
3494
|
+
}
|
|
3495
|
+
interface TrainingCurvesOptions {
|
|
3496
|
+
series: TrainingSeries[];
|
|
3497
|
+
/** EMA smoothing weight 0..1 (0 = raw). Default 0.6. */
|
|
3498
|
+
smoothing?: number;
|
|
3499
|
+
/** Draw the faint raw curve behind the smoothed one. Default true. */
|
|
3500
|
+
showRaw?: boolean;
|
|
3501
|
+
/** Mark the best epoch of each series. */
|
|
3502
|
+
best?: "min" | "max";
|
|
3503
|
+
width?: number;
|
|
3504
|
+
palette?: readonly string[];
|
|
3505
|
+
renderType?: RenderType;
|
|
3506
|
+
}
|
|
3507
|
+
interface TrainingCurvesHandle {
|
|
3508
|
+
raw: LineLayer[];
|
|
3509
|
+
smoothed: LineLayer[];
|
|
3510
|
+
}
|
|
3511
|
+
/**
|
|
3512
|
+
* Training curves with TensorBoard-style EMA smoothing — a faint raw line under
|
|
3513
|
+
* a bold smoothed one per series, each streamable via `setData`. Optionally
|
|
3514
|
+
* marks the best epoch. Pair with `renderType: "dynamic"` for live updates.
|
|
3515
|
+
*/
|
|
3516
|
+
declare function addTrainingCurves(plot: Plot, opts: TrainingCurvesOptions): TrainingCurvesHandle;
|
|
3517
|
+
interface RidgeGroup {
|
|
3518
|
+
label?: string;
|
|
3519
|
+
values: ArrayLike<number>;
|
|
3520
|
+
}
|
|
3521
|
+
interface RidgelineOptions {
|
|
3522
|
+
/** One distribution per group (e.g. a layer's weights per epoch). */
|
|
3523
|
+
groups: RidgeGroup[];
|
|
3524
|
+
/** KDE sample count. Default 96. */
|
|
3525
|
+
points?: number;
|
|
3526
|
+
/** Ridge overlap, 0 = touching, 1 = one full row of overlap. Default 1. */
|
|
3527
|
+
overlap?: number;
|
|
3528
|
+
palette?: readonly string[];
|
|
3529
|
+
/** Fill each ridge. Default true. */
|
|
3530
|
+
fill?: boolean;
|
|
3531
|
+
/** Shared x-range; inferred from the data when omitted. */
|
|
3532
|
+
range?: Range;
|
|
3533
|
+
}
|
|
3534
|
+
interface RidgelineHandle {
|
|
3535
|
+
areas: AreaLayer[];
|
|
3536
|
+
lines: LineLayer[];
|
|
3537
|
+
}
|
|
3538
|
+
/**
|
|
3539
|
+
* Ridgeline / joyplot — one KDE per group, vertically offset (TensorBoard's
|
|
3540
|
+
* "distributions over time"). Ridge `i` is baselined at `y=i`; `overlap` lets
|
|
3541
|
+
* neighbours interleave. Feed per-epoch weight/activation samples.
|
|
3542
|
+
*/
|
|
3543
|
+
declare function addRidgeline(plot: Plot, opts: RidgelineOptions): RidgelineHandle;
|
|
3544
|
+
interface BeeswarmOptions {
|
|
3545
|
+
bins?: number;
|
|
3546
|
+
spread?: number;
|
|
3547
|
+
}
|
|
3548
|
+
/**
|
|
3549
|
+
* Deterministic 1-D beeswarm: given point x-positions, return a symmetric
|
|
3550
|
+
* vertical offset per point (in ±spread/2) so overlapping points fan out by
|
|
3551
|
+
* local density. Pure — no RNG. Backs {@link addShapBeeswarm}.
|
|
3552
|
+
*/
|
|
3553
|
+
declare function beeswarmLayout(x: ArrayLike<number>, opts?: BeeswarmOptions): number[];
|
|
3554
|
+
|
|
3555
|
+
/**
|
|
3556
|
+
* Squarified treemap — a pure layout plus a {@link Plot} builder that composes
|
|
3557
|
+
* the existing {@link PatchesLayer} (one rect patch per item) and a centered
|
|
3558
|
+
* label annotation per cell. Import from `@photonviz/core`.
|
|
3559
|
+
*/
|
|
3560
|
+
|
|
3561
|
+
/** A weighted item to lay into the treemap. */
|
|
3562
|
+
interface TreemapItem {
|
|
3563
|
+
label: string;
|
|
3564
|
+
value: number;
|
|
3565
|
+
/** Explicit fill; otherwise a palette color is cycled by index. */
|
|
3566
|
+
color?: string;
|
|
3567
|
+
}
|
|
3568
|
+
/** A laid-out cell: the input item plus its axis-aligned rect `[x0,y0]`–`[x1,y1]`. */
|
|
3569
|
+
interface TreemapCell {
|
|
3570
|
+
label: string;
|
|
3571
|
+
value: number;
|
|
3572
|
+
color?: string;
|
|
3573
|
+
x0: number;
|
|
3574
|
+
y0: number;
|
|
3575
|
+
x1: number;
|
|
3576
|
+
y1: number;
|
|
3577
|
+
}
|
|
3578
|
+
/** The rectangle the layout fills. */
|
|
3579
|
+
interface TreemapExtent {
|
|
3580
|
+
x: [number, number];
|
|
3581
|
+
y: [number, number];
|
|
3582
|
+
}
|
|
3583
|
+
/** tab10-ish default palette, cycled by index for items without a color. */
|
|
3584
|
+
declare const TREEMAP_PALETTE: readonly string[];
|
|
3585
|
+
/**
|
|
3586
|
+
* Squarified treemap layout: sizes rects ∝ `value`, packing them into `extent`
|
|
3587
|
+
* with aspect ratios kept near 1. Pure — no side effects. Zero/negative values
|
|
3588
|
+
* and empty input yield no cells.
|
|
3589
|
+
*/
|
|
3590
|
+
declare function treemapLayout(items: readonly TreemapItem[], extent?: TreemapExtent): TreemapCell[];
|
|
3591
|
+
interface TreemapOptions {
|
|
3592
|
+
items: TreemapItem[];
|
|
3593
|
+
extent?: TreemapExtent;
|
|
3594
|
+
/** Palette cycled by index for items lacking a `color`. Defaults to {@link TREEMAP_PALETTE}. */
|
|
3595
|
+
colors?: string[];
|
|
3596
|
+
opacity?: number;
|
|
3597
|
+
name?: string;
|
|
3598
|
+
renderType?: RenderType;
|
|
3599
|
+
/** Draw a centered label per cell (tiny cells are skipped). Default true. */
|
|
3600
|
+
labels?: boolean;
|
|
3601
|
+
}
|
|
3602
|
+
/**
|
|
3603
|
+
* Add a squarified treemap: one filled rect {@link Patch} per item plus centered
|
|
3604
|
+
* labels. Composes {@link Plot.addPatches} — low-risk, no new layer type.
|
|
3605
|
+
*/
|
|
3606
|
+
declare function addTreemap(plot: Plot, opts: TreemapOptions): PatchesLayer;
|
|
3607
|
+
|
|
3608
|
+
/**
|
|
3609
|
+
* Funnel chart — a pure layout plus a {@link Plot} builder that composes the
|
|
3610
|
+
* existing {@link PatchesLayer} (one centered trapezoid per stage) with a
|
|
3611
|
+
* centered label per stage. Import from `@photonviz/core`.
|
|
3612
|
+
*/
|
|
3613
|
+
|
|
3614
|
+
/** One funnel stage: a labeled weighted value. */
|
|
3615
|
+
interface FunnelItem {
|
|
3616
|
+
label: string;
|
|
3617
|
+
value: number;
|
|
3618
|
+
/** Explicit fill; otherwise a palette color is cycled by index. */
|
|
3619
|
+
color?: string;
|
|
3620
|
+
}
|
|
3621
|
+
/** A laid-out stage: the input item plus its trapezoid polygon ring. */
|
|
3622
|
+
interface FunnelStage {
|
|
3623
|
+
label: string;
|
|
3624
|
+
value: number;
|
|
3625
|
+
color?: string;
|
|
3626
|
+
/** Closed polygon ring (4 corners) in data space. */
|
|
3627
|
+
poly: {
|
|
3628
|
+
x: number[];
|
|
3629
|
+
y: number[];
|
|
3630
|
+
};
|
|
3631
|
+
}
|
|
3632
|
+
interface FunnelLayoutOptions {
|
|
3633
|
+
/** Full plot width the largest stage spans. Default 1 (extent `[-0.5, 0.5]`). */
|
|
3634
|
+
width?: number;
|
|
3635
|
+
/** Total stack height. Default 1 (extent `[0, 1]`, top stage first). */
|
|
3636
|
+
height?: number;
|
|
3637
|
+
/** Bottom width of the last stage as a fraction of its value width. Default 0.4. */
|
|
3638
|
+
neck?: number;
|
|
3639
|
+
}
|
|
3640
|
+
/** tab10-ish default palette, cycled by index for stages without a color. */
|
|
3641
|
+
declare const FUNNEL_PALETTE: readonly string[];
|
|
3642
|
+
/**
|
|
3643
|
+
* Funnel layout: centered trapezoids stacked top-to-bottom, each stage's top
|
|
3644
|
+
* width ∝ its value and bottom width ∝ the next value (the last stage tapers to
|
|
3645
|
+
* a `neck` fraction of its own width). Pure — no side effects.
|
|
3646
|
+
*/
|
|
3647
|
+
declare function funnelLayout(items: readonly FunnelItem[], opts?: FunnelLayoutOptions): FunnelStage[];
|
|
3648
|
+
interface FunnelOptions {
|
|
3649
|
+
items: FunnelItem[];
|
|
3650
|
+
width?: number;
|
|
3651
|
+
height?: number;
|
|
3652
|
+
neck?: number;
|
|
3653
|
+
/** Palette cycled by index for stages lacking a `color`. Defaults to {@link FUNNEL_PALETTE}. */
|
|
3654
|
+
colors?: string[];
|
|
3655
|
+
opacity?: number;
|
|
3656
|
+
name?: string;
|
|
3657
|
+
renderType?: RenderType;
|
|
3658
|
+
/** Draw a centered label per stage. Default true. */
|
|
3659
|
+
labels?: boolean;
|
|
3660
|
+
}
|
|
3661
|
+
/**
|
|
3662
|
+
* Add a funnel chart: one filled trapezoid {@link Patch} per stage plus centered
|
|
3663
|
+
* labels. Composes {@link Plot.addPatches} — low-risk, no new layer type.
|
|
3664
|
+
*/
|
|
3665
|
+
declare function addFunnel(plot: Plot, opts: FunnelOptions): PatchesLayer;
|
|
3666
|
+
|
|
3667
|
+
/**
|
|
3668
|
+
* Sunburst (radial icicle) builder. Renders a hierarchy as concentric annular
|
|
3669
|
+
* sectors — one ring per depth, angular span ∝ summed leaf value — by
|
|
3670
|
+
* tessellating each sector into a polygon {@link Patch} ring. Pure
|
|
3671
|
+
* {@link sunburstLayout} does the math; {@link addSunburst} composes the
|
|
3672
|
+
* existing {@link PatchesLayer}. Import from `@photonviz/core`.
|
|
3673
|
+
*/
|
|
3674
|
+
|
|
3675
|
+
/** A node in the input hierarchy; `value` counts only for leaves. */
|
|
3676
|
+
interface SunburstNode {
|
|
3677
|
+
name: string;
|
|
3678
|
+
value?: number;
|
|
3679
|
+
color?: string;
|
|
3680
|
+
children?: SunburstNode[];
|
|
3681
|
+
}
|
|
3682
|
+
/** Tunables for {@link sunburstLayout}. */
|
|
3683
|
+
interface SunburstLayoutOptions {
|
|
3684
|
+
/** Radial thickness of each depth ring, in data units. Default 1. */
|
|
3685
|
+
ringWidth?: number;
|
|
3686
|
+
/** Inner radius of the depth-0 ring (hole at the center). Default 0. */
|
|
3687
|
+
center?: number;
|
|
3688
|
+
/** Angle of the first sector edge, radians. Default `Math.PI / 2` (12 o'clock). */
|
|
3689
|
+
startAngle?: number;
|
|
3690
|
+
}
|
|
3691
|
+
/** One laid-out sector: angular range `[a0,a1]` (radians) and radial ring `[r0,r1]`. */
|
|
3692
|
+
interface SunburstArc {
|
|
3693
|
+
name: string;
|
|
3694
|
+
depth: number;
|
|
3695
|
+
a0: number;
|
|
3696
|
+
a1: number;
|
|
3697
|
+
r0: number;
|
|
3698
|
+
r1: number;
|
|
3699
|
+
color?: string;
|
|
3700
|
+
}
|
|
3701
|
+
/**
|
|
3702
|
+
* Lay a hierarchy out into flat annular sectors. Angular span is proportional to
|
|
3703
|
+
* summed leaf value; each depth occupies its own radius ring. Side-effect-free.
|
|
3704
|
+
*/
|
|
3705
|
+
declare function sunburstLayout(root: SunburstNode, opts?: SunburstLayoutOptions): SunburstArc[];
|
|
3706
|
+
/** Options for {@link addSunburst}. */
|
|
3707
|
+
interface SunburstOptions {
|
|
3708
|
+
root: SunburstNode;
|
|
3709
|
+
/** Radial thickness of each depth ring, in data units. Default 1. */
|
|
3710
|
+
ringWidth?: number;
|
|
3711
|
+
/** Explicit palette, cycled by node index. Falls back to a built-in palette. */
|
|
3712
|
+
colors?: string[];
|
|
3713
|
+
/** Fill opacity, 0..1. Default 1. */
|
|
3714
|
+
opacity?: number;
|
|
3715
|
+
name?: string;
|
|
3716
|
+
/** Buffer-usage hint; set `"dynamic"` when streaming. Default `"static"`. */
|
|
3717
|
+
renderType?: RenderType;
|
|
3718
|
+
}
|
|
3719
|
+
/**
|
|
3720
|
+
* Build a sunburst from a hierarchy and add it as a {@link PatchesLayer} centered
|
|
3721
|
+
* at (0,0). Set the plot's `equalAspect: true` so the rings stay circular.
|
|
3722
|
+
*/
|
|
3723
|
+
declare function addSunburst(plot: Plot, opts: SunburstOptions): PatchesLayer;
|
|
3724
|
+
|
|
3725
|
+
/**
|
|
3726
|
+
* Radial gauge builder. Draws a background track arc, a colored value arc over
|
|
3727
|
+
* `[min,max]` mapped to an angular sweep (default 220°, 200°→-20°), and a needle.
|
|
3728
|
+
* Pure {@link gaugeLayout} produces tessellated polygons; {@link addGauge}
|
|
3729
|
+
* composes the existing {@link PatchesLayer}. Import from `@photonviz/core`.
|
|
3730
|
+
*/
|
|
3731
|
+
|
|
3732
|
+
/** An annular-sector polygon, tessellated into a single ring. */
|
|
3733
|
+
interface Ring {
|
|
3734
|
+
x: number[];
|
|
3735
|
+
y: number[];
|
|
3736
|
+
}
|
|
3737
|
+
/** A `{value, color}` band; the arc takes the color of the highest one `value` reaches. */
|
|
3738
|
+
interface GaugeThreshold {
|
|
3739
|
+
value: number;
|
|
3740
|
+
color: string;
|
|
3741
|
+
}
|
|
3742
|
+
/** Tunables for {@link gaugeLayout}. */
|
|
3743
|
+
interface GaugeLayoutOptions {
|
|
3744
|
+
value: number;
|
|
3745
|
+
/** Value at the start of the sweep. Default 0. */
|
|
3746
|
+
min?: number;
|
|
3747
|
+
/** Value at the end of the sweep. Default 100. */
|
|
3748
|
+
max?: number;
|
|
3749
|
+
/** Angle of the sweep start, degrees. Default 200. */
|
|
3750
|
+
startAngle?: number;
|
|
3751
|
+
/** Angle of the sweep end, degrees. Default -20. */
|
|
3752
|
+
endAngle?: number;
|
|
3753
|
+
/** Outer radius, data units. Default 1. */
|
|
3754
|
+
radius?: number;
|
|
3755
|
+
/** Inner (track) radius, data units. Default 0.7. */
|
|
3756
|
+
innerRadius?: number;
|
|
3757
|
+
}
|
|
3758
|
+
/**
|
|
3759
|
+
* Compute the gauge geometry: a full background sector, a value sector clamped to
|
|
3760
|
+
* `[min,max]`, and a thin needle triangle from the center to the value angle.
|
|
3761
|
+
* Angles sweep from `startAngle` to `endAngle` (degrees). Side-effect-free.
|
|
3762
|
+
*/
|
|
3763
|
+
declare function gaugeLayout(opts: GaugeLayoutOptions): {
|
|
3764
|
+
bg: Ring;
|
|
3765
|
+
value: Ring;
|
|
3766
|
+
needle: {
|
|
3767
|
+
x: number[];
|
|
3768
|
+
y: number[];
|
|
3769
|
+
};
|
|
3770
|
+
};
|
|
3771
|
+
/** Options for {@link addGauge}. */
|
|
3772
|
+
interface GaugeOptions {
|
|
3773
|
+
value: number;
|
|
3774
|
+
/** Value at the start of the sweep. Default 0. */
|
|
3775
|
+
min?: number;
|
|
3776
|
+
/** Value at the end of the sweep. Default 100. */
|
|
3777
|
+
max?: number;
|
|
3778
|
+
/** `{value,color}` bands; the value arc takes the color of the highest one reached. */
|
|
3779
|
+
thresholds?: GaugeThreshold[];
|
|
3780
|
+
/** Value-arc color when no thresholds apply. Default blue. */
|
|
3781
|
+
color?: string;
|
|
3782
|
+
/** Background-track color. Default a muted gray. */
|
|
3783
|
+
trackColor?: string;
|
|
3784
|
+
/** Angle of the sweep start, degrees. Default 200. */
|
|
3785
|
+
startAngle?: number;
|
|
3786
|
+
/** Angle of the sweep end, degrees. Default -20. */
|
|
3787
|
+
endAngle?: number;
|
|
3788
|
+
/** Needle color. Default a dark slate. */
|
|
3789
|
+
needleColor?: string;
|
|
3790
|
+
/** Center label text; defaults to the numeric value. Pass `false` to omit. */
|
|
3791
|
+
label?: string | false;
|
|
3792
|
+
name?: string;
|
|
3793
|
+
/** Buffer-usage hint; set `"dynamic"` when streaming. Default `"static"`. */
|
|
3794
|
+
renderType?: RenderType;
|
|
3795
|
+
}
|
|
3796
|
+
/**
|
|
3797
|
+
* Build a radial gauge (track + value arc + needle) and add it as a
|
|
3798
|
+
* {@link PatchesLayer} centered at (0,0), with an optional center label.
|
|
3799
|
+
* Set the plot's `equalAspect: true` so it stays circular.
|
|
3800
|
+
*/
|
|
3801
|
+
declare function addGauge(plot: Plot, opts: GaugeOptions): PatchesLayer;
|
|
3802
|
+
|
|
3803
|
+
/** A node: a display `name` and an optional explicit fill `color`. */
|
|
3804
|
+
interface SankeyNode {
|
|
3805
|
+
name: string;
|
|
3806
|
+
color?: string;
|
|
3807
|
+
}
|
|
3808
|
+
/** A flow from node index `source` to node index `target` carrying `value`. */
|
|
3809
|
+
interface SankeyLink {
|
|
3810
|
+
source: number;
|
|
3811
|
+
target: number;
|
|
3812
|
+
value: number;
|
|
3813
|
+
}
|
|
3814
|
+
/** Tuning for the pure {@link sankeyLayout}. All in normalized-extent units. */
|
|
3815
|
+
interface SankeyLayoutOptions {
|
|
3816
|
+
/** Drawing box. Defaults to x `[0,1]`, y `[0,1]`. */
|
|
3817
|
+
extent?: {
|
|
3818
|
+
x?: Range;
|
|
3819
|
+
y?: Range;
|
|
3820
|
+
};
|
|
3821
|
+
/** Node rectangle width along x. Default 0.02. */
|
|
3822
|
+
nodeWidth?: number;
|
|
3823
|
+
/** Vertical gap between stacked nodes, as a fraction of the y extent. Default 0.02. */
|
|
3824
|
+
nodePadding?: number;
|
|
3825
|
+
}
|
|
3826
|
+
/** One laid-out node rectangle, keyed by node index `i`. */
|
|
3827
|
+
interface SankeyNodeRect {
|
|
3828
|
+
i: number;
|
|
3829
|
+
x0: number;
|
|
3830
|
+
y0: number;
|
|
3831
|
+
x1: number;
|
|
3832
|
+
y1: number;
|
|
3833
|
+
}
|
|
3834
|
+
/** One laid-out ribbon polygon (closed ring), keyed by link index. */
|
|
3835
|
+
interface SankeyRibbon {
|
|
3836
|
+
link: number;
|
|
3837
|
+
x: number[];
|
|
3838
|
+
y: number[];
|
|
3839
|
+
}
|
|
3840
|
+
/** Result of {@link sankeyLayout}: node rectangles and link ribbons. */
|
|
3841
|
+
interface SankeyLayoutResult {
|
|
3842
|
+
nodeRects: SankeyNodeRect[];
|
|
3843
|
+
ribbons: SankeyRibbon[];
|
|
3844
|
+
}
|
|
3845
|
+
/**
|
|
3846
|
+
* Pure, side-effect-free Sankey layout. Assigns each node a layer by longest
|
|
3847
|
+
* path from the sources, stacks nodes vertically by throughput, and traces each
|
|
3848
|
+
* link as a bezier ribbon between its source and target edges.
|
|
3849
|
+
*/
|
|
3850
|
+
declare function sankeyLayout(nodes: SankeyNode[], links: SankeyLink[], opts?: SankeyLayoutOptions): SankeyLayoutResult;
|
|
3851
|
+
/** Options for {@link addSankey}. */
|
|
3852
|
+
interface SankeyOptions {
|
|
3853
|
+
nodes: SankeyNode[];
|
|
3854
|
+
links: SankeyLink[];
|
|
3855
|
+
/** Drawing box in data space. Defaults to x `[0,1]`, y `[0,1]`. */
|
|
3856
|
+
extent?: {
|
|
3857
|
+
x?: Range;
|
|
3858
|
+
y?: Range;
|
|
3859
|
+
};
|
|
3860
|
+
nodeWidth?: number;
|
|
3861
|
+
nodePadding?: number;
|
|
3862
|
+
/** Per-node colors (by index); overridden by a node's own `color`. */
|
|
3863
|
+
colors?: string[];
|
|
3864
|
+
/** Layer fill opacity (0..1), forwarded to the patches layer. Default 1. */
|
|
3865
|
+
opacity?: number;
|
|
3866
|
+
name?: string;
|
|
3867
|
+
renderType?: RenderType;
|
|
3868
|
+
/** Draw node name labels. Default true. */
|
|
3869
|
+
labels?: boolean;
|
|
3870
|
+
}
|
|
3871
|
+
/**
|
|
3872
|
+
* Build a Sankey diagram on `plot`: one node rectangle {@link Patch} per node
|
|
3873
|
+
* plus one semi-transparent ribbon patch per link (colored from its source
|
|
3874
|
+
* node), added as a single {@link PatchesLayer}. Node name labels are added as
|
|
3875
|
+
* plot annotations unless `labels` is false.
|
|
3876
|
+
*/
|
|
3877
|
+
declare function addSankey(plot: Plot, opts: SankeyOptions): PatchesLayer;
|
|
3878
|
+
|
|
3879
|
+
/**
|
|
3880
|
+
* Chord diagram — a pure circular layout plus a {@link Plot} builder that composes
|
|
3881
|
+
* the existing {@link PatchesLayer}: thin annular sectors for the group arcs and
|
|
3882
|
+
* bezier-bounded ribbons for the flows between groups, with labels outside each
|
|
3883
|
+
* arc. Import from `@photonviz/core`. Use `equalAspect: true` so it stays circular.
|
|
3884
|
+
*/
|
|
3885
|
+
|
|
3886
|
+
/** tab10-ish default palette, cycled by group index. */
|
|
3887
|
+
declare const CHORD_PALETTE: readonly string[];
|
|
3888
|
+
/** A laid-out group arc as a closed ring of `x`/`y` (thin annular sector). */
|
|
3889
|
+
interface ChordGroupArc {
|
|
3890
|
+
i: number;
|
|
3891
|
+
x: number[];
|
|
3892
|
+
y: number[];
|
|
3893
|
+
}
|
|
3894
|
+
/** A laid-out ribbon between groups `i` and `j` as a closed ring of `x`/`y`. */
|
|
3895
|
+
interface ChordRibbon {
|
|
3896
|
+
i: number;
|
|
3897
|
+
j: number;
|
|
3898
|
+
x: number[];
|
|
3899
|
+
y: number[];
|
|
3900
|
+
}
|
|
3901
|
+
/** The result of {@link chordLayout}: outer group arcs plus inter-group ribbons. */
|
|
3902
|
+
interface ChordLayoutResult {
|
|
3903
|
+
groupArcs: ChordGroupArc[];
|
|
3904
|
+
ribbons: ChordRibbon[];
|
|
3905
|
+
}
|
|
3906
|
+
/** Tunable geometry for {@link chordLayout}. */
|
|
3907
|
+
interface ChordLayoutOptions {
|
|
3908
|
+
/** Outer radius of the group arcs. Default 1. */
|
|
3909
|
+
radius?: number;
|
|
3910
|
+
/** Total angular gap (radians) split evenly between groups. Default 0.1·2π. */
|
|
3911
|
+
padAngle?: number;
|
|
3912
|
+
/** Thickness of the outer arc as a fraction of `radius`. Default 0.06. */
|
|
3913
|
+
arcWidth?: number;
|
|
3914
|
+
/** Points sampled along each connecting bezier edge of a ribbon. Default 24. */
|
|
3915
|
+
samples?: number;
|
|
3916
|
+
}
|
|
3917
|
+
/**
|
|
3918
|
+
* Chord layout: groups sit around a circle with angular span ∝ their row-sum
|
|
3919
|
+
* (standard chord convention), separated by `padAngle`. Each group's arc is
|
|
3920
|
+
* sub-divided per target `j`; a ribbon between `i` and `j` is bounded by the two
|
|
3921
|
+
* matching sub-arcs and closed by quadratic beziers curving through the center.
|
|
3922
|
+
* Pure — no side effects. Empty/zero-flow input yields empty arrays.
|
|
3923
|
+
*/
|
|
3924
|
+
declare function chordLayout(matrix: number[][], opts?: ChordLayoutOptions): ChordLayoutResult;
|
|
3925
|
+
interface ChordOptions {
|
|
3926
|
+
/** Square flow matrix; `matrix[i][j]` is the flow from group `i` to group `j`. */
|
|
3927
|
+
matrix: number[][];
|
|
3928
|
+
/** Optional group labels, placed just outside each arc. */
|
|
3929
|
+
labels?: string[];
|
|
3930
|
+
/** Outer radius. Default 1. */
|
|
3931
|
+
radius?: number;
|
|
3932
|
+
/** Palette cycled by group index. Defaults to {@link CHORD_PALETTE}. */
|
|
3933
|
+
colors?: string[];
|
|
3934
|
+
/** Ribbon fill opacity, 0..1. Default 0.65. */
|
|
3935
|
+
opacity?: number;
|
|
3936
|
+
name?: string;
|
|
3937
|
+
renderType?: RenderType;
|
|
3938
|
+
}
|
|
3939
|
+
/**
|
|
3940
|
+
* Add a chord diagram: opaque per-group outer arcs plus semi-transparent ribbons
|
|
3941
|
+
* (colored by their source group) as {@link Patch}es, with labels outside each
|
|
3942
|
+
* arc. Composes {@link Plot.addPatches} — set `equalAspect: true` on the plot.
|
|
3943
|
+
*/
|
|
3944
|
+
declare function addChord(plot: Plot, opts: ChordOptions): PatchesLayer;
|
|
3945
|
+
|
|
3946
|
+
/**
|
|
3947
|
+
* Parallel coordinates — a pure per-dimension normalization plus a {@link Plot}
|
|
3948
|
+
* builder that composes existing {@link LineLayer}s: one polyline per row crossing
|
|
3949
|
+
* N vertical axes, each axis drawn as a `span` guide with a name label on top.
|
|
3950
|
+
* Import from `@photonviz/core`.
|
|
3951
|
+
*/
|
|
3952
|
+
|
|
3953
|
+
/** tab10-ish default palette, cycled by row index (or by `colorBy` band). */
|
|
3954
|
+
declare const PARALLEL_PALETTE: readonly string[];
|
|
3955
|
+
/** A laid-out axis: its dimension name, x position, and observed value range. */
|
|
3956
|
+
interface ParallelAxis {
|
|
3957
|
+
dim: string;
|
|
3958
|
+
x: number;
|
|
3959
|
+
min: number;
|
|
3960
|
+
max: number;
|
|
3961
|
+
}
|
|
3962
|
+
/** A laid-out row as a polyline of N points (one per dimension). */
|
|
3963
|
+
interface ParallelLine {
|
|
3964
|
+
row: number;
|
|
3965
|
+
x: number[];
|
|
3966
|
+
y: number[];
|
|
3967
|
+
}
|
|
3968
|
+
/** The result of {@link parallelLayout}: axis metadata plus per-row polylines. */
|
|
3969
|
+
interface ParallelLayoutResult {
|
|
3970
|
+
axes: ParallelAxis[];
|
|
3971
|
+
lines: ParallelLine[];
|
|
3972
|
+
}
|
|
3973
|
+
/**
|
|
3974
|
+
* Parallel-coordinates layout: axis `i` sits at `x = i`; each dimension's values
|
|
3975
|
+
* are normalized to `y ∈ [0,1]` by its own min/max (a flat dimension maps to 0.5).
|
|
3976
|
+
* Each row becomes an N-point polyline. Pure — no side effects. Non-finite values
|
|
3977
|
+
* fall back to the axis midpoint.
|
|
3978
|
+
*/
|
|
3979
|
+
declare function parallelLayout(dimensions: string[], rows: number[][]): ParallelLayoutResult;
|
|
3980
|
+
interface ParallelOptions {
|
|
3981
|
+
/** One name per axis, left to right. */
|
|
3982
|
+
dimensions: string[];
|
|
3983
|
+
/** Data rows, each parallel to `dimensions`. */
|
|
3984
|
+
rows: number[][];
|
|
3985
|
+
/** Optional per-row value mapped through a palette ramp for coloring. */
|
|
3986
|
+
colorBy?: number[];
|
|
3987
|
+
/** Palette cycled by row index (or banded by `colorBy`). Defaults to {@link PARALLEL_PALETTE}. */
|
|
3988
|
+
colors?: string[];
|
|
3989
|
+
/** Polyline width in px. Default 1. */
|
|
3990
|
+
width?: number;
|
|
3991
|
+
/** Line opacity, 0..1. Default 0.7. */
|
|
3992
|
+
opacity?: number;
|
|
3993
|
+
name?: string;
|
|
3994
|
+
renderType?: RenderType;
|
|
3995
|
+
}
|
|
3996
|
+
/** The layers created by {@link addParallelCoordinates}: one {@link LineLayer} per row. */
|
|
3997
|
+
interface ParallelHandle {
|
|
3998
|
+
lines: LineLayer[];
|
|
3999
|
+
}
|
|
4000
|
+
/**
|
|
4001
|
+
* Add a parallel-coordinates plot: each row as a {@link Plot.addLine} polyline
|
|
4002
|
+
* (colored via `colorBy` ramp or a cycled palette), each axis as a vertical
|
|
4003
|
+
* `span` guide, plus a dimension-name label at the top of every axis.
|
|
4004
|
+
*/
|
|
4005
|
+
declare function addParallelCoordinates(plot: Plot, opts: ParallelOptions): ParallelHandle;
|
|
4006
|
+
|
|
2932
4007
|
/** Parse a CSS hex/rgb color string into normalized RGBA (0..1). */
|
|
2933
4008
|
declare function parseColor(input: string): [number, number, number, number];
|
|
2934
4009
|
/** Normalized RGBA (0..1) back to a CSS `rgba(...)` string. */
|
|
2935
4010
|
declare function toColorCss(c: readonly [number, number, number, number]): string;
|
|
2936
4011
|
|
|
2937
|
-
export { type Annotation, AreaLayer, type AreaOptions, type AreaSeries, Axis, type AxisConfig, type AxisFrame, type AxisScaleOptions, Bar3DLayer, type Bar3DOptions, BarLayer, type BarOptions, type BarSeries, type BollingerBands, type BollingerHandle, type BollingerOptions, type Bounds, type Bounds3, type BoxGroup, BoxLayer, type BoxOptions, type BoxStats, type Brick, type Candle, type CandlestickData, CandlestickLayer, type CandlestickOptions, CategoricalScale, type Color, type ColorInfo, type ColormapName, Contour3DLayer, type Contour3DOptions, ContourLayer, type ContourOptions, type Density, type DepthCurves, type DepthHandle, type DepthOptions, type Dim, type DrawState, ErrorBarLayer, type ErrorBarOptions, type ForceLayoutOptions, type GraphInput, GraphLayer, type GraphOptions, type GroupedBarOptions, HeatmapLayer, type HeatmapOptions, type HeikinAshiOptions, HexbinLayer, type HexbinOptions, type Histogram, type HoverReadoutRow, 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, type Macd, type MarkerShape, type Ohlc, type OhlcArrays, type OhlcInput, OhlcLayer, type OhlcOptions, OrdinalTimeScale, type Patch, PatchesLayer, type PatchesOptions, 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, Quiver3DLayer, type Quiver3DOptions, QuiverLayer, type QuiverOptions, type RGB, type Range, type RenderType, type RenkoOptions, type ResolvedAxisStyle, type Scale, type ScaleType, ScatterLayer, type ScatterOptions, type Spectrogram, type StackedAreaOptions, type StackedBarOptions, StemLayer, type StemOptions, SurfaceLayer, type SurfaceOptions, TRANSFORM_GLSL, TRANSFORM_UNIFORMS, type Theme, type Tick, type TicksSpec, TimeScale, type ToolbarHost, type ToolbarTheme, VolumeLayer, type VolumeOptions, type VolumeProfile, type VolumeProfileOptions, type YAxisOptions, addBollinger, addDepth, addHeikinAshi, addRenko, addVolumeProfile, atr, autoTicks, bollinger, boxStats, bufferUsage, colormap, colormapLUT, createProgram, createToolbar, darkTheme, defaultFormat, depth, earcut, ema, fft, firstFinite, forceLayout, heikinAshi, histogram, kde, lightTheme, lineBreak, linkX, macd, makeScale, marchingCubes, parseColor, pointAndFigure, quantileSorted, renko, resolveAxisStyle, resolveTicks, rollingStd, rsi, setTransformUniforms, sma, spectrogram, toColorCss, trueRange, uniformLocations, volumeProfile, vwap, withMinorTicks, wma };
|
|
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 };
|