@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.
Files changed (258) hide show
  1. package/LICENSE.md +193 -0
  2. package/dist/cdn/perspective-viewer-charts.js +3 -0
  3. package/dist/cdn/perspective-viewer-charts.js.map +7 -0
  4. package/dist/esm/axis/axis-primitives.d.ts +24 -0
  5. package/dist/esm/axis/bar-axis.d.ts +51 -0
  6. package/dist/esm/axis/canvas.d.ts +24 -0
  7. package/dist/esm/axis/categorical-axis-core.d.ts +42 -0
  8. package/dist/esm/axis/categorical-axis.d.ts +27 -0
  9. package/dist/esm/axis/facet-chrome.d.ts +13 -0
  10. package/dist/esm/axis/label-geometry.d.ts +41 -0
  11. package/dist/esm/axis/legend.d.ts +44 -0
  12. package/dist/esm/axis/numeric-axis.d.ts +20 -0
  13. package/dist/esm/charts/candlestick/candlestick-build.d.ts +129 -0
  14. package/dist/esm/charts/candlestick/candlestick-interact.d.ts +10 -0
  15. package/dist/esm/charts/candlestick/candlestick-render.d.ts +24 -0
  16. package/dist/esm/charts/candlestick/candlestick.d.ts +144 -0
  17. package/dist/esm/charts/candlestick/glyphs/draw-candlesticks.d.ts +36 -0
  18. package/dist/esm/charts/candlestick/glyphs/draw-ohlc.d.ts +33 -0
  19. package/dist/esm/charts/canvas-types.d.ts +15 -0
  20. package/dist/esm/charts/cartesian/cartesian-build.d.ts +14 -0
  21. package/dist/esm/charts/cartesian/cartesian-interact.d.ts +20 -0
  22. package/dist/esm/charts/cartesian/cartesian-render.d.ts +26 -0
  23. package/dist/esm/charts/cartesian/cartesian.d.ts +239 -0
  24. package/dist/esm/charts/cartesian/glyph.d.ts +53 -0
  25. package/dist/esm/charts/cartesian/glyphs/density.d.ts +142 -0
  26. package/dist/esm/charts/cartesian/glyphs/lines.d.ts +23 -0
  27. package/dist/esm/charts/cartesian/glyphs/points.d.ts +24 -0
  28. package/dist/esm/charts/cartesian/label-interner.d.ts +21 -0
  29. package/dist/esm/charts/cartesian/tooltip-lines.d.ts +11 -0
  30. package/dist/esm/charts/chart-base.d.ts +402 -0
  31. package/dist/esm/charts/chart.d.ts +338 -0
  32. package/dist/esm/charts/common/band-layout.d.ts +32 -0
  33. package/dist/esm/charts/common/categorical-y-chart.d.ts +53 -0
  34. package/dist/esm/charts/common/category-axis-resolver.d.ts +90 -0
  35. package/dist/esm/charts/common/chrome-cache.d.ts +18 -0
  36. package/dist/esm/charts/common/draw-tooltip-box.d.ts +9 -0
  37. package/dist/esm/charts/common/leaf-color.d.ts +33 -0
  38. package/dist/esm/charts/common/node-store.d.ts +81 -0
  39. package/dist/esm/charts/common/tree-chart.d.ts +48 -0
  40. package/dist/esm/charts/common/tree-chrome.d.ts +31 -0
  41. package/dist/esm/charts/common/tree-data.d.ts +54 -0
  42. package/dist/esm/charts/common/visible-extent.d.ts +51 -0
  43. package/dist/esm/charts/heatmap/heatmap-build.d.ts +86 -0
  44. package/dist/esm/charts/heatmap/heatmap-interact.d.ts +19 -0
  45. package/dist/esm/charts/heatmap/heatmap-render.d.ts +19 -0
  46. package/dist/esm/charts/heatmap/heatmap-y-axis.d.ts +46 -0
  47. package/dist/esm/charts/heatmap/heatmap.d.ts +117 -0
  48. package/dist/esm/charts/map/map.d.ts +67 -0
  49. package/dist/esm/charts/registry.d.ts +14 -0
  50. package/dist/esm/charts/series/glyphs/draw-areas.d.ts +30 -0
  51. package/dist/esm/charts/series/glyphs/draw-bars.d.ts +15 -0
  52. package/dist/esm/charts/series/glyphs/draw-lines.d.ts +34 -0
  53. package/dist/esm/charts/series/glyphs/draw-scatter.d.ts +33 -0
  54. package/dist/esm/charts/series/series-build.d.ts +228 -0
  55. package/dist/esm/charts/series/series-interact.d.ts +35 -0
  56. package/dist/esm/charts/series/series-render.d.ts +41 -0
  57. package/dist/esm/charts/series/series-type.d.ts +49 -0
  58. package/dist/esm/charts/series/series.d.ts +317 -0
  59. package/dist/esm/charts/sunburst/sunburst-interact.d.ts +7 -0
  60. package/dist/esm/charts/sunburst/sunburst-layout.d.ts +33 -0
  61. package/dist/esm/charts/sunburst/sunburst-render.d.ts +22 -0
  62. package/dist/esm/charts/sunburst/sunburst.d.ts +85 -0
  63. package/dist/esm/charts/treemap/treemap-interact.d.ts +12 -0
  64. package/dist/esm/charts/treemap/treemap-layout.d.ts +28 -0
  65. package/dist/esm/charts/treemap/treemap-render.d.ts +18 -0
  66. package/dist/esm/charts/treemap/treemap.d.ts +74 -0
  67. package/dist/esm/config.d.ts +27 -0
  68. package/dist/esm/data/lazy-row.d.ts +32 -0
  69. package/dist/esm/data/split-groups.d.ts +20 -0
  70. package/dist/esm/data/view-reader.d.ts +35 -0
  71. package/dist/esm/event-detail.d.ts +28 -0
  72. package/dist/esm/index.d.ts +3 -0
  73. package/dist/esm/interaction/hit-test.d.ts +30 -0
  74. package/dist/esm/interaction/host-sink-dom.d.ts +19 -0
  75. package/dist/esm/interaction/host-sink-message.d.ts +46 -0
  76. package/dist/esm/interaction/lazy-tooltip.d.ts +61 -0
  77. package/dist/esm/interaction/raw-event-forwarder.d.ts +27 -0
  78. package/dist/esm/interaction/spatial-grid.d.ts +15 -0
  79. package/dist/esm/interaction/tooltip-controller.d.ts +193 -0
  80. package/dist/esm/interaction/zoom-controller.d.ts +106 -0
  81. package/dist/esm/interaction/zoom-router.d.ts +48 -0
  82. package/dist/esm/layout/facet-grid.d.ts +126 -0
  83. package/dist/esm/layout/plot-layout.d.ts +104 -0
  84. package/dist/esm/layout/ticks.d.ts +17 -0
  85. package/dist/esm/map/mercator.d.ts +102 -0
  86. package/dist/esm/map/tile-cache.d.ts +38 -0
  87. package/dist/esm/map/tile-layer.d.ts +66 -0
  88. package/dist/esm/map/tile-loader.d.ts +52 -0
  89. package/dist/esm/map/tile-source.d.ts +66 -0
  90. package/dist/esm/perspective-viewer-charts.js +3 -0
  91. package/dist/esm/perspective-viewer-charts.js.map +7 -0
  92. package/dist/esm/plugin/charts.d.ts +40 -0
  93. package/dist/esm/plugin/plugin.d.ts +95 -0
  94. package/dist/esm/render/scheduler.d.ts +41 -0
  95. package/dist/esm/theme/gradient.d.ts +48 -0
  96. package/dist/esm/theme/palette.d.ts +13 -0
  97. package/dist/esm/theme/theme-snapshot.d.ts +7 -0
  98. package/dist/esm/theme/theme.d.ts +53 -0
  99. package/dist/esm/transport/protocol.d.ts +430 -0
  100. package/dist/esm/transport/renderer-transport.d.ts +201 -0
  101. package/dist/esm/utils/css.d.ts +1 -0
  102. package/dist/esm/utils/font-snapshot.d.ts +50 -0
  103. package/dist/esm/webgl/buffer-pool.d.ts +62 -0
  104. package/dist/esm/webgl/context-manager.d.ts +184 -0
  105. package/dist/esm/webgl/gradient-texture.d.ts +17 -0
  106. package/dist/esm/webgl/instanced-attrs.d.ts +44 -0
  107. package/dist/esm/webgl/plot-frame.d.ts +39 -0
  108. package/dist/esm/webgl/program-cache.d.ts +13 -0
  109. package/dist/esm/webgl/shader-manifest.d.ts +53 -0
  110. package/dist/esm/webgl/shader-registry.d.ts +22 -0
  111. package/dist/esm/worker/boot.d.ts +0 -0
  112. package/dist/esm/worker/dispatch.d.ts +9 -0
  113. package/dist/esm/worker/font-loader.d.ts +2 -0
  114. package/dist/esm/worker/renderer.worker.d.ts +115 -0
  115. package/dist/esm/worker/session-host.d.ts +26 -0
  116. package/package.json +47 -0
  117. package/src/css/perspective-viewer-charts.css +95 -0
  118. package/src/ts/axis/axis-primitives.ts +125 -0
  119. package/src/ts/axis/bar-axis.ts +345 -0
  120. package/src/ts/axis/canvas.ts +64 -0
  121. package/src/ts/axis/categorical-axis-core.ts +125 -0
  122. package/src/ts/axis/categorical-axis.ts +716 -0
  123. package/src/ts/axis/facet-chrome.ts +42 -0
  124. package/src/ts/axis/label-geometry.ts +188 -0
  125. package/src/ts/axis/legend.ts +218 -0
  126. package/src/ts/axis/numeric-axis.ts +353 -0
  127. package/src/ts/charts/candlestick/candlestick-build.ts +516 -0
  128. package/src/ts/charts/candlestick/candlestick-interact.ts +256 -0
  129. package/src/ts/charts/candlestick/candlestick-render.ts +387 -0
  130. package/src/ts/charts/candlestick/candlestick.ts +367 -0
  131. package/src/ts/charts/candlestick/glyphs/draw-candlesticks.ts +432 -0
  132. package/src/ts/charts/candlestick/glyphs/draw-ohlc.ts +317 -0
  133. package/src/ts/charts/canvas-types.ts +30 -0
  134. package/src/ts/charts/cartesian/cartesian-build.ts +616 -0
  135. package/src/ts/charts/cartesian/cartesian-interact.ts +355 -0
  136. package/src/ts/charts/cartesian/cartesian-render.ts +948 -0
  137. package/src/ts/charts/cartesian/cartesian.ts +469 -0
  138. package/src/ts/charts/cartesian/glyph.ts +81 -0
  139. package/src/ts/charts/cartesian/glyphs/density.ts +1263 -0
  140. package/src/ts/charts/cartesian/glyphs/lines.ts +320 -0
  141. package/src/ts/charts/cartesian/glyphs/points.ts +239 -0
  142. package/src/ts/charts/cartesian/label-interner.ts +56 -0
  143. package/src/ts/charts/cartesian/tooltip-lines.ts +80 -0
  144. package/src/ts/charts/chart-base.ts +840 -0
  145. package/src/ts/charts/chart.ts +427 -0
  146. package/src/ts/charts/common/band-layout.ts +63 -0
  147. package/src/ts/charts/common/categorical-y-chart.ts +81 -0
  148. package/src/ts/charts/common/category-axis-resolver.ts +314 -0
  149. package/src/ts/charts/common/chrome-cache.ts +79 -0
  150. package/src/ts/charts/common/draw-tooltip-box.ts +84 -0
  151. package/src/ts/charts/common/leaf-color.ts +92 -0
  152. package/src/ts/charts/common/node-store.ts +235 -0
  153. package/src/ts/charts/common/tree-chart.ts +76 -0
  154. package/src/ts/charts/common/tree-chrome.ts +123 -0
  155. package/src/ts/charts/common/tree-data.ts +623 -0
  156. package/src/ts/charts/common/visible-extent.ts +112 -0
  157. package/src/ts/charts/heatmap/heatmap-build.ts +426 -0
  158. package/src/ts/charts/heatmap/heatmap-interact.ts +274 -0
  159. package/src/ts/charts/heatmap/heatmap-render.ts +815 -0
  160. package/src/ts/charts/heatmap/heatmap-y-axis.ts +351 -0
  161. package/src/ts/charts/heatmap/heatmap.ts +368 -0
  162. package/src/ts/charts/map/map.ts +201 -0
  163. package/src/ts/charts/registry.ts +65 -0
  164. package/src/ts/charts/series/glyphs/draw-areas.ts +331 -0
  165. package/src/ts/charts/series/glyphs/draw-bars.ts +113 -0
  166. package/src/ts/charts/series/glyphs/draw-lines.ts +320 -0
  167. package/src/ts/charts/series/glyphs/draw-scatter.ts +328 -0
  168. package/src/ts/charts/series/series-build.ts +848 -0
  169. package/src/ts/charts/series/series-interact.ts +604 -0
  170. package/src/ts/charts/series/series-render.ts +1109 -0
  171. package/src/ts/charts/series/series-type.ts +99 -0
  172. package/src/ts/charts/series/series.ts +794 -0
  173. package/src/ts/charts/sunburst/sunburst-interact.ts +460 -0
  174. package/src/ts/charts/sunburst/sunburst-layout.ts +238 -0
  175. package/src/ts/charts/sunburst/sunburst-render.ts +887 -0
  176. package/src/ts/charts/sunburst/sunburst.ts +248 -0
  177. package/src/ts/charts/treemap/treemap-interact.ts +445 -0
  178. package/src/ts/charts/treemap/treemap-layout.ts +328 -0
  179. package/src/ts/charts/treemap/treemap-render.ts +886 -0
  180. package/src/ts/charts/treemap/treemap.ts +247 -0
  181. package/src/ts/config.ts +41 -0
  182. package/src/ts/data/lazy-row.ts +140 -0
  183. package/src/ts/data/split-groups.ts +97 -0
  184. package/src/ts/data/view-reader.ts +107 -0
  185. package/src/ts/event-detail.ts +44 -0
  186. package/src/ts/index.ts +53 -0
  187. package/src/ts/interaction/hit-test.ts +106 -0
  188. package/src/ts/interaction/host-sink-dom.ts +85 -0
  189. package/src/ts/interaction/host-sink-message.ts +75 -0
  190. package/src/ts/interaction/lazy-tooltip.ts +102 -0
  191. package/src/ts/interaction/raw-event-forwarder.ts +175 -0
  192. package/src/ts/interaction/spatial-grid.ts +100 -0
  193. package/src/ts/interaction/tooltip-controller.ts +407 -0
  194. package/src/ts/interaction/zoom-controller.ts +468 -0
  195. package/src/ts/interaction/zoom-router.ts +230 -0
  196. package/src/ts/layout/facet-grid.ts +346 -0
  197. package/src/ts/layout/plot-layout.ts +277 -0
  198. package/src/ts/layout/ticks.ts +168 -0
  199. package/src/ts/map/mercator.ts +204 -0
  200. package/src/ts/map/tile-cache.ts +96 -0
  201. package/src/ts/map/tile-layer.ts +382 -0
  202. package/src/ts/map/tile-loader.ts +143 -0
  203. package/src/ts/map/tile-source.ts +156 -0
  204. package/src/ts/plugin/charts.ts +286 -0
  205. package/src/ts/plugin/plugin.ts +668 -0
  206. package/src/ts/render/scheduler.ts +339 -0
  207. package/src/ts/shaders/area.frag.glsl +20 -0
  208. package/src/ts/shaders/area.vert.glsl +19 -0
  209. package/src/ts/shaders/bar.frag.glsl +25 -0
  210. package/src/ts/shaders/bar.vert.glsl +60 -0
  211. package/src/ts/shaders/candlestick-body.frag.glsl +19 -0
  212. package/src/ts/shaders/candlestick-body.vert.glsl +34 -0
  213. package/src/ts/shaders/density-extreme.frag.glsl +30 -0
  214. package/src/ts/shaders/density-mrt.frag.glsl +44 -0
  215. package/src/ts/shaders/density-mrt.vert.glsl +48 -0
  216. package/src/ts/shaders/density-resolve.frag.glsl +89 -0
  217. package/src/ts/shaders/density-resolve.vert.glsl +23 -0
  218. package/src/ts/shaders/density-splat.frag.glsl +34 -0
  219. package/src/ts/shaders/density-splat.vert.glsl +52 -0
  220. package/src/ts/shaders/gridline.frag.glsl +18 -0
  221. package/src/ts/shaders/gridline.vert.glsl +18 -0
  222. package/src/ts/shaders/heatmap.frag.glsl +23 -0
  223. package/src/ts/shaders/heatmap.vert.glsl +42 -0
  224. package/src/ts/shaders/line-uniform.frag.glsl +26 -0
  225. package/src/ts/shaders/line-uniform.vert.glsl +54 -0
  226. package/src/ts/shaders/line.frag.glsl +28 -0
  227. package/src/ts/shaders/line.vert.glsl +87 -0
  228. package/src/ts/shaders/scatter.frag.glsl +39 -0
  229. package/src/ts/shaders/scatter.vert.glsl +67 -0
  230. package/src/ts/shaders/sunburst-arc.frag.glsl +19 -0
  231. package/src/ts/shaders/sunburst-arc.vert.glsl +79 -0
  232. package/src/ts/shaders/tile.frag.glsl +27 -0
  233. package/src/ts/shaders/tile.vert.glsl +35 -0
  234. package/src/ts/shaders/treemap.frag.glsl +19 -0
  235. package/src/ts/shaders/treemap.vert.glsl +25 -0
  236. package/src/ts/shaders/y-scatter.frag.glsl +30 -0
  237. package/src/ts/shaders/y-scatter.vert.glsl +31 -0
  238. package/src/ts/theme/gradient.ts +312 -0
  239. package/src/ts/theme/palette.ts +64 -0
  240. package/src/ts/theme/theme-snapshot.ts +66 -0
  241. package/src/ts/theme/theme.ts +166 -0
  242. package/src/ts/transport/protocol.ts +497 -0
  243. package/src/ts/transport/renderer-transport.ts +788 -0
  244. package/src/ts/utils/css.ts +36 -0
  245. package/src/ts/utils/font-snapshot.ts +159 -0
  246. package/src/ts/webgl/buffer-pool.ts +163 -0
  247. package/src/ts/webgl/context-manager.ts +414 -0
  248. package/src/ts/webgl/gradient-texture.ts +84 -0
  249. package/src/ts/webgl/instanced-attrs.ts +139 -0
  250. package/src/ts/webgl/plot-frame.ts +91 -0
  251. package/src/ts/webgl/program-cache.ts +46 -0
  252. package/src/ts/webgl/shader-manifest.ts +148 -0
  253. package/src/ts/webgl/shader-registry.ts +97 -0
  254. package/src/ts/worker/boot.ts +22 -0
  255. package/src/ts/worker/dispatch.ts +99 -0
  256. package/src/ts/worker/font-loader.ts +89 -0
  257. package/src/ts/worker/renderer.worker.ts +734 -0
  258. package/src/ts/worker/session-host.ts +118 -0
@@ -0,0 +1,427 @@
1
+ // ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2
+ // ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
3
+ // ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
4
+ // ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
5
+ // ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
6
+ // ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7
+ // ┃ Copyright (c) 2017, the Perspective Authors. ┃
8
+ // ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9
+ // ┃ This file is part of the Perspective library, distributed under the terms ┃
10
+ // ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11
+ // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
+
13
+ import type { View } from "@perspective-dev/client";
14
+ import type { ColumnDataMap } from "../data/view-reader";
15
+ import type { WebGLContextManager } from "../webgl/context-manager";
16
+ import type { ZoomController } from "../interaction/zoom-controller";
17
+ import type { HostSink } from "../interaction/tooltip-controller";
18
+
19
+ export interface ChartImplementation {
20
+ uploadAndRender(
21
+ glManager: WebGLContextManager,
22
+ columns: ColumnDataMap,
23
+ startRow: number,
24
+ endRow: number,
25
+ ): void;
26
+
27
+ /**
28
+ * The single render entrypoint. Every render-triggering caller —
29
+ * upload chunks, zoom / pan, resize, theme invalidation,
30
+ * host-driven redraws — calls this. Routes through the
31
+ * module-level scheduler ([render/scheduler.ts]) so concurrent
32
+ * calls collapse to one `_fullRender` per RAF and the host
33
+ * blitter receives one bitmap per frame per chart.
34
+ *
35
+ * The returned promise resolves after this entry's `_fullRender`
36
+ * + `awaitGpuFence` + `endFrame` chain completes — independent
37
+ * of other charts in the same RAF, which run their fence waits
38
+ * in parallel.
39
+ *
40
+ * The synchronous-render bypass for `snapshotPng` (calls
41
+ * `_fullRender` directly, skips `endFrame`) is the only
42
+ * sanctioned exception and lives inside the worker renderer.
43
+ */
44
+ requestRender(glManager: WebGLContextManager): Promise<void>;
45
+
46
+ /**
47
+ * The chart-specific frame builder. The scheduler wraps this with
48
+ * fence + `endFrame`; callers must not invoke it directly except
49
+ * for `snapshotPng`, which needs an intact GL backbuffer for
50
+ * `gl.readPixels` and so must skip the `endFrame` pair.
51
+ */
52
+ _fullRender(glManager: WebGLContextManager): void;
53
+
54
+ /**
55
+ * Hand the current View to the chart so it can make on-demand
56
+ * per-row queries (for lazy tooltip column lookups). Called on
57
+ * every `draw`; the chart disposes any prior fetcher and clears
58
+ * dependent UI (pinned tooltip) so stale rows never surface.
59
+ *
60
+ * TODO: pinned tooltips are dismissed on view update today. A
61
+ * future enhancement is to keep a pinned tooltip visible (with its
62
+ * captured data) until the user dismisses it, even after the
63
+ * underlying view no longer contains that row.
64
+ */
65
+ setView?(view: View): void;
66
+
67
+ /**
68
+ * Set the gridline canvas (behind WebGL, for gridlines).
69
+ */
70
+ setGridlineCanvas?(canvas: HTMLCanvasElement | OffscreenCanvas): void;
71
+
72
+ /**
73
+ * Set the chrome canvas (above WebGL, for axes/labels/legend/tooltip).
74
+ */
75
+ setChromeCanvas?(canvas: HTMLCanvasElement | OffscreenCanvas): void;
76
+
77
+ /**
78
+ * Hand the chart a pre-computed CSS-variable map produced on the
79
+ * main thread via `snapshotThemeVars(el)`, which it can decode into
80
+ * a full `Theme` without touching the DOM (charts always run inside
81
+ * the renderer scope, which has no `getComputedStyle`).
82
+ */
83
+ setTheme?(vars: Record<string, string>): void;
84
+
85
+ /**
86
+ * Set the zoom controller for interactive zoom/pan.
87
+ */
88
+ setZoomController?(zc: ZoomController): void;
89
+
90
+ /**
91
+ * Wire the chart's `TooltipController` for virtual-dispatch hover /
92
+ * click events forwarded from the host. The renderer drives
93
+ * `dispatchHover` / `dispatchLeave` / `dispatchClick` /
94
+ * `dispatchDblClick` from `InteractionEvent`s; the supplied
95
+ * `HostSink` posts pin / dismiss / setCursor intents back to the
96
+ * host so the resulting DOM mutations happen there (the renderer
97
+ * scope has no DOM in worker mode, and uses the same channel
98
+ * in-process for symmetry).
99
+ */
100
+ attachTooltip?(host: HostSink): void;
101
+
102
+ /**
103
+ * Set the column slot config (with nulls for empty slots).
104
+ */
105
+ setColumnSlots?(slots: (string | null)[]): void;
106
+
107
+ /**
108
+ * Set group_by and split_by config from the viewer.
109
+ */
110
+ setViewPivots?(groupBy: string[], splitBy: string[]): void;
111
+
112
+ /**
113
+ * Set column type schema from the view (e.g., { "col": "date" }).
114
+ */
115
+ setColumnTypes?(schema: Record<string, string>): void;
116
+
117
+ /**
118
+ * Set the source-column types used for `group_by` level lookups —
119
+ * sourced from `table.schema()` + `view.expression_schema()`. Used
120
+ * by categorical-axis charts to detect numeric / date / boolean
121
+ * group_by levels (which are not keyed in `view.schema()` because
122
+ * they surface as `__ROW_PATH_N__` columns).
123
+ */
124
+ setGroupByTypes?(schema: Record<string, string>): void;
125
+
126
+ /**
127
+ * Set per-column render config (the second argument to `plugin.restore`).
128
+ * Key is the aggregate base name; value is an open object whose
129
+ * `chart_type` / `stack` fields are consumed by the Y-bar glyph router.
130
+ */
131
+ setColumnsConfig?(cfg: Record<string, any>): void;
132
+
133
+ /**
134
+ * Set the plugin's default glyph type. Used by the Y-series chart
135
+ * family (Y Bar / Y Line / Y Scatter / Y Area): each tag is the same
136
+ * `BarChart` impl with a different starting `chart_type` applied to
137
+ * columns that lack an explicit entry in `columns_config`.
138
+ */
139
+ setDefaultChartType?(chartType: string): void;
140
+
141
+ /**
142
+ * Set the faceting config: one small-multiple sub-plot per
143
+ * `split_by` group, optional shared axes, coordinated tooltip, and
144
+ * zoom routing mode. Seeded from `DEFAULT_FACET_CONFIG` at init;
145
+ * `plugin_config.facet_mode` / `facet_zoom_mode` override the
146
+ * matching fields via `AbstractChart.setPluginConfig`.
147
+ */
148
+ setFacetConfig?(cfg: FacetConfig): void;
149
+
150
+ /**
151
+ * Set the plugin-scoped global configuration — the values backing
152
+ * `plugin_config_schema` / `plugin_config` in `restore`. Replaces
153
+ * the previous module-level constants (`LINE_WIDTH_PX`,
154
+ * `POINT_SIZE_PX`, `BAND_INNER_FRAC`, `BAR_INNER_PAD`,
155
+ * `WICK_WIDTH_PX`, `OHLC_LINE_WIDTH_PX`, `AUTO_ALT_Y_AXIS`) plus
156
+ * the faceted/series zoom-mode semantics described in
157
+ * {@link PluginConfig}.
158
+ */
159
+ setPluginConfig?(cfg: PluginConfig): void;
160
+
161
+ /**
162
+ * Drop any cached theme values so the next render re-reads CSS
163
+ * variables. Driven from `plugin.restyle()`.
164
+ */
165
+ invalidateTheme?(): void;
166
+
167
+ /**
168
+ * Clear the `domain_mode: "expand"` accumulator state so the next
169
+ * data load starts from the current data extent. Driven from
170
+ * `resetAllZooms` (the user clicked "Reset Zoom"). View-config
171
+ * mutations route through `AbstractChart`'s `setColumnSlots` /
172
+ * `setViewPivots` / `setColumnTypes` setters, which call the same
173
+ * hook internally.
174
+ */
175
+ resetExpandedDomain?(): void;
176
+
177
+ destroy(): void;
178
+ }
179
+
180
+ export interface FacetConfig {
181
+ /**
182
+ * "grid" = small multiples (default); "overlay" = legacy single-plot.
183
+ */
184
+ facet_mode: "grid" | "overlay";
185
+
186
+ /**
187
+ * Share one bottom X axis across all columns of facets.
188
+ */
189
+ shared_x_axis: boolean;
190
+
191
+ /**
192
+ * Share one left Y axis across all rows of facets.
193
+ */
194
+ shared_y_axis: boolean;
195
+
196
+ /**
197
+ * Paint a tooltip in every facet (otherwise only the source facet).
198
+ */
199
+ coordinated_tooltip: boolean;
200
+
201
+ /**
202
+ * "shared" = one viewport for all facets; "independent" = per-facet.
203
+ */
204
+ zoom_mode: "shared" | "independent";
205
+
206
+ /**
207
+ * Pixel gap between adjacent facet cells in grid mode.
208
+ */
209
+ facet_padding: number;
210
+ }
211
+
212
+ export const DEFAULT_FACET_CONFIG: FacetConfig = {
213
+ facet_mode: "grid",
214
+ shared_x_axis: true,
215
+ shared_y_axis: true,
216
+ coordinated_tooltip: false,
217
+ zoom_mode: "shared",
218
+ facet_padding: 6,
219
+ };
220
+
221
+ /**
222
+ * Plugin-scoped global configuration — the user-facing settings backing
223
+ * `plugin_config_schema()` / the `plugin_config` slot in `restore`.
224
+ *
225
+ * Each chart type's `plugin_config_schema` returns only the fields that
226
+ * are applicable for that chart (see `applicable_plugin_fields` on
227
+ * `ChartTypeConfig`); inapplicable fields are hidden in the UI. The
228
+ * chart impl receives the full struct on `setPluginConfig` and reads
229
+ * only the fields its render / build pipeline cares about.
230
+ *
231
+ * Some fields overlap with {@link FacetConfig} (`facet_mode`,
232
+ * `facet_zoom_mode`); the base `AbstractChart.setPluginConfig` syncs
233
+ * those onto `_facetConfig` so deep render code keeps reading the
234
+ * single facet struct it already does. `series_zoom_mode` toggles the
235
+ * categorical-Y chart base's `_autoFitValue` flag.
236
+ */
237
+ export interface PluginConfig {
238
+ /**
239
+ * Auto-detect Y dual-axis splits when aggregate magnitudes differ
240
+ * by more than `DUAL_Y_RATIO_THRESHOLD`×. Series charts only.
241
+ * Replaces the `AUTO_ALT_Y_AXIS` compile-time toggle.
242
+ */
243
+ auto_alt_y_axis: boolean;
244
+
245
+ /**
246
+ * Faceting strategy when `split_by` is non-empty.
247
+ *
248
+ * - `"grid"` — one small-multiple sub-plot per split group.
249
+ * - `"overlay"` — single plot with split groups differentiated by
250
+ * color. Synced into `_facetConfig.facet_mode`.
251
+ */
252
+ facet_mode: "grid" | "overlay";
253
+
254
+ /**
255
+ * Faceted-cartesian zoom routing. `"shared"` — one viewport across
256
+ * all facets; `"independent"` — wheel/pan routes to the facet under
257
+ * the cursor with its own viewport. Synced into
258
+ * `_facetConfig.zoom_mode`.
259
+ */
260
+ facet_zoom_mode: "shared" | "independent";
261
+
262
+ /**
263
+ * Series-chart value-axis behavior on zoom.
264
+ *
265
+ * - `"dynamic"` — value axis refits to the visible categorical
266
+ * slice (current default; `CategoricalYChart._autoFitValue` =
267
+ * true).
268
+ * - `"fixed"` — value axis stays pinned to the full-data extent.
269
+ */
270
+ series_zoom_mode: "fixed" | "dynamic";
271
+
272
+ /**
273
+ * Anchor the value axis to zero — when true, `0` is forced into
274
+ * the rendered domain even if all data sits well above or below
275
+ * it. Natural for bar / area glyphs (which grow from the zero
276
+ * baseline) and surprising for line / scatter (where the
277
+ * interesting variation often lives far from zero). Per-chart-type
278
+ * defaults route through `ChartTypeConfig.plugin_field_defaults`:
279
+ * `true` for Y Bar / Y Area / X Bar, `false` elsewhere.
280
+ */
281
+ include_zero: boolean;
282
+
283
+ /**
284
+ * Domain accumulation policy across successive `View` updates.
285
+ *
286
+ * - `"fit"` — every update recomputes the rendered domain (and on
287
+ * cartesian charts, the X/Y range and color/size scales) from
288
+ * the current data extent. Can grow or shrink frame-to-frame.
289
+ * - `"expand"` — the rendered domain monotonically *grows*: each
290
+ * update unions the new data extent with the previously rendered
291
+ * extent, so once a value is in scope it stays in scope. Reset
292
+ * by the "Reset Zoom" button, view-config changes (group_by /
293
+ * split_by / column-slot / column-type), or toggling back to
294
+ * `"fit"`.
295
+ */
296
+ domain_mode: "fit" | "expand";
297
+
298
+ /**
299
+ * Width of polyline glyphs in CSS pixels (multiplied by DPR at GL
300
+ * upload). Replaces the duplicated `LINE_WIDTH_PX` constants in
301
+ * the cartesian + series line glyphs.
302
+ */
303
+ line_width_px: number;
304
+
305
+ /**
306
+ * Diameter of scatter point glyphs in CSS pixels. Replaces
307
+ * `POINT_SIZE_PX`.
308
+ */
309
+ point_size_px: number;
310
+
311
+ /**
312
+ * Fraction of each category band occupied by its slot(s). Replaces
313
+ * `BAND_INNER_FRAC`. Affects buffer contents — takes effect on
314
+ * next data load.
315
+ */
316
+ band_inner_frac: number;
317
+
318
+ /**
319
+ * Relative inner padding between adjacent slots within a band.
320
+ * Replaces `BAR_INNER_PAD`. Affects buffer contents — takes effect
321
+ * on next data load.
322
+ */
323
+ bar_inner_pad: number;
324
+
325
+ /**
326
+ * Candlestick wick stroke width in CSS pixels. Replaces
327
+ * `WICK_WIDTH_PX`.
328
+ */
329
+ wick_width_px: number;
330
+
331
+ /**
332
+ * OHLC bar stroke width in CSS pixels. Replaces
333
+ * `OHLC_LINE_WIDTH_PX`.
334
+ */
335
+ ohlc_line_width_px: number;
336
+
337
+ /**
338
+ * density splat radius in CSS pixels. Each data point is
339
+ * rasterized as a soft disk of this radius into the accumulation
340
+ * FBO before the gradient LUT pass resolves to a heat color.
341
+ */
342
+ gradient_radius_px: number;
343
+
344
+ /**
345
+ * density per-splat intensity multiplier. Controls how
346
+ * fast the density grows when points overlap (low values produce
347
+ * a smoother, more diffuse field; high values produce sharper
348
+ * peaks).
349
+ */
350
+ gradient_intensity: number;
351
+
352
+ /**
353
+ * density clamp on the maximum accumulated heat used for
354
+ * the gradient-LUT lookup. Lower values saturate sooner (more of
355
+ * the LUT's hot stops show up); higher values stay cooler. In
356
+ * every mode this controls the alpha (intensity) ramp; in
357
+ * `density` mode it also drives the hue, and in `signed` mode it
358
+ * scales the signed-sum-to-hue mapping.
359
+ */
360
+ gradient_heat_max: number;
361
+
362
+ /**
363
+ * density color-reduction mode. Controls how each pixel's
364
+ * stack of overlapping splats is reduced to a single LUT-t / alpha
365
+ * pair in the resolve pass.
366
+ *
367
+ * - `mean` (default) — hue is the density-weighted average of
368
+ * per-point color-t. Reads as "the typical color-column value
369
+ * in this region." Uses robust (5th/95th-percentile) bounds so
370
+ * one outlier can't compress the rest of the data toward the
371
+ * gradient midpoint.
372
+ * - `density` — ignore the color column even when wired; hue and
373
+ * alpha both follow density. Reads as "where do points cluster."
374
+ * Useful when the color column is attached for tooltip lookup
375
+ * only.
376
+ * - `extreme` — keep the per-pixel maximum signed deviation of
377
+ * `t - 0.5` (split into positive and negative channels, MAX-
378
+ * blended). Reads as "where are the outliers." Density still
379
+ * drives alpha so a single-point extreme fades naturally.
380
+ * Requires a second framebuffer; uses MRT on WebGL2 hardware
381
+ * with `OES_draw_buffers_indexed`, two passes otherwise.
382
+ * - `signed` — accumulate signed `t - 0.5` and let positive vs
383
+ * negative cancel out. Reads as "net positive vs net negative
384
+ * in each region." Requires a float-capable framebuffer; on
385
+ * `UNSIGNED_BYTE` fallback hardware degrades silently to
386
+ * `mean` with a one-line console warning.
387
+ */
388
+ gradient_color_mode: "mean" | "density" | "extreme" | "signed";
389
+
390
+ /**
391
+ * Map basemap tile provider. Applies only to map plugin tags
392
+ * (`map-scatter`, `map-line`, `map-density`). Cartesian charts
393
+ * ignore the field. Surfaced as an enum on the settings panel so
394
+ * users can switch light/dark/voyager without writing custom
395
+ * tile-source code.
396
+ */
397
+ map_tile_provider: "carto-positron" | "carto-dark-matter" | "carto-voyager";
398
+
399
+ /**
400
+ * Map basemap alpha (0..1). Pre-multiplied into the tile fragment
401
+ * shader's output so the chart's glyph layer composites over a
402
+ * dimmer or brighter version of the basemap. `1.0` (default)
403
+ * shows the tiles at full opacity.
404
+ */
405
+ map_tile_alpha: number;
406
+ }
407
+
408
+ export const DEFAULT_PLUGIN_CONFIG: PluginConfig = {
409
+ auto_alt_y_axis: false,
410
+ facet_mode: "grid",
411
+ facet_zoom_mode: "shared",
412
+ series_zoom_mode: "dynamic",
413
+ include_zero: false,
414
+ domain_mode: "fit",
415
+ line_width_px: 2.0,
416
+ point_size_px: 8.0,
417
+ band_inner_frac: 0.5,
418
+ bar_inner_pad: 0.1,
419
+ wick_width_px: 1.0,
420
+ ohlc_line_width_px: 1.0,
421
+ gradient_radius_px: 32.0,
422
+ gradient_intensity: 0.6,
423
+ gradient_heat_max: 4.0,
424
+ gradient_color_mode: "mean",
425
+ map_tile_provider: "carto-positron",
426
+ map_tile_alpha: 1.0,
427
+ };
@@ -0,0 +1,63 @@
1
+ // ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2
+ // ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
3
+ // ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
4
+ // ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
5
+ // ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
6
+ // ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7
+ // ┃ Copyright (c) 2017, the Perspective Authors. ┃
8
+ // ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9
+ // ┃ This file is part of the Perspective library, distributed under the terms ┃
10
+ // ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11
+ // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
+
13
+ /**
14
+ * Shared per-category band geometry used by categorical-X charts (bar,
15
+ * candlestick, ohlc). The category axis uses unit-wide bands centered
16
+ * on integer indices; within each band, `numSlots` rectangles (bars,
17
+ * candles, …) are laid out side by side with a small inner padding.
18
+ */
19
+
20
+ export interface SlotGeometry {
21
+ /**
22
+ * Width (in data-space units) of a single slot.
23
+ */
24
+ slotWidth: number;
25
+
26
+ /**
27
+ * Half the drawable width of each slot after inner padding.
28
+ */
29
+ halfWidth: number;
30
+ }
31
+
32
+ /**
33
+ * Compute slot geometry for `numSlots` rectangles per category band.
34
+ *
35
+ * `bandInnerFrac` is the fraction of each category's band width
36
+ * actually covered by slots; `barInnerPad` is the relative padding
37
+ * between adjacent slots within a band. Both come from
38
+ * {@link PluginConfig.band_inner_frac} / `bar_inner_pad`. Defaults
39
+ * match the previous hard-coded constants (0.5 / 0.1).
40
+ */
41
+ export function computeSlotGeometry(
42
+ numSlots: number,
43
+ bandInnerFrac: number = 0.5,
44
+ barInnerPad: number = 0.1,
45
+ ): SlotGeometry {
46
+ const slotWidth = bandInnerFrac / Math.max(1, numSlots);
47
+ const halfWidth = (slotWidth * (1 - barInnerPad)) / 2;
48
+ return { slotWidth, halfWidth };
49
+ }
50
+
51
+ /**
52
+ * X-center for slot `slotIdx` of `numSlots` in the band centered at
53
+ * `catIdx`. Matches bar's layout: slot 0 on the far left, numSlots-1 on
54
+ * the far right, symmetric about `catIdx`.
55
+ */
56
+ export function slotCenter(
57
+ catIdx: number,
58
+ slotIdx: number,
59
+ numSlots: number,
60
+ slotWidth: number,
61
+ ): number {
62
+ return catIdx + (slotIdx - (numSlots - 1) / 2) * slotWidth;
63
+ }
@@ -0,0 +1,81 @@
1
+ // ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2
+ // ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
3
+ // ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
4
+ // ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
5
+ // ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
6
+ // ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7
+ // ┃ Copyright (c) 2017, the Perspective Authors. ┃
8
+ // ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9
+ // ┃ This file is part of the Perspective library, distributed under the terms ┃
10
+ // ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11
+ // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
+
13
+ import type { PlotLayout } from "../../layout/plot-layout";
14
+ import type { AxisDomain } from "../../axis/numeric-axis";
15
+ import type {
16
+ CategoricalDomain,
17
+ CategoricalLevel,
18
+ } from "../../axis/categorical-axis";
19
+ import type { ZoomConfig } from "../../interaction/zoom-controller";
20
+ import { AbstractChart } from "../chart-base";
21
+
22
+ /**
23
+ * Common base for charts with a categorical X axis, a numeric Y (value)
24
+ * axis, and an optional zoom-on-categorical interaction. Today that's
25
+ * Bar (all four Y-family plugins + X Bar) and Candlestick/OHLC.
26
+ *
27
+ * The class is deliberately thin: it consolidates the bookkeeping that
28
+ * genuinely repeats across those chart families (categorical domain
29
+ * state, last-frame cache for overlay-only redraws, value-axis lock
30
+ * default, shared GL-program + corner-buffer fields) and nothing more.
31
+ * Glyph rendering, hit-testing, build pipelines, and horizontal / dual-
32
+ * axis variance live in the concrete subclasses because they diverge
33
+ * too much to usefully share.
34
+ */
35
+ export abstract class CategoricalYChart extends AbstractChart {
36
+ // Categorical X axis state
37
+ /**
38
+ * Row-path levels (group_by hierarchy) for X-axis tick rendering.
39
+ */
40
+ _rowPaths: CategoricalLevel[] = [];
41
+
42
+ /**
43
+ * Number of categories on the X axis.
44
+ */
45
+ _numCategories = 0;
46
+
47
+ /**
48
+ * Offset into the aggregated-row stream (total-rows are skipped).
49
+ */
50
+ _rowOffset = 0;
51
+
52
+ // Shared GL resources
53
+ _program: WebGLProgram | null = null;
54
+ _cornerBuffer: WebGLBuffer | null = null;
55
+
56
+ // Last-frame cache (for chrome-only redraws)
57
+ _lastLayout: PlotLayout | null = null;
58
+ _lastXDomain: CategoricalDomain | null = null;
59
+ _lastYDomain: AxisDomain | null = null;
60
+ _lastYTicks: number[] | null = null;
61
+
62
+ // Auto-fit value axis (opt-in per chart)
63
+ /**
64
+ * When true, the value axis refits to the visible categorical
65
+ * window each frame — so zooming the categorical axis tightens the
66
+ * value axis to just the bars / candles in view. Subclasses own
67
+ * the per-frame cache object because the cache key shape varies
68
+ * (bar needs `hiddenSeries`, candlestick doesn't; bar may have
69
+ * dual-axis extents, candlestick is single-axis).
70
+ */
71
+ _autoFitValue = true;
72
+
73
+ /**
74
+ * Lock the value axis by default — user wheel/pan should only
75
+ * scroll the categorical axis. Subclasses override to flip
76
+ * orientation (e.g. X Bar where the value axis is on X).
77
+ */
78
+ protected override getZoomConfig(): ZoomConfig {
79
+ return { lockAxis: "y" };
80
+ }
81
+ }