@chipmobilesdk/rn-chart 0.3.0 → 0.5.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 (373) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/README.md +45 -3
  3. package/lib/commonjs/a11y/summary.js +190 -0
  4. package/lib/commonjs/a11y/summary.js.map +1 -0
  5. package/lib/commonjs/contract/datasource.js +64 -0
  6. package/lib/commonjs/contract/datasource.js.map +1 -0
  7. package/lib/commonjs/contract/distribution.js +45 -0
  8. package/lib/commonjs/contract/distribution.js.map +1 -0
  9. package/lib/commonjs/contract/errors.js +88 -0
  10. package/lib/commonjs/contract/errors.js.map +1 -0
  11. package/lib/commonjs/contract/format.js +133 -0
  12. package/lib/commonjs/contract/format.js.map +1 -0
  13. package/lib/commonjs/contract/interaction.js +24 -0
  14. package/lib/commonjs/contract/interaction.js.map +1 -0
  15. package/lib/commonjs/contract/marker.js +55 -0
  16. package/lib/commonjs/contract/marker.js.map +1 -0
  17. package/lib/commonjs/contract/props.js +6 -0
  18. package/lib/commonjs/contract/props.js.map +1 -0
  19. package/lib/commonjs/contract/state.js +68 -0
  20. package/lib/commonjs/contract/state.js.map +1 -0
  21. package/lib/commonjs/contract/strings.js +54 -0
  22. package/lib/commonjs/contract/strings.js.map +1 -0
  23. package/lib/commonjs/contract/theme.js +116 -0
  24. package/lib/commonjs/contract/theme.js.map +1 -0
  25. package/lib/commonjs/contract/value.js +112 -0
  26. package/lib/commonjs/contract/value.js.map +1 -0
  27. package/lib/commonjs/geometry/bar.js +257 -0
  28. package/lib/commonjs/geometry/bar.js.map +1 -0
  29. package/lib/commonjs/geometry/distribution.js +197 -0
  30. package/lib/commonjs/geometry/distribution.js.map +1 -0
  31. package/lib/commonjs/geometry/heatmap.js +186 -0
  32. package/lib/commonjs/geometry/heatmap.js.map +1 -0
  33. package/lib/commonjs/geometry/hitTest.js +117 -0
  34. package/lib/commonjs/geometry/hitTest.js.map +1 -0
  35. package/lib/commonjs/geometry/layout.js +134 -0
  36. package/lib/commonjs/geometry/layout.js.map +1 -0
  37. package/lib/commonjs/geometry/markers.js +59 -0
  38. package/lib/commonjs/geometry/markers.js.map +1 -0
  39. package/lib/commonjs/geometry/path.js +166 -0
  40. package/lib/commonjs/geometry/path.js.map +1 -0
  41. package/lib/commonjs/geometry/progress.js +203 -0
  42. package/lib/commonjs/geometry/progress.js.map +1 -0
  43. package/lib/commonjs/geometry/scale.js +127 -0
  44. package/lib/commonjs/geometry/scale.js.map +1 -0
  45. package/lib/commonjs/geometry/ticks.js +120 -0
  46. package/lib/commonjs/geometry/ticks.js.map +1 -0
  47. package/lib/commonjs/geometry/timeSeries.js +157 -0
  48. package/lib/commonjs/geometry/timeSeries.js.map +1 -0
  49. package/lib/commonjs/geometry/types.js +43 -0
  50. package/lib/commonjs/geometry/types.js.map +1 -0
  51. package/lib/commonjs/index.js +284 -0
  52. package/lib/commonjs/index.js.map +1 -0
  53. package/lib/commonjs/package.json +1 -0
  54. package/lib/commonjs/react/ChartBoundary.js +82 -0
  55. package/lib/commonjs/react/ChartBoundary.js.map +1 -0
  56. package/lib/commonjs/react/ChartFrame.js +270 -0
  57. package/lib/commonjs/react/ChartFrame.js.map +1 -0
  58. package/lib/commonjs/react/ChartLegend.js +242 -0
  59. package/lib/commonjs/react/ChartLegend.js.map +1 -0
  60. package/lib/commonjs/react/ChartPlot.js +62 -0
  61. package/lib/commonjs/react/ChartPlot.js.map +1 -0
  62. package/lib/commonjs/react/ChartStateOverlay.js +89 -0
  63. package/lib/commonjs/react/ChartStateOverlay.js.map +1 -0
  64. package/lib/commonjs/react/ChartThemeProvider.js +51 -0
  65. package/lib/commonjs/react/ChartThemeProvider.js.map +1 -0
  66. package/lib/commonjs/react/charts.js +108 -0
  67. package/lib/commonjs/react/charts.js.map +1 -0
  68. package/lib/commonjs/react/pointEvent.js +35 -0
  69. package/lib/commonjs/react/pointEvent.js.map +1 -0
  70. package/lib/commonjs/react/useChartA11y.js +97 -0
  71. package/lib/commonjs/react/useChartA11y.js.map +1 -0
  72. package/lib/commonjs/react/useChartFormatters.js +66 -0
  73. package/lib/commonjs/react/useChartFormatters.js.map +1 -0
  74. package/lib/commonjs/react/useChartLayout.js +100 -0
  75. package/lib/commonjs/react/useChartLayout.js.map +1 -0
  76. package/lib/commonjs/react/useChartSelection.js +131 -0
  77. package/lib/commonjs/react/useChartSelection.js.map +1 -0
  78. package/lib/commonjs/react/useChartStatus.js +74 -0
  79. package/lib/commonjs/react/useChartStatus.js.map +1 -0
  80. package/lib/commonjs/render/Axis.js +88 -0
  81. package/lib/commonjs/render/Axis.js.map +1 -0
  82. package/lib/commonjs/render/Marks.js +184 -0
  83. package/lib/commonjs/render/Marks.js.map +1 -0
  84. package/lib/commonjs/validation/budgets.js +106 -0
  85. package/lib/commonjs/validation/budgets.js.map +1 -0
  86. package/lib/commonjs/validation/validateDatasource.js +189 -0
  87. package/lib/commonjs/validation/validateDatasource.js.map +1 -0
  88. package/lib/module/a11y/summary.js +184 -0
  89. package/lib/module/a11y/summary.js.map +1 -0
  90. package/lib/module/contract/datasource.js +57 -0
  91. package/lib/module/contract/datasource.js.map +1 -0
  92. package/lib/module/contract/distribution.js +40 -0
  93. package/lib/module/contract/distribution.js.map +1 -0
  94. package/lib/module/contract/errors.js +80 -0
  95. package/lib/module/contract/errors.js.map +1 -0
  96. package/lib/module/contract/format.js +123 -0
  97. package/lib/module/contract/format.js.map +1 -0
  98. package/lib/module/contract/interaction.js +20 -0
  99. package/lib/module/contract/interaction.js.map +1 -0
  100. package/lib/module/contract/marker.js +49 -0
  101. package/lib/module/contract/marker.js.map +1 -0
  102. package/lib/module/contract/props.js +4 -0
  103. package/lib/module/contract/props.js.map +1 -0
  104. package/lib/module/contract/state.js +61 -0
  105. package/lib/module/contract/state.js.map +1 -0
  106. package/lib/module/contract/strings.js +49 -0
  107. package/lib/module/contract/strings.js.map +1 -0
  108. package/lib/module/contract/theme.js +109 -0
  109. package/lib/module/contract/theme.js.map +1 -0
  110. package/lib/module/contract/value.js +101 -0
  111. package/lib/module/contract/value.js.map +1 -0
  112. package/lib/module/geometry/bar.js +253 -0
  113. package/lib/module/geometry/bar.js.map +1 -0
  114. package/lib/module/geometry/distribution.js +193 -0
  115. package/lib/module/geometry/distribution.js.map +1 -0
  116. package/lib/module/geometry/heatmap.js +182 -0
  117. package/lib/module/geometry/heatmap.js.map +1 -0
  118. package/lib/module/geometry/hitTest.js +110 -0
  119. package/lib/module/geometry/hitTest.js.map +1 -0
  120. package/lib/module/geometry/layout.js +122 -0
  121. package/lib/module/geometry/layout.js.map +1 -0
  122. package/lib/module/geometry/markers.js +53 -0
  123. package/lib/module/geometry/markers.js.map +1 -0
  124. package/lib/module/geometry/path.js +157 -0
  125. package/lib/module/geometry/path.js.map +1 -0
  126. package/lib/module/geometry/progress.js +199 -0
  127. package/lib/module/geometry/progress.js.map +1 -0
  128. package/lib/module/geometry/scale.js +119 -0
  129. package/lib/module/geometry/scale.js.map +1 -0
  130. package/lib/module/geometry/ticks.js +112 -0
  131. package/lib/module/geometry/ticks.js.map +1 -0
  132. package/lib/module/geometry/timeSeries.js +153 -0
  133. package/lib/module/geometry/timeSeries.js.map +1 -0
  134. package/lib/module/geometry/types.js +39 -0
  135. package/lib/module/geometry/types.js.map +1 -0
  136. package/lib/module/index.js +85 -0
  137. package/lib/module/index.js.map +1 -0
  138. package/lib/module/package.json +1 -0
  139. package/lib/module/react/ChartBoundary.js +75 -0
  140. package/lib/module/react/ChartBoundary.js.map +1 -0
  141. package/lib/module/react/ChartFrame.js +263 -0
  142. package/lib/module/react/ChartFrame.js.map +1 -0
  143. package/lib/module/react/ChartLegend.js +234 -0
  144. package/lib/module/react/ChartLegend.js.map +1 -0
  145. package/lib/module/react/ChartPlot.js +56 -0
  146. package/lib/module/react/ChartPlot.js.map +1 -0
  147. package/lib/module/react/ChartStateOverlay.js +82 -0
  148. package/lib/module/react/ChartStateOverlay.js.map +1 -0
  149. package/lib/module/react/ChartThemeProvider.js +44 -0
  150. package/lib/module/react/ChartThemeProvider.js.map +1 -0
  151. package/lib/module/react/charts.js +102 -0
  152. package/lib/module/react/charts.js.map +1 -0
  153. package/lib/module/react/pointEvent.js +30 -0
  154. package/lib/module/react/pointEvent.js.map +1 -0
  155. package/lib/module/react/useChartA11y.js +92 -0
  156. package/lib/module/react/useChartA11y.js.map +1 -0
  157. package/lib/module/react/useChartFormatters.js +61 -0
  158. package/lib/module/react/useChartFormatters.js.map +1 -0
  159. package/lib/module/react/useChartLayout.js +95 -0
  160. package/lib/module/react/useChartLayout.js.map +1 -0
  161. package/lib/module/react/useChartSelection.js +125 -0
  162. package/lib/module/react/useChartSelection.js.map +1 -0
  163. package/lib/module/react/useChartStatus.js +69 -0
  164. package/lib/module/react/useChartStatus.js.map +1 -0
  165. package/lib/module/render/Axis.js +80 -0
  166. package/lib/module/render/Axis.js.map +1 -0
  167. package/lib/module/render/Marks.js +173 -0
  168. package/lib/module/render/Marks.js.map +1 -0
  169. package/lib/module/validation/budgets.js +97 -0
  170. package/lib/module/validation/budgets.js.map +1 -0
  171. package/lib/module/validation/validateDatasource.js +184 -0
  172. package/lib/module/validation/validateDatasource.js.map +1 -0
  173. package/lib/typescript/commonjs/a11y/summary.d.ts +38 -0
  174. package/lib/typescript/commonjs/a11y/summary.d.ts.map +1 -0
  175. package/lib/typescript/commonjs/contract/datasource.d.ts +94 -0
  176. package/lib/typescript/commonjs/contract/datasource.d.ts.map +1 -0
  177. package/lib/typescript/commonjs/contract/distribution.d.ts +17 -0
  178. package/lib/typescript/commonjs/contract/distribution.d.ts.map +1 -0
  179. package/lib/typescript/commonjs/contract/errors.d.ts +53 -0
  180. package/lib/typescript/commonjs/contract/errors.d.ts.map +1 -0
  181. package/lib/typescript/commonjs/contract/format.d.ts +63 -0
  182. package/lib/typescript/commonjs/contract/format.d.ts.map +1 -0
  183. package/lib/typescript/commonjs/contract/interaction.d.ts +53 -0
  184. package/lib/typescript/commonjs/contract/interaction.d.ts.map +1 -0
  185. package/lib/typescript/commonjs/contract/marker.d.ts +39 -0
  186. package/lib/typescript/commonjs/contract/marker.d.ts.map +1 -0
  187. package/lib/typescript/commonjs/contract/props.d.ts +58 -0
  188. package/lib/typescript/commonjs/contract/props.d.ts.map +1 -0
  189. package/lib/typescript/commonjs/contract/state.d.ts +45 -0
  190. package/lib/typescript/commonjs/contract/state.d.ts.map +1 -0
  191. package/lib/typescript/commonjs/contract/strings.d.ts +39 -0
  192. package/lib/typescript/commonjs/contract/strings.d.ts.map +1 -0
  193. package/lib/typescript/commonjs/contract/theme.d.ts +85 -0
  194. package/lib/typescript/commonjs/contract/theme.d.ts.map +1 -0
  195. package/lib/typescript/commonjs/contract/value.d.ts +69 -0
  196. package/lib/typescript/commonjs/contract/value.d.ts.map +1 -0
  197. package/lib/typescript/commonjs/geometry/bar.d.ts +18 -0
  198. package/lib/typescript/commonjs/geometry/bar.d.ts.map +1 -0
  199. package/lib/typescript/commonjs/geometry/distribution.d.ts +23 -0
  200. package/lib/typescript/commonjs/geometry/distribution.d.ts.map +1 -0
  201. package/lib/typescript/commonjs/geometry/heatmap.d.ts +24 -0
  202. package/lib/typescript/commonjs/geometry/heatmap.d.ts.map +1 -0
  203. package/lib/typescript/commonjs/geometry/hitTest.d.ts +68 -0
  204. package/lib/typescript/commonjs/geometry/hitTest.d.ts.map +1 -0
  205. package/lib/typescript/commonjs/geometry/layout.d.ts +67 -0
  206. package/lib/typescript/commonjs/geometry/layout.d.ts.map +1 -0
  207. package/lib/typescript/commonjs/geometry/markers.d.ts +29 -0
  208. package/lib/typescript/commonjs/geometry/markers.d.ts.map +1 -0
  209. package/lib/typescript/commonjs/geometry/path.d.ts +66 -0
  210. package/lib/typescript/commonjs/geometry/path.d.ts.map +1 -0
  211. package/lib/typescript/commonjs/geometry/progress.d.ts +17 -0
  212. package/lib/typescript/commonjs/geometry/progress.d.ts.map +1 -0
  213. package/lib/typescript/commonjs/geometry/scale.d.ts +55 -0
  214. package/lib/typescript/commonjs/geometry/scale.d.ts.map +1 -0
  215. package/lib/typescript/commonjs/geometry/ticks.d.ts +48 -0
  216. package/lib/typescript/commonjs/geometry/ticks.d.ts.map +1 -0
  217. package/lib/typescript/commonjs/geometry/timeSeries.d.ts +20 -0
  218. package/lib/typescript/commonjs/geometry/timeSeries.d.ts.map +1 -0
  219. package/lib/typescript/commonjs/geometry/types.d.ts +91 -0
  220. package/lib/typescript/commonjs/geometry/types.d.ts.map +1 -0
  221. package/lib/typescript/commonjs/index.d.ts +47 -0
  222. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  223. package/lib/typescript/commonjs/package.json +1 -0
  224. package/lib/typescript/commonjs/react/ChartBoundary.d.ts +47 -0
  225. package/lib/typescript/commonjs/react/ChartBoundary.d.ts.map +1 -0
  226. package/lib/typescript/commonjs/react/ChartFrame.d.ts +31 -0
  227. package/lib/typescript/commonjs/react/ChartFrame.d.ts.map +1 -0
  228. package/lib/typescript/commonjs/react/ChartLegend.d.ts +31 -0
  229. package/lib/typescript/commonjs/react/ChartLegend.d.ts.map +1 -0
  230. package/lib/typescript/commonjs/react/ChartPlot.d.ts +19 -0
  231. package/lib/typescript/commonjs/react/ChartPlot.d.ts.map +1 -0
  232. package/lib/typescript/commonjs/react/ChartStateOverlay.d.ts +25 -0
  233. package/lib/typescript/commonjs/react/ChartStateOverlay.d.ts.map +1 -0
  234. package/lib/typescript/commonjs/react/ChartThemeProvider.d.ts +21 -0
  235. package/lib/typescript/commonjs/react/ChartThemeProvider.d.ts.map +1 -0
  236. package/lib/typescript/commonjs/react/charts.d.ts +51 -0
  237. package/lib/typescript/commonjs/react/charts.d.ts.map +1 -0
  238. package/lib/typescript/commonjs/react/pointEvent.d.ts +13 -0
  239. package/lib/typescript/commonjs/react/pointEvent.d.ts.map +1 -0
  240. package/lib/typescript/commonjs/react/useChartA11y.d.ts +37 -0
  241. package/lib/typescript/commonjs/react/useChartA11y.d.ts.map +1 -0
  242. package/lib/typescript/commonjs/react/useChartFormatters.d.ts +21 -0
  243. package/lib/typescript/commonjs/react/useChartFormatters.d.ts.map +1 -0
  244. package/lib/typescript/commonjs/react/useChartLayout.d.ts +27 -0
  245. package/lib/typescript/commonjs/react/useChartLayout.d.ts.map +1 -0
  246. package/lib/typescript/commonjs/react/useChartSelection.d.ts +52 -0
  247. package/lib/typescript/commonjs/react/useChartSelection.d.ts.map +1 -0
  248. package/lib/typescript/commonjs/react/useChartStatus.d.ts +22 -0
  249. package/lib/typescript/commonjs/react/useChartStatus.d.ts.map +1 -0
  250. package/lib/typescript/commonjs/render/Axis.d.ts +31 -0
  251. package/lib/typescript/commonjs/render/Axis.d.ts.map +1 -0
  252. package/lib/typescript/commonjs/render/Marks.d.ts +44 -0
  253. package/lib/typescript/commonjs/render/Marks.d.ts.map +1 -0
  254. package/lib/typescript/commonjs/validation/budgets.d.ts +24 -0
  255. package/lib/typescript/commonjs/validation/budgets.d.ts.map +1 -0
  256. package/lib/typescript/commonjs/validation/validateDatasource.d.ts +26 -0
  257. package/lib/typescript/commonjs/validation/validateDatasource.d.ts.map +1 -0
  258. package/lib/typescript/module/a11y/summary.d.ts +38 -0
  259. package/lib/typescript/module/a11y/summary.d.ts.map +1 -0
  260. package/lib/typescript/module/contract/datasource.d.ts +94 -0
  261. package/lib/typescript/module/contract/datasource.d.ts.map +1 -0
  262. package/lib/typescript/module/contract/distribution.d.ts +17 -0
  263. package/lib/typescript/module/contract/distribution.d.ts.map +1 -0
  264. package/lib/typescript/module/contract/errors.d.ts +53 -0
  265. package/lib/typescript/module/contract/errors.d.ts.map +1 -0
  266. package/lib/typescript/module/contract/format.d.ts +63 -0
  267. package/lib/typescript/module/contract/format.d.ts.map +1 -0
  268. package/lib/typescript/module/contract/interaction.d.ts +53 -0
  269. package/lib/typescript/module/contract/interaction.d.ts.map +1 -0
  270. package/lib/typescript/module/contract/marker.d.ts +39 -0
  271. package/lib/typescript/module/contract/marker.d.ts.map +1 -0
  272. package/lib/typescript/module/contract/props.d.ts +58 -0
  273. package/lib/typescript/module/contract/props.d.ts.map +1 -0
  274. package/lib/typescript/module/contract/state.d.ts +45 -0
  275. package/lib/typescript/module/contract/state.d.ts.map +1 -0
  276. package/lib/typescript/module/contract/strings.d.ts +39 -0
  277. package/lib/typescript/module/contract/strings.d.ts.map +1 -0
  278. package/lib/typescript/module/contract/theme.d.ts +85 -0
  279. package/lib/typescript/module/contract/theme.d.ts.map +1 -0
  280. package/lib/typescript/module/contract/value.d.ts +69 -0
  281. package/lib/typescript/module/contract/value.d.ts.map +1 -0
  282. package/lib/typescript/module/geometry/bar.d.ts +18 -0
  283. package/lib/typescript/module/geometry/bar.d.ts.map +1 -0
  284. package/lib/typescript/module/geometry/distribution.d.ts +23 -0
  285. package/lib/typescript/module/geometry/distribution.d.ts.map +1 -0
  286. package/lib/typescript/module/geometry/heatmap.d.ts +24 -0
  287. package/lib/typescript/module/geometry/heatmap.d.ts.map +1 -0
  288. package/lib/typescript/module/geometry/hitTest.d.ts +68 -0
  289. package/lib/typescript/module/geometry/hitTest.d.ts.map +1 -0
  290. package/lib/typescript/module/geometry/layout.d.ts +67 -0
  291. package/lib/typescript/module/geometry/layout.d.ts.map +1 -0
  292. package/lib/typescript/module/geometry/markers.d.ts +29 -0
  293. package/lib/typescript/module/geometry/markers.d.ts.map +1 -0
  294. package/lib/typescript/module/geometry/path.d.ts +66 -0
  295. package/lib/typescript/module/geometry/path.d.ts.map +1 -0
  296. package/lib/typescript/module/geometry/progress.d.ts +17 -0
  297. package/lib/typescript/module/geometry/progress.d.ts.map +1 -0
  298. package/lib/typescript/module/geometry/scale.d.ts +55 -0
  299. package/lib/typescript/module/geometry/scale.d.ts.map +1 -0
  300. package/lib/typescript/module/geometry/ticks.d.ts +48 -0
  301. package/lib/typescript/module/geometry/ticks.d.ts.map +1 -0
  302. package/lib/typescript/module/geometry/timeSeries.d.ts +20 -0
  303. package/lib/typescript/module/geometry/timeSeries.d.ts.map +1 -0
  304. package/lib/typescript/module/geometry/types.d.ts +91 -0
  305. package/lib/typescript/module/geometry/types.d.ts.map +1 -0
  306. package/lib/typescript/module/index.d.ts +47 -0
  307. package/lib/typescript/module/index.d.ts.map +1 -0
  308. package/lib/typescript/module/package.json +1 -0
  309. package/lib/typescript/module/react/ChartBoundary.d.ts +47 -0
  310. package/lib/typescript/module/react/ChartBoundary.d.ts.map +1 -0
  311. package/lib/typescript/module/react/ChartFrame.d.ts +31 -0
  312. package/lib/typescript/module/react/ChartFrame.d.ts.map +1 -0
  313. package/lib/typescript/module/react/ChartLegend.d.ts +31 -0
  314. package/lib/typescript/module/react/ChartLegend.d.ts.map +1 -0
  315. package/lib/typescript/module/react/ChartPlot.d.ts +19 -0
  316. package/lib/typescript/module/react/ChartPlot.d.ts.map +1 -0
  317. package/lib/typescript/module/react/ChartStateOverlay.d.ts +25 -0
  318. package/lib/typescript/module/react/ChartStateOverlay.d.ts.map +1 -0
  319. package/lib/typescript/module/react/ChartThemeProvider.d.ts +21 -0
  320. package/lib/typescript/module/react/ChartThemeProvider.d.ts.map +1 -0
  321. package/lib/typescript/module/react/charts.d.ts +51 -0
  322. package/lib/typescript/module/react/charts.d.ts.map +1 -0
  323. package/lib/typescript/module/react/pointEvent.d.ts +13 -0
  324. package/lib/typescript/module/react/pointEvent.d.ts.map +1 -0
  325. package/lib/typescript/module/react/useChartA11y.d.ts +37 -0
  326. package/lib/typescript/module/react/useChartA11y.d.ts.map +1 -0
  327. package/lib/typescript/module/react/useChartFormatters.d.ts +21 -0
  328. package/lib/typescript/module/react/useChartFormatters.d.ts.map +1 -0
  329. package/lib/typescript/module/react/useChartLayout.d.ts +27 -0
  330. package/lib/typescript/module/react/useChartLayout.d.ts.map +1 -0
  331. package/lib/typescript/module/react/useChartSelection.d.ts +52 -0
  332. package/lib/typescript/module/react/useChartSelection.d.ts.map +1 -0
  333. package/lib/typescript/module/react/useChartStatus.d.ts +22 -0
  334. package/lib/typescript/module/react/useChartStatus.d.ts.map +1 -0
  335. package/lib/typescript/module/render/Axis.d.ts +31 -0
  336. package/lib/typescript/module/render/Axis.d.ts.map +1 -0
  337. package/lib/typescript/module/render/Marks.d.ts +44 -0
  338. package/lib/typescript/module/render/Marks.d.ts.map +1 -0
  339. package/lib/typescript/module/validation/budgets.d.ts +24 -0
  340. package/lib/typescript/module/validation/budgets.d.ts.map +1 -0
  341. package/lib/typescript/module/validation/validateDatasource.d.ts +26 -0
  342. package/lib/typescript/module/validation/validateDatasource.d.ts.map +1 -0
  343. package/package.json +40 -15
  344. package/skills/sdk-rn-chart/SKILL.md +49 -14
  345. package/src/a11y/summary.ts +34 -15
  346. package/src/contract/distribution.ts +44 -0
  347. package/src/contract/errors.ts +6 -0
  348. package/src/contract/interaction.ts +2 -2
  349. package/src/contract/strings.ts +2 -0
  350. package/src/geometry/bar.ts +27 -16
  351. package/src/geometry/distribution.ts +11 -6
  352. package/src/geometry/heatmap.ts +34 -17
  353. package/src/geometry/hitTest.ts +35 -0
  354. package/src/geometry/progress.ts +0 -1
  355. package/src/geometry/ticks.ts +0 -13
  356. package/src/geometry/timeSeries.ts +7 -2
  357. package/src/geometry/types.ts +11 -0
  358. package/src/index.ts +4 -1
  359. package/src/react/ChartFrame.tsx +126 -373
  360. package/src/react/ChartLegend.tsx +60 -3
  361. package/src/react/ChartPlot.tsx +57 -0
  362. package/src/react/ChartStateOverlay.tsx +94 -0
  363. package/src/react/charts.tsx +27 -12
  364. package/src/react/pointEvent.ts +40 -0
  365. package/src/react/useChartA11y.ts +113 -0
  366. package/src/react/useChartFormatters.ts +105 -0
  367. package/src/react/useChartLayout.ts +5 -2
  368. package/src/react/useChartSelection.ts +77 -40
  369. package/src/react/useChartStatus.ts +85 -0
  370. package/src/render/Axis.tsx +26 -22
  371. package/src/render/Marks.tsx +2 -9
  372. package/src/validation/budgets.ts +6 -4
  373. package/src/validation/validateDatasource.ts +38 -14
@@ -0,0 +1,257 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.buildBarGeometry = buildBarGeometry;
7
+ var _value = require("../contract/value.js");
8
+ var _layout = require("./layout.js");
9
+ var _markers = require("./markers.js");
10
+ var _path = require("./path.js");
11
+ var _scale = require("./scale.js");
12
+ var _ticks = require("./ticks.js");
13
+ /**
14
+ * Bar geometry: one batched path per series, grouped or stacked.
15
+ *
16
+ * Bars measure length from zero, so the domain always includes it — otherwise
17
+ * a bar's length means nothing. Negative values place the baseline correctly
18
+ * rather than clamping to the plot floor.
19
+ *
20
+ * PURE. No React, no SVG.
21
+ */
22
+
23
+ /**
24
+ * Bars accept both category and instant positions — that dual acceptance is
25
+ * what makes swapping a time-series chart for a bar chart free. Both collapse
26
+ * to a string key for the band scale.
27
+ */
28
+ function categoryKey(position) {
29
+ switch (position.kind) {
30
+ case 'category':
31
+ return position.category;
32
+ case 'instant':
33
+ return String(position.at);
34
+ default:
35
+ return '';
36
+ }
37
+ }
38
+ function countExcluded(datasource) {
39
+ let excluded = 0;
40
+ for (const series of datasource.series) {
41
+ for (const point of series.points) {
42
+ if (!(0, _value.isKnown)(point.value)) {
43
+ excluded += 1;
44
+ }
45
+ }
46
+ }
47
+ return excluded;
48
+ }
49
+ function groupedDomainValues(datasource) {
50
+ const values = [];
51
+ for (const series of datasource.series) {
52
+ for (const point of series.points) {
53
+ if ((0, _value.isKnown)(point.value)) {
54
+ values.push(point.value.value);
55
+ }
56
+ }
57
+ }
58
+ return values;
59
+ }
60
+
61
+ /**
62
+ * A stacked axis must fit the stack totals, not the individual values.
63
+ * Positive and negative parts accumulate separately so a stack straddling zero
64
+ * still fits.
65
+ */
66
+ function stackedDomainValues(categories, visible) {
67
+ const values = [];
68
+
69
+ // One pass over the points instead of a search per category and series.
70
+ const positive = new Map();
71
+ const negative = new Map();
72
+ for (const series of visible) {
73
+ const counted = new Set();
74
+ for (const point of series.points) {
75
+ const category = categoryKey(point.position);
76
+ // The first point of a series in a category is the one drawn there.
77
+ if (counted.has(category) || !(0, _value.isKnown)(point.value)) {
78
+ continue;
79
+ }
80
+ counted.add(category);
81
+ const sums = point.value.value >= 0 ? positive : negative;
82
+ sums.set(category, (sums.get(category) ?? 0) + point.value.value);
83
+ }
84
+ }
85
+ for (const category of categories) {
86
+ values.push(positive.get(category) ?? 0, negative.get(category) ?? 0);
87
+ }
88
+ return values;
89
+ }
90
+ function groupedBarX(bandStart, bandWidth, seriesIndex, seriesCount) {
91
+ const barWidth = bandWidth / Math.max(seriesCount, 1);
92
+ return {
93
+ barX: bandStart + seriesIndex * barWidth,
94
+ barWidth
95
+ };
96
+ }
97
+
98
+ /** Grows from the zero baseline, upward or downward as the sign requires. */
99
+ function groupedBarY(value, zeroY, project) {
100
+ const valueY = project(value);
101
+ return {
102
+ top: Math.min(zeroY, valueY),
103
+ height: Math.abs(valueY - zeroY)
104
+ };
105
+ }
106
+
107
+ /** Grows from wherever the running stack for this sign currently ends. */
108
+ function stackedBarY(value, category, stack, project) {
109
+ const base = stack.get(category) ?? 0;
110
+ const from = project(base);
111
+ const to = project(base + value);
112
+ stack.set(category, base + value);
113
+ return {
114
+ top: Math.min(from, to),
115
+ height: Math.abs(to - from)
116
+ };
117
+ }
118
+ function buildBarGeometry(datasource, input, options = {}) {
119
+ const grouping = options.grouping ?? 'grouped';
120
+
121
+ // Preserve first-seen order rather than sorting: the app chose this order.
122
+ const categories = [];
123
+ const seen = new Set();
124
+ for (const series of datasource.series) {
125
+ for (const point of series.points) {
126
+ const key = categoryKey(point.position);
127
+ if (key && !seen.has(key)) {
128
+ seen.add(key);
129
+ categories.push(key);
130
+ }
131
+ }
132
+ }
133
+
134
+ // Instants have an order of their own. First-seen order put Tuesday before
135
+ // Monday when one series started a day late, and disagreed with the
136
+ // time-series chart drawn from the same datasource (CHT-20).
137
+ if (datasource.positionKind === 'instant') {
138
+ categories.sort((a, b) => Number(a) - Number(b));
139
+ }
140
+ const visible = datasource.series.filter(s => !s.hidden);
141
+ const excluded = countExcluded(datasource);
142
+ const values = [...(grouping === 'stacked' ? stackedDomainValues(categories, visible) : groupedDomainValues(datasource)),
143
+ // A threshold above every bar must still be on the chart.
144
+ ...(0, _markers.markerDomainValues)(datasource.markers)];
145
+
146
+ // Labels depend only on the domain, so they are known before any pixel is,
147
+ // and the plot can make room for them first.
148
+ // Bars grow from zero, so padding past zero on a side no bar reaches only
149
+ // adds a meaningless tick (-5.5 under all-positive data) crowding the 0.
150
+ const padded = (0, _scale.domainFrom)(values, {
151
+ includeZero: true,
152
+ padFraction: 0.05
153
+ });
154
+ const domain = (0, _scale.widenDegenerateDomain)({
155
+ min: values.some(v => v < 0) ? padded.min : Math.max(padded.min, 0),
156
+ max: values.some(v => v > 0) ? padded.max : Math.min(padded.max, 0)
157
+ });
158
+ // Round steps a reader can count in, not the padded extremes (105.3).
159
+ const yTickValues = (0, _ticks.niceTickValues)(domain, 4);
160
+ const xLabel = c => datasource.positionKind === 'instant' ? input.formatInstant(Number(c)) : input.formatCategory(c);
161
+ const plot = (0, _layout.insetForAxes)(input.plot, {
162
+ xLabels: categories.map(xLabel),
163
+ yLabels: yTickValues.map(input.formatValue),
164
+ fontSize: input.fontSize
165
+ });
166
+ const xBand = (0, _scale.bandScale)(categories, {
167
+ min: plot.x,
168
+ max: (0, _layout.plotRight)(plot)
169
+ }, 0.25);
170
+ const y = (0, _scale.linearScale)(domain, {
171
+ min: (0, _layout.plotBottom)(plot),
172
+ max: plot.y
173
+ });
174
+ const zeroY = y.project(0);
175
+ const paths = [];
176
+ const hitRegions = [];
177
+
178
+ // Running stack offsets, tracked separately per sign so negative bars grow
179
+ // downward from zero while positive bars grow upward.
180
+ const stackUp = new Map();
181
+ const stackDown = new Map();
182
+ visible.forEach((series, seriesIndex) => {
183
+ const rects = [];
184
+ for (const point of series.points) {
185
+ const category = categoryKey(point.position);
186
+ const bandStart = xBand.project(category);
187
+ if (bandStart === undefined || !(0, _value.isKnown)(point.value)) {
188
+ continue;
189
+ }
190
+ const value = point.value.value;
191
+ const {
192
+ barX,
193
+ barWidth
194
+ } = grouping === 'grouped' ? groupedBarX(bandStart, xBand.bandWidth, seriesIndex, visible.length) : {
195
+ barX: bandStart,
196
+ barWidth: xBand.bandWidth
197
+ };
198
+ const stack = value >= 0 ? stackUp : stackDown;
199
+ const {
200
+ top,
201
+ height
202
+ } = grouping === 'stacked' ? stackedBarY(value, category, stack, y.project) : groupedBarY(value, zeroY, y.project);
203
+ rects.push({
204
+ x: barX,
205
+ y: top,
206
+ width: barWidth,
207
+ height,
208
+ radius: options.radius ?? input.radius?.bar
209
+ });
210
+ hitRegions.push({
211
+ seriesId: series.id,
212
+ pointId: point.id,
213
+ x: barX + barWidth / 2,
214
+ y: top + height / 2,
215
+ bounds: {
216
+ x: barX,
217
+ y: top,
218
+ width: barWidth,
219
+ height
220
+ },
221
+ selectable: !(0, _value.isWithheld)(point.value)
222
+ });
223
+ }
224
+ if (rects.length > 0) {
225
+ paths.push({
226
+ key: `bars-${series.id}`,
227
+ seriesId: series.id,
228
+ d: (0, _path.rectBatchPath)(rects),
229
+ color: input.seriesColors[series.id],
230
+ pattern: series.pattern ?? 'solid',
231
+ filled: true
232
+ });
233
+ }
234
+ });
235
+ const xTicks = categories.map(c => ({
236
+ value: 0,
237
+ position: xBand.centerOf(c) ?? plot.x,
238
+ label: xLabel(c)
239
+ }));
240
+ const yTicks = yTickValues.map(v => ({
241
+ value: v,
242
+ position: y.project(v),
243
+ label: input.formatValue(v)
244
+ }));
245
+ const markers = (0, _markers.horizontalMarkers)(datasource.markers, plot, y.project);
246
+ return {
247
+ plot,
248
+ paths,
249
+ markers: markers.lines,
250
+ labels: markers.labels,
251
+ xTicks: (0, _ticks.thinTicks)(xTicks, input.fontSize, plot.width),
252
+ yTicks,
253
+ hitRegions,
254
+ incomplete: excluded > 0
255
+ };
256
+ }
257
+ //# sourceMappingURL=bar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_value","require","_layout","_markers","_path","_scale","_ticks","categoryKey","position","kind","category","String","at","countExcluded","datasource","excluded","series","point","points","isKnown","value","groupedDomainValues","values","push","stackedDomainValues","categories","visible","positive","Map","negative","counted","Set","has","add","sums","set","get","groupedBarX","bandStart","bandWidth","seriesIndex","seriesCount","barWidth","Math","max","barX","groupedBarY","zeroY","project","valueY","top","min","height","abs","stackedBarY","stack","base","from","to","buildBarGeometry","input","options","grouping","seen","key","positionKind","sort","a","b","Number","filter","s","hidden","markerDomainValues","markers","padded","domainFrom","includeZero","padFraction","domain","widenDegenerateDomain","some","v","yTickValues","niceTickValues","xLabel","c","formatInstant","formatCategory","plot","insetForAxes","xLabels","map","yLabels","formatValue","fontSize","xBand","bandScale","x","plotRight","y","linearScale","plotBottom","paths","hitRegions","stackUp","stackDown","forEach","rects","undefined","length","width","radius","bar","seriesId","id","pointId","bounds","selectable","isWithheld","d","rectBatchPath","color","seriesColors","pattern","filled","xTicks","centerOf","label","yTicks","horizontalMarkers","lines","labels","thinTicks","incomplete"],"sourceRoot":"../../../src","sources":["geometry/bar.ts"],"mappings":";;;;;;AAUA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA,SAASM,WAAWA,CAACC,QAAkB,EAAU;EAChD,QAAQA,QAAQ,CAACC,IAAI;IACpB,KAAK,UAAU;MACd,OAAOD,QAAQ,CAACE,QAAQ;IACzB,KAAK,SAAS;MACb,OAAOC,MAAM,CAACH,QAAQ,CAACI,EAAE,CAAC;IAC3B;MACC,OAAO,EAAE;EACX;AACD;AAEA,SAASC,aAAaA,CAAIC,UAA8B,EAAU;EACjE,IAAIC,QAAQ,GAAG,CAAC;EAChB,KAAK,MAAMC,MAAM,IAAIF,UAAU,CAACE,MAAM,EAAE;IACvC,KAAK,MAAMC,KAAK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":[]}
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.buildDistributionGeometry = buildDistributionGeometry;
7
+ var _distribution = require("../contract/distribution.js");
8
+ var _theme = require("../contract/theme.js");
9
+ var _value = require("../contract/value.js");
10
+ var _path = require("./path.js");
11
+ /**
12
+ * Distribution geometry: proportions between groups.
13
+ *
14
+ * Segments that do not sum to the whole are **not** rescaled to force a full
15
+ * circle (FR-024). The arc stops short and the geometry reports `incomplete`,
16
+ * so the chart can say the data is partial rather than quietly implying it is
17
+ * complete.
18
+ *
19
+ * PURE. No React, no SVG.
20
+ */
21
+
22
+ const TAU = Math.PI * 2;
23
+ function buildDistributionGeometry(datasource, input, options = {}) {
24
+ const {
25
+ plot
26
+ } = input;
27
+ const shape = options.shape ?? 'donut';
28
+ const segments = datasource.series.flatMap(series => series.points.map(point => ({
29
+ series,
30
+ point
31
+ })));
32
+ if (segments.length === 0 || plot.width <= 0 || plot.height <= 0) {
33
+ return {
34
+ plot,
35
+ paths: [],
36
+ markers: [],
37
+ labels: [],
38
+ xTicks: [],
39
+ yTicks: [],
40
+ hitRegions: [],
41
+ incomplete: false
42
+ };
43
+ }
44
+ const total = (0, _value.sumKnown)(segments.map(s => s.point.value));
45
+ // Nothing known: there is no distribution to draw, and drawing a full grey
46
+ // circle would imply a shape the data does not support.
47
+ if (total.countedPoints === 0 || total.total <= 0) {
48
+ return {
49
+ plot,
50
+ paths: [],
51
+ markers: [],
52
+ labels: [],
53
+ xTicks: [],
54
+ yTicks: [],
55
+ hitRegions: [],
56
+ incomplete: true
57
+ };
58
+ }
59
+
60
+ // Proportions supplied directly (each in 0..1, summing to ~1) are honoured
61
+ // as given; absolute values are normalised by their own total. Either way we
62
+ // never stretch a short sum to fill the circle.
63
+ const suppliedAsProportions = (0, _distribution.resolveDistributionValues)(datasource, options.valuesAre) === 'proportions';
64
+ // Shares declared as proportions that add up past the whole are normalised
65
+ // rather than drawn over one another.
66
+ const denominator = suppliedAsProportions ? Math.max(1, total.total) : total.total;
67
+ const coverage = total.total / denominator;
68
+ const incomplete = total.incomplete || coverage < 0.999;
69
+ const paths = [];
70
+ const labels = [];
71
+ const hitRegions = [];
72
+ const colorOf = (seriesId, pointId) => input.segmentColors?.[(0, _theme.segmentKey)(seriesId, pointId)] ?? input.seriesColors[seriesId];
73
+ if (shape === 'segmentedBar') {
74
+ const barHeight = Math.min(plot.height, 28);
75
+ const barY = plot.y + (plot.height - barHeight) / 2;
76
+ let cursor = plot.x;
77
+ for (const {
78
+ series,
79
+ point
80
+ } of segments) {
81
+ if (!(0, _value.isKnown)(point.value) || point.value.value < 0) {
82
+ continue;
83
+ }
84
+ const fraction = point.value.value / denominator;
85
+ const width = plot.width * fraction;
86
+ paths.push({
87
+ key: `seg-${series.id}-${point.id}`,
88
+ seriesId: series.id,
89
+ d: (0, _path.rectSubpath)({
90
+ x: cursor,
91
+ y: barY,
92
+ width,
93
+ height: barHeight
94
+ }),
95
+ color: colorOf(series.id, point.id),
96
+ pattern: 'solid',
97
+ filled: true
98
+ });
99
+ hitRegions.push({
100
+ seriesId: series.id,
101
+ pointId: point.id,
102
+ x: cursor + width / 2,
103
+ y: barY + barHeight / 2,
104
+ bounds: {
105
+ x: cursor,
106
+ y: barY,
107
+ width,
108
+ height: barHeight
109
+ },
110
+ selectable: !(0, _value.isWithheld)(point.value)
111
+ });
112
+ cursor += width;
113
+ }
114
+ return {
115
+ plot,
116
+ paths,
117
+ markers: [],
118
+ labels,
119
+ xTicks: [],
120
+ yTicks: [],
121
+ hitRegions,
122
+ incomplete
123
+ };
124
+ }
125
+ const cx = plot.x + plot.width / 2;
126
+ const cy = plot.y + plot.height / 2;
127
+ const outerRadius = Math.min(plot.width, plot.height) / 2;
128
+ const innerRadius = shape === 'pie' ? 0 : outerRadius * (options.innerRadiusRatio ?? 0.6);
129
+ let angle = 0;
130
+ for (const {
131
+ series,
132
+ point
133
+ } of segments) {
134
+ if (!(0, _value.isKnown)(point.value) || point.value.value < 0) {
135
+ continue;
136
+ }
137
+ const fraction = point.value.value / denominator;
138
+ const sweep = fraction * TAU;
139
+ const start = angle;
140
+ const end = angle + sweep;
141
+ angle = end;
142
+ paths.push({
143
+ key: `arc-${series.id}-${point.id}`,
144
+ seriesId: series.id,
145
+ d: (0, _path.arcPath)({
146
+ cx,
147
+ cy,
148
+ outerRadius,
149
+ innerRadius,
150
+ startAngle: start,
151
+ endAngle: end
152
+ }),
153
+ color: colorOf(series.id, point.id),
154
+ pattern: 'solid',
155
+ filled: true
156
+ });
157
+
158
+ // Label at the segment's midpoint, on the ring between the two radii.
159
+ const mid = start + sweep / 2 - Math.PI / 2;
160
+ const labelRadius = (outerRadius + innerRadius) / 2;
161
+ labels.push({
162
+ key: `arc-label-${series.id}-${point.id}`,
163
+ text: `${Math.round(fraction * 100)}%`,
164
+ x: cx + labelRadius * Math.cos(mid),
165
+ y: cy + labelRadius * Math.sin(mid),
166
+ anchor: 'middle',
167
+ // Hide labels on slivers where the text would not fit anyway.
168
+ muted: fraction < 0.05
169
+ });
170
+ hitRegions.push({
171
+ seriesId: series.id,
172
+ pointId: point.id,
173
+ x: cx + labelRadius * Math.cos(mid),
174
+ y: cy + labelRadius * Math.sin(mid),
175
+ arc: {
176
+ cx,
177
+ cy,
178
+ innerRadius,
179
+ outerRadius,
180
+ startAngle: start,
181
+ endAngle: end
182
+ },
183
+ selectable: !(0, _value.isWithheld)(point.value)
184
+ });
185
+ }
186
+ return {
187
+ plot,
188
+ paths,
189
+ markers: [],
190
+ labels,
191
+ xTicks: [],
192
+ yTicks: [],
193
+ hitRegions,
194
+ incomplete
195
+ };
196
+ }
197
+ //# sourceMappingURL=distribution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_distribution","require","_theme","_value","_path","TAU","Math","PI","buildDistributionGeometry","datasource","input","options","plot","shape","segments","series","flatMap","points","map","point","length","width","height","paths","markers","labels","xTicks","yTicks","hitRegions","incomplete","total","sumKnown","s","value","countedPoints","suppliedAsProportions","resolveDistributionValues","valuesAre","denominator","max","coverage","colorOf","seriesId","pointId","segmentColors","segmentKey","seriesColors","barHeight","min","barY","y","cursor","x","isKnown","fraction","push","key","id","d","rectSubpath","color","pattern","filled","bounds","selectable","isWithheld","cx","cy","outerRadius","innerRadius","innerRadiusRatio","angle","sweep","start","end","arcPath","startAngle","endAngle","mid","labelRadius","text","round","cos","sin","anchor","muted","arc"],"sourceRoot":"../../../src","sources":["geometry/distribution.ts"],"mappings":";;;;;;AAWA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAH,OAAA;AAfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA,MAAMI,GAAG,GAAGC,IAAI,CAACC,EAAE,GAAG,CAAC;AAEhB,SAASC,yBAAyBA,CACxCC,UAA8B,EAC9BC,KAAoB,EACpBC,OAA4B,GAAG,CAAC,CAAC,EACd;EACnB,MAAM;IAAEC;EAAK,CAAC,GAAGF,KAAK;EACtB,MAAMG,KAAK,GAAGF,OAAO,CAACE,KAAK,IAAI,OAAO;EAEtC,MAAMC,QAAQ,GAAGL,UAAU,CAACM,MAAM,CAACC,OAAO,CAACD,MAAM,IAChDA,MAAM,CAACE,MAAM,CAACC,GAAG,CAACC,KAAK,KAAK;IAAEJ,MAAM;IAAEI;EAAM,CAAC,CAAC,CAC/C,CAAC;EAED,IAAIL,QAAQ,CAACM,MAAM,KAAK,CAAC,IAAIR,IAAI,CAACS,KAAK,IAAI,CAAC,IAAIT,IAAI,CAACU,MAAM,IAAI,CAAC,EAAE;IACjE,OAAO;MACNV,IAAI;MACJW,KAAK,EAAE,EAAE;MACTC,OAAO,EAAE,EAAE;MACXC,MAAM,EAAE,EAAE;MACVC,MAAM,EAAE,EAAE;MACVC,MAAM,EAAE,EAAE;MACVC,UAAU,EAAE,EAAE;MACdC,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AE,GAAGa,WAAW,GAAGzE,IAAI,CAAC4E,GAAG,CAACJ,GAAG,CAAC;MACnC5B,CAAC,EAAEiB,EAAE,GAAGY,WAAW,GAAGzE,IAAI,CAAC6E,GAAG,CAACL,GAAG,CAAC;MACnCQ,GAAG,EAAE;QAAEpB,EAAE;QAAEC,EAAE;QAAEE,WAAW;QAAED,WAAW;QAAEQ,UAAU,EAAEH,KAAK;QAAEI,QAAQ,EAAEH;MAAI,CAAC;MAC3EV,UAAU,EAAE,CAAC,IAAAC,iBAAU,EAAC9C,KAAK,CAACc,KAAK;IACpC,CAAC,CAAC;EACH;EAEA,OAAO;IACNrB,IAAI;IACJW,KAAK;IACLC,OAAO,EAAE,EAAE;IACXC,MAAM;IACNC,MAAM,EAAE,EAAE;IACVC,MAAM,EAAE,EAAE;IACVC,UAAU;IACVC;EACD,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.buildHeatmapGeometry = buildHeatmapGeometry;
7
+ var _value = require("../contract/value.js");
8
+ var _layout = require("./layout.js");
9
+ var _path = require("./path.js");
10
+ var _ticks = require("./ticks.js");
11
+ /**
12
+ * Heatmap geometry: a matrix of cells, batched by intensity bucket.
13
+ *
14
+ * This is where batching pays off most. A thousand cells become roughly eight
15
+ * paths — one per intensity bucket, plus one per non-value class — instead of a
16
+ * thousand elements. Cell count no longer drives element count at all
17
+ * (research.md R2).
18
+ *
19
+ * Empty, zero, and unavailable cells are distinct by construction (FR-027): a
20
+ * genuine zero lands in the lowest ramp bucket, while unknown, not-applicable,
21
+ * and withheld each get their own texture.
22
+ *
23
+ * PURE. No React, no SVG.
24
+ */
25
+
26
+ function buildHeatmapGeometry(datasource, input, options = {}) {
27
+ const rows = [];
28
+ const columns = [];
29
+ const rowSeen = new Set();
30
+ const colSeen = new Set();
31
+ for (const series of datasource.series) {
32
+ for (const point of series.points) {
33
+ if (point.position.kind !== 'matrix') {
34
+ continue;
35
+ }
36
+ if (!rowSeen.has(point.position.row)) {
37
+ rowSeen.add(point.position.row);
38
+ rows.push(point.position.row);
39
+ }
40
+ if (!colSeen.has(point.position.column)) {
41
+ colSeen.add(point.position.column);
42
+ columns.push(point.position.column);
43
+ }
44
+ }
45
+ }
46
+ if (rows.length === 0 || columns.length === 0 || input.plot.width <= 0) {
47
+ return {
48
+ plot: input.plot,
49
+ paths: [],
50
+ markers: [],
51
+ labels: [],
52
+ xTicks: [],
53
+ yTicks: [],
54
+ hitRegions: [],
55
+ incomplete: false
56
+ };
57
+ }
58
+
59
+ // Row and column names are the heatmap's axes. The plot makes room for
60
+ // them; they were computed before and never drawn (CHT-15).
61
+ const columnLabels = columns.map(input.formatCategory);
62
+ const rowLabels = rows.map(input.formatCategory);
63
+ const plot = (0, _layout.insetForAxes)(input.plot, {
64
+ xLabels: columnLabels,
65
+ yLabels: rowLabels,
66
+ fontSize: input.fontSize
67
+ });
68
+ const columnIndex = new Map(columns.map((column, index) => [column, index]));
69
+ const rowIndex = new Map(rows.map((row, index) => [row, index]));
70
+ const gap = options.cellGap ?? 2;
71
+ const cellWidth = plot.width / columns.length;
72
+ const cellHeight = plot.height / rows.length;
73
+ const ramp = input.heatmapRamp;
74
+ const bucketCount = Math.max(2, Math.min(options.buckets ?? ramp.length, ramp.length));
75
+ let min = Infinity;
76
+ let max = -Infinity;
77
+ for (const series of datasource.series) {
78
+ for (const point of series.points) {
79
+ if ((0, _value.isKnown)(point.value)) {
80
+ min = Math.min(min, point.value.value);
81
+ max = Math.max(max, point.value.value);
82
+ }
83
+ }
84
+ }
85
+ const hasKnown = Number.isFinite(min) && Number.isFinite(max);
86
+ const span = max - min;
87
+
88
+ // Rects grouped by the path they will join.
89
+ const byBucket = new Map();
90
+ const byTexture = new Map();
91
+ const hitRegions = [];
92
+ let excluded = 0;
93
+ for (const series of datasource.series) {
94
+ if (series.hidden) {
95
+ continue;
96
+ }
97
+ for (const point of series.points) {
98
+ if (point.position.kind !== 'matrix') {
99
+ continue;
100
+ }
101
+ const col = columnIndex.get(point.position.column);
102
+ const row = rowIndex.get(point.position.row);
103
+ if (col === undefined || row === undefined) {
104
+ continue;
105
+ }
106
+ const rect = {
107
+ x: plot.x + col * cellWidth + gap / 2,
108
+ y: plot.y + row * cellHeight + gap / 2,
109
+ width: Math.max(0, cellWidth - gap),
110
+ height: Math.max(0, cellHeight - gap),
111
+ radius: options.cellRadius ?? input.radius?.cell
112
+ };
113
+ if ((0, _value.isKnown)(point.value)) {
114
+ // A zero lands in bucket 0 rather than being treated as absent —
115
+ // "logged nothing" and "we do not know" must not look alike.
116
+ const t = hasKnown && span > 0 ? (point.value.value - min) / span : 0;
117
+ const bucket = Math.min(bucketCount - 1, Math.floor(t * (bucketCount - 1) + 0.5));
118
+ const list = byBucket.get(bucket) ?? [];
119
+ list.push(rect);
120
+ byBucket.set(bucket, list);
121
+ } else {
122
+ excluded += 1;
123
+ const kind = point.value.kind;
124
+ const list = byTexture.get(kind) ?? [];
125
+ list.push(rect);
126
+ byTexture.set(kind, list);
127
+ }
128
+ hitRegions.push({
129
+ seriesId: series.id,
130
+ pointId: point.id,
131
+ x: rect.x + rect.width / 2,
132
+ y: rect.y + rect.height / 2,
133
+ bounds: rect,
134
+ selectable: !(0, _value.isWithheld)(point.value)
135
+ });
136
+ }
137
+ }
138
+ const paths = [];
139
+ for (const [bucket, rects] of byBucket) {
140
+ paths.push({
141
+ key: `cells-${bucket}`,
142
+ seriesId: datasource.series[0]?.id ?? 'heatmap',
143
+ d: (0, _path.rectBatchPath)(rects),
144
+ color: ramp[Math.min(bucket, ramp.length - 1)],
145
+ pattern: 'solid',
146
+ filled: true
147
+ });
148
+ }
149
+ for (const [kind, rects] of byTexture) {
150
+ paths.push({
151
+ key: `cells-${kind}`,
152
+ seriesId: datasource.series[0]?.id ?? 'heatmap',
153
+ d: (0, _path.rectBatchPath)(rects),
154
+ color: ramp[0],
155
+ pattern: 'solid',
156
+ filled: true,
157
+ texture: input.nonValueTextures[kind]
158
+ });
159
+ }
160
+ return {
161
+ plot,
162
+ paths,
163
+ markers: [],
164
+ labels: [],
165
+ xTicks: (0, _ticks.thinTicks)(columnLabels.map((label, i) => ({
166
+ value: i,
167
+ position: plot.x + i * cellWidth + cellWidth / 2,
168
+ label
169
+ })), input.fontSize, plot.width),
170
+ yTicks: rowLabels.map((label, i) => ({
171
+ value: i,
172
+ position: plot.y + i * cellHeight + cellHeight / 2,
173
+ label
174
+ })),
175
+ hitRegions,
176
+ ...(hasKnown ? {
177
+ colorScale: {
178
+ min,
179
+ max,
180
+ colors: ramp.slice(0, bucketCount)
181
+ }
182
+ } : {}),
183
+ incomplete: excluded > 0
184
+ };
185
+ }
186
+ //# sourceMappingURL=heatmap.js.map