@cdx-ui/components 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/README.md +1 -1
  2. package/coverage.svg +1 -1
  3. package/docs/components/bar-chart/content.md +703 -0
  4. package/docs/components/content.md +9 -1
  5. package/docs/components/line-chart/content.md +567 -0
  6. package/docs/components/pie-chart/content.md +493 -0
  7. package/docs/components/progress-segmented/content.md +1 -1
  8. package/docs/components/stepper/content.md +599 -0
  9. package/docs/components/system-alert/content.md +533 -0
  10. package/docs/foundations/styles/tokens/all-tokens/content.md +2 -1
  11. package/docs/llms.txt +9 -0
  12. package/docs/patterns/content.md +1 -0
  13. package/docs/patterns/dashboard/content.md +423 -19
  14. package/docs/patterns/insights/content.md +590 -0
  15. package/docs/resources/release-notes/0.3.5/content.md +7 -0
  16. package/docs/resources/release-notes/content.md +1 -0
  17. package/lib/commonjs/components/BarChart/geometry.js +1130 -0
  18. package/lib/commonjs/components/BarChart/geometry.js.map +1 -0
  19. package/lib/commonjs/components/BarChart/index.js +942 -0
  20. package/lib/commonjs/components/BarChart/index.js.map +1 -0
  21. package/lib/commonjs/components/BarChart/styles.js +26 -0
  22. package/lib/commonjs/components/BarChart/styles.js.map +1 -0
  23. package/lib/commonjs/components/Button/index.js +2 -2
  24. package/lib/commonjs/components/Button/index.js.map +1 -1
  25. package/lib/commonjs/components/LineChart/geometry.js +698 -0
  26. package/lib/commonjs/components/LineChart/geometry.js.map +1 -0
  27. package/lib/commonjs/components/LineChart/index.js +747 -0
  28. package/lib/commonjs/components/LineChart/index.js.map +1 -0
  29. package/lib/commonjs/components/LineChart/styles.js +25 -0
  30. package/lib/commonjs/components/LineChart/styles.js.map +1 -0
  31. package/lib/commonjs/components/PieChart/geometry.js +216 -0
  32. package/lib/commonjs/components/PieChart/geometry.js.map +1 -0
  33. package/lib/commonjs/components/PieChart/index.js +476 -0
  34. package/lib/commonjs/components/PieChart/index.js.map +1 -0
  35. package/lib/commonjs/components/PieChart/styles.js +88 -0
  36. package/lib/commonjs/components/PieChart/styles.js.map +1 -0
  37. package/lib/commonjs/components/ProgressCircle/ProgressCircleRing.js +9 -31
  38. package/lib/commonjs/components/ProgressCircle/ProgressCircleRing.js.map +1 -1
  39. package/lib/commonjs/components/ProgressCircle/ProgressRing.js +52 -0
  40. package/lib/commonjs/components/ProgressCircle/ProgressRing.js.map +1 -0
  41. package/lib/commonjs/components/ScrollShadow/useScrollShadow.js +8 -7
  42. package/lib/commonjs/components/ScrollShadow/useScrollShadow.js.map +1 -1
  43. package/lib/commonjs/components/Stepper/index.js +369 -0
  44. package/lib/commonjs/components/Stepper/index.js.map +1 -0
  45. package/lib/commonjs/components/Stepper/styles.js +211 -0
  46. package/lib/commonjs/components/Stepper/styles.js.map +1 -0
  47. package/lib/commonjs/components/Stepper/useStepperLabelFit.js +22 -0
  48. package/lib/commonjs/components/Stepper/useStepperLabelFit.js.map +1 -0
  49. package/lib/commonjs/components/Stepper/useStepperLabelFit.web.js +52 -0
  50. package/lib/commonjs/components/Stepper/useStepperLabelFit.web.js.map +1 -0
  51. package/lib/commonjs/components/Stepper/useStepperRingColors.js +31 -0
  52. package/lib/commonjs/components/Stepper/useStepperRingColors.js.map +1 -0
  53. package/lib/commonjs/components/SystemAlert/animation.js +218 -0
  54. package/lib/commonjs/components/SystemAlert/animation.js.map +1 -0
  55. package/lib/commonjs/components/SystemAlert/index.js +525 -0
  56. package/lib/commonjs/components/SystemAlert/index.js.map +1 -0
  57. package/lib/commonjs/components/SystemAlert/styles.js +178 -0
  58. package/lib/commonjs/components/SystemAlert/styles.js.map +1 -0
  59. package/lib/commonjs/components/SystemAlert/useSystemAlertStatusBarStyle.js +53 -0
  60. package/lib/commonjs/components/SystemAlert/useSystemAlertStatusBarStyle.js.map +1 -0
  61. package/lib/commonjs/components/Tabs/index.js +4 -0
  62. package/lib/commonjs/components/Tabs/index.js.map +1 -1
  63. package/lib/commonjs/components/Tabs/styles.js +1 -1
  64. package/lib/commonjs/components/Tabs/styles.js.map +1 -1
  65. package/lib/commonjs/components/chart/ChartInspector.js +610 -0
  66. package/lib/commonjs/components/chart/ChartInspector.js.map +1 -0
  67. package/lib/commonjs/components/chart/format.js +93 -0
  68. package/lib/commonjs/components/chart/format.js.map +1 -0
  69. package/lib/commonjs/components/chart/index.js +2 -0
  70. package/lib/commonjs/components/chart/index.js.map +1 -0
  71. package/lib/commonjs/components/chart/motion.js +97 -0
  72. package/lib/commonjs/components/chart/motion.js.map +1 -0
  73. package/lib/commonjs/components/chart/palette.js +178 -0
  74. package/lib/commonjs/components/chart/palette.js.map +1 -0
  75. package/lib/commonjs/components/chart/size.js +34 -0
  76. package/lib/commonjs/components/chart/size.js.map +1 -0
  77. package/lib/commonjs/components/chart/ticks.js +59 -0
  78. package/lib/commonjs/components/chart/ticks.js.map +1 -0
  79. package/lib/commonjs/components/chart/types.js +6 -0
  80. package/lib/commonjs/components/chart/types.js.map +1 -0
  81. package/lib/commonjs/components/chart/useChartHostWidth.js +27 -0
  82. package/lib/commonjs/components/chart/useChartHostWidth.js.map +1 -0
  83. package/lib/commonjs/components/index.js +60 -0
  84. package/lib/commonjs/components/index.js.map +1 -1
  85. package/lib/commonjs/figma/SystemAlert.Button.figma.js +28 -0
  86. package/lib/commonjs/figma/SystemAlert.Button.figma.js.map +1 -0
  87. package/lib/commonjs/figma/SystemAlert.Close.figma.js +22 -0
  88. package/lib/commonjs/figma/SystemAlert.Close.figma.js.map +1 -0
  89. package/lib/commonjs/figma/SystemAlert.Description.figma.js +20 -0
  90. package/lib/commonjs/figma/SystemAlert.Description.figma.js.map +1 -0
  91. package/lib/commonjs/figma/SystemAlert.IconButton.figma.js +31 -0
  92. package/lib/commonjs/figma/SystemAlert.IconButton.figma.js.map +1 -0
  93. package/lib/commonjs/figma/SystemAlert.figma.js +48 -0
  94. package/lib/commonjs/figma/SystemAlert.figma.js.map +1 -0
  95. package/lib/module/components/BarChart/geometry.js +1110 -0
  96. package/lib/module/components/BarChart/geometry.js.map +1 -0
  97. package/lib/module/components/BarChart/index.js +936 -0
  98. package/lib/module/components/BarChart/index.js.map +1 -0
  99. package/lib/module/components/BarChart/styles.js +22 -0
  100. package/lib/module/components/BarChart/styles.js.map +1 -0
  101. package/lib/module/components/Button/index.js +2 -2
  102. package/lib/module/components/Button/index.js.map +1 -1
  103. package/lib/module/components/LineChart/geometry.js +685 -0
  104. package/lib/module/components/LineChart/geometry.js.map +1 -0
  105. package/lib/module/components/LineChart/index.js +741 -0
  106. package/lib/module/components/LineChart/index.js.map +1 -0
  107. package/lib/module/components/LineChart/styles.js +21 -0
  108. package/lib/module/components/LineChart/styles.js.map +1 -0
  109. package/lib/module/components/PieChart/geometry.js +209 -0
  110. package/lib/module/components/PieChart/geometry.js.map +1 -0
  111. package/lib/module/components/PieChart/index.js +471 -0
  112. package/lib/module/components/PieChart/index.js.map +1 -0
  113. package/lib/module/components/PieChart/styles.js +84 -0
  114. package/lib/module/components/PieChart/styles.js.map +1 -0
  115. package/lib/module/components/ProgressCircle/ProgressCircleRing.js +10 -32
  116. package/lib/module/components/ProgressCircle/ProgressCircleRing.js.map +1 -1
  117. package/lib/module/components/ProgressCircle/ProgressRing.js +48 -0
  118. package/lib/module/components/ProgressCircle/ProgressRing.js.map +1 -0
  119. package/lib/module/components/ScrollShadow/useScrollShadow.js +8 -7
  120. package/lib/module/components/ScrollShadow/useScrollShadow.js.map +1 -1
  121. package/lib/module/components/Stepper/index.js +360 -0
  122. package/lib/module/components/Stepper/index.js.map +1 -0
  123. package/lib/module/components/Stepper/styles.js +206 -0
  124. package/lib/module/components/Stepper/styles.js.map +1 -0
  125. package/lib/module/components/Stepper/useStepperLabelFit.js +18 -0
  126. package/lib/module/components/Stepper/useStepperLabelFit.js.map +1 -0
  127. package/lib/module/components/Stepper/useStepperLabelFit.web.js +48 -0
  128. package/lib/module/components/Stepper/useStepperLabelFit.web.js.map +1 -0
  129. package/lib/module/components/Stepper/useStepperRingColors.js +28 -0
  130. package/lib/module/components/Stepper/useStepperRingColors.js.map +1 -0
  131. package/lib/module/components/SystemAlert/animation.js +213 -0
  132. package/lib/module/components/SystemAlert/animation.js.map +1 -0
  133. package/lib/module/components/SystemAlert/index.js +515 -0
  134. package/lib/module/components/SystemAlert/index.js.map +1 -0
  135. package/lib/module/components/SystemAlert/styles.js +174 -0
  136. package/lib/module/components/SystemAlert/styles.js.map +1 -0
  137. package/lib/module/components/SystemAlert/useSystemAlertStatusBarStyle.js +49 -0
  138. package/lib/module/components/SystemAlert/useSystemAlertStatusBarStyle.js.map +1 -0
  139. package/lib/module/components/Tabs/index.js +4 -0
  140. package/lib/module/components/Tabs/index.js.map +1 -1
  141. package/lib/module/components/Tabs/styles.js +1 -1
  142. package/lib/module/components/Tabs/styles.js.map +1 -1
  143. package/lib/module/components/chart/ChartInspector.js +600 -0
  144. package/lib/module/components/chart/ChartInspector.js.map +1 -0
  145. package/lib/module/components/chart/format.js +84 -0
  146. package/lib/module/components/chart/format.js.map +1 -0
  147. package/lib/module/components/chart/index.js +2 -0
  148. package/lib/module/components/chart/index.js.map +1 -0
  149. package/lib/module/components/chart/motion.js +89 -0
  150. package/lib/module/components/chart/motion.js.map +1 -0
  151. package/lib/module/components/chart/palette.js +168 -0
  152. package/lib/module/components/chart/palette.js.map +1 -0
  153. package/lib/module/components/chart/size.js +29 -0
  154. package/lib/module/components/chart/size.js.map +1 -0
  155. package/lib/module/components/chart/ticks.js +55 -0
  156. package/lib/module/components/chart/ticks.js.map +1 -0
  157. package/lib/module/components/chart/types.js +4 -0
  158. package/lib/module/components/chart/types.js.map +1 -0
  159. package/lib/module/components/chart/useChartHostWidth.js +23 -0
  160. package/lib/module/components/chart/useChartHostWidth.js.map +1 -0
  161. package/lib/module/components/index.js +5 -0
  162. package/lib/module/components/index.js.map +1 -1
  163. package/lib/module/figma/SystemAlert.Button.figma.js +22 -0
  164. package/lib/module/figma/SystemAlert.Button.figma.js.map +1 -0
  165. package/lib/module/figma/SystemAlert.Close.figma.js +18 -0
  166. package/lib/module/figma/SystemAlert.Close.figma.js.map +1 -0
  167. package/lib/module/figma/SystemAlert.Description.figma.js +14 -0
  168. package/lib/module/figma/SystemAlert.Description.figma.js.map +1 -0
  169. package/lib/module/figma/SystemAlert.IconButton.figma.js +25 -0
  170. package/lib/module/figma/SystemAlert.IconButton.figma.js.map +1 -0
  171. package/lib/module/figma/SystemAlert.figma.js +42 -0
  172. package/lib/module/figma/SystemAlert.figma.js.map +1 -0
  173. package/lib/typescript/components/BarChart/geometry.d.ts +236 -0
  174. package/lib/typescript/components/BarChart/geometry.d.ts.map +1 -0
  175. package/lib/typescript/components/BarChart/index.d.ts +193 -0
  176. package/lib/typescript/components/BarChart/index.d.ts.map +1 -0
  177. package/lib/typescript/components/BarChart/styles.d.ts +32 -0
  178. package/lib/typescript/components/BarChart/styles.d.ts.map +1 -0
  179. package/lib/typescript/components/LineChart/geometry.d.ts +248 -0
  180. package/lib/typescript/components/LineChart/geometry.d.ts.map +1 -0
  181. package/lib/typescript/components/LineChart/index.d.ts +105 -0
  182. package/lib/typescript/components/LineChart/index.d.ts.map +1 -0
  183. package/lib/typescript/components/LineChart/styles.d.ts +12 -0
  184. package/lib/typescript/components/LineChart/styles.d.ts.map +1 -0
  185. package/lib/typescript/components/PieChart/geometry.d.ts +43 -0
  186. package/lib/typescript/components/PieChart/geometry.d.ts.map +1 -0
  187. package/lib/typescript/components/PieChart/index.d.ts +147 -0
  188. package/lib/typescript/components/PieChart/index.d.ts.map +1 -0
  189. package/lib/typescript/components/PieChart/styles.d.ts +27 -0
  190. package/lib/typescript/components/PieChart/styles.d.ts.map +1 -0
  191. package/lib/typescript/components/ProgressCircle/ProgressCircleRing.d.ts.map +1 -1
  192. package/lib/typescript/components/ProgressCircle/ProgressRing.d.ts +17 -0
  193. package/lib/typescript/components/ProgressCircle/ProgressRing.d.ts.map +1 -0
  194. package/lib/typescript/components/ScrollShadow/useScrollShadow.d.ts.map +1 -1
  195. package/lib/typescript/components/Stepper/index.d.ts +68 -0
  196. package/lib/typescript/components/Stepper/index.d.ts.map +1 -0
  197. package/lib/typescript/components/Stepper/styles.d.ts +46 -0
  198. package/lib/typescript/components/Stepper/styles.d.ts.map +1 -0
  199. package/lib/typescript/components/Stepper/useStepperLabelFit.d.ts +15 -0
  200. package/lib/typescript/components/Stepper/useStepperLabelFit.d.ts.map +1 -0
  201. package/lib/typescript/components/Stepper/useStepperLabelFit.web.d.ts +10 -0
  202. package/lib/typescript/components/Stepper/useStepperLabelFit.web.d.ts.map +1 -0
  203. package/lib/typescript/components/Stepper/useStepperRingColors.d.ts +6 -0
  204. package/lib/typescript/components/Stepper/useStepperRingColors.d.ts.map +1 -0
  205. package/lib/typescript/components/SystemAlert/animation.d.ts +56 -0
  206. package/lib/typescript/components/SystemAlert/animation.d.ts.map +1 -0
  207. package/lib/typescript/components/SystemAlert/index.d.ts +110 -0
  208. package/lib/typescript/components/SystemAlert/index.d.ts.map +1 -0
  209. package/lib/typescript/components/SystemAlert/styles.d.ts +38 -0
  210. package/lib/typescript/components/SystemAlert/styles.d.ts.map +1 -0
  211. package/lib/typescript/components/SystemAlert/useSystemAlertStatusBarStyle.d.ts +14 -0
  212. package/lib/typescript/components/SystemAlert/useSystemAlertStatusBarStyle.d.ts.map +1 -0
  213. package/lib/typescript/components/Tabs/index.d.ts.map +1 -1
  214. package/lib/typescript/components/chart/ChartInspector.d.ts +101 -0
  215. package/lib/typescript/components/chart/ChartInspector.d.ts.map +1 -0
  216. package/lib/typescript/components/chart/format.d.ts +16 -0
  217. package/lib/typescript/components/chart/format.d.ts.map +1 -0
  218. package/lib/typescript/components/chart/index.d.ts +3 -0
  219. package/lib/typescript/components/chart/index.d.ts.map +1 -0
  220. package/lib/typescript/components/chart/motion.d.ts +27 -0
  221. package/lib/typescript/components/chart/motion.d.ts.map +1 -0
  222. package/lib/typescript/components/chart/palette.d.ts +44 -0
  223. package/lib/typescript/components/chart/palette.d.ts.map +1 -0
  224. package/lib/typescript/components/chart/size.d.ts +25 -0
  225. package/lib/typescript/components/chart/size.d.ts.map +1 -0
  226. package/lib/typescript/components/chart/ticks.d.ts +3 -0
  227. package/lib/typescript/components/chart/ticks.d.ts.map +1 -0
  228. package/lib/typescript/components/chart/types.d.ts +163 -0
  229. package/lib/typescript/components/chart/types.d.ts.map +1 -0
  230. package/lib/typescript/components/chart/useChartHostWidth.d.ts +9 -0
  231. package/lib/typescript/components/chart/useChartHostWidth.d.ts.map +1 -0
  232. package/lib/typescript/components/index.d.ts +5 -0
  233. package/lib/typescript/components/index.d.ts.map +1 -1
  234. package/lib/typescript/figma/SystemAlert.Button.figma.d.ts +11 -0
  235. package/lib/typescript/figma/SystemAlert.Button.figma.d.ts.map +1 -0
  236. package/lib/typescript/figma/SystemAlert.Close.figma.d.ts +11 -0
  237. package/lib/typescript/figma/SystemAlert.Close.figma.d.ts.map +1 -0
  238. package/lib/typescript/figma/SystemAlert.Description.figma.d.ts +8 -0
  239. package/lib/typescript/figma/SystemAlert.Description.figma.d.ts.map +1 -0
  240. package/lib/typescript/figma/SystemAlert.IconButton.figma.d.ts +11 -0
  241. package/lib/typescript/figma/SystemAlert.IconButton.figma.d.ts.map +1 -0
  242. package/lib/typescript/figma/SystemAlert.figma.d.ts +8 -0
  243. package/lib/typescript/figma/SystemAlert.figma.d.ts.map +1 -0
  244. package/package.json +5 -5
  245. package/src/components/BarChart/geometry.ts +1469 -0
  246. package/src/components/BarChart/index.tsx +1424 -0
  247. package/src/components/BarChart/styles.ts +31 -0
  248. package/src/components/Button/index.tsx +1 -1
  249. package/src/components/LineChart/geometry.ts +957 -0
  250. package/src/components/LineChart/index.tsx +1109 -0
  251. package/src/components/LineChart/styles.ts +26 -0
  252. package/src/components/PieChart/geometry.ts +295 -0
  253. package/src/components/PieChart/index.tsx +715 -0
  254. package/src/components/PieChart/styles.ts +101 -0
  255. package/src/components/ProgressCircle/ProgressCircleRing.tsx +10 -39
  256. package/src/components/ProgressCircle/ProgressRing.tsx +60 -0
  257. package/src/components/ScrollShadow/useScrollShadow.ts +12 -11
  258. package/src/components/Stepper/index.tsx +452 -0
  259. package/src/components/Stepper/styles.ts +234 -0
  260. package/src/components/Stepper/useStepperLabelFit.ts +21 -0
  261. package/src/components/Stepper/useStepperLabelFit.web.ts +53 -0
  262. package/src/components/Stepper/useStepperRingColors.ts +29 -0
  263. package/src/components/SystemAlert/animation.ts +252 -0
  264. package/src/components/SystemAlert/index.tsx +684 -0
  265. package/src/components/SystemAlert/styles.ts +212 -0
  266. package/src/components/SystemAlert/useSystemAlertStatusBarStyle.ts +57 -0
  267. package/src/components/Tabs/index.tsx +4 -0
  268. package/src/components/Tabs/styles.ts +1 -1
  269. package/src/components/chart/ChartInspector.tsx +726 -0
  270. package/src/components/chart/format.ts +95 -0
  271. package/src/components/chart/index.ts +24 -0
  272. package/src/components/chart/motion.ts +98 -0
  273. package/src/components/chart/palette.tsx +247 -0
  274. package/src/components/chart/size.ts +21 -0
  275. package/src/components/chart/ticks.ts +53 -0
  276. package/src/components/chart/types.ts +183 -0
  277. package/src/components/chart/useChartHostWidth.ts +26 -0
  278. package/src/components/index.ts +5 -0
@@ -0,0 +1,698 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MIN_LINE_POINT_BAND = exports.LINE_POINT_HIT_PX = exports.LINE_POINTER_HIT_PX = exports.LINE_MARKER_PADDING_TOP = exports.LINE_MARKER_PADDING_RIGHT = exports.DEFAULT_LINE_TICK_NUMBER = void 0;
7
+ exports.layoutLineChart = layoutLineChart;
8
+ exports.layoutLineChartMarkers = layoutLineChartMarkers;
9
+ exports.lineChartGutters = lineChartGutters;
10
+ exports.lineChartMarkerGutters = lineChartMarkerGutters;
11
+ exports.lineSeriesPaths = lineSeriesPaths;
12
+ exports.lineValueDomain = lineValueDomain;
13
+ exports.nearestCategoryInPlot = nearestCategoryInPlot;
14
+ exports.nearestCategoryOnLines = nearestCategoryOnLines;
15
+ exports.resolveLineChartContentSize = resolveLineChartContentSize;
16
+ exports.resolveLineChartData = resolveLineChartData;
17
+ var _ticks = require("../chart/ticks");
18
+ /** How points connect. Names match MUI X `curve`. */
19
+
20
+ const MIN_LINE_POINT_BAND = exports.MIN_LINE_POINT_BAND = 32;
21
+ /** Max distance from a series stroke (overlay px) that still counts as hovering the line. */
22
+ const LINE_POINTER_HIT_PX = exports.LINE_POINTER_HIT_PX = 20;
23
+ /** Extra radius around a plotted point (dots / markers) so a valley like Lowest is easy to hit. */
24
+ const LINE_POINT_HIT_PX = exports.LINE_POINT_HIT_PX = 28;
25
+ /** Extra plot padding when a marker draws a caption or value. */
26
+ const LINE_MARKER_PADDING_TOP = exports.LINE_MARKER_PADDING_TOP = 28;
27
+ const LINE_MARKER_PADDING_RIGHT = exports.LINE_MARKER_PADDING_RIGHT = 36;
28
+ const DEFAULT_LINE_TICK_NUMBER = exports.DEFAULT_LINE_TICK_NUMBER = 4;
29
+ const VALUE_TICK_LEFT = 40;
30
+ const VALUE_TICK_END = 28;
31
+ const TIGHT_GUTTER = 8;
32
+ const PLOT_END_GUTTER = 20;
33
+ const CATEGORY_GUTTER = 28;
34
+ function round2(value) {
35
+ 'worklet';
36
+
37
+ const rounded = Math.round(value * 100) / 100;
38
+ return Object.is(rounded, -0) ? 0 : rounded;
39
+ }
40
+ function readNumber(row, key) {
41
+ const raw = row[key];
42
+ if (typeof raw !== 'number' || !Number.isFinite(raw)) {
43
+ return null;
44
+ }
45
+ return raw;
46
+ }
47
+ function rawCategory(row, key, index) {
48
+ if (key === undefined || row === undefined) {
49
+ return index;
50
+ }
51
+ return row[key];
52
+ }
53
+ function categoryText(raw, index, location, axis) {
54
+ if (typeof raw === 'string') {
55
+ return raw;
56
+ }
57
+ if (typeof raw === 'number') {
58
+ return axis?.valueFormatter?.(raw, {
59
+ location,
60
+ dataIndex: index
61
+ }) ?? String(raw);
62
+ }
63
+ if (raw === null || raw === undefined) {
64
+ return '';
65
+ }
66
+ return String(raw);
67
+ }
68
+
69
+ /**
70
+ * Maps the public `dataset` + `series` + `xAxis` props onto geometry inputs. Row keys are read
71
+ * only through `dataKey`, so no key is reserved.
72
+ */
73
+ function resolveLineChartData({
74
+ dataset,
75
+ series,
76
+ xAxis
77
+ }) {
78
+ const axis = xAxis;
79
+ const interval = axis?.tickLabelInterval;
80
+ const hidden = axis?.position === 'none';
81
+ const categories = dataset.map((row, index) => {
82
+ const raw = rawCategory(row, axis?.dataKey, index);
83
+ const label = categoryText(raw, index, 'tick', axis);
84
+ const shown = typeof interval === 'function' ? interval(raw, index) : true;
85
+ return {
86
+ label,
87
+ title: categoryText(raw, index, 'tooltip', axis),
88
+ tick: !hidden && shown && label.length > 0
89
+ };
90
+ });
91
+ const inputs = series.map(item => {
92
+ const dashed = item.dashed === true;
93
+ const dashAt = dashed || item.dashedFrom === undefined || !Number.isInteger(item.dashedFrom) ? -1 : item.dashedFrom;
94
+ return {
95
+ id: item.id,
96
+ label: item.label ?? '',
97
+ curve: item.curve ?? 'monotoneX',
98
+ area: item.area === true,
99
+ dashed,
100
+ dashAt,
101
+ values: dataset.map(row => readNumber(row, item.dataKey))
102
+ };
103
+ });
104
+ return {
105
+ categories,
106
+ series: inputs
107
+ };
108
+ }
109
+ function lineChartGutters({
110
+ showValueTicks = true,
111
+ showCategoryLabels = true
112
+ } = {}) {
113
+ return {
114
+ paddingLeft: showValueTicks ? VALUE_TICK_LEFT : TIGHT_GUTTER,
115
+ paddingRight: showValueTicks ? VALUE_TICK_END : PLOT_END_GUTTER,
116
+ paddingTop: TIGHT_GUTTER,
117
+ paddingBottom: showCategoryLabels ? CATEGORY_GUTTER : TIGHT_GUTTER
118
+ };
119
+ }
120
+ function resolveLineChartContentSize({
121
+ viewportWidth,
122
+ viewportHeight,
123
+ categoryCount,
124
+ gutters,
125
+ scrollable,
126
+ visiblePoints
127
+ }) {
128
+ if (!scrollable || categoryCount <= 0) {
129
+ return {
130
+ width: viewportWidth,
131
+ height: viewportHeight
132
+ };
133
+ }
134
+ const plotWidth = Math.max(viewportWidth - gutters.paddingLeft - gutters.paddingRight, 0);
135
+ const band = visiblePoints !== undefined && visiblePoints > 0 ? plotWidth / Math.max(visiblePoints - 1, 1) : MIN_LINE_POINT_BAND;
136
+ const contentPlot = Math.max(plotWidth, Math.max(categoryCount - 1, 1) * band);
137
+ return {
138
+ width: contentPlot + gutters.paddingLeft + gutters.paddingRight,
139
+ height: viewportHeight
140
+ };
141
+ }
142
+
143
+ /**
144
+ * Value domain and ticks. `min` / `max` pin that end exactly; an open end rounds to a readable
145
+ * tick. `tickNumber` is approximate.
146
+ */
147
+ function lineValueDomain(values, {
148
+ min: minOption,
149
+ max: maxOption,
150
+ tickNumber = DEFAULT_LINE_TICK_NUMBER
151
+ } = {}) {
152
+ const min = minOption !== undefined && Number.isFinite(minOption) ? minOption : undefined;
153
+ const max = maxOption !== undefined && Number.isFinite(maxOption) ? maxOption : undefined;
154
+ let low = min ?? (values.length > 0 ? Math.min(...values) : 0);
155
+ let high = max ?? (values.length > 0 ? Math.max(...values) : 1);
156
+ if (low > high) {
157
+ [low, high] = [high, low];
158
+ }
159
+ if (low === high) {
160
+ if (min === undefined) {
161
+ low -= 1;
162
+ }
163
+ if (max === undefined || min !== undefined) {
164
+ high += 1;
165
+ }
166
+ }
167
+ const nice = (0, _ticks.niceTicks)(low, high, tickNumber);
168
+ const domainMin = min ?? nice[0] ?? low;
169
+ const domainMax = max ?? nice[nice.length - 1] ?? high;
170
+ const epsilon = (domainMax - domainMin) * 1e-9;
171
+ const ticks = nice.filter(tick => tick >= domainMin - epsilon && tick <= domainMax + epsilon);
172
+ return {
173
+ min: domainMin,
174
+ max: domainMax,
175
+ ticks
176
+ };
177
+ }
178
+ function coord(x, y) {
179
+ 'worklet';
180
+
181
+ return `${String(round2(x))} ${String(round2(y))}`;
182
+ }
183
+ function linearPath(points) {
184
+ 'worklet';
185
+
186
+ return points.map((point, index) => `${index === 0 ? 'M' : 'L'} ${coord(point.x, point.y)}`).join(' ');
187
+ }
188
+ function stepPath(points) {
189
+ 'worklet';
190
+
191
+ if (points.length === 0) {
192
+ return '';
193
+ }
194
+ const parts = [`M ${coord(points[0].x, points[0].y)}`];
195
+ for (let index = 1; index < points.length; index += 1) {
196
+ const prev = points[index - 1];
197
+ const point = points[index];
198
+ parts.push(`L ${coord(point.x, prev.y)}`, `L ${coord(point.x, point.y)}`);
199
+ }
200
+ return parts.join(' ');
201
+ }
202
+ function monotoneControls(points) {
203
+ 'worklet';
204
+
205
+ const count = points.length;
206
+ const dx = [];
207
+ const slope = [];
208
+ for (let index = 0; index < count - 1; index += 1) {
209
+ const deltaX = points[index + 1].x - points[index].x;
210
+ dx.push(deltaX);
211
+ slope.push(deltaX === 0 ? 0 : (points[index + 1].y - points[index].y) / deltaX);
212
+ }
213
+ const tangent = [slope[0]];
214
+ for (let index = 1; index < count - 1; index += 1) {
215
+ tangent.push(slope[index - 1] * slope[index] <= 0 ? 0 : (slope[index - 1] + slope[index]) / 2);
216
+ }
217
+ tangent.push(slope[count - 2]);
218
+ for (let index = 0; index < count - 1; index += 1) {
219
+ if (Math.abs(slope[index]) < 1e-8) {
220
+ tangent[index] = 0;
221
+ tangent[index + 1] = 0;
222
+ continue;
223
+ }
224
+ const alpha = tangent[index] / slope[index];
225
+ const beta = tangent[index + 1] / slope[index];
226
+ const magnitude = alpha * alpha + beta * beta;
227
+ if (magnitude > 9) {
228
+ const scale = 3 / Math.sqrt(magnitude);
229
+ tangent[index] = scale * alpha * slope[index];
230
+ tangent[index + 1] = scale * beta * slope[index];
231
+ }
232
+ }
233
+ return {
234
+ dx,
235
+ tangent
236
+ };
237
+ }
238
+ function monotonePathSlice(points, from, to) {
239
+ 'worklet';
240
+
241
+ const count = points.length;
242
+ if (count === 0 || to < from || from < 0 || to > count - 1) {
243
+ return '';
244
+ }
245
+ if (from === to) {
246
+ return `M ${coord(points[from].x, points[from].y)}`;
247
+ }
248
+ if (count === 2) {
249
+ return linearPath(points.slice(from, to + 1));
250
+ }
251
+ const {
252
+ dx,
253
+ tangent
254
+ } = monotoneControls(points);
255
+ const parts = [`M ${coord(points[from].x, points[from].y)}`];
256
+ for (let index = from; index < to; index += 1) {
257
+ const start = points[index];
258
+ const end = points[index + 1];
259
+ const handle = dx[index] / 3;
260
+ parts.push(`C ${coord(start.x + handle, start.y + tangent[index] * handle)} ${coord(end.x - handle, end.y - tangent[index + 1] * handle)} ${coord(end.x, end.y)}`);
261
+ }
262
+ return parts.join(' ');
263
+ }
264
+ function monotonePath(points) {
265
+ 'worklet';
266
+
267
+ if (points.length === 0) {
268
+ return '';
269
+ }
270
+ return monotonePathSlice(points, 0, points.length - 1);
271
+ }
272
+ function pathForCurve(points, curve) {
273
+ 'worklet';
274
+
275
+ if (curve === 'stepAfter') {
276
+ return stepPath(points);
277
+ }
278
+ if (curve === 'monotoneX') {
279
+ return monotonePath(points);
280
+ }
281
+ return linearPath(points);
282
+ }
283
+ function pathSlice(points, curve, from, to) {
284
+ 'worklet';
285
+
286
+ if (to <= from) {
287
+ return '';
288
+ }
289
+ if (curve === 'monotoneX') {
290
+ return monotonePathSlice(points, from, to);
291
+ }
292
+ return pathForCurve(points.slice(from, to + 1), curve);
293
+ }
294
+ function areaFromLine(linePath, run, baselineY) {
295
+ 'worklet';
296
+
297
+ if (linePath.length === 0 || run.length === 0) {
298
+ return '';
299
+ }
300
+ const first = run[0];
301
+ const last = run[run.length - 1];
302
+ return `${linePath} L ${coord(last.x, baselineY)} L ${coord(first.x, baselineY)} Z`;
303
+ }
304
+
305
+ /**
306
+ * Line and area paths for one series. `ys` uses `NaN` for missing values, which
307
+ * open a gap. Runs on the UI thread while a chart animates.
308
+ * `dashAt` is a category index; cubics before it stay solid, after it dashed,
309
+ * using the same monotone tangents so the join stays round.
310
+ */
311
+ function lineSeriesPaths(xs, ys, curve, baselineY, dashAt = -1) {
312
+ 'worklet';
313
+
314
+ const runs = [];
315
+ let current = [];
316
+ for (let index = 0; index < ys.length; index += 1) {
317
+ const y = ys[index];
318
+ if (!Number.isFinite(y)) {
319
+ if (current.length > 0) {
320
+ runs.push(current);
321
+ current = [];
322
+ }
323
+ continue;
324
+ }
325
+ current.push({
326
+ x: xs[index] ?? 0,
327
+ y,
328
+ index
329
+ });
330
+ }
331
+ if (current.length > 0) {
332
+ runs.push(current);
333
+ }
334
+ const solids = [];
335
+ const dashes = [];
336
+ const areas = [];
337
+ for (const run of runs) {
338
+ const line = pathForCurve(run, curve);
339
+ areas.push(areaFromLine(line, run, baselineY));
340
+ const first = run[0]?.index ?? -1;
341
+ const last = run[run.length - 1]?.index ?? -1;
342
+ if (dashAt < 0 || dashAt <= first || dashAt >= last) {
343
+ if (dashAt >= 0 && dashAt <= first) {
344
+ dashes.push(line);
345
+ } else {
346
+ solids.push(line);
347
+ }
348
+ continue;
349
+ }
350
+ const split = run.findIndex(point => point.index === dashAt);
351
+ if (split <= 0) {
352
+ solids.push(line);
353
+ continue;
354
+ }
355
+ solids.push(pathSlice(run, curve, 0, split));
356
+ dashes.push(pathSlice(run, curve, split, run.length - 1));
357
+ }
358
+ return {
359
+ path: solids.join(' '),
360
+ dashedPath: dashes.join(' '),
361
+ areaPath: areas.join(' ')
362
+ };
363
+ }
364
+
365
+ /** Pins each marker to its `dataIndex` row; markers that cannot resolve are dropped. */
366
+ function layoutLineChartMarkers(markers, series) {
367
+ return markers.flatMap((marker, markerIndex) => {
368
+ const index = marker.dataIndex;
369
+ if (!Number.isInteger(index)) {
370
+ return [];
371
+ }
372
+ const seriesItem = marker.seriesId !== undefined ? series.find(item => item.key === marker.seriesId) : series.find(item => item.points[index]?.y != null);
373
+ const point = seriesItem?.points[index];
374
+ if (seriesItem === undefined || point?.y == null || point.value == null) {
375
+ return [];
376
+ }
377
+ return [{
378
+ key: `${seriesItem.key}-${String(index)}-${String(markerIndex)}`,
379
+ index,
380
+ seriesIndex: series.indexOf(seriesItem),
381
+ seriesId: seriesItem.key,
382
+ x: point.x,
383
+ y: point.y,
384
+ value: point.value,
385
+ label: marker.label,
386
+ showValue: marker.showValue === true,
387
+ color: marker.color,
388
+ legend: marker.legend,
389
+ guide: marker.guide !== false,
390
+ dot: marker.dot !== false
391
+ }];
392
+ });
393
+ }
394
+ function distanceToSegment(px, py, ax, ay, bx, by) {
395
+ const dx = bx - ax;
396
+ const dy = by - ay;
397
+ const length = dx * dx + dy * dy;
398
+ if (length === 0) {
399
+ return Math.hypot(px - ax, py - ay);
400
+ }
401
+ const t = Math.max(0, Math.min(1, ((px - ax) * dx + (py - ay) * dy) / length));
402
+ return Math.hypot(px - (ax + t * dx), py - (ay + t * dy));
403
+ }
404
+ function cubicPoint(t, p0, p1, p2, p3) {
405
+ const u = 1 - t;
406
+ const a = u * u * u;
407
+ const b = 3 * u * u * t;
408
+ const c = 3 * u * t * t;
409
+ const d = t * t * t;
410
+ return {
411
+ x: a * p0.x + b * p1.x + c * p2.x + d * p3.x,
412
+ y: a * p0.y + b * p1.y + c * p2.y + d * p3.y
413
+ };
414
+ }
415
+ function sampleMonotoneRun(points) {
416
+ if (points.length < 3) {
417
+ return [...points];
418
+ }
419
+ const count = points.length;
420
+ const dx = [];
421
+ const slope = [];
422
+ for (let index = 0; index < count - 1; index += 1) {
423
+ const from = points[index];
424
+ const to = points[index + 1];
425
+ if (from === undefined || to === undefined) {
426
+ continue;
427
+ }
428
+ const deltaX = to.x - from.x;
429
+ dx.push(deltaX);
430
+ slope.push(deltaX === 0 ? 0 : (to.y - from.y) / deltaX);
431
+ }
432
+ const tangent = [slope[0] ?? 0];
433
+ for (let index = 1; index < count - 1; index += 1) {
434
+ tangent.push((slope[index - 1] ?? 0) * (slope[index] ?? 0) <= 0 ? 0 : ((slope[index - 1] ?? 0) + (slope[index] ?? 0)) / 2);
435
+ }
436
+ tangent.push(slope[count - 2] ?? 0);
437
+ for (let index = 0; index < count - 1; index += 1) {
438
+ if (Math.abs(slope[index] ?? 0) < 1e-8) {
439
+ tangent[index] = 0;
440
+ tangent[index + 1] = 0;
441
+ }
442
+ }
443
+ const sampled = [];
444
+ const steps = 8;
445
+ for (let index = 0; index < count - 1; index += 1) {
446
+ const start = points[index];
447
+ const end = points[index + 1];
448
+ if (start === undefined || end === undefined) {
449
+ continue;
450
+ }
451
+ const handle = (dx[index] ?? 0) / 3;
452
+ const c1 = {
453
+ x: start.x + handle,
454
+ y: start.y + (tangent[index] ?? 0) * handle
455
+ };
456
+ const c2 = {
457
+ x: end.x - handle,
458
+ y: end.y - (tangent[index + 1] ?? 0) * handle
459
+ };
460
+ for (let step = 0; step < steps; step += 1) {
461
+ const t = step / steps;
462
+ const point = cubicPoint(t, start, c1, c2, end);
463
+ sampled.push({
464
+ x: point.x,
465
+ y: point.y,
466
+ index: t < 0.5 ? start.index : end.index
467
+ });
468
+ }
469
+ }
470
+ const last = points[count - 1];
471
+ if (last !== undefined) {
472
+ sampled.push(last);
473
+ }
474
+ return sampled;
475
+ }
476
+ function strokeSamples(points, curve) {
477
+ if (curve === 'monotoneX') {
478
+ return sampleMonotoneRun(points);
479
+ }
480
+ if (curve === 'stepAfter') {
481
+ const sampled = [];
482
+ for (let index = 0; index < points.length; index += 1) {
483
+ const from = points[index];
484
+ const to = points[index + 1];
485
+ if (from === undefined) {
486
+ continue;
487
+ }
488
+ sampled.push(from);
489
+ if (to !== undefined) {
490
+ sampled.push({
491
+ x: to.x,
492
+ y: from.y,
493
+ index: from.index
494
+ });
495
+ }
496
+ }
497
+ return sampled;
498
+ }
499
+ return [...points];
500
+ }
501
+
502
+ /**
503
+ * Category index of the closest point on any series stroke, or `null` when the pointer is
504
+ * farther than `maxDistance` from every line. Overlay coordinates (`plot.x` already subtracted).
505
+ * Uses the same monotone cubics as the painted path so a valley (Lowest) still hits.
506
+ */
507
+ function nearestCategoryOnLines(series, overlayX, overlayY, plotOffsetX, maxDistance, pointDistance = maxDistance) {
508
+ let bestDistance = Math.max(maxDistance, pointDistance);
509
+ let bestIndex = null;
510
+ for (const item of series) {
511
+ const points = item.points.flatMap(point => point.y == null ? [] : [{
512
+ x: point.x - plotOffsetX,
513
+ y: point.y,
514
+ index: point.index
515
+ }]);
516
+ for (const point of points) {
517
+ const distance = Math.hypot(overlayX - point.x, overlayY - point.y);
518
+ if (distance <= pointDistance && distance <= bestDistance) {
519
+ bestDistance = distance;
520
+ bestIndex = point.index;
521
+ }
522
+ }
523
+ const sampled = strokeSamples(points, item.curve);
524
+ for (let i = 0; i < sampled.length; i += 1) {
525
+ const from = sampled[i];
526
+ const to = sampled[i + 1];
527
+ if (from === undefined) {
528
+ continue;
529
+ }
530
+ const distance = to === undefined ? Math.hypot(overlayX - from.x, overlayY - from.y) : distanceToSegment(overlayX, overlayY, from.x, from.y, to.x, to.y);
531
+ if (distance > maxDistance || distance > bestDistance) {
532
+ continue;
533
+ }
534
+ bestDistance = distance;
535
+ if (to === undefined) {
536
+ bestIndex = from.index;
537
+ } else {
538
+ const closerToStart = Math.hypot(overlayX - from.x, overlayY - from.y) <= Math.hypot(overlayX - to.x, overlayY - to.y);
539
+ bestIndex = closerToStart ? from.index : to.index;
540
+ }
541
+ }
542
+ }
543
+ return bestIndex;
544
+ }
545
+
546
+ /**
547
+ * Category under the pointer when it is inside the plot box. Snaps to the nearest category on X.
548
+ * Overlay coordinates (`plot.x` already subtracted).
549
+ */
550
+ function nearestCategoryInPlot(labels, plot, overlayX, overlayY, plotOffsetX) {
551
+ if (labels.length === 0) {
552
+ return null;
553
+ }
554
+ if (overlayY < plot.y || overlayY > plot.y + plot.height) {
555
+ return null;
556
+ }
557
+ if (overlayX < 0 || overlayX > plot.width) {
558
+ return null;
559
+ }
560
+ let bestIndex = 0;
561
+ let bestDist = Number.POSITIVE_INFINITY;
562
+ labels.forEach((item, index) => {
563
+ const dist = Math.abs(item.x - plotOffsetX - overlayX);
564
+ if (dist < bestDist) {
565
+ bestDist = dist;
566
+ bestIndex = index;
567
+ }
568
+ });
569
+ return bestIndex;
570
+ }
571
+ function lineChartMarkerGutters(categoryCount, markers, base = lineChartGutters()) {
572
+ if (markers === undefined || markers.length === 0) {
573
+ return base;
574
+ }
575
+ const hasCaption = markers.some(marker => marker.label !== undefined && marker.label.length > 0 || marker.showValue === true);
576
+ const hasEndValue = markers.some(marker => marker.showValue === true && marker.dataIndex === categoryCount - 1);
577
+ return {
578
+ ...base,
579
+ paddingTop: hasCaption ? LINE_MARKER_PADDING_TOP : base.paddingTop,
580
+ paddingRight: hasEndValue ? LINE_MARKER_PADDING_RIGHT : base.paddingRight
581
+ };
582
+ }
583
+ function layoutLineChart({
584
+ categories,
585
+ series,
586
+ width,
587
+ height,
588
+ referenceLines = [],
589
+ yAxis,
590
+ formatTick = String,
591
+ gutters: guttersProp
592
+ }) {
593
+ const empty = {
594
+ series: [],
595
+ categoryLabels: [],
596
+ valueTicks: [],
597
+ gridLines: [],
598
+ referenceLines: [],
599
+ baselineY: 0,
600
+ plot: {
601
+ x: 0,
602
+ y: 0,
603
+ width: 0,
604
+ height: 0
605
+ }
606
+ };
607
+ if (width <= 0 || height <= 0 || categories.length === 0 || series.length === 0) {
608
+ return empty;
609
+ }
610
+ const gutters = guttersProp ?? lineChartGutters();
611
+ const plot = {
612
+ x: gutters.paddingLeft,
613
+ y: gutters.paddingTop,
614
+ width: Math.max(width - gutters.paddingLeft - gutters.paddingRight, 0),
615
+ height: Math.max(height - gutters.paddingTop - gutters.paddingBottom, 0)
616
+ };
617
+ const values = [...series.flatMap(item => item.values.filter(value => value !== null)), ...referenceLines.flatMap(line => Number.isFinite(line.value) ? [line.value] : [])];
618
+ const domain = lineValueDomain(values, yAxis);
619
+ const span = domain.max - domain.min || 1;
620
+ const lastIndex = Math.max(categories.length - 1, 1);
621
+ const valueToY = value => plot.y + plot.height * (1 - (value - domain.min) / span);
622
+ const indexToX = index => categories.length === 1 ? plot.x + plot.width / 2 : plot.x + index / lastIndex * plot.width;
623
+ const baselineY = valueToY(Math.min(Math.max(0, domain.min), domain.max));
624
+ const categoryLabels = categories.map((category, index) => ({
625
+ label: category.label,
626
+ title: category.title,
627
+ x: round2(indexToX(index)),
628
+ y: round2(height - 8),
629
+ tick: category.tick
630
+ }));
631
+ const seriesLayouts = series.map(item => {
632
+ const points = categories.map((_, index) => {
633
+ const value = item.values[index] ?? null;
634
+ return {
635
+ index,
636
+ value,
637
+ x: round2(indexToX(index)),
638
+ y: value === null ? null : round2(valueToY(value))
639
+ };
640
+ });
641
+ const dashAt = item.dashAt < categories.length ? item.dashAt : -1;
642
+ const {
643
+ path,
644
+ dashedPath,
645
+ areaPath
646
+ } = lineSeriesPaths(points.map(point => point.x), points.map(point => point.y ?? Number.NaN), item.curve, baselineY, dashAt);
647
+ return {
648
+ key: item.id,
649
+ label: item.label,
650
+ curve: item.curve,
651
+ area: item.area,
652
+ dashed: item.dashed,
653
+ path,
654
+ dashedPath,
655
+ dashAt,
656
+ areaPath,
657
+ points
658
+ };
659
+ });
660
+ const valueTicks = domain.ticks.map(value => ({
661
+ value,
662
+ x: round2(plot.x - 8),
663
+ y: round2(valueToY(value)),
664
+ text: formatTick(value)
665
+ }));
666
+ const gridLines = domain.ticks.map(value => {
667
+ const y = round2(valueToY(value));
668
+ return {
669
+ x1: round2(plot.x),
670
+ y1: y,
671
+ x2: round2(plot.x + plot.width),
672
+ y2: y
673
+ };
674
+ });
675
+ const laidReference = referenceLines.flatMap(line => {
676
+ if (!Number.isFinite(line.value)) {
677
+ return [];
678
+ }
679
+ const y = round2(valueToY(line.value));
680
+ return [{
681
+ x1: round2(plot.x),
682
+ y1: y,
683
+ x2: round2(plot.x + plot.width),
684
+ y2: y,
685
+ label: line.label
686
+ }];
687
+ });
688
+ return {
689
+ series: seriesLayouts,
690
+ categoryLabels,
691
+ valueTicks,
692
+ gridLines,
693
+ referenceLines: laidReference,
694
+ baselineY: round2(baselineY),
695
+ plot
696
+ };
697
+ }
698
+ //# sourceMappingURL=geometry.js.map