@chipmobilesdk/rn-chart 0.4.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 (343) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/README.md +1 -1
  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
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Distribution geometry: proportions between groups.
5
+ *
6
+ * Segments that do not sum to the whole are **not** rescaled to force a full
7
+ * circle (FR-024). The arc stops short and the geometry reports `incomplete`,
8
+ * so the chart can say the data is partial rather than quietly implying it is
9
+ * complete.
10
+ *
11
+ * PURE. No React, no SVG.
12
+ */
13
+
14
+ import { resolveDistributionValues } from "../contract/distribution.js";
15
+ import { segmentKey } from "../contract/theme.js";
16
+ import { isKnown, isWithheld, sumKnown } from "../contract/value.js";
17
+ import { arcPath, rectSubpath } from "./path.js";
18
+ const TAU = Math.PI * 2;
19
+ export function buildDistributionGeometry(datasource, input, options = {}) {
20
+ const {
21
+ plot
22
+ } = input;
23
+ const shape = options.shape ?? 'donut';
24
+ const segments = datasource.series.flatMap(series => series.points.map(point => ({
25
+ series,
26
+ point
27
+ })));
28
+ if (segments.length === 0 || plot.width <= 0 || plot.height <= 0) {
29
+ return {
30
+ plot,
31
+ paths: [],
32
+ markers: [],
33
+ labels: [],
34
+ xTicks: [],
35
+ yTicks: [],
36
+ hitRegions: [],
37
+ incomplete: false
38
+ };
39
+ }
40
+ const total = sumKnown(segments.map(s => s.point.value));
41
+ // Nothing known: there is no distribution to draw, and drawing a full grey
42
+ // circle would imply a shape the data does not support.
43
+ if (total.countedPoints === 0 || total.total <= 0) {
44
+ return {
45
+ plot,
46
+ paths: [],
47
+ markers: [],
48
+ labels: [],
49
+ xTicks: [],
50
+ yTicks: [],
51
+ hitRegions: [],
52
+ incomplete: true
53
+ };
54
+ }
55
+
56
+ // Proportions supplied directly (each in 0..1, summing to ~1) are honoured
57
+ // as given; absolute values are normalised by their own total. Either way we
58
+ // never stretch a short sum to fill the circle.
59
+ const suppliedAsProportions = resolveDistributionValues(datasource, options.valuesAre) === 'proportions';
60
+ // Shares declared as proportions that add up past the whole are normalised
61
+ // rather than drawn over one another.
62
+ const denominator = suppliedAsProportions ? Math.max(1, total.total) : total.total;
63
+ const coverage = total.total / denominator;
64
+ const incomplete = total.incomplete || coverage < 0.999;
65
+ const paths = [];
66
+ const labels = [];
67
+ const hitRegions = [];
68
+ const colorOf = (seriesId, pointId) => input.segmentColors?.[segmentKey(seriesId, pointId)] ?? input.seriesColors[seriesId];
69
+ if (shape === 'segmentedBar') {
70
+ const barHeight = Math.min(plot.height, 28);
71
+ const barY = plot.y + (plot.height - barHeight) / 2;
72
+ let cursor = plot.x;
73
+ for (const {
74
+ series,
75
+ point
76
+ } of segments) {
77
+ if (!isKnown(point.value) || point.value.value < 0) {
78
+ continue;
79
+ }
80
+ const fraction = point.value.value / denominator;
81
+ const width = plot.width * fraction;
82
+ paths.push({
83
+ key: `seg-${series.id}-${point.id}`,
84
+ seriesId: series.id,
85
+ d: rectSubpath({
86
+ x: cursor,
87
+ y: barY,
88
+ width,
89
+ height: barHeight
90
+ }),
91
+ color: colorOf(series.id, point.id),
92
+ pattern: 'solid',
93
+ filled: true
94
+ });
95
+ hitRegions.push({
96
+ seriesId: series.id,
97
+ pointId: point.id,
98
+ x: cursor + width / 2,
99
+ y: barY + barHeight / 2,
100
+ bounds: {
101
+ x: cursor,
102
+ y: barY,
103
+ width,
104
+ height: barHeight
105
+ },
106
+ selectable: !isWithheld(point.value)
107
+ });
108
+ cursor += width;
109
+ }
110
+ return {
111
+ plot,
112
+ paths,
113
+ markers: [],
114
+ labels,
115
+ xTicks: [],
116
+ yTicks: [],
117
+ hitRegions,
118
+ incomplete
119
+ };
120
+ }
121
+ const cx = plot.x + plot.width / 2;
122
+ const cy = plot.y + plot.height / 2;
123
+ const outerRadius = Math.min(plot.width, plot.height) / 2;
124
+ const innerRadius = shape === 'pie' ? 0 : outerRadius * (options.innerRadiusRatio ?? 0.6);
125
+ let angle = 0;
126
+ for (const {
127
+ series,
128
+ point
129
+ } of segments) {
130
+ if (!isKnown(point.value) || point.value.value < 0) {
131
+ continue;
132
+ }
133
+ const fraction = point.value.value / denominator;
134
+ const sweep = fraction * TAU;
135
+ const start = angle;
136
+ const end = angle + sweep;
137
+ angle = end;
138
+ paths.push({
139
+ key: `arc-${series.id}-${point.id}`,
140
+ seriesId: series.id,
141
+ d: arcPath({
142
+ cx,
143
+ cy,
144
+ outerRadius,
145
+ innerRadius,
146
+ startAngle: start,
147
+ endAngle: end
148
+ }),
149
+ color: colorOf(series.id, point.id),
150
+ pattern: 'solid',
151
+ filled: true
152
+ });
153
+
154
+ // Label at the segment's midpoint, on the ring between the two radii.
155
+ const mid = start + sweep / 2 - Math.PI / 2;
156
+ const labelRadius = (outerRadius + innerRadius) / 2;
157
+ labels.push({
158
+ key: `arc-label-${series.id}-${point.id}`,
159
+ text: `${Math.round(fraction * 100)}%`,
160
+ x: cx + labelRadius * Math.cos(mid),
161
+ y: cy + labelRadius * Math.sin(mid),
162
+ anchor: 'middle',
163
+ // Hide labels on slivers where the text would not fit anyway.
164
+ muted: fraction < 0.05
165
+ });
166
+ hitRegions.push({
167
+ seriesId: series.id,
168
+ pointId: point.id,
169
+ x: cx + labelRadius * Math.cos(mid),
170
+ y: cy + labelRadius * Math.sin(mid),
171
+ arc: {
172
+ cx,
173
+ cy,
174
+ innerRadius,
175
+ outerRadius,
176
+ startAngle: start,
177
+ endAngle: end
178
+ },
179
+ selectable: !isWithheld(point.value)
180
+ });
181
+ }
182
+ return {
183
+ plot,
184
+ paths,
185
+ markers: [],
186
+ labels,
187
+ xTicks: [],
188
+ yTicks: [],
189
+ hitRegions,
190
+ incomplete
191
+ };
192
+ }
193
+ //# sourceMappingURL=distribution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["resolveDistributionValues","segmentKey","isKnown","isWithheld","sumKnown","arcPath","rectSubpath","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","s","value","countedPoints","suppliedAsProportions","valuesAre","denominator","max","coverage","colorOf","seriesId","pointId","segmentColors","seriesColors","barHeight","min","barY","y","cursor","x","fraction","push","key","id","d","color","pattern","filled","bounds","selectable","cx","cy","outerRadius","innerRadius","innerRadiusRatio","angle","sweep","start","end","startAngle","endAngle","mid","labelRadius","text","round","cos","sin","anchor","muted","arc"],"sourceRoot":"../../../src","sources":["geometry/distribution.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,yBAAyB,QAAiC,6BAA0B;AAC7F,SAASC,UAAU,QAAQ,sBAAmB;AAC9C,SAASC,OAAO,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,sBAAmB;AAEjE,SAASC,OAAO,EAAEC,WAAW,QAAQ,WAAQ;AAa7C,MAAMC,GAAG,GAAGC,IAAI,CAACC,EAAE,GAAG,CAAC;AAEvB,OAAO,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,IAA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B,UAAU,CAACuB,IAAI,CAAC;MACfX,QAAQ,EAAEzB,MAAM,CAACsC,EAAE;MACnBZ,OAAO,EAAEtB,KAAK,CAACkC,EAAE;MACjBJ,CAAC,EAAEW,EAAE,GAAGY,WAAW,GAAGlE,IAAI,CAACqE,GAAG,CAACJ,GAAG,CAAC;MACnCxB,CAAC,EAAEc,EAAE,GAAGW,WAAW,GAAGlE,IAAI,CAACsE,GAAG,CAACL,GAAG,CAAC;MACnCQ,GAAG,EAAE;QAAEnB,EAAE;QAAEC,EAAE;QAAEE,WAAW;QAAED,WAAW;QAAEO,UAAU,EAAEF,KAAK;QAAEG,QAAQ,EAAEF;MAAI,CAAC;MAC3ET,UAAU,EAAE,CAAC1D,UAAU,CAACkB,KAAK,CAACa,KAAK;IACpC,CAAC,CAAC;EACH;EAEA,OAAO;IACNpB,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,182 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Heatmap geometry: a matrix of cells, batched by intensity bucket.
5
+ *
6
+ * This is where batching pays off most. A thousand cells become roughly eight
7
+ * paths — one per intensity bucket, plus one per non-value class — instead of a
8
+ * thousand elements. Cell count no longer drives element count at all
9
+ * (research.md R2).
10
+ *
11
+ * Empty, zero, and unavailable cells are distinct by construction (FR-027): a
12
+ * genuine zero lands in the lowest ramp bucket, while unknown, not-applicable,
13
+ * and withheld each get their own texture.
14
+ *
15
+ * PURE. No React, no SVG.
16
+ */
17
+
18
+ import { isKnown, isWithheld } from "../contract/value.js";
19
+ import { insetForAxes } from "./layout.js";
20
+ import { rectBatchPath } from "./path.js";
21
+ import { thinTicks } from "./ticks.js";
22
+ export function buildHeatmapGeometry(datasource, input, options = {}) {
23
+ const rows = [];
24
+ const columns = [];
25
+ const rowSeen = new Set();
26
+ const colSeen = new Set();
27
+ for (const series of datasource.series) {
28
+ for (const point of series.points) {
29
+ if (point.position.kind !== 'matrix') {
30
+ continue;
31
+ }
32
+ if (!rowSeen.has(point.position.row)) {
33
+ rowSeen.add(point.position.row);
34
+ rows.push(point.position.row);
35
+ }
36
+ if (!colSeen.has(point.position.column)) {
37
+ colSeen.add(point.position.column);
38
+ columns.push(point.position.column);
39
+ }
40
+ }
41
+ }
42
+ if (rows.length === 0 || columns.length === 0 || input.plot.width <= 0) {
43
+ return {
44
+ plot: input.plot,
45
+ paths: [],
46
+ markers: [],
47
+ labels: [],
48
+ xTicks: [],
49
+ yTicks: [],
50
+ hitRegions: [],
51
+ incomplete: false
52
+ };
53
+ }
54
+
55
+ // Row and column names are the heatmap's axes. The plot makes room for
56
+ // them; they were computed before and never drawn (CHT-15).
57
+ const columnLabels = columns.map(input.formatCategory);
58
+ const rowLabels = rows.map(input.formatCategory);
59
+ const plot = insetForAxes(input.plot, {
60
+ xLabels: columnLabels,
61
+ yLabels: rowLabels,
62
+ fontSize: input.fontSize
63
+ });
64
+ const columnIndex = new Map(columns.map((column, index) => [column, index]));
65
+ const rowIndex = new Map(rows.map((row, index) => [row, index]));
66
+ const gap = options.cellGap ?? 2;
67
+ const cellWidth = plot.width / columns.length;
68
+ const cellHeight = plot.height / rows.length;
69
+ const ramp = input.heatmapRamp;
70
+ const bucketCount = Math.max(2, Math.min(options.buckets ?? ramp.length, ramp.length));
71
+ let min = Infinity;
72
+ let max = -Infinity;
73
+ for (const series of datasource.series) {
74
+ for (const point of series.points) {
75
+ if (isKnown(point.value)) {
76
+ min = Math.min(min, point.value.value);
77
+ max = Math.max(max, point.value.value);
78
+ }
79
+ }
80
+ }
81
+ const hasKnown = Number.isFinite(min) && Number.isFinite(max);
82
+ const span = max - min;
83
+
84
+ // Rects grouped by the path they will join.
85
+ const byBucket = new Map();
86
+ const byTexture = new Map();
87
+ const hitRegions = [];
88
+ let excluded = 0;
89
+ for (const series of datasource.series) {
90
+ if (series.hidden) {
91
+ continue;
92
+ }
93
+ for (const point of series.points) {
94
+ if (point.position.kind !== 'matrix') {
95
+ continue;
96
+ }
97
+ const col = columnIndex.get(point.position.column);
98
+ const row = rowIndex.get(point.position.row);
99
+ if (col === undefined || row === undefined) {
100
+ continue;
101
+ }
102
+ const rect = {
103
+ x: plot.x + col * cellWidth + gap / 2,
104
+ y: plot.y + row * cellHeight + gap / 2,
105
+ width: Math.max(0, cellWidth - gap),
106
+ height: Math.max(0, cellHeight - gap),
107
+ radius: options.cellRadius ?? input.radius?.cell
108
+ };
109
+ if (isKnown(point.value)) {
110
+ // A zero lands in bucket 0 rather than being treated as absent —
111
+ // "logged nothing" and "we do not know" must not look alike.
112
+ const t = hasKnown && span > 0 ? (point.value.value - min) / span : 0;
113
+ const bucket = Math.min(bucketCount - 1, Math.floor(t * (bucketCount - 1) + 0.5));
114
+ const list = byBucket.get(bucket) ?? [];
115
+ list.push(rect);
116
+ byBucket.set(bucket, list);
117
+ } else {
118
+ excluded += 1;
119
+ const kind = point.value.kind;
120
+ const list = byTexture.get(kind) ?? [];
121
+ list.push(rect);
122
+ byTexture.set(kind, list);
123
+ }
124
+ hitRegions.push({
125
+ seriesId: series.id,
126
+ pointId: point.id,
127
+ x: rect.x + rect.width / 2,
128
+ y: rect.y + rect.height / 2,
129
+ bounds: rect,
130
+ selectable: !isWithheld(point.value)
131
+ });
132
+ }
133
+ }
134
+ const paths = [];
135
+ for (const [bucket, rects] of byBucket) {
136
+ paths.push({
137
+ key: `cells-${bucket}`,
138
+ seriesId: datasource.series[0]?.id ?? 'heatmap',
139
+ d: rectBatchPath(rects),
140
+ color: ramp[Math.min(bucket, ramp.length - 1)],
141
+ pattern: 'solid',
142
+ filled: true
143
+ });
144
+ }
145
+ for (const [kind, rects] of byTexture) {
146
+ paths.push({
147
+ key: `cells-${kind}`,
148
+ seriesId: datasource.series[0]?.id ?? 'heatmap',
149
+ d: rectBatchPath(rects),
150
+ color: ramp[0],
151
+ pattern: 'solid',
152
+ filled: true,
153
+ texture: input.nonValueTextures[kind]
154
+ });
155
+ }
156
+ return {
157
+ plot,
158
+ paths,
159
+ markers: [],
160
+ labels: [],
161
+ xTicks: thinTicks(columnLabels.map((label, i) => ({
162
+ value: i,
163
+ position: plot.x + i * cellWidth + cellWidth / 2,
164
+ label
165
+ })), input.fontSize, plot.width),
166
+ yTicks: rowLabels.map((label, i) => ({
167
+ value: i,
168
+ position: plot.y + i * cellHeight + cellHeight / 2,
169
+ label
170
+ })),
171
+ hitRegions,
172
+ ...(hasKnown ? {
173
+ colorScale: {
174
+ min,
175
+ max,
176
+ colors: ramp.slice(0, bucketCount)
177
+ }
178
+ } : {}),
179
+ incomplete: excluded > 0
180
+ };
181
+ }
182
+ //# sourceMappingURL=heatmap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isKnown","isWithheld","insetForAxes","rectBatchPath","thinTicks","buildHeatmapGeometry","datasource","input","options","rows","columns","rowSeen","Set","colSeen","series","point","points","position","kind","has","row","add","push","column","length","plot","width","paths","markers","labels","xTicks","yTicks","hitRegions","incomplete","columnLabels","map","formatCategory","rowLabels","xLabels","yLabels","fontSize","columnIndex","Map","index","rowIndex","gap","cellGap","cellWidth","cellHeight","height","ramp","heatmapRamp","bucketCount","Math","max","min","buckets","Infinity","value","hasKnown","Number","isFinite","span","byBucket","byTexture","excluded","hidden","col","get","undefined","rect","x","y","radius","cellRadius","cell","t","bucket","floor","list","set","seriesId","id","pointId","bounds","selectable","rects","key","d","color","pattern","filled","texture","nonValueTextures","label","i","colorScale","colors","slice"],"sourceRoot":"../../../src","sources":["geometry/heatmap.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,EAAEC,UAAU,QAAQ,sBAAmB;AAEvD,SAASC,YAAY,QAAQ,aAAU;AACvC,SAASC,aAAa,QAAuB,WAAQ;AACrD,SAASC,SAAS,QAAQ,YAAS;AAUn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;MACvBG,KAAK,EAAEvC,IAAI,CAAC,CAAC,CAAC;MACdwC,OAAO,EAAE,OAAO;MAChBC,MAAM,EAAE,IAAI;MACZC,OAAO,EAAErF,KAAK,CAACsF,gBAAgB,CAAC3E,IAAI;IACrC,CAAC,CAAC;EACH;EAEA,OAAO;IACNO,IAAI;IACJE,KAAK;IACLC,OAAO,EAAE,EAAE;IACXC,MAAM,EAAE,EAAE;IACVC,MAAM,EAAE1B,SAAS,CAChB8B,YAAY,CAACC,GAAG,CAAC,CAAC2D,KAAK,EAAEC,CAAC,MAAM;MAC/BrC,KAAK,EAAEqC,CAAC;MACR9E,QAAQ,EAAEQ,IAAI,CAAC8C,CAAC,GAAGwB,CAAC,GAAGhD,SAAS,GAAGA,SAAS,GAAG,CAAC;MAChD+C;IACD,CAAC,CAAC,CAAC,EACHvF,KAAK,CAACiC,QAAQ,EACdf,IAAI,CAACC,KACN,CAAC;IACDK,MAAM,EAAEM,SAAS,CAACF,GAAG,CAAC,CAAC2D,KAAK,EAAEC,CAAC,MAAM;MACpCrC,KAAK,EAAEqC,CAAC;MACR9E,QAAQ,EAAEQ,IAAI,CAAC+C,CAAC,GAAGuB,CAAC,GAAG/C,UAAU,GAAGA,UAAU,GAAG,CAAC;MAClD8C;IACD,CAAC,CAAC,CAAC;IACH9D,UAAU;IACV,IAAI2B,QAAQ,GAAG;MAAEqC,UAAU,EAAE;QAAEzC,GAAG;QAAED,GAAG;QAAE2C,MAAM,EAAE/C,IAAI,CAACgD,KAAK,CAAC,CAAC,EAAE9C,WAAW;MAAE;IAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrFnB,UAAU,EAAEgC,QAAQ,GAAG;EACxB,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Hit-testing for batched marks.
5
+ *
6
+ * Because marks are batched into one path per series, there are no per-element
7
+ * press handlers to rely on — a touch is resolved against geometry instead.
8
+ * That work would be needed anyway (a mobile time-series chart needs
9
+ * nearest-point search regardless of how it is drawn), and doing it in one
10
+ * place means a single implementation serves every family.
11
+ *
12
+ * PURE. No React, no SVG.
13
+ */
14
+
15
+ /** Touch slop: how far from a mark a tap still counts, in px. */
16
+ export const DEFAULT_HIT_RADIUS = 44;
17
+ function inBounds(region, x, y) {
18
+ const b = region.bounds;
19
+ if (!b) {
20
+ return false;
21
+ }
22
+ return x >= b.x && x <= b.x + b.width && y >= b.y && y <= b.y + b.height;
23
+ }
24
+ const TAU = Math.PI * 2;
25
+ function inArc(arc, x, y) {
26
+ const dx = x - arc.cx;
27
+ const dy = y - arc.cy;
28
+ const radius = Math.sqrt(dx * dx + dy * dy);
29
+ if (radius < arc.innerRadius || radius > arc.outerRadius) {
30
+ return false;
31
+ }
32
+ // Clockwise from the top, the convention the arcs are drawn in.
33
+ const angle = (Math.atan2(dy, dx) + Math.PI / 2 + TAU) % TAU;
34
+ return angle >= arc.startAngle && angle < arc.endAngle;
35
+ }
36
+
37
+ /**
38
+ * Resolves a touch to a mark.
39
+ *
40
+ * Containment wins over proximity where bounds exist — tapping inside a bar
41
+ * should select that bar even if a neighbouring bar's centre happens to be
42
+ * closer. Otherwise the nearest selectable mark within the hit radius wins.
43
+ */
44
+ export function hitTest(regions, x, y, hitRadius = DEFAULT_HIT_RADIUS) {
45
+ let best = null;
46
+ for (const region of regions) {
47
+ if (!region.selectable) {
48
+ continue;
49
+ }
50
+ if (inBounds(region, x, y)) {
51
+ return {
52
+ seriesId: region.seriesId,
53
+ pointId: region.pointId,
54
+ distance: 0
55
+ };
56
+ }
57
+ if (region.arc) {
58
+ // A large segment's edge is far from its midpoint, and a neighbour's
59
+ // midpoint can be nearer: only the segment under the finger counts.
60
+ if (inArc(region.arc, x, y)) {
61
+ return {
62
+ seriesId: region.seriesId,
63
+ pointId: region.pointId,
64
+ distance: 0
65
+ };
66
+ }
67
+ continue;
68
+ }
69
+ const dx = region.x - x;
70
+ const dy = region.y - y;
71
+ const distance = Math.sqrt(dx * dx + dy * dy);
72
+ if (distance <= hitRadius && (best === null || distance < best.distance)) {
73
+ best = {
74
+ seriesId: region.seriesId,
75
+ pointId: region.pointId,
76
+ distance
77
+ };
78
+ }
79
+ }
80
+ return best;
81
+ }
82
+
83
+ /**
84
+ * Nearest mark by horizontal distance only.
85
+ *
86
+ * The right model for a time-series chart: a user aiming at "that Tuesday
87
+ * spike" cares about the x position, and demanding vertical accuracy on a line
88
+ * that may sit anywhere in the plot makes selection frustrating.
89
+ */
90
+ export function hitTestByX(regions, x) {
91
+ let best = null;
92
+ for (const region of regions) {
93
+ if (!region.selectable) {
94
+ continue;
95
+ }
96
+ const distance = Math.abs(region.x - x);
97
+ if (best === null || distance < best.distance) {
98
+ best = {
99
+ seriesId: region.seriesId,
100
+ pointId: region.pointId,
101
+ distance
102
+ };
103
+ }
104
+ }
105
+ return best;
106
+ }
107
+ export function findRegion(regions, seriesId, pointId) {
108
+ return regions.find(r => r.seriesId === seriesId && (pointId === undefined || r.pointId === pointId));
109
+ }
110
+ //# sourceMappingURL=hitTest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DEFAULT_HIT_RADIUS","inBounds","region","x","y","b","bounds","width","height","TAU","Math","PI","inArc","arc","dx","cx","dy","cy","radius","sqrt","innerRadius","outerRadius","angle","atan2","startAngle","endAngle","hitTest","regions","hitRadius","best","selectable","seriesId","pointId","distance","hitTestByX","abs","findRegion","find","r","undefined"],"sourceRoot":"../../../src","sources":["geometry/hitTest.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyCA;AACA,OAAO,MAAMA,kBAAkB,GAAG,EAAE;AAEpC,SAASC,QAAQA,CAACC,MAAiB,EAAEC,CAAS,EAAEC,CAAS,EAAW;EACnE,MAAMC,CAAC,GAAGH,MAAM,CAACI,MAAM;EACvB,IAAI,CAACD,CAAC,EAAE;IACP,OAAO,KAAK;EACb;EACA,OAAOF,CAAC,IAAIE,CAAC,CAACF,CAAC,IA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C,IAAI0B,IAAI,KAAK,IAAI,IAAII,QAAQ,GAAGJ,IAAI,CAACI,QAAQ,EAAE;MAC9CJ,IAAI,GAAG;QAAEE,QAAQ,EAAE7B,MAAM,CAAC6B,QAAQ;QAAEC,OAAO,EAAE9B,MAAM,CAAC8B,OAAO;QAAEC;MAAS,CAAC;IACxE;EACD;EAEA,OAAOJ,IAAI;AACZ;AAEA,OAAO,SAASO,UAAUA,CACzBT,OAA6B,EAC7BI,QAAgB,EAChBC,OAAgB,EACQ;EACxB,OAAOL,OAAO,CAACU,IAAI,CAClBC,CAAC,IAAIA,CAAC,CAACP,QAAQ,KAAKA,QAAQ,KAAKC,OAAO,KAAKO,SAAS,IAAID,CAAC,CAACN,OAAO,KAAKA,OAAO,CAChF,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Plot layout: turning a container size into a drawable plot rectangle.
5
+ *
6
+ * Font scale arrives as a parameter rather than being read from `PixelRatio`
7
+ * here, so this module stays pure and testable at any scale without mocking a
8
+ * platform API. The React layer reads the real value and passes it in.
9
+ *
10
+ * PURE. No React, no SVG.
11
+ */
12
+ import { estimateTextWidth, reserveAxisSpace } from "./ticks.js";
13
+ /**
14
+ * Ceiling on how far system text scaling may inflate chart labels.
15
+ *
16
+ * Beyond this the plot area collapses faster than the labels become useful, so
17
+ * we cap the growth rather than let the chart squeeze itself out of existence.
18
+ * The cap is documented in the README as the supported dynamic-type range.
19
+ */
20
+ export const MAX_FONT_SCALE = 1.6;
21
+ export function effectiveFontSize(baseFontSize, fontScale) {
22
+ const clamped = Math.max(1, Math.min(fontScale, MAX_FONT_SCALE));
23
+ return Math.round(baseFontSize * clamped);
24
+ }
25
+
26
+ /** A container that has not been measured yet, or has collapsed (FR-078). */
27
+ export function isMeasurable(size) {
28
+ return Number.isFinite(size.width) && Number.isFinite(size.height) && size.width > 0 && size.height > 0;
29
+ }
30
+ export const EMPTY_PLOT = {
31
+ x: 0,
32
+ y: 0,
33
+ width: 0,
34
+ height: 0
35
+ };
36
+
37
+ /**
38
+ * Reserves axis space from estimated label widths, then hands back what is
39
+ * left for the marks.
40
+ *
41
+ * If the reservations would leave nothing to draw on, they are scaled back:
42
+ * a cramped axis beats a zero-area plot.
43
+ */
44
+ export function resolvePlotRect(options) {
45
+ if (!isMeasurable(options.container)) {
46
+ return EMPTY_PLOT;
47
+ }
48
+ const pad = options.padding ?? 0;
49
+ const fontSize = effectiveFontSize(options.baseFontSize, options.fontScale);
50
+ let left = pad;
51
+ let bottom = pad;
52
+ if (options.yLabels && options.yLabels.length > 0) {
53
+ left += reserveAxisSpace(options.yLabels, fontSize, 'vertical');
54
+ }
55
+ if (options.xLabels && options.xLabels.length > 0) {
56
+ bottom += reserveAxisSpace(options.xLabels, fontSize, 'horizontal');
57
+ }
58
+ const availableWidth = options.container.width - pad;
59
+ const availableHeight = options.container.height - pad;
60
+
61
+ // Never let axis reservations consume more than 40% of either dimension.
62
+ const maxLeft = availableWidth * 0.4;
63
+ const maxBottom = availableHeight * 0.4;
64
+ left = Math.min(left, maxLeft);
65
+ bottom = Math.min(bottom, maxBottom);
66
+ return {
67
+ x: left,
68
+ y: pad,
69
+ width: Math.max(0, options.container.width - left - pad),
70
+ height: Math.max(0, options.container.height - bottom - pad)
71
+ };
72
+ }
73
+ /**
74
+ * Shrinks a plot so its own axis labels fit inside the container.
75
+ *
76
+ * Builders call this once they know their tick labels (which depend only on
77
+ * the data domain) and before projecting anything, so the reservation costs no
78
+ * second pass. Without it the frame handed every builder the full container:
79
+ * Y labels, drawn right-aligned left of the plot, landed at negative x, and X
80
+ * labels below the baseline fell past the bottom of the SVG (CHT-01).
81
+ *
82
+ * - left: the widest Y label plus a gutter, and at least half the widest X
83
+ * label, because the first X label is centred on the plot's left edge;
84
+ * - right: half the widest X label, for the last one;
85
+ * - top: the part of the topmost Y label that rises above its tick;
86
+ * - bottom: one line of X labels plus a gutter.
87
+ *
88
+ * Each side is capped so labels can never squeeze the plot out of existence.
89
+ */
90
+ export function insetForAxes(outer, labels) {
91
+ const {
92
+ fontSize
93
+ } = labels;
94
+ let widestX = 0;
95
+ for (const label of labels.xLabels) {
96
+ widestX = Math.max(widestX, estimateTextWidth(label, fontSize));
97
+ }
98
+ const hasY = labels.yLabels.length > 0;
99
+ const hasX = labels.xLabels.length > 0;
100
+ const left = Math.min(Math.max(hasY ? reserveAxisSpace(labels.yLabels, fontSize, 'vertical') : 0, widestX / 2), outer.width * 0.4);
101
+ const right = Math.min(widestX / 2, outer.width * 0.25);
102
+ // Y labels sit on their tick at `position + fontSize / 3`, so two thirds of
103
+ // the glyph box rise above it.
104
+ const top = hasY ? Math.min(Math.ceil(fontSize * 2 / 3), outer.height * 0.2) : 0;
105
+ const bottom = hasX ? Math.min(reserveAxisSpace(labels.xLabels, fontSize, 'horizontal'), outer.height * 0.4) : 0;
106
+ return {
107
+ x: outer.x + left,
108
+ y: outer.y + top,
109
+ width: Math.max(0, outer.width - left - right),
110
+ height: Math.max(0, outer.height - top - bottom)
111
+ };
112
+ }
113
+ export function plotBottom(plot) {
114
+ return plot.y + plot.height;
115
+ }
116
+ export function plotRight(plot) {
117
+ return plot.x + plot.width;
118
+ }
119
+ export function containsPoint(plot, x, y) {
120
+ return x >= plot.x && x <= plotRight(plot) && y >= plot.y && y <= plotBottom(plot);
121
+ }
122
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["estimateTextWidth","reserveAxisSpace","MAX_FONT_SCALE","effectiveFontSize","baseFontSize","fontScale","clamped","Math","max","min","round","isMeasurable","size","Number","isFinite","width","height","EMPTY_PLOT","x","y","resolvePlotRect","options","container","pad","padding","fontSize","left","bottom","yLabels","length","xLabels","availableWidth","availableHeight","maxLeft","maxBottom","insetForAxes","outer","labels","widestX","label","hasY","hasX","right","top","ceil","plotBottom","plot","plotRight","containsPoint"],"sourceRoot":"../../../src","sources":["geometry/layout.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;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