solid-recharts 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (639) hide show
  1. package/NEXT_SESSION_PROMPT.md +114 -0
  2. package/package.json +28 -0
  3. package/src/animation/AnimatedItems.tsx +169 -0
  4. package/src/animation/AnimationController.ts +24 -0
  5. package/src/animation/AnimationControllerImpl.ts +37 -0
  6. package/src/animation/AnimationHandle.ts +273 -0
  7. package/src/animation/CSSTransitionAnimate.tsx +142 -0
  8. package/src/animation/JavascriptAnimate.tsx +107 -0
  9. package/src/animation/easing.ts +261 -0
  10. package/src/animation/matchBy.ts +211 -0
  11. package/src/animation/timeoutController.ts +51 -0
  12. package/src/animation/useAnimationController.tsx +31 -0
  13. package/src/animation/useAnimationStartSnapshot.ts +73 -0
  14. package/src/animation/util.ts +16 -0
  15. package/src/cartesian/Area.tsx +810 -0
  16. package/src/cartesian/AreaRevealShape.tsx +250 -0
  17. package/src/cartesian/Bar.tsx +1216 -0
  18. package/src/cartesian/BarStack.tsx +148 -0
  19. package/src/cartesian/Brush.tsx +653 -0
  20. package/src/cartesian/CartesianAxis.tsx +541 -0
  21. package/src/cartesian/CartesianGrid.tsx +605 -0
  22. package/src/cartesian/ErrorBar.tsx +319 -0
  23. package/src/cartesian/Funnel.tsx +594 -0
  24. package/src/cartesian/GraphicalItemClipPath.tsx +75 -0
  25. package/src/cartesian/Line.tsx +742 -0
  26. package/src/cartesian/LineDrawShape.tsx +190 -0
  27. package/src/cartesian/ReferenceArea.tsx +275 -0
  28. package/src/cartesian/ReferenceDot.tsx +286 -0
  29. package/src/cartesian/ReferenceLine.tsx +414 -0
  30. package/src/cartesian/RenderedTicksReporter.tsx +49 -0
  31. package/src/cartesian/Scatter.tsx +741 -0
  32. package/src/cartesian/XAxis.tsx +293 -0
  33. package/src/cartesian/YAxis.tsx +333 -0
  34. package/src/cartesian/ZAxis.tsx +80 -0
  35. package/src/cartesian/getCartesianPosition.ts +255 -0
  36. package/src/cartesian/getEquidistantTicks.ts +126 -0
  37. package/src/cartesian/getTicks.ts +225 -0
  38. package/src/cartesian/useAnimatedLineLength.ts +84 -0
  39. package/src/chart/AreaChart.tsx +30 -0
  40. package/src/chart/BarChart.tsx +27 -0
  41. package/src/chart/CartesianChart.tsx +91 -0
  42. package/src/chart/CategoricalChart.tsx +60 -0
  43. package/src/chart/ComposedChart.tsx +29 -0
  44. package/src/chart/FunnelChart.tsx +29 -0
  45. package/src/chart/LineChart.tsx +29 -0
  46. package/src/chart/PieChart.tsx +41 -0
  47. package/src/chart/PolarChart.tsx +97 -0
  48. package/src/chart/RadarChart.tsx +37 -0
  49. package/src/chart/RadialBarChart.tsx +39 -0
  50. package/src/chart/RechartsWrapper.tsx +486 -0
  51. package/src/chart/Sankey.tsx +992 -0
  52. package/src/chart/ScatterChart.tsx +29 -0
  53. package/src/chart/SunburstChart.tsx +394 -0
  54. package/src/chart/Treemap.tsx +874 -0
  55. package/src/chart/types.ts +37 -0
  56. package/src/component/ActivePoints.tsx +136 -0
  57. package/src/component/Cell.tsx +72 -0
  58. package/src/component/Cursor.tsx +249 -0
  59. package/src/component/Customized.tsx +8 -0
  60. package/src/component/DefaultLegendContent.tsx +205 -0
  61. package/src/component/DefaultTooltipContent.tsx +247 -0
  62. package/src/component/Dots.tsx +128 -0
  63. package/src/component/Label.tsx +507 -0
  64. package/src/component/LabelList.tsx +270 -0
  65. package/src/component/Legend.tsx +273 -0
  66. package/src/component/ResponsiveContainer.tsx +397 -0
  67. package/src/component/Text.tsx +436 -0
  68. package/src/component/Tooltip.tsx +309 -0
  69. package/src/component/TooltipBoundingBox.tsx +152 -0
  70. package/src/component/responsiveContainerUtils.ts +128 -0
  71. package/src/container/ClipPathProvider.tsx +40 -0
  72. package/src/container/Layer.tsx +38 -0
  73. package/src/container/RootSurface.tsx +124 -0
  74. package/src/container/Surface.tsx +70 -0
  75. package/src/context/ErrorBarContext.tsx +85 -0
  76. package/src/context/PanoramaContext.tsx +13 -0
  77. package/src/context/RegisterGraphicalItemId.tsx +41 -0
  78. package/src/context/accessibilityContext.tsx +10 -0
  79. package/src/context/brushUpdateContext.ts +14 -0
  80. package/src/context/chartDataContext.tsx +79 -0
  81. package/src/context/chartLayoutContext.tsx +158 -0
  82. package/src/context/legendPayloadContext.ts +11 -0
  83. package/src/context/legendPortalContext.ts +11 -0
  84. package/src/context/tooltipContext.ts +72 -0
  85. package/src/context/tooltipPortalContext.ts +14 -0
  86. package/src/context/useTooltipAxis.ts +24 -0
  87. package/src/hooks.ts +312 -0
  88. package/src/index.ts +288 -0
  89. package/src/polar/Pie.tsx +912 -0
  90. package/src/polar/PolarAngleAxis.tsx +494 -0
  91. package/src/polar/PolarGrid.tsx +269 -0
  92. package/src/polar/PolarRadiusAxis.tsx +422 -0
  93. package/src/polar/Radar.tsx +652 -0
  94. package/src/polar/RadialBar.tsx +767 -0
  95. package/src/polar/defaultPolarAngleAxisProps.tsx +33 -0
  96. package/src/polar/defaultPolarRadiusAxisProps.tsx +28 -0
  97. package/src/shape/Cross.tsx +83 -0
  98. package/src/shape/Curve.tsx +335 -0
  99. package/src/shape/Dot.tsx +49 -0
  100. package/src/shape/Polygon.tsx +168 -0
  101. package/src/shape/Rectangle.tsx +301 -0
  102. package/src/shape/Sector.tsx +304 -0
  103. package/src/shape/Symbols.tsx +144 -0
  104. package/src/shape/Trapezoid.tsx +228 -0
  105. package/src/state/RechartsReduxContext.tsx +8 -0
  106. package/src/state/RechartsStoreContext.ts +15 -0
  107. package/src/state/RechartsStoreProvider.tsx +27 -0
  108. package/src/state/ReportChartProps.tsx +19 -0
  109. package/src/state/ReportEventSettings.tsx +19 -0
  110. package/src/state/ReportMainChartProps.tsx +35 -0
  111. package/src/state/ReportPolarOptions.tsx +28 -0
  112. package/src/state/SetLegendPayload.ts +50 -0
  113. package/src/state/SetTooltipEntrySettings.tsx +46 -0
  114. package/src/state/brushSlice.ts +60 -0
  115. package/src/state/cartesianAxisSlice.ts +288 -0
  116. package/src/state/chartDataSlice.ts +115 -0
  117. package/src/state/errorBarSlice.ts +84 -0
  118. package/src/state/eventSettingsSlice.ts +41 -0
  119. package/src/state/externalEventsMiddleware.ts +136 -0
  120. package/src/state/graphicalItemsSlice.ts +162 -0
  121. package/src/state/hooks.ts +42 -0
  122. package/src/state/keyboardEventsMiddleware.ts +213 -0
  123. package/src/state/layoutSlice.ts +71 -0
  124. package/src/state/legendSlice.ts +107 -0
  125. package/src/state/mouseEventsMiddleware.ts +103 -0
  126. package/src/state/optionsSlice.ts +64 -0
  127. package/src/state/polarAxisSlice.ts +65 -0
  128. package/src/state/polarOptionsSlice.ts +54 -0
  129. package/src/state/reduxDevtoolsJsonStringifyReplacer.ts +15 -0
  130. package/src/state/referenceElementsSlice.ts +121 -0
  131. package/src/state/renderedTicksSlice.ts +61 -0
  132. package/src/state/rootPropsSlice.ts +70 -0
  133. package/src/state/selectors/areaSelectors.ts +169 -0
  134. package/src/state/selectors/arrayEqualityCheck.ts +8 -0
  135. package/src/state/selectors/axisSelectors.ts +2196 -0
  136. package/src/state/selectors/barSelectors.ts +319 -0
  137. package/src/state/selectors/barStackSelectors.ts +79 -0
  138. package/src/state/selectors/brushSelectors.ts +40 -0
  139. package/src/state/selectors/combiners/combineActiveLabel.ts +21 -0
  140. package/src/state/selectors/combiners/combineActiveTooltipIndex.ts +93 -0
  141. package/src/state/selectors/combiners/combineAllBarPositions.ts +131 -0
  142. package/src/state/selectors/combiners/combineAxisRangeWithReverse.ts +17 -0
  143. package/src/state/selectors/combiners/combineBarPosition.ts +24 -0
  144. package/src/state/selectors/combiners/combineBarSizeList.ts +75 -0
  145. package/src/state/selectors/combiners/combineCheckedDomain.ts +49 -0
  146. package/src/state/selectors/combiners/combineConfiguredScale.ts +121 -0
  147. package/src/state/selectors/combiners/combineCoordinateForDefaultIndex.ts +43 -0
  148. package/src/state/selectors/combiners/combineDisplayedStackedData.ts +50 -0
  149. package/src/state/selectors/combiners/combineInverseScaleFunction.ts +17 -0
  150. package/src/state/selectors/combiners/combineRealScaleType.ts +48 -0
  151. package/src/state/selectors/combiners/combineStackedData.ts +28 -0
  152. package/src/state/selectors/combiners/combineTooltipInteractionState.ts +86 -0
  153. package/src/state/selectors/combiners/combineTooltipPayload.ts +203 -0
  154. package/src/state/selectors/combiners/combineTooltipPayloadConfigurations.ts +45 -0
  155. package/src/state/selectors/containerSelectors.ts +12 -0
  156. package/src/state/selectors/dataSelectors.ts +90 -0
  157. package/src/state/selectors/funnelSelectors.ts +83 -0
  158. package/src/state/selectors/graphicalItemSelectors.ts +23 -0
  159. package/src/state/selectors/legendSelectors.ts +29 -0
  160. package/src/state/selectors/lineSelectors.ts +111 -0
  161. package/src/state/selectors/numberDomainEqualityCheck.ts +8 -0
  162. package/src/state/selectors/pickAxisId.ts +6 -0
  163. package/src/state/selectors/pickAxisType.ts +4 -0
  164. package/src/state/selectors/pieSelectors.ts +103 -0
  165. package/src/state/selectors/polarAxisSelectors.ts +202 -0
  166. package/src/state/selectors/polarGridSelectors.ts +24 -0
  167. package/src/state/selectors/polarScaleSelectors.ts +149 -0
  168. package/src/state/selectors/polarSelectors.ts +211 -0
  169. package/src/state/selectors/radarSelectors.ts +152 -0
  170. package/src/state/selectors/radialBarSelectors.ts +328 -0
  171. package/src/state/selectors/rootPropsSelectors.ts +36 -0
  172. package/src/state/selectors/scatterSelectors.ts +77 -0
  173. package/src/state/selectors/selectAllAxes.ts +10 -0
  174. package/src/state/selectors/selectChartOffset.ts +15 -0
  175. package/src/state/selectors/selectChartOffsetInternal.ts +111 -0
  176. package/src/state/selectors/selectPlotArea.ts +27 -0
  177. package/src/state/selectors/selectTooltipAxisId.ts +6 -0
  178. package/src/state/selectors/selectTooltipAxisType.ts +33 -0
  179. package/src/state/selectors/selectTooltipEventType.ts +45 -0
  180. package/src/state/selectors/selectTooltipPayloadSearcher.ts +7 -0
  181. package/src/state/selectors/selectTooltipSettings.ts +6 -0
  182. package/src/state/selectors/selectTooltipState.ts +5 -0
  183. package/src/state/selectors/tooltipSelectors.ts +690 -0
  184. package/src/state/selectors/touchSelectors.ts +29 -0
  185. package/src/state/store.ts +167 -0
  186. package/src/state/tooltipSlice.ts +289 -0
  187. package/src/state/types/AreaSettings.ts +17 -0
  188. package/src/state/types/BarSettings.ts +16 -0
  189. package/src/state/types/LineSettings.ts +12 -0
  190. package/src/state/types/PieSettings.ts +32 -0
  191. package/src/state/types/RadarSettings.ts +6 -0
  192. package/src/state/types/RadialBarSettings.ts +10 -0
  193. package/src/state/types/ScatterSettings.ts +13 -0
  194. package/src/state/types/StackedGraphicalItem.ts +33 -0
  195. package/src/state/unregisterOnCleanup.ts +26 -0
  196. package/src/state/zIndexSlice.ts +128 -0
  197. package/src/synchronisation/syncRegistry.ts +131 -0
  198. package/src/synchronisation/syncSelectors.ts +7 -0
  199. package/src/synchronisation/types.ts +42 -0
  200. package/src/synchronisation/useChartSynchronisation.tsx +372 -0
  201. package/src/types.ts +39 -0
  202. package/src/util/ActiveShapeUtils.tsx +80 -0
  203. package/src/util/BarUtils.tsx +74 -0
  204. package/src/util/CartesianUtils.ts +53 -0
  205. package/src/util/ChartUtils.ts +696 -0
  206. package/src/util/Constants.ts +42 -0
  207. package/src/util/CssPrefixUtils.ts +24 -0
  208. package/src/util/DOMUtils.ts +141 -0
  209. package/src/util/DataUtils.ts +205 -0
  210. package/src/util/FunnelUtils.tsx +37 -0
  211. package/src/util/Global.ts +15 -0
  212. package/src/util/IfOverflow.ts +17 -0
  213. package/src/util/LRUCache.ts +46 -0
  214. package/src/util/LogUtils.ts +26 -0
  215. package/src/util/PolarUtils.ts +134 -0
  216. package/src/util/RadialBarUtils.tsx +35 -0
  217. package/src/util/ReduceCSSCalc.ts +186 -0
  218. package/src/util/ShallowEqual.ts +43 -0
  219. package/src/util/TickUtils.ts +61 -0
  220. package/src/util/YAxisUtils.ts +49 -0
  221. package/src/util/adaptEventHandlers.ts +69 -0
  222. package/src/util/axisPropsAreEqual.ts +42 -0
  223. package/src/util/collectionUtils.ts +83 -0
  224. package/src/util/createCartesianCharts.tsx +101 -0
  225. package/src/util/createEventProxy.ts +24 -0
  226. package/src/util/createPolarCharts.tsx +86 -0
  227. package/src/util/cursor/getCursorPoints.ts +48 -0
  228. package/src/util/cursor/getCursorRectangle.ts +31 -0
  229. package/src/util/cursor/getRadialCursorPoints.ts +34 -0
  230. package/src/util/excludeEventProps.ts +172 -0
  231. package/src/util/getActiveCoordinate.ts +205 -0
  232. package/src/util/getAxisTypeBasedOnLayout.ts +21 -0
  233. package/src/util/getEveryNth.ts +30 -0
  234. package/src/util/getRadiusAndStrokeWidthFromDot.ts +35 -0
  235. package/src/util/getRelativeCoordinate.ts +84 -0
  236. package/src/util/getSliced.ts +21 -0
  237. package/src/util/isDomainSpecifiedByUser.ts +217 -0
  238. package/src/util/isWellBehavedNumber.ts +10 -0
  239. package/src/util/objectPath.ts +129 -0
  240. package/src/util/payload/getUniqPayload.ts +31 -0
  241. package/src/util/propsAreEqual.ts +137 -0
  242. package/src/util/resolveDefaultProps.tsx +8 -0
  243. package/src/util/round.ts +35 -0
  244. package/src/util/scale/CartesianScaleHelper.ts +72 -0
  245. package/src/util/scale/CustomScaleDefinition.ts +82 -0
  246. package/src/util/scale/RechartsScale.ts +131 -0
  247. package/src/util/scale/createCategoricalInverse.ts +83 -0
  248. package/src/util/scale/getNiceTickValues.ts +334 -0
  249. package/src/util/scale/index.ts +3 -0
  250. package/src/util/scale/util/DecimalLite.ts +194 -0
  251. package/src/util/scale/util/arithmetic.ts +56 -0
  252. package/src/util/stacks/getStackSeriesIdentifier.ts +20 -0
  253. package/src/util/stacks/stackTypes.ts +53 -0
  254. package/src/util/svgPropertiesAndEvents.ts +84 -0
  255. package/src/util/svgPropertiesNoEvents.ts +520 -0
  256. package/src/util/tooltip/translate.ts +179 -0
  257. package/src/util/typedDataKey.ts +8 -0
  258. package/src/util/types.ts +724 -0
  259. package/src/util/useAnimationId.tsx +31 -0
  260. package/src/util/useElementOffset.ts +164 -0
  261. package/src/util/useId.ts +20 -0
  262. package/src/util/usePrefersReducedMotion.ts +44 -0
  263. package/src/util/useUniqueId.ts +34 -0
  264. package/src/zIndex/DefaultZIndexes.tsx +87 -0
  265. package/src/zIndex/ZIndexLayer.tsx +126 -0
  266. package/src/zIndex/ZIndexPortal.tsx +69 -0
  267. package/src/zIndex/getZIndexFromUnknown.tsx +17 -0
  268. package/src/zIndex/zIndexSelectors.ts +46 -0
  269. package/test/_data.ts +408 -0
  270. package/test/animation/AnimationController.typed.spec.ts +53 -0
  271. package/test/animation/AnimationControllerImpl.spec.ts +271 -0
  272. package/test/animation/CSSTransitionAnimate.timing.spec.tsx +473 -0
  273. package/test/animation/JavascriptAnimate.spec.tsx +62 -0
  274. package/test/animation/RechartsAnimation.spec.ts +636 -0
  275. package/test/animation/easing.spec.ts +218 -0
  276. package/test/animation/legacyAnimationLengthChange.spec.tsx +803 -0
  277. package/test/animation/matchBy.spec.ts +467 -0
  278. package/test/animation/mockAnimationController.ts +40 -0
  279. package/test/animation/mockControllerAnimationManager.ts +143 -0
  280. package/test/animation/mockTimeoutController.ts +114 -0
  281. package/test/animation/timeoutController.spec.ts +138 -0
  282. package/test/animation/useAnimationStartSnapshot.spec.ts +147 -0
  283. package/test/animation/util.spec.ts +28 -0
  284. package/test/cartesian/Area.animation.spec.tsx +363 -0
  285. package/test/cartesian/Area.range.spec.tsx +54 -0
  286. package/test/cartesian/Area.spec.tsx +1202 -0
  287. package/test/cartesian/Area.stacked.render.spec.tsx +69 -0
  288. package/test/cartesian/Area.typed.spec.tsx +209 -0
  289. package/test/cartesian/Axis.integration.spec.tsx +158 -0
  290. package/test/cartesian/Bar/Bar.csstransition.spec.tsx +299 -0
  291. package/test/cartesian/Bar/Bar.spec.tsx +2314 -0
  292. package/test/cartesian/Bar/Bar.typed.spec.tsx +192 -0
  293. package/test/cartesian/Bar.animation.spec.tsx +426 -0
  294. package/test/cartesian/Bar.stackDomain.spec.tsx +66 -0
  295. package/test/cartesian/Bar.stacked.render.spec.tsx +53 -0
  296. package/test/cartesian/Bar.truncateByDomain.spec.tsx +237 -0
  297. package/test/cartesian/Bar.zeroDimensionFiltering.spec.tsx +336 -0
  298. package/test/cartesian/BarStack.spec.tsx +91 -0
  299. package/test/cartesian/Brush.keyboard.spec.tsx +88 -0
  300. package/test/cartesian/Brush.panorama.spec.tsx +41 -0
  301. package/test/cartesian/Brush.props.spec.tsx +63 -0
  302. package/test/cartesian/Brush.render.spec.tsx +117 -0
  303. package/test/cartesian/Brush.spec.tsx +522 -0
  304. package/test/cartesian/Brush.stacked.spec.tsx +221 -0
  305. package/test/cartesian/CartesianAxis.render.spec.tsx +50 -0
  306. package/test/cartesian/CartesianAxis.spec.tsx +396 -0
  307. package/test/cartesian/CartesianGrid.render.spec.tsx +39 -0
  308. package/test/cartesian/CartesianGrid.spec.tsx +2103 -0
  309. package/test/cartesian/ErrorBar.render.spec.tsx +69 -0
  310. package/test/cartesian/ErrorBar.spec.tsx +2414 -0
  311. package/test/cartesian/Funnel.animation.spec.tsx +241 -0
  312. package/test/cartesian/Funnel.spec.tsx +226 -0
  313. package/test/cartesian/Funnel.typed.spec.tsx +221 -0
  314. package/test/cartesian/GraphicalItemClipPath.scale-behavior.spec.tsx +627 -0
  315. package/test/cartesian/GraphicalItemClipPath.spec.tsx +427 -0
  316. package/test/cartesian/Line.animation.spec.tsx +643 -0
  317. package/test/cartesian/Line.sparseAnimationPath.spec.tsx +98 -0
  318. package/test/cartesian/Line.spec.tsx +471 -0
  319. package/test/cartesian/Line.typed.spec.tsx +152 -0
  320. package/test/cartesian/ReferenceArea.render.spec.tsx +63 -0
  321. package/test/cartesian/ReferenceArea.spec.tsx +663 -0
  322. package/test/cartesian/ReferenceArea.typed.spec.tsx +74 -0
  323. package/test/cartesian/ReferenceDot.render.spec.tsx +55 -0
  324. package/test/cartesian/ReferenceDot.spec.tsx +462 -0
  325. package/test/cartesian/ReferenceDot.typed.spec.tsx +76 -0
  326. package/test/cartesian/ReferenceLine/ReferenceLine.panorama.spec.tsx +184 -0
  327. package/test/cartesian/ReferenceLine/ReferenceLine.spec.tsx +744 -0
  328. package/test/cartesian/ReferenceLine/ReferenceLine.typed.spec.tsx +74 -0
  329. package/test/cartesian/ReferenceLine/getEndPoints.spec.ts +399 -0
  330. package/test/cartesian/ReferenceLine.render.spec.tsx +134 -0
  331. package/test/cartesian/Scatter.animation.spec.tsx +381 -0
  332. package/test/cartesian/Scatter.render.spec.tsx +61 -0
  333. package/test/cartesian/Scatter.spec.tsx +406 -0
  334. package/test/cartesian/Scatter.typed.spec.tsx +153 -0
  335. package/test/cartesian/XAxis/XAxis.barSize.spec.tsx +336 -0
  336. package/test/cartesian/XAxis/XAxis.brush.spec.tsx +266 -0
  337. package/test/cartesian/XAxis/XAxis.categorydomain.spec.tsx +872 -0
  338. package/test/cartesian/XAxis/XAxis.dataKey.spec.tsx +86 -0
  339. package/test/cartesian/XAxis/XAxis.datatypes.spec.tsx +127 -0
  340. package/test/cartesian/XAxis/XAxis.hide.spec.tsx +106 -0
  341. package/test/cartesian/XAxis/XAxis.multiaxis.spec.tsx +336 -0
  342. package/test/cartesian/XAxis/XAxis.numberdomain.spec.tsx +1466 -0
  343. package/test/cartesian/XAxis/XAxis.padding.spec.tsx +758 -0
  344. package/test/cartesian/XAxis/XAxis.padding_clip.spec.tsx +65 -0
  345. package/test/cartesian/XAxis/XAxis.state.spec.tsx +355 -0
  346. package/test/cartesian/XAxis/XAxis.tick.spec.tsx +493 -0
  347. package/test/cartesian/XAxis/XAxis.timescale.spec.tsx +233 -0
  348. package/test/cartesian/XAxis/XAxis.type.spec.tsx +107 -0
  349. package/test/cartesian/XAxis/XAxis.typed.spec.tsx +102 -0
  350. package/test/cartesian/XAxis/XAxis.vertical.spec.tsx +265 -0
  351. package/test/cartesian/XAxis.tickFormatter.spec.tsx +54 -0
  352. package/test/cartesian/YAxis/YAxis.7362.derivedDomain.spec.tsx +230 -0
  353. package/test/cartesian/YAxis/YAxis.7362.spec.tsx +104 -0
  354. package/test/cartesian/YAxis/YAxis.interval-zero.spec.tsx +88 -0
  355. package/test/cartesian/YAxis/YAxis.label.spec.tsx +219 -0
  356. package/test/cartesian/YAxis/YAxis.spec.tsx +1595 -0
  357. package/test/cartesian/YAxis/YAxis.tick.spec.tsx +428 -0
  358. package/test/cartesian/YAxis/YAxis.tickFormatter.spec.tsx +54 -0
  359. package/test/cartesian/YAxis/YAxis.ticks.spec.tsx +263 -0
  360. package/test/cartesian/YAxis/YAxis.type.spec.tsx +107 -0
  361. package/test/cartesian/YAxis/YAxis.typed.spec.tsx +102 -0
  362. package/test/cartesian/ZAxis.spec.tsx +300 -0
  363. package/test/cartesian/ZAxis.typed.spec.tsx +33 -0
  364. package/test/cartesian/__snapshots__/Brush.spec.tsx.snap +5 -0
  365. package/test/cartesian/axisLineAndStroke.spec.tsx +72 -0
  366. package/test/cartesian/getCartesianPosition.spec.ts +907 -0
  367. package/test/cartesian/getEquidistantTicks.spec.ts +88 -0
  368. package/test/cartesian/getTicks.spec.ts +378 -0
  369. package/test/cartesian/miscFeatureGaps.spec.tsx +89 -0
  370. package/test/cartesian/useAnimatedLineLength.spec.ts +168 -0
  371. package/test/chart/AccessibilityLayer.spec.tsx +569 -0
  372. package/test/chart/AccessibilityScans.spec.tsx +286 -0
  373. package/test/chart/AreaChart.spec.tsx +409 -0
  374. package/test/chart/AreaChart.stacked.spec.tsx +1407 -0
  375. package/test/chart/AreaChart.typed.spec.tsx +39 -0
  376. package/test/chart/BarChart.spec.tsx +3719 -0
  377. package/test/chart/BarChart.typed.spec.tsx +60 -0
  378. package/test/chart/CategoricalChart.spec.tsx +255 -0
  379. package/test/chart/ComposedChart.spec.tsx +199 -0
  380. package/test/chart/ComposedChart.typed.spec.tsx +39 -0
  381. package/test/chart/FunnelChart.spec.tsx +215 -0
  382. package/test/chart/FunnelChart.typed.spec.tsx +39 -0
  383. package/test/chart/LineChart.multiseries.spec.tsx +50 -0
  384. package/test/chart/LineChart.smoke.spec.tsx +50 -0
  385. package/test/chart/LineChart.spec.tsx +930 -0
  386. package/test/chart/LineChart.typed.spec.tsx +39 -0
  387. package/test/chart/NicheChartTooltip.spec.tsx +81 -0
  388. package/test/chart/PieChart.spec.tsx +793 -0
  389. package/test/chart/PieChart.typed.spec.tsx +39 -0
  390. package/test/chart/RadarChart.spec.tsx +530 -0
  391. package/test/chart/RadarChart.typed.spec.tsx +39 -0
  392. package/test/chart/RadialBarChart.5966.spec.tsx +48 -0
  393. package/test/chart/RadialBarChart.spec.tsx +679 -0
  394. package/test/chart/RadialBarChart.typed.spec.tsx +39 -0
  395. package/test/chart/RechartsWrapper.spec.tsx +83 -0
  396. package/test/chart/Sankey.content.spec.tsx +46 -0
  397. package/test/chart/Sankey.spec.tsx +952 -0
  398. package/test/chart/Sankey.typed.spec.tsx +29 -0
  399. package/test/chart/ScatterChart.spec.tsx +2613 -0
  400. package/test/chart/ScatterChart.typed.spec.tsx +39 -0
  401. package/test/chart/SunburstChart.spec.tsx +146 -0
  402. package/test/chart/Treemap.animation.spec.tsx +52 -0
  403. package/test/chart/Treemap.spec.tsx +1003 -0
  404. package/test/chart/Treemap.typed.spec.tsx +26 -0
  405. package/test/chart/chartEvents.spec.tsx +127 -0
  406. package/test/chart/responsive.spec.tsx +620 -0
  407. package/test/component/Cell.render.spec.tsx +155 -0
  408. package/test/component/Cell.spec.tsx +12 -0
  409. package/test/component/Cursor.spec.tsx +186 -0
  410. package/test/component/DefaultTooltipContent.spec.tsx +102 -0
  411. package/test/component/Label.render.spec.tsx +63 -0
  412. package/test/component/Label.spec.tsx +686 -0
  413. package/test/component/Label.typed.spec.tsx +46 -0
  414. package/test/component/LabelList.spec.tsx +188 -0
  415. package/test/component/Legend.itemSorter.spec.tsx +704 -0
  416. package/test/component/Legend.render.spec.tsx +92 -0
  417. package/test/component/Legend.spec.tsx +2213 -0
  418. package/test/component/Legend.typed.spec.tsx +22 -0
  419. package/test/component/ResponsiveContainer.spec.tsx +523 -0
  420. package/test/component/ResponsiveContainerDataTest.spec.tsx +51 -0
  421. package/test/component/Text.spec.tsx +415 -0
  422. package/test/component/Text.typed.spec.tsx +46 -0
  423. package/test/component/Tooltip/ActiveDot.spec.tsx +370 -0
  424. package/test/component/Tooltip/Tooltip.animation.spec.tsx +209 -0
  425. package/test/component/Tooltip/Tooltip.content.spec.tsx +128 -0
  426. package/test/component/Tooltip/Tooltip.formatter.spec.tsx +152 -0
  427. package/test/component/Tooltip/Tooltip.includeHidden.spec.tsx +79 -0
  428. package/test/component/Tooltip/Tooltip.multipleDataArrays.spec.tsx +165 -0
  429. package/test/component/Tooltip/Tooltip.offset.spec.tsx +113 -0
  430. package/test/component/Tooltip/Tooltip.state.spec.tsx +74 -0
  431. package/test/component/Tooltip/Tooltip.sync.spec.tsx +639 -0
  432. package/test/component/Tooltip/defaultIndex.spec.tsx +227 -0
  433. package/test/component/Tooltip/graphicalItem.formatter.spec.tsx +138 -0
  434. package/test/component/Tooltip/itemSorter.spec.tsx +2815 -0
  435. package/test/component/Tooltip/tooltipEventType.spec.tsx +344 -0
  436. package/test/component/Tooltip/tooltipMouseHoverSelectors.ts +41 -0
  437. package/test/component/Tooltip/tooltipTestHelpers.tsx +162 -0
  438. package/test/component/Tooltip.defaultIndex.spec.tsx +48 -0
  439. package/test/component/Tooltip.hover.spec.tsx +61 -0
  440. package/test/component/Tooltip.item.spec.tsx +54 -0
  441. package/test/component/Tooltip.keyboard.spec.tsx +51 -0
  442. package/test/component/Tooltip.payload.spec.tsx +1716 -0
  443. package/test/component/Tooltip.touch.spec.tsx +39 -0
  444. package/test/component/Tooltip.visibility.spec.tsx +1889 -0
  445. package/test/component/TooltipBoundingBox.spec.tsx +89 -0
  446. package/test/component/responsiveContainerUtils.spec.ts +205 -0
  447. package/test/container/ClipPath.spec.tsx +602 -0
  448. package/test/container/chartDimensions.spec.tsx +368 -0
  449. package/test/context/chartLayoutContext.spec.tsx +378 -0
  450. package/test/helper/ExpectAxisDomain.tsx +27 -0
  451. package/test/helper/assertNotNull.ts +6 -0
  452. package/test/helper/assertZIndexLayerOrder.ts +19 -0
  453. package/test/helper/createSelectorTestCase.tsx +176 -0
  454. package/test/helper/expectAnimatedPieAngles.ts +100 -0
  455. package/test/helper/expectAnimatedPiePaths.ts +78 -0
  456. package/test/helper/expectAreaCurve.ts +15 -0
  457. package/test/helper/expectAxisTicks.ts +48 -0
  458. package/test/helper/expectBars.ts +54 -0
  459. package/test/helper/expectFunctionReturning.ts +58 -0
  460. package/test/helper/expectLabel.ts +32 -0
  461. package/test/helper/expectLastCalledWith.ts +48 -0
  462. package/test/helper/expectLine.ts +20 -0
  463. package/test/helper/expectPieSectors.ts +80 -0
  464. package/test/helper/expectScale.ts +37 -0
  465. package/test/helper/expectScatterPoints.ts +52 -0
  466. package/test/helper/expectStackGroups.ts +144 -0
  467. package/test/helper/mockAxes.ts +22 -0
  468. package/test/helper/mockGetBoundingClientRect.ts +66 -0
  469. package/test/helper/mockHTMLElementProperty.ts +19 -0
  470. package/test/helper/mockTouchingElement.ts +27 -0
  471. package/test/helper/offsetHelpers.ts +19 -0
  472. package/test/helper/parameterizedTestCases.tsx +99 -0
  473. package/test/helper/produceState.ts +32 -0
  474. package/test/helper/render.ts +7 -0
  475. package/test/helper/selectorTestHelpers.tsx +63 -0
  476. package/test/helper/trim.spec.ts +35 -0
  477. package/test/helper/trim.ts +11 -0
  478. package/test/hooks/useActiveTooltipDataPoints.spec.tsx +358 -0
  479. package/test/hooks/useAxisDomain.spec.tsx +361 -0
  480. package/test/hooks/useAxisScale.spec.tsx +283 -0
  481. package/test/hooks/useAxisTicks.spec.tsx +130 -0
  482. package/test/hooks/useOffset.spec.tsx +248 -0
  483. package/test/hooks/useTooltipStateHooks.spec.tsx +109 -0
  484. package/test/polar/Pie/Pie-TwoLevelPieChart.spec.tsx +135 -0
  485. package/test/polar/Pie/Pie.spec.tsx +784 -0
  486. package/test/polar/Pie/Pie.typed.spec.tsx +78 -0
  487. package/test/polar/Pie.animation.spec.tsx +529 -0
  488. package/test/polar/PieWithLegend.animation.spec.tsx +142 -0
  489. package/test/polar/PolarAngleAxis/PolarAngleAxis.events.spec.tsx +76 -0
  490. package/test/polar/PolarAngleAxis/PolarAngleAxis.spec.tsx +2079 -0
  491. package/test/polar/PolarAngleAxis/PolarAngleAxis.typed.spec.tsx +102 -0
  492. package/test/polar/PolarAngleAxis.render.spec.tsx +79 -0
  493. package/test/polar/PolarGrid.render.spec.tsx +75 -0
  494. package/test/polar/PolarGrid.spec.tsx +918 -0
  495. package/test/polar/PolarLegendPerRow.render.spec.tsx +85 -0
  496. package/test/polar/PolarRadiusAxis.events.spec.tsx +65 -0
  497. package/test/polar/PolarRadiusAxis.render.spec.tsx +52 -0
  498. package/test/polar/PolarRadiusAxis.spec.tsx +991 -0
  499. package/test/polar/PolarRadiusAxis.typed.spec.tsx +84 -0
  500. package/test/polar/PolarTooltipLegend.render.spec.tsx +80 -0
  501. package/test/polar/Radar.animation.spec.tsx +570 -0
  502. package/test/polar/Radar.render.spec.tsx +71 -0
  503. package/test/polar/Radar.spec.tsx +265 -0
  504. package/test/polar/Radar.typed.spec.tsx +119 -0
  505. package/test/polar/RadialBar/RadialBar.spec.tsx +1521 -0
  506. package/test/polar/RadialBar/RadialBar.typed.spec.tsx +132 -0
  507. package/test/polar/RadialBar.animation.spec.tsx +375 -0
  508. package/test/polar/RadialBar.render.spec.tsx +66 -0
  509. package/test/polar/RadialBar.stacked.spec.tsx +57 -0
  510. package/test/setup.ts +84 -0
  511. package/test/shape/ActiveShape.spec.tsx +181 -0
  512. package/test/shape/Cross.spec.tsx +60 -0
  513. package/test/shape/Cross.typed.spec.tsx +26 -0
  514. package/test/shape/Curve.spec.tsx +368 -0
  515. package/test/shape/Curve.typed.spec.tsx +69 -0
  516. package/test/shape/Dot.spec.tsx +73 -0
  517. package/test/shape/Dot.typed.spec.tsx +30 -0
  518. package/test/shape/Polygon.spec.tsx +357 -0
  519. package/test/shape/Polygon.typed.spec.tsx +28 -0
  520. package/test/shape/Rectangle.animation.spec.tsx +451 -0
  521. package/test/shape/Rectangle.spec.tsx +68 -0
  522. package/test/shape/Rectangle.typed.spec.tsx +24 -0
  523. package/test/shape/Sector.spec.tsx +76 -0
  524. package/test/shape/Sector.typed.spec.tsx +24 -0
  525. package/test/shape/Symbols.spec.tsx +43 -0
  526. package/test/shape/Symbols.typed.spec.tsx +24 -0
  527. package/test/shape/Trapezoid.spec.tsx +50 -0
  528. package/test/shape/Trapezoid.typed.spec.tsx +24 -0
  529. package/test/shape/__snapshots__/Cross.spec.tsx.snap +62 -0
  530. package/test/shape/__snapshots__/Curve.spec.tsx.snap +460 -0
  531. package/test/shape/__snapshots__/Polygon.spec.tsx.snap +58 -0
  532. package/test/shape/__snapshots__/Rectangle.spec.tsx.snap +117 -0
  533. package/test/shape/__snapshots__/Sector.spec.tsx.snap +71 -0
  534. package/test/shape/__snapshots__/Trapezoid.spec.tsx.snap +64 -0
  535. package/test/state/chartDataSlice.spec.ts +53 -0
  536. package/test/state/externalEventsMiddleware.spec.ts +178 -0
  537. package/test/state/graphicalItemsSlice.spec.ts +92 -0
  538. package/test/state/hooks.spec.tsx +68 -0
  539. package/test/state/legendSlice.spec.ts +44 -0
  540. package/test/state/mouseEventsMiddleware.spec.ts +75 -0
  541. package/test/state/optionsSlice.spec.ts +19 -0
  542. package/test/state/reduxDevtoolsJsonStringifyReplacer.spec.ts +25 -0
  543. package/test/state/referenceElementsSlice.spec.ts +84 -0
  544. package/test/state/selectors/areaSelectors.spec.tsx +77 -0
  545. package/test/state/selectors/axisSelectors.spec.tsx +1418 -0
  546. package/test/state/selectors/barStackSelectors.spec.tsx +752 -0
  547. package/test/state/selectors/brushSelectors.spec.tsx +30 -0
  548. package/test/state/selectors/cartesianAxisSlice.spec.ts +96 -0
  549. package/test/state/selectors/combineNiceTicks.spec.ts +207 -0
  550. package/test/state/selectors/combiners/combineActiveTooltipIndex.spec.ts +61 -0
  551. package/test/state/selectors/combiners/combineAllBarPositions.spec.ts +39 -0
  552. package/test/state/selectors/combiners/combineConfiguredScale.spec.ts +56 -0
  553. package/test/state/selectors/combiners/combineDisplayedStackedData.spec.ts +123 -0
  554. package/test/state/selectors/combiners/combineRealScaleType.spec.ts +80 -0
  555. package/test/state/selectors/containerSelectors.spec.tsx +168 -0
  556. package/test/state/selectors/dataSelectors.spec.tsx +136 -0
  557. package/test/state/selectors/legendSelectors.spec.tsx +113 -0
  558. package/test/state/selectors/lineSelectors.spec.tsx +60 -0
  559. package/test/state/selectors/pieSelectors.spec.tsx +72 -0
  560. package/test/state/selectors/radarSelectors.spec.tsx +496 -0
  561. package/test/state/selectors/rootPropsSelectors.spec.tsx +169 -0
  562. package/test/state/selectors/scatterSelectors.spec.tsx +47 -0
  563. package/test/state/selectors/selectActiveTooltipIndex.spec.tsx +234 -0
  564. package/test/state/selectors/selectAllAxes.spec.tsx +18 -0
  565. package/test/state/selectors/selectAxisDomain.spec.tsx +21 -0
  566. package/test/state/selectors/selectAxisDomainIncludingNiceTicks.spec.tsx +19 -0
  567. package/test/state/selectors/selectAxisRangeWithReverse.spec.tsx +22 -0
  568. package/test/state/selectors/selectAxisScale.spec.tsx +91 -0
  569. package/test/state/selectors/selectBarRectangles.stackOffset.spec.tsx +503 -0
  570. package/test/state/selectors/selectBaseAxis.spec.tsx +56 -0
  571. package/test/state/selectors/selectCartesianItemsSettings.spec.tsx +57 -0
  572. package/test/state/selectors/selectChartOffset.spec.tsx +26 -0
  573. package/test/state/selectors/selectDisplayedData.spec.tsx +282 -0
  574. package/test/state/selectors/selectIsTooltipActive.spec.tsx +231 -0
  575. package/test/state/selectors/selectNumericalDomain.spec.tsx +21 -0
  576. package/test/state/selectors/selectRealScaleType.spec.tsx +19 -0
  577. package/test/state/selectors/selectStackGroups.spec.tsx +322 -0
  578. package/test/state/selectors/selectXAxisPosition.spec.tsx +22 -0
  579. package/test/state/selectors/selectYAxisPosition.spec.tsx +22 -0
  580. package/test/state/selectors/selectors.spec.tsx +1613 -0
  581. package/test/state/throttling.spec.ts +200 -0
  582. package/test/state/zIndexSlice.spec.ts +85 -0
  583. package/test/synchronisation/useChartSynchronisation.spec.tsx +225 -0
  584. package/test/util/BarUtils.spec.ts +39 -0
  585. package/test/util/CartesianUtils/CartesianUtils.spec.ts +261 -0
  586. package/test/util/CartesianUtils/rectWithPoints.spec.ts +48 -0
  587. package/test/util/ChartUtils/ChartUtils.spec.ts +491 -0
  588. package/test/util/ChartUtils/appendOffsetOfLegend.spec.ts +136 -0
  589. package/test/util/ChartUtils/appendOffsetOfLegend.spec.tsx +133 -0
  590. package/test/util/ChartUtils/getCateCoordinateOfLine.spec.ts +83 -0
  591. package/test/util/ChartUtils/getStackedData.spec.ts +416 -0
  592. package/test/util/ChartUtils/truncateByDomain.spec.ts +70 -0
  593. package/test/util/DataUtils.spec.ts +385 -0
  594. package/test/util/DomUtils.spec.tsx +117 -0
  595. package/test/util/FunnelUtils.spec.tsx +70 -0
  596. package/test/util/Global.spec.ts +11 -0
  597. package/test/util/LRUCache.spec.ts +81 -0
  598. package/test/util/LogUtils.spec.ts +45 -0
  599. package/test/util/PolarUtils.spec.ts +66 -0
  600. package/test/util/ReduceCssCalcPrototype.spec.ts +141 -0
  601. package/test/util/ShallowEqual.spec.ts +102 -0
  602. package/test/util/TickUtils.spec.ts +29 -0
  603. package/test/util/axisPropsAreEqual.spec.ts +93 -0
  604. package/test/util/createChartHelpers.spec.tsx +210 -0
  605. package/test/util/cursor/getCursorPoints.spec.ts +136 -0
  606. package/test/util/cursor/getCursorRectangle.spec.ts +50 -0
  607. package/test/util/cursor/getRadialCursorPoints.spec.ts +36 -0
  608. package/test/util/errorValue.spec.ts +69 -0
  609. package/test/util/getEveryNth.spec.ts +39 -0
  610. package/test/util/getRadiusAndStrokeWidthFromDot.spec.ts +51 -0
  611. package/test/util/getRelativeCoordinate.spec.ts +250 -0
  612. package/test/util/getSliced.spec.ts +45 -0
  613. package/test/util/isDomainSpecifiedByUser.spec.ts +207 -0
  614. package/test/util/isWellBehavedNumber.spec.ts +54 -0
  615. package/test/util/payload/getUniqPayload.spec.ts +56 -0
  616. package/test/util/propsAreEqual.spec.ts +75 -0
  617. package/test/util/round.spec.ts +112 -0
  618. package/test/util/scale/arithmetic.spec.ts +61 -0
  619. package/test/util/scale/createCategoricalInverse.spec.ts +84 -0
  620. package/test/util/scale/getNiceTickValues.spec.ts +421 -0
  621. package/test/util/scale/getTickValuesFixedDomain.spec.ts +155 -0
  622. package/test/util/svgPropertiesAndEvents.spec.tsx +206 -0
  623. package/test/util/svgPropertiesNoEvents.spec.tsx +228 -0
  624. package/test/util/tooltip/translate.spec.ts +396 -0
  625. package/test/util/useAnimationId.spec.tsx +59 -0
  626. package/test/util/useElementOffset.spec.tsx +173 -0
  627. package/test/util/usePrefersReducedMotion.spec.ts +54 -0
  628. package/test/util/useUniqueId.spec.ts +99 -0
  629. package/test/utils/diagnostics-allowlist.ts +18 -0
  630. package/test/utils/diagnostics.ts +58 -0
  631. package/test/zIndex/AllZIndexPortals.spec.tsx +83 -0
  632. package/test/zIndex/DefaultZIndexes.spec.ts +80 -0
  633. package/test/zIndex/DynamicZIndex.spec.tsx +102 -0
  634. package/test/zIndex/ZIndexLayer.portalOwner.spec.tsx +125 -0
  635. package/test/zIndex/componentZIndex.spec.tsx +255 -0
  636. package/test/zIndex/getZIndexFromUnknown.spec.ts +51 -0
  637. package/test/zIndex/multiChartZIndexIsolation.spec.tsx +90 -0
  638. package/test/zIndex/zIndexSelectors.spec.ts +172 -0
  639. package/tsconfig.json +11 -0
@@ -0,0 +1,2414 @@
1
+ // Ported from recharts 3.8.1 test/cartesian/ErrorBar.spec.tsx — the render-geometry
2
+ // matrix from the top-level `<ErrorBar />` describe (Bar / stacked-Bar / Line /
3
+ // Scatter horizontal+vertical golden line coordinates), the "ErrorBar and axis
4
+ // domain interaction" describe (rerender→signal), and the 5 animation cases
5
+ // (React animationManager → Solid createManagerRegistry + completeAll; the
6
+ // "with animation delay" case also covers the bare `begin` SVG-attr passthrough
7
+ // onto the whisker group via svgPropertiesNoEvents).
8
+ import { describe, expect, it, test } from "vitest";
9
+ import { createSignal, flush, Show } from "solid-js";
10
+ import {
11
+ Bar,
12
+ BarChart,
13
+ ErrorBar,
14
+ Line,
15
+ LineChart,
16
+ Scatter,
17
+ ScatterChart,
18
+ XAxis,
19
+ YAxis,
20
+ } from "../../src";
21
+ import { render } from "../helper/render";
22
+ import { AnimationControllerProvider } from "../../src/animation/useAnimationController";
23
+ import type { AnimationController } from "../../src";
24
+ import { MockControllerAnimationManager } from "../animation/mockControllerAnimationManager";
25
+ import { expectScatterPoints } from "../helper/expectScatterPoints";
26
+ import { createSelectorTestCase } from "../helper/createSelectorTestCase";
27
+ import { expectXAxisTicks, expectYAxisTicks } from "../helper/expectAxisTicks";
28
+ import { expectBars } from "../helper/expectBars";
29
+ import { expectLastCalledWith } from "../helper/expectLastCalledWith";
30
+ import {
31
+ getErrorDomainByDataKey,
32
+ selectAxisDomainIncludingNiceTicks,
33
+ selectNumericalDomain,
34
+ } from "../../src/state/selectors/axisSelectors";
35
+ import { useIsPanorama } from "../../src/context/PanoramaContext";
36
+ import type { RechartsRootState } from "../../src/state/store";
37
+
38
+ type ExpectedErrorBarLine = {
39
+ x1: string | null;
40
+ x2: string | null;
41
+ y1: string | null;
42
+ y2: string | null;
43
+ };
44
+
45
+ const expectErrorBars = (
46
+ container: HTMLElement,
47
+ linesExpected: ReadonlyArray<ExpectedErrorBarLine>,
48
+ ) => {
49
+ const errorBarLines = container.querySelectorAll(".recharts-errorBar line");
50
+
51
+ const linesActual = Array.from(errorBarLines).map((line) => {
52
+ return {
53
+ x1: line.getAttribute("x1"),
54
+ x2: line.getAttribute("x2"),
55
+ y1: line.getAttribute("y1"),
56
+ y2: line.getAttribute("y2"),
57
+ };
58
+ });
59
+
60
+ expect(linesActual).toEqual(linesExpected);
61
+ };
62
+
63
+ // Port of the reference's assertAnimationStyles: every whisker line carries the
64
+ // expected CSS, and `transition` is present iff animation is active.
65
+ function assertAnimationStyles(
66
+ container: HTMLElement,
67
+ animation: boolean,
68
+ expectedStyles: Record<string, string>,
69
+ ): void {
70
+ container.querySelectorAll(".recharts-errorBar").forEach((bar) => {
71
+ bar.querySelectorAll("line").forEach((line) => {
72
+ const style = line.getAttribute("style");
73
+ Object.entries(expectedStyles).forEach(([key, value]) => {
74
+ expect(style).toContain(`${key}: ${value}`);
75
+ });
76
+ if (animation) {
77
+ expect(style).toContain("transition");
78
+ } else {
79
+ expect(style).not.toContain("transition");
80
+ }
81
+ });
82
+ });
83
+ }
84
+
85
+ // ErrorBar renders one CSSTransitionAnimate per whisker line, each keyed by a unique
86
+ // animationId. On the v3.9 engine the injected AnimationController routes per-id
87
+ // (via handle.getAnimationId()) to its own MockControllerAnimationManager, and
88
+ // completeAll() finishes them all.
89
+ function createManagerRegistry(): {
90
+ controller: AnimationController;
91
+ completeAll: () => Promise<void>;
92
+ } {
93
+ const managers = new Map<string, MockControllerAnimationManager>();
94
+ return {
95
+ controller: (timeoutController, animationHandle, listener) => {
96
+ const id = animationHandle.getAnimationId();
97
+ let m = managers.get(id);
98
+ if (m == null) {
99
+ m = new MockControllerAnimationManager(id);
100
+ managers.set(id, m);
101
+ }
102
+ m.start(animationHandle, listener);
103
+ return () => m.stop();
104
+ },
105
+ completeAll: async () => {
106
+ // Some consumers in the tree (e.g. a Bar with isAnimationActive=false) get a
107
+ // manager but never enqueue an animation; ignore their "Queue is empty".
108
+ await Promise.all(
109
+ Array.from(managers.values()).map((m) =>
110
+ m.completeAnimation().catch((e: unknown) => {
111
+ if (!(e instanceof Error) || !e.message.includes("Queue is empty")) {
112
+ throw e;
113
+ }
114
+ }),
115
+ ),
116
+ );
117
+ },
118
+ };
119
+ }
120
+
121
+ describe("<ErrorBar />", () => {
122
+ const dataWithError = [
123
+ { name: "food", uv: 2000, pv: 2013, time: 1, uvError: [100, 50], pvError: [110, 20] },
124
+ { name: "cosmetic", uv: 3300, pv: 2000, time: 2, uvError: [120, 140], pvError: 50 },
125
+ { name: "storage", uv: 3200, pv: 1398, time: 3, uvError: [120, 80], pvError: [200, 100] },
126
+ { name: "digital", uv: 2800, pv: 2800, time: 4, uvError: [100, 200], pvError: 30 },
127
+ ];
128
+
129
+ const expectedErrorBars = [
130
+ {
131
+ x1: "61.25",
132
+ x2: "71.25",
133
+ y1: "215.97222222222223",
134
+ y2: "215.97222222222223",
135
+ },
136
+ {
137
+ x1: "66.25",
138
+ x2: "66.25",
139
+ y1: "236.38888888888889",
140
+ y2: "215.97222222222223",
141
+ },
142
+ {
143
+ x1: "61.25",
144
+ x2: "71.25",
145
+ y1: "236.38888888888889",
146
+ y2: "236.38888888888889",
147
+ },
148
+ {
149
+ x1: "183.75",
150
+ x2: "193.75",
151
+ y1: "26.777777777777754",
152
+ y2: "26.777777777777754",
153
+ },
154
+ {
155
+ x1: "188.75",
156
+ x2: "188.75",
157
+ y1: "62.16666666666668",
158
+ y2: "26.777777777777754",
159
+ },
160
+ {
161
+ x1: "183.75",
162
+ x2: "193.75",
163
+ y1: "62.16666666666668",
164
+ y2: "62.16666666666668",
165
+ },
166
+ {
167
+ x1: "306.25",
168
+ x2: "316.25",
169
+ y1: "48.555555555555564",
170
+ y2: "48.555555555555564",
171
+ },
172
+ {
173
+ x1: "311.25",
174
+ x2: "311.25",
175
+ y1: "75.77777777777779",
176
+ y2: "48.555555555555564",
177
+ },
178
+ {
179
+ x1: "306.25",
180
+ x2: "316.25",
181
+ y1: "75.77777777777779",
182
+ y2: "75.77777777777779",
183
+ },
184
+ {
185
+ x1: "428.75",
186
+ x2: "438.75",
187
+ y1: "86.66666666666666",
188
+ y2: "86.66666666666666",
189
+ },
190
+ {
191
+ x1: "433.75",
192
+ x2: "433.75",
193
+ y1: "127.5",
194
+ y2: "86.66666666666666",
195
+ },
196
+ {
197
+ x1: "428.75",
198
+ x2: "438.75",
199
+ y1: "127.5",
200
+ y2: "127.5",
201
+ },
202
+ ];
203
+ it("Renders Error Bars in Bar", () => {
204
+ const renderTestCase = createSelectorTestCase(() => (
205
+ <BarChart data={dataWithError} width={500} height={500}>
206
+ <Bar isAnimationActive={false} dataKey="uv">
207
+ <ErrorBar dataKey="uvError" />
208
+ </Bar>
209
+ </BarChart>
210
+ ));
211
+
212
+ const { container } = renderTestCase();
213
+
214
+ expectErrorBars(container, expectedErrorBars);
215
+ });
216
+
217
+ it("Renders Multiple Error Bars in Bar", () => {
218
+ const renderTestCase = createSelectorTestCase(() => (
219
+ <BarChart data={dataWithError} width={500} height={500} layout="vertical">
220
+ <Bar isAnimationActive={false} dataKey="uv">
221
+ <ErrorBar dataKey="uvError" direction="x" />
222
+ <ErrorBar dataKey="pvError" direction="x" />
223
+ </Bar>
224
+ {/* Axes are needed in order to actually render anything useful in a vertical chart */}
225
+ <XAxis dataKey="uv" type="number" />
226
+ <YAxis dataKey="name" type="category" />
227
+ </BarChart>
228
+ ));
229
+
230
+ const { container } = renderTestCase();
231
+
232
+ expectErrorBars(container, [
233
+ {
234
+ x1: "309.8611111111111",
235
+ x2: "309.8611111111111",
236
+ y1: "67.5",
237
+ y2: "57.5",
238
+ },
239
+ {
240
+ x1: "291.94444444444446",
241
+ x2: "309.8611111111111",
242
+ y1: "62.5",
243
+ y2: "62.5",
244
+ },
245
+ {
246
+ x1: "291.94444444444446",
247
+ x2: "291.94444444444446",
248
+ y1: "67.5",
249
+ y2: "57.5",
250
+ },
251
+ {
252
+ x1: "475.8888888888889",
253
+ x2: "475.8888888888889",
254
+ y1: "182.5",
255
+ y2: "172.5",
256
+ },
257
+ {
258
+ x1: "444.8333333333333",
259
+ x2: "475.8888888888889",
260
+ y1: "177.5",
261
+ y2: "177.5",
262
+ },
263
+ {
264
+ x1: "444.8333333333333",
265
+ x2: "444.8333333333333",
266
+ y1: "182.5",
267
+ y2: "172.5",
268
+ },
269
+ {
270
+ x1: "456.77777777777777",
271
+ x2: "456.77777777777777",
272
+ y1: "297.5",
273
+ y2: "287.5",
274
+ },
275
+ {
276
+ x1: "432.8888888888889",
277
+ x2: "456.77777777777777",
278
+ y1: "292.5",
279
+ y2: "292.5",
280
+ },
281
+ {
282
+ x1: "432.8888888888889",
283
+ x2: "432.8888888888889",
284
+ y1: "297.5",
285
+ y2: "287.5",
286
+ },
287
+ {
288
+ x1: "423.3333333333333",
289
+ x2: "423.3333333333333",
290
+ y1: "412.5",
291
+ y2: "402.5",
292
+ },
293
+ {
294
+ x1: "387.5",
295
+ x2: "423.3333333333333",
296
+ y1: "407.5",
297
+ y2: "407.5",
298
+ },
299
+ {
300
+ x1: "387.5",
301
+ x2: "387.5",
302
+ y1: "412.5",
303
+ y2: "402.5",
304
+ },
305
+ {
306
+ x1: "306.27777777777777",
307
+ x2: "306.27777777777777",
308
+ y1: "67.5",
309
+ y2: "57.5",
310
+ },
311
+ {
312
+ x1: "290.75",
313
+ x2: "306.27777777777777",
314
+ y1: "62.5",
315
+ y2: "62.5",
316
+ },
317
+ {
318
+ x1: "290.75",
319
+ x2: "290.75",
320
+ y1: "67.5",
321
+ y2: "57.5",
322
+ },
323
+ {
324
+ x1: "465.1388888888889",
325
+ x2: "465.1388888888889",
326
+ y1: "182.5",
327
+ y2: "172.5",
328
+ },
329
+ {
330
+ x1: "453.19444444444446",
331
+ x2: "465.1388888888889",
332
+ y1: "177.5",
333
+ y2: "177.5",
334
+ },
335
+ {
336
+ x1: "453.19444444444446",
337
+ x2: "453.19444444444446",
338
+ y1: "182.5",
339
+ y2: "172.5",
340
+ },
341
+ {
342
+ x1: "459.1666666666667",
343
+ x2: "459.1666666666667",
344
+ y1: "297.5",
345
+ y2: "287.5",
346
+ },
347
+ {
348
+ x1: "423.3333333333333",
349
+ x2: "459.1666666666667",
350
+ y1: "292.5",
351
+ y2: "292.5",
352
+ },
353
+ {
354
+ x1: "423.3333333333333",
355
+ x2: "423.3333333333333",
356
+ y1: "297.5",
357
+ y2: "287.5",
358
+ },
359
+ {
360
+ x1: "403.02777777777777",
361
+ x2: "403.02777777777777",
362
+ y1: "412.5",
363
+ y2: "402.5",
364
+ },
365
+ {
366
+ x1: "395.8611111111111",
367
+ x2: "403.02777777777777",
368
+ y1: "407.5",
369
+ y2: "407.5",
370
+ },
371
+ {
372
+ x1: "395.8611111111111",
373
+ x2: "395.8611111111111",
374
+ y1: "412.5",
375
+ y2: "402.5",
376
+ },
377
+ ]);
378
+ });
379
+
380
+ it("Renders Error Bars in stacked Bar", () => {
381
+ const renderTestCase = createSelectorTestCase(() => (
382
+ <BarChart data={dataWithError} width={500} height={500}>
383
+ <Bar isAnimationActive={false} dataKey="uv" stackId="1">
384
+ <ErrorBar dataKey="uvError" />
385
+ </Bar>
386
+ <Bar isAnimationActive={false} dataKey="pv" stackId="1">
387
+ <ErrorBar dataKey="uvError" />
388
+ </Bar>
389
+ </BarChart>
390
+ ));
391
+
392
+ const { container } = renderTestCase();
393
+
394
+ expectErrorBars(container, [
395
+ {
396
+ x1: "61.25",
397
+ x2: "71.25",
398
+ y1: "327.5833333333333",
399
+ y2: "327.5833333333333",
400
+ },
401
+ {
402
+ x1: "66.25",
403
+ x2: "66.25",
404
+ y1: "339.8333333333333",
405
+ y2: "327.5833333333333",
406
+ },
407
+ {
408
+ x1: "61.25",
409
+ x2: "71.25",
410
+ y1: "339.8333333333333",
411
+ y2: "339.8333333333333",
412
+ },
413
+ {
414
+ x1: "183.75",
415
+ x2: "193.75",
416
+ y1: "214.06666666666666",
417
+ y2: "214.06666666666666",
418
+ },
419
+ {
420
+ x1: "188.75",
421
+ x2: "188.75",
422
+ y1: "235.29999999999998",
423
+ y2: "214.06666666666666",
424
+ },
425
+ {
426
+ x1: "183.75",
427
+ x2: "193.75",
428
+ y1: "235.29999999999998",
429
+ y2: "235.29999999999998",
430
+ },
431
+ {
432
+ x1: "306.25",
433
+ x2: "316.25",
434
+ y1: "227.13333333333333",
435
+ y2: "227.13333333333333",
436
+ },
437
+ {
438
+ x1: "311.25",
439
+ x2: "311.25",
440
+ y1: "243.46666666666667",
441
+ y2: "227.13333333333333",
442
+ },
443
+ {
444
+ x1: "306.25",
445
+ x2: "316.25",
446
+ y1: "243.46666666666667",
447
+ y2: "243.46666666666667",
448
+ },
449
+ {
450
+ x1: "428.75",
451
+ x2: "438.75",
452
+ y1: "250",
453
+ y2: "250",
454
+ },
455
+ {
456
+ x1: "433.75",
457
+ x2: "433.75",
458
+ y1: "274.5",
459
+ y2: "250",
460
+ },
461
+ {
462
+ x1: "428.75",
463
+ x2: "438.75",
464
+ y1: "274.5",
465
+ y2: "274.5",
466
+ },
467
+ {
468
+ x1: "61.25",
469
+ x2: "71.25",
470
+ y1: "163.1883333333333",
471
+ y2: "163.1883333333333",
472
+ },
473
+ {
474
+ x1: "66.25",
475
+ x2: "66.25",
476
+ y1: "175.43833333333333",
477
+ y2: "163.1883333333333",
478
+ },
479
+ {
480
+ x1: "61.25",
481
+ x2: "71.25",
482
+ y1: "175.43833333333333",
483
+ y2: "175.43833333333333",
484
+ },
485
+ {
486
+ x1: "183.75",
487
+ x2: "193.75",
488
+ y1: "50.733333333333356",
489
+ y2: "50.733333333333356",
490
+ },
491
+ {
492
+ x1: "188.75",
493
+ x2: "188.75",
494
+ y1: "71.96666666666668",
495
+ y2: "50.733333333333356",
496
+ },
497
+ {
498
+ x1: "183.75",
499
+ x2: "193.75",
500
+ y1: "71.96666666666668",
501
+ y2: "71.96666666666668",
502
+ },
503
+ {
504
+ x1: "306.25",
505
+ x2: "316.25",
506
+ y1: "112.96333333333335",
507
+ y2: "112.96333333333335",
508
+ },
509
+ {
510
+ x1: "311.25",
511
+ x2: "311.25",
512
+ y1: "129.29666666666668",
513
+ y2: "112.96333333333335",
514
+ },
515
+ {
516
+ x1: "306.25",
517
+ x2: "316.25",
518
+ y1: "129.29666666666668",
519
+ y2: "129.29666666666668",
520
+ },
521
+ {
522
+ x1: "428.75",
523
+ x2: "438.75",
524
+ y1: "21.33333333333333",
525
+ y2: "21.33333333333333",
526
+ },
527
+ {
528
+ x1: "433.75",
529
+ x2: "433.75",
530
+ y1: "45.83333333333336",
531
+ y2: "21.33333333333333",
532
+ },
533
+ {
534
+ x1: "428.75",
535
+ x2: "438.75",
536
+ y1: "45.83333333333336",
537
+ y2: "45.83333333333336",
538
+ },
539
+ ]);
540
+ });
541
+
542
+ const lineData = [
543
+ { name: "Page A", uv: 1000, pv: 2400, amt: 2400, uvError: [75, 20], pvError: [90, 40] },
544
+ { name: "Page B", uv: 300, pv: 4567, amt: 2400, uvError: [90, 40], pvError: [75, 20] },
545
+ { name: "Page C", uv: 280, pv: 1398, amt: 2400, uvError: 40, pvError: 20 },
546
+ { name: "Page D", uv: 200, pv: 9800, amt: 2400, uvError: 20, pvError: 28 },
547
+ { name: "Page I", uv: 189, pv: 4800, amt: 2400, uvError: 28, pvError: 40 },
548
+ ];
549
+
550
+ it("Renders Error Bars in Line", () => {
551
+ const renderTestCase = createSelectorTestCase(() => (
552
+ <LineChart data={lineData} width={500} height={500}>
553
+ <Line isAnimationActive={false} dataKey="uv">
554
+ <ErrorBar dataKey="uvError" />
555
+ </Line>
556
+ </LineChart>
557
+ ));
558
+
559
+ const { container } = renderTestCase();
560
+
561
+ expectErrorBars(container, [
562
+ {
563
+ x1: "0",
564
+ x2: "10",
565
+ y1: "78.50000000000001",
566
+ y2: "78.50000000000001",
567
+ },
568
+ {
569
+ x1: "5",
570
+ x2: "5",
571
+ y1: "117.29166666666666",
572
+ y2: "78.50000000000001",
573
+ },
574
+ {
575
+ x1: "0",
576
+ x2: "10",
577
+ y1: "117.29166666666666",
578
+ y2: "117.29166666666666",
579
+ },
580
+ {
581
+ x1: "122.5",
582
+ x2: "132.5",
583
+ y1: "356.1666666666667",
584
+ y2: "356.1666666666667",
585
+ },
586
+ {
587
+ x1: "127.5",
588
+ x2: "127.5",
589
+ y1: "409.25",
590
+ y2: "356.1666666666667",
591
+ },
592
+ {
593
+ x1: "122.5",
594
+ x2: "132.5",
595
+ y1: "409.25",
596
+ y2: "409.25",
597
+ },
598
+ {
599
+ x1: "245",
600
+ x2: "255",
601
+ y1: "364.33333333333337",
602
+ y2: "364.33333333333337",
603
+ },
604
+ {
605
+ x1: "250",
606
+ x2: "250",
607
+ y1: "397",
608
+ y2: "364.33333333333337",
609
+ },
610
+ {
611
+ x1: "245",
612
+ x2: "255",
613
+ y1: "397",
614
+ y2: "397",
615
+ },
616
+ {
617
+ x1: "367.5",
618
+ x2: "377.5",
619
+ y1: "405.1666666666667",
620
+ y2: "405.1666666666667",
621
+ },
622
+ {
623
+ x1: "372.5",
624
+ x2: "372.5",
625
+ y1: "421.5",
626
+ y2: "405.1666666666667",
627
+ },
628
+ {
629
+ x1: "367.5",
630
+ x2: "377.5",
631
+ y1: "421.5",
632
+ y2: "421.5",
633
+ },
634
+ {
635
+ x1: "490",
636
+ x2: "500",
637
+ y1: "406.3916666666666",
638
+ y2: "406.3916666666666",
639
+ },
640
+ {
641
+ x1: "495",
642
+ x2: "495",
643
+ y1: "429.2583333333333",
644
+ y2: "406.3916666666666",
645
+ },
646
+ {
647
+ x1: "490",
648
+ x2: "500",
649
+ y1: "429.2583333333333",
650
+ y2: "429.2583333333333",
651
+ },
652
+ ]);
653
+ });
654
+
655
+ it("Renders Multiple Error Bars in Line", () => {
656
+ const renderTestCase = createSelectorTestCase(() => (
657
+ <LineChart data={lineData} width={500} height={500}>
658
+ <Line isAnimationActive={false} dataKey="uv">
659
+ <ErrorBar dataKey="uvError" />
660
+ <ErrorBar dataKey="pvError" />
661
+ </Line>
662
+ </LineChart>
663
+ ));
664
+
665
+ const { container } = renderTestCase();
666
+
667
+ expectErrorBars(container, [
668
+ {
669
+ x1: "0",
670
+ x2: "10",
671
+ y1: "78.50000000000001",
672
+ y2: "78.50000000000001",
673
+ },
674
+ {
675
+ x1: "5",
676
+ x2: "5",
677
+ y1: "117.29166666666666",
678
+ y2: "78.50000000000001",
679
+ },
680
+ {
681
+ x1: "0",
682
+ x2: "10",
683
+ y1: "117.29166666666666",
684
+ y2: "117.29166666666666",
685
+ },
686
+ {
687
+ x1: "122.5",
688
+ x2: "132.5",
689
+ y1: "356.1666666666667",
690
+ y2: "356.1666666666667",
691
+ },
692
+ {
693
+ x1: "127.5",
694
+ x2: "127.5",
695
+ y1: "409.25",
696
+ y2: "356.1666666666667",
697
+ },
698
+ {
699
+ x1: "122.5",
700
+ x2: "132.5",
701
+ y1: "409.25",
702
+ y2: "409.25",
703
+ },
704
+ {
705
+ x1: "245",
706
+ x2: "255",
707
+ y1: "364.33333333333337",
708
+ y2: "364.33333333333337",
709
+ },
710
+ {
711
+ x1: "250",
712
+ x2: "250",
713
+ y1: "397",
714
+ y2: "364.33333333333337",
715
+ },
716
+ {
717
+ x1: "245",
718
+ x2: "255",
719
+ y1: "397",
720
+ y2: "397",
721
+ },
722
+ {
723
+ x1: "367.5",
724
+ x2: "377.5",
725
+ y1: "405.1666666666667",
726
+ y2: "405.1666666666667",
727
+ },
728
+ {
729
+ x1: "372.5",
730
+ x2: "372.5",
731
+ y1: "421.5",
732
+ y2: "405.1666666666667",
733
+ },
734
+ {
735
+ x1: "367.5",
736
+ x2: "377.5",
737
+ y1: "421.5",
738
+ y2: "421.5",
739
+ },
740
+ {
741
+ x1: "490",
742
+ x2: "500",
743
+ y1: "406.3916666666666",
744
+ y2: "406.3916666666666",
745
+ },
746
+ {
747
+ x1: "495",
748
+ x2: "495",
749
+ y1: "429.2583333333333",
750
+ y2: "406.3916666666666",
751
+ },
752
+ {
753
+ x1: "490",
754
+ x2: "500",
755
+ y1: "429.2583333333333",
756
+ y2: "429.2583333333333",
757
+ },
758
+ {
759
+ x1: "0",
760
+ x2: "10",
761
+ y1: "70.33333333333331",
762
+ y2: "70.33333333333331",
763
+ },
764
+ {
765
+ x1: "5",
766
+ x2: "5",
767
+ y1: "123.41666666666669",
768
+ y2: "70.33333333333331",
769
+ },
770
+ {
771
+ x1: "0",
772
+ x2: "10",
773
+ y1: "123.41666666666669",
774
+ y2: "123.41666666666669",
775
+ },
776
+ {
777
+ x1: "122.5",
778
+ x2: "132.5",
779
+ y1: "364.33333333333337",
780
+ y2: "364.33333333333337",
781
+ },
782
+ {
783
+ x1: "127.5",
784
+ x2: "127.5",
785
+ y1: "403.125",
786
+ y2: "364.33333333333337",
787
+ },
788
+ {
789
+ x1: "122.5",
790
+ x2: "132.5",
791
+ y1: "403.125",
792
+ y2: "403.125",
793
+ },
794
+ {
795
+ x1: "245",
796
+ x2: "255",
797
+ y1: "372.5",
798
+ y2: "372.5",
799
+ },
800
+ {
801
+ x1: "250",
802
+ x2: "250",
803
+ y1: "388.8333333333333",
804
+ y2: "372.5",
805
+ },
806
+ {
807
+ x1: "245",
808
+ x2: "255",
809
+ y1: "388.8333333333333",
810
+ y2: "388.8333333333333",
811
+ },
812
+ {
813
+ x1: "367.5",
814
+ x2: "377.5",
815
+ y1: "401.90000000000003",
816
+ y2: "401.90000000000003",
817
+ },
818
+ {
819
+ x1: "372.5",
820
+ x2: "372.5",
821
+ y1: "424.76666666666665",
822
+ y2: "401.90000000000003",
823
+ },
824
+ {
825
+ x1: "367.5",
826
+ x2: "377.5",
827
+ y1: "424.76666666666665",
828
+ y2: "424.76666666666665",
829
+ },
830
+ {
831
+ x1: "490",
832
+ x2: "500",
833
+ y1: "401.4916666666667",
834
+ y2: "401.4916666666667",
835
+ },
836
+ {
837
+ x1: "495",
838
+ x2: "495",
839
+ y1: "434.15833333333336",
840
+ y2: "401.4916666666667",
841
+ },
842
+ {
843
+ x1: "490",
844
+ x2: "500",
845
+ y1: "434.15833333333336",
846
+ y2: "434.15833333333336",
847
+ },
848
+ ]);
849
+ });
850
+
851
+ it("renders two ErrorBars in ScatterChart, one for XAxis another for YAxis", () => {
852
+ const renderTestCase = createSelectorTestCase(() => (
853
+ <ScatterChart width={500} height={500}>
854
+ <Scatter isAnimationActive={false} data={dataWithError} dataKey="uv">
855
+ <ErrorBar dataKey="uvError" direction="y" />
856
+ <ErrorBar dataKey="pvError" direction="x" />
857
+ </Scatter>
858
+ <XAxis type="number" />
859
+ </ScatterChart>
860
+ ));
861
+
862
+ const { container } = renderTestCase();
863
+ expect(container.querySelectorAll(".recharts-errorBars")).toHaveLength(2);
864
+
865
+ expectScatterPoints(container, [
866
+ {
867
+ cx: "326671.6666666667",
868
+ cy: "209.44444444444443",
869
+ d: "M4.514,0A4.514,4.514,0,1,1,-4.514,0A4.514,4.514,0,1,1,4.514,0",
870
+ height: "9.0270333367641",
871
+ transform: "translate(326671.6666666667, 209.44444444444443)",
872
+ width: "9.0270333367641",
873
+ },
874
+ {
875
+ cx: "539005",
876
+ cy: "43.33333333333335",
877
+ d: "M4.514,0A4.514,4.514,0,1,1,-4.514,0A4.514,4.514,0,1,1,4.514,0",
878
+ height: "9.0270333367641",
879
+ transform: "translate(539005, 43.33333333333335)",
880
+ width: "9.0270333367641",
881
+ },
882
+ {
883
+ cx: "522671.6666666667",
884
+ cy: "56.111111111111136",
885
+ d: "M4.514,0A4.514,4.514,0,1,1,-4.514,0A4.514,4.514,0,1,1,4.514,0",
886
+ height: "9.0270333367641",
887
+ transform: "translate(522671.6666666667, 56.111111111111136)",
888
+ width: "9.0270333367641",
889
+ },
890
+ {
891
+ cx: "457338.3333333333",
892
+ cy: "107.22222222222221",
893
+ d: "M4.514,0A4.514,4.514,0,1,1,-4.514,0A4.514,4.514,0,1,1,4.514,0",
894
+ height: "9.0270333367641",
895
+ transform: "translate(457338.3333333333, 107.22222222222221)",
896
+ width: "9.0270333367641",
897
+ },
898
+ ]);
899
+
900
+ expectErrorBars(container, [
901
+ {
902
+ x1: "326666.6666666667",
903
+ x2: "326676.6666666667",
904
+ y1: "203.05555555555557",
905
+ y2: "203.05555555555557",
906
+ },
907
+ {
908
+ x1: "326671.6666666667",
909
+ x2: "326671.6666666667",
910
+ y1: "222.2222222222222",
911
+ y2: "203.05555555555557",
912
+ },
913
+ {
914
+ x1: "326666.6666666667",
915
+ x2: "326676.6666666667",
916
+ y1: "222.2222222222222",
917
+ y2: "222.2222222222222",
918
+ },
919
+ {
920
+ x1: "539000",
921
+ x2: "539010",
922
+ y1: "25.444444444444425",
923
+ y2: "25.444444444444425",
924
+ },
925
+ {
926
+ x1: "539005",
927
+ x2: "539005",
928
+ y1: "58.66666666666668",
929
+ y2: "25.444444444444425",
930
+ },
931
+ {
932
+ x1: "539000",
933
+ x2: "539010",
934
+ y1: "58.66666666666668",
935
+ y2: "58.66666666666668",
936
+ },
937
+ {
938
+ x1: "522666.6666666667",
939
+ x2: "522676.6666666667",
940
+ y1: "45.8888888888889",
941
+ y2: "45.8888888888889",
942
+ },
943
+ {
944
+ x1: "522671.6666666667",
945
+ x2: "522671.6666666667",
946
+ y1: "71.44444444444446",
947
+ y2: "45.8888888888889",
948
+ },
949
+ {
950
+ x1: "522666.6666666667",
951
+ x2: "522676.6666666667",
952
+ y1: "71.44444444444446",
953
+ y2: "71.44444444444446",
954
+ },
955
+ {
956
+ x1: "457333.3333333333",
957
+ x2: "457343.3333333333",
958
+ y1: "81.66666666666666",
959
+ y2: "81.66666666666666",
960
+ },
961
+ {
962
+ x1: "457338.3333333333",
963
+ x2: "457338.3333333333",
964
+ y1: "120",
965
+ y2: "81.66666666666666",
966
+ },
967
+ {
968
+ x1: "457333.3333333333",
969
+ x2: "457343.3333333333",
970
+ y1: "120",
971
+ y2: "120",
972
+ },
973
+ {
974
+ x1: "329938.3333333333",
975
+ x2: "329938.3333333333",
976
+ y1: "214.44444444444443",
977
+ y2: "204.44444444444443",
978
+ },
979
+ {
980
+ x1: "308705",
981
+ x2: "329938.3333333333",
982
+ y1: "209.44444444444443",
983
+ y2: "209.44444444444443",
984
+ },
985
+ {
986
+ x1: "308705",
987
+ x2: "308705",
988
+ y1: "214.44444444444443",
989
+ y2: "204.44444444444443",
990
+ },
991
+ {
992
+ x1: "547171.6666666666",
993
+ x2: "547171.6666666666",
994
+ y1: "48.33333333333335",
995
+ y2: "38.33333333333335",
996
+ },
997
+ {
998
+ x1: "530838.3333333334",
999
+ x2: "547171.6666666666",
1000
+ y1: "43.33333333333335",
1001
+ y2: "43.33333333333335",
1002
+ },
1003
+ {
1004
+ x1: "530838.3333333334",
1005
+ x2: "530838.3333333334",
1006
+ y1: "48.33333333333335",
1007
+ y2: "38.33333333333335",
1008
+ },
1009
+ {
1010
+ x1: "539005",
1011
+ x2: "539005",
1012
+ y1: "61.111111111111136",
1013
+ y2: "51.111111111111136",
1014
+ },
1015
+ {
1016
+ x1: "490005",
1017
+ x2: "539005",
1018
+ y1: "56.111111111111136",
1019
+ y2: "56.111111111111136",
1020
+ },
1021
+ {
1022
+ x1: "490005",
1023
+ x2: "490005",
1024
+ y1: "61.111111111111136",
1025
+ y2: "51.111111111111136",
1026
+ },
1027
+ {
1028
+ x1: "462238.3333333333",
1029
+ x2: "462238.3333333333",
1030
+ y1: "112.22222222222221",
1031
+ y2: "102.22222222222221",
1032
+ },
1033
+ {
1034
+ x1: "452438.3333333333",
1035
+ x2: "462238.3333333333",
1036
+ y1: "107.22222222222221",
1037
+ y2: "107.22222222222221",
1038
+ },
1039
+ {
1040
+ x1: "452438.3333333333",
1041
+ x2: "452438.3333333333",
1042
+ y1: "112.22222222222221",
1043
+ y2: "102.22222222222221",
1044
+ },
1045
+ ]);
1046
+ });
1047
+
1048
+ it("renders two ErrorBars in vertical ScatterChart, one for XAxis another for YAxis", () => {
1049
+ const renderTestCase = createSelectorTestCase(() => (
1050
+ <ScatterChart width={500} height={500} layout="vertical">
1051
+ <Scatter isAnimationActive={false} data={dataWithError} dataKey="uv">
1052
+ <ErrorBar dataKey="uvError" direction="y" />
1053
+ <ErrorBar dataKey="pvError" direction="x" />
1054
+ </Scatter>
1055
+ <XAxis type="number" />
1056
+ </ScatterChart>
1057
+ ));
1058
+
1059
+ const { container } = renderTestCase();
1060
+
1061
+ expect(container.querySelectorAll(".recharts-errorBars")).toHaveLength(2);
1062
+
1063
+ const errorBars = container.querySelectorAll(".recharts-errorBar");
1064
+ errorBars.forEach((bar) => {
1065
+ expect(bar.tagName).toEqual("g");
1066
+ expect(bar.getAttributeNames()).toEqual(["class", "stroke", "stroke-width", "offset"]);
1067
+ expect(bar.childElementCount).toEqual(3);
1068
+ });
1069
+
1070
+ expectScatterPoints(container, [
1071
+ {
1072
+ cx: "293.2352941176471",
1073
+ cy: "306671.6666666667",
1074
+ d: "M4.514,0A4.514,4.514,0,1,1,-4.514,0A4.514,4.514,0,1,1,4.514,0",
1075
+ height: "9.0270333367641",
1076
+ transform: "translate(293.2352941176471, 306671.6666666667)",
1077
+ width: "9.0270333367641",
1078
+ },
1079
+ {
1080
+ cx: "480.5882352941176",
1081
+ cy: "506005",
1082
+ d: "M4.514,0A4.514,4.514,0,1,1,-4.514,0A4.514,4.514,0,1,1,4.514,0",
1083
+ height: "9.0270333367641",
1084
+ transform: "translate(480.5882352941176, 506005)",
1085
+ width: "9.0270333367641",
1086
+ },
1087
+ {
1088
+ cx: "466.1764705882353",
1089
+ cy: "490671.66666666674",
1090
+ d: "M4.514,0A4.514,4.514,0,1,1,-4.514,0A4.514,4.514,0,1,1,4.514,0",
1091
+ height: "9.0270333367641",
1092
+ transform: "translate(466.1764705882353, 490671.66666666674)",
1093
+ width: "9.0270333367641",
1094
+ },
1095
+ {
1096
+ cx: "408.52941176470586",
1097
+ cy: "429338.3333333333",
1098
+ d: "M4.514,0A4.514,4.514,0,1,1,-4.514,0A4.514,4.514,0,1,1,4.514,0",
1099
+ height: "9.0270333367641",
1100
+ transform: "translate(408.52941176470586, 429338.3333333333)",
1101
+ width: "9.0270333367641",
1102
+ },
1103
+ ]);
1104
+
1105
+ expectErrorBars(container, [
1106
+ {
1107
+ x1: "288.2352941176471",
1108
+ x2: "298.2352941176471",
1109
+ y1: "314338.3333333333",
1110
+ y2: "314338.3333333333",
1111
+ },
1112
+ {
1113
+ x1: "293.2352941176471",
1114
+ x2: "293.2352941176471",
1115
+ y1: "291338.3333333333",
1116
+ y2: "314338.3333333333",
1117
+ },
1118
+ {
1119
+ x1: "288.2352941176471",
1120
+ x2: "298.2352941176471",
1121
+ y1: "291338.3333333333",
1122
+ y2: "291338.3333333333",
1123
+ },
1124
+ {
1125
+ x1: "475.5882352941176",
1126
+ x2: "485.5882352941176",
1127
+ y1: "527471.6666666666",
1128
+ y2: "527471.6666666666",
1129
+ },
1130
+ {
1131
+ x1: "480.5882352941176",
1132
+ x2: "480.5882352941176",
1133
+ y1: "487605",
1134
+ y2: "527471.6666666666",
1135
+ },
1136
+ {
1137
+ x1: "475.5882352941176",
1138
+ x2: "485.5882352941176",
1139
+ y1: "487605",
1140
+ y2: "487605",
1141
+ },
1142
+ {
1143
+ x1: "461.1764705882353",
1144
+ x2: "471.1764705882353",
1145
+ y1: "502938.33333333326",
1146
+ y2: "502938.33333333326",
1147
+ },
1148
+ {
1149
+ x1: "466.1764705882353",
1150
+ x2: "466.1764705882353",
1151
+ y1: "472271.66666666674",
1152
+ y2: "502938.33333333326",
1153
+ },
1154
+ {
1155
+ x1: "461.1764705882353",
1156
+ x2: "471.1764705882353",
1157
+ y1: "472271.66666666674",
1158
+ y2: "472271.66666666674",
1159
+ },
1160
+ {
1161
+ x1: "403.52941176470586",
1162
+ x2: "413.52941176470586",
1163
+ y1: "460005",
1164
+ y2: "460005",
1165
+ },
1166
+ {
1167
+ x1: "408.52941176470586",
1168
+ x2: "408.52941176470586",
1169
+ y1: "414005",
1170
+ y2: "460005",
1171
+ },
1172
+ {
1173
+ x1: "403.52941176470586",
1174
+ x2: "413.52941176470586",
1175
+ y1: "414005",
1176
+ y2: "414005",
1177
+ },
1178
+ {
1179
+ x1: "296.1176470588235",
1180
+ x2: "296.1176470588235",
1181
+ y1: "306676.6666666667",
1182
+ y2: "306666.6666666667",
1183
+ },
1184
+ {
1185
+ x1: "277.3823529411765",
1186
+ x2: "296.1176470588235",
1187
+ y1: "306671.6666666667",
1188
+ y2: "306671.6666666667",
1189
+ },
1190
+ {
1191
+ x1: "277.3823529411765",
1192
+ x2: "277.3823529411765",
1193
+ y1: "306676.6666666667",
1194
+ y2: "306666.6666666667",
1195
+ },
1196
+ {
1197
+ x1: "487.79411764705884",
1198
+ x2: "487.79411764705884",
1199
+ y1: "506010",
1200
+ y2: "506000",
1201
+ },
1202
+ {
1203
+ x1: "473.3823529411765",
1204
+ x2: "487.79411764705884",
1205
+ y1: "506005",
1206
+ y2: "506005",
1207
+ },
1208
+ {
1209
+ x1: "473.3823529411765",
1210
+ x2: "473.3823529411765",
1211
+ y1: "506010",
1212
+ y2: "506000",
1213
+ },
1214
+ {
1215
+ x1: "480.5882352941176",
1216
+ x2: "480.5882352941176",
1217
+ y1: "490676.66666666674",
1218
+ y2: "490666.66666666674",
1219
+ },
1220
+ {
1221
+ x1: "437.35294117647055",
1222
+ x2: "480.5882352941176",
1223
+ y1: "490671.66666666674",
1224
+ y2: "490671.66666666674",
1225
+ },
1226
+ {
1227
+ x1: "437.35294117647055",
1228
+ x2: "437.35294117647055",
1229
+ y1: "490676.66666666674",
1230
+ y2: "490666.66666666674",
1231
+ },
1232
+ {
1233
+ x1: "412.8529411764706",
1234
+ x2: "412.8529411764706",
1235
+ y1: "429343.3333333333",
1236
+ y2: "429333.3333333333",
1237
+ },
1238
+ {
1239
+ x1: "404.20588235294116",
1240
+ x2: "412.8529411764706",
1241
+ y1: "429338.3333333333",
1242
+ y2: "429338.3333333333",
1243
+ },
1244
+ {
1245
+ x1: "404.20588235294116",
1246
+ x2: "404.20588235294116",
1247
+ y1: "429343.3333333333",
1248
+ y2: "429333.3333333333",
1249
+ },
1250
+ ]);
1251
+ });
1252
+
1253
+ it.each(["category", undefined] as const)(
1254
+ "does not render anything when direction=x and XAxis id type=%s",
1255
+ (domainType) => {
1256
+ const renderTestCase = createSelectorTestCase(() => (
1257
+ <BarChart data={dataWithError} width={500} height={500}>
1258
+ <XAxis dataKey="name" type={domainType} />
1259
+ <Bar isAnimationActive={false} dataKey="uv">
1260
+ <ErrorBar isAnimationActive animationEasing="linear" dataKey="uvError" direction="x" />
1261
+ </Bar>
1262
+ </BarChart>
1263
+ ));
1264
+
1265
+ const { container } = renderTestCase();
1266
+ expectErrorBars(container, []);
1267
+ },
1268
+ );
1269
+
1270
+ describe("ErrorBar and axis domain interaction", () => {
1271
+ describe("extending domain when data is declared on chart container", () => {
1272
+ // Two static renders (without/with ErrorBar) + unmount between — avoids the dynamic-mount NO_OWNER artifact.
1273
+ const renderWithoutError = createSelectorTestCase((props) => (
1274
+ <BarChart data={dataWithError} width={500} height={500}>
1275
+ <YAxis dataKey="uv" />
1276
+ <Bar isAnimationActive={false} dataKey="uv" />
1277
+ {props.children}
1278
+ </BarChart>
1279
+ ));
1280
+ const renderWithError = createSelectorTestCase((props) => (
1281
+ <BarChart data={dataWithError} width={500} height={500}>
1282
+ <YAxis dataKey="uv" />
1283
+ <Bar isAnimationActive={false} dataKey="uv">
1284
+ <ErrorBar dataKey="uvError" />
1285
+ </Bar>
1286
+ {props.children}
1287
+ </BarChart>
1288
+ ));
1289
+
1290
+ test("selectAxisDomainIncludingNiceTicks", () => {
1291
+ const { spy, unmount } = renderWithoutError((state: RechartsRootState) =>
1292
+ selectAxisDomainIncludingNiceTicks(state, "yAxis", 0, useIsPanorama()),
1293
+ );
1294
+ expect(spy).toHaveBeenCalledWith([0, 3400]);
1295
+
1296
+ unmount();
1297
+ const { spy: spyWith } = renderWithError((state: RechartsRootState) =>
1298
+ selectAxisDomainIncludingNiceTicks(state, "yAxis", 0, useIsPanorama()),
1299
+ );
1300
+ expect(spyWith).toHaveBeenLastCalledWith([0, 3600]);
1301
+ });
1302
+
1303
+ test("YAxis ticks", () => {
1304
+ const { container, unmount } = renderWithoutError();
1305
+ expectYAxisTicks(container, [
1306
+ {
1307
+ textContent: "0",
1308
+ x: "57",
1309
+ y: "495",
1310
+ },
1311
+ {
1312
+ textContent: "850",
1313
+ x: "57",
1314
+ y: "372.5",
1315
+ },
1316
+ {
1317
+ textContent: "1700",
1318
+ x: "57",
1319
+ y: "250",
1320
+ },
1321
+ {
1322
+ textContent: "2550",
1323
+ x: "57",
1324
+ y: "127.5",
1325
+ },
1326
+ {
1327
+ textContent: "3400",
1328
+ x: "57",
1329
+ y: "5",
1330
+ },
1331
+ ]);
1332
+
1333
+ unmount();
1334
+ const { container: containerWith } = renderWithError();
1335
+
1336
+ // these ticks are in the same position but going higher because the ErrorBar pushed YAxis domain
1337
+ expectYAxisTicks(containerWith, [
1338
+ {
1339
+ textContent: "0",
1340
+ x: "57",
1341
+ y: "495",
1342
+ },
1343
+ {
1344
+ textContent: "900",
1345
+ x: "57",
1346
+ y: "372.5",
1347
+ },
1348
+ {
1349
+ textContent: "1800",
1350
+ x: "57",
1351
+ y: "250",
1352
+ },
1353
+ {
1354
+ textContent: "2700",
1355
+ x: "57",
1356
+ y: "127.5",
1357
+ },
1358
+ {
1359
+ textContent: "3600",
1360
+ x: "57",
1361
+ y: "5",
1362
+ },
1363
+ ]);
1364
+ });
1365
+
1366
+ it("should render ErrorBars", () => {
1367
+ const { container, unmount } = renderWithoutError();
1368
+ expectErrorBars(container, []);
1369
+ unmount();
1370
+ const { container: containerWith } = renderWithError();
1371
+ expectErrorBars(containerWith, [
1372
+ {
1373
+ x1: "113.75",
1374
+ x2: "123.75",
1375
+ y1: "215.97222222222223",
1376
+ y2: "215.97222222222223",
1377
+ },
1378
+ {
1379
+ x1: "118.75",
1380
+ x2: "118.75",
1381
+ y1: "236.38888888888889",
1382
+ y2: "215.97222222222223",
1383
+ },
1384
+ {
1385
+ x1: "113.75",
1386
+ x2: "123.75",
1387
+ y1: "236.38888888888889",
1388
+ y2: "236.38888888888889",
1389
+ },
1390
+ {
1391
+ x1: "221.25",
1392
+ x2: "231.25",
1393
+ y1: "26.777777777777754",
1394
+ y2: "26.777777777777754",
1395
+ },
1396
+ {
1397
+ x1: "226.25",
1398
+ x2: "226.25",
1399
+ y1: "62.16666666666668",
1400
+ y2: "26.777777777777754",
1401
+ },
1402
+ {
1403
+ x1: "221.25",
1404
+ x2: "231.25",
1405
+ y1: "62.16666666666668",
1406
+ y2: "62.16666666666668",
1407
+ },
1408
+ {
1409
+ x1: "328.75",
1410
+ x2: "338.75",
1411
+ y1: "48.555555555555564",
1412
+ y2: "48.555555555555564",
1413
+ },
1414
+ {
1415
+ x1: "333.75",
1416
+ x2: "333.75",
1417
+ y1: "75.77777777777779",
1418
+ y2: "48.555555555555564",
1419
+ },
1420
+ {
1421
+ x1: "328.75",
1422
+ x2: "338.75",
1423
+ y1: "75.77777777777779",
1424
+ y2: "75.77777777777779",
1425
+ },
1426
+ {
1427
+ x1: "436.25",
1428
+ x2: "446.25",
1429
+ y1: "86.66666666666666",
1430
+ y2: "86.66666666666666",
1431
+ },
1432
+ {
1433
+ x1: "441.25",
1434
+ x2: "441.25",
1435
+ y1: "127.5",
1436
+ y2: "86.66666666666666",
1437
+ },
1438
+ {
1439
+ x1: "436.25",
1440
+ x2: "446.25",
1441
+ y1: "127.5",
1442
+ y2: "127.5",
1443
+ },
1444
+ ]);
1445
+ });
1446
+ });
1447
+
1448
+ describe("extending YAxis domain when data is defined on the graphical item", () => {
1449
+ const [withError, setWithError] = createSignal(false);
1450
+ const renderTestCase = createSelectorTestCase((props) => (
1451
+ <LineChart width={500} height={500}>
1452
+ <YAxis dataKey="uv" />
1453
+ <Line isAnimationActive={false} dataKey="uv" data={dataWithError}>
1454
+ <Show when={withError()}>
1455
+ <ErrorBar dataKey="uvError" />
1456
+ </Show>
1457
+ </Line>
1458
+ {props.children}
1459
+ </LineChart>
1460
+ ));
1461
+
1462
+ test("selectAxisDomainIncludingNiceTicks", () => {
1463
+ setWithError(false);
1464
+ const { spy } = renderTestCase((state: RechartsRootState) =>
1465
+ selectAxisDomainIncludingNiceTicks(state, "yAxis", 0, useIsPanorama()),
1466
+ );
1467
+ expect(spy).toHaveBeenCalledWith([0, 3400]);
1468
+
1469
+ setWithError(true);
1470
+ flush();
1471
+
1472
+ expect(spy).toHaveBeenLastCalledWith([0, 3600]);
1473
+ });
1474
+
1475
+ test("YAxis ticks", () => {
1476
+ setWithError(false);
1477
+ const { container } = renderTestCase();
1478
+
1479
+ expectYAxisTicks(container, [
1480
+ {
1481
+ textContent: "0",
1482
+ x: "57",
1483
+ y: "495",
1484
+ },
1485
+ {
1486
+ textContent: "850",
1487
+ x: "57",
1488
+ y: "372.5",
1489
+ },
1490
+ {
1491
+ textContent: "1700",
1492
+ x: "57",
1493
+ y: "250",
1494
+ },
1495
+ {
1496
+ textContent: "2550",
1497
+ x: "57",
1498
+ y: "127.5",
1499
+ },
1500
+ {
1501
+ textContent: "3400",
1502
+ x: "57",
1503
+ y: "5",
1504
+ },
1505
+ ]);
1506
+
1507
+ setWithError(true);
1508
+ flush();
1509
+
1510
+ expectYAxisTicks(container, [
1511
+ {
1512
+ textContent: "0",
1513
+ x: "57",
1514
+ y: "495",
1515
+ },
1516
+ {
1517
+ textContent: "900",
1518
+ x: "57",
1519
+ y: "372.5",
1520
+ },
1521
+ {
1522
+ textContent: "1800",
1523
+ x: "57",
1524
+ y: "250",
1525
+ },
1526
+ {
1527
+ textContent: "2700",
1528
+ x: "57",
1529
+ y: "127.5",
1530
+ },
1531
+ {
1532
+ textContent: "3600",
1533
+ x: "57",
1534
+ y: "5",
1535
+ },
1536
+ ]);
1537
+ });
1538
+
1539
+ test("should render ErrorBars", () => {
1540
+ setWithError(false);
1541
+ const { container } = renderTestCase();
1542
+
1543
+ expectErrorBars(container, []);
1544
+
1545
+ setWithError(true);
1546
+ flush();
1547
+
1548
+ expectErrorBars(container, [
1549
+ {
1550
+ x1: "60",
1551
+ x2: "70",
1552
+ y1: "215.97222222222223",
1553
+ y2: "215.97222222222223",
1554
+ },
1555
+ {
1556
+ x1: "65",
1557
+ x2: "65",
1558
+ y1: "236.38888888888889",
1559
+ y2: "215.97222222222223",
1560
+ },
1561
+ {
1562
+ x1: "60",
1563
+ x2: "70",
1564
+ y1: "236.38888888888889",
1565
+ y2: "236.38888888888889",
1566
+ },
1567
+ {
1568
+ x1: "203.33333333333334",
1569
+ x2: "213.33333333333334",
1570
+ y1: "26.777777777777754",
1571
+ y2: "26.777777777777754",
1572
+ },
1573
+ {
1574
+ x1: "208.33333333333334",
1575
+ x2: "208.33333333333334",
1576
+ y1: "62.16666666666668",
1577
+ y2: "26.777777777777754",
1578
+ },
1579
+ {
1580
+ x1: "203.33333333333334",
1581
+ x2: "213.33333333333334",
1582
+ y1: "62.16666666666668",
1583
+ y2: "62.16666666666668",
1584
+ },
1585
+ {
1586
+ x1: "346.6666666666667",
1587
+ x2: "356.6666666666667",
1588
+ y1: "48.555555555555564",
1589
+ y2: "48.555555555555564",
1590
+ },
1591
+ {
1592
+ x1: "351.6666666666667",
1593
+ x2: "351.6666666666667",
1594
+ y1: "75.77777777777779",
1595
+ y2: "48.555555555555564",
1596
+ },
1597
+ {
1598
+ x1: "346.6666666666667",
1599
+ x2: "356.6666666666667",
1600
+ y1: "75.77777777777779",
1601
+ y2: "75.77777777777779",
1602
+ },
1603
+ {
1604
+ x1: "490",
1605
+ x2: "500",
1606
+ y1: "86.66666666666666",
1607
+ y2: "86.66666666666666",
1608
+ },
1609
+ {
1610
+ x1: "495",
1611
+ x2: "495",
1612
+ y1: "127.5",
1613
+ y2: "86.66666666666666",
1614
+ },
1615
+ {
1616
+ x1: "490",
1617
+ x2: "500",
1618
+ y1: "127.5",
1619
+ y2: "127.5",
1620
+ },
1621
+ ]);
1622
+ });
1623
+ });
1624
+
1625
+ describe("extending YAxis domain for ranged Bar values", () => {
1626
+ type BoxPlotDatum = {
1627
+ category: string;
1628
+ min: number;
1629
+ q1: number;
1630
+ q3: number;
1631
+ max: number;
1632
+ };
1633
+
1634
+ const boxPlotData: ReadonlyArray<BoxPlotDatum> = [
1635
+ { category: "A", min: 16, q1: 20, q3: 29, max: 35 },
1636
+ { category: "B", min: 12, q1: 15, q3: 21, max: 27 },
1637
+ { category: "C", min: 22, q1: 26, q3: 34, max: 39 },
1638
+ { category: "D", min: 9, q1: 13, q3: 20, max: 26 },
1639
+ ];
1640
+
1641
+ const boxDataKey = (entry: BoxPlotDatum): [number, number] => [entry.q1, entry.q3];
1642
+ const whiskerDataKey = (entry: BoxPlotDatum): [number, number] => [
1643
+ entry.q3 - entry.min,
1644
+ entry.max - entry.q3,
1645
+ ];
1646
+
1647
+ // Two static renders (without/with ErrorBar) + unmount between — avoids the dynamic-mount NO_OWNER artifact.
1648
+ const renderWithoutError = createSelectorTestCase((props) => (
1649
+ <BarChart data={boxPlotData} width={500} height={500}>
1650
+ <YAxis />
1651
+ <Bar isAnimationActive={false} dataKey={boxDataKey} />
1652
+ {props.children}
1653
+ </BarChart>
1654
+ ));
1655
+ const renderWithError = createSelectorTestCase((props) => (
1656
+ <BarChart data={boxPlotData} width={500} height={500}>
1657
+ <YAxis />
1658
+ <Bar isAnimationActive={false} dataKey={boxDataKey}>
1659
+ <ErrorBar dataKey={whiskerDataKey} />
1660
+ </Bar>
1661
+ {props.children}
1662
+ </BarChart>
1663
+ ));
1664
+
1665
+ test("getErrorDomainByDataKey should support ranged bar values", () => {
1666
+ const errorDomain = getErrorDomainByDataKey(boxPlotData[0]!, boxDataKey(boxPlotData[0]!), [
1667
+ { direction: "y", dataKey: whiskerDataKey },
1668
+ ]);
1669
+ expect(errorDomain).toEqual([16, 35]);
1670
+ });
1671
+
1672
+ test("selectNumericalDomain should include error bars for ranged bars", () => {
1673
+ const { spy, unmount } = renderWithoutError((state: RechartsRootState) =>
1674
+ selectNumericalDomain(state, "yAxis", 0, false),
1675
+ );
1676
+
1677
+ expectLastCalledWith(spy, [0, 34]);
1678
+
1679
+ unmount();
1680
+ const { spy: spyWith } = renderWithError((state: RechartsRootState) =>
1681
+ selectNumericalDomain(state, "yAxis", 0, false),
1682
+ );
1683
+
1684
+ expectLastCalledWith(spyWith, [0, 39]);
1685
+ });
1686
+ });
1687
+
1688
+ describe("extending YAxis domain when Scatter has its own data (boxplot example)", () => {
1689
+ type BoxPlotDatum = {
1690
+ category: string;
1691
+ min: number;
1692
+ q1: number;
1693
+ q3: number;
1694
+ max: number;
1695
+ };
1696
+
1697
+ const boxPlotData: ReadonlyArray<BoxPlotDatum> = [
1698
+ { category: "A", min: 16, q1: 20, q3: 29, max: 35 },
1699
+ { category: "B", min: 12, q1: 15, q3: 21, max: 27 },
1700
+ { category: "C", min: 22, q1: 26, q3: 34, max: 39 },
1701
+ { category: "D", min: 9, q1: 13, q3: 20, max: 26 },
1702
+ ];
1703
+
1704
+ type OutlierDatum = {
1705
+ category: string;
1706
+ value: number;
1707
+ };
1708
+
1709
+ // All outlier values are within the box plot + ErrorBar range (max=39),
1710
+ // so the YAxis domain should remain [0, 39] driven by the Bar+ErrorBar.
1711
+ // The bug: when Scatter has its own data, selectDisplayedData returns ONLY the
1712
+ // Scatter outliers, ignoring Bar chart data entirely. The domain then becomes
1713
+ // [0, 25] (max of outliers) instead of the correct [0, 39].
1714
+ const outliers: ReadonlyArray<OutlierDatum> = [
1715
+ { category: "A", value: 10 },
1716
+ { category: "B", value: 5 },
1717
+ { category: "D", value: 25 },
1718
+ ];
1719
+
1720
+ const boxDataKey = (entry: BoxPlotDatum): [number, number] => [entry.q1, entry.q3];
1721
+ const whiskerDataKey = (entry: BoxPlotDatum): [number, number] => [
1722
+ entry.q3 - entry.min,
1723
+ entry.max - entry.q3,
1724
+ ];
1725
+
1726
+ const renderWithScatter = createSelectorTestCase((props) => (
1727
+ <BarChart data={boxPlotData} width={500} height={500}>
1728
+ <YAxis />
1729
+ <Bar isAnimationActive={false} dataKey={boxDataKey}>
1730
+ <ErrorBar dataKey={whiskerDataKey} />
1731
+ </Bar>
1732
+ <Scatter data={outliers} dataKey="value" />
1733
+ {props.children}
1734
+ </BarChart>
1735
+ ));
1736
+
1737
+ test("selectNumericalDomain should cover Bar+ErrorBar range even when Scatter has its own data", () => {
1738
+ const { spy } = renderWithScatter((state: RechartsRootState) =>
1739
+ selectNumericalDomain(state, "yAxis", 0, false),
1740
+ );
1741
+
1742
+ // Bar q1/q3 range + ErrorBar extending to min/max: C.max=39 is the highest value.
1743
+ // Scatter outliers are all within that range (max=25 < 39).
1744
+ // Therefore the domain should be [0, 39], not [0, 25].
1745
+ expectLastCalledWith(spy, [0, 39]);
1746
+ });
1747
+ });
1748
+
1749
+ describe("extending XAxis domain", () => {
1750
+ // Two static renders (without/with ErrorBar) + unmount between — avoids the dynamic-mount NO_OWNER artifact.
1751
+ const renderWithoutError = createSelectorTestCase((props) => (
1752
+ <BarChart data={dataWithError} width={500} height={500} layout="vertical">
1753
+ <XAxis dataKey="uv" type="number" />
1754
+ <Bar isAnimationActive={false} dataKey="uv" />
1755
+ <YAxis type="category" />
1756
+ {props.children}
1757
+ </BarChart>
1758
+ ));
1759
+ const renderWithError = createSelectorTestCase((props) => (
1760
+ <BarChart data={dataWithError} width={500} height={500} layout="vertical">
1761
+ <XAxis dataKey="uv" type="number" />
1762
+ <Bar isAnimationActive={false} dataKey="uv">
1763
+ <ErrorBar isAnimationActive animationEasing="linear" dataKey="uvError" />
1764
+ </Bar>
1765
+ <YAxis type="category" />
1766
+ {props.children}
1767
+ </BarChart>
1768
+ ));
1769
+
1770
+ test("selectAxisDomainIncludingNiceTicks", () => {
1771
+ const { spy, unmount } = renderWithoutError((state: RechartsRootState) =>
1772
+ selectAxisDomainIncludingNiceTicks(state, "xAxis", 0, useIsPanorama()),
1773
+ );
1774
+ expect(spy).toHaveBeenCalledWith([0, 3400]);
1775
+
1776
+ unmount();
1777
+ const { spy: spyWith } = renderWithError((state: RechartsRootState) =>
1778
+ selectAxisDomainIncludingNiceTicks(state, "xAxis", 0, useIsPanorama()),
1779
+ );
1780
+
1781
+ expect(spyWith).toHaveBeenLastCalledWith([0, 3600]);
1782
+ });
1783
+
1784
+ test("XAxis ticks", () => {
1785
+ const { container, unmount } = renderWithoutError();
1786
+
1787
+ expectXAxisTicks(container, [
1788
+ {
1789
+ textContent: "0",
1790
+ x: "65",
1791
+ y: "473",
1792
+ },
1793
+ {
1794
+ textContent: "850",
1795
+ x: "172.5",
1796
+ y: "473",
1797
+ },
1798
+ {
1799
+ textContent: "1700",
1800
+ x: "280",
1801
+ y: "473",
1802
+ },
1803
+ {
1804
+ textContent: "2550",
1805
+ x: "387.5",
1806
+ y: "473",
1807
+ },
1808
+ {
1809
+ textContent: "3400",
1810
+ x: "495",
1811
+ y: "473",
1812
+ },
1813
+ ]);
1814
+
1815
+ unmount();
1816
+ const { container: containerWith } = renderWithError();
1817
+
1818
+ expectXAxisTicks(containerWith, [
1819
+ {
1820
+ textContent: "0",
1821
+ x: "65",
1822
+ y: "473",
1823
+ },
1824
+ {
1825
+ textContent: "900",
1826
+ x: "172.5",
1827
+ y: "473",
1828
+ },
1829
+ {
1830
+ textContent: "1800",
1831
+ x: "280",
1832
+ y: "473",
1833
+ },
1834
+ {
1835
+ textContent: "2700",
1836
+ x: "387.5",
1837
+ y: "473",
1838
+ },
1839
+ {
1840
+ textContent: "3600",
1841
+ x: "495",
1842
+ y: "473",
1843
+ },
1844
+ ]);
1845
+ });
1846
+
1847
+ test("should render bars", () => {
1848
+ const { container, unmount } = renderWithoutError();
1849
+
1850
+ expectBars(container, [
1851
+ {
1852
+ d: "M 65,16.5 h 252.9412 v 92 h -252.9412 Z",
1853
+ height: "92",
1854
+ radius: "0",
1855
+ width: "252.9412",
1856
+ x: "65",
1857
+ y: "16.5",
1858
+ },
1859
+ {
1860
+ d: "M 65,131.5 h 417.3529 v 92 h -417.3529 Z",
1861
+ height: "92",
1862
+ radius: "0",
1863
+ width: "417.3529",
1864
+ x: "65",
1865
+ y: "131.5",
1866
+ },
1867
+ {
1868
+ d: "M 65,246.5 h 404.7059 v 92 h -404.7059 Z",
1869
+ height: "92",
1870
+ radius: "0",
1871
+ width: "404.7059",
1872
+ x: "65",
1873
+ y: "246.5",
1874
+ },
1875
+ {
1876
+ d: "M 65,361.5 h 354.1176 v 92 h -354.1176 Z",
1877
+ height: "92",
1878
+ radius: "0",
1879
+ width: "354.1176",
1880
+ x: "65",
1881
+ y: "361.5",
1882
+ },
1883
+ ]);
1884
+
1885
+ unmount();
1886
+ const { container: containerWith } = renderWithError();
1887
+
1888
+ expectBars(containerWith, [
1889
+ {
1890
+ d: "M 65,16.5 h 238.8889 v 92 h -238.8889 Z",
1891
+ height: "92",
1892
+ radius: "0",
1893
+ width: "238.8889",
1894
+ x: "65",
1895
+ y: "16.5",
1896
+ },
1897
+ {
1898
+ d: "M 65,131.5 h 394.1667 v 92 h -394.1667 Z",
1899
+ height: "92",
1900
+ radius: "0",
1901
+ width: "394.1667",
1902
+ x: "65",
1903
+ y: "131.5",
1904
+ },
1905
+ {
1906
+ d: "M 65,246.5 h 382.2222 v 92 h -382.2222 Z",
1907
+ height: "92",
1908
+ radius: "0",
1909
+ width: "382.2222",
1910
+ x: "65",
1911
+ y: "246.5",
1912
+ },
1913
+ {
1914
+ d: "M 65,361.5 h 334.4444 v 92 h -334.4444 Z",
1915
+ height: "92",
1916
+ radius: "0",
1917
+ width: "334.4444",
1918
+ x: "65",
1919
+ y: "361.5",
1920
+ },
1921
+ ]);
1922
+ });
1923
+
1924
+ test("should render ErrorBars", () => {
1925
+ const { container, unmount } = renderWithoutError();
1926
+
1927
+ expectErrorBars(container, []);
1928
+
1929
+ unmount();
1930
+ const { container: containerWith } = renderWithError();
1931
+
1932
+ expectErrorBars(containerWith, [
1933
+ {
1934
+ x1: "309.8611111111111",
1935
+ x2: "309.8611111111111",
1936
+ y1: "67.5",
1937
+ y2: "57.5",
1938
+ },
1939
+ {
1940
+ x1: "291.94444444444446",
1941
+ x2: "309.8611111111111",
1942
+ y1: "62.5",
1943
+ y2: "62.5",
1944
+ },
1945
+ {
1946
+ x1: "291.94444444444446",
1947
+ x2: "291.94444444444446",
1948
+ y1: "67.5",
1949
+ y2: "57.5",
1950
+ },
1951
+ {
1952
+ x1: "475.8888888888889",
1953
+ x2: "475.8888888888889",
1954
+ y1: "182.5",
1955
+ y2: "172.5",
1956
+ },
1957
+ {
1958
+ x1: "444.8333333333333",
1959
+ x2: "475.8888888888889",
1960
+ y1: "177.5",
1961
+ y2: "177.5",
1962
+ },
1963
+ {
1964
+ x1: "444.8333333333333",
1965
+ x2: "444.8333333333333",
1966
+ y1: "182.5",
1967
+ y2: "172.5",
1968
+ },
1969
+ {
1970
+ x1: "456.77777777777777",
1971
+ x2: "456.77777777777777",
1972
+ y1: "297.5",
1973
+ y2: "287.5",
1974
+ },
1975
+ {
1976
+ x1: "432.8888888888889",
1977
+ x2: "456.77777777777777",
1978
+ y1: "292.5",
1979
+ y2: "292.5",
1980
+ },
1981
+ {
1982
+ x1: "432.8888888888889",
1983
+ x2: "432.8888888888889",
1984
+ y1: "297.5",
1985
+ y2: "287.5",
1986
+ },
1987
+ {
1988
+ x1: "423.3333333333333",
1989
+ x2: "423.3333333333333",
1990
+ y1: "412.5",
1991
+ y2: "402.5",
1992
+ },
1993
+ {
1994
+ x1: "387.5",
1995
+ x2: "423.3333333333333",
1996
+ y1: "407.5",
1997
+ y2: "407.5",
1998
+ },
1999
+ {
2000
+ x1: "387.5",
2001
+ x2: "387.5",
2002
+ y1: "412.5",
2003
+ y2: "402.5",
2004
+ },
2005
+ ]);
2006
+ });
2007
+ });
2008
+
2009
+ describe("extending XAxis domain when data is defined on the graphical item", () => {
2010
+ const [withError, setWithError] = createSignal(false);
2011
+ const renderTestCase = createSelectorTestCase((props) => (
2012
+ <LineChart width={500} height={500}>
2013
+ <XAxis dataKey="uv" type="number" />
2014
+ <Line isAnimationActive={false} dataKey="uv" data={dataWithError}>
2015
+ <Show when={withError()}>
2016
+ <ErrorBar dataKey="uvError" direction="x" />
2017
+ </Show>
2018
+ </Line>
2019
+ {props.children}
2020
+ </LineChart>
2021
+ ));
2022
+
2023
+ test("selectAxisDomainIncludingNiceTicks", () => {
2024
+ setWithError(false);
2025
+ const { spy } = renderTestCase((state: RechartsRootState) =>
2026
+ selectAxisDomainIncludingNiceTicks(state, "xAxis", 0, useIsPanorama()),
2027
+ );
2028
+ expect(spy).toHaveBeenCalledWith([0, 3400]);
2029
+
2030
+ setWithError(true);
2031
+ flush();
2032
+
2033
+ expect(spy).toHaveBeenLastCalledWith([0, 3600]);
2034
+ });
2035
+
2036
+ test("XAxis ticks", () => {
2037
+ setWithError(false);
2038
+ const { container } = renderTestCase();
2039
+
2040
+ expectXAxisTicks(container, [
2041
+ {
2042
+ textContent: "0",
2043
+ x: "5",
2044
+ y: "473",
2045
+ },
2046
+ {
2047
+ textContent: "850",
2048
+ x: "127.5",
2049
+ y: "473",
2050
+ },
2051
+ {
2052
+ textContent: "1700",
2053
+ x: "250",
2054
+ y: "473",
2055
+ },
2056
+ {
2057
+ textContent: "2550",
2058
+ x: "372.5",
2059
+ y: "473",
2060
+ },
2061
+ {
2062
+ textContent: "3400",
2063
+ x: "495",
2064
+ y: "473",
2065
+ },
2066
+ ]);
2067
+
2068
+ setWithError(true);
2069
+ flush();
2070
+
2071
+ expectXAxisTicks(container, [
2072
+ {
2073
+ textContent: "0",
2074
+ x: "5",
2075
+ y: "473",
2076
+ },
2077
+ {
2078
+ textContent: "900",
2079
+ x: "127.5",
2080
+ y: "473",
2081
+ },
2082
+ {
2083
+ textContent: "1800",
2084
+ x: "250",
2085
+ y: "473",
2086
+ },
2087
+ {
2088
+ textContent: "2700",
2089
+ x: "372.5",
2090
+ y: "473",
2091
+ },
2092
+ {
2093
+ textContent: "3600",
2094
+ x: "495",
2095
+ y: "473",
2096
+ },
2097
+ ]);
2098
+ });
2099
+
2100
+ test("should render ErrorBars", () => {
2101
+ setWithError(false);
2102
+ const { container } = renderTestCase();
2103
+
2104
+ expectErrorBars(container, []);
2105
+
2106
+ setWithError(true);
2107
+ flush();
2108
+
2109
+ expectErrorBars(container, [
2110
+ {
2111
+ x1: "284.02777777777777",
2112
+ x2: "284.02777777777777",
2113
+ y1: "199.41176470588235",
2114
+ y2: "189.41176470588235",
2115
+ },
2116
+ {
2117
+ x1: "263.6111111111111",
2118
+ x2: "284.02777777777777",
2119
+ y1: "194.41176470588235",
2120
+ y2: "194.41176470588235",
2121
+ },
2122
+ {
2123
+ x1: "263.6111111111111",
2124
+ x2: "263.6111111111111",
2125
+ y1: "199.41176470588235",
2126
+ y2: "189.41176470588235",
2127
+ },
2128
+ {
2129
+ x1: "473.22222222222223",
2130
+ x2: "473.22222222222223",
2131
+ y1: "23.529411764705884",
2132
+ y2: "13.529411764705884",
2133
+ },
2134
+ {
2135
+ x1: "437.8333333333333",
2136
+ x2: "473.22222222222223",
2137
+ y1: "18.529411764705884",
2138
+ y2: "18.529411764705884",
2139
+ },
2140
+ {
2141
+ x1: "437.8333333333333",
2142
+ x2: "437.8333333333333",
2143
+ y1: "23.529411764705884",
2144
+ y2: "13.529411764705884",
2145
+ },
2146
+ {
2147
+ x1: "451.44444444444446",
2148
+ x2: "451.44444444444446",
2149
+ y1: "37.05882352941177",
2150
+ y2: "27.058823529411768",
2151
+ },
2152
+ {
2153
+ x1: "424.22222222222223",
2154
+ x2: "451.44444444444446",
2155
+ y1: "32.05882352941177",
2156
+ y2: "32.05882352941177",
2157
+ },
2158
+ {
2159
+ x1: "424.22222222222223",
2160
+ x2: "424.22222222222223",
2161
+ y1: "37.05882352941177",
2162
+ y2: "27.058823529411768",
2163
+ },
2164
+ {
2165
+ x1: "413.3333333333333",
2166
+ x2: "413.3333333333333",
2167
+ y1: "91.1764705882353",
2168
+ y2: "81.1764705882353",
2169
+ },
2170
+ {
2171
+ x1: "372.5",
2172
+ x2: "413.3333333333333",
2173
+ y1: "86.1764705882353",
2174
+ y2: "86.1764705882353",
2175
+ },
2176
+ {
2177
+ x1: "372.5",
2178
+ x2: "372.5",
2179
+ y1: "91.1764705882353",
2180
+ y2: "81.1764705882353",
2181
+ },
2182
+ ]);
2183
+ });
2184
+ });
2185
+
2186
+ describe("should extend domains to negative values", () => {
2187
+ const data = [
2188
+ { x: 100, y: 200, errorY: 30, errorX: 30 },
2189
+ { x: 120, y: 100, errorY: [500, 30], errorX: [200, 30] },
2190
+ { x: 170, y: 300, errorY: [10, 20], errorX: 20 },
2191
+ { x: 140, y: 250, errorY: 30, errorX: 20 },
2192
+ { x: 150, y: 400, errorY: [20, 300], errorX: 30 },
2193
+ { x: 110, y: 280, errorY: 40, errorX: 40 },
2194
+ ];
2195
+ const renderTestCase = createSelectorTestCase((props) => (
2196
+ <ScatterChart
2197
+ width={400}
2198
+ height={400}
2199
+ margin={{
2200
+ top: 20,
2201
+ right: 20,
2202
+ bottom: 20,
2203
+ left: 20,
2204
+ }}
2205
+ >
2206
+ <XAxis type="number" dataKey="x" />
2207
+ <YAxis type="number" dataKey="y" />
2208
+ <Scatter data={data}>
2209
+ <ErrorBar dataKey="errorX" direction="x" />
2210
+ <ErrorBar dataKey="errorY" direction="y" />
2211
+ </Scatter>
2212
+ {props.children}
2213
+ </ScatterChart>
2214
+ ));
2215
+
2216
+ it("should select XAxis domain", () => {
2217
+ const { spy } = renderTestCase((state: RechartsRootState) =>
2218
+ selectNumericalDomain(state, "xAxis", 0, false),
2219
+ );
2220
+ // lowest X is 120, with 200 error on the left, so -80
2221
+ // highest X is 170, with 20 error on the right, so 190
2222
+ expectLastCalledWith(spy, [-80, 190]);
2223
+ });
2224
+
2225
+ it("should select YAxis domain", () => {
2226
+ const { spy } = renderTestCase((state: RechartsRootState) =>
2227
+ selectNumericalDomain(state, "yAxis", 0, false),
2228
+ );
2229
+ // lowest Y is 100, with 500 error on the bottom, so -400
2230
+ // highest Y is 400, with 300 error on the top, so 700
2231
+ expectLastCalledWith(spy, [-400, 700]);
2232
+ });
2233
+
2234
+ it("should render XAxis ticks", () => {
2235
+ const { container } = renderTestCase();
2236
+ expectXAxisTicks(container, [
2237
+ {
2238
+ textContent: "-80",
2239
+ x: "80",
2240
+ y: "358",
2241
+ },
2242
+ {
2243
+ textContent: "0",
2244
+ x: "155",
2245
+ y: "358",
2246
+ },
2247
+ {
2248
+ textContent: "80",
2249
+ x: "230",
2250
+ y: "358",
2251
+ },
2252
+ {
2253
+ textContent: "160",
2254
+ x: "305",
2255
+ y: "358",
2256
+ },
2257
+ {
2258
+ textContent: "240",
2259
+ x: "380",
2260
+ y: "358",
2261
+ },
2262
+ ]);
2263
+ });
2264
+
2265
+ it("should render YAxis ticks", () => {
2266
+ const { container } = renderTestCase();
2267
+ expectYAxisTicks(container, [
2268
+ {
2269
+ textContent: "-700",
2270
+ x: "72",
2271
+ y: "350",
2272
+ },
2273
+ {
2274
+ textContent: "-350",
2275
+ x: "72",
2276
+ y: "267.5",
2277
+ },
2278
+ {
2279
+ textContent: "0",
2280
+ x: "72",
2281
+ y: "185",
2282
+ },
2283
+ {
2284
+ textContent: "350",
2285
+ x: "72",
2286
+ y: "102.5",
2287
+ },
2288
+ {
2289
+ textContent: "700",
2290
+ x: "72",
2291
+ y: "20",
2292
+ },
2293
+ ]);
2294
+ });
2295
+ });
2296
+ });
2297
+
2298
+ // Ported from recharts: ErrorBar whisker animation (CSS transform scale 0→1).
2299
+ it("Renders Error Bars with animation delay", async () => {
2300
+ const registry = createManagerRegistry();
2301
+ const { container } = render(() => (
2302
+ <AnimationControllerProvider value={registry.controller}>
2303
+ <BarChart data={dataWithError} width={500} height={500}>
2304
+ <Bar isAnimationActive={false} dataKey="uv">
2305
+ <ErrorBar isAnimationActive begin={200} dataKey="uvError" />
2306
+ </Bar>
2307
+ </BarChart>
2308
+ </AnimationControllerProvider>
2309
+ ));
2310
+ flush();
2311
+
2312
+ await registry.completeAll();
2313
+ flush();
2314
+
2315
+ expectErrorBars(container, expectedErrorBars);
2316
+ assertAnimationStyles(container, true, {
2317
+ transition: "transform 400ms ease-in-out",
2318
+ transform: "scaleY(1)",
2319
+ });
2320
+
2321
+ // The bare `begin` SVG attribute rides through to the whisker group
2322
+ // (recharts `Props = SVGProps & ErrorBarProps` passthrough).
2323
+ const errorBars = container.querySelectorAll(".recharts-errorBar");
2324
+ expect(errorBars.length).toBeGreaterThan(0);
2325
+ errorBars.forEach((bar) => {
2326
+ expect(bar.getAttribute("begin")).toBe("200");
2327
+ });
2328
+ });
2329
+
2330
+ it("Renders Error Bars with animation", async () => {
2331
+ const registry = createManagerRegistry();
2332
+ const { container } = render(() => (
2333
+ <AnimationControllerProvider value={registry.controller}>
2334
+ <BarChart data={dataWithError} width={500} height={500}>
2335
+ <Bar isAnimationActive={false} dataKey="uv">
2336
+ <ErrorBar isAnimationActive dataKey="uvError" />
2337
+ </Bar>
2338
+ </BarChart>
2339
+ </AnimationControllerProvider>
2340
+ ));
2341
+ flush();
2342
+
2343
+ await registry.completeAll();
2344
+ flush();
2345
+
2346
+ expectErrorBars(container, expectedErrorBars);
2347
+ assertAnimationStyles(container, true, {
2348
+ transition: "transform 400ms ease-in-out",
2349
+ transform: "scaleY(1)",
2350
+ });
2351
+ });
2352
+
2353
+ it("Renders Error Bars without animation", () => {
2354
+ const { container } = render(() => (
2355
+ <BarChart data={dataWithError} width={500} height={500}>
2356
+ <Bar isAnimationActive={false} dataKey="uv">
2357
+ <ErrorBar isAnimationActive={false} dataKey="uvError" />
2358
+ </Bar>
2359
+ </BarChart>
2360
+ ));
2361
+ flush();
2362
+
2363
+ expectErrorBars(container, expectedErrorBars);
2364
+ assertAnimationStyles(container, false, {
2365
+ transform: "scaleY(1)",
2366
+ });
2367
+ });
2368
+
2369
+ it("Renders Error Bars with animation duration", async () => {
2370
+ const registry = createManagerRegistry();
2371
+ const { container } = render(() => (
2372
+ <AnimationControllerProvider value={registry.controller}>
2373
+ <BarChart data={dataWithError} width={500} height={500}>
2374
+ <Bar isAnimationActive={false} dataKey="uv">
2375
+ <ErrorBar isAnimationActive animationDuration={400} dataKey="uvError" />
2376
+ </Bar>
2377
+ </BarChart>
2378
+ </AnimationControllerProvider>
2379
+ ));
2380
+ flush();
2381
+
2382
+ await registry.completeAll();
2383
+ flush();
2384
+
2385
+ expectErrorBars(container, expectedErrorBars);
2386
+ assertAnimationStyles(container, true, {
2387
+ transition: "transform 400ms ease-in-out",
2388
+ transform: "scaleY(1)",
2389
+ });
2390
+ });
2391
+
2392
+ it("Renders Error Bars with animation easing", async () => {
2393
+ const registry = createManagerRegistry();
2394
+ const { container } = render(() => (
2395
+ <AnimationControllerProvider value={registry.controller}>
2396
+ <BarChart data={dataWithError} width={500} height={500}>
2397
+ <Bar isAnimationActive={false} dataKey="uv">
2398
+ <ErrorBar isAnimationActive animationEasing="linear" dataKey="uvError" />
2399
+ </Bar>
2400
+ </BarChart>
2401
+ </AnimationControllerProvider>
2402
+ ));
2403
+ flush();
2404
+
2405
+ await registry.completeAll();
2406
+ flush();
2407
+
2408
+ expectErrorBars(container, expectedErrorBars);
2409
+ assertAnimationStyles(container, true, {
2410
+ transition: "transform 400ms linear",
2411
+ transform: "scaleY(1)",
2412
+ });
2413
+ });
2414
+ });