insomni-plot 0.1.0-alpha.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 (242) hide show
  1. package/LICENSE.md +674 -0
  2. package/README.md +81 -0
  3. package/dist/core.d.mts +340 -0
  4. package/dist/core.mjs +1047 -0
  5. package/dist/index.d.mts +3426 -0
  6. package/dist/index.mjs +12762 -0
  7. package/dist/interactions-DEFL_F4E.mjs +5395 -0
  8. package/dist/range-presets-CzECsu3V.d.mts +1523 -0
  9. package/package.json +34 -0
  10. package/src/annotations.d.ts +121 -0
  11. package/src/annotations.ts +438 -0
  12. package/src/axis.d.ts +184 -0
  13. package/src/axis.test.ts +131 -0
  14. package/src/axis.ts +765 -0
  15. package/src/colorbar.d.ts +69 -0
  16. package/src/colorbar.ts +294 -0
  17. package/src/colors.d.ts +57 -0
  18. package/src/colors.test.ts +28 -0
  19. package/src/colors.ts +486 -0
  20. package/src/core.ts +299 -0
  21. package/src/format.d.ts +54 -0
  22. package/src/format.ts +138 -0
  23. package/src/grammar/accessibility.d.ts +147 -0
  24. package/src/grammar/accessibility.test.ts +199 -0
  25. package/src/grammar/accessibility.ts +443 -0
  26. package/src/grammar/aes.d.ts +35 -0
  27. package/src/grammar/aes.test.ts +75 -0
  28. package/src/grammar/aes.ts +120 -0
  29. package/src/grammar/annotations.d.ts +86 -0
  30. package/src/grammar/annotations.test.ts +68 -0
  31. package/src/grammar/annotations.ts +336 -0
  32. package/src/grammar/attach-brush.d.ts +44 -0
  33. package/src/grammar/attach-brush.test.ts +214 -0
  34. package/src/grammar/attach-brush.ts +111 -0
  35. package/src/grammar/attach-presets.d.ts +33 -0
  36. package/src/grammar/attach-presets.test.ts +106 -0
  37. package/src/grammar/attach-presets.ts +215 -0
  38. package/src/grammar/chart.d.ts +952 -0
  39. package/src/grammar/chart.test.ts +118 -0
  40. package/src/grammar/chart.ts +1172 -0
  41. package/src/grammar/color-utils.d.ts +29 -0
  42. package/src/grammar/color-utils.test.ts +53 -0
  43. package/src/grammar/color-utils.ts +66 -0
  44. package/src/grammar/constants.d.ts +45 -0
  45. package/src/grammar/constants.ts +61 -0
  46. package/src/grammar/coord.d.ts +183 -0
  47. package/src/grammar/coord.test.ts +355 -0
  48. package/src/grammar/coord.ts +619 -0
  49. package/src/grammar/data/pivot.d.ts +57 -0
  50. package/src/grammar/data/pivot.ts +107 -0
  51. package/src/grammar/emphasis-driver.d.ts +69 -0
  52. package/src/grammar/emphasis-driver.test.ts +199 -0
  53. package/src/grammar/emphasis-driver.ts +205 -0
  54. package/src/grammar/equality.d.ts +3 -0
  55. package/src/grammar/equality.ts +40 -0
  56. package/src/grammar/facet.d.ts +63 -0
  57. package/src/grammar/facet.test.ts +60 -0
  58. package/src/grammar/facet.ts +175 -0
  59. package/src/grammar/geoms/_categorical.d.ts +94 -0
  60. package/src/grammar/geoms/_categorical.ts +0 -0
  61. package/src/grammar/geoms/_distribution.d.ts +52 -0
  62. package/src/grammar/geoms/_distribution.ts +125 -0
  63. package/src/grammar/geoms/_mark.d.ts +69 -0
  64. package/src/grammar/geoms/_mark.ts +136 -0
  65. package/src/grammar/geoms/_shape.d.ts +41 -0
  66. package/src/grammar/geoms/_shape.ts +74 -0
  67. package/src/grammar/geoms/aggregate.d.ts +95 -0
  68. package/src/grammar/geoms/aggregate.test.ts +554 -0
  69. package/src/grammar/geoms/aggregate.ts +840 -0
  70. package/src/grammar/geoms/area.d.ts +32 -0
  71. package/src/grammar/geoms/area.test.ts +165 -0
  72. package/src/grammar/geoms/area.ts +578 -0
  73. package/src/grammar/geoms/band.d.ts +27 -0
  74. package/src/grammar/geoms/band.test.ts +57 -0
  75. package/src/grammar/geoms/band.ts +126 -0
  76. package/src/grammar/geoms/bar.d.ts +56 -0
  77. package/src/grammar/geoms/bar.test.ts +367 -0
  78. package/src/grammar/geoms/bar.ts +1054 -0
  79. package/src/grammar/geoms/boxplot.d.ts +129 -0
  80. package/src/grammar/geoms/boxplot.test.ts +299 -0
  81. package/src/grammar/geoms/boxplot.ts +834 -0
  82. package/src/grammar/geoms/connected-scatter.d.ts +27 -0
  83. package/src/grammar/geoms/connected-scatter.test.ts +157 -0
  84. package/src/grammar/geoms/connected-scatter.ts +63 -0
  85. package/src/grammar/geoms/emphasis.d.ts +76 -0
  86. package/src/grammar/geoms/emphasis.test.ts +135 -0
  87. package/src/grammar/geoms/emphasis.ts +162 -0
  88. package/src/grammar/geoms/histogram.d.ts +75 -0
  89. package/src/grammar/geoms/histogram.test.ts +262 -0
  90. package/src/grammar/geoms/histogram.ts +740 -0
  91. package/src/grammar/geoms/index.d.ts +20 -0
  92. package/src/grammar/geoms/index.ts +77 -0
  93. package/src/grammar/geoms/interval.d.ts +31 -0
  94. package/src/grammar/geoms/interval.test.ts +154 -0
  95. package/src/grammar/geoms/interval.ts +342 -0
  96. package/src/grammar/geoms/line.d.ts +38 -0
  97. package/src/grammar/geoms/line.test.ts +247 -0
  98. package/src/grammar/geoms/line.ts +659 -0
  99. package/src/grammar/geoms/point.d.ts +57 -0
  100. package/src/grammar/geoms/point.test.ts +163 -0
  101. package/src/grammar/geoms/point.ts +545 -0
  102. package/src/grammar/geoms/polar.test.ts +216 -0
  103. package/src/grammar/geoms/ribbon.d.ts +21 -0
  104. package/src/grammar/geoms/ribbon.test.ts +170 -0
  105. package/src/grammar/geoms/ribbon.ts +87 -0
  106. package/src/grammar/geoms/ridgeline.d.ts +89 -0
  107. package/src/grammar/geoms/ridgeline.test.ts +247 -0
  108. package/src/grammar/geoms/ridgeline.ts +1164 -0
  109. package/src/grammar/geoms/rolling.d.ts +43 -0
  110. package/src/grammar/geoms/rolling.test.ts +217 -0
  111. package/src/grammar/geoms/rolling.ts +387 -0
  112. package/src/grammar/geoms/rug.d.ts +28 -0
  113. package/src/grammar/geoms/rug.test.ts +126 -0
  114. package/src/grammar/geoms/rug.ts +214 -0
  115. package/src/grammar/geoms/rule.d.ts +23 -0
  116. package/src/grammar/geoms/rule.test.ts +69 -0
  117. package/src/grammar/geoms/rule.ts +212 -0
  118. package/src/grammar/geoms/smooth.d.ts +54 -0
  119. package/src/grammar/geoms/smooth.test.ts +78 -0
  120. package/src/grammar/geoms/smooth.ts +337 -0
  121. package/src/grammar/geoms/text.d.ts +29 -0
  122. package/src/grammar/geoms/text.test.ts +64 -0
  123. package/src/grammar/geoms/text.ts +234 -0
  124. package/src/grammar/geoms/tile.d.ts +61 -0
  125. package/src/grammar/geoms/tile.test.ts +157 -0
  126. package/src/grammar/geoms/tile.ts +621 -0
  127. package/src/grammar/geoms/types.d.ts +319 -0
  128. package/src/grammar/geoms/types.ts +362 -0
  129. package/src/grammar/geoms/violin.d.ts +85 -0
  130. package/src/grammar/geoms/violin.test.ts +187 -0
  131. package/src/grammar/geoms/violin.ts +672 -0
  132. package/src/grammar/index.d.ts +22 -0
  133. package/src/grammar/index.ts +269 -0
  134. package/src/grammar/interactions/_disposable.d.ts +5 -0
  135. package/src/grammar/interactions/_disposable.ts +23 -0
  136. package/src/grammar/interactions/_z.d.ts +4 -0
  137. package/src/grammar/interactions/_z.ts +16 -0
  138. package/src/grammar/interactions/brush-selection.test.ts +262 -0
  139. package/src/grammar/interactions/brush.d.ts +63 -0
  140. package/src/grammar/interactions/brush.test.ts +483 -0
  141. package/src/grammar/interactions/brush.ts +452 -0
  142. package/src/grammar/interactions/crosshair.d.ts +19 -0
  143. package/src/grammar/interactions/crosshair.test.ts +127 -0
  144. package/src/grammar/interactions/crosshair.ts +76 -0
  145. package/src/grammar/interactions/hit-layer.d.ts +64 -0
  146. package/src/grammar/interactions/hit-layer.ts +246 -0
  147. package/src/grammar/interactions/legend.d.ts +19 -0
  148. package/src/grammar/interactions/legend.ts +101 -0
  149. package/src/grammar/interactions/menu.d.ts +93 -0
  150. package/src/grammar/interactions/menu.test.ts +373 -0
  151. package/src/grammar/interactions/menu.ts +342 -0
  152. package/src/grammar/interactions/selection.d.ts +25 -0
  153. package/src/grammar/interactions/selection.test.ts +289 -0
  154. package/src/grammar/interactions/selection.ts +142 -0
  155. package/src/grammar/interactions/series-readout.d.ts +91 -0
  156. package/src/grammar/interactions/series-readout.test.ts +668 -0
  157. package/src/grammar/interactions/series-readout.ts +422 -0
  158. package/src/grammar/interactions/series-snap.d.ts +70 -0
  159. package/src/grammar/interactions/series-snap.test.ts +214 -0
  160. package/src/grammar/interactions/series-snap.ts +218 -0
  161. package/src/grammar/interactions/tooltip-axis.test.ts +176 -0
  162. package/src/grammar/interactions/tooltip-touch.browser.test.ts +49 -0
  163. package/src/grammar/interactions/tooltip-touch.test.ts +161 -0
  164. package/src/grammar/interactions/tooltip.d.ts +140 -0
  165. package/src/grammar/interactions/tooltip.test.ts +406 -0
  166. package/src/grammar/interactions/tooltip.ts +622 -0
  167. package/src/grammar/interactions/transitions.d.ts +34 -0
  168. package/src/grammar/interactions/transitions.test.ts +172 -0
  169. package/src/grammar/interactions/transitions.ts +160 -0
  170. package/src/grammar/layout.d.ts +68 -0
  171. package/src/grammar/layout.ts +186 -0
  172. package/src/grammar/legend-merge.test.ts +332 -0
  173. package/src/grammar/mount.d.ts +78 -0
  174. package/src/grammar/mount.test.ts +479 -0
  175. package/src/grammar/mount.ts +2112 -0
  176. package/src/grammar/palettes.d.ts +54 -0
  177. package/src/grammar/palettes.test.ts +80 -0
  178. package/src/grammar/palettes.ts +167 -0
  179. package/src/grammar/pan-zoom.test.ts +398 -0
  180. package/src/grammar/phylo.d.ts +65 -0
  181. package/src/grammar/phylo.test.ts +59 -0
  182. package/src/grammar/phylo.ts +112 -0
  183. package/src/grammar/pipeline.auto-ticks.test.ts +40 -0
  184. package/src/grammar/pipeline.d.ts +158 -0
  185. package/src/grammar/pipeline.test.ts +463 -0
  186. package/src/grammar/pipeline.ts +1233 -0
  187. package/src/grammar/profiling.d.ts +8 -0
  188. package/src/grammar/profiling.ts +24 -0
  189. package/src/grammar/scales.d.ts +188 -0
  190. package/src/grammar/scales.test.ts +181 -0
  191. package/src/grammar/scales.ts +800 -0
  192. package/src/grammar/svg.d.ts +3 -0
  193. package/src/grammar/svg.ts +39 -0
  194. package/src/grammar/theme.d.ts +261 -0
  195. package/src/grammar/theme.test.ts +105 -0
  196. package/src/grammar/theme.ts +490 -0
  197. package/src/heatmap/cpu.ts +109 -0
  198. package/src/heatmap/gpu.ts +565 -0
  199. package/src/heatmap/types.ts +177 -0
  200. package/src/heatmap.browser.test.ts +308 -0
  201. package/src/heatmap.test.ts +320 -0
  202. package/src/heatmap.ts +123 -0
  203. package/src/index.d.ts +1 -0
  204. package/src/index.ts +8 -0
  205. package/src/interactions.d.ts +48 -0
  206. package/src/interactions.test.ts +226 -0
  207. package/src/interactions.ts +394 -0
  208. package/src/layout/box.d.ts +48 -0
  209. package/src/layout/box.test.ts +107 -0
  210. package/src/layout/box.ts +143 -0
  211. package/src/legend.d.ts +115 -0
  212. package/src/legend.ts +422 -0
  213. package/src/marks/curve.d.ts +43 -0
  214. package/src/marks/curve.ts +244 -0
  215. package/src/marks/stack.d.ts +53 -0
  216. package/src/marks/stack.ts +184 -0
  217. package/src/marks.d.ts +273 -0
  218. package/src/marks.test.ts +541 -0
  219. package/src/marks.ts +1292 -0
  220. package/src/navigator.test.ts +174 -0
  221. package/src/navigator.ts +393 -0
  222. package/src/range-presets.d.ts +113 -0
  223. package/src/range-presets.test.ts +345 -0
  224. package/src/range-presets.ts +349 -0
  225. package/src/scales.d.ts +98 -0
  226. package/src/scales.test.ts +103 -0
  227. package/src/scales.ts +695 -0
  228. package/src/stats/index.d.ts +200 -0
  229. package/src/stats/index.test.ts +349 -0
  230. package/src/stats/index.ts +740 -0
  231. package/src/stats/regression.d.ts +38 -0
  232. package/src/stats/regression.test.ts +56 -0
  233. package/src/stats/regression.ts +396 -0
  234. package/src/stats/rolling-window.d.ts +55 -0
  235. package/src/stats/rolling-window.test.ts +237 -0
  236. package/src/stats/rolling-window.ts +256 -0
  237. package/src/test-setup.ts +19 -0
  238. package/src/viewport/axis-state.d.ts +72 -0
  239. package/src/viewport/axis-state.ts +476 -0
  240. package/src/viewport.d.ts +170 -0
  241. package/src/viewport.test.ts +363 -0
  242. package/src/viewport.ts +510 -0
package/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # insomni-plot
2
+
3
+ A grammar-of-graphics charting layer built on top of [`insomni`](../insomni), the
4
+ WebGPU 2D renderer. You describe a chart declaratively — data, geoms, scales,
5
+ axes, coordinate system — and `insomni-plot` compiles that spec into `insomni`
6
+ layers and renders it on the GPU. The builder is immutable: every method
7
+ (`.layer()`, `.scale()`, `.axes()`, …) returns a new `Chart`, and
8
+ `.mount(canvas)` / `.render(target)` / `.toSVG()` materialize it.
9
+
10
+ ## Install
11
+
12
+ This is a workspace package, depended on with `workspace:*`. It declares
13
+ `insomni` as a (workspace) dependency, so a WebGPU-capable environment and a
14
+ `GPUDevice` are required at mount time.
15
+
16
+ ```jsonc
17
+ {
18
+ "dependencies": {
19
+ "insomni-plot": "workspace:*",
20
+ "insomni": "workspace:*",
21
+ },
22
+ }
23
+ ```
24
+
25
+ ## Quick start
26
+
27
+ ```ts
28
+ import { plot, point } from "insomni-plot";
29
+
30
+ type Row = { weight: number; mpg: number; cylinders: number };
31
+
32
+ const data: Row[] = [
33
+ { weight: 3.2, mpg: 21, cylinders: 6 },
34
+ { weight: 1.6, mpg: 39, cylinders: 4 },
35
+ { weight: 4.1, mpg: 15, cylinders: 8 },
36
+ ];
37
+
38
+ const device = await (await navigator.gpu.requestAdapter())!.requestDevice();
39
+ const canvas = document.querySelector("canvas")!;
40
+
41
+ const chart = plot<Row>({ data })
42
+ .layer(point({ x: "weight", y: "mpg", color: "cylinders" }))
43
+ .axes({ x: { title: "Weight" }, y: { title: "MPG" } })
44
+ .title("Fuel economy");
45
+
46
+ const mounted = chart.mount(canvas, { device });
47
+
48
+ // later, swap the data or tear down
49
+ mounted.setData(data);
50
+ mounted.destroy();
51
+ ```
52
+
53
+ Aesthetic channels (`x`, `y`, `color`, …) accept a column-name string, an
54
+ accessor `(row, i) => value`, or a constant. A `line(...)` or `bar(...)` layer
55
+ slots in the same way as `point(...)`.
56
+
57
+ ## Two entry points
58
+
59
+ - **`insomni-plot`** — the grammar API. `plot(spec)` returns an immutable
60
+ `Chart`; compose it with geoms (`point`, `line`, `bar`, …), `coordCartesian` /
61
+ `coordPolar` / `coordRadial`, `theme`, faceting, annotations, color palettes,
62
+ and statistics helpers (`bin`, `kde`, `boxStats`, regression fits).
63
+ - **`insomni-plot/core`** — the low-level imperative primitives the grammar is
64
+ built on: scales (`linearScale`, `bandScale`, `timeScale`, `logScale`, …),
65
+ axis builders (`bottomAxis`, `leftAxis`, …), mark builders (`pointMark`,
66
+ `lineMark`, `barMark`, `areaMark`, stacking), legends, color scales/palettes,
67
+ formatters, the data `viewport`, and the data `navigator`. Reach for `/core`
68
+ when you want to hand-wire a render without the `Chart` builder.
69
+
70
+ ## Geoms
71
+
72
+ `aggregate`, `area`, `band`, `bar`, `boxplot`, `connectedScatter`, `histogram`,
73
+ `interval`, `line`, `point`, `ribbon`, `ridgeline`, `rug`, `rule`, `smooth`,
74
+ `statRolling`, `text`, `tile`, `violin`.
75
+
76
+ ## Interactions & more
77
+
78
+ The mount can wire hover tooltips, a snapping crosshair, click-selection,
79
+ drag-to-rect brushing, legend toggling, a context menu, animated transitions,
80
+ and pan/zoom — see `MountPlotOptions` in `src/grammar/chart.ts`. Charts also
81
+ export to SVG via `chart.toSVG()`.
@@ -0,0 +1,340 @@
1
+ import { $ as polyFit, $n as LineCurvePreset, $t as SwatchSpec, A as binBreaks, An as MarkOrigin, Ar as groupedBandScale, At as pastel, B as RollingPoint, Bn as categoricalBarMark, Bt as set3, C as KdeBandwidth, Cn as CategoricalBarMarkOptions, Cr as GroupedBandScaleOptions, Ct as dark2, D as QuantileMethod, Dn as LineDashStyle, Dr as TimeIntervalUnit, Dt as magma, E as KdeResult, En as GroupedBarMarkOptions, Er as TickFormatter, Et as inferno, F as histogramMeasureValue, Fn as StackedBarMarkOptions, Fr as timeTickFormat, Ft as purples, G as rollingWindow, Gn as stackedBarMark, Gt as BarSwatchSpec, H as RollingStatisticKind, Hn as lineMark, Ht as tableau10, I as jitter, In as StackedMarkBuilder, Ir as timeTicks, It as rdbu, J as LoessOptions, Jn as StackOrder, Jt as LegendEntry, K as ConfidenceBandOptions, Kn as StackOffset, Kt as LegendAlign, L as kde, Ln as ValueOrAccessor, Lt as reds, M as binWithBreaks, Mn as PointMarkOptions, Mr as logScale, Mt as plasma, N as boxStats, Nn as PointShapeKind, Nr as sqrtScale, Nt as prgn, O as WhiskerRule, On as LineMarkOptions, Or as TimeScale, Ot as oranges, P as groupBy, Pn as StackedAreaMarkOptions, Pr as timeScale, Pt as puor, Q as loessFit, Qn as LineCurve, Qt as PointSwatchSpec, R as quantile, Rn as areaMark, Rt as set1, S as HistogramMeasure, Sn as BarOrientation, Sr as GroupedBandScale, St as coolwarm, T as KdeOptions, Tn as DOTTED_PATTERN, Tr as NumericRange, Tt as greys, U as RollingWindow, Un as pointMark, Ut as viridis, V as RollingStatistic, Vn as groupedBarMark, Vt as spectral, W as RollingWindowOptions, Wn as stackedAreaMark, Wt as AreaSwatchSpec, X as confidenceBand, Xn as stack, Xt as LegendOrientation, Y as RegressionFit, Yn as StackSegment, Yt as LegendOptions, Z as linearFit, Zn as CustomCurve, Zt as LineSwatchSpec, _ as BinOptions, _n as valueLabelMark, _r as AxisScale, _t as categoricalPalette, a as RangePresetDomain, an as BandMarkOptions, ar as AxisMeasurement, at as createDataViewport, b as BoxStats, bn as BarBorderStyle, br as ContinuousScale, bt as colorScale, c as RangePresetsSubscriber, cr as AxisTickFormatter, ct as ContinuousAxisConfig, d as linearPreset, dn as ValueLabelAlign, dr as TickSpec, dt as VisibleDomainInput, en as areaSwatch, er as cardinalCurve, et as DataPanBoundsOptions, f as logPreset, fn as ValueLabelMarkOptions, fr as bottomAxis, ft as CategoricalPalette, g as BinClosed, gn as ruleMark, gr as truncateToWidth, gt as brbg, h as BinByResult, hn as bandMark, hr as topAxis, ht as blues, i as RangePresetDataDomain, in as pointSwatch, ir as AxisLabelConfig, it as Viewport, j as binBy, jn as PointBorderStyle, jr as linearScale, jt as piyg, k as bin, kn as MarkBuilder, kr as bandScale, kt as paired, l as TimePresetKey, ln as RuleAnchor, lr as AxisTitle, lt as TimeAxisConfig, m as BinByOptions, mn as VerticalRuleOptions, mr as rightAxis, mt as accent, n as RangePresetAxis, nn as legend, nr as resamplePoints, nt as DataViewportOptions, o as RangePresetsController, on as HorizontalBandOptions, or as AxisOptions, ot as linkViewports, p as timePreset, pn as VerticalBandOptions, pr as leftAxis, pt as ContinuousPalette, q as ConfidenceBandPoint, qn as StackOptions, qt as LegendBuilder, r as RangePresetContext, rn as lineSwatch, rr as AxisBuilder, rt as LinkViewportsOptions, s as RangePresetsOptions, sn as HorizontalRuleOptions, sr as AxisOrigin, st as BandAxisConfig, t as RangePreset, tn as barSwatch, tr as defineCurve, tt as DataViewport, u as createRangePresets, un as RuleMarkOptions, ur as TickIntervalSpec, ut as ViewportAxisConfig, v as BinResult, vn as Accessor, vr as BandScale, vt as category10, w as KdeKernel, wn as DASHED_PATTERN, wr as NumericDomain, wt as greens, x as BoxStatsOptions, xn as BarMarkOptions, xr as DateDomain, xt as continuousPalette, y as BinRule, yn as AreaMarkOptions, yr as BandScaleOptions, yt as cividis, z as RollingAxis, zn as barMark, zt as set2 } from "./range-presets-CzECsu3V.mjs";
2
+ import { BlendSpace, Color, FlingOptions, FrameRect, GlyphAtlas, Group, InteractionManager, Layer, Renderer2D } from "insomni";
3
+
4
+ //#region src/format.d.ts
5
+ interface SiNumberOptions {
6
+ /** Significant fraction digits after auto-scaling. Default `1`. */
7
+ precision?: number;
8
+ /** Trim trailing zeros (e.g. `1.0k` → `1k`). Default `true`. */
9
+ trim?: boolean;
10
+ /** Optional unit appended after the suffix (`siNumber(1500, { unit: "B" })` → `1.5kB`). */
11
+ unit?: string;
12
+ }
13
+ /**
14
+ * Format a number with SI suffix (`k`, `M`, `B`, `T`, `m`, `µ`, `n`).
15
+ * Negatives keep their sign. NaN → `"NaN"`. ±Infinity → `"∞"` / `"-∞"`.
16
+ */
17
+ declare function siNumber(value: number, options?: SiNumberOptions): string;
18
+ interface CurrencyOptions {
19
+ /** Currency symbol. Default `"$"`. */
20
+ symbol?: string;
21
+ /** Where the symbol goes. Default `"prefix"`. */
22
+ position?: "prefix" | "suffix";
23
+ /** Significant fraction digits. Default `1`. */
24
+ precision?: number;
25
+ /** Trim trailing zeros. Default `true`. */
26
+ trim?: boolean;
27
+ }
28
+ /**
29
+ * Currency-flavoured `siNumber` — `$1.2B`, `$420M`, `$50k`. The symbol can
30
+ * also go on the right (`1.2B €`) by setting `position: "suffix"`.
31
+ */
32
+ declare function currency(value: number, options?: CurrencyOptions): string;
33
+ interface PercentOptions {
34
+ /** Fraction digits. Default `0`. */
35
+ precision?: number;
36
+ /**
37
+ * If `true`, the input is a fraction (`0.42` → `"42%"`). If `false`, the
38
+ * input is already in percent units (`42` → `"42%"`). Default `false`.
39
+ */
40
+ fraction?: boolean;
41
+ }
42
+ /** Format `42` (or `0.42` with `fraction: true`) as `"42%"`. */
43
+ declare function percent(value: number, options?: PercentOptions): string;
44
+ interface FixedNumberOptions {
45
+ precision?: number;
46
+ /** Optional unit suffix (e.g. `" ms"`). */
47
+ unit?: string;
48
+ }
49
+ /** Plain `value.toFixed(precision)` plus optional unit. Useful for axes. */
50
+ declare function fixed(value: number, options?: FixedNumberOptions): string;
51
+ //#endregion
52
+ //#region src/heatmap/types.d.ts
53
+ interface HeatmapSpec<T> {
54
+ /** Datum → x value (in `xDomain` units). */
55
+ x: (d: T) => number;
56
+ /** Datum → y value (in `yDomain` units). */
57
+ y: (d: T) => number;
58
+ /** Datum → weight added to its bin. Default: `() => 1`. */
59
+ weight?: (d: T) => number;
60
+ /** Grid resolution `[nx, ny]`. */
61
+ bins: readonly [number, number];
62
+ /**
63
+ * Data domain along x. Data outside this range is dropped.
64
+ * Required unless `viewport` is supplied (in which case the viewport's
65
+ * visible x domain is used and this field is ignored).
66
+ */
67
+ xDomain?: readonly [number, number];
68
+ /** Data domain along y. See `xDomain`. */
69
+ yDomain?: readonly [number, number];
70
+ /**
71
+ * CSS-pixel rectangle the heatmap paints into.
72
+ * Required unless `viewport` is supplied (in which case `viewport.frame`
73
+ * is used and this field is ignored).
74
+ */
75
+ frame?: FrameRect;
76
+ /**
77
+ * Optional viewport for interactive pan/zoom. When supplied, the heatmap
78
+ * re-bins on every viewport change against `viewport.visibleXDomain` /
79
+ * `visibleYDomain`, and paints into `viewport.frame`. Pair with
80
+ * `bindViewport` to wire mouse / wheel / touch input.
81
+ */
82
+ viewport?: DataViewport<number, number>;
83
+ /** Palette sampled per-cell. */
84
+ colorMap: ContinuousPalette;
85
+ /**
86
+ * Fixed-point divisor used to encode float weights as `atomic<i32>` on the
87
+ * GPU path. `round(weight * weightScale)` is added per splat. Keep
88
+ * `|weight| * N * weightScale` inside `i32` range per cell.
89
+ * Default: `1_000_000`.
90
+ */
91
+ weightScale?: number;
92
+ /**
93
+ * Output strategy used by CPU-only renderers (e.g. `SVGRenderer`):
94
+ * - `"rects"`: emit one vector rect per non-empty bin. Best when the grid is
95
+ * small and you want an editable/inspectable SVG.
96
+ * - `"image"`: rasterize bins to a PNG and emit a single `<image>` element.
97
+ * Keeps exports small for dense grids.
98
+ * - `"auto"` (default): pick `"image"` when `nx * ny > 128 * 128`,
99
+ * otherwise `"rects"`.
100
+ */
101
+ svgExport?: "auto" | "rects" | "image";
102
+ /**
103
+ * How cells are sampled when the bin grid is upscaled to `frame`.
104
+ * - `"nearest"` (default): each cell renders as a crisp rectangle.
105
+ * - `"linear"`: bilinearly interpolate between cells for a smoothed look.
106
+ *
107
+ * Applies to both the GPU path (sprite sampler) and the CPU/SVG `"image"`
108
+ * path (CSS `image-rendering`). Has no effect on the `"rects"` SVG export.
109
+ */
110
+ interpolation?: "nearest" | "linear";
111
+ /**
112
+ * Per-cell value transform applied before color sampling. Default `"max"`
113
+ * — divide each bin by the grid's max so the palette spans `[0, 1]`.
114
+ * `"log"` and `"sqrt"` compress dynamic range so isolated hotspots don't
115
+ * wash out the rest of the field.
116
+ */
117
+ normalize?: "max" | "log" | "sqrt";
118
+ }
119
+ //#endregion
120
+ //#region src/heatmap/cpu.d.ts
121
+ /**
122
+ * CPU heatmap output: v3 `Layer`s of vector rects, consumed by the SVG export
123
+ * path and device-less consumers.
124
+ *
125
+ * The v1-only rasterized `ImageLayer` fast-path (dense grids / `svgExport:
126
+ * "image"`) was dropped in the v3 migration: v3's SVG renderer walks
127
+ * `Layer.pack` only and cannot emit `<image>`/sprite drawables, so that path
128
+ * silently rendered nothing post-migration. Dense grids now always emit vector
129
+ * rects (correct, if heavier). Re-introducing image export is future work on
130
+ * the v3 SVG backend (sprite → `<image>`).
131
+ */
132
+ type HeatmapCpuDrawable = Layer;
133
+ //#endregion
134
+ //#region src/heatmap.d.ts
135
+ /** Options threaded into the GPU build path. */
136
+ interface HeatmapBuildOptions {
137
+ /** The v3 renderer whose `compute(cb)` seam the binning passes are recorded onto. */
138
+ renderer: Renderer2D;
139
+ }
140
+ interface HeatmapProducer<T> {
141
+ /** Swap the underlying data. Invalidates both CPU and GPU bin state. */
142
+ setData(data: readonly T[]): void;
143
+ /**
144
+ * Largest bin weight currently visible. Triggers a (cheap) CPU rebin if
145
+ * needed. Useful when wiring a continuous color-bar legend whose domain
146
+ * tracks the actual data range. Returns `0` when no data is in view.
147
+ */
148
+ getMax(): number;
149
+ /**
150
+ * GPU path — queues the binning compute onto `renderer.compute(cb)` and returns
151
+ * a `space:"ui"` sprite {@link Layer} (a single quad covering the frame,
152
+ * sampling the compute-written output texture) to draw post-main. The renderer's
153
+ * device owns the GPU buffers/textures via `resolveRoot(renderer.device)`.
154
+ */
155
+ buildGPU(opts: HeatmapBuildOptions): Layer;
156
+ /**
157
+ * CPU path — returns v3 `Layer`s (vector rects) or a rasterized image layer.
158
+ * Used by the SVG export path and any device-less consumer.
159
+ */
160
+ buildCPU(): readonly HeatmapCpuDrawable[];
161
+ destroy(): void;
162
+ }
163
+ declare function heatmapLayer<T>(data: readonly T[], spec: HeatmapSpec<T>): HeatmapProducer<T>;
164
+ //#endregion
165
+ //#region src/interactions.d.ts
166
+ type AxisSelection = "x" | "y" | "xy" | "none";
167
+ interface BindDataViewportOptions {
168
+ /** Enable pointer drag pan. Default: true. */
169
+ drag?: boolean;
170
+ /** Enable mouse-wheel zoom. Default: true. */
171
+ wheel?: boolean;
172
+ /** Enable two-finger pinch (touch). Default: true. */
173
+ pinch?: boolean;
174
+ /** SmoothDamp time constant (seconds). `0` = instant (no smoothing). Default: `0`. */
175
+ smoothTime?: number;
176
+ /**
177
+ * Drag-release fling. `true` enables with defaults, `false` disables, or
178
+ * pass an object to tune. Default: off (fling on a chart feels disorienting).
179
+ */
180
+ fling?: boolean | FlingOptions;
181
+ /**
182
+ * Axes that respond to drag / pinch pan. Default: derived from axis types
183
+ * (continuous/time axes pan; band axes don't).
184
+ */
185
+ pan?: AxisSelection;
186
+ /** Axes that respond to wheel / pinch zoom. Default: derived from axis types. */
187
+ zoom?: AxisSelection;
188
+ /** Multiplier applied to wheel deltaY. Default: 0.001. */
189
+ wheelSensitivity?: number;
190
+ /**
191
+ * When true, Shift while wheeling zooms Y only; Meta / Ctrl zoom X only.
192
+ * Default: true.
193
+ */
194
+ axisModifiers?: boolean;
195
+ }
196
+ interface DataViewportBinding {
197
+ readonly mode: "data";
198
+ /** True while the user is actively dragging or pinching. */
199
+ readonly interacting: boolean;
200
+ /** True while a drag-release fling is still decaying. */
201
+ readonly flinging: boolean;
202
+ /** Hard disable. */
203
+ enabled: boolean;
204
+ /** Advance smoothing / fling by `dt` seconds and apply pending pan. */
205
+ update(dt: number): void;
206
+ /** Immediately cancel any pending smoothing and fling. */
207
+ stopAnimation(): void;
208
+ /** Remove all listeners and release any pending state. */
209
+ destroy(): void;
210
+ }
211
+ declare function bindDataViewport<X, Y>(viewport: DataViewport<X, Y>, element: HTMLElement, options?: BindDataViewportOptions): DataViewportBinding;
212
+ //#endregion
213
+ //#region src/colorbar.d.ts
214
+ type ColorBarOrientation = "vertical" | "horizontal";
215
+ type ColorBarLabelSide = "auto" | "before" | "after";
216
+ interface ColorBarOptions {
217
+ /** Continuous palette to sample. */
218
+ palette: ContinuousPalette;
219
+ /** Numeric domain mapped onto the bar. */
220
+ domain: readonly [number, number];
221
+ /** Default `"vertical"` (chart-right placement). */
222
+ orientation?: ColorBarOrientation;
223
+ /** Long-axis length in pixels. Default `120`. */
224
+ length?: number;
225
+ /** Short-axis thickness in pixels. Default `12`. */
226
+ thickness?: number;
227
+ /** Number of palette stops sampled into rects. Default `64`. */
228
+ steps?: number;
229
+ /** Tick count target. Default `5`. */
230
+ ticks?: number;
231
+ /** Optional explicit tick values (override `ticks`). */
232
+ tickValues?: readonly number[];
233
+ /**
234
+ * Minor ticks between majors — number `N` subdivides each major interval
235
+ * into `N` parts (so `N=2` puts one minor halfway between adjacent majors).
236
+ * Pass an explicit array to place minor ticks at specific values.
237
+ */
238
+ minorTicks?: number | readonly number[];
239
+ /** Length of minor tick marks. Default `tickSize / 2` from the axis. */
240
+ minorTickSize?: number;
241
+ /**
242
+ * Render a tick label only every `N`th major tick. Default `1`. Use `2`
243
+ * to label every other major, etc. The unlabeled ticks still draw.
244
+ */
245
+ labelStep?: number;
246
+ /** Tick label formatter. Default uses the underlying linear-scale formatter. */
247
+ format?: (v: number) => string;
248
+ /**
249
+ * Where to draw the tick labels relative to the bar.
250
+ * - `"after"` (default): right of vertical / below horizontal — the
251
+ * conventional placement next to a chart's outer edge.
252
+ * - `"before"`: left of vertical / above horizontal.
253
+ */
254
+ labelSide?: ColorBarLabelSide;
255
+ /** Optional axis title (typically the color channel's name). */
256
+ title?: string;
257
+ /** Atlas required to render labels/title. Without it the bar is unlabeled. */
258
+ atlas?: GlyphAtlas;
259
+ fontSize?: number;
260
+ labelColor?: Color;
261
+ titleFontSize?: number;
262
+ titleColor?: Color;
263
+ /** Optional outline around the bar rectangle. */
264
+ stroke?: Color;
265
+ strokeWidth?: number;
266
+ group?: Group;
267
+ /**
268
+ * Override the color space used to interpolate the palette stops into
269
+ * the bar's gradient. Falls back to the palette's own `blendSpace`
270
+ * (which the chart pipeline normally sets from `theme.paletteBlendSpace`,
271
+ * default `"oklch"`).
272
+ */
273
+ blendSpace?: BlendSpace;
274
+ }
275
+ /**
276
+ * Continuous color bar. Returned shape matches `LegendBuilder` so it slots
277
+ * into the same chart-pipeline legend anchor as the categorical legend().
278
+ */
279
+ declare function colorBar(options: ColorBarOptions): LegendBuilder;
280
+ //#endregion
281
+ //#region src/navigator.d.ts
282
+ /** Which axes the navigator's indicator (and interaction) tracks. */
283
+ type DataNavigatorAxes = "xy" | "x" | "y";
284
+ interface DataNavigatorIndicatorOptions {
285
+ fill?: Color;
286
+ stroke?: Color;
287
+ strokeWidth?: number;
288
+ cornerRadius?: number;
289
+ }
290
+ interface DataNavigatorInteractionOptions {
291
+ manager: InteractionManager;
292
+ /** Drag inside the overview to pan/reframe the source. Default: true. */
293
+ drag?: boolean;
294
+ /** Press outside the indicator to recenter. Default: `"center"`. */
295
+ click?: "center" | false;
296
+ /**
297
+ * Drag the indicator's outer edges to reframe the source instead of panning.
298
+ * 1D-only — only meaningful for `axes: "x"` or `"y"`. Default: `true` for 1D,
299
+ * `false` for `"xy"`.
300
+ */
301
+ resizeEdges?: boolean;
302
+ /** Edge hit-zone width in CSS pixels. Default: 6. */
303
+ edgeHitPx?: number;
304
+ /** Override the interaction-node bounds. Default: `overview.absoluteFrame`. */
305
+ bounds?: () => FrameRect;
306
+ /** Interaction node z-index. Default: 50. */
307
+ zIndex?: number;
308
+ }
309
+ interface DataNavigatorOptions<X = unknown, Y = unknown> {
310
+ /** Source data viewport the user navigates in the main view. */
311
+ source: DataViewport<X, Y>;
312
+ /** Overview data viewport that hosts the navigator. */
313
+ overview: DataViewport<X, Y>;
314
+ /** Required: callback that populates the navigator-owned content layer. */
315
+ render: (target: Layer) => void;
316
+ /** Which axes the indicator tracks. Default: `"xy"`. */
317
+ axes?: DataNavigatorAxes;
318
+ indicator?: DataNavigatorIndicatorOptions;
319
+ interaction?: DataNavigatorInteractionOptions;
320
+ /** Bake the render-callback target to an offscreen texture. */
321
+ cache?: {
322
+ renderer: {
323
+ cacheLayer(layer: Layer): void;
324
+ };
325
+ };
326
+ }
327
+ interface DataNavigator {
328
+ readonly layers: readonly Layer[];
329
+ readonly interacting: boolean;
330
+ refresh(): void;
331
+ dispose(): void;
332
+ }
333
+ /**
334
+ * Build a Navigator for a data viewport: a secondary view of the same data
335
+ * with a rect that tracks the source's visible domain. Drag inside the
336
+ * overview pans/reframes the source.
337
+ */
338
+ declare function createDataNavigator<X = unknown, Y = unknown>(opts: DataNavigatorOptions<X, Y>): DataNavigator;
339
+ //#endregion
340
+ export { type Accessor, type AreaMarkOptions, type AreaSwatchSpec, type AxisBuilder, type AxisLabelConfig, type AxisMeasurement, type AxisOptions, type AxisOrigin, type AxisScale, type AxisSelection, type AxisTickFormatter, type AxisTitle, type BandAxisConfig, type BandMarkOptions, type BandScale, type BandScaleOptions, type BarBorderStyle, type BarMarkOptions, type BarOrientation, type BarSwatchSpec, type BinByOptions, type BinByResult, type BinClosed, type BinOptions, type BinResult, type BinRule, type BindDataViewportOptions, type BoxStats, type BoxStatsOptions, type CategoricalBarMarkOptions, type CategoricalPalette, type ColorBarLabelSide, type ColorBarOptions, type ColorBarOrientation, type ConfidenceBandOptions, type ConfidenceBandPoint, type ContinuousAxisConfig, type ContinuousPalette, type ContinuousScale, type CurrencyOptions, type CustomCurve, DASHED_PATTERN, DOTTED_PATTERN, type DataNavigator, type DataNavigatorAxes, type DataNavigatorIndicatorOptions, type DataNavigatorInteractionOptions, type DataNavigatorOptions, type DataPanBoundsOptions, type DataViewport, type DataViewportBinding, type DataViewportOptions, type DateDomain, type FixedNumberOptions, type GroupedBandScale, type GroupedBandScaleOptions, type GroupedBarMarkOptions, type HeatmapProducer, type HeatmapSpec, type HistogramMeasure, type HorizontalBandOptions, type HorizontalRuleOptions, type KdeBandwidth, type KdeKernel, type KdeOptions, type KdeResult, type LegendAlign, type LegendBuilder, type LegendEntry, type LegendOptions, type LegendOrientation, type LineCurve, type LineCurvePreset, type LineDashStyle, type LineMarkOptions, type LineSwatchSpec, type LinkViewportsOptions, type LoessOptions, type MarkBuilder, type MarkOrigin, type NumericDomain, type NumericRange, type PercentOptions, type PointBorderStyle, type PointMarkOptions, type PointShapeKind, type PointSwatchSpec, type QuantileMethod, type RangePreset, type RangePresetAxis, type RangePresetContext, type RangePresetDataDomain, type RangePresetDomain, type RangePresetsController, type RangePresetsOptions, type RangePresetsSubscriber, type RegressionFit, type RollingAxis, type RollingPoint, type RollingStatistic, type RollingStatisticKind, type RollingWindow, type RollingWindowOptions, type RuleAnchor, type RuleMarkOptions, type SiNumberOptions, type StackOffset, type StackOptions, type StackOrder, type StackSegment, type StackedAreaMarkOptions, type StackedBarMarkOptions, type StackedMarkBuilder, type SwatchSpec, type TickFormatter, type TickIntervalSpec, type TickSpec, type TimeAxisConfig, type TimeIntervalUnit, type TimePresetKey, type TimeScale, type ValueLabelAlign, type ValueLabelMarkOptions, type ValueOrAccessor, type VerticalBandOptions, type VerticalRuleOptions, type Viewport, type ViewportAxisConfig, type VisibleDomainInput, type WhiskerRule, accent, areaMark, areaSwatch, bandMark, bandScale, barMark, barSwatch, bin, binBreaks, binBy, binWithBreaks, bindDataViewport, blues, bottomAxis, boxStats, brbg, cardinalCurve, categoricalBarMark, categoricalPalette, category10, cividis, colorBar, colorScale, confidenceBand, continuousPalette, coolwarm, createDataNavigator, createDataViewport, createRangePresets, currency, dark2, defineCurve, fixed, greens, greys, groupBy, groupedBandScale, groupedBarMark, heatmapLayer, histogramMeasureValue, inferno, jitter, kde, leftAxis, legend, lineMark, lineSwatch, linearFit, linearPreset, linearScale, linkViewports, loessFit, logPreset, logScale, magma, oranges, paired, pastel, percent, piyg, plasma, pointMark, pointSwatch, polyFit, prgn, puor, purples, quantile, rdbu, reds, resamplePoints, rightAxis, rollingWindow, ruleMark, set1, set2, set3, siNumber, spectral, sqrtScale, stack, stackedAreaMark, stackedBarMark, tableau10, timePreset, timeScale, timeTickFormat, timeTicks, topAxis, truncateToWidth, valueLabelMark, viridis };