@tetrascience-npm/ts-lib-viz 0.0.0-stage → 0.1.4

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 (278) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +2171 -2
  3. package/dist/src/builder/PlotPanel.d.ts +42 -0
  4. package/dist/src/builder/PlotPanel.js +433 -0
  5. package/dist/src/builder/Popover.d.ts +37 -0
  6. package/dist/src/builder/Popover.js +32 -0
  7. package/dist/src/builder/Stepper.d.ts +21 -0
  8. package/dist/src/builder/Stepper.js +41 -0
  9. package/dist/src/builder/index.d.ts +10 -0
  10. package/dist/src/builder/index.js +10 -0
  11. package/dist/src/core/adapters.d.ts +86 -0
  12. package/dist/src/core/adapters.js +219 -0
  13. package/dist/src/core/aggregate.d.ts +74 -0
  14. package/dist/src/core/aggregate.js +102 -0
  15. package/dist/src/core/annotations.d.ts +34 -0
  16. package/dist/src/core/annotations.js +71 -0
  17. package/dist/src/core/band-order.d.ts +86 -0
  18. package/dist/src/core/band-order.js +132 -0
  19. package/dist/src/core/binning.d.ts +123 -0
  20. package/dist/src/core/binning.js +193 -0
  21. package/dist/src/core/bounds.d.ts +40 -0
  22. package/dist/src/core/bounds.js +107 -0
  23. package/dist/src/core/brush.d.ts +73 -0
  24. package/dist/src/core/brush.js +102 -0
  25. package/dist/src/core/build.d.ts +322 -0
  26. package/dist/src/core/build.js +496 -0
  27. package/dist/src/core/camera.d.ts +152 -0
  28. package/dist/src/core/camera.js +303 -0
  29. package/dist/src/core/capabilities.d.ts +24 -0
  30. package/dist/src/core/capabilities.js +307 -0
  31. package/dist/src/core/chord.d.ts +49 -0
  32. package/dist/src/core/chord.js +57 -0
  33. package/dist/src/core/circular.d.ts +83 -0
  34. package/dist/src/core/circular.js +63 -0
  35. package/dist/src/core/cluster.d.ts +136 -0
  36. package/dist/src/core/cluster.js +607 -0
  37. package/dist/src/core/critique.d.ts +92 -0
  38. package/dist/src/core/critique.js +905 -0
  39. package/dist/src/core/density.d.ts +38 -0
  40. package/dist/src/core/density.js +82 -0
  41. package/dist/src/core/figure-set.d.ts +34 -0
  42. package/dist/src/core/figure-set.js +55 -0
  43. package/dist/src/core/finding-codes.d.ts +10 -0
  44. package/dist/src/core/finding-codes.js +1 -0
  45. package/dist/src/core/fit-types.d.ts +46 -0
  46. package/dist/src/core/fit-types.js +7 -0
  47. package/dist/src/core/fitter.d.ts +62 -0
  48. package/dist/src/core/fitter.js +102 -0
  49. package/dist/src/core/frame-geometry.d.ts +407 -0
  50. package/dist/src/core/frame-geometry.js +612 -0
  51. package/dist/src/core/frame.d.ts +329 -0
  52. package/dist/src/core/frame.js +1432 -0
  53. package/dist/src/core/geom-table.d.ts +503 -0
  54. package/dist/src/core/geom-table.js +484 -0
  55. package/dist/src/core/geom-types.d.ts +182 -0
  56. package/dist/src/core/geom-types.js +17 -0
  57. package/dist/src/core/grammar.d.ts +359 -0
  58. package/dist/src/core/grammar.js +397 -0
  59. package/dist/src/core/heat-reductions.d.ts +36 -0
  60. package/dist/src/core/heat-reductions.js +133 -0
  61. package/dist/src/core/hexbin.d.ts +84 -0
  62. package/dist/src/core/hexbin.js +168 -0
  63. package/dist/src/core/hierarchy.d.ts +59 -0
  64. package/dist/src/core/hierarchy.js +248 -0
  65. package/dist/src/core/hit.d.ts +75 -0
  66. package/dist/src/core/hit.js +37 -0
  67. package/dist/src/core/index.d.ts +33 -0
  68. package/dist/src/core/index.js +18 -0
  69. package/dist/src/core/internal.d.ts +58 -0
  70. package/dist/src/core/internal.js +58 -0
  71. package/dist/src/core/labels.d.ts +37 -0
  72. package/dist/src/core/labels.js +54 -0
  73. package/dist/src/core/layers.d.ts +594 -0
  74. package/dist/src/core/layers.js +2892 -0
  75. package/dist/src/core/load.d.ts +17 -0
  76. package/dist/src/core/load.js +356 -0
  77. package/dist/src/core/marginal.d.ts +65 -0
  78. package/dist/src/core/marginal.js +116 -0
  79. package/dist/src/core/mesh.d.ts +69 -0
  80. package/dist/src/core/mesh.js +237 -0
  81. package/dist/src/core/omission.d.ts +41 -0
  82. package/dist/src/core/omission.js +62 -0
  83. package/dist/src/core/palette-sets.d.ts +623 -0
  84. package/dist/src/core/palette-sets.js +1058 -0
  85. package/dist/src/core/palette.d.ts +871 -0
  86. package/dist/src/core/palette.js +511 -0
  87. package/dist/src/core/plot-data.d.ts +71 -0
  88. package/dist/src/core/plot-data.js +82 -0
  89. package/dist/src/core/predicate.d.ts +50 -0
  90. package/dist/src/core/predicate.js +20 -0
  91. package/dist/src/core/profile.d.ts +111 -0
  92. package/dist/src/core/profile.js +221 -0
  93. package/dist/src/core/readout.d.ts +108 -0
  94. package/dist/src/core/readout.js +215 -0
  95. package/dist/src/core/region.d.ts +56 -0
  96. package/dist/src/core/region.js +101 -0
  97. package/dist/src/core/rings.d.ts +96 -0
  98. package/dist/src/core/rings.js +171 -0
  99. package/dist/src/core/rules.d.ts +45 -0
  100. package/dist/src/core/rules.js +69 -0
  101. package/dist/src/core/sankey.d.ts +49 -0
  102. package/dist/src/core/sankey.js +96 -0
  103. package/dist/src/core/select.d.ts +52 -0
  104. package/dist/src/core/select.js +216 -0
  105. package/dist/src/core/side-track.d.ts +98 -0
  106. package/dist/src/core/side-track.js +197 -0
  107. package/dist/src/core/sizing.d.ts +54 -0
  108. package/dist/src/core/sizing.js +37 -0
  109. package/dist/src/core/spec-edit.d.ts +68 -0
  110. package/dist/src/core/spec-edit.js +105 -0
  111. package/dist/src/core/spec.d.ts +1111 -0
  112. package/dist/src/core/spec.js +39 -0
  113. package/dist/src/core/stats.d.ts +161 -0
  114. package/dist/src/core/stats.js +318 -0
  115. package/dist/src/core/tick-format.d.ts +21 -0
  116. package/dist/src/core/tick-format.js +87 -0
  117. package/dist/src/core/tokens.d.ts +47 -0
  118. package/dist/src/core/tokens.js +138 -0
  119. package/dist/src/core/transform.d.ts +21 -0
  120. package/dist/src/core/transform.js +19 -0
  121. package/dist/src/core/voxels.d.ts +53 -0
  122. package/dist/src/core/voxels.js +129 -0
  123. package/dist/src/core/zoom.d.ts +76 -0
  124. package/dist/src/core/zoom.js +103 -0
  125. package/dist/src/graph/GraphSurface.d.ts +127 -0
  126. package/dist/src/graph/GraphSurface.js +423 -0
  127. package/dist/src/graph/data.d.ts +103 -0
  128. package/dist/src/graph/data.js +140 -0
  129. package/dist/src/graph/index.d.ts +7 -0
  130. package/dist/src/graph/index.js +7 -0
  131. package/dist/src/mcp/data.d.ts +28 -0
  132. package/dist/src/mcp/data.js +131 -0
  133. package/dist/src/mcp/index.d.ts +7 -0
  134. package/dist/src/mcp/index.js +7 -0
  135. package/dist/src/mcp/paths.d.ts +12 -0
  136. package/dist/src/mcp/paths.js +30 -0
  137. package/dist/src/mcp/render.d.ts +67 -0
  138. package/dist/src/mcp/render.js +189 -0
  139. package/dist/src/mcp/server.d.ts +7 -0
  140. package/dist/src/mcp/server.js +25 -0
  141. package/dist/src/mcp/tools.d.ts +82 -0
  142. package/dist/src/mcp/tools.js +412 -0
  143. package/dist/src/react/BrushLayer.d.ts +20 -0
  144. package/dist/src/react/BrushLayer.js +98 -0
  145. package/dist/src/react/ColorLegend.d.ts +45 -0
  146. package/dist/src/react/ColorLegend.js +64 -0
  147. package/dist/src/react/Figure.d.ts +19 -0
  148. package/dist/src/react/Figure.js +6 -0
  149. package/dist/src/react/Frame.d.ts +87 -0
  150. package/dist/src/react/Frame.js +192 -0
  151. package/dist/src/react/MarkLegend.d.ts +32 -0
  152. package/dist/src/react/MarkLegend.js +24 -0
  153. package/dist/src/react/SeriesLegend.d.ts +38 -0
  154. package/dist/src/react/SeriesLegend.js +27 -0
  155. package/dist/src/react/SizeLegend.d.ts +24 -0
  156. package/dist/src/react/SizeLegend.js +25 -0
  157. package/dist/src/react/Toolbar.d.ts +109 -0
  158. package/dist/src/react/Toolbar.js +483 -0
  159. package/dist/src/react/Tooltip.d.ts +37 -0
  160. package/dist/src/react/Tooltip.js +59 -0
  161. package/dist/src/react/Viz.d.ts +112 -0
  162. package/dist/src/react/Viz.js +1311 -0
  163. package/dist/src/react/export.d.ts +32 -0
  164. package/dist/src/react/export.js +181 -0
  165. package/dist/src/react/geoms/Area.d.ts +38 -0
  166. package/dist/src/react/geoms/Area.js +48 -0
  167. package/dist/src/react/geoms/Bars.d.ts +130 -0
  168. package/dist/src/react/geoms/Bars.js +164 -0
  169. package/dist/src/react/geoms/Box.d.ts +50 -0
  170. package/dist/src/react/geoms/Box.js +32 -0
  171. package/dist/src/react/geoms/Chord.d.ts +60 -0
  172. package/dist/src/react/geoms/Chord.js +78 -0
  173. package/dist/src/react/geoms/Contour.d.ts +44 -0
  174. package/dist/src/react/geoms/Contour.js +78 -0
  175. package/dist/src/react/geoms/DensityCurve.d.ts +30 -0
  176. package/dist/src/react/geoms/DensityCurve.js +38 -0
  177. package/dist/src/react/geoms/FitCurve.d.ts +26 -0
  178. package/dist/src/react/geoms/FitCurve.js +52 -0
  179. package/dist/src/react/geoms/Freqpoly.d.ts +30 -0
  180. package/dist/src/react/geoms/Freqpoly.js +45 -0
  181. package/dist/src/react/geoms/Gauge.d.ts +42 -0
  182. package/dist/src/react/geoms/Gauge.js +90 -0
  183. package/dist/src/react/geoms/Heatmap.d.ts +79 -0
  184. package/dist/src/react/geoms/Heatmap.js +51 -0
  185. package/dist/src/react/geoms/Hexbin.d.ts +74 -0
  186. package/dist/src/react/geoms/Hexbin.js +89 -0
  187. package/dist/src/react/geoms/Icicle.d.ts +38 -0
  188. package/dist/src/react/geoms/Icicle.js +9 -0
  189. package/dist/src/react/geoms/Ideogram.d.ts +58 -0
  190. package/dist/src/react/geoms/Ideogram.js +77 -0
  191. package/dist/src/react/geoms/Interval.d.ts +28 -0
  192. package/dist/src/react/geoms/Interval.js +39 -0
  193. package/dist/src/react/geoms/Line.d.ts +39 -0
  194. package/dist/src/react/geoms/Line.js +52 -0
  195. package/dist/src/react/geoms/Parallel.d.ts +38 -0
  196. package/dist/src/react/geoms/Parallel.js +131 -0
  197. package/dist/src/react/geoms/Pie.d.ts +62 -0
  198. package/dist/src/react/geoms/Pie.js +59 -0
  199. package/dist/src/react/geoms/Points.d.ts +84 -0
  200. package/dist/src/react/geoms/Points.js +207 -0
  201. package/dist/src/react/geoms/Points3d.d.ts +49 -0
  202. package/dist/src/react/geoms/Points3d.js +58 -0
  203. package/dist/src/react/geoms/Radar.d.ts +39 -0
  204. package/dist/src/react/geoms/Radar.js +59 -0
  205. package/dist/src/react/geoms/Range.d.ts +31 -0
  206. package/dist/src/react/geoms/Range.js +20 -0
  207. package/dist/src/react/geoms/RingStack.d.ts +39 -0
  208. package/dist/src/react/geoms/RingStack.js +65 -0
  209. package/dist/src/react/geoms/Rule.d.ts +29 -0
  210. package/dist/src/react/geoms/Rule.js +51 -0
  211. package/dist/src/react/geoms/Sankey.d.ts +24 -0
  212. package/dist/src/react/geoms/Sankey.js +51 -0
  213. package/dist/src/react/geoms/Segment.d.ts +36 -0
  214. package/dist/src/react/geoms/Segment.js +39 -0
  215. package/dist/src/react/geoms/Sunburst.d.ts +46 -0
  216. package/dist/src/react/geoms/Sunburst.js +64 -0
  217. package/dist/src/react/geoms/Surface.d.ts +32 -0
  218. package/dist/src/react/geoms/Surface.js +49 -0
  219. package/dist/src/react/geoms/Text.d.ts +35 -0
  220. package/dist/src/react/geoms/Text.js +40 -0
  221. package/dist/src/react/geoms/Treemap.d.ts +39 -0
  222. package/dist/src/react/geoms/Treemap.js +16 -0
  223. package/dist/src/react/geoms/Violin.d.ts +56 -0
  224. package/dist/src/react/geoms/Violin.js +60 -0
  225. package/dist/src/react/geoms/Volume.d.ts +37 -0
  226. package/dist/src/react/geoms/Volume.js +40 -0
  227. package/dist/src/react/geoms/Waterfall.d.ts +43 -0
  228. package/dist/src/react/geoms/Waterfall.js +18 -0
  229. package/dist/src/react/geoms/cube-stage.d.ts +39 -0
  230. package/dist/src/react/geoms/cube-stage.js +85 -0
  231. package/dist/src/react/geoms/hierarchy-cells.d.ts +42 -0
  232. package/dist/src/react/geoms/hierarchy-cells.js +59 -0
  233. package/dist/src/react/geoms/sector-axis.d.ts +66 -0
  234. package/dist/src/react/geoms/sector-axis.js +99 -0
  235. package/dist/src/react/gl/GlMesh.d.ts +22 -0
  236. package/dist/src/react/gl/GlMesh.js +78 -0
  237. package/dist/src/react/gl/GlPoints.d.ts +45 -0
  238. package/dist/src/react/gl/GlPoints.js +117 -0
  239. package/dist/src/react/gl/GlVolume.d.ts +28 -0
  240. package/dist/src/react/gl/GlVolume.js +112 -0
  241. package/dist/src/react/gl/GlWalls.d.ts +24 -0
  242. package/dist/src/react/gl/GlWalls.js +55 -0
  243. package/dist/src/react/gl/context.d.ts +71 -0
  244. package/dist/src/react/gl/context.js +98 -0
  245. package/dist/src/react/gl/encode.d.ts +120 -0
  246. package/dist/src/react/gl/encode.js +215 -0
  247. package/dist/src/react/gl/index.d.ts +10 -0
  248. package/dist/src/react/gl/index.js +8 -0
  249. package/dist/src/react/gl/refresh.d.ts +7 -0
  250. package/dist/src/react/gl/refresh.js +19 -0
  251. package/dist/src/react/gl/renderer.d.ts +377 -0
  252. package/dist/src/react/gl/renderer.js +1081 -0
  253. package/dist/src/react/gl/shaders.d.ts +92 -0
  254. package/dist/src/react/gl/shaders.js +405 -0
  255. package/dist/src/react/gl/surface.d.ts +31 -0
  256. package/dist/src/react/gl/surface.js +73 -0
  257. package/dist/src/react/index.d.ts +12 -0
  258. package/dist/src/react/index.js +11 -0
  259. package/dist/src/react/orbit.d.ts +38 -0
  260. package/dist/src/react/orbit.js +81 -0
  261. package/dist/src/react/sides/DendrogramPanel.d.ts +32 -0
  262. package/dist/src/react/sides/DendrogramPanel.js +39 -0
  263. package/dist/src/react/sides/DensityPanel.d.ts +31 -0
  264. package/dist/src/react/sides/DensityPanel.js +37 -0
  265. package/dist/src/react/sides/HistogramPanel.d.ts +30 -0
  266. package/dist/src/react/sides/HistogramPanel.js +18 -0
  267. package/dist/src/react/sides/RugPanel.d.ts +28 -0
  268. package/dist/src/react/sides/RugPanel.js +21 -0
  269. package/dist/src/react/sides/TrackPanel.d.ts +37 -0
  270. package/dist/src/react/sides/TrackPanel.js +27 -0
  271. package/dist/src/react/theme.d.ts +48 -0
  272. package/dist/src/react/theme.js +148 -0
  273. package/dist/src/react/useFits.d.ts +26 -0
  274. package/dist/src/react/useFits.js +62 -0
  275. package/dist/src/react/useZoom.d.ts +50 -0
  276. package/dist/src/react/useZoom.js +141 -0
  277. package/package.json +164 -5
  278. package/theme/default.css +62 -0
@@ -0,0 +1,594 @@
1
+ /**
2
+ * What a plot draws, resolved to a flat list of traces before anything renders.
3
+ *
4
+ * A series names a chart kind. This resolves it to a geom and a reduction.
5
+ */
6
+ import { type BinSpec } from "./binning.js";
7
+ import { type PlotData, type PlotField } from "./plot-data.js";
8
+ import { type Assignments } from "./figure-set.js";
9
+ import { type ChartSpec, type ColorScale, type Linetype, type PlotKind, type LayerSpec } from "./spec.js";
10
+ import { type Metrics } from "./sizing.js";
11
+ import { type MeshData, type Relief } from "./mesh.js";
12
+ import { type Field3d } from "./voxels.js";
13
+ import { type Density } from "./stats.js";
14
+ import { type PointShape } from "./geom-types.js";
15
+ import type { BarDatum, IntervalPoint } from "./geom-types.js";
16
+ import type { HeatCell } from "./geom-types.js";
17
+ import type { BoxDatum } from "./geom-types.js";
18
+ import type { SegmentPoint } from "./geom-types.js";
19
+ import type { ViolinDatum } from "./geom-types.js";
20
+ import type { ParallelAxis, ParallelLine } from "./geom-types.js";
21
+ import type { SankeyLinkInput, SankeyNodeInput } from "./geom-types.js";
22
+ import { type ChordLink } from "./chord.js";
23
+ import { type RingReading } from "./rings.js";
24
+ import type { PositionLink, SectorSpec } from "./circular.js";
25
+ import { type HierarchyCell } from "./hierarchy.js";
26
+ import type { PlotPoint } from "./hit.js";
27
+ import { type Aggregate } from "./aggregate.js";
28
+ import { type Omission } from "./omission.js";
29
+ import type { RuleLine } from "./rules.js";
30
+ import { type AxisTransform } from "./transform.js";
31
+ /** Geoms a layer can resolve to. */
32
+ export type Geom = "point" | "line" | "area" | "ribbon" | "range" | "segment" | "smooth" | "bar" | "waterfall" | "freqpoly" | "boxplot" | "violin" | "density" | "hex" | "contour" | "treemap" | "icicle" | "sunburst" | "sankey" | "chord" | "ideogram" | "heatmap" | "parcoords" | "radar" | "pie" | "gauge" | "point3d" | "surface" | "mesh3d" | "isosurface" | "volume" | "hline" | "vline" | "abline" | "text";
33
+ /**
34
+ * Whether a geom draws against the frame's axes.
35
+ *
36
+ * A treemap positions by nesting and a sankey by flow. Read off `GRAMMAR`'s coordinate column.
37
+ */
38
+ export declare const drawsAxes: (geom: Geom) => boolean;
39
+ /** Whether the horizontal axis positions by category or by value. */
40
+ export type AxisKind = "band" | "continuous";
41
+ /**
42
+ * The geometry a kind draws with. A kind this version does not know answers undefined.
43
+ *
44
+ * Reads the geometry column of `GRAMMAR`.
45
+ */
46
+ export declare const geomFor: (kind: PlotKind) => Geom | undefined;
47
+ /** A record projected into plot space, carrying enough to reach the row behind it. */
48
+ export interface LayerPoint extends PlotPoint {
49
+ /** Row in the source. A click opens the record the grid already knows. */
50
+ row: number;
51
+ /** Row in the table the figure read, before a split or a facet narrowed it. The tooltip reads there. */
52
+ plotRow?: number;
53
+ /** Direct label, where the series asked for one. */
54
+ text?: string;
55
+ /** Breaks a line before this reading. A missing or dropped reading sits between it and the one before. */
56
+ gap?: boolean;
57
+ /**
58
+ * The size field's reading, in its own units, beside the radius resolved from it.
59
+ *
60
+ * `size` is pixels and no rescale reaches them. The value survives the build for
61
+ * `shareScales`.
62
+ */
63
+ sizeValue?: number;
64
+ }
65
+ /** A segment and the row it came from. */
66
+ export interface LayerSegment extends SegmentPoint {
67
+ /** Row in the source. */
68
+ row: number;
69
+ /** Row in the table the figure read, before a split or a facet narrowed it. */
70
+ plotRow?: number;
71
+ }
72
+ /** What both hierarchy arrangements carry. The geom beside it says which of the two drew. */
73
+ interface HierarchyData {
74
+ at: "groups";
75
+ cells: HierarchyCell[];
76
+ aggregate: Aggregate;
77
+ /** Cells the cap turned down, with their descendants. The footer states the count. */
78
+ dropped: number;
79
+ }
80
+ /**
81
+ * What a trace holds, and how it draws.
82
+ *
83
+ * Two questions. `at` says whether the payload is records or a reduction per group. `geom` says
84
+ * what draws it.
85
+ */
86
+ export type LayerData = {
87
+ at: "records";
88
+ geom: "point" | "hex" | "contour" | "line" | "smooth";
89
+ points: LayerPoint[];
90
+ /**
91
+ * Multiplier on the smoothing radius, where the geom estimates a density. Absent takes 1.
92
+ *
93
+ * A contour estimates in pixel space. The radius belongs to the geom.
94
+ */
95
+ adjust?: number;
96
+ /** A contour's own lattice, where a measure is bound to `z`. The bands cut its values. */
97
+ grid?: Relief;
98
+ } | {
99
+ at: "records";
100
+ geom: "point3d";
101
+ points: LayerPoint[];
102
+ zField: PlotField;
103
+ xDomain: [number, number];
104
+ yDomain: [number, number];
105
+ zDomain: [number, number];
106
+ } | {
107
+ at: "groups";
108
+ geom: "isosurface" | "volume";
109
+ field: Field3d;
110
+ /** The measure the cells carry, or absent where the reduction is a count of the rows. */
111
+ valueField?: PlotField;
112
+ xDomain: [number, number];
113
+ yDomain: [number, number];
114
+ zDomain: [number, number];
115
+ } | {
116
+ at: "groups";
117
+ geom: "surface" | "mesh3d";
118
+ mesh: MeshData;
119
+ zField: PlotField;
120
+ xDomain: [number, number];
121
+ yDomain: [number, number];
122
+ /** Set on a relief, which reduces a measure over a grid. A structure reduces nothing. */
123
+ aggregate?: Aggregate;
124
+ } | {
125
+ at: "records";
126
+ geom: "ribbon";
127
+ readings: IntervalPoint[];
128
+ } | {
129
+ at: "records";
130
+ geom: "range";
131
+ glyph: "errorbar" | "linerange" | "pointrange" | "crossbar";
132
+ readings: IntervalPoint[];
133
+ } | {
134
+ at: "records";
135
+ geom: "segment";
136
+ segments: LayerSegment[];
137
+ } | {
138
+ at: "records";
139
+ geom: "hline" | "vline" | "abline";
140
+ rules: RuleLine[];
141
+ } | {
142
+ at: "records";
143
+ geom: "text";
144
+ points: LayerPoint[];
145
+ boxed?: boolean;
146
+ slot?: {
147
+ index: number;
148
+ of: number;
149
+ width?: number;
150
+ cap?: number;
151
+ ofBand?: Record<string, number>;
152
+ };
153
+ } | {
154
+ at: "records";
155
+ geom: "parcoords";
156
+ axes: ParallelAxis[];
157
+ lines: ParallelLine[];
158
+ } | {
159
+ at: "records";
160
+ geom: "radar";
161
+ axes: ParallelAxis[];
162
+ lines: ParallelLine[];
163
+ } | (HierarchyData & {
164
+ geom: "treemap";
165
+ }) | (HierarchyData & {
166
+ geom: "icicle";
167
+ }) | (HierarchyData & {
168
+ geom: "sunburst";
169
+ }) | {
170
+ at: "groups";
171
+ geom: "gauge";
172
+ value: number;
173
+ /** Low and high end of the dial, from `scales.y.limits` or from the measure's own extent. */
174
+ range: [number, number];
175
+ aggregate: Aggregate;
176
+ } | {
177
+ at: "groups";
178
+ geom: "bar" | "waterfall" | "line" | "area" | "pie" | "freqpoly";
179
+ bars: BarDatum[];
180
+ aggregate: Aggregate;
181
+ binWidth?: number;
182
+ /** Which interval the whiskers stand for. The footer names it. */
183
+ error?: "sd" | "sem";
184
+ /** Groups with more readings than a band separates. The footer states the count. */
185
+ replicatesDropped?: number;
186
+ /** Rows the horizontal axis's transform had no place for. The footer states the count. */
187
+ offScale?: number;
188
+ /**
189
+ * Which slot of the band this geom takes. Absent takes it whole.
190
+ *
191
+ * The core says which of how many and the geom does the arithmetic.
192
+ */
193
+ slot?: {
194
+ index: number;
195
+ of: number;
196
+ width?: number;
197
+ };
198
+ /**
199
+ * Set where a fill divided these geoms by their band's total. The values are shares.
200
+ *
201
+ * They are dimensionless and sum to one per band. Held on the payload beside `slot`.
202
+ */
203
+ shares?: boolean;
204
+ /** Set where each value adds the ones before it. A band keeps its read order under it. */
205
+ cumulative?: boolean;
206
+ } | {
207
+ at: "groups";
208
+ geom: "boxplot";
209
+ boxes: BoxDatum[];
210
+ } | {
211
+ at: "groups";
212
+ geom: "violin";
213
+ violins: ViolinDatum[];
214
+ }
215
+ /**
216
+ * A kernel density over one measure, as one curve.
217
+ *
218
+ * The bandwidth travels with the curve and the footer names it. A `group` gives one each.
219
+ */
220
+ | {
221
+ at: "groups";
222
+ geom: "density";
223
+ curve: Density;
224
+ } | {
225
+ at: "groups";
226
+ geom: "heatmap";
227
+ cells: HeatCell[];
228
+ aggregate: Aggregate;
229
+ } | {
230
+ at: "groups";
231
+ geom: "ideogram";
232
+ sectors: SectorSpec[];
233
+ /** One span per row, in its sector's own units. */
234
+ tiles: {
235
+ sector: string;
236
+ start: number;
237
+ end: number;
238
+ level?: string;
239
+ }[];
240
+ /** The stains a tile paints by, in the order they were met. */
241
+ levels: string[];
242
+ /** One pair of positions per row that named a far end. */
243
+ links: PositionLink[];
244
+ /** Where the links' own measure runs, for the magnitude map. Absent where none was bound. */
245
+ linkDomain?: [number, number];
246
+ rings: (RingReading | null)[];
247
+ } | {
248
+ at: "groups";
249
+ geom: "chord";
250
+ links: ChordLink[];
251
+ /** One entry per ring the author stacked, innermost first. A ring with no reading is null. */
252
+ rings: (RingReading | null)[];
253
+ } | {
254
+ at: "groups";
255
+ geom: "sankey";
256
+ nodes: SankeyNodeInput[];
257
+ links: SankeyLinkInput[];
258
+ /** What a value is measured against. The geom holds the height a thickness needs. */
259
+ normalize?: "global" | "column";
260
+ /** Links a cap refused. A partial flow should not read as the whole one. */
261
+ dropped: number;
262
+ };
263
+ /**
264
+ * A style channel a column drives, with what its guide needs to draw.
265
+ *
266
+ * One shape for the three. A category hands out levels and a measure hands out a domain.
267
+ */
268
+ export interface StyleChannel<T> {
269
+ field: PlotField;
270
+ /** One level per value, in the order the codes assigned them. Absent where the field is a measure. */
271
+ levels?: readonly {
272
+ value: string;
273
+ at: T;
274
+ }[];
275
+ /** The two ends the channel ran between, where the field is a measure. */
276
+ domain?: [number, number];
277
+ }
278
+ /** A series resolved against the data it reads. */
279
+ export interface Trace {
280
+ id: string;
281
+ layerId: string;
282
+ name: string;
283
+ color: string;
284
+ axis: "y" | "y2";
285
+ /** Measure on Y, for the readout and the axis title. */
286
+ field?: PlotField;
287
+ /**
288
+ * Maps a point's weight to a color. Constant with nothing bound.
289
+ *
290
+ * The weight keeps the field's own units. A geom asks for a color and learns nothing else.
291
+ */
292
+ ramp: ValueRamp;
293
+ /** Field on the color channel, for the readout. */
294
+ colorField?: PlotField;
295
+ /**
296
+ * The magnitude map and scale options this trace was built with.
297
+ *
298
+ * `paint` and `shareScales` rebuild the ramp off the chart's map. Held on the trace.
299
+ */
300
+ sequential?: UnitRamp;
301
+ colorOptions?: ColorScale;
302
+ /**
303
+ * The categories a bound identity channel paints, with each assigned index.
304
+ *
305
+ * A measure's legend is a bar off `colorDomain`. An identity's is a swatch per value.
306
+ */
307
+ colorLevels?: readonly {
308
+ value: string;
309
+ code: number;
310
+ }[];
311
+ /**
312
+ * The two ends the magnitude map runs between, in the value's own units.
313
+ *
314
+ * `shareScales` spans this across a facet. Absent on an identity color.
315
+ */
316
+ colorDomain?: [number, number];
317
+ /**
318
+ * The two ends the data itself had.
319
+ *
320
+ * `colorDomain` is where the ramp runs and this is what it ran over.
321
+ */
322
+ colorExtent?: [number, number];
323
+ /** Field on the third position scale, where the trace draws in a cube. */
324
+ zField?: PlotField;
325
+ /** Field on the size channel, for the readout and the legend. Absent where nothing is bound. */
326
+ sizeField?: PlotField;
327
+ /** That field's range over the whole table. The legend states what a diameter means. */
328
+ sizeDomain?: [number, number];
329
+ /** Smallest and largest radius the channel resolved to, in pixels. */
330
+ sizeRadii?: readonly [number, number];
331
+ /** Glyph per level, where the shape channel is bound. Absent where nothing is. */
332
+ shapeChannel?: StyleChannel<PointShape>;
333
+ /** Opacity per level or across a range, where the opacity channel is bound. */
334
+ alphaChannel?: StyleChannel<number>;
335
+ /**
336
+ * The pattern this run draws, where the dash channel is bound.
337
+ *
338
+ * One level. A dash belongs to a path and the build gave each level its own trace.
339
+ */
340
+ linetypeChannel?: {
341
+ field: PlotField;
342
+ at: Linetype;
343
+ value: string;
344
+ };
345
+ /** Value of the split field this trace holds. Absent where the series draws as one trace. */
346
+ splitValue?: string;
347
+ /** Field the series split on. The legend groups traces that share it. */
348
+ splitField?: PlotField;
349
+ /** Value of the facet field this trace's panel holds. Absent outside a facet. */
350
+ facetValue?: string;
351
+ /** Field the figure faceted on, where the trace's table holds it. */
352
+ facetField?: PlotField;
353
+ /** Set where the split is ggplot's `group`. The legend names the series once and the color channel's levels. */
354
+ grouped?: boolean;
355
+ /** The layer's own rows, where the series brought them. A readout reads its row there. */
356
+ table?: PlotData;
357
+ /** Set where the series keeps out of the legend. ggplot's `show.legend = FALSE`. */
358
+ showLegend?: false;
359
+ data: LayerData;
360
+ }
361
+ /**
362
+ * A ramp reading a position in the magnitude map, over 0..1.
363
+ *
364
+ * Two conventions, told apart by a phantom tag. `T` is the color a renderer wants.
365
+ */
366
+ export type UnitRamp<T = string> = ((t: number) => T) & {
367
+ readonly unit?: true;
368
+ readonly value?: never;
369
+ };
370
+ /**
371
+ * A ramp reading a value in the measure's own units.
372
+ *
373
+ * The counterpart to `UnitRamp`. The normalization is closed over. `valueRamp` produces one.
374
+ */
375
+ export type ValueRamp<T = string> = ((value: number) => T) & {
376
+ readonly unit?: never;
377
+ readonly value?: true;
378
+ };
379
+ /** The two maps a chart may color from, held apart per chart-design rule 8. */
380
+ export interface Palettes {
381
+ /** Magnitude, over 0..1. */
382
+ sequential: UnitRamp;
383
+ /**
384
+ * A named magnitude map, for a series or a side track painting off its own.
385
+ *
386
+ * Absent leaves `LayerSpec.palette` unread, and a track reads the registry. `palettesFor` fills it.
387
+ */
388
+ sequentialFor?: (palette: string) => UnitRamp;
389
+ /** A named categorical map, for a layer naming one. Undefined for a map of another kind. */
390
+ categoricalFor?: (palette: string) => Pick<Palettes, "categorical" | "categoricalSize"> | undefined;
391
+ /** Identity, by position in the categorical map. */
392
+ categorical: (index: number) => string;
393
+ /**
394
+ * Distinct colors the categorical map offers before it repeats.
395
+ *
396
+ * A figure with more identities than this gets two of them in one color.
397
+ */
398
+ categoricalSize?: number;
399
+ /**
400
+ * The color a cytogenetic band draws with, by its stain. An unknown level answers undefined.
401
+ *
402
+ * A karyotype is ordered and the categorical map states nothing about that order.
403
+ */
404
+ stain?: (stain: string) => string | undefined;
405
+ /**
406
+ * The value the magnitude map treats as its middle.
407
+ *
408
+ * Set where the map has two arms. A column running -2 to +18 would color +8 as no change.
409
+ */
410
+ center?: number;
411
+ }
412
+ /**
413
+ * The radii a bound size channel spans, in pixels.
414
+ *
415
+ * Derived from the panel's own point radius. Half that radius to two and a half times it.
416
+ */
417
+ export declare const sizeRadiiFor: (metrics: Metrics) => [number, number];
418
+ /**
419
+ * Radius a value takes on the size channel, in pixels.
420
+ *
421
+ * Area stands for quantity per chart-design rule 11. The radius is the square root of it.
422
+ */
423
+ export declare function sizeRadius(value: number, lo: number, hi: number, radii: readonly [number, number]): number;
424
+ /**
425
+ * A value's position in the magnitude map, over 0..1.
426
+ *
427
+ * Without a center the domain maps straight on. With one the scale is symmetric about it.
428
+ */
429
+ export declare function rampPosition(value: number, lo: number, hi: number, center?: number): number;
430
+ /**
431
+ * The ends the map runs between. The author's setting comes ahead of the data's.
432
+ *
433
+ * Cuts state their own ends. A value outside them has no bin to fall in.
434
+ */
435
+ export declare function colorDomainOf(derived: [number, number], options?: ColorScale): [number, number];
436
+ /** A scaled color channel carries the data's extent and the ends the author set. */
437
+ export declare const colorScaleOf: (derived: [number, number], options?: ColorScale) => {
438
+ colorExtent: [number, number];
439
+ colorDomain: [number, number];
440
+ };
441
+ /**
442
+ * The ramp settings a geom reads, with a z-scored grid's neutral filled in.
443
+ *
444
+ * Centering each row on its mean gives the cells a zero. `paint` closes ramps through this too.
445
+ */
446
+ export declare function rampOptionsFor(geom: Geom, options?: ColorScale): ColorScale | undefined;
447
+ /**
448
+ * A value's color, in the units the value carries.
449
+ *
450
+ * The contract `Trace.ramp` states. n cuts make n-1 bins. Without cuts the map is continuous.
451
+ */
452
+ export declare function valueRamp(domain: [number, number], palettes: Palettes, options?: ColorScale): ValueRamp;
453
+ export interface BuiltLayers {
454
+ traces: Trace[];
455
+ axisKind: AxisKind;
456
+ xField?: PlotField;
457
+ /** Fields a layer's own rows hold and the chart's table does not. */
458
+ fields: PlotField[];
459
+ /** Kinds a layer names that this version does not know, as a newer document's. The figure reports them. */
460
+ unbuilt: PlotKind[];
461
+ /**
462
+ * What the build's own caps turned down, for the footer to state.
463
+ *
464
+ * Splits past a legend, rows a stride sampled over, and measures an axis cap refused.
465
+ */
466
+ omitted: Omission[];
467
+ }
468
+ /**
469
+ * Which scale the horizontal axis runs.
470
+ *
471
+ * The author's choice wins. Otherwise a numeric field gets a value scale and the rest get bands.
472
+ */
473
+ export declare function axisKindFor(plot: ChartSpec, xField: PlotField | undefined): AxisKind;
474
+ /** The horizontal axis's transform. A stated `transform` wins over the field's log default. */
475
+ export declare const horizontalTransform: (plot: ChartSpec, xField: PlotField | undefined) => AxisTransform;
476
+ /**
477
+ * The vertical axis's transform. A stated `transform` wins over the field's log default.
478
+ *
479
+ * A bar is read as a length from zero and a log scale has no zero. A grounded geom drops the
480
+ * measure's preference.
481
+ */
482
+ export declare function verticalTransform(declared: AxisTransform | undefined, fieldLog: boolean | undefined, grounded: boolean): AxisTransform;
483
+ /**
484
+ * Bars an automatic width may draw.
485
+ *
486
+ * Freedman-Diaconis reads the middle half of the data and bounds no interval count.
487
+ */
488
+ export declare const BIN_CAP = 60;
489
+ /**
490
+ * Bin width by the Freedman-Diaconis rule.
491
+ *
492
+ * Scales with the interquartile range. Falls back to Sturges where the IQR is zero.
493
+ */
494
+ export declare function autoBinWidth(values: number[]): number;
495
+ /**
496
+ * The binning a series states in `statParams`.
497
+ *
498
+ * None stated answers `auto`, the Freedman-Diaconis width.
499
+ */
500
+ export declare function binOf(series: LayerSpec): BinSpec;
501
+ /**
502
+ * A measure cut into intervals, reduced per interval.
503
+ *
504
+ * The bar draws at the bin's center. A transformed axis is cut in its own space.
505
+ */
506
+ export declare function binnedBars(data: PlotData, xId: string, yId: string | undefined, aggregate: Aggregate, bin: BinSpec, transform?: AxisTransform,
507
+ /** Half-width of the interval a bin draws, given its spread. Absent draws none. */
508
+ halfWidth?: (of: {
509
+ sd: number;
510
+ sem: number;
511
+ }) => number | undefined): {
512
+ bars: BarDatum[];
513
+ width: number;
514
+ offScale: number;
515
+ };
516
+ /**
517
+ * Rows of the table under each value of a field, in first-seen order.
518
+ *
519
+ * Row indices. Splitting 250k rows costs one pass and one array of numbers per group.
520
+ */
521
+ export declare function rowsByValue(data: PlotData, field: string): Map<string, number[]>;
522
+ /**
523
+ * The table narrowed to some of its rows.
524
+ *
525
+ * A split trace reads one group. Narrowing here keeps a per-group count honest.
526
+ */
527
+ export declare function viewOf(data: PlotData, rows: number[]): PlotData;
528
+ /** The two ends a bound opacity runs between. The low end clears the page. */
529
+ export declare const ALPHA_RANGE: [number, number];
530
+ /**
531
+ * Traces one split may produce.
532
+ *
533
+ * Past two dozen the palette repeats itself. The largest groups are kept and the footer counts
534
+ * the rest.
535
+ */
536
+ export declare const SPLIT_CAP = 24;
537
+ /**
538
+ * Whether the color a series draws is the author's to pick.
539
+ *
540
+ * A bound color channel paints from a column. A `group` split keeps the one color.
541
+ */
542
+ export declare const drawsOneColor: (series: LayerSpec) => boolean;
543
+ /** What a build reads beside the spec and its rows. */
544
+ export interface BuildOptions {
545
+ /** The two color maps the figure draws with. */
546
+ palettes: Palettes;
547
+ /** The sizing the build reads, `REGULAR` unless stated. A facet hands each panel its own. */
548
+ metrics?: Metrics;
549
+ /** Category codes a figure set pins. A value keeps its color across the set. */
550
+ pinned?: Assignments;
551
+ /** The facet field and the value of the panel this build draws. */
552
+ facet?: {
553
+ field: PlotField;
554
+ value: string;
555
+ };
556
+ }
557
+ export declare function buildLayers(plot: ChartSpec, data: PlotData, { palettes, pinned, metrics, facet }: BuildOptions): BuiltLayers;
558
+ /** Categories a trace occupies, in the order it produced them. */
559
+ export declare function categoriesOf(trace: Trace): string[];
560
+ /** Links a flow draws before the ribbons stop being separable. */
561
+ export declare const LINK_CAP = 80;
562
+ /**
563
+ * Nodes a flow draws in one column.
564
+ *
565
+ * Sixty links out of two thousand plates draw a comb of hairlines. Bounding the nodes keeps the
566
+ * survivors readable.
567
+ */
568
+ export declare const NODE_CAP = 20;
569
+ /**
570
+ * Lines a parallel plot draws.
571
+ *
572
+ * A line crossing four axes covers far more panel than a dot. The footer says how many rows the
573
+ * sample passed over.
574
+ */
575
+ export declare const LINE_CAP = 2000;
576
+ /**
577
+ * Readings a group can show behind its geom.
578
+ *
579
+ * The dots spread across the bar's own width. Past the cap a group shows none and the footer
580
+ * counts them.
581
+ */
582
+ export declare const REPLICATE_CAP = 40;
583
+ /**
584
+ * Measures a parallel plot spans.
585
+ *
586
+ * Each axis takes a column of the panel. Past the cap the measures are dropped and the footer
587
+ * states it.
588
+ */
589
+ export declare const AXIS_CAP = 8;
590
+ /** Sectors an ideogram draws. Past this the arcs are slivers and the names collide. */
591
+ export declare const SECTOR_CAP = 64;
592
+ /** Reference lines one layer draws. The footer counts the rest. */
593
+ export declare const RULE_CAP = 24;
594
+ export {};