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,2079 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+ import { createEffect, createSignal, flush } from "solid-js";
3
+ import { Show } from "@solidjs/web";
4
+ import {
5
+ PolarAngleAxis,
6
+ PolarRadiusAxis,
7
+ Radar,
8
+ RadarChart,
9
+ RadialBar,
10
+ RadialBarChart,
11
+ } from "../../../src";
12
+ import { exampleRadarData, PageData, pageDataWithFillColor } from "../../_data";
13
+ import { assertNotNull } from "../../helper/assertNotNull";
14
+ import {
15
+ implicitAngleAxis,
16
+ selectAngleAxis,
17
+ selectAngleAxisRangeWithReversed,
18
+ selectPolarOptions,
19
+ } from "../../../src/state/selectors/polarAxisSelectors";
20
+ import { useAppSelector } from "../../../src/state/hooks";
21
+ import { selectNiceTicks, selectRealScaleType } from "../../../src/state/selectors/axisSelectors";
22
+ import {
23
+ selectPolarAxisScale,
24
+ selectPolarAxisTicks,
25
+ } from "../../../src/state/selectors/polarScaleSelectors";
26
+ import {
27
+ selectPolarAppliedValues,
28
+ selectPolarAxisDomain,
29
+ selectPolarItemsSettings,
30
+ selectPolarNiceTicks,
31
+ } from "../../../src/state/selectors/polarSelectors";
32
+ import { expectLastCalledWithScale } from "../../helper/expectScale";
33
+ import { createSelectorTestCase } from "../../helper/createSelectorTestCase";
34
+ import { expectLastCalledWith } from "../../helper/expectLastCalledWith";
35
+ import { render } from "../../helper/render";
36
+ import type { PolarAngleTickContentProps } from "../../../src/polar/PolarAngleAxis";
37
+
38
+ /*
39
+ * Ported from recharts 3.8.1 test/polar/PolarAngleAxis/PolarAngleAxis.spec.tsx.
40
+ * Wrappers read `props.children` (not destructured) so the Spy mounts inside the
41
+ * chart store. Ported incrementally by describe block.
42
+ */
43
+
44
+ type ExpectedAngleAxisTick = {
45
+ x1: string | null;
46
+ x2: string | null;
47
+ y1: string | null;
48
+ y2: string | null;
49
+ };
50
+
51
+ function expectAngleAxisTicks(
52
+ container: Element,
53
+ expectedTicks: ReadonlyArray<ExpectedAngleAxisTick>,
54
+ ): void {
55
+ assertNotNull(container);
56
+ const allTicks = container.querySelectorAll(".recharts-polar-angle-axis-tick-line");
57
+ const actualTicks = Array.from(allTicks).map((tick) => ({
58
+ x1: tick.getAttribute("x1"),
59
+ x2: tick.getAttribute("x2"),
60
+ y1: tick.getAttribute("y1"),
61
+ y2: tick.getAttribute("y2"),
62
+ }));
63
+ expect(actualTicks).toEqual(expectedTicks);
64
+ }
65
+
66
+ type ExpectedAxisTickLabel = {
67
+ textContext: string | null;
68
+ x: string | null;
69
+ y: string | null;
70
+ };
71
+
72
+ function expectAngleAxisTickLabels(
73
+ container: Element,
74
+ expectedLabels: ReadonlyArray<ExpectedAxisTickLabel>,
75
+ ): void {
76
+ assertNotNull(container);
77
+ const allTickLabels = container.querySelectorAll(
78
+ ".recharts-text.recharts-polar-angle-axis-tick-value",
79
+ );
80
+ const actualLabels = Array.from(allTickLabels).map((label) => ({
81
+ textContext: label.textContent,
82
+ x: label.getAttribute("x"),
83
+ y: label.getAttribute("y"),
84
+ }));
85
+ expect(actualLabels).toEqual(expectedLabels);
86
+ }
87
+
88
+ describe("<PolarAngleAxis />", () => {
89
+ describe("in RadarChart", () => {
90
+ describe("when axis has a dataKey", () => {
91
+ const renderTestCase = createSelectorTestCase((props) => (
92
+ <RadarChart width={500} height={500} data={exampleRadarData}>
93
+ <Radar dataKey="value" />
94
+ <PolarAngleAxis dataKey="value" />
95
+ {props.children}
96
+ </RadarChart>
97
+ ));
98
+
99
+ it("should select angle axis settings", () => {
100
+ const { spy } = renderTestCase((state) => selectAngleAxis(state, 0));
101
+ expectLastCalledWith(spy, {
102
+ allowDataOverflow: false,
103
+ allowDecimals: false,
104
+ allowDuplicatedCategory: false,
105
+ dataKey: "value",
106
+ domain: undefined,
107
+ id: 0,
108
+ includeHidden: false,
109
+ name: undefined,
110
+ reversed: false,
111
+ niceTicks: "auto",
112
+ scale: "auto",
113
+ tick: true,
114
+ tickCount: undefined,
115
+ ticks: undefined,
116
+ type: "category",
117
+ unit: undefined,
118
+ });
119
+ });
120
+
121
+ it("should select polar items", () => {
122
+ const { spy } = renderTestCase((state) => selectPolarItemsSettings(state, "angleAxis", 0));
123
+ expectLastCalledWith(spy, [
124
+ {
125
+ id: expect.stringMatching("radar-"),
126
+ type: "radar",
127
+ angleAxisId: 0,
128
+ data: undefined,
129
+ dataKey: "value",
130
+ hide: false,
131
+ radiusAxisId: 0,
132
+ },
133
+ ]);
134
+ });
135
+
136
+ it("should select angle axis domain", () => {
137
+ const { spy } = renderTestCase((state) => selectPolarAxisDomain(state, "angleAxis", 0));
138
+ expectLastCalledWith(spy, [420, 460, 999, 500, 864, 650, 765, 365]);
139
+ });
140
+
141
+ it("should select angle axis range", () => {
142
+ const { spy } = renderTestCase((state) => selectAngleAxisRangeWithReversed(state, 0));
143
+ expectLastCalledWith(spy, [90, -270]);
144
+ });
145
+
146
+ it("should select real scale type", () => {
147
+ const { spy } = renderTestCase((state) => selectRealScaleType(state, "angleAxis", 0));
148
+ expectLastCalledWith(spy, "band");
149
+ });
150
+
151
+ it("should select scale", () => {
152
+ const { spy } = renderTestCase((state) => selectPolarAxisScale(state, "angleAxis", 0));
153
+ expectLastCalledWithScale(spy, {
154
+ domain: [420, 460, 999, 500, 864, 650, 765, 365],
155
+ range: [-270, 90],
156
+ });
157
+ });
158
+
159
+ it("should select ticks", () => {
160
+ const { spy } = renderTestCase((state) =>
161
+ selectPolarAxisTicks(state, "angleAxis", 0, false),
162
+ );
163
+ expectLastCalledWith(spy, [
164
+ { coordinate: 90, index: 0, offset: 45, value: 420 },
165
+ { coordinate: 45, index: 1, offset: 45, value: 460 },
166
+ { coordinate: 0, index: 2, offset: 45, value: 999 },
167
+ { coordinate: -45, index: 3, offset: 45, value: 500 },
168
+ { coordinate: -90, index: 4, offset: 45, value: 864 },
169
+ { coordinate: -135, index: 5, offset: 45, value: 650 },
170
+ { coordinate: -180, index: 6, offset: 45, value: 765 },
171
+ { coordinate: -225, index: 7, offset: 45, value: 365 },
172
+ ]);
173
+ });
174
+
175
+ it("should select nice ticks", () => {
176
+ const { spy } = renderTestCase((state) => selectNiceTicks(state, "angleAxis", 0, false));
177
+ expectLastCalledWith(spy, undefined);
178
+ });
179
+
180
+ it("should select applied data", () => {
181
+ const { spy } = renderTestCase((state) => selectPolarAppliedValues(state, "angleAxis", 0));
182
+ expectLastCalledWith(spy, [
183
+ { value: 420 },
184
+ { value: 460 },
185
+ { value: 999 },
186
+ { value: 500 },
187
+ { value: 864 },
188
+ { value: 650 },
189
+ { value: 765 },
190
+ { value: 365 },
191
+ ]);
192
+ });
193
+
194
+ it("should render axis ticks", () => {
195
+ const { container } = renderTestCase((): null => null);
196
+ expectAngleAxisTicks(container, [
197
+ { x1: "250", x2: "250", y1: "54", y2: "46" },
198
+ {
199
+ x1: "388.5929291125633",
200
+ x2: "394.2497833620557",
201
+ y1: "111.4070708874367",
202
+ y2: "105.7502166379443",
203
+ },
204
+ { x1: "446", x2: "454", y1: "250", y2: "250" },
205
+ {
206
+ x1: "388.5929291125633",
207
+ x2: "394.2497833620557",
208
+ y1: "388.5929291125633",
209
+ y2: "394.2497833620557",
210
+ },
211
+ { x1: "250", x2: "250", y1: "446", y2: "454" },
212
+ {
213
+ x1: "111.4070708874367",
214
+ x2: "105.7502166379443",
215
+ y1: "388.5929291125633",
216
+ y2: "394.2497833620557",
217
+ },
218
+ { x1: "54", x2: "46", y1: "250.00000000000003", y2: "250.00000000000003" },
219
+ {
220
+ x1: "111.40707088743665",
221
+ x2: "105.75021663794428",
222
+ y1: "111.4070708874367",
223
+ y2: "105.7502166379443",
224
+ },
225
+ ]);
226
+ });
227
+
228
+ it("should render angle labels", () => {
229
+ const { container } = renderTestCase((): null => null);
230
+ expectAngleAxisTickLabels(container, [
231
+ { textContext: "420", x: "250", y: "46" },
232
+ { textContext: "460", x: "394.2497833620557", y: "105.7502166379443" },
233
+ { textContext: "999", x: "454", y: "250" },
234
+ { textContext: "500", x: "394.2497833620557", y: "394.2497833620557" },
235
+ { textContext: "864", x: "250", y: "454" },
236
+ { textContext: "650", x: "105.7502166379443", y: "394.2497833620557" },
237
+ { textContext: "765", x: "46", y: "250.00000000000003" },
238
+ { textContext: "365", x: "105.75021663794428", y: "105.7502166379443" },
239
+ ]);
240
+ });
241
+ });
242
+
243
+ describe("with default axis", () => {
244
+ const renderTestCase = createSelectorTestCase((props) => (
245
+ <RadarChart width={500} height={500} data={exampleRadarData}>
246
+ <Radar dataKey="value" />
247
+ <PolarAngleAxis />
248
+ {props.children}
249
+ </RadarChart>
250
+ ));
251
+
252
+ it("should select angle axis settings", () => {
253
+ const { spy } = renderTestCase((state) => selectAngleAxis(state, 0));
254
+ expectLastCalledWith(spy, {
255
+ allowDataOverflow: false,
256
+ allowDecimals: false,
257
+ allowDuplicatedCategory: false,
258
+ dataKey: undefined,
259
+ domain: undefined,
260
+ id: 0,
261
+ includeHidden: false,
262
+ name: undefined,
263
+ reversed: false,
264
+ niceTicks: "auto",
265
+ scale: "auto",
266
+ tick: true,
267
+ tickCount: undefined,
268
+ ticks: undefined,
269
+ type: "category",
270
+ unit: undefined,
271
+ });
272
+ });
273
+
274
+ it("should select polar items", () => {
275
+ const { spy } = renderTestCase((state) => selectPolarItemsSettings(state, "angleAxis", 0));
276
+ expectLastCalledWith(spy, [
277
+ {
278
+ id: expect.stringMatching("radar-"),
279
+ type: "radar",
280
+ angleAxisId: 0,
281
+ data: undefined,
282
+ dataKey: "value",
283
+ hide: false,
284
+ radiusAxisId: 0,
285
+ },
286
+ ]);
287
+ });
288
+
289
+ it("should select angle axis domain", () => {
290
+ const { spy } = renderTestCase((state) => selectPolarAxisDomain(state, "angleAxis", 0));
291
+ expectLastCalledWith(spy, [0, 1, 2, 3, 4, 5, 6, 7]);
292
+ });
293
+
294
+ it("should select angle axis range", () => {
295
+ const { spy } = renderTestCase((state) => selectAngleAxisRangeWithReversed(state, 0));
296
+ expectLastCalledWith(spy, [90, -270]);
297
+ });
298
+
299
+ it("should select real scale type", () => {
300
+ const { spy } = renderTestCase((state) => selectRealScaleType(state, "angleAxis", 0));
301
+ expectLastCalledWith(spy, "band");
302
+ });
303
+
304
+ it("should select scale", () => {
305
+ const { spy } = renderTestCase((state) => selectPolarAxisScale(state, "angleAxis", 0));
306
+ expectLastCalledWithScale(spy, { domain: [0, 1, 2, 3, 4, 5, 6, 7], range: [-270, 90] });
307
+ });
308
+
309
+ it("should select applied data", () => {
310
+ const { spy } = renderTestCase((state) => selectPolarAppliedValues(state, "angleAxis", 0));
311
+ expectLastCalledWith(spy, [
312
+ { value: 420 },
313
+ { value: 460 },
314
+ { value: 999 },
315
+ { value: 500 },
316
+ { value: 864 },
317
+ { value: 650 },
318
+ { value: 765 },
319
+ { value: 365 },
320
+ ]);
321
+ });
322
+
323
+ it("should render ticks", () => {
324
+ const { container } = renderTestCase((): null => null);
325
+ expectAngleAxisTicks(container, [
326
+ { x1: "250", x2: "250", y1: "54", y2: "46" },
327
+ {
328
+ x1: "388.5929291125633",
329
+ x2: "394.2497833620557",
330
+ y1: "111.4070708874367",
331
+ y2: "105.7502166379443",
332
+ },
333
+ { x1: "446", x2: "454", y1: "250", y2: "250" },
334
+ {
335
+ x1: "388.5929291125633",
336
+ x2: "394.2497833620557",
337
+ y1: "388.5929291125633",
338
+ y2: "394.2497833620557",
339
+ },
340
+ { x1: "250", x2: "250", y1: "446", y2: "454" },
341
+ {
342
+ x1: "111.4070708874367",
343
+ x2: "105.7502166379443",
344
+ y1: "388.5929291125633",
345
+ y2: "394.2497833620557",
346
+ },
347
+ { x1: "54", x2: "46", y1: "250.00000000000003", y2: "250.00000000000003" },
348
+ {
349
+ x1: "111.40707088743665",
350
+ x2: "105.75021663794428",
351
+ y1: "111.4070708874367",
352
+ y2: "105.7502166379443",
353
+ },
354
+ ]);
355
+ });
356
+
357
+ it("should render labels", () => {
358
+ const { container } = renderTestCase();
359
+ expectAngleAxisTickLabels(container, [
360
+ { textContext: "0", x: "250", y: "46" },
361
+ { textContext: "1", x: "394.2497833620557", y: "105.7502166379443" },
362
+ { textContext: "2", x: "454", y: "250" },
363
+ { textContext: "3", x: "394.2497833620557", y: "394.2497833620557" },
364
+ { textContext: "4", x: "250", y: "454" },
365
+ { textContext: "5", x: "105.7502166379443", y: "394.2497833620557" },
366
+ { textContext: "6", x: "46", y: "250.00000000000003" },
367
+ { textContext: "7", x: "105.75021663794428", y: "105.7502166379443" },
368
+ ]);
369
+ });
370
+ });
371
+
372
+ describe("with implicit axis", () => {
373
+ const renderTestCase = createSelectorTestCase((props) => (
374
+ <RadarChart width={500} height={500} data={exampleRadarData}>
375
+ <Radar dataKey="value" />
376
+ {props.children}
377
+ </RadarChart>
378
+ ));
379
+
380
+ it("should select angle axis settings", () => {
381
+ const { spy } = renderTestCase((state) => selectAngleAxis(state, 0));
382
+ expectLastCalledWith(spy, {
383
+ allowDataOverflow: false,
384
+ allowDecimals: false,
385
+ allowDuplicatedCategory: false,
386
+ dataKey: undefined,
387
+ domain: undefined,
388
+ id: 0,
389
+ includeHidden: false,
390
+ name: undefined,
391
+ reversed: false,
392
+ niceTicks: "auto",
393
+ scale: "auto",
394
+ tick: true,
395
+ tickCount: undefined,
396
+ ticks: undefined,
397
+ type: "category",
398
+ unit: undefined,
399
+ });
400
+ });
401
+
402
+ it("should select polar items", () => {
403
+ const { spy } = renderTestCase((state) => selectPolarItemsSettings(state, "angleAxis", 0));
404
+ expectLastCalledWith(spy, [
405
+ {
406
+ id: expect.stringMatching("radar-"),
407
+ type: "radar",
408
+ angleAxisId: 0,
409
+ data: undefined,
410
+ dataKey: "value",
411
+ hide: false,
412
+ radiusAxisId: 0,
413
+ },
414
+ ]);
415
+ });
416
+
417
+ it("should select applied values", () => {
418
+ const { spy } = renderTestCase((state) => selectPolarAppliedValues(state, "angleAxis", 0));
419
+ expectLastCalledWith(spy, [
420
+ { value: 420 },
421
+ { value: 460 },
422
+ { value: 999 },
423
+ { value: 500 },
424
+ { value: 864 },
425
+ { value: 650 },
426
+ { value: 765 },
427
+ { value: 365 },
428
+ ]);
429
+ });
430
+
431
+ it("should select angle axis domain", () => {
432
+ const { spy } = renderTestCase((state) => selectPolarAxisDomain(state, "angleAxis", 0));
433
+ expectLastCalledWith(spy, [0, 1, 2, 3, 4, 5, 6, 7]);
434
+ });
435
+
436
+ it("should select angle axis range", () => {
437
+ const { spy } = renderTestCase((state) => selectAngleAxisRangeWithReversed(state, 0));
438
+ expectLastCalledWith(spy, [90, -270]);
439
+ });
440
+
441
+ it("should select real scale type", () => {
442
+ const { spy } = renderTestCase((state) => selectRealScaleType(state, "angleAxis", 0));
443
+ expectLastCalledWith(spy, "band");
444
+ });
445
+
446
+ it("should select scale", () => {
447
+ const { spy } = renderTestCase((state) => selectPolarAxisScale(state, "angleAxis", 0));
448
+ expectLastCalledWithScale(spy, { domain: [0, 1, 2, 3, 4, 5, 6, 7], range: [-270, 90] });
449
+ });
450
+
451
+ it("should not render ticks", () => {
452
+ const { container } = renderTestCase((): null => null);
453
+ expectAngleAxisTicks(container, []);
454
+ });
455
+
456
+ it("should not render labels", () => {
457
+ const { container } = renderTestCase((): null => null);
458
+ expectAngleAxisTickLabels(container, []);
459
+ });
460
+ });
461
+
462
+ describe("with type=number", () => {
463
+ const data = [
464
+ { angle: 0, r: 11 },
465
+ { angle: 90, r: 22 },
466
+ { angle: 180, r: 33 },
467
+ { angle: 270, r: 44 },
468
+ ];
469
+
470
+ const renderTestCase = createSelectorTestCase((props) => (
471
+ <RadarChart width={360} height={360} data={data}>
472
+ <PolarAngleAxis dataKey="angle" axisLineType="circle" type="number" domain={[0, 360]} />
473
+ {/* recharts also passes a no-op `type="number"` to this Radar; omitted (not a Radar prop). */}
474
+ <Radar name="r" dataKey="r" fillOpacity={0} stroke="#000" />
475
+ {props.children}
476
+ </RadarChart>
477
+ ));
478
+
479
+ it("should select axis settings", () => {
480
+ const { spy } = renderTestCase((state) => selectAngleAxis(state, 0));
481
+ expectLastCalledWith(spy, {
482
+ allowDataOverflow: false,
483
+ allowDecimals: false,
484
+ allowDuplicatedCategory: false,
485
+ dataKey: "angle",
486
+ domain: [0, 360],
487
+ id: 0,
488
+ includeHidden: false,
489
+ name: undefined,
490
+ reversed: false,
491
+ niceTicks: "auto",
492
+ scale: "auto",
493
+ tick: true,
494
+ tickCount: undefined,
495
+ ticks: undefined,
496
+ type: "number",
497
+ unit: undefined,
498
+ });
499
+ });
500
+
501
+ it("should select polar items", () => {
502
+ const { spy } = renderTestCase((state) => selectPolarItemsSettings(state, "angleAxis", 0));
503
+ expectLastCalledWith(spy, [
504
+ {
505
+ id: expect.stringMatching("radar-"),
506
+ type: "radar",
507
+ angleAxisId: 0,
508
+ data: undefined,
509
+ dataKey: "r",
510
+ hide: false,
511
+ radiusAxisId: 0,
512
+ },
513
+ ]);
514
+ });
515
+
516
+ it("should select angle axis domain", () => {
517
+ const { spy } = renderTestCase((state) => selectPolarAxisDomain(state, "angleAxis", 0));
518
+ expectLastCalledWith(spy, [0, 360]);
519
+ });
520
+
521
+ it("should select angle axis range", () => {
522
+ const { spy } = renderTestCase((state) => selectAngleAxisRangeWithReversed(state, 0));
523
+ expectLastCalledWith(spy, [90, -270]);
524
+ });
525
+
526
+ it("should select real scale type", () => {
527
+ const { spy } = renderTestCase((state) => selectRealScaleType(state, "angleAxis", 0));
528
+ expectLastCalledWith(spy, "linear");
529
+ });
530
+
531
+ it("should select scale", () => {
532
+ const { spy } = renderTestCase((state) => selectPolarAxisScale(state, "angleAxis", 0));
533
+ expectLastCalledWithScale(spy, { domain: [0, 360], range: [-270, 90] });
534
+ });
535
+
536
+ it("should select ticks", () => {
537
+ const { spy } = renderTestCase((state) =>
538
+ selectPolarAxisTicks(state, "angleAxis", 0, false),
539
+ );
540
+ expectLastCalledWith(spy, [
541
+ { coordinate: 90, index: 0, offset: 0, value: 0 },
542
+ { coordinate: 0, index: 1, offset: 0, value: 90 },
543
+ { coordinate: -90, index: 2, offset: 0, value: 180 },
544
+ { coordinate: -180, index: 3, offset: 0, value: 270 },
545
+ ]);
546
+ });
547
+
548
+ it("should select nice ticks", () => {
549
+ const { spy } = renderTestCase((state) => selectNiceTicks(state, "angleAxis", 0, false));
550
+ expectLastCalledWith(spy, undefined);
551
+ });
552
+
553
+ it("should select applied data", () => {
554
+ const { spy } = renderTestCase((state) => selectPolarAppliedValues(state, "angleAxis", 0));
555
+ expectLastCalledWith(spy, [{ value: 0 }, { value: 90 }, { value: 180 }, { value: 270 }]);
556
+ });
557
+
558
+ it("should render axis ticks", () => {
559
+ const { container } = renderTestCase((): null => null);
560
+ expectAngleAxisTicks(container, [
561
+ { x1: "180", x2: "180", y1: "40", y2: "32" },
562
+ { x1: "320", x2: "328", y1: "180", y2: "180" },
563
+ { x1: "180", x2: "180", y1: "320", y2: "328" },
564
+ { x1: "40", x2: "32", y1: "180.00000000000003", y2: "180.00000000000003" },
565
+ ]);
566
+ });
567
+
568
+ it("should render angle labels", () => {
569
+ const { container } = renderTestCase((): null => null);
570
+ expectAngleAxisTickLabels(container, [
571
+ { textContext: "0", x: "180", y: "32" },
572
+ { textContext: "90", x: "328", y: "180" },
573
+ { textContext: "180", x: "180", y: "328" },
574
+ { textContext: "270", x: "32", y: "180.00000000000003" },
575
+ ]);
576
+ });
577
+ });
578
+
579
+ describe("renders regularly spaced ticks, even if the data is different", () => {
580
+ const data = [
581
+ { angle: 0, value: 5 },
582
+ { angle: 45, value: 5 },
583
+ { angle: 90, value: 5 },
584
+ { angle: 125, value: 5 },
585
+ { angle: 180, value: 5 },
586
+ { angle: 225, value: 5 },
587
+ { angle: 270, value: 5 },
588
+ { angle: 315, value: 5 },
589
+ { angle: 360, value: 5 },
590
+ ];
591
+
592
+ const renderTestCase = createSelectorTestCase((props) => (
593
+ <RadarChart width={500} height={500} data={data}>
594
+ <PolarAngleAxis dataKey="angle" type="number" domain={[0, 360]} tickCount={9} />
595
+ <Radar dataKey="value" />
596
+ {props.children}
597
+ </RadarChart>
598
+ ));
599
+
600
+ it("should select axis settings with tickCount=9", () => {
601
+ const { spy } = renderTestCase((state) => selectAngleAxis(state, 0));
602
+ expectLastCalledWith(spy, {
603
+ allowDataOverflow: false,
604
+ allowDecimals: false,
605
+ allowDuplicatedCategory: false,
606
+ dataKey: "angle",
607
+ domain: [0, 360],
608
+ id: 0,
609
+ includeHidden: false,
610
+ name: undefined,
611
+ reversed: false,
612
+ niceTicks: "auto",
613
+ scale: "auto",
614
+ tick: true,
615
+ tickCount: 9,
616
+ ticks: undefined,
617
+ type: "number",
618
+ unit: undefined,
619
+ });
620
+ });
621
+
622
+ it("should select nice ticks", () => {
623
+ const { spy } = renderTestCase((state) => selectPolarNiceTicks(state, "angleAxis", 0));
624
+ expectLastCalledWith(spy, [0, 45, 90, 135, 180, 225, 270, 315, 360]);
625
+ });
626
+
627
+ it("should render regularly spaced ticks and labels", () => {
628
+ const { container } = renderTestCase((): null => null);
629
+ expectAngleAxisTicks(container, [
630
+ { x1: "250", x2: "250", y1: "54", y2: "46" },
631
+ {
632
+ x1: "388.5929291125633",
633
+ x2: "394.2497833620557",
634
+ y1: "111.4070708874367",
635
+ y2: "105.7502166379443",
636
+ },
637
+ { x1: "446", x2: "454", y1: "250", y2: "250" },
638
+ {
639
+ x1: "388.5929291125633",
640
+ x2: "394.2497833620557",
641
+ y1: "388.5929291125633",
642
+ y2: "394.2497833620557",
643
+ },
644
+ { x1: "250", x2: "250", y1: "446", y2: "454" },
645
+ {
646
+ x1: "111.4070708874367",
647
+ x2: "105.7502166379443",
648
+ y1: "388.5929291125633",
649
+ y2: "394.2497833620557",
650
+ },
651
+ { x1: "54", x2: "46", y1: "250.00000000000003", y2: "250.00000000000003" },
652
+ {
653
+ x1: "111.40707088743665",
654
+ x2: "105.75021663794428",
655
+ y1: "111.4070708874367",
656
+ y2: "105.7502166379443",
657
+ },
658
+ ]);
659
+ expectAngleAxisTickLabels(container, [
660
+ { textContext: "0", x: "250", y: "46" },
661
+ { textContext: "45", x: "394.2497833620557", y: "105.7502166379443" },
662
+ { textContext: "90", x: "454", y: "250" },
663
+ { textContext: "135", x: "394.2497833620557", y: "394.2497833620557" },
664
+ { textContext: "180", x: "250", y: "454" },
665
+ { textContext: "225", x: "105.7502166379443", y: "394.2497833620557" },
666
+ { textContext: "270", x: "46", y: "250.00000000000003" },
667
+ { textContext: "315", x: "105.75021663794428", y: "105.7502166379443" },
668
+ ]);
669
+ });
670
+ });
671
+
672
+ // Adaptation: the reference passes `type="number"` to <Radar> too, but the
673
+ // port's RadarProps has no `type` (recharts' Radar ignores it as well).
674
+ it("renders 4 ticks", () => {
675
+ const data = [
676
+ { angle: 0, r: 1 },
677
+ { angle: 90, r: 2 },
678
+ { angle: 180, r: 3 },
679
+ { angle: 270, r: 4 },
680
+ ];
681
+
682
+ const { container } = render(() => (
683
+ <RadarChart width={500} height={500} data={data}>
684
+ <PolarAngleAxis dataKey="angle" axisLineType="circle" type="number" domain={[0, 360]} />
685
+ <Radar name="r" dataKey="r" fillOpacity={0} stroke="#000" />
686
+ </RadarChart>
687
+ ));
688
+
689
+ expectAngleAxisTicks(container, [
690
+ { x1: "250", x2: "250", y1: "54", y2: "46" },
691
+ { x1: "446", x2: "454", y1: "250", y2: "250" },
692
+ { x1: "250", x2: "250", y1: "446", y2: "454" },
693
+ { x1: "54", x2: "46", y1: "250.00000000000003", y2: "250.00000000000003" },
694
+ ]);
695
+ expectAngleAxisTickLabels(container, [
696
+ { textContext: "0", x: "250", y: "46" },
697
+ { textContext: "90", x: "454", y: "250" },
698
+ { textContext: "180", x: "250", y: "454" },
699
+ { textContext: "270", x: "46", y: "250.00000000000003" },
700
+ ]);
701
+ });
702
+
703
+ describe("orientation, axisLine, reversed, and linear-scale niceTicks", () => {
704
+ it("renders labels and ticks on the inside with orientation=inner", () => {
705
+ const renderTestCase = createSelectorTestCase((props) => (
706
+ <RadarChart width={500} height={500} data={exampleRadarData}>
707
+ <Radar dataKey="value" />
708
+ <PolarAngleAxis dataKey="value" orientation="inner" />
709
+ {props.children}
710
+ </RadarChart>
711
+ ));
712
+ const { container } = renderTestCase((): null => null);
713
+
714
+ expectAngleAxisTicks(container, [
715
+ { x1: "250", x2: "250", y1: "54", y2: "62" },
716
+ {
717
+ x1: "388.5929291125633",
718
+ x2: "382.936074863071",
719
+ y1: "111.4070708874367",
720
+ y2: "117.06392513692907",
721
+ },
722
+ { x1: "446", x2: "438", y1: "250", y2: "250" },
723
+ {
724
+ x1: "388.5929291125633",
725
+ x2: "382.936074863071",
726
+ y1: "388.5929291125633",
727
+ y2: "382.9360748630709",
728
+ },
729
+ { x1: "250", x2: "250", y1: "446", y2: "438" },
730
+ {
731
+ x1: "111.4070708874367",
732
+ x2: "117.06392513692907",
733
+ y1: "388.5929291125633",
734
+ y2: "382.936074863071",
735
+ },
736
+ { x1: "54", x2: "62", y1: "250.00000000000003", y2: "250.00000000000003" },
737
+ {
738
+ x1: "111.40707088743665",
739
+ x2: "117.06392513692904",
740
+ y1: "111.4070708874367",
741
+ y2: "117.06392513692907",
742
+ },
743
+ ]);
744
+ expectAngleAxisTickLabels(container, [
745
+ { textContext: "420", x: "250", y: "62" },
746
+ { textContext: "460", x: "382.936074863071", y: "117.06392513692907" },
747
+ { textContext: "999", x: "438", y: "250" },
748
+ { textContext: "500", x: "382.936074863071", y: "382.9360748630709" },
749
+ { textContext: "864", x: "250", y: "438" },
750
+ { textContext: "650", x: "117.06392513692907", y: "382.936074863071" },
751
+ { textContext: "765", x: "62", y: "250.00000000000003" },
752
+ { textContext: "365", x: "117.06392513692904", y: "117.06392513692907" },
753
+ ]);
754
+ });
755
+
756
+ it("does not render any line when axisLine=false", () => {
757
+ const renderTestCase = createSelectorTestCase((props) => (
758
+ <RadarChart width={500} height={500} data={exampleRadarData}>
759
+ <Radar dataKey="value" />
760
+ <PolarAngleAxis dataKey="value" axisLine={false} />
761
+ {props.children}
762
+ </RadarChart>
763
+ ));
764
+ const { container } = renderTestCase((): null => null);
765
+
766
+ const axisLineElement = container.querySelector(".recharts-polar-angle-axis-line");
767
+ expect(axisLineElement).toBeNull();
768
+ });
769
+
770
+ it.each([undefined, "polygon"] as const)(
771
+ "renders polygon axisLine when axisLineType=%s",
772
+ (axisLineType) => {
773
+ const renderTestCase = createSelectorTestCase((props) => (
774
+ <RadarChart width={500} height={500} data={exampleRadarData}>
775
+ <Radar dataKey="value" />
776
+ <PolarAngleAxis dataKey="value" axisLineType={axisLineType} />
777
+ {props.children}
778
+ </RadarChart>
779
+ ));
780
+ const { container } = renderTestCase((): null => null);
781
+
782
+ const axisLineElement = container.querySelector(".recharts-polar-angle-axis-line");
783
+ assertNotNull(axisLineElement);
784
+ expect(axisLineElement.tagName).toBe("path");
785
+ expect(axisLineElement.getAttribute("fill")).toBe("none");
786
+ expect(axisLineElement.getAttribute("d")).toBe(
787
+ "M250,54L388.5929,111.4071L446,250L388.5929,388.5929L250,446L111.4071,388.5929L54,250L111.4071,111.4071L250,54Z",
788
+ );
789
+ },
790
+ );
791
+
792
+ it("renders circle axisLine", () => {
793
+ const renderTestCase = createSelectorTestCase((props) => (
794
+ <RadarChart width={500} height={300} data={exampleRadarData}>
795
+ <Radar dataKey="value" />
796
+ <PolarAngleAxis dataKey="value" axisLineType="circle" />
797
+ {props.children}
798
+ </RadarChart>
799
+ ));
800
+ const { container } = renderTestCase((): null => null);
801
+
802
+ const axisLineElement = container.querySelector(".recharts-polar-angle-axis-line");
803
+ assertNotNull(axisLineElement);
804
+ expect(axisLineElement.tagName).toBe("circle");
805
+ expect(axisLineElement.getAttribute("fill")).toBe("none");
806
+ expect(axisLineElement.getAttribute("cx")).toBe("250");
807
+ expect(axisLineElement.getAttribute("cy")).toBe("150");
808
+ expect(axisLineElement.getAttribute("r")).toBe("116");
809
+ });
810
+
811
+ // Object-form axisLine/tickLine (recharts `SVGProps` form): extra
812
+ // presentation props restyle the shapes; geometry stays computed.
813
+ it("merges object-form axisLine presentation props onto the axis line", () => {
814
+ const renderTestCase = createSelectorTestCase((props) => (
815
+ <RadarChart width={500} height={500} data={exampleRadarData}>
816
+ <Radar dataKey="value" />
817
+ <PolarAngleAxis dataKey="value" axisLine={{ stroke: "red", strokeWidth: 2 }} />
818
+ {props.children}
819
+ </RadarChart>
820
+ ));
821
+ const { container } = renderTestCase((): null => null);
822
+
823
+ const axisLineElement = container.querySelector(".recharts-polar-angle-axis-line");
824
+ assertNotNull(axisLineElement);
825
+ expect(axisLineElement.getAttribute("stroke")).toBe("red");
826
+ expect(axisLineElement.getAttribute("stroke-width")).toBe("2");
827
+ expect(axisLineElement.getAttribute("fill")).toBe("none");
828
+ });
829
+
830
+ it("merges object-form tickLine presentation props onto each tick line", () => {
831
+ const renderTestCase = createSelectorTestCase((props) => (
832
+ <RadarChart width={500} height={500} data={exampleRadarData}>
833
+ <Radar dataKey="value" />
834
+ <PolarAngleAxis dataKey="value" tickLine={{ stroke: "red", strokeDasharray: "3 3" }} />
835
+ {props.children}
836
+ </RadarChart>
837
+ ));
838
+ const { container } = renderTestCase((): null => null);
839
+
840
+ const tickLines = container.querySelectorAll(".recharts-polar-angle-axis-tick-line");
841
+ expect(tickLines.length).toBeGreaterThan(0);
842
+ tickLines.forEach((tickLine) => {
843
+ expect(tickLine.getAttribute("stroke")).toBe("red");
844
+ expect(tickLine.getAttribute("stroke-dasharray")).toBe("3 3");
845
+ });
846
+ });
847
+
848
+ it("renders labels in reverse if reversed=true", () => {
849
+ const renderTestCase = createSelectorTestCase((props) => (
850
+ <RadarChart width={500} height={500} data={exampleRadarData}>
851
+ <Radar dataKey="value" />
852
+ <PolarAngleAxis dataKey="value" reversed />
853
+ {props.children}
854
+ </RadarChart>
855
+ ));
856
+ const { container } = renderTestCase((): null => null);
857
+
858
+ expectAngleAxisTickLabels(container, [
859
+ { textContext: "420", x: "394.24978336205567", y: "105.75021663794428" },
860
+ { textContext: "460", x: "249.99999999999997", y: "46" },
861
+ { textContext: "999", x: "105.75021663794428", y: "105.7502166379443" },
862
+ { textContext: "500", x: "46", y: "250.00000000000003" },
863
+ { textContext: "864", x: "105.7502166379443", y: "394.2497833620557" },
864
+ { textContext: "650", x: "250", y: "454" },
865
+ { textContext: "765", x: "394.2497833620557", y: "394.2497833620557" },
866
+ { textContext: "365", x: "454", y: "250" },
867
+ ]);
868
+ });
869
+
870
+ it("linear scale should produce niceTicks=undefined too because that is what the generator does", () => {
871
+ const renderTestCase = createSelectorTestCase((props) => (
872
+ <RadarChart width={500} height={500} data={exampleRadarData}>
873
+ <Radar dataKey="value" />
874
+ <PolarAngleAxis dataKey="value" type="number" />
875
+ {props.children}
876
+ </RadarChart>
877
+ ));
878
+ const { container, spy } = renderTestCase((state) =>
879
+ selectPolarNiceTicks(state, "angleAxis", 0),
880
+ );
881
+
882
+ expectAngleAxisTicks(container, [
883
+ {
884
+ x1: "343.9696838086067",
885
+ x2: "347.8051811069172",
886
+ y1: "422.0049375015452",
887
+ y2: "429.02554719548584",
888
+ },
889
+ {
890
+ x1: "298.1937708077547",
891
+ x2: "300.1608634937854",
892
+ y1: "439.9825267105625",
893
+ y2: "447.73691555589164",
894
+ },
895
+ {
896
+ x1: "249.99999999999997",
897
+ x2: "249.99999999999997",
898
+ y1: "54",
899
+ y2: "46",
900
+ },
901
+ {
902
+ x1: "249.3836324872836",
903
+ x2: "249.3584746296217",
904
+ y1: "445.9990308422194",
905
+ y2: "453.998991284759",
906
+ },
907
+ {
908
+ x1: "102.86822817046604",
909
+ x2: "96.86284972844425",
910
+ y1: "120.507754215544",
911
+ y2: "115.22235642842335",
912
+ },
913
+ {
914
+ x1: "90.9630154532783",
915
+ x2: "84.47170996157536",
916
+ y1: "364.5567001370317",
917
+ y2: "369.2324838160942",
918
+ },
919
+ {
920
+ x1: "54.96086149174786",
921
+ x2: "47.00008032814574",
922
+ y1: "230.6161291286071",
923
+ y2: "229.8249507256931",
924
+ },
925
+ {
926
+ x1: "396.72382587365814",
927
+ x2: "402.7125534603381",
928
+ y1: "379.95429550806097",
929
+ y2: "385.2585524675737",
930
+ },
931
+ ]);
932
+ expectAngleAxisTickLabels(container, [
933
+ { textContext: "420", x: "347.8051811069172", y: "429.02554719548584" },
934
+ { textContext: "460", x: "300.1608634937854", y: "447.73691555589164" },
935
+ { textContext: "999", x: "249.99999999999997", y: "46" },
936
+ { textContext: "500", x: "249.3584746296217", y: "453.998991284759" },
937
+ { textContext: "864", x: "96.86284972844425", y: "115.22235642842335" },
938
+ { textContext: "650", x: "84.47170996157536", y: "369.2324838160942" },
939
+ { textContext: "765", x: "47.00008032814574", y: "229.8249507256931" },
940
+ { textContext: "365", x: "402.7125534603381", y: "385.2585524675737" },
941
+ ]);
942
+
943
+ expectLastCalledWith(spy, undefined);
944
+ });
945
+ });
946
+
947
+ describe.each([
948
+ { axisType: "number", expectedScale: "linear" },
949
+ { axisType: "category", expectedScale: "band" },
950
+ { axisType: undefined, expectedScale: "band" },
951
+ ] as const)("uses $expectedScale scale when type=$axisType", ({ axisType, expectedScale }) => {
952
+ it("selects the expected real scale type", () => {
953
+ const renderTestCase = createSelectorTestCase((props) => (
954
+ <RadarChart width={500} height={500} data={PageData}>
955
+ <Radar dataKey="uv" />
956
+ <PolarAngleAxis dataKey="uv" type={axisType} />
957
+ {props.children}
958
+ </RadarChart>
959
+ ));
960
+ const { spy } = renderTestCase((state) => selectRealScaleType(state, "angleAxis", 0));
961
+ expectLastCalledWith(spy, expectedScale);
962
+ });
963
+ });
964
+ });
965
+
966
+ describe("in RadialBarChart", () => {
967
+ describe("with default axis", () => {
968
+ const renderTestCase = createSelectorTestCase((props) => (
969
+ <RadialBarChart width={500} height={500} data={PageData}>
970
+ <RadialBar dataKey="uv" />
971
+ <PolarAngleAxis />
972
+ <PolarRadiusAxis />
973
+ {props.children}
974
+ </RadialBarChart>
975
+ ));
976
+
977
+ it("should render ticks", () => {
978
+ const { container } = renderTestCase();
979
+ expectAngleAxisTicks(container, [
980
+ { x1: "446", x2: "454", y1: "250", y2: "250" },
981
+ {
982
+ x1: "388.5929291125633",
983
+ x2: "394.2497833620557",
984
+ y1: "111.4070708874367",
985
+ y2: "105.7502166379443",
986
+ },
987
+ { x1: "250", x2: "250", y1: "54", y2: "46" },
988
+ {
989
+ x1: "111.4070708874367",
990
+ x2: "105.7502166379443",
991
+ y1: "111.40707088743667",
992
+ y2: "105.7502166379443",
993
+ },
994
+ { x1: "54", x2: "46", y1: "249.99999999999997", y2: "249.99999999999997" },
995
+ {
996
+ x1: "111.40707088743665",
997
+ x2: "105.75021663794428",
998
+ y1: "388.5929291125633",
999
+ y2: "394.2497833620557",
1000
+ },
1001
+ { x1: "249.99999999999997", x2: "249.99999999999997", y1: "446", y2: "454" },
1002
+ {
1003
+ x1: "388.5929291125633",
1004
+ x2: "394.24978336205567",
1005
+ y1: "388.59292911256335",
1006
+ y2: "394.2497833620557",
1007
+ },
1008
+ ]);
1009
+ });
1010
+
1011
+ it("should render labels", () => {
1012
+ const { container } = renderTestCase();
1013
+ expectAngleAxisTickLabels(container, [
1014
+ { textContext: "0", x: "454", y: "250" },
1015
+ { textContext: "50", x: "394.2497833620557", y: "105.7502166379443" },
1016
+ { textContext: "100", x: "250", y: "46" },
1017
+ { textContext: "150", x: "105.7502166379443", y: "105.7502166379443" },
1018
+ { textContext: "200", x: "46", y: "249.99999999999997" },
1019
+ { textContext: "250", x: "105.75021663794428", y: "394.2497833620557" },
1020
+ { textContext: "300", x: "249.99999999999997", y: "454" },
1021
+ { textContext: "350", x: "394.24978336205567", y: "394.2497833620557" },
1022
+ ]);
1023
+ });
1024
+
1025
+ it("should select axis settings", () => {
1026
+ const { spy } = renderTestCase((state) => selectAngleAxis(state, 0));
1027
+ expectLastCalledWith(spy, {
1028
+ allowDataOverflow: false,
1029
+ allowDecimals: false,
1030
+ allowDuplicatedCategory: false,
1031
+ dataKey: undefined,
1032
+ domain: undefined,
1033
+ id: 0,
1034
+ includeHidden: false,
1035
+ name: undefined,
1036
+ reversed: false,
1037
+ niceTicks: "auto",
1038
+ scale: "auto",
1039
+ tick: true,
1040
+ tickCount: undefined,
1041
+ ticks: undefined,
1042
+ type: "number",
1043
+ unit: undefined,
1044
+ });
1045
+ });
1046
+
1047
+ it("should select applied values", () => {
1048
+ const { spy } = renderTestCase((state) => selectPolarAppliedValues(state, "angleAxis", 0));
1049
+ expectLastCalledWith(spy, [
1050
+ { value: 400 },
1051
+ { value: 300 },
1052
+ { value: 300 },
1053
+ { value: 200 },
1054
+ { value: 278 },
1055
+ { value: 189 },
1056
+ ]);
1057
+ });
1058
+
1059
+ it("should select domain", () => {
1060
+ const { spy } = renderTestCase((state) => selectPolarAxisDomain(state, "angleAxis", 0));
1061
+ expectLastCalledWith(spy, [0, 400]);
1062
+ });
1063
+
1064
+ it("should select range", () => {
1065
+ const { spy } = renderTestCase((state) => selectAngleAxisRangeWithReversed(state, 0));
1066
+ expectLastCalledWith(spy, [0, 360]);
1067
+ });
1068
+
1069
+ it("should select scale", () => {
1070
+ const { spy } = renderTestCase((state) => selectPolarAxisScale(state, "angleAxis", 0));
1071
+ expectLastCalledWithScale(spy, { domain: [0, 400], range: [0, 360] });
1072
+ });
1073
+
1074
+ it("should select real scale type", () => {
1075
+ const { spy } = renderTestCase((state) => selectRealScaleType(state, "angleAxis", 0));
1076
+ expectLastCalledWith(spy, "linear");
1077
+ });
1078
+
1079
+ it("should select polarItemsSettings", () => {
1080
+ const { spy } = renderTestCase((state) => selectPolarItemsSettings(state, "angleAxis", 0));
1081
+ expectLastCalledWith(spy, [
1082
+ {
1083
+ // Deviation: recharts auto-ids RadialBar as `radialBar-N`; this port uses
1084
+ // the kebab `recharts-radial-bar-…` prefix (an internal id detail).
1085
+ id: expect.stringMatching(/recharts-radial-bar-/),
1086
+ maxBarSize: undefined,
1087
+ minPointSize: 0,
1088
+ barSize: undefined,
1089
+ stackId: undefined,
1090
+ type: "radialBar",
1091
+ angleAxisId: 0,
1092
+ data: undefined,
1093
+ dataKey: "uv",
1094
+ hide: false,
1095
+ radiusAxisId: 0,
1096
+ },
1097
+ ]);
1098
+ });
1099
+
1100
+ it("should select ticks", () => {
1101
+ const { spy } = renderTestCase((state) =>
1102
+ selectPolarAxisTicks(state, "angleAxis", 0, false),
1103
+ );
1104
+ expectLastCalledWith(spy, [
1105
+ { coordinate: 0, index: 0, offset: -0, value: 0 },
1106
+ { coordinate: 45, index: 1, offset: -0, value: 50 },
1107
+ { coordinate: 90, index: 2, offset: -0, value: 100 },
1108
+ { coordinate: 135, index: 3, offset: -0, value: 150 },
1109
+ { coordinate: 180, index: 4, offset: -0, value: 200 },
1110
+ { coordinate: 225, index: 5, offset: -0, value: 250 },
1111
+ { coordinate: 270, index: 6, offset: -0, value: 300 },
1112
+ { coordinate: 315, index: 7, offset: -0, value: 350 },
1113
+ { coordinate: 360, index: 8, offset: -0, value: 400 },
1114
+ ]);
1115
+ });
1116
+ });
1117
+
1118
+ describe("with category axis", () => {
1119
+ const renderTestCase = createSelectorTestCase((props) => (
1120
+ <RadialBarChart width={500} height={500} data={PageData}>
1121
+ <RadialBar dataKey="uv" />
1122
+ <PolarAngleAxis type="category" />
1123
+ <PolarRadiusAxis />
1124
+ {props.children}
1125
+ </RadialBarChart>
1126
+ ));
1127
+
1128
+ it("should render ticks", () => {
1129
+ const { container } = renderTestCase();
1130
+ expectAngleAxisTicks(container, [
1131
+ {
1132
+ x1: "310.5673308974897",
1133
+ x2: "313.0394668524893",
1134
+ y1: "436.4070771938501",
1135
+ y2: "444.01552932421134",
1136
+ },
1137
+ { x1: "446", x2: "454", y1: "250", y2: "250" },
1138
+ {
1139
+ x1: "310.5673308974897",
1140
+ x2: "313.0394668524893",
1141
+ y1: "63.592922806149915",
1142
+ y2: "55.984470675788685",
1143
+ },
1144
+ {
1145
+ x1: "91.43266910251032",
1146
+ x2: "84.96053314751074",
1147
+ y1: "134.79409055067526",
1148
+ y2: "130.09180853233545",
1149
+ },
1150
+ {
1151
+ x1: "91.43266910251029",
1152
+ x2: "84.96053314751072",
1153
+ y1: "365.20590944932474",
1154
+ y2: "369.9081914676645",
1155
+ },
1156
+ ]);
1157
+ });
1158
+
1159
+ it("should render labels", () => {
1160
+ const { container } = renderTestCase();
1161
+ expectAngleAxisTickLabels(container, [
1162
+ { textContext: "400", x: "313.0394668524893", y: "444.01552932421134" },
1163
+ { textContext: "300", x: "454", y: "250" },
1164
+ { textContext: "200", x: "313.0394668524893", y: "55.984470675788685" },
1165
+ { textContext: "278", x: "84.96053314751074", y: "130.09180853233545" },
1166
+ { textContext: "189", x: "84.96053314751072", y: "369.9081914676645" },
1167
+ ]);
1168
+ });
1169
+
1170
+ it("should select axis settings", () => {
1171
+ const { spy } = renderTestCase((state) => selectAngleAxis(state, 0));
1172
+ expectLastCalledWith(spy, {
1173
+ allowDataOverflow: false,
1174
+ allowDecimals: false,
1175
+ allowDuplicatedCategory: false,
1176
+ dataKey: undefined,
1177
+ domain: undefined,
1178
+ id: 0,
1179
+ includeHidden: false,
1180
+ name: undefined,
1181
+ reversed: false,
1182
+ niceTicks: "auto",
1183
+ scale: "auto",
1184
+ tick: true,
1185
+ tickCount: undefined,
1186
+ ticks: undefined,
1187
+ type: "category",
1188
+ unit: undefined,
1189
+ });
1190
+ });
1191
+
1192
+ it("should select applied values", () => {
1193
+ const { spy } = renderTestCase((state) => selectPolarAppliedValues(state, "angleAxis", 0));
1194
+ expectLastCalledWith(spy, [
1195
+ { value: 400 },
1196
+ { value: 300 },
1197
+ { value: 300 },
1198
+ { value: 200 },
1199
+ { value: 278 },
1200
+ { value: 189 },
1201
+ ]);
1202
+ });
1203
+
1204
+ it("should select domain", () => {
1205
+ const { spy } = renderTestCase((state) => selectPolarAxisDomain(state, "angleAxis", 0));
1206
+ expectLastCalledWith(spy, [400, 300, 200, 278, 189]);
1207
+ });
1208
+
1209
+ it("should select range", () => {
1210
+ const { spy } = renderTestCase((state) => selectAngleAxisRangeWithReversed(state, 0));
1211
+ expectLastCalledWith(spy, [0, 360]);
1212
+ });
1213
+
1214
+ it("should select scale", () => {
1215
+ const { spy } = renderTestCase((state) => selectPolarAxisScale(state, "angleAxis", 0));
1216
+ expectLastCalledWithScale(spy, { domain: [400, 300, 200, 278, 189], range: [0, 360] });
1217
+ });
1218
+
1219
+ it("should select real scale type", () => {
1220
+ const { spy } = renderTestCase((state) => selectRealScaleType(state, "angleAxis", 0));
1221
+ expectLastCalledWith(spy, "band");
1222
+ });
1223
+
1224
+ it("should select polarItemsSettings", () => {
1225
+ const { spy } = renderTestCase((state) => selectPolarItemsSettings(state, "angleAxis", 0));
1226
+ expectLastCalledWith(spy, [
1227
+ {
1228
+ id: expect.stringMatching(/recharts-radial-bar-/),
1229
+ maxBarSize: undefined,
1230
+ minPointSize: 0,
1231
+ barSize: undefined,
1232
+ stackId: undefined,
1233
+ type: "radialBar",
1234
+ angleAxisId: 0,
1235
+ data: undefined,
1236
+ dataKey: "uv",
1237
+ hide: false,
1238
+ radiusAxisId: 0,
1239
+ },
1240
+ ]);
1241
+ });
1242
+
1243
+ it("should select ticks", () => {
1244
+ const { spy } = renderTestCase((state) =>
1245
+ selectPolarAxisTicks(state, "angleAxis", 0, false),
1246
+ );
1247
+ expectLastCalledWith(spy, [
1248
+ { coordinate: -72, index: 0, offset: -72, value: 400 },
1249
+ { coordinate: 0, index: 1, offset: -72, value: 300 },
1250
+ { coordinate: 72, index: 2, offset: -72, value: 200 },
1251
+ { coordinate: 144, index: 3, offset: -72, value: 278 },
1252
+ { coordinate: 216, index: 4, offset: -72, value: 189 },
1253
+ ]);
1254
+ });
1255
+ });
1256
+
1257
+ describe("with implicit axis", () => {
1258
+ const renderTestCase = createSelectorTestCase((props) => (
1259
+ <RadialBarChart width={500} height={500} data={PageData}>
1260
+ <RadialBar dataKey="uv" />
1261
+ {props.children}
1262
+ </RadialBarChart>
1263
+ ));
1264
+
1265
+ it("should not render ticks", () => {
1266
+ const { container } = renderTestCase();
1267
+ expectAngleAxisTicks(container, []);
1268
+ });
1269
+
1270
+ it("should not render axis labels", () => {
1271
+ const { container } = renderTestCase();
1272
+ expectAngleAxisTickLabels(container, []);
1273
+ });
1274
+
1275
+ it("should select axis settings", () => {
1276
+ const { spy } = renderTestCase((state) => selectAngleAxis(state, 0));
1277
+ expectLastCalledWith(spy, {
1278
+ allowDataOverflow: false,
1279
+ allowDecimals: false,
1280
+ allowDuplicatedCategory: false,
1281
+ dataKey: undefined,
1282
+ domain: undefined,
1283
+ id: 0,
1284
+ includeHidden: false,
1285
+ name: undefined,
1286
+ reversed: false,
1287
+ niceTicks: "auto",
1288
+ scale: "auto",
1289
+ tick: true,
1290
+ tickCount: undefined,
1291
+ ticks: undefined,
1292
+ type: "number",
1293
+ unit: undefined,
1294
+ });
1295
+ });
1296
+
1297
+ it("should select applied values", () => {
1298
+ const { spy } = renderTestCase((state) => selectPolarAppliedValues(state, "angleAxis", 0));
1299
+ expectLastCalledWith(spy, [
1300
+ { value: 400 },
1301
+ { value: 300 },
1302
+ { value: 300 },
1303
+ { value: 200 },
1304
+ { value: 278 },
1305
+ { value: 189 },
1306
+ ]);
1307
+ });
1308
+
1309
+ it("should select domain", () => {
1310
+ const { spy } = renderTestCase((state) => selectPolarAxisDomain(state, "angleAxis", 0));
1311
+ expectLastCalledWith(spy, [0, 400]);
1312
+ });
1313
+
1314
+ it("should select range", () => {
1315
+ const { spy } = renderTestCase((state) => selectAngleAxisRangeWithReversed(state, 0));
1316
+ expectLastCalledWith(spy, [0, 360]);
1317
+ });
1318
+
1319
+ it("should select scale", () => {
1320
+ const { spy } = renderTestCase((state) => selectPolarAxisScale(state, "angleAxis", 0));
1321
+ expectLastCalledWithScale(spy, { domain: [0, 400], range: [0, 360] });
1322
+ });
1323
+
1324
+ it("should select real scale type", () => {
1325
+ const { spy } = renderTestCase((state) => selectRealScaleType(state, "angleAxis", 0));
1326
+ expectLastCalledWith(spy, "linear");
1327
+ });
1328
+
1329
+ it("should select polarItemsSettings", () => {
1330
+ const { spy } = renderTestCase((state) => selectPolarItemsSettings(state, "angleAxis", 0));
1331
+ expectLastCalledWith(spy, [
1332
+ {
1333
+ id: expect.stringMatching(/recharts-radial-bar-/),
1334
+ maxBarSize: undefined,
1335
+ minPointSize: 0,
1336
+ barSize: undefined,
1337
+ stackId: undefined,
1338
+ type: "radialBar",
1339
+ angleAxisId: 0,
1340
+ data: undefined,
1341
+ dataKey: "uv",
1342
+ hide: false,
1343
+ radiusAxisId: 0,
1344
+ },
1345
+ ]);
1346
+ });
1347
+
1348
+ it("should select ticks", () => {
1349
+ const { spy } = renderTestCase((state) =>
1350
+ selectPolarAxisTicks(state, "angleAxis", 0, false),
1351
+ );
1352
+ expectLastCalledWith(spy, [
1353
+ { index: 0, coordinate: 0, offset: -0, value: 0 },
1354
+ { index: 1, coordinate: 45, offset: -0, value: 50 },
1355
+ { index: 2, coordinate: 90, offset: -0, value: 100 },
1356
+ { index: 3, coordinate: 135, offset: -0, value: 150 },
1357
+ { index: 4, coordinate: 180, offset: -0, value: 200 },
1358
+ { index: 5, coordinate: 225, offset: -0, value: 250 },
1359
+ { index: 6, coordinate: 270, offset: -0, value: 300 },
1360
+ { index: 7, coordinate: 315, offset: -0, value: 350 },
1361
+ { index: 8, coordinate: 360, offset: -0, value: 400 },
1362
+ ]);
1363
+ });
1364
+ });
1365
+
1366
+ describe("with reversed axis", () => {
1367
+ const renderTestCase = createSelectorTestCase((props) => (
1368
+ <RadialBarChart width={500} height={500} data={PageData}>
1369
+ <RadialBar dataKey="uv" />
1370
+ <PolarAngleAxis reversed />
1371
+ <PolarRadiusAxis />
1372
+ {props.children}
1373
+ </RadialBarChart>
1374
+ ));
1375
+
1376
+ it("should select axis settings", () => {
1377
+ const { spy } = renderTestCase((state) => selectAngleAxis(state, 0));
1378
+ expectLastCalledWith(spy, {
1379
+ allowDataOverflow: false,
1380
+ allowDecimals: false,
1381
+ allowDuplicatedCategory: false,
1382
+ dataKey: undefined,
1383
+ domain: undefined,
1384
+ id: 0,
1385
+ includeHidden: false,
1386
+ name: undefined,
1387
+ reversed: true,
1388
+ niceTicks: "auto",
1389
+ scale: "auto",
1390
+ tick: true,
1391
+ tickCount: undefined,
1392
+ ticks: undefined,
1393
+ type: "number",
1394
+ unit: undefined,
1395
+ });
1396
+ });
1397
+
1398
+ it("should select domain", () => {
1399
+ const { spy } = renderTestCase((state) => selectPolarAxisDomain(state, "angleAxis", 0));
1400
+ expectLastCalledWith(spy, [0, 400]);
1401
+ });
1402
+
1403
+ it("should select range", () => {
1404
+ const { spy } = renderTestCase((state) => selectAngleAxisRangeWithReversed(state, 0));
1405
+ expectLastCalledWith(spy, [360, 0]);
1406
+ });
1407
+
1408
+ it("should select scale", () => {
1409
+ const { spy } = renderTestCase((state) => selectPolarAxisScale(state, "angleAxis", 0));
1410
+ expectLastCalledWithScale(spy, { domain: [0, 400], range: [0, 360] });
1411
+ });
1412
+
1413
+ it("should render ticks", () => {
1414
+ const { container } = renderTestCase();
1415
+ expectAngleAxisTicks(container, [
1416
+ { x1: "446", x2: "454", y1: "250.00000000000006", y2: "250.00000000000006" },
1417
+ {
1418
+ x1: "388.5929291125633",
1419
+ x2: "394.24978336205567",
1420
+ y1: "388.59292911256335",
1421
+ y2: "394.2497833620557",
1422
+ },
1423
+ { x1: "249.99999999999997", x2: "249.99999999999997", y1: "446", y2: "454" },
1424
+ {
1425
+ x1: "111.40707088743665",
1426
+ x2: "105.75021663794428",
1427
+ y1: "388.5929291125633",
1428
+ y2: "394.2497833620557",
1429
+ },
1430
+ { x1: "54", x2: "46", y1: "249.99999999999997", y2: "249.99999999999997" },
1431
+ {
1432
+ x1: "111.4070708874367",
1433
+ x2: "105.7502166379443",
1434
+ y1: "111.40707088743667",
1435
+ y2: "105.7502166379443",
1436
+ },
1437
+ { x1: "250", x2: "250", y1: "54", y2: "46" },
1438
+ {
1439
+ x1: "388.5929291125633",
1440
+ x2: "394.2497833620557",
1441
+ y1: "111.4070708874367",
1442
+ y2: "105.7502166379443",
1443
+ },
1444
+ ]);
1445
+ });
1446
+
1447
+ it("should render labels reversed", () => {
1448
+ const { container } = renderTestCase();
1449
+ expectAngleAxisTickLabels(container, [
1450
+ { textContext: "0", x: "454", y: "250.00000000000006" },
1451
+ { textContext: "50", x: "394.24978336205567", y: "394.2497833620557" },
1452
+ { textContext: "100", x: "249.99999999999997", y: "454" },
1453
+ { textContext: "150", x: "105.75021663794428", y: "394.2497833620557" },
1454
+ { textContext: "200", x: "46", y: "249.99999999999997" },
1455
+ { textContext: "250", x: "105.7502166379443", y: "105.7502166379443" },
1456
+ { textContext: "300", x: "250", y: "46" },
1457
+ { textContext: "350", x: "394.2497833620557", y: "105.7502166379443" },
1458
+ ]);
1459
+ });
1460
+ });
1461
+
1462
+ describe("with custom angles", () => {
1463
+ const ringsData = [
1464
+ { name: "Elves", rings: 3, fill: "green" },
1465
+ { name: "Dwarves", rings: 7, fill: "blue" },
1466
+ { name: "Humans", rings: 9, fill: "red" },
1467
+ { name: "Sauron", rings: 1, fill: "black" },
1468
+ ];
1469
+
1470
+ const renderTestCase = createSelectorTestCase((props) => (
1471
+ <RadialBarChart width={500} height={500} data={ringsData} startAngle={20} endAngle={220}>
1472
+ <RadialBar dataKey="rings" />
1473
+ <PolarAngleAxis type="number" />
1474
+ <PolarRadiusAxis />
1475
+ {props.children}
1476
+ </RadialBarChart>
1477
+ ));
1478
+
1479
+ it("should select axis settings", () => {
1480
+ const { spy } = renderTestCase((state) => selectAngleAxis(state, 0));
1481
+ expectLastCalledWith(spy, {
1482
+ allowDataOverflow: false,
1483
+ allowDecimals: false,
1484
+ allowDuplicatedCategory: false,
1485
+ dataKey: undefined,
1486
+ domain: undefined,
1487
+ id: 0,
1488
+ includeHidden: false,
1489
+ name: undefined,
1490
+ reversed: false,
1491
+ niceTicks: "auto",
1492
+ scale: "auto",
1493
+ tick: true,
1494
+ tickCount: undefined,
1495
+ ticks: undefined,
1496
+ type: "number",
1497
+ unit: undefined,
1498
+ });
1499
+ });
1500
+
1501
+ it("should select polar chart options", () => {
1502
+ const { spy } = renderTestCase(selectPolarOptions);
1503
+ expectLastCalledWith(spy, {
1504
+ startAngle: 20,
1505
+ endAngle: 220,
1506
+ cx: "50%",
1507
+ cy: "50%",
1508
+ innerRadius: 0,
1509
+ outerRadius: "80%",
1510
+ });
1511
+ });
1512
+
1513
+ it("should select axis domain", () => {
1514
+ const { spy } = renderTestCase((state) => selectPolarAxisDomain(state, "angleAxis", 0));
1515
+ expectLastCalledWith(spy, [0, 9]);
1516
+ });
1517
+
1518
+ it("should select axis range", () => {
1519
+ const { spy } = renderTestCase((state) => selectAngleAxisRangeWithReversed(state, 0));
1520
+ expectLastCalledWith(spy, [20, 220]);
1521
+ });
1522
+
1523
+ it("should select scale", () => {
1524
+ const { spy } = renderTestCase((state) => selectPolarAxisScale(state, "angleAxis", 0));
1525
+ expectLastCalledWithScale(spy, { domain: [0, 9], range: [20, 220] });
1526
+ });
1527
+
1528
+ it("should render ticks in the angled part only", () => {
1529
+ const { container } = renderTestCase();
1530
+ expectAngleAxisTicks(container, [
1531
+ {
1532
+ x1: "434.179753674038",
1533
+ x2: "441.6972946403253",
1534
+ y1: "182.96405190816893",
1535
+ y2: "180.22789076156357",
1536
+ },
1537
+ {
1538
+ x1: "395.1466265693649",
1539
+ x2: "401.0709786742369",
1540
+ y1: "118.28645933111761",
1541
+ y2: "112.91039644667342",
1542
+ },
1543
+ {
1544
+ x1: "334.5516688735257",
1545
+ x2: "338.00275739897575",
1546
+ y1: "73.17518474291663",
1547
+ y2: "65.95784534466833",
1548
+ },
1549
+ {
1550
+ x1: "261.3963864664533",
1551
+ x2: "261.8615450977371",
1552
+ y1: "54.33160097883143",
1553
+ y2: "46.34513571266129",
1554
+ },
1555
+ {
1556
+ x1: "186.54814735656907",
1557
+ x2: "183.95827582010253",
1558
+ y1: "64.55496125235291",
1559
+ y2: "56.985775997346906",
1560
+ },
1561
+ {
1562
+ x1: "121.12581176046348",
1563
+ x2: "115.86564081191096",
1564
+ y1: "102.32656431977853",
1565
+ y2: "96.29907714915723",
1566
+ },
1567
+ {
1568
+ x1: "74.84800249661123",
1569
+ x2: "67.69894137402392",
1570
+ y1: "162.0353606807094",
1571
+ y2: "158.44496723910567",
1572
+ },
1573
+ {
1574
+ x1: "54.58938353111273",
1575
+ x2: "46.613440001770414",
1576
+ y1: "234.8114855483016",
1577
+ y2: "234.19154618292615",
1578
+ },
1579
+ {
1580
+ x1: "63.3594144736706",
1581
+ x2: "55.74143139096327",
1582
+ y1: "309.84389554824213",
1583
+ y2: "312.28650352980304",
1584
+ },
1585
+ {
1586
+ x1: "99.8552891486803",
1587
+ x2: "93.72693360372847",
1588
+ y1: "375.9863714985617",
1589
+ y2: "381.128672376054",
1590
+ },
1591
+ ]);
1592
+ });
1593
+ });
1594
+
1595
+ describe("RadialBarWithColors with default axis", () => {
1596
+ const renderTestCase = createSelectorTestCase((props) => (
1597
+ <RadialBarChart width={500} height={500} data={pageDataWithFillColor}>
1598
+ <RadialBar dataKey="uv" />
1599
+ <PolarAngleAxis />
1600
+ {props.children}
1601
+ </RadialBarChart>
1602
+ ));
1603
+
1604
+ it("should render ticks", () => {
1605
+ const { container } = renderTestCase();
1606
+ expectAngleAxisTicks(container, [
1607
+ { x1: "446", x2: "454", y1: "250", y2: "250" },
1608
+ {
1609
+ x1: "430.5803711701581",
1610
+ x2: "437.9509985648584",
1611
+ y1: "173.79810010211077",
1612
+ y2: "170.6878184736255",
1613
+ },
1614
+ {
1615
+ x1: "386.74765767298027",
1616
+ x2: "392.32919472085706",
1617
+ y1: "109.58604727110134",
1618
+ y2: "103.85486552706465",
1619
+ },
1620
+ {
1621
+ x1: "321.39863678123476",
1622
+ x2: "324.3128668539382",
1623
+ y1: "67.46716825244476",
1624
+ y2: "60.01684858927925",
1625
+ },
1626
+ {
1627
+ x1: "244.8155293780266",
1628
+ x2: "244.60391833223176",
1629
+ y1: "54.06858020120944",
1630
+ y2: "46.071379393095526",
1631
+ },
1632
+ {
1633
+ x1: "169.04816292043114",
1634
+ x2: "165.74400630493852",
1635
+ y1: "71.49845918468117",
1636
+ y2: "64.2126820085457",
1637
+ },
1638
+ {
1639
+ x1: "106.01801361447642",
1640
+ x2: "100.14119784363871",
1641
+ y1: "117.01433311638843",
1642
+ y2: "111.58634671297571",
1643
+ },
1644
+ {
1645
+ x1: "65.64244378044125",
1646
+ x2: "58.11764556739806",
1647
+ y1: "183.4545909566089",
1648
+ y2: "180.73845181198072",
1649
+ },
1650
+ {
1651
+ x1: "54.274272812552084",
1652
+ x2: "46.285467621227696",
1653
+ y1: "260.36531316192213",
1654
+ y2: "260.7883871685312",
1655
+ },
1656
+ {
1657
+ x1: "73.70220455569708",
1658
+ x2: "66.50637617021533",
1659
+ y1: "335.645124329869",
1660
+ y2: "339.1408436902718",
1661
+ },
1662
+ {
1663
+ x1: "120.86938700568427",
1664
+ x2: "115.59874974061017",
1665
+ y1: "397.44926174013983",
1666
+ y2: "403.46759895402306",
1667
+ },
1668
+ {
1669
+ x1: "188.35438703671548",
1670
+ x2: "185.83823956882634",
1671
+ y1: "436.0532676476845",
1672
+ y2: "443.6472785720798",
1673
+ },
1674
+ {
1675
+ x1: "265.5389020767459",
1676
+ x2: "266.1731429778376",
1677
+ y1: "445.3830661092442",
1678
+ y2: "453.35788513411137",
1679
+ },
1680
+ {
1681
+ x1: "340.278477295892",
1682
+ x2: "343.9633131038876",
1683
+ y1: "423.97067723365086",
1684
+ y2: "431.0715212023713",
1685
+ },
1686
+ {
1687
+ x1: "400.81335240048736",
1688
+ x2: "406.96899943724196",
1689
+ y1: "375.1851937639847",
1690
+ y2: "380.2947935094535",
1691
+ },
1692
+ {
1693
+ x1: "437.6187793765148",
1694
+ x2: "445.2766887388216",
1695
+ y1: "306.7026774082729",
1696
+ y2: "309.0170724045289",
1697
+ },
1698
+ ]);
1699
+ });
1700
+
1701
+ it("should render labels", () => {
1702
+ const { container } = renderTestCase();
1703
+ expectAngleAxisTickLabels(container, [
1704
+ { textContext: "0", x: "454", y: "250" },
1705
+ { textContext: "2", x: "437.9509985648584", y: "170.6878184736255" },
1706
+ { textContext: "4", x: "392.32919472085706", y: "103.85486552706465" },
1707
+ { textContext: "6", x: "324.3128668539382", y: "60.01684858927925" },
1708
+ { textContext: "8", x: "244.60391833223176", y: "46.071379393095526" },
1709
+ { textContext: "10", x: "165.74400630493852", y: "64.2126820085457" },
1710
+ { textContext: "12", x: "100.14119784363871", y: "111.58634671297571" },
1711
+ { textContext: "14", x: "58.11764556739806", y: "180.73845181198072" },
1712
+ { textContext: "16", x: "46.285467621227696", y: "260.7883871685312" },
1713
+ { textContext: "18", x: "66.50637617021533", y: "339.1408436902718" },
1714
+ { textContext: "20", x: "115.59874974061017", y: "403.46759895402306" },
1715
+ { textContext: "22", x: "185.83823956882634", y: "443.6472785720798" },
1716
+ { textContext: "24", x: "266.1731429778376", y: "453.35788513411137" },
1717
+ { textContext: "26", x: "343.9633131038876", y: "431.0715212023713" },
1718
+ { textContext: "28", x: "406.96899943724196", y: "380.2947935094535" },
1719
+ { textContext: "30", x: "445.2766887388216", y: "309.0170724045289" },
1720
+ ]);
1721
+ });
1722
+
1723
+ it("should select domain", () => {
1724
+ const { spy } = renderTestCase((state) => selectPolarAxisDomain(state, "angleAxis", 0));
1725
+ expectLastCalledWith(spy, [0, 31.47]);
1726
+ });
1727
+
1728
+ it("should select scale", () => {
1729
+ const { spy } = renderTestCase((state) => selectPolarAxisScale(state, "angleAxis", 0));
1730
+ expectLastCalledWithScale(spy, { domain: [0, 31.47], range: [0, 360] });
1731
+ });
1732
+ });
1733
+
1734
+ describe("RadialBarWithColors with implicit axis", () => {
1735
+ const renderTestCase = createSelectorTestCase((props) => (
1736
+ <RadialBarChart width={500} height={500} data={pageDataWithFillColor}>
1737
+ <RadialBar dataKey="pv" />
1738
+ {props.children}
1739
+ </RadialBarChart>
1740
+ ));
1741
+
1742
+ it("should not render ticks", () => {
1743
+ const { container } = renderTestCase();
1744
+ expectAngleAxisTicks(container, []);
1745
+ });
1746
+
1747
+ it("should not render labels", () => {
1748
+ const { container } = renderTestCase();
1749
+ expectAngleAxisTickLabels(container, []);
1750
+ });
1751
+
1752
+ it("should select domain", () => {
1753
+ const { spy } = renderTestCase((state) => selectPolarAxisDomain(state, "angleAxis", 0));
1754
+ expectLastCalledWith(spy, [0, 9800]);
1755
+ });
1756
+
1757
+ it("should select scale", () => {
1758
+ const { spy } = renderTestCase((state) => selectPolarAxisScale(state, "angleAxis", 0));
1759
+ expectLastCalledWithScale(spy, { domain: [0, 9800], range: [0, 360] });
1760
+ });
1761
+ });
1762
+
1763
+ describe.each([
1764
+ { axisType: "number", expectedScale: "linear" },
1765
+ { axisType: "category", expectedScale: "band" },
1766
+ { axisType: undefined, expectedScale: "linear" },
1767
+ ] as const)("uses $expectedScale scale when type=$axisType", ({ axisType, expectedScale }) => {
1768
+ it("selects the expected real scale type", () => {
1769
+ const renderTestCase = createSelectorTestCase((props) => (
1770
+ <RadialBarChart width={500} height={500} data={PageData}>
1771
+ <RadialBar dataKey="uv" />
1772
+ <PolarAngleAxis dataKey="uv" type={axisType} />
1773
+ {props.children}
1774
+ </RadialBarChart>
1775
+ ));
1776
+ const { spy } = renderTestCase((state) => selectRealScaleType(state, "angleAxis", 0));
1777
+ expectLastCalledWith(spy, expectedScale);
1778
+ });
1779
+ });
1780
+ });
1781
+
1782
+ describe("state integration", () => {
1783
+ // Solid deviation: the reference unmounts via `rerender()`; here a signal-driven
1784
+ // <Show> removes the axis (same pattern as Radar.spec). Call-count assertions are
1785
+ // omitted (Solid's flush timing differs from React's render count).
1786
+ it("should report its settings to Redux store, and remove it when component is removed", () => {
1787
+ const angleAxisSpy = vi.fn();
1788
+ const [showAxis, setShowAxis] = createSignal(true);
1789
+ const Comp = (): null => {
1790
+ const settings = useAppSelector((state) => selectAngleAxis(state, 0));
1791
+ createEffect(
1792
+ () => settings(),
1793
+ (v) => angleAxisSpy(v),
1794
+ );
1795
+ return null;
1796
+ };
1797
+ render(() => (
1798
+ <RadarChart width={1} height={2}>
1799
+ <Show when={showAxis()}>
1800
+ <PolarAngleAxis />
1801
+ </Show>
1802
+ <Comp />
1803
+ </RadarChart>
1804
+ ));
1805
+ flush();
1806
+
1807
+ const expectedAxis = {
1808
+ allowDataOverflow: false,
1809
+ allowDecimals: false,
1810
+ allowDuplicatedCategory: false,
1811
+ dataKey: undefined,
1812
+ domain: undefined,
1813
+ id: 0,
1814
+ includeHidden: false,
1815
+ name: undefined,
1816
+ reversed: false,
1817
+ niceTicks: "auto",
1818
+ scale: "auto",
1819
+ tick: true,
1820
+ tickCount: undefined,
1821
+ ticks: undefined,
1822
+ type: "category",
1823
+ unit: undefined,
1824
+ };
1825
+ expect(angleAxisSpy).toHaveBeenLastCalledWith(expectedAxis);
1826
+
1827
+ setShowAxis(false);
1828
+ flush();
1829
+
1830
+ expect(angleAxisSpy).toHaveBeenLastCalledWith({ ...implicitAngleAxis, type: "category" });
1831
+ });
1832
+
1833
+ it("should select angle axis settings", () => {
1834
+ const exampleTicks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
1835
+ const renderTestCase = createSelectorTestCase((props) => (
1836
+ <RadarChart
1837
+ cx={100}
1838
+ cy={150}
1839
+ outerRadius={150}
1840
+ width={600}
1841
+ height={500}
1842
+ data={exampleRadarData}
1843
+ >
1844
+ <Radar dataKey="value" angleAxisId="angle-id" />
1845
+ <PolarAngleAxis
1846
+ dataKey="value"
1847
+ allowDuplicatedCategory={false}
1848
+ angleAxisId="angle-id"
1849
+ id="html-id"
1850
+ name="angle-name"
1851
+ reversed
1852
+ scale="log"
1853
+ domain={[100, 200]}
1854
+ ticks={exampleTicks}
1855
+ tick={false}
1856
+ allowDecimals
1857
+ tickCount={19}
1858
+ />
1859
+ {props.children}
1860
+ </RadarChart>
1861
+ ));
1862
+
1863
+ const settingsCase = renderTestCase((state) => selectAngleAxis(state, "angle-id"));
1864
+ expectLastCalledWith(settingsCase.spy, {
1865
+ allowDataOverflow: false,
1866
+ allowDecimals: true,
1867
+ allowDuplicatedCategory: false,
1868
+ dataKey: "value",
1869
+ domain: [100, 200],
1870
+ id: "angle-id",
1871
+ includeHidden: false,
1872
+ name: "angle-name",
1873
+ reversed: true,
1874
+ niceTicks: "auto",
1875
+ scale: "log",
1876
+ tick: false,
1877
+ tickCount: 19,
1878
+ ticks: exampleTicks,
1879
+ type: "category",
1880
+ unit: undefined,
1881
+ });
1882
+
1883
+ const rangeCase = renderTestCase((state) =>
1884
+ selectAngleAxisRangeWithReversed(state, "angle-id"),
1885
+ );
1886
+ expectLastCalledWith(rangeCase.spy, [-270, 90]);
1887
+
1888
+ const domainCase = renderTestCase((state) =>
1889
+ selectPolarAxisDomain(state, "angleAxis", "angle-id"),
1890
+ );
1891
+ expectLastCalledWith(domainCase.spy, [420, 460, 999, 500, 864, 650, 765, 365]);
1892
+
1893
+ const scaleCase = renderTestCase((state) =>
1894
+ selectPolarAxisScale(state, "angleAxis", "angle-id"),
1895
+ );
1896
+ expectLastCalledWithScale(scaleCase.spy, {
1897
+ domain: [420, 460, 999, 500, 864, 650, 765, 365],
1898
+ range: [-270, 90],
1899
+ });
1900
+
1901
+ const ticksCase = renderTestCase((state) =>
1902
+ selectPolarAxisTicks(state, "angleAxis", "angle-id", false),
1903
+ );
1904
+ expectLastCalledWith(ticksCase.spy, [
1905
+ { coordinate: -24172.926148617094, index: 0, offset: -0, value: 1 },
1906
+ { coordinate: -21429.954757673444, index: 1, offset: -0, value: 2 },
1907
+ { coordinate: -19825.41935342046, index: 2, offset: -0, value: 3 },
1908
+ { coordinate: -18686.983366729797, index: 3, offset: -0, value: 4 },
1909
+ { coordinate: -17803.943812512767, index: 4, offset: -0, value: 5 },
1910
+ { coordinate: -17082.44796247681, index: 5, offset: -0, value: 6 },
1911
+ { coordinate: -16472.431913188248, index: 6, offset: -0, value: 7 },
1912
+ { coordinate: -15944.011975786148, index: 7, offset: -0, value: 8 },
1913
+ { coordinate: -15477.912558223828, index: 8, offset: -0, value: 9 },
1914
+ { coordinate: -15060.972421569122, index: 9, offset: -0, value: 10 },
1915
+ ]);
1916
+
1917
+ const niceTicksCase = renderTestCase((state) =>
1918
+ selectNiceTicks(state, "angleAxis", "angle-id", false),
1919
+ );
1920
+ expectLastCalledWith(niceTicksCase.spy, undefined);
1921
+ });
1922
+ });
1923
+
1924
+ describe("with custom tick formatter and numerical values", () => {
1925
+ const renderTestCase = createSelectorTestCase((props) => (
1926
+ <RadialBarChart width={500} height={500} data={PageData}>
1927
+ <RadialBar dataKey="uv" />
1928
+ <PolarAngleAxis tickFormatter={(value) => `${String(value)}°`} />
1929
+ {props.children}
1930
+ </RadialBarChart>
1931
+ ));
1932
+
1933
+ it("should render labels with custom formatter", () => {
1934
+ const { container } = renderTestCase();
1935
+ expectAngleAxisTickLabels(container, [
1936
+ { textContext: "0°", x: "454", y: "250" },
1937
+ { textContext: "50°", x: "394.2497833620557", y: "105.7502166379443" },
1938
+ { textContext: "100°", x: "250", y: "46" },
1939
+ { textContext: "150°", x: "105.7502166379443", y: "105.7502166379443" },
1940
+ { textContext: "200°", x: "46", y: "249.99999999999997" },
1941
+ { textContext: "250°", x: "105.75021663794428", y: "394.2497833620557" },
1942
+ { textContext: "300°", x: "249.99999999999997", y: "454" },
1943
+ { textContext: "350°", x: "394.24978336205567", y: "394.2497833620557" },
1944
+ ]);
1945
+ });
1946
+
1947
+ it("should call the custom tick formatter with the tick value and index", () => {
1948
+ const formatter = vi.fn((value: unknown) => `${String(value)}°`);
1949
+ const renderFormatterCase = createSelectorTestCase((props) => (
1950
+ <RadialBarChart width={500} height={500} data={PageData}>
1951
+ <RadialBar dataKey="uv" />
1952
+ <PolarAngleAxis tickFormatter={formatter} />
1953
+ {props.children}
1954
+ </RadialBarChart>
1955
+ ));
1956
+ renderFormatterCase();
1957
+ expect(formatter).toHaveBeenCalledWith(0, 0);
1958
+ expect(formatter).toHaveBeenCalledWith(50, 1);
1959
+ expect(formatter).toHaveBeenCalledWith(100, 2);
1960
+ expect(formatter).toHaveBeenLastCalledWith(350, 7);
1961
+ });
1962
+ });
1963
+
1964
+ describe("with custom tick formatter and category values", () => {
1965
+ // https://github.com/recharts/recharts/issues/6010
1966
+ const renderTestCase = createSelectorTestCase((props) => (
1967
+ <RadarChart width={500} height={500} data={exampleRadarData}>
1968
+ <Radar dataKey="value" />
1969
+ <PolarAngleAxis dataKey="name" tickFormatter={(value) => `Formatted: ${String(value)}`} />
1970
+ {props.children}
1971
+ </RadarChart>
1972
+ ));
1973
+
1974
+ it("should select ticks", () => {
1975
+ const { spy } = renderTestCase((state) => selectPolarAxisTicks(state, "angleAxis", 0, false));
1976
+ expectLastCalledWith(spy, [
1977
+ { coordinate: 90, index: 0, offset: 45, value: "iPhone 3GS" },
1978
+ { coordinate: 45, index: 1, offset: 45, value: "iPhone 4" },
1979
+ { coordinate: 0, index: 2, offset: 45, value: "iPhone 4s" },
1980
+ { coordinate: -45, index: 3, offset: 45, value: "iPhone 5" },
1981
+ { coordinate: -90, index: 4, offset: 45, value: "iPhone 5s" },
1982
+ { coordinate: -135, index: 5, offset: 45, value: "iPhone 6" },
1983
+ { coordinate: -180, index: 6, offset: 45, value: "iPhone 6s" },
1984
+ { coordinate: -225, index: 7, offset: 45, value: "iPhone 5se" },
1985
+ ]);
1986
+ });
1987
+
1988
+ it("should render labels with custom formatter", () => {
1989
+ const { container } = renderTestCase();
1990
+ expectAngleAxisTickLabels(container, [
1991
+ { textContext: "Formatted: iPhone 3GS", x: "250", y: "46" },
1992
+ { textContext: "Formatted: iPhone 4", x: "394.2497833620557", y: "105.7502166379443" },
1993
+ { textContext: "Formatted: iPhone 4s", x: "454", y: "250" },
1994
+ { textContext: "Formatted: iPhone 5", x: "394.2497833620557", y: "394.2497833620557" },
1995
+ { textContext: "Formatted: iPhone 5s", x: "250", y: "454" },
1996
+ { textContext: "Formatted: iPhone 6", x: "105.7502166379443", y: "394.2497833620557" },
1997
+ { textContext: "Formatted: iPhone 6s", x: "46", y: "250.00000000000003" },
1998
+ { textContext: "Formatted: iPhone 5se", x: "105.75021663794428", y: "105.7502166379443" },
1999
+ ]);
2000
+ });
2001
+ });
2002
+
2003
+ describe("function-form tick", () => {
2004
+ it("Renders ticks when tick is set to be a function", () => {
2005
+ const Tick = (props: PolarAngleTickContentProps) => (
2006
+ <text x={props.x} y={props.y} class="customized-tick">
2007
+ test
2008
+ </text>
2009
+ );
2010
+ const { container } = render(() => (
2011
+ <RadarChart width={500} height={500} data={exampleRadarData}>
2012
+ <Radar dataKey="value" />
2013
+ <PolarAngleAxis tick={Tick} axisLineType="circle" />
2014
+ </RadarChart>
2015
+ ));
2016
+
2017
+ expect(container.querySelectorAll(".customized-tick")).toHaveLength(exampleRadarData.length);
2018
+ });
2019
+
2020
+ it("passes custom data to the tick function", () => {
2021
+ const tick = vi.fn().mockImplementation(() => null);
2022
+
2023
+ render(() => (
2024
+ <RadarChart width={500} height={500} data={exampleRadarData}>
2025
+ <Radar dataKey="value" />
2026
+ <PolarAngleAxis tick={tick} />
2027
+ </RadarChart>
2028
+ ));
2029
+
2030
+ // Harness deviation: Solid re-runs the renderer when the polar layout
2031
+ // settles after the first flush, so assert on the final round of calls
2032
+ // (recharts' single React render calls it exactly once per tick).
2033
+ expect(tick.mock.calls.length % exampleRadarData.length).toBe(0);
2034
+ const lastRound = tick.mock.calls
2035
+ .slice(-exampleRadarData.length)
2036
+ .map((args: ReadonlyArray<unknown>) => args[0]);
2037
+ expect(lastRound[0]).toEqual({
2038
+ angle: 0,
2039
+ cx: 250,
2040
+ cy: 250,
2041
+ fill: undefined,
2042
+ index: 0,
2043
+ orientation: "outer",
2044
+ payload: {
2045
+ coordinate: 90,
2046
+ index: 0,
2047
+ offset: 45,
2048
+ value: 0,
2049
+ },
2050
+ radius: 196,
2051
+ stroke: "none",
2052
+ textAnchor: "middle",
2053
+ verticalAnchor: "end",
2054
+ x: 250,
2055
+ y: 46,
2056
+ });
2057
+ expect(lastRound[1]).toEqual({
2058
+ angle: 0,
2059
+ cx: 250,
2060
+ cy: 250,
2061
+ fill: undefined,
2062
+ index: 1,
2063
+ orientation: "outer",
2064
+ payload: {
2065
+ coordinate: 45,
2066
+ index: 1,
2067
+ offset: 45,
2068
+ value: 1,
2069
+ },
2070
+ radius: 196,
2071
+ stroke: "none",
2072
+ textAnchor: "start",
2073
+ verticalAnchor: "end",
2074
+ x: 394.2497833620557,
2075
+ y: 105.7502166379443,
2076
+ });
2077
+ });
2078
+ });
2079
+ });