solid-recharts 0.2.1 → 1.0.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 (488) hide show
  1. package/package.json +13 -11
  2. package/src/animation/AnimatedItems.tsx +2 -4
  3. package/src/animation/CSSTransitionAnimate.tsx +41 -39
  4. package/src/animation/JavascriptAnimate.tsx +45 -41
  5. package/src/cartesian/Area.tsx +4 -4
  6. package/src/cartesian/AreaRevealShape.tsx +1 -1
  7. package/src/cartesian/Bar.tsx +33 -21
  8. package/src/cartesian/BarStack.tsx +5 -5
  9. package/src/cartesian/Brush.tsx +19 -15
  10. package/src/cartesian/CartesianAxis.tsx +4 -4
  11. package/src/cartesian/CartesianGrid.tsx +5 -5
  12. package/src/cartesian/ErrorBar.tsx +9 -7
  13. package/src/cartesian/Funnel.tsx +3 -3
  14. package/src/cartesian/GraphicalItemClipPath.tsx +1 -1
  15. package/src/cartesian/Line.tsx +18 -16
  16. package/src/cartesian/LineDrawShape.tsx +14 -13
  17. package/src/cartesian/ReferenceArea.tsx +4 -4
  18. package/src/cartesian/ReferenceDot.tsx +4 -4
  19. package/src/cartesian/ReferenceLine.tsx +4 -4
  20. package/src/cartesian/RenderedTicksReporter.tsx +19 -17
  21. package/src/cartesian/Scatter.tsx +3 -3
  22. package/src/cartesian/XAxis.tsx +1 -1
  23. package/src/cartesian/YAxis.tsx +35 -33
  24. package/src/cartesian/ZAxis.tsx +3 -2
  25. package/src/chart/AreaChart.tsx +1 -1
  26. package/src/chart/BarChart.tsx +1 -1
  27. package/src/chart/CartesianChart.tsx +4 -3
  28. package/src/chart/CategoricalChart.tsx +5 -5
  29. package/src/chart/ComposedChart.tsx +1 -1
  30. package/src/chart/FunnelChart.tsx +1 -1
  31. package/src/chart/LineChart.tsx +1 -1
  32. package/src/chart/PieChart.tsx +4 -3
  33. package/src/chart/PolarChart.tsx +4 -3
  34. package/src/chart/RadarChart.tsx +4 -3
  35. package/src/chart/RadialBarChart.tsx +7 -3
  36. package/src/chart/RechartsWrapper.tsx +14 -24
  37. package/src/chart/Sankey.tsx +9 -6
  38. package/src/chart/ScatterChart.tsx +1 -1
  39. package/src/chart/SunburstChart.tsx +5 -4
  40. package/src/chart/Treemap.tsx +5 -4
  41. package/src/component/ActivePoints.tsx +6 -6
  42. package/src/component/Cell.tsx +23 -5
  43. package/src/component/Cursor.tsx +3 -3
  44. package/src/component/DefaultLegendContent.tsx +8 -6
  45. package/src/component/DefaultTooltipContent.tsx +14 -10
  46. package/src/component/Dots.tsx +5 -5
  47. package/src/component/Label.tsx +13 -10
  48. package/src/component/LabelList.tsx +12 -7
  49. package/src/component/Legend.tsx +26 -21
  50. package/src/component/ResponsiveContainer.tsx +52 -49
  51. package/src/component/Text.tsx +5 -5
  52. package/src/component/Tooltip.tsx +21 -18
  53. package/src/component/TooltipBoundingBox.tsx +18 -16
  54. package/src/component/responsiveContainerUtils.ts +1 -1
  55. package/src/container/ClipPathProvider.tsx +3 -3
  56. package/src/container/Layer.tsx +5 -5
  57. package/src/container/RootSurface.tsx +1 -1
  58. package/src/container/Surface.tsx +5 -6
  59. package/src/context/ErrorBarContext.tsx +2 -2
  60. package/src/context/PanoramaContext.tsx +2 -2
  61. package/src/context/RegisterGraphicalItemId.tsx +4 -2
  62. package/src/context/chartDataContext.tsx +26 -23
  63. package/src/context/chartLayoutContext.tsx +16 -12
  64. package/src/polar/Pie.tsx +13 -12
  65. package/src/polar/PolarAngleAxis.tsx +3 -3
  66. package/src/polar/PolarGrid.tsx +5 -5
  67. package/src/polar/PolarRadiusAxis.tsx +3 -3
  68. package/src/polar/Radar.tsx +3 -3
  69. package/src/polar/RadialBar.tsx +3 -3
  70. package/src/shape/Cross.tsx +5 -5
  71. package/src/shape/Curve.tsx +6 -7
  72. package/src/shape/Dot.tsx +4 -4
  73. package/src/shape/Polygon.tsx +5 -5
  74. package/src/shape/Rectangle.tsx +22 -20
  75. package/src/shape/Sector.tsx +5 -5
  76. package/src/shape/Symbols.tsx +5 -5
  77. package/src/shape/Trapezoid.tsx +29 -27
  78. package/src/state/RechartsStoreProvider.tsx +5 -3
  79. package/src/state/ReportChartProps.tsx +8 -6
  80. package/src/state/ReportEventSettings.tsx +8 -6
  81. package/src/state/ReportMainChartProps.tsx +11 -9
  82. package/src/state/ReportPolarOptions.tsx +15 -13
  83. package/src/state/SetLegendPayload.ts +1 -1
  84. package/src/state/SetTooltipEntrySettings.tsx +1 -1
  85. package/src/state/brushSlice.ts +10 -8
  86. package/src/state/cartesianAxisSlice.ts +46 -38
  87. package/src/state/chartDataSlice.ts +29 -23
  88. package/src/state/errorBarSlice.ts +22 -16
  89. package/src/state/eventSettingsSlice.ts +11 -9
  90. package/src/state/graphicalItemsSlice.ts +17 -13
  91. package/src/state/layoutSlice.ts +27 -19
  92. package/src/state/legendSlice.ts +24 -18
  93. package/src/state/optionsSlice.ts +8 -6
  94. package/src/state/polarAxisSlice.ts +21 -13
  95. package/src/state/polarOptionsSlice.ts +16 -14
  96. package/src/state/referenceElementsSlice.ts +25 -19
  97. package/src/state/registerInStore.ts +15 -13
  98. package/src/state/renderedTicksSlice.ts +11 -7
  99. package/src/state/rootPropsSlice.ts +16 -14
  100. package/src/state/tooltipSlice.ts +115 -95
  101. package/src/state/unregisterOnCleanup.ts +5 -20
  102. package/src/state/zIndexSlice.ts +50 -42
  103. package/src/synchronisation/useChartSynchronisation.tsx +213 -217
  104. package/src/util/ActiveShapeUtils.tsx +2 -2
  105. package/src/util/BarUtils.tsx +5 -3
  106. package/src/util/DirectPortal.tsx +107 -0
  107. package/src/util/FunnelUtils.tsx +1 -1
  108. package/src/util/RadialBarUtils.tsx +4 -3
  109. package/src/util/createCartesianCharts.tsx +1 -1
  110. package/src/util/createPolarCharts.tsx +1 -1
  111. package/src/util/svgPropertiesAndEvents.ts +1 -1
  112. package/src/util/tooltip/translate.ts +2 -2
  113. package/src/util/types.ts +2 -2
  114. package/src/zIndex/ZIndexLayer.tsx +39 -68
  115. package/src/zIndex/ZIndexPortal.tsx +29 -25
  116. package/test/_data.ts +0 -408
  117. package/test/animation/AnimationController.typed.spec.ts +0 -53
  118. package/test/animation/AnimationControllerImpl.spec.ts +0 -271
  119. package/test/animation/CSSTransitionAnimate.timing.spec.tsx +0 -473
  120. package/test/animation/JavascriptAnimate.spec.tsx +0 -62
  121. package/test/animation/RechartsAnimation.spec.ts +0 -636
  122. package/test/animation/easing.spec.ts +0 -218
  123. package/test/animation/legacyAnimationLengthChange.spec.tsx +0 -803
  124. package/test/animation/matchBy.spec.ts +0 -467
  125. package/test/animation/mockAnimationController.ts +0 -40
  126. package/test/animation/mockControllerAnimationManager.ts +0 -143
  127. package/test/animation/mockTimeoutController.ts +0 -114
  128. package/test/animation/timeoutController.spec.ts +0 -138
  129. package/test/animation/useAnimationStartSnapshot.spec.ts +0 -147
  130. package/test/animation/util.spec.ts +0 -28
  131. package/test/cartesian/Area.animation.spec.tsx +0 -363
  132. package/test/cartesian/Area.range.spec.tsx +0 -54
  133. package/test/cartesian/Area.spec.tsx +0 -1202
  134. package/test/cartesian/Area.stacked.render.spec.tsx +0 -69
  135. package/test/cartesian/Area.typed.spec.tsx +0 -209
  136. package/test/cartesian/Axis.integration.spec.tsx +0 -158
  137. package/test/cartesian/Bar/Bar.csstransition.spec.tsx +0 -299
  138. package/test/cartesian/Bar/Bar.spec.tsx +0 -2314
  139. package/test/cartesian/Bar/Bar.typed.spec.tsx +0 -192
  140. package/test/cartesian/Bar.animation.spec.tsx +0 -426
  141. package/test/cartesian/Bar.stackDomain.spec.tsx +0 -66
  142. package/test/cartesian/Bar.stacked.render.spec.tsx +0 -53
  143. package/test/cartesian/Bar.truncateByDomain.spec.tsx +0 -237
  144. package/test/cartesian/Bar.zeroDimensionFiltering.spec.tsx +0 -336
  145. package/test/cartesian/BarStack.spec.tsx +0 -91
  146. package/test/cartesian/Brush.keyboard.spec.tsx +0 -88
  147. package/test/cartesian/Brush.panorama.spec.tsx +0 -41
  148. package/test/cartesian/Brush.props.spec.tsx +0 -63
  149. package/test/cartesian/Brush.render.spec.tsx +0 -117
  150. package/test/cartesian/Brush.spec.tsx +0 -522
  151. package/test/cartesian/Brush.stacked.spec.tsx +0 -221
  152. package/test/cartesian/CartesianAxis.render.spec.tsx +0 -50
  153. package/test/cartesian/CartesianAxis.spec.tsx +0 -396
  154. package/test/cartesian/CartesianGrid.render.spec.tsx +0 -39
  155. package/test/cartesian/CartesianGrid.spec.tsx +0 -2103
  156. package/test/cartesian/ErrorBar.render.spec.tsx +0 -69
  157. package/test/cartesian/ErrorBar.spec.tsx +0 -2414
  158. package/test/cartesian/Funnel.animation.spec.tsx +0 -241
  159. package/test/cartesian/Funnel.spec.tsx +0 -226
  160. package/test/cartesian/Funnel.typed.spec.tsx +0 -221
  161. package/test/cartesian/GraphicalItemClipPath.scale-behavior.spec.tsx +0 -627
  162. package/test/cartesian/GraphicalItemClipPath.spec.tsx +0 -427
  163. package/test/cartesian/Line.animation.spec.tsx +0 -643
  164. package/test/cartesian/Line.sparseAnimationPath.spec.tsx +0 -98
  165. package/test/cartesian/Line.spec.tsx +0 -471
  166. package/test/cartesian/Line.typed.spec.tsx +0 -152
  167. package/test/cartesian/ReferenceArea.render.spec.tsx +0 -63
  168. package/test/cartesian/ReferenceArea.spec.tsx +0 -663
  169. package/test/cartesian/ReferenceArea.typed.spec.tsx +0 -74
  170. package/test/cartesian/ReferenceDot.render.spec.tsx +0 -55
  171. package/test/cartesian/ReferenceDot.spec.tsx +0 -462
  172. package/test/cartesian/ReferenceDot.typed.spec.tsx +0 -76
  173. package/test/cartesian/ReferenceLine/ReferenceLine.panorama.spec.tsx +0 -184
  174. package/test/cartesian/ReferenceLine/ReferenceLine.spec.tsx +0 -744
  175. package/test/cartesian/ReferenceLine/ReferenceLine.typed.spec.tsx +0 -74
  176. package/test/cartesian/ReferenceLine/getEndPoints.spec.ts +0 -399
  177. package/test/cartesian/ReferenceLine.render.spec.tsx +0 -134
  178. package/test/cartesian/Scatter.animation.spec.tsx +0 -381
  179. package/test/cartesian/Scatter.render.spec.tsx +0 -61
  180. package/test/cartesian/Scatter.spec.tsx +0 -406
  181. package/test/cartesian/Scatter.typed.spec.tsx +0 -153
  182. package/test/cartesian/XAxis/XAxis.barSize.spec.tsx +0 -336
  183. package/test/cartesian/XAxis/XAxis.brush.spec.tsx +0 -266
  184. package/test/cartesian/XAxis/XAxis.categorydomain.spec.tsx +0 -872
  185. package/test/cartesian/XAxis/XAxis.dataKey.spec.tsx +0 -86
  186. package/test/cartesian/XAxis/XAxis.datatypes.spec.tsx +0 -127
  187. package/test/cartesian/XAxis/XAxis.hide.spec.tsx +0 -106
  188. package/test/cartesian/XAxis/XAxis.multiaxis.spec.tsx +0 -336
  189. package/test/cartesian/XAxis/XAxis.numberdomain.spec.tsx +0 -1466
  190. package/test/cartesian/XAxis/XAxis.padding.spec.tsx +0 -758
  191. package/test/cartesian/XAxis/XAxis.padding_clip.spec.tsx +0 -65
  192. package/test/cartesian/XAxis/XAxis.state.spec.tsx +0 -355
  193. package/test/cartesian/XAxis/XAxis.tick.spec.tsx +0 -493
  194. package/test/cartesian/XAxis/XAxis.timescale.spec.tsx +0 -233
  195. package/test/cartesian/XAxis/XAxis.type.spec.tsx +0 -107
  196. package/test/cartesian/XAxis/XAxis.typed.spec.tsx +0 -102
  197. package/test/cartesian/XAxis/XAxis.vertical.spec.tsx +0 -265
  198. package/test/cartesian/XAxis.tickFormatter.spec.tsx +0 -54
  199. package/test/cartesian/YAxis/YAxis.7362.derivedDomain.spec.tsx +0 -230
  200. package/test/cartesian/YAxis/YAxis.7362.spec.tsx +0 -104
  201. package/test/cartesian/YAxis/YAxis.interval-zero.spec.tsx +0 -88
  202. package/test/cartesian/YAxis/YAxis.label.spec.tsx +0 -219
  203. package/test/cartesian/YAxis/YAxis.spec.tsx +0 -1595
  204. package/test/cartesian/YAxis/YAxis.tick.spec.tsx +0 -428
  205. package/test/cartesian/YAxis/YAxis.tickFormatter.spec.tsx +0 -54
  206. package/test/cartesian/YAxis/YAxis.ticks.spec.tsx +0 -263
  207. package/test/cartesian/YAxis/YAxis.type.spec.tsx +0 -107
  208. package/test/cartesian/YAxis/YAxis.typed.spec.tsx +0 -102
  209. package/test/cartesian/ZAxis.spec.tsx +0 -300
  210. package/test/cartesian/ZAxis.typed.spec.tsx +0 -33
  211. package/test/cartesian/__snapshots__/Brush.spec.tsx.snap +0 -5
  212. package/test/cartesian/axisLineAndStroke.spec.tsx +0 -72
  213. package/test/cartesian/getCartesianPosition.spec.ts +0 -907
  214. package/test/cartesian/getEquidistantTicks.spec.ts +0 -88
  215. package/test/cartesian/getTicks.spec.ts +0 -378
  216. package/test/cartesian/miscFeatureGaps.spec.tsx +0 -89
  217. package/test/cartesian/useAnimatedLineLength.spec.ts +0 -168
  218. package/test/chart/AccessibilityLayer.spec.tsx +0 -569
  219. package/test/chart/AccessibilityScans.spec.tsx +0 -286
  220. package/test/chart/AreaChart.spec.tsx +0 -409
  221. package/test/chart/AreaChart.stacked.spec.tsx +0 -1407
  222. package/test/chart/AreaChart.typed.spec.tsx +0 -39
  223. package/test/chart/BarChart.spec.tsx +0 -3719
  224. package/test/chart/BarChart.typed.spec.tsx +0 -60
  225. package/test/chart/CategoricalChart.spec.tsx +0 -255
  226. package/test/chart/ComposedChart.spec.tsx +0 -199
  227. package/test/chart/ComposedChart.typed.spec.tsx +0 -39
  228. package/test/chart/FunnelChart.spec.tsx +0 -215
  229. package/test/chart/FunnelChart.typed.spec.tsx +0 -39
  230. package/test/chart/LineChart.multiseries.spec.tsx +0 -50
  231. package/test/chart/LineChart.smoke.spec.tsx +0 -50
  232. package/test/chart/LineChart.spec.tsx +0 -930
  233. package/test/chart/LineChart.typed.spec.tsx +0 -39
  234. package/test/chart/NicheChartTooltip.spec.tsx +0 -81
  235. package/test/chart/PieChart.spec.tsx +0 -793
  236. package/test/chart/PieChart.typed.spec.tsx +0 -39
  237. package/test/chart/RadarChart.spec.tsx +0 -530
  238. package/test/chart/RadarChart.typed.spec.tsx +0 -39
  239. package/test/chart/RadialBarChart.5966.spec.tsx +0 -48
  240. package/test/chart/RadialBarChart.spec.tsx +0 -679
  241. package/test/chart/RadialBarChart.typed.spec.tsx +0 -39
  242. package/test/chart/RechartsWrapper.spec.tsx +0 -83
  243. package/test/chart/Sankey.content.spec.tsx +0 -46
  244. package/test/chart/Sankey.spec.tsx +0 -952
  245. package/test/chart/Sankey.typed.spec.tsx +0 -29
  246. package/test/chart/ScatterChart.spec.tsx +0 -2613
  247. package/test/chart/ScatterChart.typed.spec.tsx +0 -39
  248. package/test/chart/SunburstChart.spec.tsx +0 -146
  249. package/test/chart/Treemap.animation.spec.tsx +0 -52
  250. package/test/chart/Treemap.spec.tsx +0 -1003
  251. package/test/chart/Treemap.typed.spec.tsx +0 -26
  252. package/test/chart/chartEvents.spec.tsx +0 -127
  253. package/test/chart/responsive.spec.tsx +0 -620
  254. package/test/component/Cell.render.spec.tsx +0 -155
  255. package/test/component/Cell.spec.tsx +0 -12
  256. package/test/component/Cursor.spec.tsx +0 -186
  257. package/test/component/DefaultTooltipContent.spec.tsx +0 -102
  258. package/test/component/Label.render.spec.tsx +0 -63
  259. package/test/component/Label.spec.tsx +0 -686
  260. package/test/component/Label.typed.spec.tsx +0 -46
  261. package/test/component/LabelList.spec.tsx +0 -188
  262. package/test/component/Legend.itemSorter.spec.tsx +0 -704
  263. package/test/component/Legend.render.spec.tsx +0 -92
  264. package/test/component/Legend.spec.tsx +0 -2213
  265. package/test/component/Legend.typed.spec.tsx +0 -22
  266. package/test/component/ResponsiveContainer.spec.tsx +0 -523
  267. package/test/component/ResponsiveContainerDataTest.spec.tsx +0 -51
  268. package/test/component/Text.spec.tsx +0 -415
  269. package/test/component/Text.typed.spec.tsx +0 -46
  270. package/test/component/Tooltip/ActiveDot.spec.tsx +0 -370
  271. package/test/component/Tooltip/Tooltip.animation.spec.tsx +0 -209
  272. package/test/component/Tooltip/Tooltip.content.spec.tsx +0 -128
  273. package/test/component/Tooltip/Tooltip.formatter.spec.tsx +0 -152
  274. package/test/component/Tooltip/Tooltip.includeHidden.spec.tsx +0 -79
  275. package/test/component/Tooltip/Tooltip.multipleDataArrays.spec.tsx +0 -165
  276. package/test/component/Tooltip/Tooltip.offset.spec.tsx +0 -113
  277. package/test/component/Tooltip/Tooltip.state.spec.tsx +0 -74
  278. package/test/component/Tooltip/Tooltip.sync.spec.tsx +0 -639
  279. package/test/component/Tooltip/defaultIndex.spec.tsx +0 -227
  280. package/test/component/Tooltip/graphicalItem.formatter.spec.tsx +0 -138
  281. package/test/component/Tooltip/itemSorter.spec.tsx +0 -2815
  282. package/test/component/Tooltip/tooltipEventType.spec.tsx +0 -344
  283. package/test/component/Tooltip/tooltipMouseHoverSelectors.ts +0 -41
  284. package/test/component/Tooltip/tooltipTestHelpers.tsx +0 -162
  285. package/test/component/Tooltip.defaultIndex.spec.tsx +0 -48
  286. package/test/component/Tooltip.hover.spec.tsx +0 -61
  287. package/test/component/Tooltip.item.spec.tsx +0 -54
  288. package/test/component/Tooltip.keyboard.spec.tsx +0 -51
  289. package/test/component/Tooltip.payload.spec.tsx +0 -1716
  290. package/test/component/Tooltip.touch.spec.tsx +0 -39
  291. package/test/component/Tooltip.visibility.spec.tsx +0 -1889
  292. package/test/component/TooltipBoundingBox.spec.tsx +0 -89
  293. package/test/component/responsiveContainerUtils.spec.ts +0 -205
  294. package/test/container/ClipPath.spec.tsx +0 -602
  295. package/test/container/chartDimensions.spec.tsx +0 -368
  296. package/test/context/chartLayoutContext.spec.tsx +0 -378
  297. package/test/helper/ExpectAxisDomain.tsx +0 -27
  298. package/test/helper/assertNotNull.ts +0 -6
  299. package/test/helper/assertZIndexLayerOrder.ts +0 -19
  300. package/test/helper/createSelectorTestCase.tsx +0 -176
  301. package/test/helper/expectAnimatedPieAngles.ts +0 -100
  302. package/test/helper/expectAnimatedPiePaths.ts +0 -78
  303. package/test/helper/expectAreaCurve.ts +0 -15
  304. package/test/helper/expectAxisTicks.ts +0 -48
  305. package/test/helper/expectBars.ts +0 -54
  306. package/test/helper/expectFunctionReturning.ts +0 -58
  307. package/test/helper/expectLabel.ts +0 -32
  308. package/test/helper/expectLastCalledWith.ts +0 -48
  309. package/test/helper/expectLine.ts +0 -20
  310. package/test/helper/expectPieSectors.ts +0 -80
  311. package/test/helper/expectScale.ts +0 -37
  312. package/test/helper/expectScatterPoints.ts +0 -52
  313. package/test/helper/expectStackGroups.ts +0 -144
  314. package/test/helper/mockAxes.ts +0 -22
  315. package/test/helper/mockGetBoundingClientRect.ts +0 -66
  316. package/test/helper/mockHTMLElementProperty.ts +0 -19
  317. package/test/helper/mockTouchingElement.ts +0 -27
  318. package/test/helper/offsetHelpers.ts +0 -19
  319. package/test/helper/parameterizedTestCases.tsx +0 -99
  320. package/test/helper/produceState.ts +0 -32
  321. package/test/helper/selectorTestHelpers.tsx +0 -63
  322. package/test/helper/trim.spec.ts +0 -35
  323. package/test/helper/trim.ts +0 -11
  324. package/test/hooks/useActiveTooltipDataPoints.spec.tsx +0 -358
  325. package/test/hooks/useAxisDomain.spec.tsx +0 -361
  326. package/test/hooks/useAxisScale.spec.tsx +0 -283
  327. package/test/hooks/useAxisTicks.spec.tsx +0 -130
  328. package/test/hooks/useOffset.spec.tsx +0 -248
  329. package/test/hooks/useTooltipStateHooks.spec.tsx +0 -109
  330. package/test/polar/Pie/Pie-TwoLevelPieChart.spec.tsx +0 -135
  331. package/test/polar/Pie/Pie.spec.tsx +0 -784
  332. package/test/polar/Pie/Pie.typed.spec.tsx +0 -78
  333. package/test/polar/Pie.animation.spec.tsx +0 -529
  334. package/test/polar/PieWithLegend.animation.spec.tsx +0 -142
  335. package/test/polar/PolarAngleAxis/PolarAngleAxis.events.spec.tsx +0 -76
  336. package/test/polar/PolarAngleAxis/PolarAngleAxis.spec.tsx +0 -2079
  337. package/test/polar/PolarAngleAxis/PolarAngleAxis.typed.spec.tsx +0 -102
  338. package/test/polar/PolarAngleAxis.render.spec.tsx +0 -79
  339. package/test/polar/PolarGrid.render.spec.tsx +0 -75
  340. package/test/polar/PolarGrid.spec.tsx +0 -918
  341. package/test/polar/PolarLegendPerRow.render.spec.tsx +0 -85
  342. package/test/polar/PolarRadiusAxis.events.spec.tsx +0 -65
  343. package/test/polar/PolarRadiusAxis.render.spec.tsx +0 -52
  344. package/test/polar/PolarRadiusAxis.spec.tsx +0 -991
  345. package/test/polar/PolarRadiusAxis.typed.spec.tsx +0 -84
  346. package/test/polar/PolarTooltipLegend.render.spec.tsx +0 -80
  347. package/test/polar/Radar.animation.spec.tsx +0 -570
  348. package/test/polar/Radar.render.spec.tsx +0 -71
  349. package/test/polar/Radar.spec.tsx +0 -265
  350. package/test/polar/Radar.typed.spec.tsx +0 -119
  351. package/test/polar/RadialBar/RadialBar.spec.tsx +0 -1521
  352. package/test/polar/RadialBar/RadialBar.typed.spec.tsx +0 -132
  353. package/test/polar/RadialBar.animation.spec.tsx +0 -375
  354. package/test/polar/RadialBar.render.spec.tsx +0 -66
  355. package/test/polar/RadialBar.stacked.spec.tsx +0 -57
  356. package/test/setup.ts +0 -84
  357. package/test/shape/ActiveShape.spec.tsx +0 -181
  358. package/test/shape/Cross.spec.tsx +0 -60
  359. package/test/shape/Cross.typed.spec.tsx +0 -26
  360. package/test/shape/Curve.spec.tsx +0 -368
  361. package/test/shape/Curve.typed.spec.tsx +0 -69
  362. package/test/shape/Dot.spec.tsx +0 -73
  363. package/test/shape/Dot.typed.spec.tsx +0 -30
  364. package/test/shape/Polygon.spec.tsx +0 -357
  365. package/test/shape/Polygon.typed.spec.tsx +0 -28
  366. package/test/shape/Rectangle.animation.spec.tsx +0 -451
  367. package/test/shape/Rectangle.spec.tsx +0 -68
  368. package/test/shape/Rectangle.typed.spec.tsx +0 -24
  369. package/test/shape/Sector.spec.tsx +0 -76
  370. package/test/shape/Sector.typed.spec.tsx +0 -24
  371. package/test/shape/Symbols.spec.tsx +0 -43
  372. package/test/shape/Symbols.typed.spec.tsx +0 -24
  373. package/test/shape/Trapezoid.spec.tsx +0 -50
  374. package/test/shape/Trapezoid.typed.spec.tsx +0 -24
  375. package/test/shape/__snapshots__/Cross.spec.tsx.snap +0 -62
  376. package/test/shape/__snapshots__/Curve.spec.tsx.snap +0 -460
  377. package/test/shape/__snapshots__/Polygon.spec.tsx.snap +0 -58
  378. package/test/shape/__snapshots__/Rectangle.spec.tsx.snap +0 -117
  379. package/test/shape/__snapshots__/Sector.spec.tsx.snap +0 -71
  380. package/test/shape/__snapshots__/Trapezoid.spec.tsx.snap +0 -64
  381. package/test/state/chartDataSlice.spec.ts +0 -53
  382. package/test/state/createCollectionActions.spec.ts +0 -87
  383. package/test/state/createSelector.spec.ts +0 -158
  384. package/test/state/externalEventsMiddleware.spec.ts +0 -178
  385. package/test/state/graphicalItemsSlice.spec.ts +0 -92
  386. package/test/state/hooks.spec.tsx +0 -68
  387. package/test/state/legendSlice.spec.ts +0 -44
  388. package/test/state/mouseEventsMiddleware.spec.ts +0 -75
  389. package/test/state/optionsSlice.spec.ts +0 -19
  390. package/test/state/referenceElementsSlice.spec.ts +0 -84
  391. package/test/state/registerInStore.spec.tsx +0 -101
  392. package/test/state/selectors/areaSelectors.spec.tsx +0 -77
  393. package/test/state/selectors/axisSelectors.spec.tsx +0 -1418
  394. package/test/state/selectors/barStackSelectors.spec.tsx +0 -752
  395. package/test/state/selectors/brushSelectors.spec.tsx +0 -30
  396. package/test/state/selectors/cartesianAxisSlice.spec.ts +0 -96
  397. package/test/state/selectors/combineNiceTicks.spec.ts +0 -207
  398. package/test/state/selectors/combiners/combineActiveTooltipIndex.spec.ts +0 -61
  399. package/test/state/selectors/combiners/combineAllBarPositions.spec.ts +0 -39
  400. package/test/state/selectors/combiners/combineConfiguredScale.spec.ts +0 -56
  401. package/test/state/selectors/combiners/combineDisplayedStackedData.spec.ts +0 -123
  402. package/test/state/selectors/combiners/combineRealScaleType.spec.ts +0 -80
  403. package/test/state/selectors/containerSelectors.spec.tsx +0 -168
  404. package/test/state/selectors/dataSelectors.spec.tsx +0 -136
  405. package/test/state/selectors/legendSelectors.spec.tsx +0 -113
  406. package/test/state/selectors/lineSelectors.spec.tsx +0 -60
  407. package/test/state/selectors/pieSelectors.spec.tsx +0 -72
  408. package/test/state/selectors/radarSelectors.spec.tsx +0 -496
  409. package/test/state/selectors/rootPropsSelectors.spec.tsx +0 -169
  410. package/test/state/selectors/scatterSelectors.spec.tsx +0 -47
  411. package/test/state/selectors/selectActiveTooltipIndex.spec.tsx +0 -234
  412. package/test/state/selectors/selectAllAxes.spec.tsx +0 -18
  413. package/test/state/selectors/selectAxisDomain.spec.tsx +0 -21
  414. package/test/state/selectors/selectAxisDomainIncludingNiceTicks.spec.tsx +0 -19
  415. package/test/state/selectors/selectAxisRangeWithReverse.spec.tsx +0 -22
  416. package/test/state/selectors/selectAxisScale.spec.tsx +0 -91
  417. package/test/state/selectors/selectBarRectangles.stackOffset.spec.tsx +0 -503
  418. package/test/state/selectors/selectBaseAxis.spec.tsx +0 -56
  419. package/test/state/selectors/selectCartesianItemsSettings.spec.tsx +0 -57
  420. package/test/state/selectors/selectChartOffset.spec.tsx +0 -26
  421. package/test/state/selectors/selectDisplayedData.spec.tsx +0 -282
  422. package/test/state/selectors/selectIsTooltipActive.spec.tsx +0 -231
  423. package/test/state/selectors/selectNumericalDomain.spec.tsx +0 -21
  424. package/test/state/selectors/selectRealScaleType.spec.tsx +0 -19
  425. package/test/state/selectors/selectStackGroups.spec.tsx +0 -322
  426. package/test/state/selectors/selectXAxisPosition.spec.tsx +0 -22
  427. package/test/state/selectors/selectYAxisPosition.spec.tsx +0 -22
  428. package/test/state/selectors/selectorMemoization.spec.tsx +0 -136
  429. package/test/state/selectors/selectors.spec.tsx +0 -1613
  430. package/test/state/throttling.spec.ts +0 -200
  431. package/test/state/zIndexSlice.spec.ts +0 -85
  432. package/test/synchronisation/useChartSynchronisation.spec.tsx +0 -225
  433. package/test/util/BarUtils.spec.ts +0 -39
  434. package/test/util/CartesianUtils/CartesianUtils.spec.ts +0 -261
  435. package/test/util/CartesianUtils/rectWithPoints.spec.ts +0 -48
  436. package/test/util/ChartUtils/ChartUtils.spec.ts +0 -491
  437. package/test/util/ChartUtils/appendOffsetOfLegend.spec.ts +0 -136
  438. package/test/util/ChartUtils/appendOffsetOfLegend.spec.tsx +0 -133
  439. package/test/util/ChartUtils/getCateCoordinateOfLine.spec.ts +0 -97
  440. package/test/util/ChartUtils/getStackedData.spec.ts +0 -416
  441. package/test/util/ChartUtils/truncateByDomain.spec.ts +0 -70
  442. package/test/util/DataUtils.spec.ts +0 -385
  443. package/test/util/DomUtils.spec.tsx +0 -117
  444. package/test/util/FunnelUtils.spec.tsx +0 -70
  445. package/test/util/Global.spec.ts +0 -11
  446. package/test/util/LRUCache.spec.ts +0 -81
  447. package/test/util/LogUtils.spec.ts +0 -45
  448. package/test/util/PolarUtils.spec.ts +0 -66
  449. package/test/util/ReduceCssCalcPrototype.spec.ts +0 -141
  450. package/test/util/ShallowEqual.spec.ts +0 -102
  451. package/test/util/TickUtils.spec.ts +0 -29
  452. package/test/util/createChartHelpers.spec.tsx +0 -210
  453. package/test/util/cursor/getCursorPoints.spec.ts +0 -136
  454. package/test/util/cursor/getCursorRectangle.spec.ts +0 -50
  455. package/test/util/cursor/getRadialCursorPoints.spec.ts +0 -36
  456. package/test/util/errorValue.spec.ts +0 -69
  457. package/test/util/getEveryNth.spec.ts +0 -39
  458. package/test/util/getRadiusAndStrokeWidthFromDot.spec.ts +0 -51
  459. package/test/util/getRelativeCoordinate.spec.ts +0 -250
  460. package/test/util/getSliced.spec.ts +0 -45
  461. package/test/util/isDomainSpecifiedByUser.spec.ts +0 -207
  462. package/test/util/isWellBehavedNumber.spec.ts +0 -54
  463. package/test/util/payload/getUniqPayload.spec.ts +0 -56
  464. package/test/util/propsAreEqual.spec.ts +0 -75
  465. package/test/util/round.spec.ts +0 -112
  466. package/test/util/scale/arithmetic.spec.ts +0 -61
  467. package/test/util/scale/createCategoricalInverse.spec.ts +0 -84
  468. package/test/util/scale/getNiceTickValues.spec.ts +0 -421
  469. package/test/util/scale/getTickValuesFixedDomain.spec.ts +0 -155
  470. package/test/util/svgPropertiesAndEvents.spec.tsx +0 -206
  471. package/test/util/svgPropertiesNoEvents.spec.tsx +0 -228
  472. package/test/util/tooltip/translate.spec.ts +0 -396
  473. package/test/util/useAnimationId.spec.tsx +0 -59
  474. package/test/util/useElementOffset.spec.tsx +0 -173
  475. package/test/util/usePrefersReducedMotion.spec.ts +0 -54
  476. package/test/util/useUniqueId.spec.ts +0 -99
  477. package/test/utils/diagnostics-allowlist.ts +0 -18
  478. package/test/utils/diagnostics.ts +0 -58
  479. package/test/zIndex/AllZIndexPortals.spec.tsx +0 -83
  480. package/test/zIndex/DefaultZIndexes.spec.ts +0 -80
  481. package/test/zIndex/DynamicZIndex.spec.tsx +0 -102
  482. package/test/zIndex/ZIndexLayer.portalOwner.spec.tsx +0 -125
  483. package/test/zIndex/componentZIndex.spec.tsx +0 -255
  484. package/test/zIndex/getZIndexFromUnknown.spec.ts +0 -51
  485. package/test/zIndex/multiChartZIndexIsolation.spec.tsx +0 -90
  486. package/test/zIndex/zIndexSelectors.spec.ts +0 -172
  487. package/test-results/.last-run.json +0 -4
  488. package/tsconfig.json +0 -11
@@ -1,2414 +0,0 @@
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 "@solidjs/testing-library";
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
- });