@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,126 @@
|
|
|
1
|
+
import { PlotLayout, type PlotRect } from "./plot-layout";
|
|
2
|
+
/**
|
|
3
|
+
* Tri-state axis mode.
|
|
4
|
+
*
|
|
5
|
+
* - `"outer"` — one shared axis band reserved at the grid edge;
|
|
6
|
+
* `outerXAxisRect` / `outerYAxisRect` populated, per-cell gutter
|
|
7
|
+
* collapsed to 0 on that side. Caller paints the shared axis
|
|
8
|
+
* once per frame using the grid's outer rect.
|
|
9
|
+
* - `"cell"` — every cell reserves its own gutter on that side;
|
|
10
|
+
* caller paints one axis per cell. Outer rect is undefined.
|
|
11
|
+
* - `"none"` — no gutter anywhere on that side: neither an outer
|
|
12
|
+
* band nor a per-cell reservation. Intended for chart types with
|
|
13
|
+
* no numeric axis at all (treemap, sunburst). When BOTH axes are
|
|
14
|
+
* `"none"` cells are also made flush on the right so adjacent
|
|
15
|
+
* plot rects share a boundary.
|
|
16
|
+
*
|
|
17
|
+
* Defaults to `"cell"` when undefined.
|
|
18
|
+
*/
|
|
19
|
+
export type AxisMode = "outer" | "cell" | "none";
|
|
20
|
+
export interface FacetGridOptions {
|
|
21
|
+
cssWidth: number;
|
|
22
|
+
cssHeight: number;
|
|
23
|
+
/**
|
|
24
|
+
* See {@link AxisMode}. Default `"cell"`.
|
|
25
|
+
*/
|
|
26
|
+
xAxis?: AxisMode;
|
|
27
|
+
/**
|
|
28
|
+
* See {@link AxisMode}. Default `"cell"`.
|
|
29
|
+
*/
|
|
30
|
+
yAxis?: AxisMode;
|
|
31
|
+
/**
|
|
32
|
+
* Reserve a right gutter for a single shared legend.
|
|
33
|
+
*/
|
|
34
|
+
hasLegend?: boolean;
|
|
35
|
+
/** Axis-label allowance (consumed only when the corresponding axis
|
|
36
|
+
* mode produces a gutter — outer band or per-cell). */
|
|
37
|
+
hasXLabel?: boolean;
|
|
38
|
+
hasYLabel?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Per-facet title strip height (px). 0 disables.
|
|
41
|
+
*/
|
|
42
|
+
titleBand?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Pixel gap between adjacent cells. Carved out of the grid
|
|
45
|
+
* interior before cell sizing; outer edges of the leftmost /
|
|
46
|
+
* rightmost columns and top / bottom rows are unaffected. Default
|
|
47
|
+
* 0 (flush cells).
|
|
48
|
+
*/
|
|
49
|
+
gap?: number;
|
|
50
|
+
}
|
|
51
|
+
export interface FacetCell {
|
|
52
|
+
index: number;
|
|
53
|
+
label: string;
|
|
54
|
+
/**
|
|
55
|
+
* Sub-plot layout. Every cell in a grid has *identical*
|
|
56
|
+
* `plotRect.width` and `plotRect.height` — cell internal margins
|
|
57
|
+
* do not vary by edge position. Shared-axis gutters live in
|
|
58
|
+
* `FacetGrid.outerXAxisRect` / `outerYAxisRect` instead, painted
|
|
59
|
+
* once per frame by the caller.
|
|
60
|
+
*/
|
|
61
|
+
layout: PlotLayout;
|
|
62
|
+
/**
|
|
63
|
+
* Title strip above the facet's plot rect, if `titleBand > 0`.
|
|
64
|
+
*/
|
|
65
|
+
titleRect?: PlotRect;
|
|
66
|
+
isLeftEdge: boolean;
|
|
67
|
+
isBottomEdge: boolean;
|
|
68
|
+
}
|
|
69
|
+
export interface FacetGrid {
|
|
70
|
+
cells: FacetCell[];
|
|
71
|
+
/**
|
|
72
|
+
* Right-gutter rect for the shared legend.
|
|
73
|
+
*/
|
|
74
|
+
legendRect?: PlotRect;
|
|
75
|
+
/**
|
|
76
|
+
* Outer band reserved for the shared X axis (ticks + label). Only
|
|
77
|
+
* set when `xAxis === "outer"`. Spans the grid interior's
|
|
78
|
+
* horizontal extent and sits immediately below the bottom row of
|
|
79
|
+
* cells.
|
|
80
|
+
*/
|
|
81
|
+
outerXAxisRect?: PlotRect;
|
|
82
|
+
/**
|
|
83
|
+
* Outer band reserved for the shared Y axis (ticks + label). Only
|
|
84
|
+
* set when `yAxis === "outer"`. Spans the grid interior's
|
|
85
|
+
* vertical extent and sits immediately left of the leftmost
|
|
86
|
+
* column of cells.
|
|
87
|
+
*/
|
|
88
|
+
outerYAxisRect?: PlotRect;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Collect the bottom-row cells' `PlotLayout`s — i.e. the cells that
|
|
92
|
+
* sit on the grid's bottom edge. Shared-X axis renderers paint X
|
|
93
|
+
* ticks aligned to each of these. Empty when the grid has zero cells.
|
|
94
|
+
*/
|
|
95
|
+
export declare function bottomRowLayouts(grid: FacetGrid): PlotLayout[];
|
|
96
|
+
/**
|
|
97
|
+
* Collect the left-column cells' `PlotLayout`s — symmetric to
|
|
98
|
+
* {@link bottomRowLayouts} for the shared-Y axis path.
|
|
99
|
+
*/
|
|
100
|
+
export declare function leftColumnLayouts(grid: FacetGrid): PlotLayout[];
|
|
101
|
+
/**
|
|
102
|
+
* Arrange `labels.length` sub-plots in a row-major grid sized to fit
|
|
103
|
+
* `(cssWidth, cssHeight)`.
|
|
104
|
+
*
|
|
105
|
+
* Grid shape is chosen to minimize cell aspect distance from square
|
|
106
|
+
* given the container's grid interior: `cols ∈ [1, count]`,
|
|
107
|
+
* `rows = ceil(count / cols)`, tie-broken toward fewer total cells.
|
|
108
|
+
*
|
|
109
|
+
* **Invariant:** every `cells[i].layout.plotRect` has the same
|
|
110
|
+
* `width` and `height`. Shared-axis gutters are carved out of the
|
|
111
|
+
* outer canvas BEFORE cell sizing, so a cell's edge position never
|
|
112
|
+
* affects its internal margins. This lets per-facet draws reuse the
|
|
113
|
+
* same projection scale and lets shared ticks line up with the
|
|
114
|
+
* interior cell boundaries exactly.
|
|
115
|
+
*
|
|
116
|
+
* Axis modes — see {@link AxisMode}:
|
|
117
|
+
* - `"outer"` → outer band rect is populated; per-cell gutter is 0.
|
|
118
|
+
* - `"cell"` → outer band is undefined; each cell owns its own gutter.
|
|
119
|
+
* - `"none"` → no gutter anywhere on that side; used by axis-less
|
|
120
|
+
* chart types.
|
|
121
|
+
*
|
|
122
|
+
* Because all cells are identical in size, callers can sample *any*
|
|
123
|
+
* cell's layout (e.g. `cells[0].layout`) for tick / scale
|
|
124
|
+
* computations.
|
|
125
|
+
*/
|
|
126
|
+
export declare function buildFacetGrid(labels: string[], opts: FacetGridOptions): FacetGrid;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export interface PlotMargins {
|
|
2
|
+
top: number;
|
|
3
|
+
right: number;
|
|
4
|
+
bottom: number;
|
|
5
|
+
left: number;
|
|
6
|
+
}
|
|
7
|
+
export interface PlotRect {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
13
|
+
export interface PlotLayoutOptions {
|
|
14
|
+
hasXLabel: boolean;
|
|
15
|
+
hasYLabel: boolean;
|
|
16
|
+
hasLegend: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Additional CSS-pixel height reserved at the bottom of the plot for a
|
|
19
|
+
* hierarchical / rotated categorical X axis. Overrides the default 24px
|
|
20
|
+
* tick band. The axis-label allowance from `hasXLabel` is preserved.
|
|
21
|
+
*/
|
|
22
|
+
bottomExtra?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Total CSS-pixel width reserved at the left of the plot for a
|
|
25
|
+
* hierarchical categorical Y axis. Overrides the default `55 +
|
|
26
|
+
* hasYLabel*16` left gutter. The axis-label allowance from `hasYLabel`
|
|
27
|
+
* is preserved.
|
|
28
|
+
*/
|
|
29
|
+
leftExtra?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Total CSS-pixel width reserved at the right of the plot. Overrides
|
|
32
|
+
* the default (`80` when `hasLegend`, else `16`). Faceted cells
|
|
33
|
+
* without axes (treemap / sunburst in grid mode) pass `0` to make
|
|
34
|
+
* adjacent cell plot rects flush; axis-bearing charts leave it
|
|
35
|
+
* unset to keep the default breathing-room margin.
|
|
36
|
+
*/
|
|
37
|
+
rightExtra?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Absolute canvas-coordinate offset for this layout's plot origin.
|
|
40
|
+
* When set, `cssWidth` / `cssHeight` describe the *outer* canvas, and
|
|
41
|
+
* `originX` / `originY` name the top-left corner of the cell this
|
|
42
|
+
* layout represents. The cell's own width/height come from
|
|
43
|
+
* `cellWidth` / `cellHeight`. `margins` are computed relative to the
|
|
44
|
+
* cell then shifted into canvas-absolute space so projection
|
|
45
|
+
* matrices, scissor, and `dataToPixel` all operate in full-canvas
|
|
46
|
+
* coordinates without branching per-facet.
|
|
47
|
+
*
|
|
48
|
+
* When any of these fields is unset, the layout is single-plot: the
|
|
49
|
+
* cell occupies the whole canvas and `originX` / `originY` default
|
|
50
|
+
* to 0.
|
|
51
|
+
*/
|
|
52
|
+
originX?: number;
|
|
53
|
+
originY?: number;
|
|
54
|
+
cellWidth?: number;
|
|
55
|
+
cellHeight?: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Coordinates margins and coordinate transforms between WebGL and Canvas2D.
|
|
59
|
+
* All measurements are in CSS pixels (not physical/DPR-scaled pixels).
|
|
60
|
+
*/
|
|
61
|
+
export declare class PlotLayout {
|
|
62
|
+
readonly margins: PlotMargins;
|
|
63
|
+
readonly plotRect: PlotRect;
|
|
64
|
+
readonly cssWidth: number;
|
|
65
|
+
readonly cssHeight: number;
|
|
66
|
+
paddedXMin: number;
|
|
67
|
+
paddedXMax: number;
|
|
68
|
+
paddedYMin: number;
|
|
69
|
+
paddedYMax: number;
|
|
70
|
+
constructor(cssWidth: number, cssHeight: number, options: PlotLayoutOptions);
|
|
71
|
+
/**
|
|
72
|
+
* Build an orthographic projection matrix that maps data coordinates
|
|
73
|
+
* [xMin..xMax, yMin..yMax] to the plot area sub-region of clip space [-1, 1].
|
|
74
|
+
*
|
|
75
|
+
* The matrix bakes margin offsets into the transform so that gl.viewport
|
|
76
|
+
* remains full-canvas and no scissor/sub-viewport is needed.
|
|
77
|
+
*
|
|
78
|
+
* `clamp`, when set, names the axis that carries the *value* (as
|
|
79
|
+
* opposed to categorical / positional) data. Today it only affects
|
|
80
|
+
* `requireZero`; both axes always receive symmetric `padRatio` padding.
|
|
81
|
+
*
|
|
82
|
+
* `requireZero`, when true, guarantees that the unpadded value `0`
|
|
83
|
+
* falls inside the clamped axis's final domain. For all-positive
|
|
84
|
+
* data the axis minimum is pinned at `0` (the baseline sits on the
|
|
85
|
+
* axis line); for all-negative data the maximum is pinned at `0`;
|
|
86
|
+
* for data that already straddles zero, nothing changes. Pairs with
|
|
87
|
+
* `clamp`, and is a no-op when `clamp` is unset.
|
|
88
|
+
*
|
|
89
|
+
* `padRatio` controls the symmetric cosmetic pad on both axes
|
|
90
|
+
* (default 2%). Charts that want plot edges flush with the axes
|
|
91
|
+
* (e.g. heatmap, whose cell rects already span the exact domain)
|
|
92
|
+
* pass `0`.
|
|
93
|
+
*/
|
|
94
|
+
buildProjectionMatrix(xMin: number, xMax: number, yMin: number, yMax: number, clamp?: "x" | "y", requireZero?: boolean, padRatio?: number, xOrigin?: number, yOrigin?: number): Float32Array;
|
|
95
|
+
/**
|
|
96
|
+
* Convert data coordinates to CSS pixel coordinates on the overlay canvas.
|
|
97
|
+
* Uses the padded domain from the last `buildProjectionMatrix` call so
|
|
98
|
+
* that pixel positions align exactly with the WebGL projection.
|
|
99
|
+
*/
|
|
100
|
+
dataToPixel(dataX: number, dataY: number): {
|
|
101
|
+
px: number;
|
|
102
|
+
py: number;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate an array of "nice" tick values spanning [min, max].
|
|
3
|
+
* @param min - Domain minimum
|
|
4
|
+
* @param max - Domain maximum
|
|
5
|
+
* @param targetCount - Desired number of ticks (approximate)
|
|
6
|
+
*/
|
|
7
|
+
export declare function computeNiceTicks(min: number, max: number, targetCount: number): number[];
|
|
8
|
+
/**
|
|
9
|
+
* Format a numeric tick value for display.
|
|
10
|
+
* Uses K/M/B suffixes for large numbers, fixed decimals for small.
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatTickValue(val: number): string;
|
|
13
|
+
/**
|
|
14
|
+
* Format a timestamp (ms since epoch) as a human-readable date/time label.
|
|
15
|
+
* Adapts precision based on the tick spacing.
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatDateTickValue(val: number, stepMs?: number): string;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Mercator projection helpers and XYZ tile-pyramid math. Pure
|
|
3
|
+
* functions, no side effects, safe to call from any thread (including
|
|
4
|
+
* the renderer worker).
|
|
5
|
+
*
|
|
6
|
+
* Mercator output is in *meters*, not the normalized [0, 1] form that
|
|
7
|
+
* some libraries use. We feed the meter values straight into the
|
|
8
|
+
* cartesian projection matrix in `plot-layout.ts`, so the upstream
|
|
9
|
+
* domain stays in physical units and per-pixel ground resolution is a
|
|
10
|
+
* straightforward division.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* WGS84 equatorial radius in meters. Matches what every standard tile
|
|
14
|
+
* provider (OSM, CartoDB, Mapbox, ...) uses for Web Mercator.
|
|
15
|
+
*/
|
|
16
|
+
export declare const EARTH_RADIUS_M = 6378137;
|
|
17
|
+
/**
|
|
18
|
+
* Half the world extent in Mercator meters: π · R ≈ 20037508.34. The
|
|
19
|
+
* full Mercator square is `[-WORLD_HALF, +WORLD_HALF]` on both axes.
|
|
20
|
+
*/
|
|
21
|
+
export declare const WORLD_HALF: number;
|
|
22
|
+
/**
|
|
23
|
+
* Maximum absolute latitude representable in Web Mercator. Beyond this
|
|
24
|
+
* the projection diverges to ±∞; tile providers don't ship tiles
|
|
25
|
+
* outside [-MAX_LAT, +MAX_LAT]. Computed as
|
|
26
|
+
* `atan(sinh(π)) · 180 / π ≈ 85.0511287798°`.
|
|
27
|
+
*/
|
|
28
|
+
export declare const MAX_LAT = 85.0511287798066;
|
|
29
|
+
/**
|
|
30
|
+
* Project (longitude, latitude) in degrees to Web Mercator meters.
|
|
31
|
+
*
|
|
32
|
+
* Latitudes outside ±MAX_LAT return `[NaN, NaN]` so callers in the
|
|
33
|
+
* cartesian build path (which already has a post-`projectPoint` NaN
|
|
34
|
+
* guard) discard those rows without special-casing.
|
|
35
|
+
*/
|
|
36
|
+
export declare function lonLatToMercator(lon: number, lat: number): [number, number];
|
|
37
|
+
/**
|
|
38
|
+
* Inverse: Mercator meters → (lon, lat) in degrees. Used by tooltip
|
|
39
|
+
* formatting and any UI that surfaces the cursor position to the user.
|
|
40
|
+
*/
|
|
41
|
+
export declare function mercatorToLonLat(x: number, y: number): [number, number];
|
|
42
|
+
/**
|
|
43
|
+
* A single XYZ tile address.
|
|
44
|
+
*/
|
|
45
|
+
export interface TileId {
|
|
46
|
+
z: number;
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Mercator extent in meters of one XYZ tile. Y is in the Mercator
|
|
52
|
+
* convention (north positive), not the tile-pyramid convention (y=0
|
|
53
|
+
* at the top); the conversion is done inside the helper.
|
|
54
|
+
*/
|
|
55
|
+
export interface TileExtent {
|
|
56
|
+
xMin: number;
|
|
57
|
+
yMin: number;
|
|
58
|
+
xMax: number;
|
|
59
|
+
yMax: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Return the Mercator-meter bounds of an XYZ tile. Tile (0, 0) at
|
|
63
|
+
* zoom 0 covers `[-WORLD_HALF, +WORLD_HALF]` on both axes — the whole
|
|
64
|
+
* world. Each zoom level subdivides into `2^z × 2^z` equal squares.
|
|
65
|
+
*/
|
|
66
|
+
export declare function tileExtent(z: number, x: number, y: number): TileExtent;
|
|
67
|
+
/**
|
|
68
|
+
* Pick the integer zoom level whose tile pixel resolution best matches
|
|
69
|
+
* the requested Mercator-meters-per-pixel. Snaps to the next coarser
|
|
70
|
+
* level so we never undersample (a finer level would fetch tiles only
|
|
71
|
+
* to scale them down).
|
|
72
|
+
*
|
|
73
|
+
* `targetResolutionMpp` is meters per *device pixel*; the caller
|
|
74
|
+
* computes it as `(domain.xMax - domain.xMin) / plotRect.width`.
|
|
75
|
+
*/
|
|
76
|
+
export declare function pickZoom(targetResolutionMpp: number, tileSizePx?: number, maxZoom?: number): number;
|
|
77
|
+
/**
|
|
78
|
+
* Enumerate every visible tile at a single zoom level that intersects
|
|
79
|
+
* the given Mercator extent. Returned in left-to-right, top-to-bottom
|
|
80
|
+
* order so the layer's render loop produces a deterministic draw
|
|
81
|
+
* sequence (helps with debugging tile-load races).
|
|
82
|
+
*
|
|
83
|
+
* Tiles outside the world's `[0, 2^z)` X range are *not* wrapped —
|
|
84
|
+
* antimeridian wraparound is a v2 feature. Callers see a gap when
|
|
85
|
+
* panning past ±180° lon; tiles inside the valid range still render.
|
|
86
|
+
*/
|
|
87
|
+
export declare function tilesForExtent(extent: TileExtent, z: number): TileId[];
|
|
88
|
+
/**
|
|
89
|
+
* Return the parent tile (one zoom level coarser) of the given tile,
|
|
90
|
+
* along with the [0, 1] UV sub-rect that this tile occupies inside
|
|
91
|
+
* its parent. Used by the layer's "draw what we have" fallback while
|
|
92
|
+
* a missing target tile is in-flight — the parent texture is sampled
|
|
93
|
+
* with the sub-rect so the visible region keeps tile-aligned content
|
|
94
|
+
* instead of flashing blank.
|
|
95
|
+
*
|
|
96
|
+
* Returns `null` for zoom-0 tiles (no parent).
|
|
97
|
+
*/
|
|
98
|
+
export declare function parentTile(tile: TileId): {
|
|
99
|
+
parent: TileId;
|
|
100
|
+
uvMin: [number, number];
|
|
101
|
+
uvMax: [number, number];
|
|
102
|
+
} | null;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded LRU of `WebGLTexture` keyed by tile cache key (see
|
|
3
|
+
* `tile-loader.tileKey`). Evicts least-recently-touched entries on
|
|
4
|
+
* insert past `capacity`, deleting their GPU textures.
|
|
5
|
+
*
|
|
6
|
+
* Default capacity of 256 is enough to cover a full screen worth of
|
|
7
|
+
* tiles at zoom-1 jumps either side of the current viewport plus the
|
|
8
|
+
* parent fallbacks — at 256×256 RGBA that's ~64 MB of texture memory,
|
|
9
|
+
* which sits comfortably under the 256 MB headroom most browsers
|
|
10
|
+
* grant to a tab.
|
|
11
|
+
*/
|
|
12
|
+
export declare class TileCache {
|
|
13
|
+
private _entries;
|
|
14
|
+
private readonly _capacity;
|
|
15
|
+
constructor(capacity?: number);
|
|
16
|
+
/**
|
|
17
|
+
* Fetch a texture by key. Touching an existing entry moves it to
|
|
18
|
+
* the LRU tail so it survives the next eviction sweep.
|
|
19
|
+
*/
|
|
20
|
+
get(key: string): WebGLTexture | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Insert a texture under `key`. If the cache is at capacity, evict
|
|
23
|
+
* the oldest entry first (calling `gl.deleteTexture` on its GPU
|
|
24
|
+
* resource).
|
|
25
|
+
*/
|
|
26
|
+
set(gl: WebGL2RenderingContext | WebGLRenderingContext, key: string, texture: WebGLTexture): void;
|
|
27
|
+
/**
|
|
28
|
+
* Whether a key is resident. Used to gate the "kick off a fetch"
|
|
29
|
+
* branch in the layer's render loop.
|
|
30
|
+
*/
|
|
31
|
+
has(key: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Release every texture. Called on chart destroy. Safe to call
|
|
34
|
+
* with a stale `gl` reference (no-op if `deleteTexture` rejects),
|
|
35
|
+
* but in practice the caller passes the still-live worker context.
|
|
36
|
+
*/
|
|
37
|
+
dispose(gl: WebGL2RenderingContext | WebGLRenderingContext): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { WebGLContextManager } from "../webgl/context-manager";
|
|
2
|
+
import type { PlotLayout } from "../layout/plot-layout";
|
|
3
|
+
import type { TileSource } from "./tile-source";
|
|
4
|
+
type GL = WebGL2RenderingContext | WebGLRenderingContext;
|
|
5
|
+
/**
|
|
6
|
+
* Renders an XYZ raster tile basemap into the chart's webgl canvas
|
|
7
|
+
* inside the plot rect's scissor. Used by `MapChart` from inside
|
|
8
|
+
* `renderInPlotFrame`, before the glyph draw, so chart glyphs (point,
|
|
9
|
+
* line, density) composite naturally on top of the basemap.
|
|
10
|
+
*
|
|
11
|
+
* The layer owns:
|
|
12
|
+
* - The tile shader program (compiled once per WebGL context).
|
|
13
|
+
* - A unit-quad corner buffer (one 2-byte attribute, reused per
|
|
14
|
+
* tile).
|
|
15
|
+
* - A `TileCache` (LRU of `WebGLTexture`).
|
|
16
|
+
* - A `TileLoader` (async fetch + dedup).
|
|
17
|
+
*
|
|
18
|
+
* On each render: pick the integer zoom that matches the requested
|
|
19
|
+
* meters-per-pixel, enumerate visible tiles at that zoom, and draw
|
|
20
|
+
* each one — either with the loaded texture or with a parent
|
|
21
|
+
* texture's sub-rect while the target is in flight.
|
|
22
|
+
*/
|
|
23
|
+
export declare class TileLayer {
|
|
24
|
+
private _program;
|
|
25
|
+
private _cornerBuffer;
|
|
26
|
+
private _cache;
|
|
27
|
+
private _loader;
|
|
28
|
+
private _source;
|
|
29
|
+
private _alpha;
|
|
30
|
+
private _onTileLoad;
|
|
31
|
+
/**
|
|
32
|
+
* Hook the "tile arrived" notification through to the chart's
|
|
33
|
+
* render scheduler. Called once when the layer is constructed
|
|
34
|
+
* by `MapChart`.
|
|
35
|
+
*/
|
|
36
|
+
setOnTileLoad(cb: () => void): void;
|
|
37
|
+
/**
|
|
38
|
+
* Swap the tile source (e.g. light ↔ dark theme). Drops the cache
|
|
39
|
+
* because the cached textures came from the prior source's URLs.
|
|
40
|
+
*/
|
|
41
|
+
setSource(gl: GL, source: TileSource): void;
|
|
42
|
+
setAlpha(alpha: number): void;
|
|
43
|
+
get source(): TileSource | null;
|
|
44
|
+
/**
|
|
45
|
+
* Render the basemap for the current visible Mercator extent.
|
|
46
|
+
* Caller is responsible for binding the chart's main framebuffer
|
|
47
|
+
* (the plot-frame scissor is already in place by the time we get
|
|
48
|
+
* here). The same `projection` matrix the glyph draw uses is
|
|
49
|
+
* passed straight through.
|
|
50
|
+
*/
|
|
51
|
+
render(glManager: WebGLContextManager, layout: PlotLayout, projection: Float32Array, domain: {
|
|
52
|
+
xMin: number;
|
|
53
|
+
xMax: number;
|
|
54
|
+
yMin: number;
|
|
55
|
+
yMax: number;
|
|
56
|
+
}, xOrigin: number, yOrigin: number): void;
|
|
57
|
+
/**
|
|
58
|
+
* Free every GPU resource. Called from `MapChart.destroyInternal`.
|
|
59
|
+
*/
|
|
60
|
+
destroy(gl: GL): void;
|
|
61
|
+
private _drawTile;
|
|
62
|
+
private _issueDraw;
|
|
63
|
+
private _kickLoad;
|
|
64
|
+
private _ensureProgram;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { TileSource } from "./tile-source";
|
|
2
|
+
/**
|
|
3
|
+
* Async tile fetcher with in-flight dedup and abort-on-zoom-change.
|
|
4
|
+
*
|
|
5
|
+
* Runs inside the renderer worker (the chart's host process). `fetch`
|
|
6
|
+
* and `createImageBitmap` are both available in workers, and the
|
|
7
|
+
* resulting `ImageBitmap` can be uploaded straight to a WebGL2 texture
|
|
8
|
+
* via `gl.texImage2D(..., ImageBitmap)` — no main-thread bounce.
|
|
9
|
+
*
|
|
10
|
+
* The loader does not own GPU resources. Upload to texture happens in
|
|
11
|
+
* the tile layer once an `ImageBitmap` resolves; the layer then drops
|
|
12
|
+
* the bitmap (calling `close()` to free the decoded pixels).
|
|
13
|
+
*/
|
|
14
|
+
export declare class TileLoader {
|
|
15
|
+
private _inFlight;
|
|
16
|
+
private _onLoad;
|
|
17
|
+
/**
|
|
18
|
+
* Register the "tile arrived" callback. The layer wires this to
|
|
19
|
+
* `chart.requestRender(glManager)` so a newly-loaded tile triggers
|
|
20
|
+
* exactly one extra frame.
|
|
21
|
+
*/
|
|
22
|
+
setOnLoad(cb: () => void): void;
|
|
23
|
+
/**
|
|
24
|
+
* Kick off a fetch (or return the in-flight one). The same
|
|
25
|
+
* (source.id, z, x, y) tuple only ever has one outstanding
|
|
26
|
+
* fetch; multiple callers share the result. Rejected fetches
|
|
27
|
+
* (network error, abort) resolve to `null` so callers can skip
|
|
28
|
+
* the tile without try/catch noise on every miss.
|
|
29
|
+
*/
|
|
30
|
+
load(source: TileSource, z: number, x: number, y: number): Promise<ImageBitmap | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Abort every in-flight fetch. Called on view teardown / chart
|
|
33
|
+
* destroy. Fetches whose `Response` has already arrived but
|
|
34
|
+
* haven't yet decoded will still complete the decode and resolve
|
|
35
|
+
* to `null` (because `_onLoad` is replaced or the cache is gone)
|
|
36
|
+
* — harmless, no resource leak.
|
|
37
|
+
*/
|
|
38
|
+
cancelAll(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Abort just the fetches whose key isn't in the supplied set.
|
|
41
|
+
* The layer calls this on every render with the currently-visible
|
|
42
|
+
* tile set so old-zoom requests don't keep arriving and triggering
|
|
43
|
+
* spurious re-renders after the user has moved on.
|
|
44
|
+
*/
|
|
45
|
+
cancelExcept(liveKeys: Set<string>): void;
|
|
46
|
+
private _fetchAndDecode;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Stable cache key for a tile under a given source. Embedded source id
|
|
50
|
+
* so swapping sources (light/dark) doesn't surface stale tiles.
|
|
51
|
+
*/
|
|
52
|
+
export declare function tileKey(sourceId: string, z: number, x: number, y: number): string;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tile source describes *where* to fetch raster XYZ tiles and what
|
|
3
|
+
* attribution text the renderer must display in the chrome canvas.
|
|
4
|
+
* Implementations are stateless — the tile loader handles caching and
|
|
5
|
+
* in-flight dedup.
|
|
6
|
+
*/
|
|
7
|
+
export interface TileSource {
|
|
8
|
+
/**
|
|
9
|
+
* Build the URL for tile (z, x, y). Implementations typically
|
|
10
|
+
* substitute a template like `{z}/{x}/{y}` and may rotate
|
|
11
|
+
* subdomains for browsers that throttle concurrent connections
|
|
12
|
+
* per host.
|
|
13
|
+
*/
|
|
14
|
+
urlFor(z: number, x: number, y: number): string;
|
|
15
|
+
/**
|
|
16
|
+
* Plain-text attribution shown in the bottom-right of the chrome
|
|
17
|
+
* canvas. Required by every major tile provider's terms of use —
|
|
18
|
+
* do not suppress it without provider-side opt-out.
|
|
19
|
+
*/
|
|
20
|
+
readonly attribution: string;
|
|
21
|
+
/**
|
|
22
|
+
* Side length of one tile in pixels. Tile providers ship 256 by
|
|
23
|
+
* default; a few offer 512 (`@2x`) variants. Used by the zoom-
|
|
24
|
+
* level picker to convert meters-per-pixel into a zoom level.
|
|
25
|
+
*/
|
|
26
|
+
readonly tileSize: number;
|
|
27
|
+
/**
|
|
28
|
+
* Maximum zoom level the provider serves. Tiles requested above
|
|
29
|
+
* this fall back to the deepest available level with sub-tile
|
|
30
|
+
* UVs — same trick used during async loads.
|
|
31
|
+
*/
|
|
32
|
+
readonly maxZoom: number;
|
|
33
|
+
/**
|
|
34
|
+
* Stable identifier for caching. Two `TileSource` instances with
|
|
35
|
+
* the same `id` share a tile cache; switching source (e.g. theme
|
|
36
|
+
* change) invalidates and re-fetches.
|
|
37
|
+
*/
|
|
38
|
+
readonly id: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Subdomain-rotated URL template. Replaces `{s}` with one of the
|
|
42
|
+
* provided subdomains hashed by `(x + y)`, and `{z}`, `{x}`, `{y}`
|
|
43
|
+
* with the tile address. Most major tile providers fit this shape.
|
|
44
|
+
*/
|
|
45
|
+
export declare class TemplatedTileSource implements TileSource {
|
|
46
|
+
readonly id: string;
|
|
47
|
+
private readonly template;
|
|
48
|
+
readonly attribution: string;
|
|
49
|
+
readonly tileSize: number;
|
|
50
|
+
readonly maxZoom: number;
|
|
51
|
+
private readonly subdomains;
|
|
52
|
+
constructor(id: string, template: string, attribution: string, tileSize?: number, maxZoom?: number, subdomains?: readonly string[]);
|
|
53
|
+
urlFor(z: number, x: number, y: number): string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Identifier of the default tile providers shipped with `viewer-charts`.
|
|
57
|
+
* Surfaced as the `map_tile_provider` PluginConfig enum so users can
|
|
58
|
+
* pick light vs. dark vs. labels-only without writing a custom source.
|
|
59
|
+
*/
|
|
60
|
+
export type TileProviderId = "carto-positron" | "carto-dark-matter" | "carto-voyager";
|
|
61
|
+
/**
|
|
62
|
+
* Resolve a `TileProviderId` (from PluginConfig) to a concrete
|
|
63
|
+
* `TileSource`. Unknown ids fall back to Positron so a misconfigured
|
|
64
|
+
* `_pluginConfig` never produces a blank map.
|
|
65
|
+
*/
|
|
66
|
+
export declare function tileSourceFor(id: TileProviderId | string): TileSource;
|