solid-recharts 0.2.0 → 1.0.0

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