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