solid-recharts 0.2.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (488) hide show
  1. package/package.json +13 -11
  2. package/src/animation/AnimatedItems.tsx +2 -4
  3. package/src/animation/CSSTransitionAnimate.tsx +41 -39
  4. package/src/animation/JavascriptAnimate.tsx +45 -41
  5. package/src/cartesian/Area.tsx +4 -4
  6. package/src/cartesian/AreaRevealShape.tsx +1 -1
  7. package/src/cartesian/Bar.tsx +33 -21
  8. package/src/cartesian/BarStack.tsx +5 -5
  9. package/src/cartesian/Brush.tsx +19 -15
  10. package/src/cartesian/CartesianAxis.tsx +4 -4
  11. package/src/cartesian/CartesianGrid.tsx +5 -5
  12. package/src/cartesian/ErrorBar.tsx +9 -7
  13. package/src/cartesian/Funnel.tsx +3 -3
  14. package/src/cartesian/GraphicalItemClipPath.tsx +1 -1
  15. package/src/cartesian/Line.tsx +18 -16
  16. package/src/cartesian/LineDrawShape.tsx +14 -13
  17. package/src/cartesian/ReferenceArea.tsx +4 -4
  18. package/src/cartesian/ReferenceDot.tsx +4 -4
  19. package/src/cartesian/ReferenceLine.tsx +4 -4
  20. package/src/cartesian/RenderedTicksReporter.tsx +19 -17
  21. package/src/cartesian/Scatter.tsx +3 -3
  22. package/src/cartesian/XAxis.tsx +1 -1
  23. package/src/cartesian/YAxis.tsx +35 -33
  24. package/src/cartesian/ZAxis.tsx +3 -2
  25. package/src/chart/AreaChart.tsx +1 -1
  26. package/src/chart/BarChart.tsx +1 -1
  27. package/src/chart/CartesianChart.tsx +4 -3
  28. package/src/chart/CategoricalChart.tsx +5 -5
  29. package/src/chart/ComposedChart.tsx +1 -1
  30. package/src/chart/FunnelChart.tsx +1 -1
  31. package/src/chart/LineChart.tsx +1 -1
  32. package/src/chart/PieChart.tsx +4 -3
  33. package/src/chart/PolarChart.tsx +4 -3
  34. package/src/chart/RadarChart.tsx +4 -3
  35. package/src/chart/RadialBarChart.tsx +7 -3
  36. package/src/chart/RechartsWrapper.tsx +14 -24
  37. package/src/chart/Sankey.tsx +9 -6
  38. package/src/chart/ScatterChart.tsx +1 -1
  39. package/src/chart/SunburstChart.tsx +5 -4
  40. package/src/chart/Treemap.tsx +5 -4
  41. package/src/component/ActivePoints.tsx +6 -6
  42. package/src/component/Cell.tsx +23 -5
  43. package/src/component/Cursor.tsx +3 -3
  44. package/src/component/DefaultLegendContent.tsx +8 -6
  45. package/src/component/DefaultTooltipContent.tsx +14 -10
  46. package/src/component/Dots.tsx +5 -5
  47. package/src/component/Label.tsx +13 -10
  48. package/src/component/LabelList.tsx +12 -7
  49. package/src/component/Legend.tsx +26 -21
  50. package/src/component/ResponsiveContainer.tsx +52 -49
  51. package/src/component/Text.tsx +5 -5
  52. package/src/component/Tooltip.tsx +21 -18
  53. package/src/component/TooltipBoundingBox.tsx +18 -16
  54. package/src/component/responsiveContainerUtils.ts +1 -1
  55. package/src/container/ClipPathProvider.tsx +3 -3
  56. package/src/container/Layer.tsx +5 -5
  57. package/src/container/RootSurface.tsx +1 -1
  58. package/src/container/Surface.tsx +5 -6
  59. package/src/context/ErrorBarContext.tsx +2 -2
  60. package/src/context/PanoramaContext.tsx +2 -2
  61. package/src/context/RegisterGraphicalItemId.tsx +4 -2
  62. package/src/context/chartDataContext.tsx +26 -23
  63. package/src/context/chartLayoutContext.tsx +16 -12
  64. package/src/polar/Pie.tsx +13 -12
  65. package/src/polar/PolarAngleAxis.tsx +3 -3
  66. package/src/polar/PolarGrid.tsx +5 -5
  67. package/src/polar/PolarRadiusAxis.tsx +3 -3
  68. package/src/polar/Radar.tsx +3 -3
  69. package/src/polar/RadialBar.tsx +3 -3
  70. package/src/shape/Cross.tsx +5 -5
  71. package/src/shape/Curve.tsx +6 -7
  72. package/src/shape/Dot.tsx +4 -4
  73. package/src/shape/Polygon.tsx +5 -5
  74. package/src/shape/Rectangle.tsx +22 -20
  75. package/src/shape/Sector.tsx +5 -5
  76. package/src/shape/Symbols.tsx +5 -5
  77. package/src/shape/Trapezoid.tsx +29 -27
  78. package/src/state/RechartsStoreProvider.tsx +5 -3
  79. package/src/state/ReportChartProps.tsx +8 -6
  80. package/src/state/ReportEventSettings.tsx +8 -6
  81. package/src/state/ReportMainChartProps.tsx +11 -9
  82. package/src/state/ReportPolarOptions.tsx +15 -13
  83. package/src/state/SetLegendPayload.ts +1 -1
  84. package/src/state/SetTooltipEntrySettings.tsx +1 -1
  85. package/src/state/brushSlice.ts +10 -8
  86. package/src/state/cartesianAxisSlice.ts +46 -38
  87. package/src/state/chartDataSlice.ts +29 -23
  88. package/src/state/errorBarSlice.ts +22 -16
  89. package/src/state/eventSettingsSlice.ts +11 -9
  90. package/src/state/graphicalItemsSlice.ts +17 -13
  91. package/src/state/layoutSlice.ts +27 -19
  92. package/src/state/legendSlice.ts +24 -18
  93. package/src/state/optionsSlice.ts +8 -6
  94. package/src/state/polarAxisSlice.ts +21 -13
  95. package/src/state/polarOptionsSlice.ts +16 -14
  96. package/src/state/referenceElementsSlice.ts +25 -19
  97. package/src/state/registerInStore.ts +15 -13
  98. package/src/state/renderedTicksSlice.ts +11 -7
  99. package/src/state/rootPropsSlice.ts +16 -14
  100. package/src/state/tooltipSlice.ts +115 -95
  101. package/src/state/unregisterOnCleanup.ts +5 -20
  102. package/src/state/zIndexSlice.ts +50 -42
  103. package/src/synchronisation/useChartSynchronisation.tsx +213 -217
  104. package/src/util/ActiveShapeUtils.tsx +2 -2
  105. package/src/util/BarUtils.tsx +5 -3
  106. package/src/util/DirectPortal.tsx +107 -0
  107. package/src/util/FunnelUtils.tsx +1 -1
  108. package/src/util/RadialBarUtils.tsx +4 -3
  109. package/src/util/createCartesianCharts.tsx +1 -1
  110. package/src/util/createPolarCharts.tsx +1 -1
  111. package/src/util/svgPropertiesAndEvents.ts +1 -1
  112. package/src/util/tooltip/translate.ts +2 -2
  113. package/src/util/types.ts +2 -2
  114. package/src/zIndex/ZIndexLayer.tsx +39 -68
  115. package/src/zIndex/ZIndexPortal.tsx +29 -25
  116. package/test/_data.ts +0 -408
  117. package/test/animation/AnimationController.typed.spec.ts +0 -53
  118. package/test/animation/AnimationControllerImpl.spec.ts +0 -271
  119. package/test/animation/CSSTransitionAnimate.timing.spec.tsx +0 -473
  120. package/test/animation/JavascriptAnimate.spec.tsx +0 -62
  121. package/test/animation/RechartsAnimation.spec.ts +0 -636
  122. package/test/animation/easing.spec.ts +0 -218
  123. package/test/animation/legacyAnimationLengthChange.spec.tsx +0 -803
  124. package/test/animation/matchBy.spec.ts +0 -467
  125. package/test/animation/mockAnimationController.ts +0 -40
  126. package/test/animation/mockControllerAnimationManager.ts +0 -143
  127. package/test/animation/mockTimeoutController.ts +0 -114
  128. package/test/animation/timeoutController.spec.ts +0 -138
  129. package/test/animation/useAnimationStartSnapshot.spec.ts +0 -147
  130. package/test/animation/util.spec.ts +0 -28
  131. package/test/cartesian/Area.animation.spec.tsx +0 -363
  132. package/test/cartesian/Area.range.spec.tsx +0 -54
  133. package/test/cartesian/Area.spec.tsx +0 -1202
  134. package/test/cartesian/Area.stacked.render.spec.tsx +0 -69
  135. package/test/cartesian/Area.typed.spec.tsx +0 -209
  136. package/test/cartesian/Axis.integration.spec.tsx +0 -158
  137. package/test/cartesian/Bar/Bar.csstransition.spec.tsx +0 -299
  138. package/test/cartesian/Bar/Bar.spec.tsx +0 -2314
  139. package/test/cartesian/Bar/Bar.typed.spec.tsx +0 -192
  140. package/test/cartesian/Bar.animation.spec.tsx +0 -426
  141. package/test/cartesian/Bar.stackDomain.spec.tsx +0 -66
  142. package/test/cartesian/Bar.stacked.render.spec.tsx +0 -53
  143. package/test/cartesian/Bar.truncateByDomain.spec.tsx +0 -237
  144. package/test/cartesian/Bar.zeroDimensionFiltering.spec.tsx +0 -336
  145. package/test/cartesian/BarStack.spec.tsx +0 -91
  146. package/test/cartesian/Brush.keyboard.spec.tsx +0 -88
  147. package/test/cartesian/Brush.panorama.spec.tsx +0 -41
  148. package/test/cartesian/Brush.props.spec.tsx +0 -63
  149. package/test/cartesian/Brush.render.spec.tsx +0 -117
  150. package/test/cartesian/Brush.spec.tsx +0 -522
  151. package/test/cartesian/Brush.stacked.spec.tsx +0 -221
  152. package/test/cartesian/CartesianAxis.render.spec.tsx +0 -50
  153. package/test/cartesian/CartesianAxis.spec.tsx +0 -396
  154. package/test/cartesian/CartesianGrid.render.spec.tsx +0 -39
  155. package/test/cartesian/CartesianGrid.spec.tsx +0 -2103
  156. package/test/cartesian/ErrorBar.render.spec.tsx +0 -69
  157. package/test/cartesian/ErrorBar.spec.tsx +0 -2414
  158. package/test/cartesian/Funnel.animation.spec.tsx +0 -241
  159. package/test/cartesian/Funnel.spec.tsx +0 -226
  160. package/test/cartesian/Funnel.typed.spec.tsx +0 -221
  161. package/test/cartesian/GraphicalItemClipPath.scale-behavior.spec.tsx +0 -627
  162. package/test/cartesian/GraphicalItemClipPath.spec.tsx +0 -427
  163. package/test/cartesian/Line.animation.spec.tsx +0 -643
  164. package/test/cartesian/Line.sparseAnimationPath.spec.tsx +0 -98
  165. package/test/cartesian/Line.spec.tsx +0 -471
  166. package/test/cartesian/Line.typed.spec.tsx +0 -152
  167. package/test/cartesian/ReferenceArea.render.spec.tsx +0 -63
  168. package/test/cartesian/ReferenceArea.spec.tsx +0 -663
  169. package/test/cartesian/ReferenceArea.typed.spec.tsx +0 -74
  170. package/test/cartesian/ReferenceDot.render.spec.tsx +0 -55
  171. package/test/cartesian/ReferenceDot.spec.tsx +0 -462
  172. package/test/cartesian/ReferenceDot.typed.spec.tsx +0 -76
  173. package/test/cartesian/ReferenceLine/ReferenceLine.panorama.spec.tsx +0 -184
  174. package/test/cartesian/ReferenceLine/ReferenceLine.spec.tsx +0 -744
  175. package/test/cartesian/ReferenceLine/ReferenceLine.typed.spec.tsx +0 -74
  176. package/test/cartesian/ReferenceLine/getEndPoints.spec.ts +0 -399
  177. package/test/cartesian/ReferenceLine.render.spec.tsx +0 -134
  178. package/test/cartesian/Scatter.animation.spec.tsx +0 -381
  179. package/test/cartesian/Scatter.render.spec.tsx +0 -61
  180. package/test/cartesian/Scatter.spec.tsx +0 -406
  181. package/test/cartesian/Scatter.typed.spec.tsx +0 -153
  182. package/test/cartesian/XAxis/XAxis.barSize.spec.tsx +0 -336
  183. package/test/cartesian/XAxis/XAxis.brush.spec.tsx +0 -266
  184. package/test/cartesian/XAxis/XAxis.categorydomain.spec.tsx +0 -872
  185. package/test/cartesian/XAxis/XAxis.dataKey.spec.tsx +0 -86
  186. package/test/cartesian/XAxis/XAxis.datatypes.spec.tsx +0 -127
  187. package/test/cartesian/XAxis/XAxis.hide.spec.tsx +0 -106
  188. package/test/cartesian/XAxis/XAxis.multiaxis.spec.tsx +0 -336
  189. package/test/cartesian/XAxis/XAxis.numberdomain.spec.tsx +0 -1466
  190. package/test/cartesian/XAxis/XAxis.padding.spec.tsx +0 -758
  191. package/test/cartesian/XAxis/XAxis.padding_clip.spec.tsx +0 -65
  192. package/test/cartesian/XAxis/XAxis.state.spec.tsx +0 -355
  193. package/test/cartesian/XAxis/XAxis.tick.spec.tsx +0 -493
  194. package/test/cartesian/XAxis/XAxis.timescale.spec.tsx +0 -233
  195. package/test/cartesian/XAxis/XAxis.type.spec.tsx +0 -107
  196. package/test/cartesian/XAxis/XAxis.typed.spec.tsx +0 -102
  197. package/test/cartesian/XAxis/XAxis.vertical.spec.tsx +0 -265
  198. package/test/cartesian/XAxis.tickFormatter.spec.tsx +0 -54
  199. package/test/cartesian/YAxis/YAxis.7362.derivedDomain.spec.tsx +0 -230
  200. package/test/cartesian/YAxis/YAxis.7362.spec.tsx +0 -104
  201. package/test/cartesian/YAxis/YAxis.interval-zero.spec.tsx +0 -88
  202. package/test/cartesian/YAxis/YAxis.label.spec.tsx +0 -219
  203. package/test/cartesian/YAxis/YAxis.spec.tsx +0 -1595
  204. package/test/cartesian/YAxis/YAxis.tick.spec.tsx +0 -428
  205. package/test/cartesian/YAxis/YAxis.tickFormatter.spec.tsx +0 -54
  206. package/test/cartesian/YAxis/YAxis.ticks.spec.tsx +0 -263
  207. package/test/cartesian/YAxis/YAxis.type.spec.tsx +0 -107
  208. package/test/cartesian/YAxis/YAxis.typed.spec.tsx +0 -102
  209. package/test/cartesian/ZAxis.spec.tsx +0 -300
  210. package/test/cartesian/ZAxis.typed.spec.tsx +0 -33
  211. package/test/cartesian/__snapshots__/Brush.spec.tsx.snap +0 -5
  212. package/test/cartesian/axisLineAndStroke.spec.tsx +0 -72
  213. package/test/cartesian/getCartesianPosition.spec.ts +0 -907
  214. package/test/cartesian/getEquidistantTicks.spec.ts +0 -88
  215. package/test/cartesian/getTicks.spec.ts +0 -378
  216. package/test/cartesian/miscFeatureGaps.spec.tsx +0 -89
  217. package/test/cartesian/useAnimatedLineLength.spec.ts +0 -168
  218. package/test/chart/AccessibilityLayer.spec.tsx +0 -569
  219. package/test/chart/AccessibilityScans.spec.tsx +0 -286
  220. package/test/chart/AreaChart.spec.tsx +0 -409
  221. package/test/chart/AreaChart.stacked.spec.tsx +0 -1407
  222. package/test/chart/AreaChart.typed.spec.tsx +0 -39
  223. package/test/chart/BarChart.spec.tsx +0 -3719
  224. package/test/chart/BarChart.typed.spec.tsx +0 -60
  225. package/test/chart/CategoricalChart.spec.tsx +0 -255
  226. package/test/chart/ComposedChart.spec.tsx +0 -199
  227. package/test/chart/ComposedChart.typed.spec.tsx +0 -39
  228. package/test/chart/FunnelChart.spec.tsx +0 -215
  229. package/test/chart/FunnelChart.typed.spec.tsx +0 -39
  230. package/test/chart/LineChart.multiseries.spec.tsx +0 -50
  231. package/test/chart/LineChart.smoke.spec.tsx +0 -50
  232. package/test/chart/LineChart.spec.tsx +0 -930
  233. package/test/chart/LineChart.typed.spec.tsx +0 -39
  234. package/test/chart/NicheChartTooltip.spec.tsx +0 -81
  235. package/test/chart/PieChart.spec.tsx +0 -793
  236. package/test/chart/PieChart.typed.spec.tsx +0 -39
  237. package/test/chart/RadarChart.spec.tsx +0 -530
  238. package/test/chart/RadarChart.typed.spec.tsx +0 -39
  239. package/test/chart/RadialBarChart.5966.spec.tsx +0 -48
  240. package/test/chart/RadialBarChart.spec.tsx +0 -679
  241. package/test/chart/RadialBarChart.typed.spec.tsx +0 -39
  242. package/test/chart/RechartsWrapper.spec.tsx +0 -83
  243. package/test/chart/Sankey.content.spec.tsx +0 -46
  244. package/test/chart/Sankey.spec.tsx +0 -952
  245. package/test/chart/Sankey.typed.spec.tsx +0 -29
  246. package/test/chart/ScatterChart.spec.tsx +0 -2613
  247. package/test/chart/ScatterChart.typed.spec.tsx +0 -39
  248. package/test/chart/SunburstChart.spec.tsx +0 -146
  249. package/test/chart/Treemap.animation.spec.tsx +0 -52
  250. package/test/chart/Treemap.spec.tsx +0 -1003
  251. package/test/chart/Treemap.typed.spec.tsx +0 -26
  252. package/test/chart/chartEvents.spec.tsx +0 -127
  253. package/test/chart/responsive.spec.tsx +0 -620
  254. package/test/component/Cell.render.spec.tsx +0 -155
  255. package/test/component/Cell.spec.tsx +0 -12
  256. package/test/component/Cursor.spec.tsx +0 -186
  257. package/test/component/DefaultTooltipContent.spec.tsx +0 -102
  258. package/test/component/Label.render.spec.tsx +0 -63
  259. package/test/component/Label.spec.tsx +0 -686
  260. package/test/component/Label.typed.spec.tsx +0 -46
  261. package/test/component/LabelList.spec.tsx +0 -188
  262. package/test/component/Legend.itemSorter.spec.tsx +0 -704
  263. package/test/component/Legend.render.spec.tsx +0 -92
  264. package/test/component/Legend.spec.tsx +0 -2213
  265. package/test/component/Legend.typed.spec.tsx +0 -22
  266. package/test/component/ResponsiveContainer.spec.tsx +0 -523
  267. package/test/component/ResponsiveContainerDataTest.spec.tsx +0 -51
  268. package/test/component/Text.spec.tsx +0 -415
  269. package/test/component/Text.typed.spec.tsx +0 -46
  270. package/test/component/Tooltip/ActiveDot.spec.tsx +0 -370
  271. package/test/component/Tooltip/Tooltip.animation.spec.tsx +0 -209
  272. package/test/component/Tooltip/Tooltip.content.spec.tsx +0 -128
  273. package/test/component/Tooltip/Tooltip.formatter.spec.tsx +0 -152
  274. package/test/component/Tooltip/Tooltip.includeHidden.spec.tsx +0 -79
  275. package/test/component/Tooltip/Tooltip.multipleDataArrays.spec.tsx +0 -165
  276. package/test/component/Tooltip/Tooltip.offset.spec.tsx +0 -113
  277. package/test/component/Tooltip/Tooltip.state.spec.tsx +0 -74
  278. package/test/component/Tooltip/Tooltip.sync.spec.tsx +0 -639
  279. package/test/component/Tooltip/defaultIndex.spec.tsx +0 -227
  280. package/test/component/Tooltip/graphicalItem.formatter.spec.tsx +0 -138
  281. package/test/component/Tooltip/itemSorter.spec.tsx +0 -2815
  282. package/test/component/Tooltip/tooltipEventType.spec.tsx +0 -344
  283. package/test/component/Tooltip/tooltipMouseHoverSelectors.ts +0 -41
  284. package/test/component/Tooltip/tooltipTestHelpers.tsx +0 -162
  285. package/test/component/Tooltip.defaultIndex.spec.tsx +0 -48
  286. package/test/component/Tooltip.hover.spec.tsx +0 -61
  287. package/test/component/Tooltip.item.spec.tsx +0 -54
  288. package/test/component/Tooltip.keyboard.spec.tsx +0 -51
  289. package/test/component/Tooltip.payload.spec.tsx +0 -1716
  290. package/test/component/Tooltip.touch.spec.tsx +0 -39
  291. package/test/component/Tooltip.visibility.spec.tsx +0 -1889
  292. package/test/component/TooltipBoundingBox.spec.tsx +0 -89
  293. package/test/component/responsiveContainerUtils.spec.ts +0 -205
  294. package/test/container/ClipPath.spec.tsx +0 -602
  295. package/test/container/chartDimensions.spec.tsx +0 -368
  296. package/test/context/chartLayoutContext.spec.tsx +0 -378
  297. package/test/helper/ExpectAxisDomain.tsx +0 -27
  298. package/test/helper/assertNotNull.ts +0 -6
  299. package/test/helper/assertZIndexLayerOrder.ts +0 -19
  300. package/test/helper/createSelectorTestCase.tsx +0 -176
  301. package/test/helper/expectAnimatedPieAngles.ts +0 -100
  302. package/test/helper/expectAnimatedPiePaths.ts +0 -78
  303. package/test/helper/expectAreaCurve.ts +0 -15
  304. package/test/helper/expectAxisTicks.ts +0 -48
  305. package/test/helper/expectBars.ts +0 -54
  306. package/test/helper/expectFunctionReturning.ts +0 -58
  307. package/test/helper/expectLabel.ts +0 -32
  308. package/test/helper/expectLastCalledWith.ts +0 -48
  309. package/test/helper/expectLine.ts +0 -20
  310. package/test/helper/expectPieSectors.ts +0 -80
  311. package/test/helper/expectScale.ts +0 -37
  312. package/test/helper/expectScatterPoints.ts +0 -52
  313. package/test/helper/expectStackGroups.ts +0 -144
  314. package/test/helper/mockAxes.ts +0 -22
  315. package/test/helper/mockGetBoundingClientRect.ts +0 -66
  316. package/test/helper/mockHTMLElementProperty.ts +0 -19
  317. package/test/helper/mockTouchingElement.ts +0 -27
  318. package/test/helper/offsetHelpers.ts +0 -19
  319. package/test/helper/parameterizedTestCases.tsx +0 -99
  320. package/test/helper/produceState.ts +0 -32
  321. package/test/helper/selectorTestHelpers.tsx +0 -63
  322. package/test/helper/trim.spec.ts +0 -35
  323. package/test/helper/trim.ts +0 -11
  324. package/test/hooks/useActiveTooltipDataPoints.spec.tsx +0 -358
  325. package/test/hooks/useAxisDomain.spec.tsx +0 -361
  326. package/test/hooks/useAxisScale.spec.tsx +0 -283
  327. package/test/hooks/useAxisTicks.spec.tsx +0 -130
  328. package/test/hooks/useOffset.spec.tsx +0 -248
  329. package/test/hooks/useTooltipStateHooks.spec.tsx +0 -109
  330. package/test/polar/Pie/Pie-TwoLevelPieChart.spec.tsx +0 -135
  331. package/test/polar/Pie/Pie.spec.tsx +0 -784
  332. package/test/polar/Pie/Pie.typed.spec.tsx +0 -78
  333. package/test/polar/Pie.animation.spec.tsx +0 -529
  334. package/test/polar/PieWithLegend.animation.spec.tsx +0 -142
  335. package/test/polar/PolarAngleAxis/PolarAngleAxis.events.spec.tsx +0 -76
  336. package/test/polar/PolarAngleAxis/PolarAngleAxis.spec.tsx +0 -2079
  337. package/test/polar/PolarAngleAxis/PolarAngleAxis.typed.spec.tsx +0 -102
  338. package/test/polar/PolarAngleAxis.render.spec.tsx +0 -79
  339. package/test/polar/PolarGrid.render.spec.tsx +0 -75
  340. package/test/polar/PolarGrid.spec.tsx +0 -918
  341. package/test/polar/PolarLegendPerRow.render.spec.tsx +0 -85
  342. package/test/polar/PolarRadiusAxis.events.spec.tsx +0 -65
  343. package/test/polar/PolarRadiusAxis.render.spec.tsx +0 -52
  344. package/test/polar/PolarRadiusAxis.spec.tsx +0 -991
  345. package/test/polar/PolarRadiusAxis.typed.spec.tsx +0 -84
  346. package/test/polar/PolarTooltipLegend.render.spec.tsx +0 -80
  347. package/test/polar/Radar.animation.spec.tsx +0 -570
  348. package/test/polar/Radar.render.spec.tsx +0 -71
  349. package/test/polar/Radar.spec.tsx +0 -265
  350. package/test/polar/Radar.typed.spec.tsx +0 -119
  351. package/test/polar/RadialBar/RadialBar.spec.tsx +0 -1521
  352. package/test/polar/RadialBar/RadialBar.typed.spec.tsx +0 -132
  353. package/test/polar/RadialBar.animation.spec.tsx +0 -375
  354. package/test/polar/RadialBar.render.spec.tsx +0 -66
  355. package/test/polar/RadialBar.stacked.spec.tsx +0 -57
  356. package/test/setup.ts +0 -84
  357. package/test/shape/ActiveShape.spec.tsx +0 -181
  358. package/test/shape/Cross.spec.tsx +0 -60
  359. package/test/shape/Cross.typed.spec.tsx +0 -26
  360. package/test/shape/Curve.spec.tsx +0 -368
  361. package/test/shape/Curve.typed.spec.tsx +0 -69
  362. package/test/shape/Dot.spec.tsx +0 -73
  363. package/test/shape/Dot.typed.spec.tsx +0 -30
  364. package/test/shape/Polygon.spec.tsx +0 -357
  365. package/test/shape/Polygon.typed.spec.tsx +0 -28
  366. package/test/shape/Rectangle.animation.spec.tsx +0 -451
  367. package/test/shape/Rectangle.spec.tsx +0 -68
  368. package/test/shape/Rectangle.typed.spec.tsx +0 -24
  369. package/test/shape/Sector.spec.tsx +0 -76
  370. package/test/shape/Sector.typed.spec.tsx +0 -24
  371. package/test/shape/Symbols.spec.tsx +0 -43
  372. package/test/shape/Symbols.typed.spec.tsx +0 -24
  373. package/test/shape/Trapezoid.spec.tsx +0 -50
  374. package/test/shape/Trapezoid.typed.spec.tsx +0 -24
  375. package/test/shape/__snapshots__/Cross.spec.tsx.snap +0 -62
  376. package/test/shape/__snapshots__/Curve.spec.tsx.snap +0 -460
  377. package/test/shape/__snapshots__/Polygon.spec.tsx.snap +0 -58
  378. package/test/shape/__snapshots__/Rectangle.spec.tsx.snap +0 -117
  379. package/test/shape/__snapshots__/Sector.spec.tsx.snap +0 -71
  380. package/test/shape/__snapshots__/Trapezoid.spec.tsx.snap +0 -64
  381. package/test/state/chartDataSlice.spec.ts +0 -53
  382. package/test/state/createCollectionActions.spec.ts +0 -87
  383. package/test/state/createSelector.spec.ts +0 -158
  384. package/test/state/externalEventsMiddleware.spec.ts +0 -178
  385. package/test/state/graphicalItemsSlice.spec.ts +0 -92
  386. package/test/state/hooks.spec.tsx +0 -68
  387. package/test/state/legendSlice.spec.ts +0 -44
  388. package/test/state/mouseEventsMiddleware.spec.ts +0 -75
  389. package/test/state/optionsSlice.spec.ts +0 -19
  390. package/test/state/referenceElementsSlice.spec.ts +0 -84
  391. package/test/state/registerInStore.spec.tsx +0 -101
  392. package/test/state/selectors/areaSelectors.spec.tsx +0 -77
  393. package/test/state/selectors/axisSelectors.spec.tsx +0 -1418
  394. package/test/state/selectors/barStackSelectors.spec.tsx +0 -752
  395. package/test/state/selectors/brushSelectors.spec.tsx +0 -30
  396. package/test/state/selectors/cartesianAxisSlice.spec.ts +0 -96
  397. package/test/state/selectors/combineNiceTicks.spec.ts +0 -207
  398. package/test/state/selectors/combiners/combineActiveTooltipIndex.spec.ts +0 -61
  399. package/test/state/selectors/combiners/combineAllBarPositions.spec.ts +0 -39
  400. package/test/state/selectors/combiners/combineConfiguredScale.spec.ts +0 -56
  401. package/test/state/selectors/combiners/combineDisplayedStackedData.spec.ts +0 -123
  402. package/test/state/selectors/combiners/combineRealScaleType.spec.ts +0 -80
  403. package/test/state/selectors/containerSelectors.spec.tsx +0 -168
  404. package/test/state/selectors/dataSelectors.spec.tsx +0 -136
  405. package/test/state/selectors/legendSelectors.spec.tsx +0 -113
  406. package/test/state/selectors/lineSelectors.spec.tsx +0 -60
  407. package/test/state/selectors/pieSelectors.spec.tsx +0 -72
  408. package/test/state/selectors/radarSelectors.spec.tsx +0 -496
  409. package/test/state/selectors/rootPropsSelectors.spec.tsx +0 -169
  410. package/test/state/selectors/scatterSelectors.spec.tsx +0 -47
  411. package/test/state/selectors/selectActiveTooltipIndex.spec.tsx +0 -234
  412. package/test/state/selectors/selectAllAxes.spec.tsx +0 -18
  413. package/test/state/selectors/selectAxisDomain.spec.tsx +0 -21
  414. package/test/state/selectors/selectAxisDomainIncludingNiceTicks.spec.tsx +0 -19
  415. package/test/state/selectors/selectAxisRangeWithReverse.spec.tsx +0 -22
  416. package/test/state/selectors/selectAxisScale.spec.tsx +0 -91
  417. package/test/state/selectors/selectBarRectangles.stackOffset.spec.tsx +0 -503
  418. package/test/state/selectors/selectBaseAxis.spec.tsx +0 -56
  419. package/test/state/selectors/selectCartesianItemsSettings.spec.tsx +0 -57
  420. package/test/state/selectors/selectChartOffset.spec.tsx +0 -26
  421. package/test/state/selectors/selectDisplayedData.spec.tsx +0 -282
  422. package/test/state/selectors/selectIsTooltipActive.spec.tsx +0 -231
  423. package/test/state/selectors/selectNumericalDomain.spec.tsx +0 -21
  424. package/test/state/selectors/selectRealScaleType.spec.tsx +0 -19
  425. package/test/state/selectors/selectStackGroups.spec.tsx +0 -322
  426. package/test/state/selectors/selectXAxisPosition.spec.tsx +0 -22
  427. package/test/state/selectors/selectYAxisPosition.spec.tsx +0 -22
  428. package/test/state/selectors/selectorMemoization.spec.tsx +0 -136
  429. package/test/state/selectors/selectors.spec.tsx +0 -1613
  430. package/test/state/throttling.spec.ts +0 -200
  431. package/test/state/zIndexSlice.spec.ts +0 -85
  432. package/test/synchronisation/useChartSynchronisation.spec.tsx +0 -225
  433. package/test/util/BarUtils.spec.ts +0 -39
  434. package/test/util/CartesianUtils/CartesianUtils.spec.ts +0 -261
  435. package/test/util/CartesianUtils/rectWithPoints.spec.ts +0 -48
  436. package/test/util/ChartUtils/ChartUtils.spec.ts +0 -491
  437. package/test/util/ChartUtils/appendOffsetOfLegend.spec.ts +0 -136
  438. package/test/util/ChartUtils/appendOffsetOfLegend.spec.tsx +0 -133
  439. package/test/util/ChartUtils/getCateCoordinateOfLine.spec.ts +0 -97
  440. package/test/util/ChartUtils/getStackedData.spec.ts +0 -416
  441. package/test/util/ChartUtils/truncateByDomain.spec.ts +0 -70
  442. package/test/util/DataUtils.spec.ts +0 -385
  443. package/test/util/DomUtils.spec.tsx +0 -117
  444. package/test/util/FunnelUtils.spec.tsx +0 -70
  445. package/test/util/Global.spec.ts +0 -11
  446. package/test/util/LRUCache.spec.ts +0 -81
  447. package/test/util/LogUtils.spec.ts +0 -45
  448. package/test/util/PolarUtils.spec.ts +0 -66
  449. package/test/util/ReduceCssCalcPrototype.spec.ts +0 -141
  450. package/test/util/ShallowEqual.spec.ts +0 -102
  451. package/test/util/TickUtils.spec.ts +0 -29
  452. package/test/util/createChartHelpers.spec.tsx +0 -210
  453. package/test/util/cursor/getCursorPoints.spec.ts +0 -136
  454. package/test/util/cursor/getCursorRectangle.spec.ts +0 -50
  455. package/test/util/cursor/getRadialCursorPoints.spec.ts +0 -36
  456. package/test/util/errorValue.spec.ts +0 -69
  457. package/test/util/getEveryNth.spec.ts +0 -39
  458. package/test/util/getRadiusAndStrokeWidthFromDot.spec.ts +0 -51
  459. package/test/util/getRelativeCoordinate.spec.ts +0 -250
  460. package/test/util/getSliced.spec.ts +0 -45
  461. package/test/util/isDomainSpecifiedByUser.spec.ts +0 -207
  462. package/test/util/isWellBehavedNumber.spec.ts +0 -54
  463. package/test/util/payload/getUniqPayload.spec.ts +0 -56
  464. package/test/util/propsAreEqual.spec.ts +0 -75
  465. package/test/util/round.spec.ts +0 -112
  466. package/test/util/scale/arithmetic.spec.ts +0 -61
  467. package/test/util/scale/createCategoricalInverse.spec.ts +0 -84
  468. package/test/util/scale/getNiceTickValues.spec.ts +0 -421
  469. package/test/util/scale/getTickValuesFixedDomain.spec.ts +0 -155
  470. package/test/util/svgPropertiesAndEvents.spec.tsx +0 -206
  471. package/test/util/svgPropertiesNoEvents.spec.tsx +0 -228
  472. package/test/util/tooltip/translate.spec.ts +0 -396
  473. package/test/util/useAnimationId.spec.tsx +0 -59
  474. package/test/util/useElementOffset.spec.tsx +0 -173
  475. package/test/util/usePrefersReducedMotion.spec.ts +0 -54
  476. package/test/util/useUniqueId.spec.ts +0 -99
  477. package/test/utils/diagnostics-allowlist.ts +0 -18
  478. package/test/utils/diagnostics.ts +0 -58
  479. package/test/zIndex/AllZIndexPortals.spec.tsx +0 -83
  480. package/test/zIndex/DefaultZIndexes.spec.ts +0 -80
  481. package/test/zIndex/DynamicZIndex.spec.tsx +0 -102
  482. package/test/zIndex/ZIndexLayer.portalOwner.spec.tsx +0 -125
  483. package/test/zIndex/componentZIndex.spec.tsx +0 -255
  484. package/test/zIndex/getZIndexFromUnknown.spec.ts +0 -51
  485. package/test/zIndex/multiChartZIndexIsolation.spec.tsx +0 -90
  486. package/test/zIndex/zIndexSelectors.spec.ts +0 -172
  487. package/test-results/.last-run.json +0 -4
  488. package/tsconfig.json +0 -11
@@ -1,1889 +0,0 @@
1
- /*
2
- * Ported from recharts 3.8.1 test/component/Tooltip/Tooltip.visibility.spec.tsx (commit 7a23854).
3
- * Solid adaptations: render(() => …)/flush; Wrapper uses props.children; createSignal for portal;
4
- * flush() replaces act+fake timers; tooltipTestHelpers mouseMove path.
5
- */
6
- import { createSignal, flush, Show } from "solid-js";
7
- import type { JSX } from "@solidjs/web";
8
- import { beforeEach, describe, expect, it, test, vi } from "vitest";
9
- import { fireEvent, getByText, render } from "@solidjs/testing-library";
10
- import {
11
- Area,
12
- AreaChart,
13
- Bar,
14
- BarChart,
15
- Brush,
16
- CartesianGrid,
17
- ComposedChart,
18
- DefaultZIndexes,
19
- Funnel,
20
- FunnelChart,
21
- Legend,
22
- Line,
23
- LineChart,
24
- LineDrawShape,
25
- Pie,
26
- PieChart,
27
- PolarAngleAxis,
28
- PolarGrid,
29
- PolarRadiusAxis,
30
- Radar,
31
- RadarChart,
32
- RadialBar,
33
- RadialBarChart,
34
- Sankey,
35
- Scatter,
36
- ScatterChart,
37
- SunburstChart,
38
- Tooltip,
39
- Treemap,
40
- XAxis,
41
- YAxis,
42
- } from "../../src";
43
- import { mockGetBoundingClientRect } from "../helper/mockGetBoundingClientRect";
44
- import { exampleSankeyData, exampleSunburstData, exampleTreemapData, PageData } from "../_data";
45
- import {
46
- expectTooltipNotVisible,
47
- expectTooltipPayload,
48
- getTooltip,
49
- MouseCoordinate,
50
- showTooltip,
51
- showTooltipOnCoordinate,
52
- showTooltipOnCoordinateTouch,
53
- } from "./Tooltip/tooltipTestHelpers";
54
- import {
55
- areaChartMouseHoverTooltipSelector,
56
- barChartMouseHoverTooltipSelector,
57
- composedChartMouseHoverTooltipSelector,
58
- funnelChartMouseHoverTooltipSelector,
59
- lineChartMouseHoverTooltipSelector,
60
- MouseHoverTooltipTriggerSelector,
61
- pieChartMouseHoverTooltipSelector,
62
- radarChartMouseHoverTooltipSelector,
63
- radialBarChartMouseHoverTooltipSelector,
64
- sankeyNodeMouseHoverTooltipSelector,
65
- scatterChartMouseHoverTooltipSelector,
66
- sunburstChartMouseHoverTooltipSelector,
67
- treemapNodeChartMouseHoverTooltipSelector,
68
- } from "./Tooltip/tooltipMouseHoverSelectors";
69
- import { createSelectorTestCase } from "../helper/createSelectorTestCase";
70
- import {
71
- selectActiveCoordinate,
72
- selectActiveLabel,
73
- selectIsTooltipActive,
74
- selectTooltipAxisDomain,
75
- selectTooltipAxisDomainIncludingNiceTicks,
76
- selectTooltipAxisRangeWithReverse,
77
- selectTooltipAxisRealScaleType,
78
- selectTooltipAxisScale,
79
- selectTooltipAxisTicks,
80
- selectTooltipCategoricalDomain,
81
- } from "../../src/state/selectors/tooltipSelectors";
82
- import { selectChartDataWithIndexes } from "../../src/state/selectors/dataSelectors";
83
- import { expectLastCalledWithScale } from "../helper/expectScale";
84
- import { selectChartLayout } from "../../src/context/chartLayoutContext";
85
- import type { TooltipIndex, TooltipState } from "../../src/state/tooltipSlice";
86
- import { selectTooltipState } from "../../src/state/selectors/selectTooltipState";
87
- import { selectChartOffsetInternal } from "../../src/state/selectors/selectChartOffsetInternal";
88
- import {
89
- selectLegendPayload,
90
- selectLegendSettings,
91
- selectLegendSize,
92
- } from "../../src/state/selectors/legendSelectors";
93
- import { mockTouchingElement } from "../helper/mockTouchingElement";
94
- import { assertNotNull } from "../helper/assertNotNull";
95
- import type { LegendSettings } from "../../src/state/legendSlice";
96
- import { selectTooltipAxisId } from "../../src/state/selectors/selectTooltipAxisId";
97
- import { selectTooltipAxisType } from "../../src/state/selectors/selectTooltipAxisType";
98
- import { expectLastCalledWith } from "../helper/expectLastCalledWith";
99
- import { selectTooltipAxis } from "../../src/state/selectors/axisSelectors";
100
- import { noop } from "../../src/util/DataUtils";
101
-
102
- type TooltipVisibilityTestCase = {
103
- // For identifying which test is running
104
- name: string;
105
- mouseHoverSelector: MouseHoverTooltipTriggerSelector;
106
- mouseCoordinate?: MouseCoordinate;
107
- Wrapper: (props: { children: JSX.Element }) => JSX.Element;
108
- expectedTransform: string;
109
- tooltipIndex: NonNullable<TooltipIndex>;
110
- };
111
-
112
- const commonChartProps = {
113
- throttledEvents: [],
114
- width: 400,
115
- height: 400,
116
- data: PageData,
117
- };
118
-
119
- const AreaChartTestCase: TooltipVisibilityTestCase = {
120
- name: "AreaChart",
121
- Wrapper: (props) => (
122
- <AreaChart {...commonChartProps}>
123
- <Area dataKey="uv" id="my-item-id" />
124
- {props.children}
125
- </AreaChart>
126
- ),
127
- mouseHoverSelector: areaChartMouseHoverTooltipSelector,
128
- expectedTransform: "transform: translate(249px, 211px);",
129
- tooltipIndex: "0",
130
- };
131
-
132
- const BarChartTestCase: TooltipVisibilityTestCase = {
133
- name: "BarChart",
134
- Wrapper: (props) => (
135
- <BarChart {...commonChartProps}>
136
- <Bar dataKey="uv" id="my-item-id" />
137
- {props.children}
138
- </BarChart>
139
- ),
140
- mouseHoverSelector: barChartMouseHoverTooltipSelector,
141
- expectedTransform: "transform: translate(242.5px, 211px);",
142
- tooltipIndex: "0",
143
- };
144
-
145
- const LineChartHorizontalTestCase: TooltipVisibilityTestCase = {
146
- name: "horizontal LineChart",
147
- Wrapper: (props) => (
148
- <LineChart {...commonChartProps}>
149
- <XAxis dataKey="name" />
150
- <YAxis />
151
- <CartesianGrid strokeDasharray="3 3" />
152
- {props.children}
153
- <Legend />
154
- <Line type="monotone" dataKey="uv" stroke="#82ca9d" id="my-item-id" />
155
- </LineChart>
156
- ),
157
- mouseHoverSelector: lineChartMouseHoverTooltipSelector,
158
- expectedTransform: "transform: translate(207px, 211px);",
159
- tooltipIndex: "0",
160
- };
161
-
162
- const LineChartVerticalTestCase: TooltipVisibilityTestCase = {
163
- name: "vertical LineChart",
164
- Wrapper: (props) => (
165
- <LineChart
166
- layout="vertical"
167
- {...commonChartProps}
168
- margin={{
169
- top: 20,
170
- right: 30,
171
- left: 20,
172
- bottom: 5,
173
- }}
174
- >
175
- <CartesianGrid strokeDasharray="3 3" />
176
- <XAxis type="number" />
177
- <YAxis dataKey="name" type="category" />
178
- {props.children}
179
- <Legend />
180
- <Line dataKey="uv" stroke="#82ca9d" id="my-item-id" />
181
- </LineChart>
182
- ),
183
- mouseHoverSelector: lineChartMouseHoverTooltipSelector,
184
- expectedTransform: "transform: translate(211px, 231px);",
185
- tooltipIndex: "0",
186
- };
187
-
188
- const ComposedChartWithAreaTestCase: TooltipVisibilityTestCase = {
189
- name: "ComposedChart with Area",
190
- Wrapper: (props) => (
191
- <ComposedChart {...commonChartProps}>
192
- <XAxis dataKey="name" type="category" />
193
- <YAxis dataKey="uv" />
194
- {props.children}
195
- <Area dataKey="pv" id="my-item-id" />
196
- </ComposedChart>
197
- ),
198
- mouseHoverSelector: composedChartMouseHoverTooltipSelector,
199
- expectedTransform: "transform: translate(207px, 211px);",
200
- tooltipIndex: "0",
201
- };
202
-
203
- const ComposedChartWithBarTestCase: TooltipVisibilityTestCase = {
204
- name: "ComposedChart with Bar",
205
- Wrapper: (props) => (
206
- <ComposedChart {...commonChartProps}>
207
- <XAxis dataKey="name" type="category" />
208
- <YAxis dataKey="uv" />
209
- {props.children}
210
- <Bar dataKey="amt" id="my-item-id" />
211
- </ComposedChart>
212
- ),
213
- mouseHoverSelector: composedChartMouseHoverTooltipSelector,
214
- expectedTransform: "transform: translate(212.5px, 211px);",
215
- tooltipIndex: "0",
216
- };
217
-
218
- const ComposedChartWithLineTestCase: TooltipVisibilityTestCase = {
219
- name: "ComposedChart with Line",
220
- Wrapper: (props) => (
221
- <ComposedChart {...commonChartProps}>
222
- <XAxis dataKey="name" type="category" />
223
- <YAxis dataKey="amt" />
224
- {props.children}
225
- <Line dataKey="pv" id="my-item-id" />
226
- </ComposedChart>
227
- ),
228
- mouseHoverSelector: composedChartMouseHoverTooltipSelector,
229
- expectedTransform: "transform: translate(207px, 211px);",
230
- tooltipIndex: "0",
231
- };
232
-
233
- const FunnelChartTestCase: TooltipVisibilityTestCase = {
234
- name: "FunnelChart",
235
- Wrapper: (props) => (
236
- <FunnelChart width={700} height={500} throttledEvents={[]}>
237
- <Funnel
238
- isAnimationActive={false}
239
- dataKey="uv"
240
- nameKey="name"
241
- data={PageData}
242
- id="my-item-id"
243
- />
244
- {props.children}
245
- </FunnelChart>
246
- ),
247
- mouseHoverSelector: funnelChartMouseHoverTooltipSelector,
248
- expectedTransform: "transform: translate(360px, 55.833333333333336px);",
249
- tooltipIndex: "0",
250
- };
251
-
252
- const PieChartTestCase: TooltipVisibilityTestCase = {
253
- name: "PieChart",
254
- Wrapper: (props) => (
255
- <PieChart height={400} width={400}>
256
- <Pie
257
- data={PageData}
258
- isAnimationActive={false}
259
- dataKey="uv"
260
- nameKey="name"
261
- cx={200}
262
- cy={200}
263
- id="my-item-id"
264
- />
265
- {props.children}
266
- </PieChart>
267
- ),
268
- mouseHoverSelector: pieChartMouseHoverTooltipSelector,
269
- expectedTransform: "transform: translate(271.8676024097812px, 161.6138988484545px);",
270
- tooltipIndex: "0",
271
- };
272
-
273
- const RadarChartTestCase: TooltipVisibilityTestCase = {
274
- name: "RadarChart",
275
- Wrapper: (props) => (
276
- <RadarChart height={600} width={600} data={PageData} throttledEvents={[]}>
277
- <PolarGrid />
278
- <PolarAngleAxis dataKey="name" />
279
- <PolarRadiusAxis />
280
- <Radar
281
- name="Mike"
282
- dataKey="uv"
283
- stroke="#8884d8"
284
- fill="#8884d8"
285
- fillOpacity={0.6}
286
- id="my-item-id"
287
- />
288
- {props.children}
289
- </RadarChart>
290
- ),
291
- mouseHoverSelector: radarChartMouseHoverTooltipSelector,
292
- expectedTransform: "transform: translate(188.75025773223268px, 239.9964286625318px);",
293
- tooltipIndex: "0",
294
- };
295
-
296
- const RadialBarChartTestCase: TooltipVisibilityTestCase = {
297
- name: "RadialBarChart",
298
- Wrapper: (props) => (
299
- <RadialBarChart height={600} width={600} data={PageData} throttledEvents={[]}>
300
- <PolarGrid />
301
- <PolarAngleAxis />
302
- <PolarRadiusAxis dataKey="name" />
303
- <RadialBar
304
- name="Mike"
305
- dataKey="uv"
306
- stroke="#8884d8"
307
- fill="#8884d8"
308
- fillOpacity={0.6}
309
- id="my-item-id"
310
- />
311
- {props.children}
312
- </RadialBarChart>
313
- ),
314
- mouseHoverSelector: radialBarChartMouseHoverTooltipSelector,
315
- expectedTransform: "transform: translate(212.65496645665198px, 212.65496645665195px);",
316
- tooltipIndex: "0",
317
- };
318
-
319
- const SankeyTestCase: TooltipVisibilityTestCase = {
320
- name: "Sankey",
321
- Wrapper: (props) => (
322
- <Sankey
323
- id="my-item-id"
324
- width={400}
325
- height={400}
326
- margin={{ top: 20, right: 20, bottom: 20, left: 20 }}
327
- data={exampleSankeyData}
328
- throttledEvents={[]}
329
- >
330
- {props.children}
331
- </Sankey>
332
- ),
333
- mouseHoverSelector: sankeyNodeMouseHoverTooltipSelector,
334
- expectedTransform: "transform: translate(35px, 114.89236115144739px);",
335
- tooltipIndex: "0",
336
- };
337
-
338
- const ScatterChartTestCase: TooltipVisibilityTestCase = {
339
- name: "ScatterChart",
340
- Wrapper: (props) => (
341
- <ScatterChart
342
- width={400}
343
- height={400}
344
- margin={{ top: 20, right: 20, bottom: 20, left: 20 }}
345
- throttledEvents={[]}
346
- >
347
- <XAxis dataKey="uv" name="stature" unit="cm" />
348
- <YAxis dataKey="pv" name="weight" unit="kg" />
349
- <Scatter line name="A school" data={PageData} fill="#ff7300" id="my-item-id" />
350
- {props.children}
351
- </ScatterChart>
352
- ),
353
- mouseHoverSelector: scatterChartMouseHoverTooltipSelector,
354
- expectedTransform: "transform: translate(115px, 280.8px);",
355
- tooltipIndex: "0",
356
- };
357
-
358
- const SunburstChartTestCase: TooltipVisibilityTestCase = {
359
- name: "SunburstChart",
360
- Wrapper: (props) => (
361
- <SunburstChart
362
- id="my-item-id"
363
- width={400}
364
- height={400}
365
- data={exampleSunburstData}
366
- throttledEvents={[]}
367
- >
368
- {props.children}
369
- </SunburstChart>
370
- ),
371
- mouseHoverSelector: sunburstChartMouseHoverTooltipSelector,
372
- expectedTransform: "transform: translate(285px, 210px);",
373
- tooltipIndex: "0",
374
- };
375
-
376
- const TreemapTestCase: TooltipVisibilityTestCase = {
377
- name: "Treemap",
378
- Wrapper: (props) => (
379
- <Treemap
380
- id="my-item-id"
381
- width={400}
382
- height={400}
383
- data={exampleTreemapData}
384
- isAnimationActive={false}
385
- nameKey="name"
386
- dataKey="value"
387
- throttledEvents={[]}
388
- >
389
- {props.children}
390
- </Treemap>
391
- ),
392
- mouseHoverSelector: treemapNodeChartMouseHoverTooltipSelector,
393
- expectedTransform: "transform: translate(94.5px, 58.5px);",
394
- tooltipIndex: "children[0]children[0]",
395
- };
396
-
397
- const testCases: ReadonlyArray<TooltipVisibilityTestCase> = [
398
- AreaChartTestCase,
399
- BarChartTestCase,
400
- LineChartHorizontalTestCase,
401
- LineChartVerticalTestCase,
402
- ComposedChartWithAreaTestCase,
403
- ComposedChartWithBarTestCase,
404
- ComposedChartWithLineTestCase,
405
- FunnelChartTestCase,
406
- PieChartTestCase,
407
- RadarChartTestCase,
408
- RadialBarChartTestCase,
409
- SankeyTestCase,
410
- ScatterChartTestCase,
411
- SunburstChartTestCase,
412
- TreemapTestCase,
413
- ];
414
-
415
- describe("Tooltip visibility", () => {
416
- beforeEach(() => {
417
- mockGetBoundingClientRect({ width: 100, height: 100 });
418
- });
419
-
420
- describe.each(testCases)(
421
- "as a child of $name",
422
- ({ name, Wrapper, mouseHoverSelector, expectedTransform, tooltipIndex }) => {
423
- test("Without an event, the tooltip wrapper is rendered but not visible", () => {
424
- const { container } = render(() => (
425
- <Wrapper>
426
- <Tooltip />
427
- </Wrapper>
428
- ));
429
- flush();
430
-
431
- const wrapper = getTooltip(container);
432
- expect(wrapper).toBeInTheDocument();
433
- expect(wrapper).not.toBeVisible();
434
- });
435
-
436
- test("No content is rendered without an explicit event", () => {
437
- const { container } = render(() => (
438
- <Wrapper>
439
- <Tooltip />
440
- </Wrapper>
441
- ));
442
- flush();
443
-
444
- const tooltipContentName = container.querySelector(".recharts-tooltip-item-name");
445
- const tooltipContentValue = container.querySelector(".recharts-tooltip-item-value");
446
- expect(tooltipContentName).toBeNull();
447
- expect(tooltipContentValue).toBeNull();
448
- });
449
-
450
- test(`Mouse over element ${mouseHoverSelector} renders content`, () => {
451
- const { container, debug } = render(() => (
452
- <Wrapper>
453
- <Tooltip />
454
- </Wrapper>
455
- ));
456
- flush();
457
-
458
- showTooltip(container, mouseHoverSelector, debug);
459
-
460
- const tooltip = getTooltip(container);
461
- expect(tooltip).toBeVisible();
462
-
463
- // After the mouse over event over the chart, the tooltip wrapper still is not set to visible,
464
- // but the content is already created based on the nearest data point.
465
- const tooltipContentName = container.querySelector(".recharts-tooltip-item-name");
466
- const tooltipContentValue = container.querySelector(".recharts-tooltip-item-value");
467
- expect(tooltipContentName).not.toBeNull();
468
- expect(tooltipContentValue).not.toBeNull();
469
- expect(tooltipContentName).toBeInTheDocument();
470
- expect(tooltipContentValue).toBeInTheDocument();
471
- });
472
-
473
- test("Should move when the mouse moves", async () => {
474
- mockGetBoundingClientRect({
475
- width: 10,
476
- height: 10,
477
- });
478
- const { container } = render(() => (
479
- <Wrapper>
480
- <Tooltip />
481
- </Wrapper>
482
- ));
483
- flush();
484
-
485
- const tooltipTriggerElement = showTooltip(container, mouseHoverSelector);
486
-
487
- const tooltip1 = getTooltip(container);
488
- expect(tooltip1.getAttribute("style")).toContain("position: absolute;");
489
- expect(tooltip1.getAttribute("style")).toContain("top: 0px");
490
- expect(tooltip1.getAttribute("style")).toContain("left: 0px");
491
-
492
- fireEvent.mouseMove(tooltipTriggerElement, { clientX: 201, clientY: 201 });
493
-
494
- flush();
495
- vi.runOnlyPendingTimers();
496
- flush();
497
-
498
- const tooltip2 = getTooltip(container);
499
-
500
- expect(tooltip2.getAttribute("style")).toContain(expectedTransform);
501
- });
502
-
503
- it(`should move tooltip onTouchMove with active tooltip index ${tooltipIndex}`, async (context) => {
504
- // TODO: these charts currently do not work onTouchMove. Did they before?
505
- // This is because these are set via item rather than axis. The middleware currently only sets axis coordinates.
506
- if (
507
- name === "SunburstChart" ||
508
- name === "FunnelChart" ||
509
- name === "Sankey" ||
510
- name === "ScatterChart"
511
- ) {
512
- context.skip();
513
- }
514
-
515
- mockTouchingElement(tooltipIndex, "my-item-id");
516
-
517
- mockGetBoundingClientRect({
518
- width: 10,
519
- height: 10,
520
- });
521
- const { container } = render(() => (
522
- <Wrapper>
523
- <Tooltip />
524
- </Wrapper>
525
- ));
526
- flush();
527
-
528
- showTooltipOnCoordinateTouch(container, mouseHoverSelector, {
529
- clientX: 200,
530
- clientY: 200,
531
- });
532
-
533
- const tooltip1 = getTooltip(container);
534
- expect(tooltip1.getAttribute("style")).toContain("position: absolute;");
535
- expect(tooltip1.getAttribute("style")).toContain("top: 0px");
536
- expect(tooltip1.getAttribute("style")).toContain("left: 0px");
537
-
538
- showTooltipOnCoordinateTouch(container, mouseHoverSelector, {
539
- clientX: 201,
540
- clientY: 201,
541
- });
542
-
543
- const tooltip2 = getTooltip(container);
544
-
545
- expect(tooltip2.getAttribute("style")).toContain(expectedTransform);
546
- });
547
-
548
- it("should render customized tooltip when content is set to be a react element", () => {
549
- const Customized = () => <div class="customized" />;
550
- const { container } = render(() => (
551
- <Wrapper>
552
- <Tooltip content={<Customized />} />
553
- </Wrapper>
554
- ));
555
- flush();
556
-
557
- showTooltip(container, mouseHoverSelector);
558
-
559
- const customizedContent = container.querySelector(".customized");
560
- expect(customizedContent).toBeInTheDocument();
561
- });
562
-
563
- describe("portal prop", () => {
564
- it("should render outside of SVG, as a direct child of recharts-wrapper by default", () => {
565
- const { container } = render(() => (
566
- <Wrapper>
567
- <Tooltip />
568
- </Wrapper>
569
- ));
570
- flush();
571
- showTooltip(container, mouseHoverSelector);
572
-
573
- expect(
574
- container.querySelectorAll(".recharts-wrapper svg .recharts-tooltip-wrapper"),
575
- ).toHaveLength(0);
576
- expect(
577
- container.querySelector(".recharts-wrapper > .recharts-tooltip-wrapper"),
578
- ).toBeVisible();
579
- });
580
-
581
- it('should render in a custom portal if "portal" prop is set', () => {
582
- function Example() {
583
- const [portalRef, setPortalRef] = createSignal<HTMLElement | null>(null);
584
-
585
- return (
586
- <>
587
- <Show when={portalRef()}>
588
- {(portal) => (
589
- <Wrapper>
590
- <Tooltip portal={portal()} />
591
- </Wrapper>
592
- )}
593
- </Show>
594
- <div
595
- data-testid="my-custom-portal-target"
596
- ref={(node) => {
597
- setPortalRef(node ?? null);
598
- }}
599
- />
600
- </>
601
- );
602
- }
603
- const { container } = render(() => <Example />);
604
- flush();
605
- showTooltip(container, mouseHoverSelector);
606
-
607
- expect(
608
- container.querySelector(".recharts-wrapper .recharts-tooltip-wrapper"),
609
- ).not.toBeInTheDocument();
610
- expect(
611
- container.querySelector(
612
- '[data-testid="my-custom-portal-target"] > .recharts-tooltip-wrapper',
613
- ),
614
- ).toBeVisible();
615
- });
616
-
617
- it("should keep custom portal visible when active is true after mouseOut, should no longer have absolute styles", () => {
618
- function Example() {
619
- const [portalRef, setPortalRef] = createSignal<HTMLElement | null>(null);
620
-
621
- return (
622
- <>
623
- <Show when={portalRef()}>
624
- {(portal) => (
625
- <Wrapper>
626
- <Tooltip portal={portal()} active />
627
- </Wrapper>
628
- )}
629
- </Show>
630
- <div
631
- data-testid="my-custom-portal-target"
632
- ref={(node) => {
633
- setPortalRef(node ?? null);
634
- }}
635
- />
636
- </>
637
- );
638
- }
639
- const { container } = render(() => <Example />);
640
- flush();
641
- showTooltip(container, mouseHoverSelector);
642
-
643
- const tooltipWrapper = container.querySelector(".recharts-tooltip-wrapper");
644
-
645
- expect(tooltipWrapper).toHaveStyle({ visibility: "visible" });
646
- expect(tooltipWrapper).not.toHaveStyle({ position: "absolute" });
647
-
648
- fireEvent.mouseLeave(container, mouseHoverSelector);
649
-
650
- expect(tooltipWrapper).toHaveStyle({ visibility: "visible" });
651
- expect(tooltipWrapper).not.toHaveStyle({ position: "absolute" });
652
-
653
- expect(
654
- container.querySelector(
655
- '[data-testid="my-custom-portal-target"] > .recharts-tooltip-wrapper',
656
- ),
657
- ).toBeVisible();
658
- });
659
- });
660
-
661
- describe("active prop", () => {
662
- test("with active=true it should render tooltip even after moving the mouse out of the chart.", () => {
663
- const { container } = render(() => (
664
- <Wrapper>
665
- <Tooltip active />
666
- </Wrapper>
667
- ));
668
- flush();
669
-
670
- const tooltip = getTooltip(container);
671
- expect(tooltip).not.toBeVisible();
672
-
673
- showTooltip(container, mouseHoverSelector);
674
-
675
- expect(tooltip).toBeVisible();
676
-
677
- const tooltipTriggerElementAfterHover = container.querySelector(mouseHoverSelector);
678
- assertNotNull(tooltipTriggerElementAfterHover);
679
- fireEvent.mouseOut(tooltipTriggerElementAfterHover);
680
- vi.runAllTimers();
681
-
682
- // Still visible after moving out of the chart, because active is true.
683
- expect(tooltip).toBeVisible();
684
- });
685
-
686
- test("with active=false it should never render tooltip", () => {
687
- const { container } = render(() => (
688
- <Wrapper>
689
- <Tooltip active={false} />
690
- </Wrapper>
691
- ));
692
- flush();
693
-
694
- const tooltip = getTooltip(container);
695
- expect(tooltip).not.toBeVisible();
696
-
697
- showTooltip(container, mouseHoverSelector);
698
-
699
- expect(tooltip).not.toBeVisible();
700
-
701
- const tooltipTriggerElementAfterHover = container.querySelector(mouseHoverSelector);
702
- assertNotNull(tooltipTriggerElementAfterHover);
703
- fireEvent.mouseOut(tooltipTriggerElementAfterHover);
704
- vi.runAllTimers();
705
-
706
- expect(tooltip).not.toBeVisible();
707
- });
708
-
709
- test("with active=undefined it should render the Tooltip only while in the chart", () => {
710
- const { container } = render(() => (
711
- <Wrapper>
712
- <Tooltip />
713
- </Wrapper>
714
- ));
715
- flush();
716
-
717
- const tooltip = getTooltip(container);
718
- expect(tooltip).not.toBeVisible();
719
-
720
- showTooltip(container, mouseHoverSelector);
721
-
722
- expect(tooltip).toBeVisible();
723
-
724
- const tooltipTriggerElementAfterHover = container.querySelector(mouseHoverSelector);
725
- assertNotNull(tooltipTriggerElementAfterHover);
726
- fireEvent.mouseOut(tooltipTriggerElementAfterHover);
727
- vi.runAllTimers();
728
-
729
- expect(tooltip).not.toBeVisible();
730
- });
731
- });
732
-
733
- describe("defaultIndex prop", () => {
734
- it("should show tooltip from the beginning if defaultIndex is set to a valid value", (context) => {
735
- if (name === "Sankey") {
736
- /*
737
- * Sankey chart won't work with numerical indexes and it will need a different format
738
- */
739
- context.skip();
740
- }
741
- const { container } = render(() => (
742
- <Wrapper>
743
- <Tooltip defaultIndex={tooltipIndex} />
744
- </Wrapper>
745
- ));
746
- flush();
747
-
748
- const tooltip = getTooltip(container);
749
- expect(tooltip).toBeInTheDocument();
750
-
751
- // Tooltip should be visible, since defaultIndex was set
752
- expect(tooltip).toBeVisible();
753
-
754
- const tooltipTriggerElement = showTooltip(container, mouseHoverSelector);
755
-
756
- // Tooltip should be able to move when the mouse moves over the chart
757
- expect(tooltip).toBeVisible();
758
-
759
- fireEvent.mouseOver(tooltipTriggerElement, { clientX: 350, clientY: 200 });
760
-
761
- // Tooltip should be able to move when the mouse moves over the chart
762
- expect(tooltip).toBeVisible();
763
-
764
- const tooltipTriggerElementAfterHover = container.querySelector(mouseHoverSelector);
765
- assertNotNull(tooltipTriggerElementAfterHover);
766
- fireEvent.mouseOut(tooltipTriggerElementAfterHover);
767
- vi.runAllTimers();
768
-
769
- // Since active is false, the tooltip can be dismissed by mousing out
770
- expect(tooltip).not.toBeVisible();
771
- });
772
-
773
- it("should ignore invalid defaultIndex value", () => {
774
- const { container } = render(() => (
775
- <Wrapper>
776
- <Tooltip defaultIndex={NaN} />
777
- </Wrapper>
778
- ));
779
- flush();
780
-
781
- const tooltip = getTooltip(container);
782
- expect(tooltip).toBeInTheDocument();
783
- expect(tooltip).not.toBeVisible();
784
- });
785
-
786
- it("should show the last item when defaultIndex is same or larger than the data.length", (context) => {
787
- if (name === "FunnelChart") {
788
- // FunnelChart throws an error when called with defaultIndex
789
- context.skip();
790
- }
791
- if (name === "Sankey") {
792
- // Sankey chart does not support numeric tooltip indexes
793
- context.skip();
794
- }
795
- if (name === "Treemap") {
796
- // Treemap chart does not support numeric tooltip indexes
797
- context.skip();
798
- }
799
- if (name === "SunburstChart") {
800
- // SunburstChart does not support numeric tooltip indexes
801
- context.skip();
802
- }
803
- const { container } = render(() => (
804
- <Wrapper>
805
- <Tooltip defaultIndex={commonChartProps.data.length} />
806
- </Wrapper>
807
- ));
808
- flush();
809
-
810
- const tooltip = getTooltip(container);
811
- expect(tooltip).toBeInTheDocument();
812
- expect(tooltip).toBeVisible();
813
- });
814
- });
815
- },
816
- );
817
-
818
- describe(`as a child of vertical LineChart`, () => {
819
- const renderTestCase = createSelectorTestCase((props) => (
820
- <LineChartVerticalTestCase.Wrapper>
821
- <Tooltip />
822
- {props.children}
823
- </LineChartVerticalTestCase.Wrapper>
824
- ));
825
-
826
- it("should select chart layout", () => {
827
- const { spy } = renderTestCase(selectChartLayout);
828
- expectLastCalledWith(spy, "vertical");
829
- });
830
-
831
- it("should select chart offset", () => {
832
- const { spy } = renderTestCase(selectChartOffsetInternal);
833
- expectLastCalledWith(spy, {
834
- bottom: 135,
835
- brushBottom: 35,
836
- height: 245,
837
- left: 80,
838
- right: 30,
839
- top: 20,
840
- width: 290,
841
- });
842
- });
843
-
844
- it("should select legend settings", () => {
845
- const { spy } = renderTestCase(selectLegendSettings);
846
- const expected: LegendSettings = {
847
- align: "center",
848
- itemSorter: "value",
849
- layout: "horizontal",
850
- verticalAlign: "bottom",
851
- };
852
- expectLastCalledWith(spy, expected);
853
- });
854
-
855
- it("should select legend size", () => {
856
- const { spy } = renderTestCase(selectLegendSize);
857
- expectLastCalledWith(spy, {
858
- height: 100,
859
- width: 100,
860
- });
861
- });
862
-
863
- it("should select legend payload", () => {
864
- const { spy } = renderTestCase(selectLegendPayload);
865
- expectLastCalledWith(spy, [
866
- {
867
- color: "#82ca9d",
868
- dataKey: "uv",
869
- inactive: false,
870
- payload: {
871
- activeDot: true,
872
- animateNewValues: true,
873
- animationBegin: 0,
874
- animationDuration: 1500,
875
- animationEasing: "ease",
876
- connectNulls: false,
877
- dataKey: "uv",
878
- dot: true,
879
- fill: "#fff",
880
- hide: false,
881
- id: "my-item-id",
882
- isAnimationActive: "auto",
883
- label: false,
884
- legendType: "line",
885
- shape: LineDrawShape,
886
- stroke: "#82ca9d",
887
- strokeWidth: 1,
888
- type: "linear",
889
- xAxisId: 0,
890
- yAxisId: 0,
891
- zIndex: DefaultZIndexes.line,
892
- },
893
- type: "line",
894
- value: "uv",
895
- },
896
- ]);
897
- });
898
-
899
- it("should select tooltip axis type", () => {
900
- const { spy } = renderTestCase(selectTooltipAxisType);
901
- expectLastCalledWith(spy, "yAxis");
902
- });
903
-
904
- it("should select tooltip axis ID", () => {
905
- const { spy } = renderTestCase(selectTooltipAxisId);
906
- expectLastCalledWith(spy, 0);
907
- });
908
-
909
- it("should select dataStartIndex and dataEndIndex", () => {
910
- const { spy } = renderTestCase(selectChartDataWithIndexes);
911
- expectLastCalledWith(spy, {
912
- chartData: [
913
- {
914
- amt: 2400,
915
- name: "Page A",
916
- pv: 2400,
917
- uv: 400,
918
- },
919
- {
920
- amt: 2400,
921
- name: "Page B",
922
- pv: 4567,
923
- uv: 300,
924
- },
925
- {
926
- amt: 2400,
927
- name: "Page C",
928
- pv: 1398,
929
- uv: 300,
930
- },
931
- {
932
- amt: 2400,
933
- name: "Page D",
934
- pv: 9800,
935
- uv: 200,
936
- },
937
- {
938
- amt: 2400,
939
- name: "Page E",
940
- pv: 3908,
941
- uv: 278,
942
- },
943
- {
944
- amt: 2400,
945
- name: "Page F",
946
- pv: 4800,
947
- uv: 189,
948
- },
949
- ],
950
- computedData: undefined,
951
- dataEndIndex: 5,
952
- dataStartIndex: 0,
953
- });
954
- });
955
-
956
- it("should select active label", () => {
957
- const { spy } = renderTestCase((state) => selectActiveLabel(state, "axis", "hover", "2"));
958
- expectLastCalledWith(spy, "Page C");
959
- });
960
-
961
- it("should select active coordinate", () => {
962
- const { container, spy } = renderTestCase((state) =>
963
- selectActiveCoordinate(state, "axis", "hover", undefined),
964
- );
965
- expectLastCalledWith(spy, undefined);
966
- expect(spy).toHaveBeenCalledTimes(1);
967
-
968
- showTooltipOnCoordinate(
969
- container,
970
- LineChartVerticalTestCase.mouseHoverSelector,
971
- LineChartVerticalTestCase.mouseCoordinate,
972
- );
973
-
974
- expectLastCalledWith(spy, {
975
- x: 200,
976
- y: 216,
977
- });
978
- expect(spy).toHaveBeenCalledTimes(2);
979
- });
980
-
981
- it("should select tooltip axis range", () => {
982
- const { spy } = renderTestCase(selectTooltipAxisRangeWithReverse);
983
- expectLastCalledWith(spy, [20, 265]);
984
- });
985
-
986
- it("should select tooltip axis scale", () => {
987
- const { spy } = renderTestCase(selectTooltipAxisScale);
988
- expectLastCalledWithScale(spy, {
989
- domain: ["Page A", "Page B", "Page C", "Page D", "Page E", "Page F"],
990
- range: [20, 265],
991
- });
992
- });
993
-
994
- it("should select categorical domain", () => {
995
- const { spy } = renderTestCase(selectTooltipCategoricalDomain);
996
- expectLastCalledWith(spy, undefined);
997
- });
998
-
999
- it("should select tooltip axis ticks", () => {
1000
- const { spy } = renderTestCase(selectTooltipAxisTicks);
1001
-
1002
- expectLastCalledWith(spy, [
1003
- {
1004
- coordinate: 20,
1005
- index: 0,
1006
- offset: 0,
1007
- value: "Page A",
1008
- },
1009
- {
1010
- coordinate: 69,
1011
- index: 1,
1012
- offset: 0,
1013
- value: "Page B",
1014
- },
1015
- {
1016
- coordinate: 118,
1017
- index: 2,
1018
- offset: 0,
1019
- value: "Page C",
1020
- },
1021
- {
1022
- coordinate: 167,
1023
- index: 3,
1024
- offset: 0,
1025
- value: "Page D",
1026
- },
1027
- {
1028
- coordinate: 216,
1029
- index: 4,
1030
- offset: 0,
1031
- value: "Page E",
1032
- },
1033
- {
1034
- coordinate: 265,
1035
- index: 5,
1036
- offset: 0,
1037
- value: "Page F",
1038
- },
1039
- ]);
1040
- });
1041
-
1042
- it("should select isActive and activeIndex, and update it after mouse hover", () => {
1043
- const { container, spy } = renderTestCase((state) =>
1044
- selectIsTooltipActive(state, "axis", "hover", undefined),
1045
- );
1046
- expectLastCalledWith(spy, {
1047
- activeIndex: null,
1048
- isActive: false,
1049
- });
1050
- expect(spy).toHaveBeenCalledTimes(2);
1051
-
1052
- showTooltipOnCoordinate(
1053
- container,
1054
- LineChartVerticalTestCase.mouseHoverSelector,
1055
- LineChartVerticalTestCase.mouseCoordinate,
1056
- );
1057
-
1058
- expectLastCalledWith(spy, {
1059
- activeIndex: "4",
1060
- isActive: true,
1061
- });
1062
- expect(spy).toHaveBeenCalledTimes(3);
1063
- });
1064
- });
1065
-
1066
- describe("as a child of RadarChart", () => {
1067
- const renderTestCase = createSelectorTestCase((props) => (
1068
- <RadarChartTestCase.Wrapper>
1069
- <Tooltip />
1070
- {props.children}
1071
- </RadarChartTestCase.Wrapper>
1072
- ));
1073
-
1074
- it("should select tooltip axis type", () => {
1075
- const { spy } = renderTestCase(selectTooltipAxisType);
1076
- expectLastCalledWith(spy, "angleAxis");
1077
- });
1078
-
1079
- it("should select tooltip axis ID", () => {
1080
- const { spy } = renderTestCase(selectTooltipAxisId);
1081
- expectLastCalledWith(spy, 0);
1082
- });
1083
-
1084
- it("should select tooltip axis settings", () => {
1085
- const { spy } = renderTestCase(selectTooltipAxis);
1086
- expectLastCalledWith(spy, {
1087
- allowDataOverflow: false,
1088
- allowDecimals: false,
1089
- allowDuplicatedCategory: false,
1090
- dataKey: "name",
1091
- domain: undefined,
1092
- id: 0,
1093
- includeHidden: false,
1094
- name: undefined,
1095
- reversed: false,
1096
- niceTicks: "auto",
1097
- scale: "auto",
1098
- tick: true,
1099
- tickCount: undefined,
1100
- ticks: undefined,
1101
- type: "category",
1102
- unit: undefined,
1103
- });
1104
- });
1105
-
1106
- it("should select tooltip axis range", () => {
1107
- const { spy } = renderTestCase(selectTooltipAxisRangeWithReverse);
1108
- expectLastCalledWith(spy, [90, -270]);
1109
- });
1110
-
1111
- it("should select tooltip axis scale", () => {
1112
- const { spy } = renderTestCase(selectTooltipAxisScale);
1113
- expectLastCalledWithScale(spy, {
1114
- domain: ["Page A", "Page B", "Page C", "Page D", "Page E", "Page F"],
1115
- range: [-270, 90],
1116
- });
1117
- });
1118
-
1119
- it("should select tooltip axis ticks", () => {
1120
- const { spy } = renderTestCase(selectTooltipAxisTicks);
1121
- expectLastCalledWith(spy, [
1122
- {
1123
- coordinate: 90,
1124
- index: 0,
1125
- offset: 60,
1126
- value: "Page A",
1127
- },
1128
- {
1129
- coordinate: 30,
1130
- index: 1,
1131
- offset: 60,
1132
- value: "Page B",
1133
- },
1134
- {
1135
- coordinate: -30,
1136
- index: 2,
1137
- offset: 60,
1138
- value: "Page C",
1139
- },
1140
- {
1141
- coordinate: -90,
1142
- index: 3,
1143
- offset: 60,
1144
- value: "Page D",
1145
- },
1146
- {
1147
- coordinate: -150,
1148
- index: 4,
1149
- offset: 60,
1150
- value: "Page E",
1151
- },
1152
- {
1153
- coordinate: -210,
1154
- index: 5,
1155
- offset: 60,
1156
- value: "Page F",
1157
- },
1158
- ]);
1159
- });
1160
-
1161
- it("should select tooltip state before & after hover", () => {
1162
- const { container, spy } = renderTestCase(selectTooltipState);
1163
-
1164
- const expectedBeforeHover: TooltipState = {
1165
- axisInteraction: {
1166
- click: {
1167
- active: false,
1168
- dataKey: undefined,
1169
- index: null,
1170
- coordinate: undefined,
1171
- graphicalItemId: undefined,
1172
- },
1173
- hover: {
1174
- active: false,
1175
- dataKey: undefined,
1176
- index: null,
1177
- coordinate: undefined,
1178
- graphicalItemId: undefined,
1179
- },
1180
- },
1181
- itemInteraction: {
1182
- click: {
1183
- active: false,
1184
- index: null,
1185
- dataKey: undefined,
1186
- coordinate: undefined,
1187
- graphicalItemId: undefined,
1188
- },
1189
- hover: {
1190
- active: false,
1191
- index: null,
1192
- dataKey: undefined,
1193
- coordinate: undefined,
1194
- graphicalItemId: undefined,
1195
- },
1196
- },
1197
- keyboardInteraction: {
1198
- active: false,
1199
- dataKey: undefined,
1200
- index: null,
1201
- coordinate: undefined,
1202
- graphicalItemId: undefined,
1203
- },
1204
- syncInteraction: {
1205
- active: false,
1206
- dataKey: undefined,
1207
- index: null,
1208
- coordinate: undefined,
1209
- label: undefined,
1210
- sourceViewBox: undefined,
1211
- graphicalItemId: undefined,
1212
- },
1213
- settings: {
1214
- axisId: 0,
1215
- shared: undefined,
1216
- trigger: "hover",
1217
- active: undefined,
1218
- defaultIndex: undefined,
1219
- },
1220
- tooltipItemPayloads: [
1221
- {
1222
- dataDefinedOnItem: undefined,
1223
- getPosition: noop,
1224
- settings: {
1225
- color: "#8884d8",
1226
- dataKey: "uv",
1227
- fill: "#8884d8",
1228
- graphicalItemId: "my-item-id",
1229
- hide: false,
1230
- name: "Mike",
1231
- nameKey: undefined,
1232
- stroke: "#8884d8",
1233
- strokeWidth: undefined,
1234
- type: undefined,
1235
- unit: "",
1236
- },
1237
- },
1238
- ],
1239
- };
1240
- expectLastCalledWith(spy, expectedBeforeHover);
1241
-
1242
- showTooltip(container, RadarChartTestCase.mouseHoverSelector);
1243
-
1244
- const expectedAfterHover: TooltipState = {
1245
- axisInteraction: {
1246
- click: {
1247
- active: false,
1248
- dataKey: undefined,
1249
- index: null,
1250
- coordinate: undefined,
1251
- graphicalItemId: undefined,
1252
- },
1253
- hover: {
1254
- active: true,
1255
- dataKey: undefined,
1256
- index: "5",
1257
- coordinate: {
1258
- angle: -210,
1259
- clockWise: false,
1260
- cx: 300,
1261
- cy: 300,
1262
- endAngle: -270,
1263
- innerRadius: 0,
1264
- outerRadius: 236,
1265
- radius: 141.4213562373095,
1266
- startAngle: 90,
1267
- x: 177.5255128608411,
1268
- y: 229.28932188134524,
1269
- },
1270
- graphicalItemId: undefined,
1271
- },
1272
- },
1273
- itemInteraction: {
1274
- click: {
1275
- active: false,
1276
- index: null,
1277
- dataKey: undefined,
1278
- coordinate: undefined,
1279
- graphicalItemId: undefined,
1280
- },
1281
- hover: {
1282
- active: false,
1283
- index: null,
1284
- dataKey: undefined,
1285
- coordinate: undefined,
1286
- graphicalItemId: undefined,
1287
- },
1288
- },
1289
- keyboardInteraction: {
1290
- active: false,
1291
- dataKey: undefined,
1292
- index: null,
1293
- coordinate: undefined,
1294
- graphicalItemId: undefined,
1295
- },
1296
- syncInteraction: {
1297
- active: false,
1298
- dataKey: undefined,
1299
- index: null,
1300
- coordinate: undefined,
1301
- label: undefined,
1302
- sourceViewBox: undefined,
1303
- graphicalItemId: undefined,
1304
- },
1305
- settings: {
1306
- axisId: 0,
1307
- shared: undefined,
1308
- trigger: "hover",
1309
- active: undefined,
1310
- defaultIndex: undefined,
1311
- },
1312
- tooltipItemPayloads: [
1313
- {
1314
- dataDefinedOnItem: undefined,
1315
- getPosition: noop,
1316
- settings: {
1317
- color: "#8884d8",
1318
- dataKey: "uv",
1319
- fill: "#8884d8",
1320
- graphicalItemId: "my-item-id",
1321
- hide: false,
1322
- name: "Mike",
1323
- nameKey: undefined,
1324
- stroke: "#8884d8",
1325
- strokeWidth: undefined,
1326
- type: undefined,
1327
- unit: "",
1328
- },
1329
- },
1330
- ],
1331
- };
1332
- expectLastCalledWith(spy, expectedAfterHover);
1333
- });
1334
-
1335
- it("should select active label", () => {
1336
- const { spy } = renderTestCase((state) => selectActiveLabel(state, "axis", "hover", "2"));
1337
- expectLastCalledWith(spy, "Page C");
1338
- });
1339
-
1340
- it("should select active coordinate", () => {
1341
- const { container, spy } = renderTestCase((state) =>
1342
- selectActiveCoordinate(state, "axis", "hover", undefined),
1343
- );
1344
- expectLastCalledWith(spy, undefined);
1345
- expect(spy).toHaveBeenCalledTimes(1);
1346
-
1347
- showTooltipOnCoordinate(
1348
- container,
1349
- RadarChartTestCase.mouseHoverSelector,
1350
- RadarChartTestCase.mouseCoordinate,
1351
- );
1352
-
1353
- expectLastCalledWith(spy, {
1354
- angle: -210,
1355
- clockWise: false,
1356
- cx: 300,
1357
- cy: 300,
1358
- endAngle: -270,
1359
- innerRadius: 0,
1360
- outerRadius: 236,
1361
- radius: 141.4213562373095,
1362
- startAngle: 90,
1363
- x: 177.5255128608411,
1364
- y: 229.28932188134524,
1365
- });
1366
- expect(spy).toHaveBeenCalledTimes(2);
1367
- });
1368
- });
1369
-
1370
- describe("as a child of RadialBarChart", () => {
1371
- const renderTestCase = createSelectorTestCase((props) => (
1372
- <RadialBarChartTestCase.Wrapper>
1373
- <Tooltip />
1374
- {props.children}
1375
- </RadialBarChartTestCase.Wrapper>
1376
- ));
1377
-
1378
- it("should select chart layout", () => {
1379
- const { spy } = renderTestCase(selectChartLayout);
1380
- expectLastCalledWith(spy, "radial");
1381
- });
1382
-
1383
- it("should select tooltip axis type", () => {
1384
- const { spy } = renderTestCase(selectTooltipAxisType);
1385
- expectLastCalledWith(spy, "radiusAxis");
1386
- });
1387
-
1388
- it("should select tooltip axis ID", () => {
1389
- const { spy } = renderTestCase(selectTooltipAxisId);
1390
- expectLastCalledWith(spy, 0);
1391
- });
1392
-
1393
- it("should select tooltip axis settings", () => {
1394
- const { spy } = renderTestCase(selectTooltipAxis);
1395
- expectLastCalledWith(spy, {
1396
- allowDataOverflow: false,
1397
- allowDecimals: false,
1398
- allowDuplicatedCategory: true,
1399
- dataKey: "name",
1400
- domain: undefined,
1401
- id: 0,
1402
- includeHidden: false,
1403
- name: undefined,
1404
- reversed: false,
1405
- niceTicks: "auto",
1406
- scale: "auto",
1407
- tick: true,
1408
- tickCount: 5,
1409
- ticks: undefined,
1410
- type: "category",
1411
- unit: undefined,
1412
- });
1413
- });
1414
-
1415
- it("should select tooltip axis range", () => {
1416
- const { spy } = renderTestCase(selectTooltipAxisRangeWithReverse);
1417
- expectLastCalledWith(spy, [0, 236]);
1418
- });
1419
-
1420
- test("selectTooltipAxisDomainIncludingNiceTicks", () => {
1421
- const { spy } = renderTestCase(selectTooltipAxisDomainIncludingNiceTicks);
1422
- expectLastCalledWith(spy, ["Page A", "Page B", "Page C", "Page D", "Page E", "Page F"]);
1423
- });
1424
-
1425
- test("selectTooltipAxisDomain", () => {
1426
- const { spy } = renderTestCase(selectTooltipAxisDomain);
1427
- expectLastCalledWith(spy, ["Page A", "Page B", "Page C", "Page D", "Page E", "Page F"]);
1428
- });
1429
-
1430
- it("should select tooltip axis scale", () => {
1431
- const { spy } = renderTestCase(selectTooltipAxisScale);
1432
- expectLastCalledWithScale(spy, {
1433
- domain: ["Page A", "Page B", "Page C", "Page D", "Page E", "Page F"],
1434
- range: [0, 236],
1435
- });
1436
- });
1437
-
1438
- it("should select categoricalDomain = undefined", () => {
1439
- const { spy } = renderTestCase(selectTooltipCategoricalDomain);
1440
- expectLastCalledWith(spy, undefined);
1441
- });
1442
-
1443
- it("should select tooltip axis ticks", () => {
1444
- const { spy } = renderTestCase(selectTooltipAxisTicks);
1445
- expectLastCalledWith(spy, [
1446
- {
1447
- coordinate: 19.666666666666668,
1448
- index: 0,
1449
- offset: 19.666666666666668,
1450
- value: "Page A",
1451
- },
1452
- {
1453
- coordinate: 59,
1454
- index: 1,
1455
- offset: 19.666666666666668,
1456
- value: "Page B",
1457
- },
1458
- {
1459
- coordinate: 98.33333333333334,
1460
- index: 2,
1461
- offset: 19.666666666666668,
1462
- value: "Page C",
1463
- },
1464
- {
1465
- coordinate: 137.66666666666666,
1466
- index: 3,
1467
- offset: 19.666666666666668,
1468
- value: "Page D",
1469
- },
1470
- {
1471
- coordinate: 177,
1472
- index: 4,
1473
- offset: 19.666666666666668,
1474
- value: "Page E",
1475
- },
1476
- {
1477
- coordinate: 216.33333333333334,
1478
- index: 5,
1479
- offset: 19.666666666666668,
1480
- value: "Page F",
1481
- },
1482
- ]);
1483
- });
1484
-
1485
- it("should move when the mouse moves", async () => {
1486
- mockGetBoundingClientRect({
1487
- width: 10,
1488
- height: 10,
1489
- });
1490
- const { container } = renderTestCase();
1491
-
1492
- showTooltipOnCoordinate(container, RadialBarChartTestCase.mouseHoverSelector, {
1493
- clientX: 200,
1494
- clientY: 200,
1495
- });
1496
-
1497
- const tooltip1 = getTooltip(container);
1498
- expect(tooltip1.getAttribute("style")).toContain("position: absolute;");
1499
- expect(tooltip1.getAttribute("style")).toContain("top: 0px");
1500
- expect(tooltip1.getAttribute("style")).toContain("left: 0px");
1501
-
1502
- showTooltipOnCoordinate(container, RadialBarChartTestCase.mouseHoverSelector, {
1503
- clientX: 201,
1504
- clientY: 201,
1505
- });
1506
-
1507
- const tooltip2 = getTooltip(container);
1508
-
1509
- expect(tooltip2.getAttribute("style")).toContain(RadialBarChartTestCase.expectedTransform);
1510
- });
1511
-
1512
- it("should move onTouchMove", async () => {
1513
- mockGetBoundingClientRect({
1514
- width: 10,
1515
- height: 10,
1516
- });
1517
- const { container } = renderTestCase();
1518
-
1519
- showTooltipOnCoordinateTouch(container, RadialBarChartTestCase.mouseHoverSelector, {
1520
- clientX: 200,
1521
- clientY: 200,
1522
- });
1523
-
1524
- const tooltip1 = getTooltip(container);
1525
- expect(tooltip1.getAttribute("style")).toContain("position: absolute;");
1526
- expect(tooltip1.getAttribute("style")).toContain("top: 0px");
1527
- expect(tooltip1.getAttribute("style")).toContain("left: 0px");
1528
-
1529
- showTooltipOnCoordinateTouch(container, RadialBarChartTestCase.mouseHoverSelector, {
1530
- clientX: 201,
1531
- clientY: 201,
1532
- });
1533
-
1534
- const tooltip2 = getTooltip(container);
1535
-
1536
- expect(tooltip2.getAttribute("style")).toContain(RadialBarChartTestCase.expectedTransform);
1537
- });
1538
- });
1539
-
1540
- describe("includeHidden prop", () => {
1541
- describe("when includeHidden = true", () => {
1542
- const renderTestCase = createSelectorTestCase((props) => (
1543
- <ComposedChart width={400} height={400} data={PageData}>
1544
- <Area dataKey="uv" hide name="1" />
1545
- <Bar dataKey="pv" hide name="2" />
1546
- <Line dataKey="amt" hide name="3" />
1547
- <Scatter dataKey="uv" hide name="4" />
1548
- <Line dataKey="pv" name="5" />
1549
- <XAxis type="number" dataKey="amt" name="stature" unit="cm" />
1550
- <YAxis type="number" dataKey="pv" name="weight" unit="kg" />
1551
- <Tooltip includeHidden />
1552
- {props.children}
1553
- </ComposedChart>
1554
- ));
1555
-
1556
- it("should select tooltip axis ID", () => {
1557
- const { spy } = renderTestCase(selectTooltipAxisId);
1558
- expectLastCalledWith(spy, 0);
1559
- });
1560
-
1561
- it("should select tooltip axis type", () => {
1562
- const { spy } = renderTestCase(selectTooltipAxisType);
1563
- expectLastCalledWith(spy, "xAxis");
1564
- });
1565
-
1566
- it("should select active label when given explicit index", () => {
1567
- const { spy } = renderTestCase((state) => selectActiveLabel(state, "axis", "hover", "2"));
1568
- expectLastCalledWith(spy, 2400);
1569
- });
1570
-
1571
- it("should select active coordinate", () => {
1572
- const { container, spy } = renderTestCase((state) =>
1573
- selectActiveCoordinate(state, "axis", "hover", undefined),
1574
- );
1575
- expectLastCalledWith(spy, undefined);
1576
- expect(spy).toHaveBeenCalledTimes(1);
1577
-
1578
- showTooltip(container, composedChartMouseHoverTooltipSelector);
1579
-
1580
- expectLastCalledWith(spy, {
1581
- x: 395,
1582
- y: 200,
1583
- });
1584
- expect(spy).toHaveBeenCalledTimes(2);
1585
- });
1586
-
1587
- it("should select tooltip axis scale", () => {
1588
- const { spy } = renderTestCase(selectTooltipAxisScale);
1589
- expectLastCalledWithScale(spy, {
1590
- domain: [0, 2400],
1591
- range: [65, 395],
1592
- });
1593
- });
1594
-
1595
- it("should select tooltip axis settings", () => {
1596
- const { spy } = renderTestCase(selectTooltipAxis);
1597
- expectLastCalledWith(spy, {
1598
- allowDataOverflow: false,
1599
- allowDecimals: true,
1600
- allowDuplicatedCategory: true,
1601
- angle: 0,
1602
- dataKey: "amt",
1603
- domain: undefined,
1604
- height: 30,
1605
- hide: false,
1606
- id: 0,
1607
- includeHidden: false,
1608
- interval: "preserveEnd",
1609
- minTickGap: 5,
1610
- mirror: false,
1611
- name: "stature",
1612
- orientation: "bottom",
1613
- padding: {
1614
- left: 0,
1615
- right: 0,
1616
- },
1617
- reversed: false,
1618
- niceTicks: "auto",
1619
- scale: "auto",
1620
- tick: true,
1621
- tickCount: 5,
1622
- tickFormatter: undefined,
1623
- ticks: undefined,
1624
- type: "number",
1625
- unit: "cm",
1626
- });
1627
- });
1628
-
1629
- it("should select tooltip axis real scale type", () => {
1630
- const { spy } = renderTestCase(selectTooltipAxisRealScaleType);
1631
- expectLastCalledWith(spy, "linear");
1632
- });
1633
-
1634
- it("should select tooltip axis ticks", () => {
1635
- const { spy } = renderTestCase(selectTooltipAxisTicks);
1636
- expectLastCalledWith(spy, [
1637
- { coordinate: 395, value: 2400, index: 0, offset: 0 },
1638
- { coordinate: 395, value: 2400, index: 1, offset: 0 },
1639
- { coordinate: 395, value: 2400, index: 2, offset: 0 },
1640
- { coordinate: 395, value: 2400, index: 3, offset: 0 },
1641
- { coordinate: 395, value: 2400, index: 4, offset: 0 },
1642
- { coordinate: 395, value: 2400, index: 5, offset: 0 },
1643
- ]);
1644
- });
1645
-
1646
- it("should select isActive", () => {
1647
- const { container, spy } = renderTestCase((state) =>
1648
- selectIsTooltipActive(state, "axis", "hover", undefined),
1649
- );
1650
- expectLastCalledWith(spy, {
1651
- activeIndex: null,
1652
- isActive: false,
1653
- });
1654
- expect(spy).toHaveBeenCalledTimes(2);
1655
-
1656
- showTooltip(container, composedChartMouseHoverTooltipSelector);
1657
-
1658
- expectLastCalledWith(spy, {
1659
- activeIndex: "0",
1660
- isActive: true,
1661
- });
1662
- expect(spy).toHaveBeenCalledTimes(3);
1663
- });
1664
-
1665
- it("should render tooltip payload for hidden items", () => {
1666
- const { container } = renderTestCase();
1667
-
1668
- expectTooltipNotVisible(container);
1669
-
1670
- showTooltip(container, composedChartMouseHoverTooltipSelector);
1671
-
1672
- expectTooltipPayload(container, "2400", [
1673
- "1 : 400",
1674
- "2 : 2400",
1675
- "3 : 2400",
1676
- "5 : 2400",
1677
- "stature : 2400cm",
1678
- "weight : 2400kg",
1679
- ]);
1680
- });
1681
- });
1682
-
1683
- describe("when includeHidden = false", () => {
1684
- const renderTestCase = createSelectorTestCase((props) => (
1685
- <ComposedChart width={400} height={400} data={PageData}>
1686
- <Area dataKey="uv" hide name="1" />
1687
- <Bar dataKey="pv" hide name="2" />
1688
- <Line dataKey="amt" hide name="3" />
1689
- <Scatter dataKey="uv" hide name="4" />
1690
- <Line dataKey="pv" name="5" />
1691
- <XAxis type="number" dataKey="amt" name="stature" unit="cm" />
1692
- <YAxis type="number" dataKey="pv" name="weight" unit="kg" />
1693
- <Tooltip includeHidden={false} />
1694
- {props.children}
1695
- </ComposedChart>
1696
- ));
1697
-
1698
- it("should hide tooltip for hidden items", () => {
1699
- const { container } = renderTestCase();
1700
-
1701
- expectTooltipNotVisible(container);
1702
-
1703
- showTooltip(container, composedChartMouseHoverTooltipSelector);
1704
-
1705
- expectTooltipPayload(container, "2400", ["5 : 2400"]);
1706
- });
1707
- });
1708
- });
1709
-
1710
- it("Should display the data selected by Brush", () => {
1711
- const { container, debug } = render(() => (
1712
- <LineChart width={600} height={300} data={PageData}>
1713
- <XAxis dataKey="name" />
1714
- <YAxis />
1715
- <CartesianGrid strokeDasharray="3 3" />
1716
- <Tooltip />
1717
- <Legend />
1718
- <Brush dataKey="name" startIndex={1} height={30} stroke="#8884d8" />
1719
- <Line type="monotone" dataKey="pv" stroke="#8884d8" activeDot={{ r: 8 }} />
1720
- <Line type="monotone" dataKey="uv" stroke="#82ca9d" />
1721
- </LineChart>
1722
- ));
1723
- flush();
1724
-
1725
- const line = container.querySelector(".recharts-cartesian-grid-horizontal line")!;
1726
- showTooltipOnCoordinate(
1727
- container,
1728
- lineChartMouseHoverTooltipSelector,
1729
- {
1730
- clientX: +line.getAttribute("x")! + 1,
1731
- clientY: 50,
1732
- },
1733
- debug,
1734
- );
1735
- expect(getByText(container, "4567")).toBeVisible();
1736
- });
1737
-
1738
- test("defaultIndex can be updated by parent control", () => {
1739
- const data2 = [
1740
- { x: 100, y: 200, z: 200 },
1741
- { x: 120, y: 100, z: 260 },
1742
- { x: 170, y: 300, z: 400 },
1743
- { x: 140, y: 250, z: 280 },
1744
- { x: 150, y: 400, z: 500 },
1745
- { x: 110, y: 280, z: 200 },
1746
- ];
1747
- const Example = () => {
1748
- const [defaultIndex, setDefaultIndex] = createSignal(0);
1749
-
1750
- return (
1751
- <div>
1752
- <ScatterChart
1753
- width={400}
1754
- height={400}
1755
- margin={{ top: 20, right: 20, bottom: 20, left: 20 }}
1756
- >
1757
- <XAxis dataKey="x" name="stature" unit="cm" />
1758
- <YAxis dataKey="y" name="weight" unit="kg" />
1759
- <Scatter line name="A school" data={data2} fill="#ff7300" />
1760
- <Tooltip defaultIndex={defaultIndex()} active />
1761
- </ScatterChart>
1762
- <button type="button" id="goRight" onClick={() => setDefaultIndex(defaultIndex() + 1)}>
1763
- Go right
1764
- </button>
1765
- </div>
1766
- );
1767
- };
1768
- const { container } = render(() => <Example />);
1769
- flush();
1770
-
1771
- const tooltip = getTooltip(container);
1772
- expect(tooltip).toBeInTheDocument();
1773
-
1774
- // Tooltip should be visible, since defaultIndex was set
1775
- expect(tooltip).toBeVisible();
1776
-
1777
- // The cursor should also be visible
1778
- expect(container.querySelector(".recharts-tooltip-cursor")).toBeVisible();
1779
-
1780
- // Data should be displayed in the Tooltip payload
1781
- expect(tooltip.textContent).toBe("stature : 100cmweight : 200kg");
1782
-
1783
- fireEvent.click(container.querySelector("#goRight") as HTMLButtonElement);
1784
- flush();
1785
-
1786
- // Data should be displayed in the Tooltip payload
1787
- expect(tooltip.textContent).toBe("stature : 120cmweight : 100kg");
1788
- });
1789
- });
1790
-
1791
- describe("Active element visibility", () => {
1792
- beforeEach(() => {
1793
- mockGetBoundingClientRect({ width: 100, height: 100 });
1794
- });
1795
-
1796
- describe.each([
1797
- AreaChartTestCase,
1798
- LineChartHorizontalTestCase,
1799
- LineChartVerticalTestCase,
1800
- ComposedChartWithAreaTestCase,
1801
- ComposedChartWithLineTestCase,
1802
- RadarChartTestCase,
1803
- ])("as a child of $name", ({ Wrapper, mouseHoverSelector }) => {
1804
- it("should display activeDot", () => {
1805
- const { container, debug } = render(() => (
1806
- <Wrapper>
1807
- <Tooltip />
1808
- </Wrapper>
1809
- ));
1810
- flush();
1811
- expect(container.querySelector(".recharts-active-dot")).not.toBeInTheDocument();
1812
-
1813
- showTooltip(container, mouseHoverSelector, debug);
1814
-
1815
- expect(container.querySelector(".recharts-active-dot")).toBeVisible();
1816
- });
1817
- });
1818
-
1819
- describe.each([
1820
- BarChartTestCase,
1821
- ComposedChartWithBarTestCase,
1822
- PieChartTestCase,
1823
- RadialBarChartTestCase,
1824
- SankeyTestCase,
1825
- ScatterChartTestCase,
1826
- SunburstChartTestCase,
1827
- TreemapTestCase,
1828
- ])("as a child of $name", ({ Wrapper, mouseHoverSelector }) => {
1829
- it("should not display activeDot", () => {
1830
- const { container, debug } = render(() => (
1831
- <Wrapper>
1832
- <Tooltip />
1833
- </Wrapper>
1834
- ));
1835
- flush();
1836
- expect(container.querySelector(".recharts-active-dot")).not.toBeInTheDocument();
1837
-
1838
- showTooltip(container, mouseHoverSelector, debug);
1839
-
1840
- expect(container.querySelector(".recharts-active-dot")).not.toBeInTheDocument();
1841
- });
1842
- });
1843
- });
1844
-
1845
- describe("Cursor visibility", () => {
1846
- beforeEach(() => {
1847
- mockGetBoundingClientRect({ width: 100, height: 100 });
1848
- });
1849
-
1850
- describe.each([
1851
- AreaChartTestCase,
1852
- BarChartTestCase,
1853
- LineChartHorizontalTestCase,
1854
- LineChartVerticalTestCase,
1855
- ComposedChartWithAreaTestCase,
1856
- ComposedChartWithLineTestCase,
1857
- RadarChartTestCase,
1858
- ])("as a child of $name", ({ Wrapper, mouseHoverSelector }) => {
1859
- it("should display cursor inside of the SVG", () => {
1860
- const { container, debug } = render(() => (
1861
- <Wrapper>
1862
- <Tooltip />
1863
- </Wrapper>
1864
- ));
1865
- flush();
1866
- expect(container.querySelector(".recharts-tooltip-cursor")).not.toBeInTheDocument();
1867
-
1868
- showTooltip(container, mouseHoverSelector, debug);
1869
-
1870
- expect(
1871
- container.querySelector(".recharts-wrapper svg .recharts-tooltip-cursor"),
1872
- ).toBeVisible();
1873
- });
1874
-
1875
- it("should not display cursor when cursor=false", () => {
1876
- const { container, debug } = render(() => (
1877
- <Wrapper>
1878
- <Tooltip cursor={false} />
1879
- </Wrapper>
1880
- ));
1881
- flush();
1882
- expect(container.querySelector(".recharts-tooltip-cursor")).not.toBeInTheDocument();
1883
-
1884
- showTooltip(container, mouseHoverSelector, debug);
1885
-
1886
- expect(container.querySelector(".recharts-tooltip-cursor")).not.toBeInTheDocument();
1887
- });
1888
- });
1889
- });