@perspective-dev/viewer-charts 4.3.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/LICENSE.md +193 -0
- package/dist/cdn/perspective-viewer-charts.js +3 -0
- package/dist/cdn/perspective-viewer-charts.js.map +7 -0
- package/dist/esm/axis/axis-primitives.d.ts +24 -0
- package/dist/esm/axis/bar-axis.d.ts +51 -0
- package/dist/esm/axis/canvas.d.ts +24 -0
- package/dist/esm/axis/categorical-axis-core.d.ts +42 -0
- package/dist/esm/axis/categorical-axis.d.ts +27 -0
- package/dist/esm/axis/facet-chrome.d.ts +13 -0
- package/dist/esm/axis/label-geometry.d.ts +41 -0
- package/dist/esm/axis/legend.d.ts +44 -0
- package/dist/esm/axis/numeric-axis.d.ts +20 -0
- package/dist/esm/charts/candlestick/candlestick-build.d.ts +129 -0
- package/dist/esm/charts/candlestick/candlestick-interact.d.ts +10 -0
- package/dist/esm/charts/candlestick/candlestick-render.d.ts +24 -0
- package/dist/esm/charts/candlestick/candlestick.d.ts +144 -0
- package/dist/esm/charts/candlestick/glyphs/draw-candlesticks.d.ts +36 -0
- package/dist/esm/charts/candlestick/glyphs/draw-ohlc.d.ts +33 -0
- package/dist/esm/charts/canvas-types.d.ts +15 -0
- package/dist/esm/charts/cartesian/cartesian-build.d.ts +14 -0
- package/dist/esm/charts/cartesian/cartesian-interact.d.ts +20 -0
- package/dist/esm/charts/cartesian/cartesian-render.d.ts +26 -0
- package/dist/esm/charts/cartesian/cartesian.d.ts +239 -0
- package/dist/esm/charts/cartesian/glyph.d.ts +53 -0
- package/dist/esm/charts/cartesian/glyphs/density.d.ts +142 -0
- package/dist/esm/charts/cartesian/glyphs/lines.d.ts +23 -0
- package/dist/esm/charts/cartesian/glyphs/points.d.ts +24 -0
- package/dist/esm/charts/cartesian/label-interner.d.ts +21 -0
- package/dist/esm/charts/cartesian/tooltip-lines.d.ts +11 -0
- package/dist/esm/charts/chart-base.d.ts +402 -0
- package/dist/esm/charts/chart.d.ts +338 -0
- package/dist/esm/charts/common/band-layout.d.ts +32 -0
- package/dist/esm/charts/common/categorical-y-chart.d.ts +53 -0
- package/dist/esm/charts/common/category-axis-resolver.d.ts +90 -0
- package/dist/esm/charts/common/chrome-cache.d.ts +18 -0
- package/dist/esm/charts/common/draw-tooltip-box.d.ts +9 -0
- package/dist/esm/charts/common/leaf-color.d.ts +33 -0
- package/dist/esm/charts/common/node-store.d.ts +81 -0
- package/dist/esm/charts/common/tree-chart.d.ts +48 -0
- package/dist/esm/charts/common/tree-chrome.d.ts +31 -0
- package/dist/esm/charts/common/tree-data.d.ts +54 -0
- package/dist/esm/charts/common/visible-extent.d.ts +51 -0
- package/dist/esm/charts/heatmap/heatmap-build.d.ts +86 -0
- package/dist/esm/charts/heatmap/heatmap-interact.d.ts +19 -0
- package/dist/esm/charts/heatmap/heatmap-render.d.ts +19 -0
- package/dist/esm/charts/heatmap/heatmap-y-axis.d.ts +46 -0
- package/dist/esm/charts/heatmap/heatmap.d.ts +117 -0
- package/dist/esm/charts/map/map.d.ts +67 -0
- package/dist/esm/charts/registry.d.ts +14 -0
- package/dist/esm/charts/series/glyphs/draw-areas.d.ts +30 -0
- package/dist/esm/charts/series/glyphs/draw-bars.d.ts +15 -0
- package/dist/esm/charts/series/glyphs/draw-lines.d.ts +34 -0
- package/dist/esm/charts/series/glyphs/draw-scatter.d.ts +33 -0
- package/dist/esm/charts/series/series-build.d.ts +228 -0
- package/dist/esm/charts/series/series-interact.d.ts +35 -0
- package/dist/esm/charts/series/series-render.d.ts +41 -0
- package/dist/esm/charts/series/series-type.d.ts +49 -0
- package/dist/esm/charts/series/series.d.ts +317 -0
- package/dist/esm/charts/sunburst/sunburst-interact.d.ts +7 -0
- package/dist/esm/charts/sunburst/sunburst-layout.d.ts +33 -0
- package/dist/esm/charts/sunburst/sunburst-render.d.ts +22 -0
- package/dist/esm/charts/sunburst/sunburst.d.ts +85 -0
- package/dist/esm/charts/treemap/treemap-interact.d.ts +12 -0
- package/dist/esm/charts/treemap/treemap-layout.d.ts +28 -0
- package/dist/esm/charts/treemap/treemap-render.d.ts +18 -0
- package/dist/esm/charts/treemap/treemap.d.ts +74 -0
- package/dist/esm/config.d.ts +27 -0
- package/dist/esm/data/lazy-row.d.ts +32 -0
- package/dist/esm/data/split-groups.d.ts +20 -0
- package/dist/esm/data/view-reader.d.ts +35 -0
- package/dist/esm/event-detail.d.ts +28 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/interaction/hit-test.d.ts +30 -0
- package/dist/esm/interaction/host-sink-dom.d.ts +19 -0
- package/dist/esm/interaction/host-sink-message.d.ts +46 -0
- package/dist/esm/interaction/lazy-tooltip.d.ts +61 -0
- package/dist/esm/interaction/raw-event-forwarder.d.ts +27 -0
- package/dist/esm/interaction/spatial-grid.d.ts +15 -0
- package/dist/esm/interaction/tooltip-controller.d.ts +193 -0
- package/dist/esm/interaction/zoom-controller.d.ts +106 -0
- package/dist/esm/interaction/zoom-router.d.ts +48 -0
- package/dist/esm/layout/facet-grid.d.ts +126 -0
- package/dist/esm/layout/plot-layout.d.ts +104 -0
- package/dist/esm/layout/ticks.d.ts +17 -0
- package/dist/esm/map/mercator.d.ts +102 -0
- package/dist/esm/map/tile-cache.d.ts +38 -0
- package/dist/esm/map/tile-layer.d.ts +66 -0
- package/dist/esm/map/tile-loader.d.ts +52 -0
- package/dist/esm/map/tile-source.d.ts +66 -0
- package/dist/esm/perspective-viewer-charts.js +3 -0
- package/dist/esm/perspective-viewer-charts.js.map +7 -0
- package/dist/esm/plugin/charts.d.ts +40 -0
- package/dist/esm/plugin/plugin.d.ts +95 -0
- package/dist/esm/render/scheduler.d.ts +41 -0
- package/dist/esm/theme/gradient.d.ts +48 -0
- package/dist/esm/theme/palette.d.ts +13 -0
- package/dist/esm/theme/theme-snapshot.d.ts +7 -0
- package/dist/esm/theme/theme.d.ts +53 -0
- package/dist/esm/transport/protocol.d.ts +430 -0
- package/dist/esm/transport/renderer-transport.d.ts +201 -0
- package/dist/esm/utils/css.d.ts +1 -0
- package/dist/esm/utils/font-snapshot.d.ts +50 -0
- package/dist/esm/webgl/buffer-pool.d.ts +62 -0
- package/dist/esm/webgl/context-manager.d.ts +184 -0
- package/dist/esm/webgl/gradient-texture.d.ts +17 -0
- package/dist/esm/webgl/instanced-attrs.d.ts +44 -0
- package/dist/esm/webgl/plot-frame.d.ts +39 -0
- package/dist/esm/webgl/program-cache.d.ts +13 -0
- package/dist/esm/webgl/shader-manifest.d.ts +53 -0
- package/dist/esm/webgl/shader-registry.d.ts +22 -0
- package/dist/esm/worker/boot.d.ts +0 -0
- package/dist/esm/worker/dispatch.d.ts +9 -0
- package/dist/esm/worker/font-loader.d.ts +2 -0
- package/dist/esm/worker/renderer.worker.d.ts +115 -0
- package/dist/esm/worker/session-host.d.ts +26 -0
- package/package.json +47 -0
- package/src/css/perspective-viewer-charts.css +95 -0
- package/src/ts/axis/axis-primitives.ts +125 -0
- package/src/ts/axis/bar-axis.ts +345 -0
- package/src/ts/axis/canvas.ts +64 -0
- package/src/ts/axis/categorical-axis-core.ts +125 -0
- package/src/ts/axis/categorical-axis.ts +716 -0
- package/src/ts/axis/facet-chrome.ts +42 -0
- package/src/ts/axis/label-geometry.ts +188 -0
- package/src/ts/axis/legend.ts +218 -0
- package/src/ts/axis/numeric-axis.ts +353 -0
- package/src/ts/charts/candlestick/candlestick-build.ts +516 -0
- package/src/ts/charts/candlestick/candlestick-interact.ts +256 -0
- package/src/ts/charts/candlestick/candlestick-render.ts +387 -0
- package/src/ts/charts/candlestick/candlestick.ts +367 -0
- package/src/ts/charts/candlestick/glyphs/draw-candlesticks.ts +432 -0
- package/src/ts/charts/candlestick/glyphs/draw-ohlc.ts +317 -0
- package/src/ts/charts/canvas-types.ts +30 -0
- package/src/ts/charts/cartesian/cartesian-build.ts +616 -0
- package/src/ts/charts/cartesian/cartesian-interact.ts +355 -0
- package/src/ts/charts/cartesian/cartesian-render.ts +948 -0
- package/src/ts/charts/cartesian/cartesian.ts +469 -0
- package/src/ts/charts/cartesian/glyph.ts +81 -0
- package/src/ts/charts/cartesian/glyphs/density.ts +1263 -0
- package/src/ts/charts/cartesian/glyphs/lines.ts +320 -0
- package/src/ts/charts/cartesian/glyphs/points.ts +239 -0
- package/src/ts/charts/cartesian/label-interner.ts +56 -0
- package/src/ts/charts/cartesian/tooltip-lines.ts +80 -0
- package/src/ts/charts/chart-base.ts +840 -0
- package/src/ts/charts/chart.ts +427 -0
- package/src/ts/charts/common/band-layout.ts +63 -0
- package/src/ts/charts/common/categorical-y-chart.ts +81 -0
- package/src/ts/charts/common/category-axis-resolver.ts +314 -0
- package/src/ts/charts/common/chrome-cache.ts +79 -0
- package/src/ts/charts/common/draw-tooltip-box.ts +84 -0
- package/src/ts/charts/common/leaf-color.ts +92 -0
- package/src/ts/charts/common/node-store.ts +235 -0
- package/src/ts/charts/common/tree-chart.ts +76 -0
- package/src/ts/charts/common/tree-chrome.ts +123 -0
- package/src/ts/charts/common/tree-data.ts +623 -0
- package/src/ts/charts/common/visible-extent.ts +112 -0
- package/src/ts/charts/heatmap/heatmap-build.ts +426 -0
- package/src/ts/charts/heatmap/heatmap-interact.ts +274 -0
- package/src/ts/charts/heatmap/heatmap-render.ts +815 -0
- package/src/ts/charts/heatmap/heatmap-y-axis.ts +351 -0
- package/src/ts/charts/heatmap/heatmap.ts +368 -0
- package/src/ts/charts/map/map.ts +201 -0
- package/src/ts/charts/registry.ts +65 -0
- package/src/ts/charts/series/glyphs/draw-areas.ts +331 -0
- package/src/ts/charts/series/glyphs/draw-bars.ts +113 -0
- package/src/ts/charts/series/glyphs/draw-lines.ts +320 -0
- package/src/ts/charts/series/glyphs/draw-scatter.ts +328 -0
- package/src/ts/charts/series/series-build.ts +848 -0
- package/src/ts/charts/series/series-interact.ts +604 -0
- package/src/ts/charts/series/series-render.ts +1109 -0
- package/src/ts/charts/series/series-type.ts +99 -0
- package/src/ts/charts/series/series.ts +794 -0
- package/src/ts/charts/sunburst/sunburst-interact.ts +460 -0
- package/src/ts/charts/sunburst/sunburst-layout.ts +238 -0
- package/src/ts/charts/sunburst/sunburst-render.ts +887 -0
- package/src/ts/charts/sunburst/sunburst.ts +248 -0
- package/src/ts/charts/treemap/treemap-interact.ts +445 -0
- package/src/ts/charts/treemap/treemap-layout.ts +328 -0
- package/src/ts/charts/treemap/treemap-render.ts +886 -0
- package/src/ts/charts/treemap/treemap.ts +247 -0
- package/src/ts/config.ts +41 -0
- package/src/ts/data/lazy-row.ts +140 -0
- package/src/ts/data/split-groups.ts +97 -0
- package/src/ts/data/view-reader.ts +107 -0
- package/src/ts/event-detail.ts +44 -0
- package/src/ts/index.ts +53 -0
- package/src/ts/interaction/hit-test.ts +106 -0
- package/src/ts/interaction/host-sink-dom.ts +85 -0
- package/src/ts/interaction/host-sink-message.ts +75 -0
- package/src/ts/interaction/lazy-tooltip.ts +102 -0
- package/src/ts/interaction/raw-event-forwarder.ts +175 -0
- package/src/ts/interaction/spatial-grid.ts +100 -0
- package/src/ts/interaction/tooltip-controller.ts +407 -0
- package/src/ts/interaction/zoom-controller.ts +468 -0
- package/src/ts/interaction/zoom-router.ts +230 -0
- package/src/ts/layout/facet-grid.ts +346 -0
- package/src/ts/layout/plot-layout.ts +277 -0
- package/src/ts/layout/ticks.ts +168 -0
- package/src/ts/map/mercator.ts +204 -0
- package/src/ts/map/tile-cache.ts +96 -0
- package/src/ts/map/tile-layer.ts +382 -0
- package/src/ts/map/tile-loader.ts +143 -0
- package/src/ts/map/tile-source.ts +156 -0
- package/src/ts/plugin/charts.ts +286 -0
- package/src/ts/plugin/plugin.ts +668 -0
- package/src/ts/render/scheduler.ts +339 -0
- package/src/ts/shaders/area.frag.glsl +20 -0
- package/src/ts/shaders/area.vert.glsl +19 -0
- package/src/ts/shaders/bar.frag.glsl +25 -0
- package/src/ts/shaders/bar.vert.glsl +60 -0
- package/src/ts/shaders/candlestick-body.frag.glsl +19 -0
- package/src/ts/shaders/candlestick-body.vert.glsl +34 -0
- package/src/ts/shaders/density-extreme.frag.glsl +30 -0
- package/src/ts/shaders/density-mrt.frag.glsl +44 -0
- package/src/ts/shaders/density-mrt.vert.glsl +48 -0
- package/src/ts/shaders/density-resolve.frag.glsl +89 -0
- package/src/ts/shaders/density-resolve.vert.glsl +23 -0
- package/src/ts/shaders/density-splat.frag.glsl +34 -0
- package/src/ts/shaders/density-splat.vert.glsl +52 -0
- package/src/ts/shaders/gridline.frag.glsl +18 -0
- package/src/ts/shaders/gridline.vert.glsl +18 -0
- package/src/ts/shaders/heatmap.frag.glsl +23 -0
- package/src/ts/shaders/heatmap.vert.glsl +42 -0
- package/src/ts/shaders/line-uniform.frag.glsl +26 -0
- package/src/ts/shaders/line-uniform.vert.glsl +54 -0
- package/src/ts/shaders/line.frag.glsl +28 -0
- package/src/ts/shaders/line.vert.glsl +87 -0
- package/src/ts/shaders/scatter.frag.glsl +39 -0
- package/src/ts/shaders/scatter.vert.glsl +67 -0
- package/src/ts/shaders/sunburst-arc.frag.glsl +19 -0
- package/src/ts/shaders/sunburst-arc.vert.glsl +79 -0
- package/src/ts/shaders/tile.frag.glsl +27 -0
- package/src/ts/shaders/tile.vert.glsl +35 -0
- package/src/ts/shaders/treemap.frag.glsl +19 -0
- package/src/ts/shaders/treemap.vert.glsl +25 -0
- package/src/ts/shaders/y-scatter.frag.glsl +30 -0
- package/src/ts/shaders/y-scatter.vert.glsl +31 -0
- package/src/ts/theme/gradient.ts +312 -0
- package/src/ts/theme/palette.ts +64 -0
- package/src/ts/theme/theme-snapshot.ts +66 -0
- package/src/ts/theme/theme.ts +166 -0
- package/src/ts/transport/protocol.ts +497 -0
- package/src/ts/transport/renderer-transport.ts +788 -0
- package/src/ts/utils/css.ts +36 -0
- package/src/ts/utils/font-snapshot.ts +159 -0
- package/src/ts/webgl/buffer-pool.ts +163 -0
- package/src/ts/webgl/context-manager.ts +414 -0
- package/src/ts/webgl/gradient-texture.ts +84 -0
- package/src/ts/webgl/instanced-attrs.ts +139 -0
- package/src/ts/webgl/plot-frame.ts +91 -0
- package/src/ts/webgl/program-cache.ts +46 -0
- package/src/ts/webgl/shader-manifest.ts +148 -0
- package/src/ts/webgl/shader-registry.ts +97 -0
- package/src/ts/worker/boot.ts +22 -0
- package/src/ts/worker/dispatch.ts +99 -0
- package/src/ts/worker/font-loader.ts +89 -0
- package/src/ts/worker/renderer.worker.ts +734 -0
- package/src/ts/worker/session-host.ts +118 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import type { View } from "@perspective-dev/client";
|
|
2
|
+
import type { ColumnDataMap } from "../data/view-reader";
|
|
3
|
+
import type { WebGLContextManager } from "../webgl/context-manager";
|
|
4
|
+
import type { ZoomController } from "../interaction/zoom-controller";
|
|
5
|
+
import type { HostSink } from "../interaction/tooltip-controller";
|
|
6
|
+
export interface ChartImplementation {
|
|
7
|
+
uploadAndRender(glManager: WebGLContextManager, columns: ColumnDataMap, startRow: number, endRow: number): void;
|
|
8
|
+
/**
|
|
9
|
+
* The single render entrypoint. Every render-triggering caller —
|
|
10
|
+
* upload chunks, zoom / pan, resize, theme invalidation,
|
|
11
|
+
* host-driven redraws — calls this. Routes through the
|
|
12
|
+
* module-level scheduler ([render/scheduler.ts]) so concurrent
|
|
13
|
+
* calls collapse to one `_fullRender` per RAF and the host
|
|
14
|
+
* blitter receives one bitmap per frame per chart.
|
|
15
|
+
*
|
|
16
|
+
* The returned promise resolves after this entry's `_fullRender`
|
|
17
|
+
* + `awaitGpuFence` + `endFrame` chain completes — independent
|
|
18
|
+
* of other charts in the same RAF, which run their fence waits
|
|
19
|
+
* in parallel.
|
|
20
|
+
*
|
|
21
|
+
* The synchronous-render bypass for `snapshotPng` (calls
|
|
22
|
+
* `_fullRender` directly, skips `endFrame`) is the only
|
|
23
|
+
* sanctioned exception and lives inside the worker renderer.
|
|
24
|
+
*/
|
|
25
|
+
requestRender(glManager: WebGLContextManager): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* The chart-specific frame builder. The scheduler wraps this with
|
|
28
|
+
* fence + `endFrame`; callers must not invoke it directly except
|
|
29
|
+
* for `snapshotPng`, which needs an intact GL backbuffer for
|
|
30
|
+
* `gl.readPixels` and so must skip the `endFrame` pair.
|
|
31
|
+
*/
|
|
32
|
+
_fullRender(glManager: WebGLContextManager): void;
|
|
33
|
+
/**
|
|
34
|
+
* Hand the current View to the chart so it can make on-demand
|
|
35
|
+
* per-row queries (for lazy tooltip column lookups). Called on
|
|
36
|
+
* every `draw`; the chart disposes any prior fetcher and clears
|
|
37
|
+
* dependent UI (pinned tooltip) so stale rows never surface.
|
|
38
|
+
*
|
|
39
|
+
* TODO: pinned tooltips are dismissed on view update today. A
|
|
40
|
+
* future enhancement is to keep a pinned tooltip visible (with its
|
|
41
|
+
* captured data) until the user dismisses it, even after the
|
|
42
|
+
* underlying view no longer contains that row.
|
|
43
|
+
*/
|
|
44
|
+
setView?(view: View): void;
|
|
45
|
+
/**
|
|
46
|
+
* Set the gridline canvas (behind WebGL, for gridlines).
|
|
47
|
+
*/
|
|
48
|
+
setGridlineCanvas?(canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
49
|
+
/**
|
|
50
|
+
* Set the chrome canvas (above WebGL, for axes/labels/legend/tooltip).
|
|
51
|
+
*/
|
|
52
|
+
setChromeCanvas?(canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
53
|
+
/**
|
|
54
|
+
* Hand the chart a pre-computed CSS-variable map produced on the
|
|
55
|
+
* main thread via `snapshotThemeVars(el)`, which it can decode into
|
|
56
|
+
* a full `Theme` without touching the DOM (charts always run inside
|
|
57
|
+
* the renderer scope, which has no `getComputedStyle`).
|
|
58
|
+
*/
|
|
59
|
+
setTheme?(vars: Record<string, string>): void;
|
|
60
|
+
/**
|
|
61
|
+
* Set the zoom controller for interactive zoom/pan.
|
|
62
|
+
*/
|
|
63
|
+
setZoomController?(zc: ZoomController): void;
|
|
64
|
+
/**
|
|
65
|
+
* Wire the chart's `TooltipController` for virtual-dispatch hover /
|
|
66
|
+
* click events forwarded from the host. The renderer drives
|
|
67
|
+
* `dispatchHover` / `dispatchLeave` / `dispatchClick` /
|
|
68
|
+
* `dispatchDblClick` from `InteractionEvent`s; the supplied
|
|
69
|
+
* `HostSink` posts pin / dismiss / setCursor intents back to the
|
|
70
|
+
* host so the resulting DOM mutations happen there (the renderer
|
|
71
|
+
* scope has no DOM in worker mode, and uses the same channel
|
|
72
|
+
* in-process for symmetry).
|
|
73
|
+
*/
|
|
74
|
+
attachTooltip?(host: HostSink): void;
|
|
75
|
+
/**
|
|
76
|
+
* Set the column slot config (with nulls for empty slots).
|
|
77
|
+
*/
|
|
78
|
+
setColumnSlots?(slots: (string | null)[]): void;
|
|
79
|
+
/**
|
|
80
|
+
* Set group_by and split_by config from the viewer.
|
|
81
|
+
*/
|
|
82
|
+
setViewPivots?(groupBy: string[], splitBy: string[]): void;
|
|
83
|
+
/**
|
|
84
|
+
* Set column type schema from the view (e.g., { "col": "date" }).
|
|
85
|
+
*/
|
|
86
|
+
setColumnTypes?(schema: Record<string, string>): void;
|
|
87
|
+
/**
|
|
88
|
+
* Set the source-column types used for `group_by` level lookups —
|
|
89
|
+
* sourced from `table.schema()` + `view.expression_schema()`. Used
|
|
90
|
+
* by categorical-axis charts to detect numeric / date / boolean
|
|
91
|
+
* group_by levels (which are not keyed in `view.schema()` because
|
|
92
|
+
* they surface as `__ROW_PATH_N__` columns).
|
|
93
|
+
*/
|
|
94
|
+
setGroupByTypes?(schema: Record<string, string>): void;
|
|
95
|
+
/**
|
|
96
|
+
* Set per-column render config (the second argument to `plugin.restore`).
|
|
97
|
+
* Key is the aggregate base name; value is an open object whose
|
|
98
|
+
* `chart_type` / `stack` fields are consumed by the Y-bar glyph router.
|
|
99
|
+
*/
|
|
100
|
+
setColumnsConfig?(cfg: Record<string, any>): void;
|
|
101
|
+
/**
|
|
102
|
+
* Set the plugin's default glyph type. Used by the Y-series chart
|
|
103
|
+
* family (Y Bar / Y Line / Y Scatter / Y Area): each tag is the same
|
|
104
|
+
* `BarChart` impl with a different starting `chart_type` applied to
|
|
105
|
+
* columns that lack an explicit entry in `columns_config`.
|
|
106
|
+
*/
|
|
107
|
+
setDefaultChartType?(chartType: string): void;
|
|
108
|
+
/**
|
|
109
|
+
* Set the faceting config: one small-multiple sub-plot per
|
|
110
|
+
* `split_by` group, optional shared axes, coordinated tooltip, and
|
|
111
|
+
* zoom routing mode. Seeded from `DEFAULT_FACET_CONFIG` at init;
|
|
112
|
+
* `plugin_config.facet_mode` / `facet_zoom_mode` override the
|
|
113
|
+
* matching fields via `AbstractChart.setPluginConfig`.
|
|
114
|
+
*/
|
|
115
|
+
setFacetConfig?(cfg: FacetConfig): void;
|
|
116
|
+
/**
|
|
117
|
+
* Set the plugin-scoped global configuration — the values backing
|
|
118
|
+
* `plugin_config_schema` / `plugin_config` in `restore`. Replaces
|
|
119
|
+
* the previous module-level constants (`LINE_WIDTH_PX`,
|
|
120
|
+
* `POINT_SIZE_PX`, `BAND_INNER_FRAC`, `BAR_INNER_PAD`,
|
|
121
|
+
* `WICK_WIDTH_PX`, `OHLC_LINE_WIDTH_PX`, `AUTO_ALT_Y_AXIS`) plus
|
|
122
|
+
* the faceted/series zoom-mode semantics described in
|
|
123
|
+
* {@link PluginConfig}.
|
|
124
|
+
*/
|
|
125
|
+
setPluginConfig?(cfg: PluginConfig): void;
|
|
126
|
+
/**
|
|
127
|
+
* Drop any cached theme values so the next render re-reads CSS
|
|
128
|
+
* variables. Driven from `plugin.restyle()`.
|
|
129
|
+
*/
|
|
130
|
+
invalidateTheme?(): void;
|
|
131
|
+
/**
|
|
132
|
+
* Clear the `domain_mode: "expand"` accumulator state so the next
|
|
133
|
+
* data load starts from the current data extent. Driven from
|
|
134
|
+
* `resetAllZooms` (the user clicked "Reset Zoom"). View-config
|
|
135
|
+
* mutations route through `AbstractChart`'s `setColumnSlots` /
|
|
136
|
+
* `setViewPivots` / `setColumnTypes` setters, which call the same
|
|
137
|
+
* hook internally.
|
|
138
|
+
*/
|
|
139
|
+
resetExpandedDomain?(): void;
|
|
140
|
+
destroy(): void;
|
|
141
|
+
}
|
|
142
|
+
export interface FacetConfig {
|
|
143
|
+
/**
|
|
144
|
+
* "grid" = small multiples (default); "overlay" = legacy single-plot.
|
|
145
|
+
*/
|
|
146
|
+
facet_mode: "grid" | "overlay";
|
|
147
|
+
/**
|
|
148
|
+
* Share one bottom X axis across all columns of facets.
|
|
149
|
+
*/
|
|
150
|
+
shared_x_axis: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Share one left Y axis across all rows of facets.
|
|
153
|
+
*/
|
|
154
|
+
shared_y_axis: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Paint a tooltip in every facet (otherwise only the source facet).
|
|
157
|
+
*/
|
|
158
|
+
coordinated_tooltip: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* "shared" = one viewport for all facets; "independent" = per-facet.
|
|
161
|
+
*/
|
|
162
|
+
zoom_mode: "shared" | "independent";
|
|
163
|
+
/**
|
|
164
|
+
* Pixel gap between adjacent facet cells in grid mode.
|
|
165
|
+
*/
|
|
166
|
+
facet_padding: number;
|
|
167
|
+
}
|
|
168
|
+
export declare const DEFAULT_FACET_CONFIG: FacetConfig;
|
|
169
|
+
/**
|
|
170
|
+
* Plugin-scoped global configuration — the user-facing settings backing
|
|
171
|
+
* `plugin_config_schema()` / the `plugin_config` slot in `restore`.
|
|
172
|
+
*
|
|
173
|
+
* Each chart type's `plugin_config_schema` returns only the fields that
|
|
174
|
+
* are applicable for that chart (see `applicable_plugin_fields` on
|
|
175
|
+
* `ChartTypeConfig`); inapplicable fields are hidden in the UI. The
|
|
176
|
+
* chart impl receives the full struct on `setPluginConfig` and reads
|
|
177
|
+
* only the fields its render / build pipeline cares about.
|
|
178
|
+
*
|
|
179
|
+
* Some fields overlap with {@link FacetConfig} (`facet_mode`,
|
|
180
|
+
* `facet_zoom_mode`); the base `AbstractChart.setPluginConfig` syncs
|
|
181
|
+
* those onto `_facetConfig` so deep render code keeps reading the
|
|
182
|
+
* single facet struct it already does. `series_zoom_mode` toggles the
|
|
183
|
+
* categorical-Y chart base's `_autoFitValue` flag.
|
|
184
|
+
*/
|
|
185
|
+
export interface PluginConfig {
|
|
186
|
+
/**
|
|
187
|
+
* Auto-detect Y dual-axis splits when aggregate magnitudes differ
|
|
188
|
+
* by more than `DUAL_Y_RATIO_THRESHOLD`×. Series charts only.
|
|
189
|
+
* Replaces the `AUTO_ALT_Y_AXIS` compile-time toggle.
|
|
190
|
+
*/
|
|
191
|
+
auto_alt_y_axis: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Faceting strategy when `split_by` is non-empty.
|
|
194
|
+
*
|
|
195
|
+
* - `"grid"` — one small-multiple sub-plot per split group.
|
|
196
|
+
* - `"overlay"` — single plot with split groups differentiated by
|
|
197
|
+
* color. Synced into `_facetConfig.facet_mode`.
|
|
198
|
+
*/
|
|
199
|
+
facet_mode: "grid" | "overlay";
|
|
200
|
+
/**
|
|
201
|
+
* Faceted-cartesian zoom routing. `"shared"` — one viewport across
|
|
202
|
+
* all facets; `"independent"` — wheel/pan routes to the facet under
|
|
203
|
+
* the cursor with its own viewport. Synced into
|
|
204
|
+
* `_facetConfig.zoom_mode`.
|
|
205
|
+
*/
|
|
206
|
+
facet_zoom_mode: "shared" | "independent";
|
|
207
|
+
/**
|
|
208
|
+
* Series-chart value-axis behavior on zoom.
|
|
209
|
+
*
|
|
210
|
+
* - `"dynamic"` — value axis refits to the visible categorical
|
|
211
|
+
* slice (current default; `CategoricalYChart._autoFitValue` =
|
|
212
|
+
* true).
|
|
213
|
+
* - `"fixed"` — value axis stays pinned to the full-data extent.
|
|
214
|
+
*/
|
|
215
|
+
series_zoom_mode: "fixed" | "dynamic";
|
|
216
|
+
/**
|
|
217
|
+
* Anchor the value axis to zero — when true, `0` is forced into
|
|
218
|
+
* the rendered domain even if all data sits well above or below
|
|
219
|
+
* it. Natural for bar / area glyphs (which grow from the zero
|
|
220
|
+
* baseline) and surprising for line / scatter (where the
|
|
221
|
+
* interesting variation often lives far from zero). Per-chart-type
|
|
222
|
+
* defaults route through `ChartTypeConfig.plugin_field_defaults`:
|
|
223
|
+
* `true` for Y Bar / Y Area / X Bar, `false` elsewhere.
|
|
224
|
+
*/
|
|
225
|
+
include_zero: boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Domain accumulation policy across successive `View` updates.
|
|
228
|
+
*
|
|
229
|
+
* - `"fit"` — every update recomputes the rendered domain (and on
|
|
230
|
+
* cartesian charts, the X/Y range and color/size scales) from
|
|
231
|
+
* the current data extent. Can grow or shrink frame-to-frame.
|
|
232
|
+
* - `"expand"` — the rendered domain monotonically *grows*: each
|
|
233
|
+
* update unions the new data extent with the previously rendered
|
|
234
|
+
* extent, so once a value is in scope it stays in scope. Reset
|
|
235
|
+
* by the "Reset Zoom" button, view-config changes (group_by /
|
|
236
|
+
* split_by / column-slot / column-type), or toggling back to
|
|
237
|
+
* `"fit"`.
|
|
238
|
+
*/
|
|
239
|
+
domain_mode: "fit" | "expand";
|
|
240
|
+
/**
|
|
241
|
+
* Width of polyline glyphs in CSS pixels (multiplied by DPR at GL
|
|
242
|
+
* upload). Replaces the duplicated `LINE_WIDTH_PX` constants in
|
|
243
|
+
* the cartesian + series line glyphs.
|
|
244
|
+
*/
|
|
245
|
+
line_width_px: number;
|
|
246
|
+
/**
|
|
247
|
+
* Diameter of scatter point glyphs in CSS pixels. Replaces
|
|
248
|
+
* `POINT_SIZE_PX`.
|
|
249
|
+
*/
|
|
250
|
+
point_size_px: number;
|
|
251
|
+
/**
|
|
252
|
+
* Fraction of each category band occupied by its slot(s). Replaces
|
|
253
|
+
* `BAND_INNER_FRAC`. Affects buffer contents — takes effect on
|
|
254
|
+
* next data load.
|
|
255
|
+
*/
|
|
256
|
+
band_inner_frac: number;
|
|
257
|
+
/**
|
|
258
|
+
* Relative inner padding between adjacent slots within a band.
|
|
259
|
+
* Replaces `BAR_INNER_PAD`. Affects buffer contents — takes effect
|
|
260
|
+
* on next data load.
|
|
261
|
+
*/
|
|
262
|
+
bar_inner_pad: number;
|
|
263
|
+
/**
|
|
264
|
+
* Candlestick wick stroke width in CSS pixels. Replaces
|
|
265
|
+
* `WICK_WIDTH_PX`.
|
|
266
|
+
*/
|
|
267
|
+
wick_width_px: number;
|
|
268
|
+
/**
|
|
269
|
+
* OHLC bar stroke width in CSS pixels. Replaces
|
|
270
|
+
* `OHLC_LINE_WIDTH_PX`.
|
|
271
|
+
*/
|
|
272
|
+
ohlc_line_width_px: number;
|
|
273
|
+
/**
|
|
274
|
+
* density splat radius in CSS pixels. Each data point is
|
|
275
|
+
* rasterized as a soft disk of this radius into the accumulation
|
|
276
|
+
* FBO before the gradient LUT pass resolves to a heat color.
|
|
277
|
+
*/
|
|
278
|
+
gradient_radius_px: number;
|
|
279
|
+
/**
|
|
280
|
+
* density per-splat intensity multiplier. Controls how
|
|
281
|
+
* fast the density grows when points overlap (low values produce
|
|
282
|
+
* a smoother, more diffuse field; high values produce sharper
|
|
283
|
+
* peaks).
|
|
284
|
+
*/
|
|
285
|
+
gradient_intensity: number;
|
|
286
|
+
/**
|
|
287
|
+
* density clamp on the maximum accumulated heat used for
|
|
288
|
+
* the gradient-LUT lookup. Lower values saturate sooner (more of
|
|
289
|
+
* the LUT's hot stops show up); higher values stay cooler. In
|
|
290
|
+
* every mode this controls the alpha (intensity) ramp; in
|
|
291
|
+
* `density` mode it also drives the hue, and in `signed` mode it
|
|
292
|
+
* scales the signed-sum-to-hue mapping.
|
|
293
|
+
*/
|
|
294
|
+
gradient_heat_max: number;
|
|
295
|
+
/**
|
|
296
|
+
* density color-reduction mode. Controls how each pixel's
|
|
297
|
+
* stack of overlapping splats is reduced to a single LUT-t / alpha
|
|
298
|
+
* pair in the resolve pass.
|
|
299
|
+
*
|
|
300
|
+
* - `mean` (default) — hue is the density-weighted average of
|
|
301
|
+
* per-point color-t. Reads as "the typical color-column value
|
|
302
|
+
* in this region." Uses robust (5th/95th-percentile) bounds so
|
|
303
|
+
* one outlier can't compress the rest of the data toward the
|
|
304
|
+
* gradient midpoint.
|
|
305
|
+
* - `density` — ignore the color column even when wired; hue and
|
|
306
|
+
* alpha both follow density. Reads as "where do points cluster."
|
|
307
|
+
* Useful when the color column is attached for tooltip lookup
|
|
308
|
+
* only.
|
|
309
|
+
* - `extreme` — keep the per-pixel maximum signed deviation of
|
|
310
|
+
* `t - 0.5` (split into positive and negative channels, MAX-
|
|
311
|
+
* blended). Reads as "where are the outliers." Density still
|
|
312
|
+
* drives alpha so a single-point extreme fades naturally.
|
|
313
|
+
* Requires a second framebuffer; uses MRT on WebGL2 hardware
|
|
314
|
+
* with `OES_draw_buffers_indexed`, two passes otherwise.
|
|
315
|
+
* - `signed` — accumulate signed `t - 0.5` and let positive vs
|
|
316
|
+
* negative cancel out. Reads as "net positive vs net negative
|
|
317
|
+
* in each region." Requires a float-capable framebuffer; on
|
|
318
|
+
* `UNSIGNED_BYTE` fallback hardware degrades silently to
|
|
319
|
+
* `mean` with a one-line console warning.
|
|
320
|
+
*/
|
|
321
|
+
gradient_color_mode: "mean" | "density" | "extreme" | "signed";
|
|
322
|
+
/**
|
|
323
|
+
* Map basemap tile provider. Applies only to map plugin tags
|
|
324
|
+
* (`map-scatter`, `map-line`, `map-density`). Cartesian charts
|
|
325
|
+
* ignore the field. Surfaced as an enum on the settings panel so
|
|
326
|
+
* users can switch light/dark/voyager without writing custom
|
|
327
|
+
* tile-source code.
|
|
328
|
+
*/
|
|
329
|
+
map_tile_provider: "carto-positron" | "carto-dark-matter" | "carto-voyager";
|
|
330
|
+
/**
|
|
331
|
+
* Map basemap alpha (0..1). Pre-multiplied into the tile fragment
|
|
332
|
+
* shader's output so the chart's glyph layer composites over a
|
|
333
|
+
* dimmer or brighter version of the basemap. `1.0` (default)
|
|
334
|
+
* shows the tiles at full opacity.
|
|
335
|
+
*/
|
|
336
|
+
map_tile_alpha: number;
|
|
337
|
+
}
|
|
338
|
+
export declare const DEFAULT_PLUGIN_CONFIG: PluginConfig;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared per-category band geometry used by categorical-X charts (bar,
|
|
3
|
+
* candlestick, ohlc). The category axis uses unit-wide bands centered
|
|
4
|
+
* on integer indices; within each band, `numSlots` rectangles (bars,
|
|
5
|
+
* candles, …) are laid out side by side with a small inner padding.
|
|
6
|
+
*/
|
|
7
|
+
export interface SlotGeometry {
|
|
8
|
+
/**
|
|
9
|
+
* Width (in data-space units) of a single slot.
|
|
10
|
+
*/
|
|
11
|
+
slotWidth: number;
|
|
12
|
+
/**
|
|
13
|
+
* Half the drawable width of each slot after inner padding.
|
|
14
|
+
*/
|
|
15
|
+
halfWidth: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Compute slot geometry for `numSlots` rectangles per category band.
|
|
19
|
+
*
|
|
20
|
+
* `bandInnerFrac` is the fraction of each category's band width
|
|
21
|
+
* actually covered by slots; `barInnerPad` is the relative padding
|
|
22
|
+
* between adjacent slots within a band. Both come from
|
|
23
|
+
* {@link PluginConfig.band_inner_frac} / `bar_inner_pad`. Defaults
|
|
24
|
+
* match the previous hard-coded constants (0.5 / 0.1).
|
|
25
|
+
*/
|
|
26
|
+
export declare function computeSlotGeometry(numSlots: number, bandInnerFrac?: number, barInnerPad?: number): SlotGeometry;
|
|
27
|
+
/**
|
|
28
|
+
* X-center for slot `slotIdx` of `numSlots` in the band centered at
|
|
29
|
+
* `catIdx`. Matches bar's layout: slot 0 on the far left, numSlots-1 on
|
|
30
|
+
* the far right, symmetric about `catIdx`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function slotCenter(catIdx: number, slotIdx: number, numSlots: number, slotWidth: number): number;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { PlotLayout } from "../../layout/plot-layout";
|
|
2
|
+
import type { AxisDomain } from "../../axis/numeric-axis";
|
|
3
|
+
import type { CategoricalDomain, CategoricalLevel } from "../../axis/categorical-axis";
|
|
4
|
+
import type { ZoomConfig } from "../../interaction/zoom-controller";
|
|
5
|
+
import { AbstractChart } from "../chart-base";
|
|
6
|
+
/**
|
|
7
|
+
* Common base for charts with a categorical X axis, a numeric Y (value)
|
|
8
|
+
* axis, and an optional zoom-on-categorical interaction. Today that's
|
|
9
|
+
* Bar (all four Y-family plugins + X Bar) and Candlestick/OHLC.
|
|
10
|
+
*
|
|
11
|
+
* The class is deliberately thin: it consolidates the bookkeeping that
|
|
12
|
+
* genuinely repeats across those chart families (categorical domain
|
|
13
|
+
* state, last-frame cache for overlay-only redraws, value-axis lock
|
|
14
|
+
* default, shared GL-program + corner-buffer fields) and nothing more.
|
|
15
|
+
* Glyph rendering, hit-testing, build pipelines, and horizontal / dual-
|
|
16
|
+
* axis variance live in the concrete subclasses because they diverge
|
|
17
|
+
* too much to usefully share.
|
|
18
|
+
*/
|
|
19
|
+
export declare abstract class CategoricalYChart extends AbstractChart {
|
|
20
|
+
/**
|
|
21
|
+
* Row-path levels (group_by hierarchy) for X-axis tick rendering.
|
|
22
|
+
*/
|
|
23
|
+
_rowPaths: CategoricalLevel[];
|
|
24
|
+
/**
|
|
25
|
+
* Number of categories on the X axis.
|
|
26
|
+
*/
|
|
27
|
+
_numCategories: number;
|
|
28
|
+
/**
|
|
29
|
+
* Offset into the aggregated-row stream (total-rows are skipped).
|
|
30
|
+
*/
|
|
31
|
+
_rowOffset: number;
|
|
32
|
+
_program: WebGLProgram | null;
|
|
33
|
+
_cornerBuffer: WebGLBuffer | null;
|
|
34
|
+
_lastLayout: PlotLayout | null;
|
|
35
|
+
_lastXDomain: CategoricalDomain | null;
|
|
36
|
+
_lastYDomain: AxisDomain | null;
|
|
37
|
+
_lastYTicks: number[] | null;
|
|
38
|
+
/**
|
|
39
|
+
* When true, the value axis refits to the visible categorical
|
|
40
|
+
* window each frame — so zooming the categorical axis tightens the
|
|
41
|
+
* value axis to just the bars / candles in view. Subclasses own
|
|
42
|
+
* the per-frame cache object because the cache key shape varies
|
|
43
|
+
* (bar needs `hiddenSeries`, candlestick doesn't; bar may have
|
|
44
|
+
* dual-axis extents, candlestick is single-axis).
|
|
45
|
+
*/
|
|
46
|
+
_autoFitValue: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Lock the value axis by default — user wheel/pan should only
|
|
49
|
+
* scroll the categorical axis. Subclasses override to flip
|
|
50
|
+
* orientation (e.g. X Bar where the value axis is on X).
|
|
51
|
+
*/
|
|
52
|
+
protected getZoomConfig(): ZoomConfig;
|
|
53
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { ColumnDataMap, ColumnData } from "../../data/view-reader";
|
|
2
|
+
import type { CategoricalLevel } from "../../axis/categorical-axis";
|
|
3
|
+
export interface CategoryAxisResult {
|
|
4
|
+
/**
|
|
5
|
+
* Fully materialized hierarchical levels — labels and group runs are
|
|
6
|
+
* pre-resolved from the view's `__ROW_PATH_N__` dictionaries (or
|
|
7
|
+
* synthesized for non-string levels) so the chart can retain them
|
|
8
|
+
* past the `with_typed_arrays` callback scope. Empty when `groupBy`
|
|
9
|
+
* is empty.
|
|
10
|
+
*/
|
|
11
|
+
rowPaths: CategoricalLevel[];
|
|
12
|
+
/**
|
|
13
|
+
* Rows that actually contribute a category (post-offset).
|
|
14
|
+
*/
|
|
15
|
+
numCategories: number;
|
|
16
|
+
/**
|
|
17
|
+
* Leading rows skipped; callers use this to rebase per-row indices.
|
|
18
|
+
*/
|
|
19
|
+
rowOffset: number;
|
|
20
|
+
}
|
|
21
|
+
export type AxisMode = {
|
|
22
|
+
mode: "category";
|
|
23
|
+
} | {
|
|
24
|
+
mode: "numeric";
|
|
25
|
+
numericType: "date" | "datetime" | "integer" | "float";
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Numeric category-axis state. Shared across bar / candlestick / heatmap
|
|
29
|
+
* pipelines: when an axis is driven by exactly one non-string group_by /
|
|
30
|
+
* split_by level, glyphs anchor at real data values via `categoryPositions`
|
|
31
|
+
* and the chrome renders a numeric (date-aware) tick row.
|
|
32
|
+
*/
|
|
33
|
+
export interface NumericCategoryDomain {
|
|
34
|
+
min: number;
|
|
35
|
+
max: number;
|
|
36
|
+
isDate: boolean;
|
|
37
|
+
label: string;
|
|
38
|
+
/**
|
|
39
|
+
* Data-unit width of one category band, from min adjacent delta.
|
|
40
|
+
*/
|
|
41
|
+
bandWidth: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Compute `categoryPositions` (per-row real data values) plus a
|
|
45
|
+
* `NumericCategoryDomain` summarizing min/max/bandWidth for a numeric
|
|
46
|
+
* row-path column. `bandWidth` falls back to the full domain when there
|
|
47
|
+
* are <2 distinct positions. Pivot rows for a single group_by come ASC
|
|
48
|
+
* by default, so a forward sweep for `minDelta` is sufficient.
|
|
49
|
+
*
|
|
50
|
+
* Returns `null` when the row-path column is missing or carries no
|
|
51
|
+
* `values` array (e.g. dictionary-encoded string column).
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveNumericCategoryDomain(rpValues: ArrayLike<number> | null | undefined, numCategories: number, rowOffset: number, label: string, isDate: boolean): {
|
|
54
|
+
categoryPositions: Float64Array;
|
|
55
|
+
numericCategoryDomain: NumericCategoryDomain;
|
|
56
|
+
} | null;
|
|
57
|
+
/**
|
|
58
|
+
* Decide whether the categorical axis should render as a stringified
|
|
59
|
+
* category axis or a true numeric axis. Numeric mode is only used when
|
|
60
|
+
* there is exactly one `group_by` level AND that level is a non-string,
|
|
61
|
+
* non-boolean numeric type. Boolean and any multi-level case → category.
|
|
62
|
+
*/
|
|
63
|
+
export declare function resolveAxisMode(groupBy: string[], groupByTypes: Record<string, string>): AxisMode;
|
|
64
|
+
/**
|
|
65
|
+
* Synthesize a `(indices, dictionary)` pair from a non-string row-path
|
|
66
|
+
* column so the rest of the categorical axis machinery (label
|
|
67
|
+
* pre-resolution, run-length encoding) can run unchanged. The dictionary
|
|
68
|
+
* uses `""` at index 0 as the rollup-row sentinel — this preserves the
|
|
69
|
+
* existing skip-rollup loop's `s !== ""` check.
|
|
70
|
+
*/
|
|
71
|
+
export declare function synthesizeStringLevel(rp: ColumnData, numRows: number, levelType: string): {
|
|
72
|
+
indices: Int32Array;
|
|
73
|
+
dictionary: string[];
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Resolve the category axis for a categorical-X chart (bar, candlestick,
|
|
77
|
+
* ohlc, …). Walks the `__ROW_PATH_N__` hierarchy columns, skips the
|
|
78
|
+
* rollup rows at the top ("Total" parent aggregates), and returns fully
|
|
79
|
+
* JS-owned level structures (precomputed labels + runs) plus the
|
|
80
|
+
* trimmed category count.
|
|
81
|
+
*
|
|
82
|
+
* Non-string row-path columns (date / datetime / integer / float /
|
|
83
|
+
* boolean group_by levels) are stringified into a synthetic dictionary
|
|
84
|
+
* so the downstream label / run-length machinery is type-agnostic.
|
|
85
|
+
*
|
|
86
|
+
* When `groupByLen === 0`, there are no row-path columns and the
|
|
87
|
+
* category axis falls back to the raw row index — callers infer that
|
|
88
|
+
* from `rowPaths.length === 0`.
|
|
89
|
+
*/
|
|
90
|
+
export declare function resolveCategoryAxis(columns: ColumnDataMap, numRows: number, groupByLen: number, levelTypes?: string[]): CategoryAxisResult;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Canvas2D, Context2D } from "../canvas-types";
|
|
2
|
+
export interface ChromeCacheChart {
|
|
3
|
+
_chromeCanvas: Canvas2D | null;
|
|
4
|
+
_chromeCache: ImageBitmap | null;
|
|
5
|
+
_chromeCacheDirty: boolean;
|
|
6
|
+
_chromeCacheGen: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Run the static-chrome cache pattern shared by sunburst + treemap.
|
|
10
|
+
* Resizes the canvas, paints the static layer (and snapshots it as an
|
|
11
|
+
* `ImageBitmap`) when dirty, otherwise blits the cache; then runs the
|
|
12
|
+
* caller-provided overlay layer for hover/highlight state.
|
|
13
|
+
*
|
|
14
|
+
* Returns the prepared `ctx` already in DPR-scaled space so the overlay
|
|
15
|
+
* callback can paint in CSS pixels — except `null` if either the canvas
|
|
16
|
+
* is missing a 2D context or the chart has nothing to paint.
|
|
17
|
+
*/
|
|
18
|
+
export declare function withChromeCache(chart: ChromeCacheChart, canvas: Canvas2D, dpr: number, cssWidth: number, cssHeight: number, drawStatic: (ctx: Context2D) => void, drawOverlay: ((ctx: Context2D) => void) | null): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Context2D } from "../canvas-types";
|
|
2
|
+
import type { Theme } from "../../theme/theme";
|
|
3
|
+
/**
|
|
4
|
+
* Draw a freestanding tooltip box anchored near (cx, cy), measuring
|
|
5
|
+
* lines, sizing/clamping the box, painting bg/border, and laying out
|
|
6
|
+
* text rows. Shared by sunburst + treemap which need a non-PlotLayout
|
|
7
|
+
* anchor.
|
|
8
|
+
*/
|
|
9
|
+
export declare function drawTooltipBox(ctx: Context2D, theme: Theme, lines: string[], cx: number, cy: number, cssWidth: number, cssHeight: number, fontFamily: string): void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { TreeChartBase } from "./tree-chart";
|
|
2
|
+
import type { Vec3 } from "../../theme/palette";
|
|
3
|
+
import { type GradientStop } from "../../theme/gradient";
|
|
4
|
+
/**
|
|
5
|
+
* Perceptual luminance for a 0..1 RGB triple. Used by tree-chart label
|
|
6
|
+
* painters to pick a contrasting text color over each leaf's fill.
|
|
7
|
+
*/
|
|
8
|
+
export declare function luminance(r: number, g: number, b: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* Sample a gradient and drop the alpha channel. Treemap / sunburst
|
|
11
|
+
* fills carry alpha separately (see {@link leafRGBA}); this is the
|
|
12
|
+
* "just give me the RGB" entry point.
|
|
13
|
+
*/
|
|
14
|
+
export declare function sampleRGB(stops: GradientStop[], t: number): [number, number, number];
|
|
15
|
+
/**
|
|
16
|
+
* Resolve a leaf's fill color according to the chart's color mode:
|
|
17
|
+
* - `"numeric"` — sign-aware gradient sample via `colorValueToT`.
|
|
18
|
+
* - `"series"` / `"empty"` — discrete palette lookup keyed by the
|
|
19
|
+
* node's `colorLabel` (composite of group_by levels in series mode;
|
|
20
|
+
* `""` in empty mode, which maps to `palette[0]`).
|
|
21
|
+
*
|
|
22
|
+
* Returns RGB only; the alpha channel is applied separately by
|
|
23
|
+
* {@link leafRGBA} using `negativeAlpha` for leaves whose raw size was
|
|
24
|
+
* negative.
|
|
25
|
+
*/
|
|
26
|
+
export declare function leafColor(chart: TreeChartBase, nodeId: number, stops: GradientStop[], palette: Vec3[]): [number, number, number];
|
|
27
|
+
/**
|
|
28
|
+
* `leafColor` + an alpha channel. Negative-size leaves receive
|
|
29
|
+
* `negativeAlpha` (mirrors `theme.areaOpacity` for area charts) so
|
|
30
|
+
* they stay visually distinguishable from positive leaves without
|
|
31
|
+
* disappearing.
|
|
32
|
+
*/
|
|
33
|
+
export declare function leafRGBA(chart: TreeChartBase, nodeId: number, stops: GradientStop[], palette: Vec3[], negativeAlpha: number): [number, number, number, number];
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Struct-of-arrays storage for a hierarchical tree (treemap + sunburst).
|
|
3
|
+
* A node is a numeric `id` into parallel typed arrays; hot numeric
|
|
4
|
+
* fields live in `Float32Array` / `Int32Array` so iteration is
|
|
5
|
+
* cache-linear and heap pressure stays flat.
|
|
6
|
+
*
|
|
7
|
+
* Children are a singly-linked list per parent (`firstChild` /
|
|
8
|
+
* `nextSibling`, with `lastChild` for O(1) append). The `NULL_NODE = -1`
|
|
9
|
+
* sentinel marks "no node" for `parent`, end-of-list for `nextSibling`,
|
|
10
|
+
* and "leaf" for `firstChild`.
|
|
11
|
+
*
|
|
12
|
+
* Layout fields come in two flavors:
|
|
13
|
+
* - `x0 / y0 / x1 / y1` — rectangular coords (treemap, future bar
|
|
14
|
+
* hierarchies)
|
|
15
|
+
* - `a0 / a1 / r0 / r1` — polar coords (sunburst)
|
|
16
|
+
* Each chart populates only its own flavor; the other set wastes ~16 B
|
|
17
|
+
* per node (32 MB at 2M nodes) — a small price for keeping a single
|
|
18
|
+
* unified store across hierarchical chart types.
|
|
19
|
+
*
|
|
20
|
+
* At typical tree shapes the SOA + linked-list representation is ~10×
|
|
21
|
+
* cheaper on heap and ~4× faster to build than per-node `Object` +
|
|
22
|
+
* `Array<Child>` (which allocates ~300 B / node and is O(N²) for naive
|
|
23
|
+
* child-name lookup). At 2M nodes the former OOMs the tab; the latter
|
|
24
|
+
* stays under 100 MB.
|
|
25
|
+
*/
|
|
26
|
+
export declare const NULL_NODE = -1;
|
|
27
|
+
export declare class NodeStore {
|
|
28
|
+
size: Float32Array;
|
|
29
|
+
value: Float32Array;
|
|
30
|
+
colorValue: Float32Array;
|
|
31
|
+
/**
|
|
32
|
+
* Sign of the leaf's raw size column value: `-1` when the source row
|
|
33
|
+
* was negative, `1` otherwise. `size` itself always stores the
|
|
34
|
+
* magnitude so layout code continues to treat negatives as positive
|
|
35
|
+
* area; render code uses `sizeSign` to apply a lower alpha on
|
|
36
|
+
* negative leaves. Always `1` for branches.
|
|
37
|
+
*/
|
|
38
|
+
sizeSign: Int8Array;
|
|
39
|
+
x0: Float32Array;
|
|
40
|
+
y0: Float32Array;
|
|
41
|
+
x1: Float32Array;
|
|
42
|
+
y1: Float32Array;
|
|
43
|
+
a0: Float32Array;
|
|
44
|
+
a1: Float32Array;
|
|
45
|
+
r0: Float32Array;
|
|
46
|
+
r1: Float32Array;
|
|
47
|
+
depth: Int32Array;
|
|
48
|
+
parent: Int32Array;
|
|
49
|
+
firstChild: Int32Array;
|
|
50
|
+
nextSibling: Int32Array;
|
|
51
|
+
lastChild: Int32Array;
|
|
52
|
+
childCount: Int32Array;
|
|
53
|
+
leafRowIdx: Int32Array;
|
|
54
|
+
name: string[];
|
|
55
|
+
colorLabel: string[];
|
|
56
|
+
count: number;
|
|
57
|
+
capacity: number;
|
|
58
|
+
constructor(initialCapacity?: number);
|
|
59
|
+
reset(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Reserve a new node id. Caller must immediately initialize the
|
|
62
|
+
* hot numeric fields and set `parent` / `depth`; topology fields
|
|
63
|
+
* default to `NULL_NODE`.
|
|
64
|
+
*/
|
|
65
|
+
allocate(): number;
|
|
66
|
+
/**
|
|
67
|
+
* O(1) append `childId` as the last child of `parentId`.
|
|
68
|
+
*/
|
|
69
|
+
appendChild(parentId: number, childId: number): void;
|
|
70
|
+
/**
|
|
71
|
+
* `true` if the node has no children (branches set firstChild when they acquire one).
|
|
72
|
+
*/
|
|
73
|
+
isLeaf(id: number): boolean;
|
|
74
|
+
private _allocate;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Walk the ancestor chain back to (but not including) the synthetic
|
|
78
|
+
* root, topmost first. Allocates a fresh string array — callers that
|
|
79
|
+
* care about allocations should inline the walk.
|
|
80
|
+
*/
|
|
81
|
+
export declare function ancestorNames(store: NodeStore, id: number): string[];
|