@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,484 @@
1
+ /**
2
+ * What each kind draws with, one row per member of `PlotKind`.
3
+ *
4
+ * A row names the aesthetics, paints, style fields and layer fields its kind reads. Two kinds sharing
5
+ * a geometry each take a row.
6
+ */
7
+ import { GRAMMAR } from "./grammar.js";
8
+ export const GEOMS = {
9
+ /*
10
+ `position` reaches the point geometry for the adjustments that move a mark.
11
+
12
+ Jitter, jitterdodge and nudge each offset a geom off its own reading.
13
+ */
14
+ point: {
15
+ requires: ["x", "y"],
16
+ accepts: ["color", "size", "shape", "alpha", "group"],
17
+ paints: ["color"],
18
+ style: ["size", "sizeRange", "shape", "alpha", "halo", "hollow"],
19
+ parts: ["outline", "label"],
20
+ layer: ["directLabels", "fit", "position"],
21
+ },
22
+ line: {
23
+ requires: ["x", "y"],
24
+ accepts: ["color", "linetype", "group"],
25
+ paints: ["color"],
26
+ style: ["alpha", "linewidth", "linetype", "step"],
27
+ parts: ["label"],
28
+ layer: ["aggregate", "position", "directLabels", "cumulative"],
29
+ },
30
+ area: {
31
+ requires: ["x", "y"],
32
+ accepts: ["fill", "group"],
33
+ paints: ["fill", "color"],
34
+ style: ["alpha", "linewidth"],
35
+ parts: ["label"],
36
+ layer: ["aggregate", "bin", "error", "position", "directLabels", "cumulative"],
37
+ },
38
+ ribbon: {
39
+ requires: ["x", "ymin", "ymax"],
40
+ accepts: ["y", "fill", "group"],
41
+ paints: ["fill", "color"],
42
+ style: ["alpha"],
43
+ parts: ["band"],
44
+ layer: [],
45
+ },
46
+ /*
47
+ The band's channels, drawn a mark at a time. ggplot's four interval geoms.
48
+
49
+ `thickness` is the cap's reach and the crossbar's width. `median` is the estimate, which the
50
+ pointrange and the crossbar mark.
51
+ */
52
+ errorbar: {
53
+ requires: ["x", "ymin", "ymax"],
54
+ accepts: ["y", "color", "group"],
55
+ paints: ["color"],
56
+ style: ["alpha", "linewidth", "thickness"],
57
+ parts: ["whisker"],
58
+ layer: [],
59
+ },
60
+ linerange: {
61
+ requires: ["x", "ymin", "ymax"],
62
+ accepts: ["y", "color", "group"],
63
+ paints: ["color"],
64
+ style: ["alpha", "linewidth"],
65
+ parts: ["whisker"],
66
+ layer: [],
67
+ },
68
+ pointrange: {
69
+ requires: ["x", "ymin", "ymax"],
70
+ accepts: ["y", "color", "group"],
71
+ paints: ["color"],
72
+ style: ["alpha", "linewidth"],
73
+ parts: ["median", "whisker"],
74
+ layer: [],
75
+ },
76
+ crossbar: {
77
+ requires: ["x", "ymin", "ymax"],
78
+ accepts: ["y", "color", "group"],
79
+ paints: ["color", "fill"],
80
+ style: ["alpha", "linewidth", "thickness"],
81
+ parts: ["median", "whisker"],
82
+ layer: [],
83
+ },
84
+ segment: {
85
+ requires: ["x", "y", "xend", "yend"],
86
+ accepts: ["color", "group"],
87
+ paints: ["color"],
88
+ style: ["alpha", "linewidth", "arrow"],
89
+ parts: [],
90
+ layer: [],
91
+ },
92
+ smooth: {
93
+ requires: ["x", "y"],
94
+ accepts: ["color", "group"],
95
+ paints: ["color"],
96
+ style: ["alpha", "linewidth"],
97
+ parts: ["band"],
98
+ layer: [],
99
+ },
100
+ bar: {
101
+ requires: ["x"],
102
+ accepts: ["y", "fill"],
103
+ paints: ["fill", "color"],
104
+ style: ["alpha", "linewidth", "thickness"],
105
+ parts: ["whisker", "staple", "replicate", "label"],
106
+ layer: ["aggregate", "error", "replicates", "position", "directLabels", "cumulative"],
107
+ },
108
+ /* The bar's geometry under a count. The statistic is fixed, and `aggregate` is off the row. */
109
+ histogram: {
110
+ requires: ["x"],
111
+ accepts: ["y", "fill"],
112
+ paints: ["fill", "color"],
113
+ style: ["alpha", "linewidth", "thickness"],
114
+ parts: ["whisker", "staple", "replicate", "label"],
115
+ layer: ["error", "replicates", "position", "directLabels", "cumulative"],
116
+ },
117
+ /*
118
+ The bar's channels less the fill one, and the hue is the step's direction.
119
+
120
+ A rise and a fall take separate paints through `parts`. `position` is off the row.
121
+ */
122
+ waterfall: {
123
+ requires: ["x"],
124
+ accepts: ["y"],
125
+ paints: ["fill", "color"],
126
+ style: ["alpha", "linewidth", "thickness"],
127
+ parts: ["rise", "fall", "connector", "label"],
128
+ layer: ["aggregate", "directLabels"],
129
+ },
130
+ boxplot: {
131
+ requires: ["y"],
132
+ accepts: ["x", "fill"],
133
+ paints: ["fill", "color"],
134
+ style: ["alpha", "linewidth", "thickness"],
135
+ parts: ["box", "whisker", "staple", "median", "outlier", "replicate"],
136
+ layer: ["replicates"],
137
+ },
138
+ /*
139
+ A run between bin centers, painting like a line and binning like a bar.
140
+
141
+ A color, a dash or a group puts one run per value.
142
+ */
143
+ freqpoly: {
144
+ requires: ["x"],
145
+ accepts: ["y", "color", "linetype", "group"],
146
+ paints: ["color"],
147
+ style: ["alpha", "linewidth", "linetype", "step"],
148
+ parts: ["label"],
149
+ layer: ["position", "directLabels", "cumulative"],
150
+ },
151
+ /*
152
+ A curve with an interior. `area` names the same pair.
153
+
154
+ The fill shows where two densities overlap and the stroke keeps them separable. A color, a fill
155
+ or a group draws one curve per value.
156
+ */
157
+ density: {
158
+ requires: ["x"],
159
+ accepts: ["color", "fill", "group"],
160
+ paints: ["color", "fill"],
161
+ style: ["alpha", "linewidth"],
162
+ parts: ["label"],
163
+ layer: ["directLabels"],
164
+ },
165
+ violin: {
166
+ requires: ["y"],
167
+ accepts: ["x", "fill"],
168
+ paints: ["fill", "color"],
169
+ style: ["alpha", "linewidth", "thickness", "half"],
170
+ parts: ["box", "median", "outlier", "quantile", "replicate"],
171
+ layer: ["replicates"],
172
+ },
173
+ hex: {
174
+ requires: ["x", "y"],
175
+ accepts: [],
176
+ paints: ["fill", "color"],
177
+ style: ["alpha", "linewidth", "tiling"],
178
+ parts: ["outline"],
179
+ layer: [],
180
+ },
181
+ /* `z` bound draws the rows' own lattice in bands. Unbound, the stat estimates a density. */
182
+ contour: {
183
+ requires: ["x", "y"],
184
+ accepts: ["z"],
185
+ paints: ["fill", "color"],
186
+ style: ["alpha"],
187
+ parts: ["band"],
188
+ layer: [],
189
+ },
190
+ /* `dimensions` binds the measures a gate grid compares against their cuts. `fill` on a text column paints each cell by category. */
191
+ heatmap: {
192
+ requires: ["x", "y"],
193
+ accepts: ["z", "dimensions", "fill"],
194
+ paints: ["fill", "color"],
195
+ style: ["alpha", "linewidth", "cornerRadius", "cellGap", "fadeBySupport", "emptyAsZero"],
196
+ parts: ["label", "outline"],
197
+ layer: ["aggregate", "numbers"],
198
+ },
199
+ /* A hierarchy names its cells and nests them, which is `label`, `value` and `parent`. */
200
+ treemap: {
201
+ requires: ["label"],
202
+ accepts: ["value", "parent"],
203
+ paints: ["fill", "color"],
204
+ style: ["alpha"],
205
+ parts: ["label", "outline"],
206
+ layer: ["aggregate"],
207
+ },
208
+ /* The same three channels. The two arrangements read one layout. */
209
+ icicle: {
210
+ requires: ["label"],
211
+ accepts: ["value", "parent"],
212
+ paints: ["fill", "color"],
213
+ style: ["alpha"],
214
+ parts: ["label", "outline"],
215
+ layer: ["aggregate"],
216
+ },
217
+ /*
218
+ The hierarchy's three channels, drawn round a center.
219
+
220
+ `numbers` joins them. A cell in a ring is read off an angle unless the figure writes the value
221
+ on it.
222
+ */
223
+ sunburst: {
224
+ requires: ["label"],
225
+ accepts: ["value", "parent"],
226
+ paints: ["fill", "color"],
227
+ style: ["alpha"],
228
+ parts: ["label", "outline"],
229
+ layer: ["aggregate", "directLabels", "numbers"],
230
+ },
231
+ sankey: {
232
+ requires: ["source", "target"],
233
+ accepts: ["value"],
234
+ paints: ["fill"],
235
+ style: ["alpha"],
236
+ parts: ["label"],
237
+ layer: [],
238
+ },
239
+ /*
240
+ A sector per chromosome, a tile per band, and the reading each tile covers.
241
+
242
+ `fill` paints a tile by its stain. The rings outside read the same rows.
243
+ */
244
+ ideogram: {
245
+ requires: ["sector", "start", "end"],
246
+ accepts: ["fill"],
247
+ paints: ["fill"],
248
+ style: ["alpha", "gap", "rotate"],
249
+ parts: ["label"],
250
+ layer: ["numbers", "rings", "links"],
251
+ },
252
+ /*
253
+ The flow's channels, read round a center.
254
+
255
+ `numbers` writes the axis each sector carries in its own units.
256
+ */
257
+ chord: {
258
+ requires: ["source", "target"],
259
+ accepts: ["value"],
260
+ paints: ["fill"],
261
+ style: ["alpha", "gap", "rotate", "inset"],
262
+ parts: ["label"],
263
+ layer: ["numbers", "rings"],
264
+ },
265
+ parcoords: {
266
+ requires: ["dimensions"],
267
+ accepts: ["color"],
268
+ paints: ["color"],
269
+ style: ["alpha"],
270
+ parts: [],
271
+ layer: [],
272
+ },
273
+ /*
274
+ The parallel plot's channels, read round a center.
275
+
276
+ The list is ordered and the order is the author's statement. `fill` stays low -- a closed
277
+ polygon's area stands for nothing.
278
+ */
279
+ radar: {
280
+ requires: ["dimensions"],
281
+ accepts: ["color"],
282
+ paints: ["color", "fill"],
283
+ style: ["alpha"],
284
+ parts: [],
285
+ layer: [],
286
+ },
287
+ /*
288
+ The polar rows. A pie reads the shared pair, and a gauge reads one magnitude.
289
+
290
+ `numbers` on all three states the condition polar is permitted under.
291
+ */
292
+ /* `innerRadius` above zero clears the hole, a donut. */
293
+ pie: {
294
+ requires: ["x"],
295
+ accepts: ["y", "fill"],
296
+ paints: ["fill", "color"],
297
+ style: ["alpha", "linewidth", "innerRadius"],
298
+ parts: ["label", "outline"],
299
+ layer: ["aggregate", "directLabels", "numbers"],
300
+ },
301
+ /*
302
+ One bound magnitude and no position of its own. The channel takes a role name.
303
+
304
+ `thickness` is the arc's weight in pixels.
305
+ */
306
+ gauge: {
307
+ requires: ["value"],
308
+ accepts: [],
309
+ paints: ["fill"],
310
+ style: ["alpha", "thickness", "radius", "sweep", "sections"],
311
+ parts: ["label"],
312
+ layer: ["aggregate", "numbers"],
313
+ },
314
+ point3d: {
315
+ requires: ["x", "y", "z"],
316
+ accepts: ["color", "size"],
317
+ paints: ["color"],
318
+ style: ["size", "sizeRange", "panes"],
319
+ parts: [],
320
+ layer: [],
321
+ },
322
+ surface: {
323
+ requires: ["x", "y", "z"],
324
+ accepts: [],
325
+ paints: ["fill"],
326
+ style: ["panes"],
327
+ parts: [],
328
+ layer: ["aggregate"],
329
+ },
330
+ mesh3d: {
331
+ requires: ["x", "y", "z", "faces"],
332
+ accepts: [],
333
+ paints: ["fill"],
334
+ style: ["panes"],
335
+ parts: [],
336
+ layer: [],
337
+ },
338
+ isosurface: {
339
+ requires: ["x", "y", "z"],
340
+ accepts: ["value"],
341
+ paints: ["fill"],
342
+ style: ["isoLevel", "panes"],
343
+ parts: [],
344
+ layer: [],
345
+ },
346
+ volume: {
347
+ requires: ["x", "y", "z"],
348
+ accepts: ["value"],
349
+ paints: ["fill"],
350
+ style: ["panes"],
351
+ parts: [],
352
+ layer: [],
353
+ },
354
+ /* A reference line reads its own position and nothing of the shared pair. `label` is rule 4's text. */
355
+ hline: {
356
+ requires: ["yintercept"],
357
+ accepts: ["color", "linetype", "label"],
358
+ paints: ["color"],
359
+ style: ["alpha", "linewidth", "linetype"],
360
+ parts: [],
361
+ layer: [],
362
+ },
363
+ vline: {
364
+ requires: ["xintercept"],
365
+ accepts: ["color", "linetype", "label"],
366
+ paints: ["color"],
367
+ style: ["alpha", "linewidth", "linetype"],
368
+ parts: [],
369
+ layer: [],
370
+ },
371
+ abline: {
372
+ requires: ["slope", "intercept"],
373
+ accepts: ["color", "linetype", "label"],
374
+ paints: ["color"],
375
+ style: ["alpha", "linewidth", "linetype"],
376
+ parts: [],
377
+ layer: [],
378
+ },
379
+ /* A label per row at its reading. A dodge moves it into the slot of the bar it names. */
380
+ text: {
381
+ requires: ["x", "y", "label"],
382
+ accepts: ["color", "group"],
383
+ paints: ["color"],
384
+ style: ["hjust", "vjust", "fontSize"],
385
+ parts: [],
386
+ layer: ["position"],
387
+ },
388
+ /* The text row, with a box behind each label. */
389
+ label: {
390
+ requires: ["x", "y", "label"],
391
+ accepts: ["color", "group"],
392
+ paints: ["color"],
393
+ style: ["hjust", "vjust", "fontSize"],
394
+ parts: [],
395
+ layer: ["position"],
396
+ },
397
+ };
398
+ /**
399
+ * The parameters each statistic reads, for the sort the builder runs over a layer's flat options.
400
+ *
401
+ * `StatOptions` at run time, held to it by `EveryStatKeyListed` below.
402
+ */
403
+ const STAT_PARAMS = {
404
+ bin: ["binwidth", "bins", "center", "boundary", "closed", "pad", "breaks", "dropEmpty"],
405
+ bin2d: ["binwidth", "bins", "center", "boundary", "closed", "drop"],
406
+ count: [],
407
+ summary: [],
408
+ flow: ["normalize", "align"],
409
+ boxplot: ["coef", "quantileType"],
410
+ density: ["bw", "adjust", "kernel", "n", "trim", "bounds"],
411
+ ydensity: ["bw", "adjust", "kernel", "trim", "bounds", "scale", "drop", "quantiles"],
412
+ density2d: ["adjust"],
413
+ };
414
+ const statKeysComplete = true;
415
+ void statKeysComplete;
416
+ const isStat = (name) => name in STAT_PARAMS;
417
+ /**
418
+ * The statistic parameters a kind reads: those of each statistic its `GRAMMAR` row runs, and the
419
+ * bin statistic's where its `GEOMS` row lists `bin`.
420
+ */
421
+ export const statKeysOf = (kind) => new Set([...GRAMMAR[kind].stat, ...GEOMS[kind].layer.filter(isStat)].flatMap((stat) => STAT_PARAMS[stat]));
422
+ /**
423
+ * Keys of `LayerStyle` a layer states flat, gathered off the table.
424
+ *
425
+ * What `add` splits a layer's options on. Gathered off the rows.
426
+ */
427
+ export const STYLE_KEYS = new Set(Object.values(GEOMS).flatMap((row) => [...row.paints, ...row.style]));
428
+ /** The geometry a kind resolves to, read off `GRAMMAR`. */
429
+ export const geomOf = (kind) => GRAMMAR[kind].geom;
430
+ /** What one kind draws with. */
431
+ export const kindFacts = (kind) => GEOMS[kind];
432
+ /** The aesthetics by name, gathered off the rows. Each member of `Aesthetic` is on some row. */
433
+ const AESTHETICS = new Set(Object.values(GEOMS).flatMap((row) => [...row.requires, ...row.accepts]));
434
+ /** Whether a key names an aesthetic, for a caller holding a key no compiler checked. */
435
+ export const isAesthetic = (key) => AESTHETICS.has(key);
436
+ /** A kind's own ink, which is the paint the palette and the author's pick land on. */
437
+ export const ownPaint = (kind) => kindFacts(kind).paints[0] ?? "color";
438
+ /**
439
+ * The paint aesthetic a layer's palette and color scale route through.
440
+ *
441
+ * A bar maps `fill` and a line maps `color`. A kind mapping both takes the first one its aes binds,
442
+ * and a kind mapping neither takes its own paint.
443
+ */
444
+ export function paintAesthetic(layer) {
445
+ const mapped = mappedPaints(layer.kind);
446
+ return mapped.find((paint) => typeof layer.aes[paint] === "string") ?? mapped[0] ?? ownPaint(layer.kind);
447
+ }
448
+ /** The paints a kind maps a column to, in its paint order. A grid's ramp reads `z` and maps none. */
449
+ const mappedPaints = (kind) => {
450
+ const facts = kindFacts(kind);
451
+ return facts.paints.filter((paint) => facts.accepts.includes(paint));
452
+ };
453
+ /** The column a layer's paint aesthetic binds, where its kind maps one and the aes binds it. */
454
+ export const paintColumn = (layer) => {
455
+ const aesthetic = paintAesthetic(layer);
456
+ const column = mappedPaints(layer.kind).includes(aesthetic) ? layer.aes[aesthetic] : undefined;
457
+ return typeof column === "string" ? column : undefined;
458
+ };
459
+ /**
460
+ * The color scale a layer reads: the chart's and the layer's own on its paint aesthetic, merged.
461
+ *
462
+ * The layer's wins field by field. Absent where neither states one.
463
+ */
464
+ export function layerScale(plot, layer) {
465
+ const aesthetic = paintAesthetic(layer);
466
+ const chart = plot.scales?.[aesthetic];
467
+ const own = layer.scales?.[aesthetic];
468
+ return chart || own ? { ...chart, ...own } : undefined;
469
+ }
470
+ /**
471
+ * The color a layer states for its geoms, read off the kind's own paint.
472
+ *
473
+ * A bar's is its `fill` and a line's its `color`. Absent where the author picked none.
474
+ */
475
+ export const geomColor = (style, kind) => style?.[ownPaint(kind)];
476
+ /**
477
+ * The style with a kind's own paint set to a color.
478
+ *
479
+ * What a control offering one color per series writes. `geomColor` reads it back.
480
+ */
481
+ export const paintedWith = (style, kind, color) => ({
482
+ ...style,
483
+ [ownPaint(kind)]: color,
484
+ });
@@ -0,0 +1,182 @@
1
+ /**
2
+ * The datum shapes a layer build produces and a geom consumes.
3
+ *
4
+ * The contract stays with the build. Any renderer reads the same shapes.
5
+ */
6
+ import type { BoxStats, Density } from "./stats.js";
7
+ import type { PlotPoint } from "./hit.js";
8
+ export interface BarDatum {
9
+ category: string;
10
+ /**
11
+ * Position on a value scale, where the bar stands for a bin.
12
+ *
13
+ * A binned bar and a banded one are one geom. The position arrives beside the label.
14
+ */
15
+ at?: number;
16
+ /**
17
+ * The interval a binned bar stands for, in the measure's own units.
18
+ *
19
+ * `closed` names the ends that hold a reading on them, as the binner placed it.
20
+ */
21
+ bin?: {
22
+ from: number;
23
+ to: number;
24
+ closed: "left" | "right" | "both" | "neither";
25
+ };
26
+ value: number;
27
+ /**
28
+ * Where the geom starts. Absent starts at the baseline.
29
+ *
30
+ * `floor + value` is the top of the segment and the reach the vertical scale needs.
31
+ */
32
+ floor?: number;
33
+ /** Half-width of the interval. Standard error or standard deviation, named in the footer. */
34
+ error?: number;
35
+ /**
36
+ * The readings behind the group, for a geom drawing them over the bar.
37
+ *
38
+ * Absent where the author asked for none or the group has too many to separate.
39
+ */
40
+ values?: number[];
41
+ n?: number;
42
+ color?: string;
43
+ /**
44
+ * How many geoms share this bar's band, where a dodge divides by the band's count, ggplot's
45
+ * `preserve = "total"`.
46
+ *
47
+ * Absent takes the slot count the whole set was given, ggplot's `preserve = "single"`.
48
+ */
49
+ slotOf?: number;
50
+ /** Which of those slots this bar takes, its rank among the geoms its band holds. Absent takes the set's. */
51
+ slotAt?: number;
52
+ }
53
+ /**
54
+ * One reading of a line -- a position and the value at it.
55
+ *
56
+ * Ordered by the caller. The path walks the readings in the order it is handed them.
57
+ */
58
+ export interface LinePoint {
59
+ x: number | string;
60
+ y: number;
61
+ /** Breaks the path before this reading. A missing reading sits between it and the one before. */
62
+ gap?: boolean;
63
+ }
64
+ /**
65
+ * One reading of a band -- a position and the two bounds around it.
66
+ *
67
+ * Both bounds are bound columns and `mid` is optional. Ordered by the caller.
68
+ */
69
+ export interface IntervalPoint {
70
+ x: number | string;
71
+ lo: number;
72
+ hi: number;
73
+ mid?: number;
74
+ }
75
+ /**
76
+ * One drift -- where a reading started and where it finished.
77
+ *
78
+ * Four bound columns and no statistic. Either end may name a band. Unordered.
79
+ */
80
+ export interface SegmentPoint {
81
+ /** A reading on a value scale, or the band it falls in. */
82
+ x: number | string;
83
+ y: number;
84
+ /** The far end. Equal to `x` on a band, where the pair runs inside one category. */
85
+ xEnd: number | string;
86
+ yEnd: number;
87
+ }
88
+ export interface HeatCell {
89
+ x: string;
90
+ y: string;
91
+ value: number;
92
+ n: number;
93
+ /** The cell's most common category, where a categorical fill binds one. `value` is its share. */
94
+ category?: string;
95
+ /** The color that category paints. Absent reads the ramp. */
96
+ color?: string;
97
+ }
98
+ export interface BoxDatum extends BoxStats {
99
+ category: string;
100
+ }
101
+ export interface ViolinDatum extends BoxDatum, Density {
102
+ /**
103
+ * Readings the outline draws a line across, in the measure's own units. Absent draws none.
104
+ *
105
+ * The probabilities are `quantiles` on the statistic, defaulting to the box's three.
106
+ */
107
+ quantiles?: number[];
108
+ }
109
+ export interface ParallelAxis {
110
+ id: string;
111
+ label: string;
112
+ lo: number;
113
+ hi: number;
114
+ }
115
+ export interface ParallelLine {
116
+ values: number[];
117
+ /** Feeds the color ramp. Absent where nothing is bound to the color channel. */
118
+ weight?: number;
119
+ /** Row in the source. A click opens the record the grid already knows. */
120
+ row: number;
121
+ /** Row in the table the figure read, before a facet narrowed it. */
122
+ plotRow?: number;
123
+ key?: string;
124
+ }
125
+ /**
126
+ * Glyph a point draws.
127
+ *
128
+ * Shape survives a printout, a color-blind reader and a screenshot. All four fill -- a stroked
129
+ * glyph at three pixels reads as a smudge.
130
+ */
131
+ export type PointShape = "circle" | "square" | "triangle" | "diamond";
132
+ /**
133
+ * The glyphs in the order a bound shape channel hands them out.
134
+ *
135
+ * Four is the channel's ceiling and the critic reports a fifth level. The circle leads.
136
+ */
137
+ export declare const POINT_SHAPES: readonly PointShape[];
138
+ /**
139
+ * Outline width of a hollow glyph, in CSS pixels.
140
+ *
141
+ * One number for both renderers. Each renderer caps it against the geom's own radius.
142
+ */
143
+ export declare const POINT_OUTLINE = 1.4;
144
+ /**
145
+ * A geom under the pointer or a click, as each geom reports it to `onHover` and `onSelect`.
146
+ *
147
+ * The datum it drew, its position in the geom's input, and the pixel a tooltip sits beside.
148
+ */
149
+ export interface GeomHit<D> {
150
+ datum: D;
151
+ /** Position in the geom's input array. A caller reaches parallel data with it. */
152
+ index: number;
153
+ /** Where the geom draws, in the plot area's pixels. */
154
+ at: {
155
+ x: number;
156
+ y: number;
157
+ };
158
+ }
159
+ /** A point under the pointer or a click. */
160
+ export type PointHit = GeomHit<PlotPoint>;
161
+ export interface SankeyNodeInput {
162
+ id: string;
163
+ label: string;
164
+ column: number;
165
+ /** Exits sort below survivors within a column. */
166
+ kind?: "survivor" | "exit";
167
+ /** Set by the caller from the palette. Absent falls back to the chart's own tones. */
168
+ color?: string;
169
+ }
170
+ export interface SankeyLinkInput {
171
+ source: string;
172
+ target: string;
173
+ value: number;
174
+ kind?: "survivor" | "exit" | "missing";
175
+ color?: string;
176
+ }
177
+ /** One line of the tooltip. */
178
+ export interface TooltipRow {
179
+ label: string;
180
+ value: string;
181
+ color?: string;
182
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The datum shapes a layer build produces and a geom consumes.
3
+ *
4
+ * The contract stays with the build. Any renderer reads the same shapes.
5
+ */
6
+ /**
7
+ * The glyphs in the order a bound shape channel hands them out.
8
+ *
9
+ * Four is the channel's ceiling and the critic reports a fifth level. The circle leads.
10
+ */
11
+ export const POINT_SHAPES = ["circle", "square", "triangle", "diamond"];
12
+ /**
13
+ * Outline width of a hollow glyph, in CSS pixels.
14
+ *
15
+ * One number for both renderers. Each renderer caps it against the geom's own radius.
16
+ */
17
+ export const POINT_OUTLINE = 1.4;