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.
- package/package.json +17 -13
- package/src/animation/AnimatedItems.tsx +2 -4
- package/src/animation/CSSTransitionAnimate.tsx +41 -39
- package/src/animation/JavascriptAnimate.tsx +45 -41
- package/src/cartesian/Area.tsx +43 -58
- package/src/cartesian/AreaRevealShape.tsx +1 -1
- package/src/cartesian/Bar.tsx +98 -78
- package/src/cartesian/BarStack.tsx +10 -7
- package/src/cartesian/Brush.tsx +20 -16
- package/src/cartesian/CartesianAxis.tsx +4 -4
- package/src/cartesian/CartesianGrid.tsx +5 -5
- package/src/cartesian/ErrorBar.tsx +9 -7
- package/src/cartesian/Funnel.tsx +17 -21
- package/src/cartesian/GraphicalItemClipPath.tsx +1 -1
- package/src/cartesian/Line.tsx +51 -66
- package/src/cartesian/LineDrawShape.tsx +20 -17
- package/src/cartesian/ReferenceArea.tsx +28 -38
- package/src/cartesian/ReferenceDot.tsx +27 -37
- package/src/cartesian/ReferenceLine.tsx +28 -37
- package/src/cartesian/RenderedTicksReporter.tsx +19 -17
- package/src/cartesian/Scatter.tsx +27 -39
- package/src/cartesian/XAxis.tsx +55 -68
- package/src/cartesian/YAxis.tsx +88 -99
- package/src/cartesian/ZAxis.tsx +29 -41
- package/src/chart/AreaChart.tsx +1 -1
- package/src/chart/BarChart.tsx +1 -1
- package/src/chart/CartesianChart.tsx +4 -3
- package/src/chart/CategoricalChart.tsx +5 -5
- package/src/chart/ComposedChart.tsx +1 -1
- package/src/chart/FunnelChart.tsx +1 -1
- package/src/chart/LineChart.tsx +1 -1
- package/src/chart/PieChart.tsx +4 -3
- package/src/chart/PolarChart.tsx +4 -3
- package/src/chart/RadarChart.tsx +4 -3
- package/src/chart/RadialBarChart.tsx +7 -3
- package/src/chart/RechartsWrapper.tsx +14 -24
- package/src/chart/Sankey.tsx +9 -6
- package/src/chart/ScatterChart.tsx +1 -1
- package/src/chart/SunburstChart.tsx +6 -5
- package/src/chart/Treemap.tsx +5 -4
- package/src/component/ActivePoints.tsx +6 -15
- package/src/component/Cell.tsx +23 -5
- package/src/component/Cursor.tsx +3 -3
- package/src/component/DefaultLegendContent.tsx +8 -6
- package/src/component/DefaultTooltipContent.tsx +14 -10
- package/src/component/Dots.tsx +11 -7
- package/src/component/Label.tsx +13 -10
- package/src/component/LabelList.tsx +12 -7
- package/src/component/Legend.tsx +26 -21
- package/src/component/ResponsiveContainer.tsx +52 -49
- package/src/component/Text.tsx +5 -5
- package/src/component/Tooltip.tsx +21 -18
- package/src/component/TooltipBoundingBox.tsx +18 -16
- package/src/component/responsiveContainerUtils.ts +1 -1
- package/src/container/ClipPathProvider.tsx +3 -3
- package/src/container/Layer.tsx +5 -5
- package/src/container/RootSurface.tsx +1 -1
- package/src/container/Surface.tsx +5 -6
- package/src/context/ErrorBarContext.tsx +17 -26
- package/src/context/PanoramaContext.tsx +2 -2
- package/src/context/RegisterGraphicalItemId.tsx +4 -2
- package/src/context/chartDataContext.tsx +26 -23
- package/src/context/chartLayoutContext.tsx +16 -12
- package/src/polar/Pie.tsx +49 -60
- package/src/polar/PolarAngleAxis.tsx +43 -52
- package/src/polar/PolarGrid.tsx +5 -5
- package/src/polar/PolarRadiusAxis.tsx +42 -50
- package/src/polar/Radar.tsx +24 -36
- package/src/polar/RadialBar.tsx +23 -41
- package/src/shape/Cross.tsx +5 -5
- package/src/shape/Curve.tsx +7 -8
- package/src/shape/Dot.tsx +4 -4
- package/src/shape/Polygon.tsx +5 -5
- package/src/shape/Rectangle.tsx +22 -20
- package/src/shape/Sector.tsx +5 -5
- package/src/shape/Symbols.tsx +6 -6
- package/src/shape/Trapezoid.tsx +29 -27
- package/src/state/RechartsStoreProvider.tsx +5 -3
- package/src/state/ReportChartProps.tsx +8 -6
- package/src/state/ReportEventSettings.tsx +8 -6
- package/src/state/ReportMainChartProps.tsx +11 -9
- package/src/state/ReportPolarOptions.tsx +15 -13
- package/src/state/SetLegendPayload.ts +20 -28
- package/src/state/SetTooltipEntrySettings.tsx +10 -27
- package/src/state/brushSlice.ts +10 -8
- package/src/state/cartesianAxisSlice.ts +72 -84
- package/src/state/chartDataSlice.ts +29 -23
- package/src/state/createCollectionActions.ts +51 -0
- package/src/state/createSelector.ts +97 -0
- package/src/state/errorBarSlice.ts +22 -16
- package/src/state/eventSettingsSlice.ts +11 -9
- package/src/state/externalEventsMiddleware.ts +2 -11
- package/src/state/graphicalItemsSlice.ts +35 -44
- package/src/state/isEventThrottled.ts +12 -0
- package/src/state/keyboardEventsMiddleware.ts +2 -8
- package/src/state/layoutSlice.ts +29 -17
- package/src/state/legendSlice.ts +35 -31
- package/src/state/mouseEventsMiddleware.ts +2 -13
- package/src/state/optionsSlice.ts +8 -6
- package/src/state/patched.ts +19 -0
- package/src/state/polarAxisSlice.ts +21 -13
- package/src/state/polarOptionsSlice.ts +16 -14
- package/src/state/referenceElementsSlice.ts +49 -34
- package/src/state/registerInStore.ts +70 -0
- package/src/state/renderedTicksSlice.ts +11 -7
- package/src/state/rootPropsSlice.ts +16 -14
- package/src/state/selectors/areaSelectors.ts +13 -36
- package/src/state/selectors/arrayEqualityCheck.ts +32 -7
- package/src/state/selectors/axisSelectors.ts +215 -169
- package/src/state/selectors/barSelectors.ts +8 -36
- package/src/state/selectors/combiners/combineConfiguredScale.ts +1 -1
- package/src/state/selectors/combiners/combineRealScaleType.ts +1 -1
- package/src/state/selectors/dataSelectors.ts +35 -16
- package/src/state/selectors/numberDomainEqualityCheck.ts +16 -8
- package/src/state/selectors/selectAxisForGraphicalItem.ts +52 -0
- package/src/state/tooltipSlice.ts +135 -86
- package/src/state/unregisterOnCleanup.ts +5 -20
- package/src/state/zIndexSlice.ts +50 -42
- package/src/synchronisation/useChartSynchronisation.tsx +213 -217
- package/src/util/ActiveShapeUtils.tsx +2 -9
- package/src/util/BarUtils.tsx +30 -23
- package/src/util/ChartUtils.ts +69 -25
- package/src/util/DirectPortal.tsx +107 -0
- package/src/util/FunnelUtils.tsx +1 -1
- package/src/util/RadialBarUtils.tsx +4 -3
- package/src/util/createCartesianCharts.tsx +1 -1
- package/src/util/createPolarCharts.tsx +1 -1
- package/src/util/propsAreEqual.ts +3 -33
- package/src/util/stacks/stackTypes.ts +1 -1
- package/src/util/svgPropertiesAndEvents.ts +1 -1
- package/src/util/tooltip/translate.ts +2 -2
- package/src/util/types.ts +3 -3
- package/src/zIndex/ZIndexLayer.tsx +39 -68
- package/src/zIndex/ZIndexPortal.tsx +29 -25
- package/src/state/reduxDevtoolsJsonStringifyReplacer.ts +0 -15
- package/src/util/axisPropsAreEqual.ts +0 -42
- package/src/util/resolveDefaultProps.tsx +0 -8
- package/src/util/typedDataKey.ts +0 -8
- package/test/_data.ts +0 -408
- package/test/animation/AnimationController.typed.spec.ts +0 -53
- package/test/animation/AnimationControllerImpl.spec.ts +0 -271
- package/test/animation/CSSTransitionAnimate.timing.spec.tsx +0 -473
- package/test/animation/JavascriptAnimate.spec.tsx +0 -62
- package/test/animation/RechartsAnimation.spec.ts +0 -636
- package/test/animation/easing.spec.ts +0 -218
- package/test/animation/legacyAnimationLengthChange.spec.tsx +0 -803
- package/test/animation/matchBy.spec.ts +0 -467
- package/test/animation/mockAnimationController.ts +0 -40
- package/test/animation/mockControllerAnimationManager.ts +0 -143
- package/test/animation/mockTimeoutController.ts +0 -114
- package/test/animation/timeoutController.spec.ts +0 -138
- package/test/animation/useAnimationStartSnapshot.spec.ts +0 -147
- package/test/animation/util.spec.ts +0 -28
- package/test/cartesian/Area.animation.spec.tsx +0 -363
- package/test/cartesian/Area.range.spec.tsx +0 -54
- package/test/cartesian/Area.spec.tsx +0 -1202
- package/test/cartesian/Area.stacked.render.spec.tsx +0 -69
- package/test/cartesian/Area.typed.spec.tsx +0 -209
- package/test/cartesian/Axis.integration.spec.tsx +0 -158
- package/test/cartesian/Bar/Bar.csstransition.spec.tsx +0 -299
- package/test/cartesian/Bar/Bar.spec.tsx +0 -2314
- package/test/cartesian/Bar/Bar.typed.spec.tsx +0 -192
- package/test/cartesian/Bar.animation.spec.tsx +0 -426
- package/test/cartesian/Bar.stackDomain.spec.tsx +0 -66
- package/test/cartesian/Bar.stacked.render.spec.tsx +0 -53
- package/test/cartesian/Bar.truncateByDomain.spec.tsx +0 -237
- package/test/cartesian/Bar.zeroDimensionFiltering.spec.tsx +0 -336
- package/test/cartesian/BarStack.spec.tsx +0 -91
- package/test/cartesian/Brush.keyboard.spec.tsx +0 -88
- package/test/cartesian/Brush.panorama.spec.tsx +0 -41
- package/test/cartesian/Brush.props.spec.tsx +0 -63
- package/test/cartesian/Brush.render.spec.tsx +0 -117
- package/test/cartesian/Brush.spec.tsx +0 -522
- package/test/cartesian/Brush.stacked.spec.tsx +0 -221
- package/test/cartesian/CartesianAxis.render.spec.tsx +0 -50
- package/test/cartesian/CartesianAxis.spec.tsx +0 -396
- package/test/cartesian/CartesianGrid.render.spec.tsx +0 -39
- package/test/cartesian/CartesianGrid.spec.tsx +0 -2103
- package/test/cartesian/ErrorBar.render.spec.tsx +0 -69
- package/test/cartesian/ErrorBar.spec.tsx +0 -2414
- package/test/cartesian/Funnel.animation.spec.tsx +0 -241
- package/test/cartesian/Funnel.spec.tsx +0 -226
- package/test/cartesian/Funnel.typed.spec.tsx +0 -221
- package/test/cartesian/GraphicalItemClipPath.scale-behavior.spec.tsx +0 -627
- package/test/cartesian/GraphicalItemClipPath.spec.tsx +0 -427
- package/test/cartesian/Line.animation.spec.tsx +0 -643
- package/test/cartesian/Line.sparseAnimationPath.spec.tsx +0 -98
- package/test/cartesian/Line.spec.tsx +0 -471
- package/test/cartesian/Line.typed.spec.tsx +0 -152
- package/test/cartesian/ReferenceArea.render.spec.tsx +0 -63
- package/test/cartesian/ReferenceArea.spec.tsx +0 -663
- package/test/cartesian/ReferenceArea.typed.spec.tsx +0 -74
- package/test/cartesian/ReferenceDot.render.spec.tsx +0 -55
- package/test/cartesian/ReferenceDot.spec.tsx +0 -462
- package/test/cartesian/ReferenceDot.typed.spec.tsx +0 -76
- package/test/cartesian/ReferenceLine/ReferenceLine.panorama.spec.tsx +0 -184
- package/test/cartesian/ReferenceLine/ReferenceLine.spec.tsx +0 -744
- package/test/cartesian/ReferenceLine/ReferenceLine.typed.spec.tsx +0 -74
- package/test/cartesian/ReferenceLine/getEndPoints.spec.ts +0 -399
- package/test/cartesian/ReferenceLine.render.spec.tsx +0 -134
- package/test/cartesian/Scatter.animation.spec.tsx +0 -381
- package/test/cartesian/Scatter.render.spec.tsx +0 -61
- package/test/cartesian/Scatter.spec.tsx +0 -406
- package/test/cartesian/Scatter.typed.spec.tsx +0 -153
- package/test/cartesian/XAxis/XAxis.barSize.spec.tsx +0 -336
- package/test/cartesian/XAxis/XAxis.brush.spec.tsx +0 -266
- package/test/cartesian/XAxis/XAxis.categorydomain.spec.tsx +0 -872
- package/test/cartesian/XAxis/XAxis.dataKey.spec.tsx +0 -86
- package/test/cartesian/XAxis/XAxis.datatypes.spec.tsx +0 -127
- package/test/cartesian/XAxis/XAxis.hide.spec.tsx +0 -106
- package/test/cartesian/XAxis/XAxis.multiaxis.spec.tsx +0 -336
- package/test/cartesian/XAxis/XAxis.numberdomain.spec.tsx +0 -1466
- package/test/cartesian/XAxis/XAxis.padding.spec.tsx +0 -758
- package/test/cartesian/XAxis/XAxis.padding_clip.spec.tsx +0 -65
- package/test/cartesian/XAxis/XAxis.state.spec.tsx +0 -355
- package/test/cartesian/XAxis/XAxis.tick.spec.tsx +0 -493
- package/test/cartesian/XAxis/XAxis.timescale.spec.tsx +0 -233
- package/test/cartesian/XAxis/XAxis.type.spec.tsx +0 -107
- package/test/cartesian/XAxis/XAxis.typed.spec.tsx +0 -102
- package/test/cartesian/XAxis/XAxis.vertical.spec.tsx +0 -265
- package/test/cartesian/XAxis.tickFormatter.spec.tsx +0 -54
- package/test/cartesian/YAxis/YAxis.7362.derivedDomain.spec.tsx +0 -230
- package/test/cartesian/YAxis/YAxis.7362.spec.tsx +0 -104
- package/test/cartesian/YAxis/YAxis.interval-zero.spec.tsx +0 -88
- package/test/cartesian/YAxis/YAxis.label.spec.tsx +0 -219
- package/test/cartesian/YAxis/YAxis.spec.tsx +0 -1595
- package/test/cartesian/YAxis/YAxis.tick.spec.tsx +0 -428
- package/test/cartesian/YAxis/YAxis.tickFormatter.spec.tsx +0 -54
- package/test/cartesian/YAxis/YAxis.ticks.spec.tsx +0 -263
- package/test/cartesian/YAxis/YAxis.type.spec.tsx +0 -107
- package/test/cartesian/YAxis/YAxis.typed.spec.tsx +0 -102
- package/test/cartesian/ZAxis.spec.tsx +0 -300
- package/test/cartesian/ZAxis.typed.spec.tsx +0 -33
- package/test/cartesian/__snapshots__/Brush.spec.tsx.snap +0 -5
- package/test/cartesian/axisLineAndStroke.spec.tsx +0 -72
- package/test/cartesian/getCartesianPosition.spec.ts +0 -907
- package/test/cartesian/getEquidistantTicks.spec.ts +0 -88
- package/test/cartesian/getTicks.spec.ts +0 -378
- package/test/cartesian/miscFeatureGaps.spec.tsx +0 -89
- package/test/cartesian/useAnimatedLineLength.spec.ts +0 -168
- package/test/chart/AccessibilityLayer.spec.tsx +0 -569
- package/test/chart/AccessibilityScans.spec.tsx +0 -286
- package/test/chart/AreaChart.spec.tsx +0 -409
- package/test/chart/AreaChart.stacked.spec.tsx +0 -1407
- package/test/chart/AreaChart.typed.spec.tsx +0 -39
- package/test/chart/BarChart.spec.tsx +0 -3719
- package/test/chart/BarChart.typed.spec.tsx +0 -60
- package/test/chart/CategoricalChart.spec.tsx +0 -255
- package/test/chart/ComposedChart.spec.tsx +0 -199
- package/test/chart/ComposedChart.typed.spec.tsx +0 -39
- package/test/chart/FunnelChart.spec.tsx +0 -215
- package/test/chart/FunnelChart.typed.spec.tsx +0 -39
- package/test/chart/LineChart.multiseries.spec.tsx +0 -50
- package/test/chart/LineChart.smoke.spec.tsx +0 -50
- package/test/chart/LineChart.spec.tsx +0 -930
- package/test/chart/LineChart.typed.spec.tsx +0 -39
- package/test/chart/NicheChartTooltip.spec.tsx +0 -81
- package/test/chart/PieChart.spec.tsx +0 -793
- package/test/chart/PieChart.typed.spec.tsx +0 -39
- package/test/chart/RadarChart.spec.tsx +0 -530
- package/test/chart/RadarChart.typed.spec.tsx +0 -39
- package/test/chart/RadialBarChart.5966.spec.tsx +0 -48
- package/test/chart/RadialBarChart.spec.tsx +0 -679
- package/test/chart/RadialBarChart.typed.spec.tsx +0 -39
- package/test/chart/RechartsWrapper.spec.tsx +0 -83
- package/test/chart/Sankey.content.spec.tsx +0 -46
- package/test/chart/Sankey.spec.tsx +0 -952
- package/test/chart/Sankey.typed.spec.tsx +0 -29
- package/test/chart/ScatterChart.spec.tsx +0 -2613
- package/test/chart/ScatterChart.typed.spec.tsx +0 -39
- package/test/chart/SunburstChart.spec.tsx +0 -146
- package/test/chart/Treemap.animation.spec.tsx +0 -52
- package/test/chart/Treemap.spec.tsx +0 -1003
- package/test/chart/Treemap.typed.spec.tsx +0 -26
- package/test/chart/chartEvents.spec.tsx +0 -127
- package/test/chart/responsive.spec.tsx +0 -620
- package/test/component/Cell.render.spec.tsx +0 -155
- package/test/component/Cell.spec.tsx +0 -12
- package/test/component/Cursor.spec.tsx +0 -186
- package/test/component/DefaultTooltipContent.spec.tsx +0 -102
- package/test/component/Label.render.spec.tsx +0 -63
- package/test/component/Label.spec.tsx +0 -686
- package/test/component/Label.typed.spec.tsx +0 -46
- package/test/component/LabelList.spec.tsx +0 -188
- package/test/component/Legend.itemSorter.spec.tsx +0 -704
- package/test/component/Legend.render.spec.tsx +0 -92
- package/test/component/Legend.spec.tsx +0 -2213
- package/test/component/Legend.typed.spec.tsx +0 -22
- package/test/component/ResponsiveContainer.spec.tsx +0 -523
- package/test/component/ResponsiveContainerDataTest.spec.tsx +0 -51
- package/test/component/Text.spec.tsx +0 -415
- package/test/component/Text.typed.spec.tsx +0 -46
- package/test/component/Tooltip/ActiveDot.spec.tsx +0 -370
- package/test/component/Tooltip/Tooltip.animation.spec.tsx +0 -209
- package/test/component/Tooltip/Tooltip.content.spec.tsx +0 -128
- package/test/component/Tooltip/Tooltip.formatter.spec.tsx +0 -152
- package/test/component/Tooltip/Tooltip.includeHidden.spec.tsx +0 -79
- package/test/component/Tooltip/Tooltip.multipleDataArrays.spec.tsx +0 -165
- package/test/component/Tooltip/Tooltip.offset.spec.tsx +0 -113
- package/test/component/Tooltip/Tooltip.state.spec.tsx +0 -74
- package/test/component/Tooltip/Tooltip.sync.spec.tsx +0 -639
- package/test/component/Tooltip/defaultIndex.spec.tsx +0 -227
- package/test/component/Tooltip/graphicalItem.formatter.spec.tsx +0 -138
- package/test/component/Tooltip/itemSorter.spec.tsx +0 -2815
- package/test/component/Tooltip/tooltipEventType.spec.tsx +0 -344
- package/test/component/Tooltip/tooltipMouseHoverSelectors.ts +0 -41
- package/test/component/Tooltip/tooltipTestHelpers.tsx +0 -162
- package/test/component/Tooltip.defaultIndex.spec.tsx +0 -48
- package/test/component/Tooltip.hover.spec.tsx +0 -61
- package/test/component/Tooltip.item.spec.tsx +0 -54
- package/test/component/Tooltip.keyboard.spec.tsx +0 -51
- package/test/component/Tooltip.payload.spec.tsx +0 -1716
- package/test/component/Tooltip.touch.spec.tsx +0 -39
- package/test/component/Tooltip.visibility.spec.tsx +0 -1889
- package/test/component/TooltipBoundingBox.spec.tsx +0 -89
- package/test/component/responsiveContainerUtils.spec.ts +0 -205
- package/test/container/ClipPath.spec.tsx +0 -602
- package/test/container/chartDimensions.spec.tsx +0 -368
- package/test/context/chartLayoutContext.spec.tsx +0 -378
- package/test/helper/ExpectAxisDomain.tsx +0 -27
- package/test/helper/assertNotNull.ts +0 -6
- package/test/helper/assertZIndexLayerOrder.ts +0 -19
- package/test/helper/createSelectorTestCase.tsx +0 -176
- package/test/helper/expectAnimatedPieAngles.ts +0 -100
- package/test/helper/expectAnimatedPiePaths.ts +0 -78
- package/test/helper/expectAreaCurve.ts +0 -15
- package/test/helper/expectAxisTicks.ts +0 -48
- package/test/helper/expectBars.ts +0 -54
- package/test/helper/expectFunctionReturning.ts +0 -58
- package/test/helper/expectLabel.ts +0 -32
- package/test/helper/expectLastCalledWith.ts +0 -48
- package/test/helper/expectLine.ts +0 -20
- package/test/helper/expectPieSectors.ts +0 -80
- package/test/helper/expectScale.ts +0 -37
- package/test/helper/expectScatterPoints.ts +0 -52
- package/test/helper/expectStackGroups.ts +0 -144
- package/test/helper/mockAxes.ts +0 -22
- package/test/helper/mockGetBoundingClientRect.ts +0 -66
- package/test/helper/mockHTMLElementProperty.ts +0 -19
- package/test/helper/mockTouchingElement.ts +0 -27
- package/test/helper/offsetHelpers.ts +0 -19
- package/test/helper/parameterizedTestCases.tsx +0 -99
- package/test/helper/produceState.ts +0 -32
- package/test/helper/selectorTestHelpers.tsx +0 -63
- package/test/helper/trim.spec.ts +0 -35
- package/test/helper/trim.ts +0 -11
- package/test/hooks/useActiveTooltipDataPoints.spec.tsx +0 -358
- package/test/hooks/useAxisDomain.spec.tsx +0 -361
- package/test/hooks/useAxisScale.spec.tsx +0 -283
- package/test/hooks/useAxisTicks.spec.tsx +0 -130
- package/test/hooks/useOffset.spec.tsx +0 -248
- package/test/hooks/useTooltipStateHooks.spec.tsx +0 -109
- package/test/polar/Pie/Pie-TwoLevelPieChart.spec.tsx +0 -135
- package/test/polar/Pie/Pie.spec.tsx +0 -784
- package/test/polar/Pie/Pie.typed.spec.tsx +0 -78
- package/test/polar/Pie.animation.spec.tsx +0 -529
- package/test/polar/PieWithLegend.animation.spec.tsx +0 -142
- package/test/polar/PolarAngleAxis/PolarAngleAxis.events.spec.tsx +0 -76
- package/test/polar/PolarAngleAxis/PolarAngleAxis.spec.tsx +0 -2079
- package/test/polar/PolarAngleAxis/PolarAngleAxis.typed.spec.tsx +0 -102
- package/test/polar/PolarAngleAxis.render.spec.tsx +0 -79
- package/test/polar/PolarGrid.render.spec.tsx +0 -75
- package/test/polar/PolarGrid.spec.tsx +0 -918
- package/test/polar/PolarLegendPerRow.render.spec.tsx +0 -85
- package/test/polar/PolarRadiusAxis.events.spec.tsx +0 -65
- package/test/polar/PolarRadiusAxis.render.spec.tsx +0 -52
- package/test/polar/PolarRadiusAxis.spec.tsx +0 -991
- package/test/polar/PolarRadiusAxis.typed.spec.tsx +0 -84
- package/test/polar/PolarTooltipLegend.render.spec.tsx +0 -80
- package/test/polar/Radar.animation.spec.tsx +0 -570
- package/test/polar/Radar.render.spec.tsx +0 -71
- package/test/polar/Radar.spec.tsx +0 -265
- package/test/polar/Radar.typed.spec.tsx +0 -119
- package/test/polar/RadialBar/RadialBar.spec.tsx +0 -1521
- package/test/polar/RadialBar/RadialBar.typed.spec.tsx +0 -132
- package/test/polar/RadialBar.animation.spec.tsx +0 -375
- package/test/polar/RadialBar.render.spec.tsx +0 -66
- package/test/polar/RadialBar.stacked.spec.tsx +0 -57
- package/test/setup.ts +0 -84
- package/test/shape/ActiveShape.spec.tsx +0 -181
- package/test/shape/Cross.spec.tsx +0 -60
- package/test/shape/Cross.typed.spec.tsx +0 -26
- package/test/shape/Curve.spec.tsx +0 -368
- package/test/shape/Curve.typed.spec.tsx +0 -69
- package/test/shape/Dot.spec.tsx +0 -73
- package/test/shape/Dot.typed.spec.tsx +0 -30
- package/test/shape/Polygon.spec.tsx +0 -357
- package/test/shape/Polygon.typed.spec.tsx +0 -28
- package/test/shape/Rectangle.animation.spec.tsx +0 -451
- package/test/shape/Rectangle.spec.tsx +0 -68
- package/test/shape/Rectangle.typed.spec.tsx +0 -24
- package/test/shape/Sector.spec.tsx +0 -76
- package/test/shape/Sector.typed.spec.tsx +0 -24
- package/test/shape/Symbols.spec.tsx +0 -43
- package/test/shape/Symbols.typed.spec.tsx +0 -24
- package/test/shape/Trapezoid.spec.tsx +0 -50
- package/test/shape/Trapezoid.typed.spec.tsx +0 -24
- package/test/shape/__snapshots__/Cross.spec.tsx.snap +0 -62
- package/test/shape/__snapshots__/Curve.spec.tsx.snap +0 -460
- package/test/shape/__snapshots__/Polygon.spec.tsx.snap +0 -58
- package/test/shape/__snapshots__/Rectangle.spec.tsx.snap +0 -117
- package/test/shape/__snapshots__/Sector.spec.tsx.snap +0 -71
- package/test/shape/__snapshots__/Trapezoid.spec.tsx.snap +0 -64
- package/test/state/chartDataSlice.spec.ts +0 -53
- package/test/state/externalEventsMiddleware.spec.ts +0 -178
- package/test/state/graphicalItemsSlice.spec.ts +0 -92
- package/test/state/hooks.spec.tsx +0 -68
- package/test/state/legendSlice.spec.ts +0 -44
- package/test/state/mouseEventsMiddleware.spec.ts +0 -75
- package/test/state/optionsSlice.spec.ts +0 -19
- package/test/state/reduxDevtoolsJsonStringifyReplacer.spec.ts +0 -25
- package/test/state/referenceElementsSlice.spec.ts +0 -84
- package/test/state/selectors/areaSelectors.spec.tsx +0 -77
- package/test/state/selectors/axisSelectors.spec.tsx +0 -1418
- package/test/state/selectors/barStackSelectors.spec.tsx +0 -752
- package/test/state/selectors/brushSelectors.spec.tsx +0 -30
- package/test/state/selectors/cartesianAxisSlice.spec.ts +0 -96
- package/test/state/selectors/combineNiceTicks.spec.ts +0 -207
- package/test/state/selectors/combiners/combineActiveTooltipIndex.spec.ts +0 -61
- package/test/state/selectors/combiners/combineAllBarPositions.spec.ts +0 -39
- package/test/state/selectors/combiners/combineConfiguredScale.spec.ts +0 -56
- package/test/state/selectors/combiners/combineDisplayedStackedData.spec.ts +0 -123
- package/test/state/selectors/combiners/combineRealScaleType.spec.ts +0 -80
- package/test/state/selectors/containerSelectors.spec.tsx +0 -168
- package/test/state/selectors/dataSelectors.spec.tsx +0 -136
- package/test/state/selectors/legendSelectors.spec.tsx +0 -113
- package/test/state/selectors/lineSelectors.spec.tsx +0 -60
- package/test/state/selectors/pieSelectors.spec.tsx +0 -72
- package/test/state/selectors/radarSelectors.spec.tsx +0 -496
- package/test/state/selectors/rootPropsSelectors.spec.tsx +0 -169
- package/test/state/selectors/scatterSelectors.spec.tsx +0 -47
- package/test/state/selectors/selectActiveTooltipIndex.spec.tsx +0 -234
- package/test/state/selectors/selectAllAxes.spec.tsx +0 -18
- package/test/state/selectors/selectAxisDomain.spec.tsx +0 -21
- package/test/state/selectors/selectAxisDomainIncludingNiceTicks.spec.tsx +0 -19
- package/test/state/selectors/selectAxisRangeWithReverse.spec.tsx +0 -22
- package/test/state/selectors/selectAxisScale.spec.tsx +0 -91
- package/test/state/selectors/selectBarRectangles.stackOffset.spec.tsx +0 -503
- package/test/state/selectors/selectBaseAxis.spec.tsx +0 -56
- package/test/state/selectors/selectCartesianItemsSettings.spec.tsx +0 -57
- package/test/state/selectors/selectChartOffset.spec.tsx +0 -26
- package/test/state/selectors/selectDisplayedData.spec.tsx +0 -282
- package/test/state/selectors/selectIsTooltipActive.spec.tsx +0 -231
- package/test/state/selectors/selectNumericalDomain.spec.tsx +0 -21
- package/test/state/selectors/selectRealScaleType.spec.tsx +0 -19
- package/test/state/selectors/selectStackGroups.spec.tsx +0 -322
- package/test/state/selectors/selectXAxisPosition.spec.tsx +0 -22
- package/test/state/selectors/selectYAxisPosition.spec.tsx +0 -22
- package/test/state/selectors/selectors.spec.tsx +0 -1613
- package/test/state/throttling.spec.ts +0 -200
- package/test/state/zIndexSlice.spec.ts +0 -85
- package/test/synchronisation/useChartSynchronisation.spec.tsx +0 -225
- package/test/util/BarUtils.spec.ts +0 -39
- package/test/util/CartesianUtils/CartesianUtils.spec.ts +0 -261
- package/test/util/CartesianUtils/rectWithPoints.spec.ts +0 -48
- package/test/util/ChartUtils/ChartUtils.spec.ts +0 -491
- package/test/util/ChartUtils/appendOffsetOfLegend.spec.ts +0 -136
- package/test/util/ChartUtils/appendOffsetOfLegend.spec.tsx +0 -133
- package/test/util/ChartUtils/getCateCoordinateOfLine.spec.ts +0 -83
- package/test/util/ChartUtils/getStackedData.spec.ts +0 -416
- package/test/util/ChartUtils/truncateByDomain.spec.ts +0 -70
- package/test/util/DataUtils.spec.ts +0 -385
- package/test/util/DomUtils.spec.tsx +0 -117
- package/test/util/FunnelUtils.spec.tsx +0 -70
- package/test/util/Global.spec.ts +0 -11
- package/test/util/LRUCache.spec.ts +0 -81
- package/test/util/LogUtils.spec.ts +0 -45
- package/test/util/PolarUtils.spec.ts +0 -66
- package/test/util/ReduceCssCalcPrototype.spec.ts +0 -141
- package/test/util/ShallowEqual.spec.ts +0 -102
- package/test/util/TickUtils.spec.ts +0 -29
- package/test/util/axisPropsAreEqual.spec.ts +0 -93
- package/test/util/createChartHelpers.spec.tsx +0 -210
- package/test/util/cursor/getCursorPoints.spec.ts +0 -136
- package/test/util/cursor/getCursorRectangle.spec.ts +0 -50
- package/test/util/cursor/getRadialCursorPoints.spec.ts +0 -36
- package/test/util/errorValue.spec.ts +0 -69
- package/test/util/getEveryNth.spec.ts +0 -39
- package/test/util/getRadiusAndStrokeWidthFromDot.spec.ts +0 -51
- package/test/util/getRelativeCoordinate.spec.ts +0 -250
- package/test/util/getSliced.spec.ts +0 -45
- package/test/util/isDomainSpecifiedByUser.spec.ts +0 -207
- package/test/util/isWellBehavedNumber.spec.ts +0 -54
- package/test/util/payload/getUniqPayload.spec.ts +0 -56
- package/test/util/propsAreEqual.spec.ts +0 -75
- package/test/util/round.spec.ts +0 -112
- package/test/util/scale/arithmetic.spec.ts +0 -61
- package/test/util/scale/createCategoricalInverse.spec.ts +0 -84
- package/test/util/scale/getNiceTickValues.spec.ts +0 -421
- package/test/util/scale/getTickValuesFixedDomain.spec.ts +0 -155
- package/test/util/svgPropertiesAndEvents.spec.tsx +0 -206
- package/test/util/svgPropertiesNoEvents.spec.tsx +0 -228
- package/test/util/tooltip/translate.spec.ts +0 -396
- package/test/util/useAnimationId.spec.tsx +0 -59
- package/test/util/useElementOffset.spec.tsx +0 -173
- package/test/util/usePrefersReducedMotion.spec.ts +0 -54
- package/test/util/useUniqueId.spec.ts +0 -99
- package/test/utils/diagnostics-allowlist.ts +0 -18
- package/test/utils/diagnostics.ts +0 -58
- package/test/zIndex/AllZIndexPortals.spec.tsx +0 -83
- package/test/zIndex/DefaultZIndexes.spec.ts +0 -80
- package/test/zIndex/DynamicZIndex.spec.tsx +0 -102
- package/test/zIndex/ZIndexLayer.portalOwner.spec.tsx +0 -125
- package/test/zIndex/componentZIndex.spec.tsx +0 -255
- package/test/zIndex/getZIndexFromUnknown.spec.ts +0 -51
- package/test/zIndex/multiChartZIndexIsolation.spec.tsx +0 -90
- package/test/zIndex/zIndexSelectors.spec.ts +0 -172
- 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
|
-
});
|