@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,747 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LineChart = void 0;
7
+ var _react = require("react");
8
+ var _reactNative = require("react-native");
9
+ var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
10
+ var _reactNativeSvg = require("react-native-svg");
11
+ var _primitives = require("@cdx-ui/primitives");
12
+ var _utils = require("@cdx-ui/utils");
13
+ var _ChartInspector = require("../chart/ChartInspector");
14
+ var _format = require("../chart/format");
15
+ var _size = require("../chart/size");
16
+ var _useChartHostWidth = require("../chart/useChartHostWidth");
17
+ var _palette = require("../chart/palette");
18
+ var _motion = require("../chart/motion");
19
+ var _geometry = require("./geometry");
20
+ var _styles = require("./styles");
21
+ var _jsxRuntime = require("react/jsx-runtime");
22
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
23
+ /* SVG `x`/`y` are paint coordinates. RN View `x`/`y` layout props are deprecated and share the name. */
24
+ /* eslint-disable @typescript-eslint/no-deprecated */
25
+
26
+ const INACTIVE_OPACITY = 0.4;
27
+ const DASH = '6 4';
28
+ /** Within this many px of a plot edge, callouts anchor inward so they are not clipped. */
29
+ const EDGE_LABEL_ROOM = 32;
30
+ /** Paint slack around the plot so dots and strokes on its edges are not cut in half. */
31
+ const CLIP_BLEED = _styles.LINE_ACTIVE_DOT_RADIUS + _styles.LINE_STROKE_WIDTH;
32
+ const AnimatedPath = _reactNativeReanimated.default.createAnimatedComponent(_reactNativeSvg.Path);
33
+ const AnimatedCircle = _reactNativeReanimated.default.createAnimatedComponent(_reactNativeSvg.Circle);
34
+ function LineChartInner({
35
+ dataset,
36
+ series: seriesProp,
37
+ xAxis: xAxisProp,
38
+ yAxis: yAxisProp,
39
+ size = 'lg',
40
+ width: widthProp,
41
+ height: heightProp,
42
+ grid,
43
+ palette = 'auto',
44
+ hideLegend = false,
45
+ tooltip: tooltipProp,
46
+ scrollable = true,
47
+ visiblePoints,
48
+ selectedItem: selectedItemProp,
49
+ defaultSelectedItem,
50
+ onSelectedItemChange,
51
+ referenceLines,
52
+ markers,
53
+ locale,
54
+ localeText: localeTextProp,
55
+ animation,
56
+ accessibilityLabel,
57
+ className,
58
+ style,
59
+ onLayout,
60
+ ...props
61
+ }, ref) {
62
+ const animated = (0, _motion.useChartMotionEnabled)(animation);
63
+ const gradientId = (0, _palette.useChartGradientId)('line-fill');
64
+ const chrome = (0, _palette.useChartChrome)();
65
+ const paints = (0, _palette.useChartColorPaints)();
66
+ const localeText = (0, _react.useMemo)(() => (0, _format.resolveChartLocaleText)(localeTextProp), [localeTextProp]);
67
+ const xAxis = xAxisProp?.[0];
68
+ const yAxis = yAxisProp?.[0];
69
+ const showValueTicks = yAxis?.position !== 'none';
70
+ const showCategoryLabels = xAxis?.position !== 'none';
71
+ const resolved = (0, _react.useMemo)(() => (0, _geometry.resolveLineChartData)({
72
+ dataset,
73
+ series: seriesProp,
74
+ xAxis
75
+ }), [dataset, seriesProp, xAxis]);
76
+ const formatters = (0, _react.useMemo)(() => seriesProp.map(item => (0, _format.resolveValueFormatter)(item, yAxis, locale)), [seriesProp, yAxis, locale]);
77
+ const formatTick = (0, _react.useMemo)(() => {
78
+ const format = (0, _format.resolveValueFormatter)(null, yAxis, locale);
79
+ return value => format(value, {
80
+ location: 'tick'
81
+ });
82
+ }, [yAxis, locale]);
83
+ const box = (0, _size.resolveChartBox)(size, widthProp, heightProp);
84
+ const [hostWidth, handleHostLayout] = (0, _useChartHostWidth.useChartHostWidth)(onLayout);
85
+ const viewportWidth = hostWidth > 0 ? Math.min(hostWidth, box.width) : box.width;
86
+ const viewportHeight = box.height;
87
+ const gutters = (0, _react.useMemo)(() => (0, _geometry.lineChartMarkerGutters)(dataset.length, markers, (0, _geometry.lineChartGutters)({
88
+ showValueTicks,
89
+ showCategoryLabels
90
+ })), [dataset.length, markers, showValueTicks, showCategoryLabels]);
91
+ const content = (0, _react.useMemo)(() => (0, _geometry.resolveLineChartContentSize)({
92
+ viewportWidth,
93
+ viewportHeight,
94
+ categoryCount: dataset.length,
95
+ gutters,
96
+ scrollable,
97
+ visiblePoints
98
+ }), [viewportWidth, viewportHeight, dataset.length, gutters, scrollable, visiblePoints]);
99
+ const layout = (0, _react.useMemo)(() => (0, _geometry.layoutLineChart)({
100
+ categories: resolved.categories,
101
+ series: resolved.series,
102
+ width: content.width,
103
+ height: content.height,
104
+ referenceLines,
105
+ yAxis,
106
+ formatTick,
107
+ gutters
108
+ }), [resolved, content.width, content.height, referenceLines, yAxis, formatTick, gutters]);
109
+ const markerLayout = (0, _react.useMemo)(() => (0, _geometry.layoutLineChartMarkers)(markers ?? [], layout.series), [markers, layout.series]);
110
+ const overflowsX = content.width > viewportWidth + 0.5;
111
+ const morph = (0, _motion.useChartMorph)(layout.series.flatMap(item => item.points.map(point => point.y ?? Number.NaN)), layout.series.flatMap(item => item.points.map(point => point.y === null ? Number.NaN : layout.baselineY)), animated);
112
+ const fills = seriesProp.map((item, seriesIndex) => (0, _palette.resolveChartColor)(item.color, paints) ?? paints[(0, _palette.chartSeriesColor)(seriesIndex, seriesProp.length, palette, 'line')]);
113
+ const marks = seriesProp.map(item => item.showMark ?? false);
114
+ const summary = accessibilityLabel ?? lineSummary(layout, formatters, localeText);
115
+ const interactive = onSelectedItemChange !== undefined || selectedItemProp !== undefined || defaultSelectedItem !== undefined;
116
+ const [selectedItemState, setSelectedItem] = (0, _utils.useControllableState)({
117
+ prop: selectedItemProp,
118
+ defaultProp: defaultSelectedItem ?? null,
119
+ onChange: next => {
120
+ onSelectedItemChange?.(next ?? null);
121
+ }
122
+ });
123
+ const selectedIndex = selectedItemState?.dataIndex ?? null;
124
+ const showTooltip = (tooltipProp?.trigger ?? 'axis') !== 'none';
125
+ const inspectable = (interactive || showTooltip) && dataset.length > 0;
126
+ const [activeIndex, setActiveIndex] = (0, _react.useState)(null);
127
+ const [dismissed, setDismissed] = (0, _react.useState)(false);
128
+ const [scrubbing, setScrubbing] = (0, _react.useState)(false);
129
+ const scrollX = (0, _react.useRef)(0);
130
+ const highlightIndex = activeIndex ?? selectedIndex;
131
+ const tooltipIndex = showTooltip && !dismissed && activeIndex !== null ? activeIndex : null;
132
+ const activate = index => {
133
+ setDismissed(false);
134
+ setActiveIndex(prev => prev === index ? prev : index);
135
+ };
136
+ const deactivate = index => {
137
+ setActiveIndex(prev => prev === index ? null : prev);
138
+ };
139
+ const selectIndex = index => {
140
+ if (selectedIndex === index) {
141
+ setSelectedItem(null);
142
+ return;
143
+ }
144
+ const owner = layout.series.find(item => item.points[index]?.value != null) ?? layout.series[0];
145
+ setSelectedItem(owner === undefined ? null : {
146
+ seriesId: owner.key,
147
+ dataIndex: index
148
+ });
149
+ };
150
+ const markerLegend = markerLayout.filter(item => item.legend !== undefined && item.legend.length > 0);
151
+ const showLegend = !hideLegend && (seriesProp.length > 0 || markerLegend.length > 0);
152
+ const plot = /*#__PURE__*/(0, _jsxRuntime.jsx)(LinePlot, {
153
+ layout: layout,
154
+ morph: morph,
155
+ fills: fills,
156
+ gradientId: gradientId,
157
+ chrome: chrome,
158
+ marks: marks,
159
+ showGrid: grid?.horizontal !== false,
160
+ highlightIndex: highlightIndex,
161
+ formatters: formatters,
162
+ markers: markerLayout,
163
+ paints: paints
164
+ });
165
+ const plotWidth = content.width - layout.plot.x;
166
+ const bleed = Math.min(CLIP_BLEED, layout.plot.x);
167
+ const axisWidth = layout.plot.x - bleed;
168
+ const targets = inspectable ? lineInspectorTargets({
169
+ layout,
170
+ width: plotWidth,
171
+ height: viewportHeight,
172
+ fills,
173
+ formatters,
174
+ localeText,
175
+ selectedIndex,
176
+ markers: markerLayout
177
+ }) : [];
178
+ const tip = tooltipIndex === null ? undefined : targets.at(tooltipIndex);
179
+ const ticks = showValueTicks ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
180
+ children: layout.valueTicks.map(tick => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Text, {
181
+ x: tick.x,
182
+ y: tick.y,
183
+ fill: chrome.label,
184
+ fontFamily: chrome.fontFamily,
185
+ fontSize: chrome.labelSize,
186
+ textAnchor: "end",
187
+ alignmentBaseline: "middle",
188
+ children: tick.text
189
+ }, `tick-${String(tick.value)}`))
190
+ }) : null;
191
+ const chart = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
192
+ className: "flex-row",
193
+ style: {
194
+ width: viewportWidth,
195
+ height: viewportHeight
196
+ },
197
+ ...(0, _primitives.dataAttributes)({
198
+ slot: 'line-chart-plot'
199
+ }),
200
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Svg, {
201
+ width: axisWidth,
202
+ height: viewportHeight,
203
+ viewBox: `0 0 ${String(axisWidth)} ${String(content.height)}`,
204
+ accessible: false,
205
+ accessibilityElementsHidden: true,
206
+ importantForAccessibility: "no-hide-descendants",
207
+ children: ticks
208
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
209
+ horizontal: true,
210
+ nestedScrollEnabled: true,
211
+ scrollEnabled: overflowsX && !scrubbing,
212
+ showsHorizontalScrollIndicator: overflowsX,
213
+ scrollEventThrottle: 16,
214
+ onScroll: event => {
215
+ scrollX.current = event.nativeEvent.contentOffset.x;
216
+ if (tooltipIndex !== null) {
217
+ setDismissed(true);
218
+ }
219
+ },
220
+ className: "flex-1",
221
+ style: {
222
+ height: viewportHeight
223
+ },
224
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
225
+ style: {
226
+ width: plotWidth + bleed,
227
+ height: viewportHeight
228
+ },
229
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Svg, {
230
+ width: plotWidth + bleed,
231
+ height: viewportHeight,
232
+ viewBox: `0 0 ${String(plotWidth + bleed)} ${String(content.height)}`,
233
+ pointerEvents: "none",
234
+ accessible: false,
235
+ accessibilityElementsHidden: true,
236
+ importantForAccessibility: "no-hide-descendants",
237
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.G, {
238
+ transform: `translate(${String(-axisWidth)}, 0)`,
239
+ children: plot
240
+ })
241
+ }), inspectable ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
242
+ className: "absolute top-0 bottom-0",
243
+ style: {
244
+ left: bleed,
245
+ width: plotWidth
246
+ },
247
+ pointerEvents: "box-none",
248
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(LineInspector, {
249
+ layout: layout,
250
+ targets: targets,
251
+ summary: summary,
252
+ selectable: interactive,
253
+ selectedIndex: selectedIndex,
254
+ activeIndex: activeIndex,
255
+ holdToScrub: overflowsX,
256
+ onScrubLockChange: setScrubbing,
257
+ onActivate: activate,
258
+ onDeactivate: deactivate,
259
+ onDismiss: () => {
260
+ setDismissed(true);
261
+ },
262
+ onSelectIndex: selectIndex
263
+ })
264
+ }) : null]
265
+ })
266
+ }), tip !== undefined ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartInspector.ChartTooltipLayer, {
267
+ content: tip.tooltip,
268
+ noValueText: localeText.noValue,
269
+ slot: "line-chart",
270
+ anchorX: layout.plot.x + tip.anchorX - scrollX.current,
271
+ anchorY: tip.anchorY,
272
+ anchorRadius: tip.anchorRadius,
273
+ width: viewportWidth,
274
+ height: viewportHeight
275
+ }) : null]
276
+ });
277
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
278
+ ref: ref,
279
+ className: (0, _utils.cn)((0, _styles.lineChartRootVariants)(), className),
280
+ style: style,
281
+ accessible: !inspectable && !showLegend,
282
+ accessibilityRole: !inspectable && !showLegend ? 'image' : undefined,
283
+ accessibilityLabel: !inspectable && !showLegend ? summary : undefined,
284
+ ...props,
285
+ onLayout: handleHostLayout,
286
+ ...(0, _primitives.mergeDataAttributes)(props, (0, _primitives.dataAttributes)({
287
+ slot: 'line-chart'
288
+ })),
289
+ children: [chart, showLegend ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
290
+ className: (0, _styles.lineChartLegendVariants)(),
291
+ ...(0, _primitives.dataAttributes)({
292
+ slot: 'line-chart-legend'
293
+ }),
294
+ children: [seriesProp.map((item, seriesIndex) => {
295
+ const selectedPoint = highlightIndex === null ? undefined : layout.series[seriesIndex]?.points.at(highlightIndex);
296
+ const isSelected = selectedPoint !== undefined && selectedPoint.value !== null;
297
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
298
+ className: (0, _styles.lineChartLegendItemVariants)(),
299
+ ...(0, _primitives.dataAttributes)({
300
+ slot: 'line-chart-legend-item'
301
+ }),
302
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
303
+ className: "h-0.5 w-3 rounded-full",
304
+ style: {
305
+ backgroundColor: fills[seriesIndex]
306
+ }
307
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
308
+ className: (0, _styles.lineChartLegendLabelVariants)({
309
+ selected: isSelected
310
+ }),
311
+ children: seriesLegendLabel(item, seriesProp.length, localeText)
312
+ })]
313
+ }, item.id);
314
+ }), markerLegend.map(item => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
315
+ className: (0, _styles.lineChartLegendItemVariants)(),
316
+ ...(0, _primitives.dataAttributes)({
317
+ slot: 'line-chart-legend-item'
318
+ }),
319
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
320
+ className: "size-2.5 rounded-full",
321
+ style: {
322
+ backgroundColor: (0, _palette.resolveChartColor)(item.color, paints) ?? fills[item.seriesIndex] ?? fills[0]
323
+ }
324
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
325
+ className: (0, _styles.lineChartLegendLabelVariants)(),
326
+ children: item.legend
327
+ })]
328
+ }, `legend-${item.key}`))]
329
+ }) : null]
330
+ });
331
+ }
332
+ const LineChart = exports.LineChart = /*#__PURE__*/(0, _react.forwardRef)(LineChartInner);
333
+ LineChart.displayName = 'LineChart';
334
+ function lineSummary(layout, formatters, localeText) {
335
+ const lastIndex = layout.categoryLabels.length - 1;
336
+ const last = layout.categoryLabels[lastIndex];
337
+ if (last === undefined) {
338
+ return localeText.lineChartSummary(null);
339
+ }
340
+ const latest = {
341
+ label: last.title,
342
+ values: layout.series.flatMap((item, seriesIndex) => {
343
+ const value = item.points[lastIndex]?.value;
344
+ if (value == null) {
345
+ return [];
346
+ }
347
+ const format = formatters[seriesIndex];
348
+ return [{
349
+ label: item.label,
350
+ formattedValue: format?.(value, {
351
+ location: 'a11y',
352
+ seriesId: item.key,
353
+ dataIndex: lastIndex
354
+ }) ?? ''
355
+ }];
356
+ })
357
+ };
358
+ return localeText.lineChartSummary(latest);
359
+ }
360
+ function showsMark(mark, index) {
361
+ return typeof mark === 'function' ? mark({
362
+ index
363
+ }) : mark === true;
364
+ }
365
+ function LinePlot({
366
+ layout,
367
+ morph,
368
+ fills,
369
+ gradientId,
370
+ chrome,
371
+ marks,
372
+ showGrid,
373
+ highlightIndex,
374
+ formatters,
375
+ markers,
376
+ paints
377
+ }) {
378
+ const xs = layout.categoryLabels.map(item => item.x);
379
+ const clipId = `${gradientId}-clip`;
380
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
381
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_palette.ChartLinearFills, {
382
+ idPrefix: gradientId,
383
+ colors: fills,
384
+ x2: "100%",
385
+ y2: "0%"
386
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSvg.Defs, {
387
+ children: [fills.map((color, index) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSvg.LinearGradient, {
388
+ id: `${gradientId}-area-${String(index)}`,
389
+ x1: "0%",
390
+ y1: "0%",
391
+ x2: "0%",
392
+ y2: "100%",
393
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Stop, {
394
+ offset: "0%",
395
+ stopColor: color,
396
+ stopOpacity: 0.32
397
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Stop, {
398
+ offset: "100%",
399
+ stopColor: color,
400
+ stopOpacity: 0
401
+ })]
402
+ }, `area-${String(index)}`)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.ClipPath, {
403
+ id: clipId,
404
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Rect, {
405
+ x: layout.plot.x - CLIP_BLEED,
406
+ y: layout.plot.y - CLIP_BLEED,
407
+ width: layout.plot.width + CLIP_BLEED * 2,
408
+ height: layout.plot.height + CLIP_BLEED * 2
409
+ })
410
+ })]
411
+ }), showGrid ? layout.gridLines.map(line => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Line, {
412
+ x1: line.x1,
413
+ y1: line.y1,
414
+ x2: line.x2,
415
+ y2: line.y2,
416
+ stroke: chrome.grid,
417
+ strokeWidth: 1
418
+ }, `grid-${String(line.x1)}-${String(line.y1)}`)) : null, layout.referenceLines.map((line, index) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSvg.G, {
419
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Line, {
420
+ x1: line.x1,
421
+ y1: line.y1,
422
+ x2: line.x2,
423
+ y2: line.y2,
424
+ stroke: chrome.label,
425
+ strokeWidth: 1,
426
+ strokeDasharray: DASH
427
+ }), line.label !== undefined && line.label.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Text, {
428
+ x: line.x1 + 4,
429
+ y: line.y1 - 4,
430
+ fill: chrome.label,
431
+ fontFamily: chrome.fontFamily,
432
+ fontSize: chrome.captionSize,
433
+ textAnchor: "start",
434
+ children: line.label
435
+ }) : null]
436
+ }, `ref-${String(line.y1)}-${String(index)}`)), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSvg.G, {
437
+ clipPath: `url(#${clipId})`,
438
+ children: [layout.series.map((item, seriesIndex) => /*#__PURE__*/(0, _jsxRuntime.jsx)(AnimatedSeries, {
439
+ item: item,
440
+ seriesIndex: seriesIndex,
441
+ xs: xs,
442
+ baselineY: layout.baselineY,
443
+ morph: morph,
444
+ areaFill: `url(#${gradientId}-area-${String(seriesIndex)})`,
445
+ stroke: (0, _palette.chartFillUrl)(gradientId, seriesIndex),
446
+ opacity: highlightIndex !== null ? INACTIVE_OPACITY + 0.35 : 1
447
+ }, item.key)), layout.series.flatMap((item, seriesIndex) => item.points.map(point => point.y === null || !showsMark(marks[seriesIndex], point.index) ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)(AnimatedDot, {
448
+ cx: point.x,
449
+ slot: seriesIndex * xs.length + point.index,
450
+ morph: morph,
451
+ fill: chrome.surface,
452
+ stroke: fills[seriesIndex] ?? chrome.label
453
+ }, `dot-${item.key}-${String(point.index)}`)))]
454
+ }), highlightIndex !== null ? (() => {
455
+ const label = layout.categoryLabels.at(highlightIndex);
456
+ if (label === undefined) {
457
+ return null;
458
+ }
459
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Line, {
460
+ x1: label.x,
461
+ x2: label.x,
462
+ y1: layout.plot.y,
463
+ y2: layout.plot.y + layout.plot.height,
464
+ stroke: chrome.label,
465
+ strokeWidth: 1,
466
+ strokeDasharray: "3 4"
467
+ });
468
+ })() : null, markers.map(marker => marker.guide ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Line, {
469
+ x1: marker.x,
470
+ x2: marker.x,
471
+ y1: layout.plot.y,
472
+ y2: layout.plot.y + layout.plot.height,
473
+ stroke: chrome.grid,
474
+ strokeWidth: 1,
475
+ strokeDasharray: "3 4",
476
+ opacity: highlightIndex !== null && highlightIndex !== marker.index ? INACTIVE_OPACITY : 1
477
+ }, `marker-guide-${marker.key}`) : null), highlightIndex !== null ? layout.series.flatMap((item, seriesIndex) => {
478
+ const point = item.points.at(highlightIndex);
479
+ if (point?.y == null) {
480
+ return [];
481
+ }
482
+ return [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Circle, {
483
+ cx: point.x,
484
+ cy: point.y,
485
+ r: _styles.LINE_ACTIVE_DOT_RADIUS,
486
+ fill: chrome.surface,
487
+ stroke: fills[seriesIndex],
488
+ strokeWidth: _styles.LINE_STROKE_WIDTH
489
+ }, `active-${item.key}`)];
490
+ }) : null, markers.map(marker => {
491
+ const color = (0, _palette.resolveChartColor)(marker.color, paints) ?? fills[marker.seriesIndex] ?? fills.at(0) ?? chrome.label;
492
+ const nearEnd = marker.x > layout.plot.x + layout.plot.width - EDGE_LABEL_ROOM;
493
+ const nearStart = marker.x < layout.plot.x + EDGE_LABEL_ROOM;
494
+ const captionAnchor = nearEnd ? 'end' : nearStart ? 'start' : 'middle';
495
+ const dimmed = highlightIndex !== null && highlightIndex !== marker.index;
496
+ const markerOpacity = dimmed ? INACTIVE_OPACITY : 1;
497
+ const format = formatters[marker.seriesIndex];
498
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSvg.G, {
499
+ children: [marker.dot ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Circle, {
500
+ cx: marker.x,
501
+ cy: marker.y,
502
+ r: _styles.LINE_ACTIVE_DOT_RADIUS,
503
+ fill: color,
504
+ stroke: chrome.surface,
505
+ strokeWidth: _styles.LINE_STROKE_WIDTH,
506
+ opacity: markerOpacity
507
+ }) : null, marker.label !== undefined && marker.label.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Text, {
508
+ x: marker.x,
509
+ y: marker.y - 16,
510
+ fill: chrome.label,
511
+ fontFamily: chrome.fontFamily,
512
+ fontSize: chrome.captionSize,
513
+ textAnchor: captionAnchor,
514
+ opacity: markerOpacity,
515
+ children: marker.label
516
+ }) : null, marker.showValue ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Text, {
517
+ x: nearEnd ? marker.x - 10 : marker.x + 10,
518
+ y: marker.y + 4,
519
+ fill: chrome.label,
520
+ fontFamily: chrome.fontFamily,
521
+ fontSize: chrome.captionSize,
522
+ textAnchor: nearEnd ? 'end' : 'start',
523
+ opacity: markerOpacity,
524
+ children: format?.(marker.value, {
525
+ location: 'label',
526
+ seriesId: marker.seriesId,
527
+ dataIndex: marker.index
528
+ }) ?? ''
529
+ }) : null]
530
+ }, `marker-${marker.key}`);
531
+ }), layout.categoryLabels.map((item, index) => item.tick ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Text, {
532
+ x: item.x,
533
+ y: item.y,
534
+ fill: chrome.label,
535
+ fontFamily: chrome.fontFamily,
536
+ fontSize: chrome.labelSize,
537
+ textAnchor: layout.categoryLabels.length < 2 ? 'middle' : index === 0 ? 'start' : index === layout.categoryLabels.length - 1 ? 'end' : 'middle',
538
+ alignmentBaseline: "middle",
539
+ children: item.label
540
+ }, `cat-${item.label}-${String(index)}`) : null)]
541
+ });
542
+ }
543
+ function categoryValues(layout, index, fills, formatters, location) {
544
+ return layout.series.flatMap((item, seriesIndex) => {
545
+ const point = item.points.at(index);
546
+ if (point?.value == null) {
547
+ return [];
548
+ }
549
+ const format = formatters[seriesIndex];
550
+ return [{
551
+ seriesId: item.key,
552
+ label: item.label,
553
+ color: fills[seriesIndex] ?? '',
554
+ formattedValue: format?.(point.value, {
555
+ location,
556
+ seriesId: item.key,
557
+ dataIndex: index
558
+ }) ?? ''
559
+ }];
560
+ });
561
+ }
562
+ function seriesLegendLabel(item, seriesCount, localeText) {
563
+ if (item.label !== undefined && item.label.length > 0) {
564
+ return item.label;
565
+ }
566
+ return seriesCount === 1 ? localeText.defaultSeriesLabel : item.id;
567
+ }
568
+ function categoryAnnouncement(label, values, noValue, notes = []) {
569
+ const parts = values.map(_ChartInspector.chartValueText);
570
+ const base = parts.length > 0 ? `${label}, ${parts.join(', ')}` : `${label}, ${noValue}`;
571
+ return notes.length > 0 ? `${base}, ${notes.join(', ')}` : base;
572
+ }
573
+ function markerNotes(markers, index) {
574
+ return markers.filter(marker => marker.index === index).flatMap(marker => [marker.legend, marker.label].filter(text => text !== undefined && text.length > 0));
575
+ }
576
+ function lineKeyboardNeighbor(index, key, count) {
577
+ if (key === 'Tab') {
578
+ return index + 1 < count ? index + 1 : null;
579
+ }
580
+ if (key === 'Shift+Tab') {
581
+ return index > 0 ? index - 1 : null;
582
+ }
583
+ return null;
584
+ }
585
+
586
+ /** Targets in scroll-content coordinates, which start at `layout.plot.x`. */
587
+ function lineInspectorTargets({
588
+ layout,
589
+ width,
590
+ height,
591
+ fills,
592
+ formatters,
593
+ localeText,
594
+ selectedIndex,
595
+ markers
596
+ }) {
597
+ const count = layout.categoryLabels.length;
598
+ const band = layout.plot.width / Math.max(count - 1, 1);
599
+ const offset = layout.plot.x;
600
+ return layout.categoryLabels.map((item, index) => {
601
+ const x = item.x - offset;
602
+ const left = index === 0 ? 0 : x - band / 2;
603
+ const right = index === count - 1 ? width : x + band / 2;
604
+ const pointYs = layout.series.flatMap(series => {
605
+ const y = series.points.at(index)?.y;
606
+ return y == null ? [] : [y];
607
+ });
608
+ return {
609
+ key: `hit-${String(index)}`,
610
+ left,
611
+ top: 0,
612
+ width: Math.max(right - left, 1),
613
+ height,
614
+ anchorX: x,
615
+ anchorY: pointYs.length > 0 ? Math.min(...pointYs) : layout.plot.y,
616
+ tooltip: {
617
+ title: item.title,
618
+ items: categoryValues(layout, index, fills, formatters, 'tooltip')
619
+ },
620
+ accessibilityLabel: categoryAnnouncement(item.title, categoryValues(layout, index, fills, formatters, 'a11y'), localeText.noValue, markerNotes(markers, index)),
621
+ selected: selectedIndex === index
622
+ };
623
+ });
624
+ }
625
+ function LineInspector({
626
+ layout,
627
+ targets,
628
+ summary,
629
+ selectable,
630
+ selectedIndex,
631
+ activeIndex,
632
+ onActivate,
633
+ onDeactivate,
634
+ onDismiss,
635
+ onSelectIndex,
636
+ holdToScrub,
637
+ onScrubLockChange
638
+ }) {
639
+ const count = layout.categoryLabels.length;
640
+ const offset = layout.plot.x;
641
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartInspector.ChartInspector, {
642
+ targets: targets,
643
+ summary: summary,
644
+ selectable: selectable,
645
+ activeIndex: activeIndex,
646
+ selectedIndex: selectedIndex,
647
+ slot: "line-chart",
648
+ holdToScrub: holdToScrub,
649
+ onActivate: onActivate,
650
+ onDeactivate: onDeactivate,
651
+ onDismiss: onDismiss,
652
+ onSelectIndex: onSelectIndex,
653
+ hitTest: (x, y) => (0, _geometry.nearestCategoryInPlot)(layout.categoryLabels, layout.plot, x, y, offset),
654
+ neighborIndex: (index, key) => lineKeyboardNeighbor(index, key, count),
655
+ onScrubLockChange: onScrubLockChange
656
+ });
657
+ }
658
+ function AnimatedSeries({
659
+ item,
660
+ seriesIndex,
661
+ xs,
662
+ baselineY,
663
+ morph,
664
+ areaFill,
665
+ stroke,
666
+ opacity
667
+ }) {
668
+ const {
669
+ from,
670
+ to,
671
+ progress
672
+ } = morph;
673
+ const start = seriesIndex * xs.length;
674
+ const end = start + xs.length;
675
+ const dashAt = item.dashAt;
676
+ const curve = item.curve;
677
+ const lineProps = (0, _reactNativeReanimated.useAnimatedProps)(() => {
678
+ const ys = (0, _motion.lerpVector)(from.get(), to.get(), progress.get()).slice(start, end);
679
+ return {
680
+ d: (0, _geometry.lineSeriesPaths)(xs, ys, curve, baselineY, dashAt).path
681
+ };
682
+ }, [from, to, progress, start, end, xs, curve, baselineY, dashAt]);
683
+ const dashProps = (0, _reactNativeReanimated.useAnimatedProps)(() => {
684
+ const ys = (0, _motion.lerpVector)(from.get(), to.get(), progress.get()).slice(start, end);
685
+ return {
686
+ d: (0, _geometry.lineSeriesPaths)(xs, ys, curve, baselineY, dashAt).dashedPath
687
+ };
688
+ }, [from, to, progress, start, end, xs, curve, baselineY, dashAt]);
689
+ const areaProps = (0, _reactNativeReanimated.useAnimatedProps)(() => {
690
+ const ys = (0, _motion.lerpVector)(from.get(), to.get(), progress.get()).slice(start, end);
691
+ return {
692
+ d: (0, _geometry.lineSeriesPaths)(xs, ys, curve, baselineY, dashAt).areaPath
693
+ };
694
+ }, [from, to, progress, start, end, xs, curve, baselineY, dashAt]);
695
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSvg.G, {
696
+ children: [item.area && item.areaPath.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(AnimatedPath, {
697
+ animatedProps: areaProps,
698
+ fill: areaFill
699
+ }) : null, item.path.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(AnimatedPath, {
700
+ animatedProps: lineProps,
701
+ fill: "none",
702
+ stroke: stroke,
703
+ strokeWidth: _styles.LINE_STROKE_WIDTH,
704
+ strokeLinecap: "round",
705
+ strokeLinejoin: "round",
706
+ strokeDasharray: item.dashed ? DASH : undefined,
707
+ opacity: opacity
708
+ }) : null, item.dashedPath.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(AnimatedPath, {
709
+ animatedProps: dashProps,
710
+ fill: "none",
711
+ stroke: stroke,
712
+ strokeWidth: _styles.LINE_STROKE_WIDTH,
713
+ strokeLinecap: "round",
714
+ strokeLinejoin: "round",
715
+ strokeDasharray: DASH,
716
+ opacity: opacity
717
+ }) : null]
718
+ });
719
+ }
720
+ function AnimatedDot({
721
+ cx,
722
+ slot,
723
+ morph,
724
+ fill,
725
+ stroke
726
+ }) {
727
+ const {
728
+ from,
729
+ to,
730
+ progress
731
+ } = morph;
732
+ const animatedProps = (0, _reactNativeReanimated.useAnimatedProps)(() => {
733
+ const ys = (0, _motion.lerpVector)(from.get(), to.get(), progress.get());
734
+ return {
735
+ cy: ys[slot] ?? 0
736
+ };
737
+ }, [from, to, progress, slot]);
738
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(AnimatedCircle, {
739
+ animatedProps: animatedProps,
740
+ cx: cx,
741
+ r: _styles.LINE_DOT_RADIUS,
742
+ fill: fill,
743
+ stroke: stroke,
744
+ strokeWidth: _styles.LINE_STROKE_WIDTH
745
+ });
746
+ }
747
+ //# sourceMappingURL=index.js.map