@kymoscope/sdk 0.0.0-stage → 0.1.1
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/LICENSE.md +69 -0
- package/README.md +138 -2
- package/dist/assets/duckdb-browser-eh.worker--3HUwN9R.js +14 -0
- package/dist/assets/duckdb-eh-D-nnNw7L.wasm.gz +0 -0
- package/dist/assets/h5wasmModule-BCQWU2Gw.js +24295 -0
- package/dist/assets/importer.worker-D4is7BLf.js +6 -0
- package/dist/assets/offscreenLineWorker-mShhnyXX.js +79 -0
- package/dist/assets/parseDataset.worker-PynRsPD8.js +5 -0
- package/dist/importers-DivmF3tx.js +5 -0
- package/dist/krc-CbE28CjD.js +9 -0
- package/dist/kymoscope-embed.js +633 -0
- package/dist/kymoscope-sdk.js +616 -0
- package/dist/react.js +2 -0
- package/dist/styles/charts.css +207 -0
- package/dist/styles/fonts/OFL.txt +93 -0
- package/dist/styles/fonts/plus-jakarta-sans-italic-latin-ext.woff2 +0 -0
- package/dist/styles/fonts/plus-jakarta-sans-italic-latin.woff2 +0 -0
- package/dist/styles/fonts/plus-jakarta-sans-latin-ext.woff2 +0 -0
- package/dist/styles/fonts/plus-jakarta-sans-latin.woff2 +0 -0
- package/dist/styles/tokens.css +218 -0
- package/dist/types/charts/AlarmOverlay.d.ts +11 -0
- package/dist/types/charts/AnnotationLayer.d.ts +29 -0
- package/dist/types/charts/ChartBody.d.ts +52 -0
- package/dist/types/charts/PerfHud.d.ts +20 -0
- package/dist/types/charts/beacon.d.ts +27 -0
- package/dist/types/charts/chartWindow.d.ts +31 -0
- package/dist/types/charts/liveOverlay.d.ts +16 -0
- package/dist/types/charts/runtime.d.ts +63 -0
- package/dist/types/charts/useWorksheetData.d.ts +159 -0
- package/dist/types/components/AreaChart.d.ts +21 -0
- package/dist/types/components/BarChart.d.ts +30 -0
- package/dist/types/components/BoxPlotChart.d.ts +16 -0
- package/dist/types/components/BubbleChart.d.ts +24 -0
- package/dist/types/components/CalibrationChart.d.ts +15 -0
- package/dist/types/components/CdfChart.d.ts +15 -0
- package/dist/types/components/ConfusionChart.d.ts +11 -0
- package/dist/types/components/ControlChart.d.ts +17 -0
- package/dist/types/components/DuckDbMultiBandPanel.d.ts +35 -0
- package/dist/types/components/EmbeddingChart.d.ts +25 -0
- package/dist/types/components/FlameGraphChart.d.ts +15 -0
- package/dist/types/components/GanttChart.d.ts +15 -0
- package/dist/types/components/GaugeChart.d.ts +27 -0
- package/dist/types/components/HeatmapChart.d.ts +41 -0
- package/dist/types/components/HistogramChart.d.ts +15 -0
- package/dist/types/components/LossCurveChart.d.ts +17 -0
- package/dist/types/components/MultiBandCanvasChart.d.ts +156 -0
- package/dist/types/components/ParallelCoordsChart.d.ts +21 -0
- package/dist/types/components/PolarChart.d.ts +17 -0
- package/dist/types/components/QQPlotChart.d.ts +16 -0
- package/dist/types/components/RadarChart.d.ts +17 -0
- package/dist/types/components/RocChart.d.ts +12 -0
- package/dist/types/components/SankeyChart.d.ts +15 -0
- package/dist/types/components/SpectrogramChart.d.ts +16 -0
- package/dist/types/components/SpectrogramWaterfall.d.ts +14 -0
- package/dist/types/components/SpectrumChart.d.ts +17 -0
- package/dist/types/components/TreemapChart.d.ts +14 -0
- package/dist/types/components/ViolinChart.d.ts +17 -0
- package/dist/types/components/XYScatterChart.d.ts +47 -0
- package/dist/types/components/XYZMeshChart.d.ts +68 -0
- package/dist/types/components/dashboardGridLayout.d.ts +50 -0
- package/dist/types/components/liveFollowEase.d.ts +10 -0
- package/dist/types/components/liveWindow.d.ts +63 -0
- package/dist/types/components/multiBandHover.d.ts +44 -0
- package/dist/types/embed/Attribution.d.ts +5 -0
- package/dist/types/embed/license.d.ts +29 -0
- package/dist/types/embed/standalone.d.ts +5 -0
- package/dist/types/engine/columns.d.ts +44 -0
- package/dist/types/engine/createEngine.d.ts +394 -0
- package/dist/types/engine/derive.d.ts +27 -0
- package/dist/types/engine/emitter.d.ts +6 -0
- package/dist/types/engine/errors.d.ts +7 -0
- package/dist/types/engine/history.d.ts +29 -0
- package/dist/types/engine/kinds.d.ts +9 -0
- package/dist/types/engine/liveController.d.ts +27 -0
- package/dist/types/engine/store.d.ts +8 -0
- package/dist/types/engine/types.d.ts +194 -0
- package/dist/types/index.d.ts +69 -0
- package/dist/types/lib/annotations.d.ts +37 -0
- package/dist/types/lib/beacon.d.ts +62 -0
- package/dist/types/lib/colorScheme.d.ts +5 -0
- package/dist/types/lib/colormap.d.ts +9 -0
- package/dist/types/lib/columnTable.d.ts +37 -0
- package/dist/types/lib/data/arrowDecimation.d.ts +11 -0
- package/dist/types/lib/data/binnedHeatmap.d.ts +27 -0
- package/dist/types/lib/data/columnCaches.d.ts +6 -0
- package/dist/types/lib/data/columnarDataSource.d.ts +34 -0
- package/dist/types/lib/data/createDataSource.d.ts +23 -0
- package/dist/types/lib/data/dataSource.d.ts +75 -0
- package/dist/types/lib/data/decimate.d.ts +25 -0
- package/dist/types/lib/data/duckDbDataSource.d.ts +42 -0
- package/dist/types/lib/data/envelope.d.ts +16 -0
- package/dist/types/lib/data/inMemoryDataSource.d.ts +25 -0
- package/dist/types/lib/data/liveDataSource.d.ts +77 -0
- package/dist/types/lib/data/lruCache.d.ts +11 -0
- package/dist/types/lib/data/openDataset.d.ts +24 -0
- package/dist/types/lib/data/opfsParquet.d.ts +4 -0
- package/dist/types/lib/data/pointColumns.d.ts +59 -0
- package/dist/types/lib/data/schemaColumns.d.ts +5 -0
- package/dist/types/lib/data/useSeriesPoints.d.ts +48 -0
- package/dist/types/lib/data/xyColumns.d.ts +77 -0
- package/dist/types/lib/dataBounds.d.ts +10 -0
- package/dist/types/lib/datasetColors.d.ts +19 -0
- package/dist/types/lib/datasetColumns.d.ts +3 -0
- package/dist/types/lib/datasetMerge.d.ts +8 -0
- package/dist/types/lib/duckdb/duckdbInstance.d.ts +7 -0
- package/dist/types/lib/duckdb/fileIdentity.d.ts +9 -0
- package/dist/types/lib/duckdb/sql.d.ts +124 -0
- package/dist/types/lib/fft.d.ts +15 -0
- package/dist/types/lib/folderTree.d.ts +29 -0
- package/dist/types/lib/gaugeColors.d.ts +32 -0
- package/dist/types/lib/importers/arrowSink.d.ts +35 -0
- package/dist/types/lib/importers/blobReader.d.ts +22 -0
- package/dist/types/lib/importers/bytes.d.ts +11 -0
- package/dist/types/lib/importers/combine.d.ts +30 -0
- package/dist/types/lib/importers/comtrade/format.d.ts +2 -0
- package/dist/types/lib/importers/comtrade/importer.d.ts +25 -0
- package/dist/types/lib/importers/dbc.d.ts +45 -0
- package/dist/types/lib/importers/edf/format.d.ts +2 -0
- package/dist/types/lib/importers/edf/importer.d.ts +7 -0
- package/dist/types/lib/importers/expr.d.ts +10 -0
- package/dist/types/lib/importers/formats.d.ts +23 -0
- package/dist/types/lib/importers/hdf5/format.d.ts +4 -0
- package/dist/types/lib/importers/hdf5/h5.d.ts +76 -0
- package/dist/types/lib/importers/hdf5/h5wasmModule.d.ts +1 -0
- package/dist/types/lib/importers/hdf5/importer.d.ts +2 -0
- package/dist/types/lib/importers/importer.worker.d.ts +5 -0
- package/dist/types/lib/importers/importers.d.ts +4 -0
- package/dist/types/lib/importers/limits.d.ts +28 -0
- package/dist/types/lib/importers/mat/format.d.ts +2 -0
- package/dist/types/lib/importers/mat/group.d.ts +19 -0
- package/dist/types/lib/importers/mat/importer.d.ts +2 -0
- package/dist/types/lib/importers/mat/v5.d.ts +24 -0
- package/dist/types/lib/importers/mat/v73.d.ts +13 -0
- package/dist/types/lib/importers/mdf/blocks3.d.ts +3 -0
- package/dist/types/lib/importers/mdf/blocks4.d.ts +7 -0
- package/dist/types/lib/importers/mdf/bus.d.ts +59 -0
- package/dist/types/lib/importers/mdf/conversion.d.ts +48 -0
- package/dist/types/lib/importers/mdf/decode.d.ts +15 -0
- package/dist/types/lib/importers/mdf/format.d.ts +2 -0
- package/dist/types/lib/importers/mdf/importer.d.ts +19 -0
- package/dist/types/lib/importers/mdf/model.d.ts +75 -0
- package/dist/types/lib/importers/mdf/records.d.ts +31 -0
- package/dist/types/lib/importers/mdf/stream.d.ts +42 -0
- package/dist/types/lib/importers/memorySink.d.ts +11 -0
- package/dist/types/lib/importers/names.d.ts +2 -0
- package/dist/types/lib/importers/openImport.d.ts +33 -0
- package/dist/types/lib/importers/registry.d.ts +24 -0
- package/dist/types/lib/importers/run.d.ts +35 -0
- package/dist/types/lib/importers/session.d.ts +28 -0
- package/dist/types/lib/importers/tdms/format.d.ts +2 -0
- package/dist/types/lib/importers/tdms/importer.d.ts +10 -0
- package/dist/types/lib/importers/types.d.ts +172 -0
- package/dist/types/lib/importers/workerCore.d.ts +44 -0
- package/dist/types/lib/importers/xdf/format.d.ts +2 -0
- package/dist/types/lib/importers/xdf/importer.d.ts +2 -0
- package/dist/types/lib/importers/zlib.d.ts +13 -0
- package/dist/types/lib/kde.d.ts +2 -0
- package/dist/types/lib/live/buffer.d.ts +265 -0
- package/dist/types/lib/live/columnsWire.d.ts +24 -0
- package/dist/types/lib/live/crypto.d.ts +157 -0
- package/dist/types/lib/live/liveMathChannels.d.ts +11 -0
- package/dist/types/lib/live/recorder.d.ts +32 -0
- package/dist/types/lib/live/stream.d.ts +33 -0
- package/dist/types/lib/live/timeBuckets.d.ts +71 -0
- package/dist/types/lib/live/types.d.ts +72 -0
- package/dist/types/lib/live/wire.d.ts +25 -0
- package/dist/types/lib/mathChannels/compile.d.ts +22 -0
- package/dist/types/lib/mathChannels/evaluator.d.ts +40 -0
- package/dist/types/lib/mathChannels/functions/conditional.d.ts +2 -0
- package/dist/types/lib/mathChannels/functions/filters.d.ts +7 -0
- package/dist/types/lib/mathChannels/functions/index.d.ts +3 -0
- package/dist/types/lib/mathChannels/functions/reference.d.ts +7 -0
- package/dist/types/lib/mathChannels/functions/windowOps.d.ts +11 -0
- package/dist/types/lib/mathChannels/index.d.ts +13 -0
- package/dist/types/lib/mathChannels/io.d.ts +18 -0
- package/dist/types/lib/mathChannels/mathjsSetup.d.ts +7 -0
- package/dist/types/lib/mathChannels/parseMath.d.ts +12 -0
- package/dist/types/lib/mathChannels/parser.d.ts +22 -0
- package/dist/types/lib/mathChannels/types.d.ts +34 -0
- package/dist/types/lib/mathChannels/usedChannels.d.ts +14 -0
- package/dist/types/lib/moduleWorker.d.ts +7 -0
- package/dist/types/lib/panelChartSettings.d.ts +438 -0
- package/dist/types/lib/parseDataset.d.ts +74 -0
- package/dist/types/lib/parseDataset.worker.d.ts +1 -0
- package/dist/types/lib/parseDatasetWorkerClient.d.ts +32 -0
- package/dist/types/lib/perfLog.d.ts +4 -0
- package/dist/types/lib/quantiles.d.ts +10 -0
- package/dist/types/lib/recordings/csvWriter.d.ts +10 -0
- package/dist/types/lib/recordings/export.d.ts +26 -0
- package/dist/types/lib/recordings/importer.d.ts +2 -0
- package/dist/types/lib/recordings/keys.d.ts +23 -0
- package/dist/types/lib/recordings/krc.d.ts +38 -0
- package/dist/types/lib/recordings/mf4Writer.d.ts +20 -0
- package/dist/types/lib/render/chartFonts.d.ts +10 -0
- package/dist/types/lib/render/colorBucket.d.ts +6 -0
- package/dist/types/lib/render/contours.d.ts +16 -0
- package/dist/types/lib/render/cssColor.d.ts +2 -0
- package/dist/types/lib/render/frames.d.ts +46 -0
- package/dist/types/lib/render/gl3d.d.ts +63 -0
- package/dist/types/lib/render/glLines.d.ts +62 -0
- package/dist/types/lib/render/glPlot.d.ts +36 -0
- package/dist/types/lib/render/glPoints.d.ts +37 -0
- package/dist/types/lib/render/glSeries.d.ts +67 -0
- package/dist/types/lib/render/heatGrid.d.ts +9 -0
- package/dist/types/lib/render/hitGrid.d.ts +16 -0
- package/dist/types/lib/render/liveZoomBus.d.ts +18 -0
- package/dist/types/lib/render/margins.d.ts +14 -0
- package/dist/types/lib/render/offscreenLineRenderer.d.ts +53 -0
- package/dist/types/lib/render/offscreenLineWorker.d.ts +1 -0
- package/dist/types/lib/render/plotFrame.d.ts +36 -0
- package/dist/types/lib/render/resample.d.ts +18 -0
- package/dist/types/lib/render/sharedGl.d.ts +38 -0
- package/dist/types/lib/render/useGlPlot.d.ts +7 -0
- package/dist/types/lib/savedLayout.d.ts +45 -0
- package/dist/types/lib/stft.d.ts +37 -0
- package/dist/types/lib/workspaces/encrypted.d.ts +50 -0
- package/dist/types/lib/workspaces/io.d.ts +120 -0
- package/dist/types/lib/xyFit.d.ts +14 -0
- package/dist/types/lib/yAxisTicks.d.ts +28 -0
- package/dist/types/react/index.d.ts +32 -0
- package/dist/types/types/loadedDataset.d.ts +42 -0
- package/dist/types/types/plotSeries.d.ts +27 -0
- package/package.json +63 -4
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A minimal ASAM MDF 4.10 file: ID, HD, FH (+ its MD comment), one sorted data group (record id size 0) with one
|
|
3
|
+
* channel group: a float64 master channel (column 0, Time, sync type time) and one float64 channel per other
|
|
4
|
+
* column, each named by a TX block, its unit in another TX; one DT block, last, with the records row-major.
|
|
5
|
+
* Blocks are 8-byte aligned. The metadata comes first, built from the plan's exact row count (`head`); then each
|
|
6
|
+
* chunk's records (`append`), so the file streams to its sink (never one buffer); `end` checks the count held.
|
|
7
|
+
* Block layouts: ASAM MDF 4.1 (ID 64 B; header 24 B = id, reserved, length, link count).
|
|
8
|
+
*/
|
|
9
|
+
import type { Chunk } from '../importers/combine';
|
|
10
|
+
import type { OutColumn } from '../importers/run';
|
|
11
|
+
export declare class Mf4Writer {
|
|
12
|
+
#private;
|
|
13
|
+
constructor(columns: OutColumn[], startTime: string | null, rows: number);
|
|
14
|
+
/** One chunk's records, row-major float64. */
|
|
15
|
+
append(c: Chunk): Uint8Array<ArrayBuffer>;
|
|
16
|
+
/** The header said `rows` records: anything else would be a corrupt file. */
|
|
17
|
+
end(): void;
|
|
18
|
+
/** Everything before the records: ID, HD, FH, the TX/MD blocks, DG, CG, the CNs and the DT header. */
|
|
19
|
+
head(): Uint8Array<ArrayBuffer>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Font families every chart draws its canvas text with. Set through
|
|
3
|
+
* `engine.charts.setFonts()`.
|
|
4
|
+
* ponytail: page-global (canvas text can't inherit CSS); per-chart fonts would
|
|
5
|
+
* need the family threaded through every renderer.
|
|
6
|
+
*/
|
|
7
|
+
export declare const chartFonts: {
|
|
8
|
+
sans: string;
|
|
9
|
+
mono: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map a normalized value in [0, 1] to one of `buckets` integer slots
|
|
3
|
+
* (0 … buckets-1), clamping out-of-range inputs. Used to batch colormapped
|
|
4
|
+
* scatter points into a handful of Path2D fills instead of one fill per point.
|
|
5
|
+
*/
|
|
6
|
+
export declare function quantizeBucket(value: number, buckets: number): number;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Isolines of a grid of values (marching squares). The grid's samples sit at
|
|
3
|
+
* integer positions (column i, row j); a segment's ends are fractional
|
|
4
|
+
* positions between them. NaN samples leave their squares out.
|
|
5
|
+
*/
|
|
6
|
+
export type Segment = [number, number, number, number];
|
|
7
|
+
/** `n` levels evenly spaced strictly inside (lo, hi). */
|
|
8
|
+
export declare function contourLevels(lo: number, hi: number, n: number): number[];
|
|
9
|
+
export declare function contourSegments(values: ArrayLike<number>, w: number, h: number, level: number): Segment[];
|
|
10
|
+
/**
|
|
11
|
+
* Boundaries of cells centred on `centres` (ascending): midway between
|
|
12
|
+
* neighbours, the outer ones half a neighbour gap out. n centres → n + 1 edges.
|
|
13
|
+
*/
|
|
14
|
+
export declare function edgesFromCentres(centres: ArrayLike<number>): Float64Array;
|
|
15
|
+
/** True when the values strictly increase (usable as cell centres). */
|
|
16
|
+
export declare function increasing(v: ArrayLike<number>): boolean;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Frame scheduling and resize observation that keep working when a chart lives
|
|
3
|
+
* in another browser window (charts.openWindow). A window's ResizeObserver only
|
|
4
|
+
* reports during that window's own rendering, and a hidden or minimised window
|
|
5
|
+
* stops its animation frames — so charts observe with their element's window
|
|
6
|
+
* and ask every open window for the next frame.
|
|
7
|
+
*/
|
|
8
|
+
export declare function addFrameWindow(w: Window): void;
|
|
9
|
+
export declare function removeFrameWindow(w: Window): void;
|
|
10
|
+
/** requestAnimationFrame from whichever open window paints first; the callback runs once. */
|
|
11
|
+
export declare function raf(cb: FrameRequestCallback): number;
|
|
12
|
+
export declare function cancelRaf(handle: number | null | undefined): void;
|
|
13
|
+
/** Count one frame whose drawn picture changed (data or view), for the perf HUD. */
|
|
14
|
+
export declare function notePaint(el: Element | null): void;
|
|
15
|
+
/** Changed frames drawn so far by the charts inside `host`. */
|
|
16
|
+
export declare function paintsWithin(host: Element): number;
|
|
17
|
+
/** True when no window that can show a chart is visible. */
|
|
18
|
+
export declare function allFramesHidden(): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* ResizeObserver with the same interface that observes each element with its
|
|
21
|
+
* own window's observer, so charts in a popup report size changes as they happen.
|
|
22
|
+
*/
|
|
23
|
+
export declare class AnyWindowResizeObserver {
|
|
24
|
+
#private;
|
|
25
|
+
constructor(cb: ResizeObserverCallback);
|
|
26
|
+
observe(el: Element, options?: ResizeObserverOptions): void;
|
|
27
|
+
unobserve(el: Element): void;
|
|
28
|
+
disconnect(): void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A chart's draw, at most once per frame, of whatever is newest then:
|
|
32
|
+
* - `schedule()` queues a draw for the next frame, keeping one already queued
|
|
33
|
+
* (cancelling and re-queuing on every change starved a chart whose data
|
|
34
|
+
* changed every frame: the draw was pushed back forever);
|
|
35
|
+
* - `now()` draws at once if the chart hasn't drawn in this frame yet, else
|
|
36
|
+
* queues: data replaced from a requestAnimationFrame loop arrives during a
|
|
37
|
+
* frame's callbacks, where a requested frame only runs on the next one, so
|
|
38
|
+
* always queueing painted every other frame. `document.timeline` holds the
|
|
39
|
+
* frame's time until the next frame, so several changes in one frame still
|
|
40
|
+
* make one draw.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createDrawScheduler(draw: () => void, doc: () => Document | null | undefined): {
|
|
43
|
+
schedule(): void;
|
|
44
|
+
now(): void;
|
|
45
|
+
cancel(): void;
|
|
46
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export type Vec3Tuple = [number, number, number];
|
|
2
|
+
export interface Gpu3dBounds {
|
|
3
|
+
minX: number;
|
|
4
|
+
maxX: number;
|
|
5
|
+
minY: number;
|
|
6
|
+
maxY: number;
|
|
7
|
+
minZ: number;
|
|
8
|
+
maxZ: number;
|
|
9
|
+
}
|
|
10
|
+
export type Gpu3dView =
|
|
11
|
+
/** Perspective, through the orbit camera (`f` = 1 / tan(fov / 2)); data X→world x, Z→y (up), Y→z. */
|
|
12
|
+
{
|
|
13
|
+
kind: '3d';
|
|
14
|
+
eye: Vec3Tuple;
|
|
15
|
+
right: Vec3Tuple;
|
|
16
|
+
up: Vec3Tuple;
|
|
17
|
+
fwd: Vec3Tuple;
|
|
18
|
+
f: number;
|
|
19
|
+
}
|
|
20
|
+
/** Data axis `h` (0 x, 1 y, 2 z) across, `v` up, the plot rectangle filled. */
|
|
21
|
+
| {
|
|
22
|
+
kind: '2d';
|
|
23
|
+
h: 0 | 1 | 2;
|
|
24
|
+
v: 0 | 1 | 2;
|
|
25
|
+
};
|
|
26
|
+
export interface Gpu3dStyle {
|
|
27
|
+
/** 256 RGBA colours along the colour axis. */
|
|
28
|
+
palette: Uint8Array;
|
|
29
|
+
/** Data axis the colour follows (0 x, 1 y, 2 z). */
|
|
30
|
+
colorAxis: 0 | 1 | 2;
|
|
31
|
+
pointRadius: number;
|
|
32
|
+
/** The mesh/surface: filled, its wire, both (or neither: points only). */
|
|
33
|
+
fill: boolean;
|
|
34
|
+
wire: boolean;
|
|
35
|
+
fillAlpha: number;
|
|
36
|
+
wireColor: [number, number, number, number];
|
|
37
|
+
}
|
|
38
|
+
export interface Gpu3d {
|
|
39
|
+
resize(cssWidth: number, cssHeight: number, dpr: number): void;
|
|
40
|
+
/** The axis box: data outside it is not drawn. */
|
|
41
|
+
setBounds(b: Gpu3dBounds): void;
|
|
42
|
+
setView(v: Gpu3dView, plot: {
|
|
43
|
+
left: number;
|
|
44
|
+
top: number;
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
}): void;
|
|
48
|
+
/** The points (null: none). Non-finite points are not drawn. */
|
|
49
|
+
setPoints(x: ArrayLike<number> | null, y?: ArrayLike<number>, z?: ArrayLike<number>): void;
|
|
50
|
+
/** Triangles over the points, as index triples (null: no mesh). */
|
|
51
|
+
setTriangles(idx: Uint32Array | null): void;
|
|
52
|
+
/**
|
|
53
|
+
* Heights over a uniform grid (null: none): `w` × `h` values row by row, row
|
|
54
|
+
* r at y0 + r·(y1 − y0)/(h − 1), column c at x0 + c·(x1 − x0)/(w − 1).
|
|
55
|
+
* NaN leaves a hole. At most {@link maxTextureSize} a side.
|
|
56
|
+
*/
|
|
57
|
+
setSurface(z: ArrayLike<number> | null, w?: number, h?: number, x?: [number, number], y?: [number, number]): void;
|
|
58
|
+
setStyle(s: Gpu3dStyle): void;
|
|
59
|
+
readonly maxTextureSize: number;
|
|
60
|
+
render(): void;
|
|
61
|
+
dispose(): void;
|
|
62
|
+
}
|
|
63
|
+
export declare function createGpu3d(canvas: HTMLCanvasElement | OffscreenCanvas): Gpu3d | null;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal WebGL2 polyline renderer for chart data lines — the part whose cost
|
|
3
|
+
* scales with point count. Axes/grid/labels/hover stay on Canvas-2D (cheap,
|
|
4
|
+
* O(ticks)). One instanced draw call per polyline; the GPU makes draw cost
|
|
5
|
+
* ~independent of point count, which is the flat-performance lever.
|
|
6
|
+
*
|
|
7
|
+
* Rendering model: each polyline segment is one INSTANCED quad, and the fragment
|
|
8
|
+
* shader computes the analytic distance from the pixel to the segment (a capsule
|
|
9
|
+
* SDF) to derive edge coverage. Two reasons this replaces the earlier
|
|
10
|
+
* triangle-strip ribbon + MSAA approach:
|
|
11
|
+
*
|
|
12
|
+
* 1. NO SHIMMER WITHOUT SNAPPING. MSAA coverage changes in discrete sample-count
|
|
13
|
+
* steps as a near-vertical edge (gear step, RPM spike) moves sub-pixel, so a
|
|
14
|
+
* live scroll made edges shimmer unless the view was snapped to whole device
|
|
15
|
+
* pixels — and that snap turned slow scrolls (wide X ranges) into visible 1px
|
|
16
|
+
* lurches. Analytic coverage varies SMOOTHLY with sub-pixel position, so the
|
|
17
|
+
* trace can scroll continuously (no snap) with stable, crisp edges at any
|
|
18
|
+
* scroll speed.
|
|
19
|
+
* 2. CORRECT JOINS. A previous analytic attempt carried a signed distance on
|
|
20
|
+
* shared ribbon vertices; the averaged-miter distance is wrong at sharp
|
|
21
|
+
* corners, visibly so on stepped channels. Per-segment capsules have no miter
|
|
22
|
+
* at all: every segment ends in a round cap, and consecutive capsules overlap
|
|
23
|
+
* into a clean round join.
|
|
24
|
+
*
|
|
25
|
+
* Coordinates are CSS pixels (top-left origin, y down). The renderer maps them to
|
|
26
|
+
* clip space and handles devicePixelRatio via the canvas backing size + viewport.
|
|
27
|
+
*/
|
|
28
|
+
/** A polyline to draw: interleaved [x0,y0, x1,y1, …] in CSS px + an RGBA color. */
|
|
29
|
+
export interface GlLineBatch {
|
|
30
|
+
points: Float32Array;
|
|
31
|
+
color: [number, number, number, number];
|
|
32
|
+
/** Optional clip rect in CSS px (top-left origin). Drawing is scissored to it. */
|
|
33
|
+
clip?: {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
w: number;
|
|
37
|
+
h: number;
|
|
38
|
+
};
|
|
39
|
+
/** Line thickness in CSS px; defaults to the renderer's `lineWidth`. */
|
|
40
|
+
width?: number;
|
|
41
|
+
}
|
|
42
|
+
export interface GlLineRenderer {
|
|
43
|
+
/** Resize the backing store for a CSS size at the given devicePixelRatio. */
|
|
44
|
+
resize(cssWidth: number, cssHeight: number, dpr: number): void;
|
|
45
|
+
/** Clear and draw all polylines for the current frame. */
|
|
46
|
+
draw(batches: GlLineBatch[]): void;
|
|
47
|
+
dispose(): void;
|
|
48
|
+
}
|
|
49
|
+
/** Parse `#rrggbb`, `#rgb` or `#rrggbbaa` to an RGBA tuple in 0..1 (the hex alpha times `alpha`). */
|
|
50
|
+
export declare function hexToRgba(hex: string, alpha?: number): [number, number, number, number];
|
|
51
|
+
/** Segment instances drawable from a points array: consecutive point pairs. */
|
|
52
|
+
export declare function segmentInstanceCount(pointsLength: number): number;
|
|
53
|
+
/** Extra half-width (CSS px) the quad extends beyond the visible line so the
|
|
54
|
+
* analytic feather (~1.75 device px smoothstep) always has geometry to land in. */
|
|
55
|
+
export declare const AA_FEATHER = 2.5;
|
|
56
|
+
/** Lines render at this multiple of device resolution, box-filtered down in draw(). */
|
|
57
|
+
export declare const SUPERSAMPLE = 2;
|
|
58
|
+
export declare function compile(gl: WebGL2RenderingContext, type: number, src: string): WebGLShader | null;
|
|
59
|
+
/** Create a renderer, or null if WebGL2 is unavailable / setup failed.
|
|
60
|
+
* `lineWidth` is the line thickness in CSS pixels. Accepts an OffscreenCanvas
|
|
61
|
+
* too, so the same renderer can run inside a Web Worker. */
|
|
62
|
+
export declare function createGlLineRenderer(canvas: HTMLCanvasElement | OffscreenCanvas, lineWidth?: number): GlLineRenderer | null;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type Rgba = [number, number, number, number];
|
|
2
|
+
export interface GpuPlot {
|
|
3
|
+
resize(cssWidth: number, cssHeight: number, dpr: number): void;
|
|
4
|
+
/** Data window and the plot rectangle (CSS px) it maps to. */
|
|
5
|
+
setView(xmin: number, xmax: number, ymin: number, ymax: number, plot: {
|
|
6
|
+
left: number;
|
|
7
|
+
top: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}): void;
|
|
11
|
+
/**
|
|
12
|
+
* Filled area between `lo` and `hi` along `x`: a trapezoid from point i to
|
|
13
|
+
* i+1, skipped where `starts[i + 1]` is set (a new trace) or a value is not finite.
|
|
14
|
+
*/
|
|
15
|
+
setBands(id: string, x: ArrayLike<number>, lo: ArrayLike<number>, hi: ArrayLike<number>, color: Rgba, starts?: Uint8Array): void;
|
|
16
|
+
/** Rectangles [x0, x1] × [y0, y1], each the colour `palette[k[i]]` (one colour when `k` is absent). */
|
|
17
|
+
setRects(id: string, x0: ArrayLike<number>, x1: ArrayLike<number>, y0: ArrayLike<number>, y1: ArrayLike<number>, palette: Rgba[], k?: ArrayLike<number>): void;
|
|
18
|
+
/** A line through the points in order, broken where `starts[i]` is set or a value is not finite. */
|
|
19
|
+
setLine(id: string, x: ArrayLike<number>, y: ArrayLike<number>, color: Rgba, width: number, starts?: Uint8Array): void;
|
|
20
|
+
/**
|
|
21
|
+
* A grid of `w` × `h` values (row-major, row 0 at `y0`) over [x0, x1] × [y0, y1],
|
|
22
|
+
* coloured through `palette` (256 RGBA colours) from `vmin` to `vmax`; NaN
|
|
23
|
+
* cells are left empty. A new range alone: {@link setGridRange}.
|
|
24
|
+
*/
|
|
25
|
+
setGrid(id: string, values: Float32Array, w: number, h: number, extent: [number, number, number, number], palette: Uint8Array, vmin: number, vmax: number): void;
|
|
26
|
+
/** A grid's colour range, without sending its values again. */
|
|
27
|
+
setGridRange(id: string, vmin: number, vmax: number): void;
|
|
28
|
+
/** Largest grid side the GPU takes. */
|
|
29
|
+
readonly maxTextureSize: number;
|
|
30
|
+
remove(id: string): void;
|
|
31
|
+
/** Remove every layer but `ids`. */
|
|
32
|
+
keep(ids: string[]): void;
|
|
33
|
+
render(): void;
|
|
34
|
+
dispose(): void;
|
|
35
|
+
}
|
|
36
|
+
export declare function createGpuPlot(canvas: HTMLCanvasElement | OffscreenCanvas): GpuPlot | null;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type GpuPointsColor = {
|
|
2
|
+
kind: 'single';
|
|
3
|
+
rgba: [number, number, number, number];
|
|
4
|
+
}
|
|
5
|
+
/** `rgba[i]` for a point's value v in 0..1 is the texel at round(v * 255). */
|
|
6
|
+
| {
|
|
7
|
+
kind: 'colormap';
|
|
8
|
+
palette: Uint8Array;
|
|
9
|
+
}
|
|
10
|
+
/** One colour per dataset index (at most 256). */
|
|
11
|
+
| {
|
|
12
|
+
kind: 'dataset';
|
|
13
|
+
palette: Uint8Array;
|
|
14
|
+
};
|
|
15
|
+
export interface GpuPointsRenderer {
|
|
16
|
+
resize(cssWidth: number, cssHeight: number, dpr: number): void;
|
|
17
|
+
/**
|
|
18
|
+
* The points: `x`, `y`, and per point either a 0..1 colour value or a dataset
|
|
19
|
+
* index in `k` (ignored for a single colour). Non-finite points are dropped.
|
|
20
|
+
* `breakOnK`: the line also breaks where `k` changes (one per dataset).
|
|
21
|
+
* `radius`: each point's own radius (CSS px) instead of the style's.
|
|
22
|
+
*/
|
|
23
|
+
setData(x: ArrayLike<number>, y: ArrayLike<number>, k?: ArrayLike<number>, breakOnK?: boolean, radius?: ArrayLike<number>): void;
|
|
24
|
+
setStyle(color: GpuPointsColor, radiusCss: number, alpha: number): void;
|
|
25
|
+
/** What to draw: the points, a line through them in order, or both (line width in CSS px). */
|
|
26
|
+
setDraw(points: boolean, lines: boolean, lineWidthCss: number): void;
|
|
27
|
+
/** Data window and the plot rectangle (CSS px) it maps to. */
|
|
28
|
+
setView(xmin: number, xmax: number, ymin: number, ymax: number, plot: {
|
|
29
|
+
left: number;
|
|
30
|
+
top: number;
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
}): void;
|
|
34
|
+
render(): void;
|
|
35
|
+
dispose(): void;
|
|
36
|
+
}
|
|
37
|
+
export declare function createGpuPointsRenderer(canvas: HTMLCanvasElement | OffscreenCanvas): GpuPointsRenderer | null;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export interface GpuSeriesStyle {
|
|
2
|
+
color: [number, number, number, number];
|
|
3
|
+
bandTop: number;
|
|
4
|
+
bandBottom: number;
|
|
5
|
+
scaleMin: number;
|
|
6
|
+
scaleMax: number;
|
|
7
|
+
/** Median consecutive |Δx| of the column (0 if unknown): drives gap-splitting. */
|
|
8
|
+
gapMedian: number;
|
|
9
|
+
/** Line thickness in CSS px; defaults to the renderer's `lineWidth`. */
|
|
10
|
+
width?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface GpuSeriesRenderer {
|
|
13
|
+
resize(cssWidth: number, cssHeight: number, dpr: number): void;
|
|
14
|
+
/**
|
|
15
|
+
* Upload a layer's data: shared X (and trace starts), one Y column per series.
|
|
16
|
+
* `xs` null: the layer's X and starts as last uploaded (new values only).
|
|
17
|
+
*/
|
|
18
|
+
setData(layer: number, xs: Float64Array | null, breaks: Uint8Array | undefined, columns: Float32Array[]): void;
|
|
19
|
+
/** Per-series styles of a layer (same order as its columns) and the plot's X extent in px. */
|
|
20
|
+
setStyles(layer: number, styles: GpuSeriesStyle[], left: number, plotW: number): void;
|
|
21
|
+
/** Drop a layer. */
|
|
22
|
+
clearLayer(layer: number): void;
|
|
23
|
+
setView(xmin: number, xmax: number): void;
|
|
24
|
+
render(): void;
|
|
25
|
+
dispose(): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* One series' points as uploaded: the finite ones only (X relative to the
|
|
29
|
+
* layer origin), with a trace start flag (255) per point. A start that falls on
|
|
30
|
+
* a dropped sample moves to the next kept one, as the on-main path flushes its
|
|
31
|
+
* polyline there. Null when every point is finite (the layer's X serves as is).
|
|
32
|
+
*/
|
|
33
|
+
export declare function compactSeries(xs: Float64Array, xRel: Float32Array, starts: Uint8Array, col: Float32Array): {
|
|
34
|
+
x: Float32Array;
|
|
35
|
+
y: Float32Array;
|
|
36
|
+
starts: Uint8Array;
|
|
37
|
+
} | null;
|
|
38
|
+
/**
|
|
39
|
+
* Every series of a layer in one set of arrays, back to back, each starting a new
|
|
40
|
+
* trace (so no segment joins the end of one series to the start of the next),
|
|
41
|
+
* with each point's series index. `counts` are the points per series.
|
|
42
|
+
*/
|
|
43
|
+
export declare function packLayer(xs: Float64Array, breaks: Uint8Array | undefined, columns: Float32Array[]): {
|
|
44
|
+
origin: number;
|
|
45
|
+
x: Float32Array;
|
|
46
|
+
y: Float32Array;
|
|
47
|
+
starts: Uint8Array;
|
|
48
|
+
sid: Float32Array;
|
|
49
|
+
counts: number[];
|
|
50
|
+
};
|
|
51
|
+
/** Points per device pixel in view above which a layer is drawn from its per-pixel min/max. */
|
|
52
|
+
export declare const RESAMPLE_DENSITY = 4;
|
|
53
|
+
/**
|
|
54
|
+
* Every series of a layer over [xmin, xmax] as per-bucket min/max (`nb` buckets),
|
|
55
|
+
* packed like {@link packLayer}: per bucket, at its centre, the min then the max
|
|
56
|
+
* (one point when they're equal); a bucket with no value is left out, so a gap
|
|
57
|
+
* stays a gap. The nearest sample on each side of the window is kept as is, so
|
|
58
|
+
* lines run on to the plot edges. `xs` must be ascending.
|
|
59
|
+
*/
|
|
60
|
+
export declare function resampleLayer(xs: Float64Array, columns: Float32Array[], origin: number, xmin: number, xmax: number, nb: number): {
|
|
61
|
+
x: Float32Array;
|
|
62
|
+
y: Float32Array;
|
|
63
|
+
starts: Uint8Array;
|
|
64
|
+
sid: Float32Array;
|
|
65
|
+
bucket: number;
|
|
66
|
+
};
|
|
67
|
+
export declare function createGpuSeriesRenderer(canvas: HTMLCanvasElement | OffscreenCanvas, lineWidth?: number): GpuSeriesRenderer | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HeatGrid } from '../../components/HeatmapChart';
|
|
2
|
+
/**
|
|
3
|
+
* The grid to draw at most `maxW` columns wide: wider grids (a matrix over
|
|
4
|
+
* millions of rows) average each run of columns into one.
|
|
5
|
+
*/
|
|
6
|
+
export declare function narrowed(g: HeatGrid, maxW: number): {
|
|
7
|
+
grid: HeatGrid;
|
|
8
|
+
per: number;
|
|
9
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nearest point under the pointer without scanning every point: the points
|
|
3
|
+
* bucketed into hit-radius cells over the plot (one pass, made on the first
|
|
4
|
+
* hover after the data or the view change), then a 3×3 cell lookup per move.
|
|
5
|
+
*/
|
|
6
|
+
export interface HitGrid {
|
|
7
|
+
cell: number;
|
|
8
|
+
nx: number;
|
|
9
|
+
ny: number;
|
|
10
|
+
start: Uint32Array;
|
|
11
|
+
ix: Uint32Array;
|
|
12
|
+
}
|
|
13
|
+
/** Points 0..n-1 at plot coordinates (`px(i)`, `py(i)`, 0..w × 0..h; outside or NaN: not hit). */
|
|
14
|
+
export declare function buildHitGrid(n: number, w: number, h: number, cell: number, px: (i: number) => number, py: (i: number) => number): HitGrid;
|
|
15
|
+
/** The point nearest (`mx`, `my`) within `r` (and within its own `reach`, when given), or null. */
|
|
16
|
+
export declare function nearestInGrid(g: HitGrid, mx: number, my: number, r: number, px: (i: number) => number, py: (i: number) => number, reach?: (i: number) => number): number | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tiny in-memory pub/sub so linked multiband charts can follow the chart being
|
|
3
|
+
* actively zoomed IN REAL TIME, instead of only catching up when the gesture
|
|
4
|
+
* commits to React ~140ms after it settles.
|
|
5
|
+
*
|
|
6
|
+
* The driving chart publishes its live X view on every wheel tick; sibling charts
|
|
7
|
+
* apply it to their internal view refs and redraw — no React re-render and no
|
|
8
|
+
* data re-query (they just stretch their existing points, same as the driver).
|
|
9
|
+
* The debounced commit still fires afterwards to refine + formally sync everyone.
|
|
10
|
+
*/
|
|
11
|
+
export type LiveZoomRange = [number, number] | null;
|
|
12
|
+
type Listener = (fromId: string, range: LiveZoomRange) => void;
|
|
13
|
+
export interface LiveZoomBus {
|
|
14
|
+
publish(fromId: string, range: LiveZoomRange): void;
|
|
15
|
+
subscribe(fn: Listener): () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function createLiveZoomBus(): LiveZoomBus;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface Margins {
|
|
2
|
+
top: number;
|
|
3
|
+
right: number;
|
|
4
|
+
bottom: number;
|
|
5
|
+
left: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A chart's margins at its size: `m`, or almost none when it is a thumbnail
|
|
9
|
+
* (narrower than 200 px or shorter than 120: a grid of many charts), where the
|
|
10
|
+
* plot fills it and the caller draws no axis labels or legend.
|
|
11
|
+
*/
|
|
12
|
+
export declare function fitMargins(m: Margins, w: number, h: number): Margins & {
|
|
13
|
+
tiny: boolean;
|
|
14
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type GpuSeriesStyle } from './glSeries';
|
|
2
|
+
/**
|
|
3
|
+
* Main-thread handle to the OffscreenCanvas line worker. The worker owns the GL
|
|
4
|
+
* context and keeps the data on the GPU (projected in the shader); the main
|
|
5
|
+
* thread posts a layer's points only when they change ({@link setData}), its
|
|
6
|
+
* styles when only those change ({@link setStyle}), and the X view window per
|
|
7
|
+
* frame of a zoom/pan ({@link setView}). The chart's GL canvas is transferred to
|
|
8
|
+
* the worker once via `transferControlToOffscreen()`. Returns null if unsupported.
|
|
9
|
+
*
|
|
10
|
+
* {@link setData} carries the X window the data belongs to. Each message the
|
|
11
|
+
* worker receives renders a frame, so posting data and view separately would
|
|
12
|
+
* paint one frame of NEW data through the OLD window — visible as the trace
|
|
13
|
+
* jumping away from the axes and snapping back. A live stream changes both on
|
|
14
|
+
* every rebuild (~8 Hz), which turned that into continuous flicker.
|
|
15
|
+
*/
|
|
16
|
+
/** How the worker draws one series: its Y scale and band, colour, width, gap rule. */
|
|
17
|
+
export type OffscreenSeriesStyle = GpuSeriesStyle;
|
|
18
|
+
/** What a layer is drawn with besides its points: series styles, plot X extent, X window. */
|
|
19
|
+
export interface OffscreenLayerFrame {
|
|
20
|
+
styles: OffscreenSeriesStyle[];
|
|
21
|
+
left: number;
|
|
22
|
+
plotW: number;
|
|
23
|
+
/** X window this layer is drawn through. Sent with the data/styles so no frame is
|
|
24
|
+
* ever drawn with the two out of sync. */
|
|
25
|
+
xmin: number;
|
|
26
|
+
xmax: number;
|
|
27
|
+
}
|
|
28
|
+
export interface OffscreenLayerData extends OffscreenLayerFrame {
|
|
29
|
+
/** Null: the layer's X and trace starts as last sent (new values only). */
|
|
30
|
+
xs: Float64Array | null;
|
|
31
|
+
/** 1 where an independent trace starts (never joined to the previous point). */
|
|
32
|
+
breaks?: Uint8Array;
|
|
33
|
+
/** One Y column per style, same order. Transferred to the worker. */
|
|
34
|
+
columns: Float32Array[];
|
|
35
|
+
}
|
|
36
|
+
export interface OffscreenChartRenderer {
|
|
37
|
+
resize(w: number, h: number, dpr: number): void;
|
|
38
|
+
/** New points for a layer (uploaded to the GPU). The worker draws every layer it holds. */
|
|
39
|
+
setData(layer: number, data: OffscreenLayerData): void;
|
|
40
|
+
/** Same points, new styles (Y scales, bands, colours) or plot size: no data moves. */
|
|
41
|
+
setStyle(layer: number, frame: OffscreenLayerFrame): void;
|
|
42
|
+
clear(layer: number): void;
|
|
43
|
+
setView(xmin: number, xmax: number): void;
|
|
44
|
+
dispose(): void;
|
|
45
|
+
}
|
|
46
|
+
export declare function createOffscreenChartRenderer(canvas: HTMLCanvasElement, lineWidth?: number): OffscreenChartRenderer | null;
|
|
47
|
+
/**
|
|
48
|
+
* The same renderer on the main thread through the page's shared WebGL
|
|
49
|
+
* context (see sharedGl): for charts past the contexts a page may own. Each
|
|
50
|
+
* message the worker would get is applied and drawn at once, then copied into
|
|
51
|
+
* the chart's canvas.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createSharedChartRenderer(canvas: HTMLCanvasElement, lineWidth?: number): OffscreenChartRenderer | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a chart's plot is on screen and what its numeric axes span: the plot
|
|
3
|
+
* rectangle (CSS px from the chart's top-left) and the data range across each
|
|
4
|
+
* numeric axis. Charts publish it every time they draw; overlays convert with
|
|
5
|
+
* it (annotations pinned to X, alarm lines).
|
|
6
|
+
*/
|
|
7
|
+
export interface AxisSpan {
|
|
8
|
+
/** Value at the left (X) or bottom (Y) of the plot. */
|
|
9
|
+
v0: number;
|
|
10
|
+
/** Value at the right (X) or top (Y) of the plot. */
|
|
11
|
+
v1: number;
|
|
12
|
+
log?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface PlotFrame {
|
|
15
|
+
left: number;
|
|
16
|
+
top: number;
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
x?: AxisSpan;
|
|
20
|
+
y?: AxisSpan;
|
|
21
|
+
}
|
|
22
|
+
/** Pixel of a value on the frame's X axis (the frame must have one). */
|
|
23
|
+
export declare const frameXToPx: (f: PlotFrame, x: number) => number;
|
|
24
|
+
export declare const frameXFromPx: (f: PlotFrame, px: number) => number;
|
|
25
|
+
/** Pixel of a value on the frame's Y axis (the frame must have one). */
|
|
26
|
+
export declare const frameYToPx: (f: PlotFrame, y: number) => number;
|
|
27
|
+
/** The latest frame of one chart; listeners hear only real changes (charts publish on every draw). */
|
|
28
|
+
export declare function createPlotFrameStore(): {
|
|
29
|
+
get: () => PlotFrame | null;
|
|
30
|
+
set: (f: PlotFrame | null) => void;
|
|
31
|
+
subscribe: (l: () => void) => () => void;
|
|
32
|
+
};
|
|
33
|
+
export type PlotFrameStore = ReturnType<typeof createPlotFrameStore>;
|
|
34
|
+
/** The chart frame's plot-frame setter, for the chart drawing inside it (a no-op elsewhere). */
|
|
35
|
+
export declare const PlotFrameContext: import("react").Context<(f: PlotFrame | null) => void>;
|
|
36
|
+
export declare const usePublishPlotFrame: () => (f: PlotFrame | null) => void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Indices of the samples to draw for an ascending `x` over [xmin, xmax] split
|
|
3
|
+
* into `buckets` (about two per device pixel): per bucket, those of its
|
|
4
|
+
* smallest and largest `y` in the order they come (M4), plus the nearest sample
|
|
5
|
+
* on each side of the window so lines run on to the plot edges. A series of
|
|
6
|
+
* millions of samples draws as a few thousand with the same picture. When the
|
|
7
|
+
* window holds fewer samples than `buckets`, every sample in it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function m4Indices(x: ArrayLike<number>, y: ArrayLike<number>, xmin: number, xmax: number, buckets: number): Uint32Array;
|
|
10
|
+
/**
|
|
11
|
+
* {@link m4Indices} for samples evenly spaced along X (X is the index, 0..n-1):
|
|
12
|
+
* no X array needed.
|
|
13
|
+
*/
|
|
14
|
+
export declare function m4IndexRange(y: ArrayLike<number>, buckets: number): Uint32Array;
|
|
15
|
+
/** `a` at `ix` (a gather), as a new Float64Array. */
|
|
16
|
+
export declare function gatherAt(a: ArrayLike<number>, ix: Uint32Array): Float64Array;
|
|
17
|
+
/** Whether `x` never decreases (NaN anywhere: no). */
|
|
18
|
+
export declare function isAscendingArray(x: ArrayLike<number>): boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebGL contexts for charts. A page gets only so many (Chrome keeps 16 and
|
|
3
|
+
* drops the oldest past that, its charts going blank), so the first charts
|
|
4
|
+
* get their own and the rest draw through ONE shared context: each draws into
|
|
5
|
+
* the shared canvas at its own size, then copies the picture into its own
|
|
6
|
+
* canvas (a GPU copy). The renderers can't tell the difference: they get a
|
|
7
|
+
* canvas-like object whose `getContext` is the shared context and whose size is
|
|
8
|
+
* the chart's own.
|
|
9
|
+
*/
|
|
10
|
+
export interface GlLease {
|
|
11
|
+
/** The canvas to create the renderer on (the chart's own, or a stand-in for the shared one). */
|
|
12
|
+
canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
13
|
+
/** True when drawing through the shared context: call `present` after each render. */
|
|
14
|
+
shared: boolean;
|
|
15
|
+
/** Copy what was just drawn into the chart's canvas (shared only; a no-op otherwise). */
|
|
16
|
+
present(): void;
|
|
17
|
+
release(): void;
|
|
18
|
+
}
|
|
19
|
+
/** Whether a chart may still own a context (a worker of its own, say). */
|
|
20
|
+
export declare function canOwnGl(): boolean;
|
|
21
|
+
/** Count a context a chart owns outside `leaseGl` (a worker's); returns its release. */
|
|
22
|
+
export declare function ownGl(): () => void;
|
|
23
|
+
/**
|
|
24
|
+
* A context for the chart canvas `visible`: its own while the budget lasts,
|
|
25
|
+
* else the shared one (the chart's canvas then shows copies through 2D).
|
|
26
|
+
*/
|
|
27
|
+
export declare function leaseGl(visible: HTMLCanvasElement): GlLease;
|
|
28
|
+
/** `make()` once per context and key. */
|
|
29
|
+
export declare function cachedPerContext<T>(gl: WebGL2RenderingContext, key: string, make: () => T): T;
|
|
30
|
+
/**
|
|
31
|
+
* A renderer made by `make` on the context due to the chart canvas `visible`
|
|
32
|
+
* (see leaseGl): its `render()` also copies the picture in when the context is
|
|
33
|
+
* shared, its `dispose()` gives the lease back. Null when `make` fails.
|
|
34
|
+
*/
|
|
35
|
+
export declare function onLeasedGl<T extends {
|
|
36
|
+
render(): void;
|
|
37
|
+
dispose(): void;
|
|
38
|
+
}>(visible: HTMLCanvasElement, make: (canvas: HTMLCanvasElement | OffscreenCanvas) => T | null): T | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import { type GpuPlot } from './glPlot';
|
|
3
|
+
/**
|
|
4
|
+
* A glPlot on the chart's GL canvas, made on first use and sized to the chart
|
|
5
|
+
* (CSS px); null without WebGL2 (the chart then draws on its 2D canvas).
|
|
6
|
+
*/
|
|
7
|
+
export declare function useGlPlot(glRef: RefObject<HTMLCanvasElement | null>): (w: number, h: number) => GpuPlot | null;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type DashboardPanel } from '../components/dashboardGridLayout';
|
|
2
|
+
import { DEFAULT_XY_POINT_RADIUS, DEFAULT_XYZ_POINT_RADIUS, type PanelChartSettings } from './panelChartSettings';
|
|
3
|
+
import type { PlotSeries } from '../types/plotSeries';
|
|
4
|
+
export { DEFAULT_XY_POINT_RADIUS, DEFAULT_XYZ_POINT_RADIUS };
|
|
5
|
+
export declare const SAVED_LAYOUT_VERSION: 9;
|
|
6
|
+
export interface Worksheet {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
panels: DashboardPanel[];
|
|
10
|
+
panelChartSettings: Record<string, PanelChartSettings>;
|
|
11
|
+
panelChartBackgrounds: Record<string, string | null>;
|
|
12
|
+
xKey: string;
|
|
13
|
+
}
|
|
14
|
+
export interface TyresPlotSavedLayout {
|
|
15
|
+
version: typeof SAVED_LAYOUT_VERSION;
|
|
16
|
+
worksheets: Worksheet[];
|
|
17
|
+
activeWorksheetId?: string;
|
|
18
|
+
panels: DashboardPanel[];
|
|
19
|
+
xKey: string;
|
|
20
|
+
/** @deprecated v7+ stores series per-panel inside `panelChartSettings`. */
|
|
21
|
+
series: PlotSeries[];
|
|
22
|
+
/** @deprecated v7+ stores addColumn per-panel inside `panelChartSettings`. */
|
|
23
|
+
addColumn: string;
|
|
24
|
+
/** @deprecated Legacy single-chart fields; superseded by `panelChartSettings` for XY / 3D panels. */
|
|
25
|
+
xyXCol: string;
|
|
26
|
+
/** @deprecated See `panelChartSettings`. */
|
|
27
|
+
xyYCol: string;
|
|
28
|
+
xyColor: string;
|
|
29
|
+
chartPlotHeight: number;
|
|
30
|
+
xyPlotHeight: number;
|
|
31
|
+
/** @deprecated Replaced by `panelChartBackgrounds`. Kept for loading old files. */
|
|
32
|
+
chartBackground: string | null;
|
|
33
|
+
/** Per-panel chart background. `null` / missing = follow app theme. */
|
|
34
|
+
panelChartBackgrounds: Record<string, string | null>;
|
|
35
|
+
/** @deprecated Use per-panel entries in `panelChartSettings`. */
|
|
36
|
+
xyPointRadius: number;
|
|
37
|
+
/** @deprecated Use per-panel entries in `panelChartSettings`. */
|
|
38
|
+
xyzPointRadius: number;
|
|
39
|
+
/** Per-panel options for multiband, X–Y scatter and 3D charts (key = panel `id`). */
|
|
40
|
+
panelChartSettings: Record<string, PanelChartSettings>;
|
|
41
|
+
}
|
|
42
|
+
/** Accept v2–v9; normalize to current shape + panel settings. */
|
|
43
|
+
export declare function parseSavedLayoutFile(v: unknown): TyresPlotSavedLayout | null;
|
|
44
|
+
/** @deprecated use parseSavedLayoutFile */
|
|
45
|
+
export declare function isTyresPlotSavedLayout(v: unknown): v is TyresPlotSavedLayout;
|