solid-recharts 1.0.0 → 2.0.0-beta.1
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 +4 -6
- package/src/animation/AnimatedItems.tsx +4 -2
- package/src/animation/CSSTransitionAnimate.tsx +39 -41
- package/src/animation/JavascriptAnimate.tsx +41 -45
- package/src/cartesian/Area.tsx +4 -4
- package/src/cartesian/AreaRevealShape.tsx +1 -1
- package/src/cartesian/Bar.tsx +21 -33
- package/src/cartesian/BarStack.tsx +5 -5
- package/src/cartesian/Brush.tsx +15 -19
- package/src/cartesian/CartesianAxis.tsx +4 -4
- package/src/cartesian/CartesianGrid.tsx +5 -5
- package/src/cartesian/ErrorBar.tsx +7 -9
- package/src/cartesian/Funnel.tsx +3 -3
- package/src/cartesian/GraphicalItemClipPath.tsx +1 -1
- package/src/cartesian/Line.tsx +16 -18
- package/src/cartesian/LineDrawShape.tsx +13 -14
- package/src/cartesian/ReferenceArea.tsx +4 -4
- package/src/cartesian/ReferenceDot.tsx +4 -4
- package/src/cartesian/ReferenceLine.tsx +4 -4
- package/src/cartesian/RenderedTicksReporter.tsx +17 -19
- package/src/cartesian/Scatter.tsx +3 -3
- package/src/cartesian/XAxis.tsx +1 -1
- package/src/cartesian/YAxis.tsx +33 -35
- package/src/cartesian/ZAxis.tsx +2 -3
- package/src/chart/AreaChart.tsx +1 -1
- package/src/chart/BarChart.tsx +1 -1
- package/src/chart/CartesianChart.tsx +3 -4
- 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 +3 -4
- package/src/chart/PolarChart.tsx +3 -4
- package/src/chart/RadarChart.tsx +3 -4
- package/src/chart/RadialBarChart.tsx +3 -7
- package/src/chart/RechartsWrapper.tsx +24 -14
- package/src/chart/Sankey.tsx +6 -9
- package/src/chart/ScatterChart.tsx +1 -1
- package/src/chart/SunburstChart.tsx +4 -5
- package/src/chart/Treemap.tsx +4 -5
- package/src/component/ActivePoints.tsx +6 -6
- package/src/component/Cell.tsx +5 -23
- package/src/component/Cursor.tsx +3 -3
- package/src/component/DefaultLegendContent.tsx +6 -8
- package/src/component/DefaultTooltipContent.tsx +10 -14
- package/src/component/Dots.tsx +5 -5
- package/src/component/Label.tsx +10 -13
- package/src/component/LabelList.tsx +7 -12
- package/src/component/Legend.tsx +21 -26
- package/src/component/ResponsiveContainer.tsx +49 -52
- package/src/component/Text.tsx +5 -5
- package/src/component/Tooltip.tsx +18 -21
- package/src/component/TooltipBoundingBox.tsx +16 -18
- 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 +6 -5
- package/src/context/ErrorBarContext.tsx +2 -2
- package/src/context/PanoramaContext.tsx +2 -2
- package/src/context/RegisterGraphicalItemId.tsx +2 -4
- package/src/context/chartDataContext.tsx +23 -26
- package/src/context/chartLayoutContext.tsx +12 -16
- package/src/polar/Pie.tsx +12 -13
- package/src/polar/PolarAngleAxis.tsx +3 -3
- package/src/polar/PolarGrid.tsx +5 -5
- package/src/polar/PolarRadiusAxis.tsx +3 -3
- package/src/polar/Radar.tsx +3 -3
- package/src/polar/RadialBar.tsx +3 -3
- package/src/shape/Cross.tsx +5 -5
- package/src/shape/Curve.tsx +7 -6
- package/src/shape/Dot.tsx +4 -4
- package/src/shape/Polygon.tsx +5 -5
- package/src/shape/Rectangle.tsx +20 -22
- package/src/shape/Sector.tsx +5 -5
- package/src/shape/Symbols.tsx +5 -5
- package/src/shape/Trapezoid.tsx +27 -29
- package/src/state/RechartsStoreProvider.tsx +3 -5
- package/src/state/ReportChartProps.tsx +6 -8
- package/src/state/ReportEventSettings.tsx +6 -8
- package/src/state/ReportMainChartProps.tsx +9 -11
- package/src/state/ReportPolarOptions.tsx +13 -15
- package/src/state/SetLegendPayload.ts +1 -1
- package/src/state/SetTooltipEntrySettings.tsx +1 -1
- package/src/state/brushSlice.ts +8 -10
- package/src/state/cartesianAxisSlice.ts +38 -46
- package/src/state/chartDataSlice.ts +23 -29
- package/src/state/errorBarSlice.ts +16 -22
- package/src/state/eventSettingsSlice.ts +9 -11
- package/src/state/graphicalItemsSlice.ts +13 -17
- package/src/state/layoutSlice.ts +19 -27
- package/src/state/legendSlice.ts +18 -24
- package/src/state/optionsSlice.ts +6 -8
- package/src/state/polarAxisSlice.ts +13 -21
- package/src/state/polarOptionsSlice.ts +14 -16
- package/src/state/referenceElementsSlice.ts +19 -25
- package/src/state/registerInStore.ts +13 -15
- package/src/state/renderedTicksSlice.ts +7 -11
- package/src/state/rootPropsSlice.ts +14 -16
- package/src/state/tooltipSlice.ts +95 -115
- package/src/state/unregisterOnCleanup.ts +20 -5
- package/src/state/zIndexSlice.ts +42 -50
- package/src/synchronisation/useChartSynchronisation.tsx +217 -213
- package/src/util/ActiveShapeUtils.tsx +2 -2
- package/src/util/BarUtils.tsx +3 -5
- package/src/util/FunnelUtils.tsx +1 -1
- package/src/util/RadialBarUtils.tsx +3 -4
- package/src/util/createCartesianCharts.tsx +1 -1
- package/src/util/createPolarCharts.tsx +1 -1
- package/src/util/svgPropertiesAndEvents.ts +1 -1
- package/src/util/tooltip/translate.ts +2 -2
- package/src/util/types.ts +2 -2
- package/src/zIndex/ZIndexLayer.tsx +68 -39
- package/src/zIndex/ZIndexPortal.tsx +25 -29
- package/test/_data.ts +408 -0
- package/test/animation/AnimationController.typed.spec.ts +53 -0
- package/test/animation/AnimationControllerImpl.spec.ts +271 -0
- package/test/animation/CSSTransitionAnimate.timing.spec.tsx +473 -0
- package/test/animation/JavascriptAnimate.spec.tsx +62 -0
- package/test/animation/RechartsAnimation.spec.ts +636 -0
- package/test/animation/easing.spec.ts +218 -0
- package/test/animation/legacyAnimationLengthChange.spec.tsx +803 -0
- package/test/animation/matchBy.spec.ts +467 -0
- package/test/animation/mockAnimationController.ts +40 -0
- package/test/animation/mockControllerAnimationManager.ts +143 -0
- package/test/animation/mockTimeoutController.ts +114 -0
- package/test/animation/timeoutController.spec.ts +138 -0
- package/test/animation/useAnimationStartSnapshot.spec.ts +147 -0
- package/test/animation/util.spec.ts +28 -0
- package/test/cartesian/Area.animation.spec.tsx +363 -0
- package/test/cartesian/Area.range.spec.tsx +54 -0
- package/test/cartesian/Area.spec.tsx +1202 -0
- package/test/cartesian/Area.stacked.render.spec.tsx +69 -0
- package/test/cartesian/Area.typed.spec.tsx +209 -0
- package/test/cartesian/Axis.integration.spec.tsx +158 -0
- package/test/cartesian/Bar/Bar.csstransition.spec.tsx +299 -0
- package/test/cartesian/Bar/Bar.spec.tsx +2314 -0
- package/test/cartesian/Bar/Bar.typed.spec.tsx +192 -0
- package/test/cartesian/Bar.animation.spec.tsx +426 -0
- package/test/cartesian/Bar.stackDomain.spec.tsx +66 -0
- package/test/cartesian/Bar.stacked.render.spec.tsx +53 -0
- package/test/cartesian/Bar.truncateByDomain.spec.tsx +237 -0
- package/test/cartesian/Bar.zeroDimensionFiltering.spec.tsx +336 -0
- package/test/cartesian/BarStack.spec.tsx +91 -0
- package/test/cartesian/Brush.keyboard.spec.tsx +88 -0
- package/test/cartesian/Brush.panorama.spec.tsx +41 -0
- package/test/cartesian/Brush.props.spec.tsx +63 -0
- package/test/cartesian/Brush.render.spec.tsx +117 -0
- package/test/cartesian/Brush.spec.tsx +522 -0
- package/test/cartesian/Brush.stacked.spec.tsx +221 -0
- package/test/cartesian/CartesianAxis.render.spec.tsx +50 -0
- package/test/cartesian/CartesianAxis.spec.tsx +396 -0
- package/test/cartesian/CartesianGrid.render.spec.tsx +39 -0
- package/test/cartesian/CartesianGrid.spec.tsx +2103 -0
- package/test/cartesian/ErrorBar.render.spec.tsx +69 -0
- package/test/cartesian/ErrorBar.spec.tsx +2414 -0
- package/test/cartesian/Funnel.animation.spec.tsx +241 -0
- package/test/cartesian/Funnel.spec.tsx +226 -0
- package/test/cartesian/Funnel.typed.spec.tsx +221 -0
- package/test/cartesian/GraphicalItemClipPath.scale-behavior.spec.tsx +627 -0
- package/test/cartesian/GraphicalItemClipPath.spec.tsx +427 -0
- package/test/cartesian/Line.animation.spec.tsx +643 -0
- package/test/cartesian/Line.sparseAnimationPath.spec.tsx +98 -0
- package/test/cartesian/Line.spec.tsx +471 -0
- package/test/cartesian/Line.typed.spec.tsx +152 -0
- package/test/cartesian/ReferenceArea.render.spec.tsx +63 -0
- package/test/cartesian/ReferenceArea.spec.tsx +663 -0
- package/test/cartesian/ReferenceArea.typed.spec.tsx +74 -0
- package/test/cartesian/ReferenceDot.render.spec.tsx +55 -0
- package/test/cartesian/ReferenceDot.spec.tsx +462 -0
- package/test/cartesian/ReferenceDot.typed.spec.tsx +76 -0
- package/test/cartesian/ReferenceLine/ReferenceLine.panorama.spec.tsx +184 -0
- package/test/cartesian/ReferenceLine/ReferenceLine.spec.tsx +744 -0
- package/test/cartesian/ReferenceLine/ReferenceLine.typed.spec.tsx +74 -0
- package/test/cartesian/ReferenceLine/getEndPoints.spec.ts +399 -0
- package/test/cartesian/ReferenceLine.render.spec.tsx +134 -0
- package/test/cartesian/Scatter.animation.spec.tsx +381 -0
- package/test/cartesian/Scatter.render.spec.tsx +61 -0
- package/test/cartesian/Scatter.spec.tsx +406 -0
- package/test/cartesian/Scatter.typed.spec.tsx +153 -0
- package/test/cartesian/XAxis/XAxis.barSize.spec.tsx +336 -0
- package/test/cartesian/XAxis/XAxis.brush.spec.tsx +266 -0
- package/test/cartesian/XAxis/XAxis.categorydomain.spec.tsx +872 -0
- package/test/cartesian/XAxis/XAxis.dataKey.spec.tsx +86 -0
- package/test/cartesian/XAxis/XAxis.datatypes.spec.tsx +127 -0
- package/test/cartesian/XAxis/XAxis.hide.spec.tsx +106 -0
- package/test/cartesian/XAxis/XAxis.multiaxis.spec.tsx +336 -0
- package/test/cartesian/XAxis/XAxis.numberdomain.spec.tsx +1466 -0
- package/test/cartesian/XAxis/XAxis.padding.spec.tsx +758 -0
- package/test/cartesian/XAxis/XAxis.padding_clip.spec.tsx +65 -0
- package/test/cartesian/XAxis/XAxis.state.spec.tsx +355 -0
- package/test/cartesian/XAxis/XAxis.tick.spec.tsx +493 -0
- package/test/cartesian/XAxis/XAxis.timescale.spec.tsx +233 -0
- package/test/cartesian/XAxis/XAxis.type.spec.tsx +107 -0
- package/test/cartesian/XAxis/XAxis.typed.spec.tsx +102 -0
- package/test/cartesian/XAxis/XAxis.vertical.spec.tsx +265 -0
- package/test/cartesian/XAxis.tickFormatter.spec.tsx +54 -0
- package/test/cartesian/YAxis/YAxis.7362.derivedDomain.spec.tsx +230 -0
- package/test/cartesian/YAxis/YAxis.7362.spec.tsx +104 -0
- package/test/cartesian/YAxis/YAxis.interval-zero.spec.tsx +88 -0
- package/test/cartesian/YAxis/YAxis.label.spec.tsx +219 -0
- package/test/cartesian/YAxis/YAxis.spec.tsx +1595 -0
- package/test/cartesian/YAxis/YAxis.tick.spec.tsx +428 -0
- package/test/cartesian/YAxis/YAxis.tickFormatter.spec.tsx +54 -0
- package/test/cartesian/YAxis/YAxis.ticks.spec.tsx +263 -0
- package/test/cartesian/YAxis/YAxis.type.spec.tsx +107 -0
- package/test/cartesian/YAxis/YAxis.typed.spec.tsx +102 -0
- package/test/cartesian/ZAxis.spec.tsx +300 -0
- package/test/cartesian/ZAxis.typed.spec.tsx +33 -0
- package/test/cartesian/__snapshots__/Brush.spec.tsx.snap +5 -0
- package/test/cartesian/axisLineAndStroke.spec.tsx +72 -0
- package/test/cartesian/getCartesianPosition.spec.ts +907 -0
- package/test/cartesian/getEquidistantTicks.spec.ts +88 -0
- package/test/cartesian/getTicks.spec.ts +378 -0
- package/test/cartesian/miscFeatureGaps.spec.tsx +89 -0
- package/test/cartesian/useAnimatedLineLength.spec.ts +168 -0
- package/test/chart/AccessibilityLayer.spec.tsx +569 -0
- package/test/chart/AccessibilityScans.spec.tsx +286 -0
- package/test/chart/AreaChart.spec.tsx +409 -0
- package/test/chart/AreaChart.stacked.spec.tsx +1407 -0
- package/test/chart/AreaChart.typed.spec.tsx +39 -0
- package/test/chart/BarChart.spec.tsx +3719 -0
- package/test/chart/BarChart.typed.spec.tsx +60 -0
- package/test/chart/CategoricalChart.spec.tsx +255 -0
- package/test/chart/ComposedChart.spec.tsx +199 -0
- package/test/chart/ComposedChart.typed.spec.tsx +39 -0
- package/test/chart/FunnelChart.spec.tsx +215 -0
- package/test/chart/FunnelChart.typed.spec.tsx +39 -0
- package/test/chart/LineChart.multiseries.spec.tsx +50 -0
- package/test/chart/LineChart.smoke.spec.tsx +50 -0
- package/test/chart/LineChart.spec.tsx +930 -0
- package/test/chart/LineChart.typed.spec.tsx +39 -0
- package/test/chart/NicheChartTooltip.spec.tsx +81 -0
- package/test/chart/PieChart.spec.tsx +793 -0
- package/test/chart/PieChart.typed.spec.tsx +39 -0
- package/test/chart/RadarChart.spec.tsx +530 -0
- package/test/chart/RadarChart.typed.spec.tsx +39 -0
- package/test/chart/RadialBarChart.5966.spec.tsx +48 -0
- package/test/chart/RadialBarChart.spec.tsx +679 -0
- package/test/chart/RadialBarChart.typed.spec.tsx +39 -0
- package/test/chart/RechartsWrapper.spec.tsx +83 -0
- package/test/chart/Sankey.content.spec.tsx +46 -0
- package/test/chart/Sankey.spec.tsx +952 -0
- package/test/chart/Sankey.typed.spec.tsx +29 -0
- package/test/chart/ScatterChart.spec.tsx +2613 -0
- package/test/chart/ScatterChart.typed.spec.tsx +39 -0
- package/test/chart/SunburstChart.spec.tsx +146 -0
- package/test/chart/Treemap.animation.spec.tsx +52 -0
- package/test/chart/Treemap.spec.tsx +1003 -0
- package/test/chart/Treemap.typed.spec.tsx +26 -0
- package/test/chart/chartEvents.spec.tsx +127 -0
- package/test/chart/responsive.spec.tsx +620 -0
- package/test/component/Cell.render.spec.tsx +155 -0
- package/test/component/Cell.spec.tsx +12 -0
- package/test/component/Cursor.spec.tsx +186 -0
- package/test/component/DefaultTooltipContent.spec.tsx +102 -0
- package/test/component/Label.render.spec.tsx +63 -0
- package/test/component/Label.spec.tsx +686 -0
- package/test/component/Label.typed.spec.tsx +46 -0
- package/test/component/LabelList.spec.tsx +188 -0
- package/test/component/Legend.itemSorter.spec.tsx +704 -0
- package/test/component/Legend.render.spec.tsx +92 -0
- package/test/component/Legend.spec.tsx +2213 -0
- package/test/component/Legend.typed.spec.tsx +22 -0
- package/test/component/ResponsiveContainer.spec.tsx +523 -0
- package/test/component/ResponsiveContainerDataTest.spec.tsx +51 -0
- package/test/component/Text.spec.tsx +415 -0
- package/test/component/Text.typed.spec.tsx +46 -0
- package/test/component/Tooltip/ActiveDot.spec.tsx +370 -0
- package/test/component/Tooltip/Tooltip.animation.spec.tsx +209 -0
- package/test/component/Tooltip/Tooltip.content.spec.tsx +128 -0
- package/test/component/Tooltip/Tooltip.formatter.spec.tsx +152 -0
- package/test/component/Tooltip/Tooltip.includeHidden.spec.tsx +79 -0
- package/test/component/Tooltip/Tooltip.multipleDataArrays.spec.tsx +165 -0
- package/test/component/Tooltip/Tooltip.offset.spec.tsx +113 -0
- package/test/component/Tooltip/Tooltip.state.spec.tsx +74 -0
- package/test/component/Tooltip/Tooltip.sync.spec.tsx +639 -0
- package/test/component/Tooltip/defaultIndex.spec.tsx +227 -0
- package/test/component/Tooltip/graphicalItem.formatter.spec.tsx +138 -0
- package/test/component/Tooltip/itemSorter.spec.tsx +2815 -0
- package/test/component/Tooltip/tooltipEventType.spec.tsx +344 -0
- package/test/component/Tooltip/tooltipMouseHoverSelectors.ts +41 -0
- package/test/component/Tooltip/tooltipTestHelpers.tsx +162 -0
- package/test/component/Tooltip.defaultIndex.spec.tsx +48 -0
- package/test/component/Tooltip.hover.spec.tsx +61 -0
- package/test/component/Tooltip.item.spec.tsx +54 -0
- package/test/component/Tooltip.keyboard.spec.tsx +51 -0
- package/test/component/Tooltip.payload.spec.tsx +1716 -0
- package/test/component/Tooltip.touch.spec.tsx +39 -0
- package/test/component/Tooltip.visibility.spec.tsx +1889 -0
- package/test/component/TooltipBoundingBox.spec.tsx +89 -0
- package/test/component/responsiveContainerUtils.spec.ts +205 -0
- package/test/container/ClipPath.spec.tsx +602 -0
- package/test/container/chartDimensions.spec.tsx +368 -0
- package/test/context/chartLayoutContext.spec.tsx +378 -0
- package/test/helper/ExpectAxisDomain.tsx +27 -0
- package/test/helper/assertNotNull.ts +6 -0
- package/test/helper/assertZIndexLayerOrder.ts +19 -0
- package/test/helper/createSelectorTestCase.tsx +176 -0
- package/test/helper/expectAnimatedPieAngles.ts +100 -0
- package/test/helper/expectAnimatedPiePaths.ts +78 -0
- package/test/helper/expectAreaCurve.ts +15 -0
- package/test/helper/expectAxisTicks.ts +48 -0
- package/test/helper/expectBars.ts +54 -0
- package/test/helper/expectFunctionReturning.ts +58 -0
- package/test/helper/expectLabel.ts +32 -0
- package/test/helper/expectLastCalledWith.ts +48 -0
- package/test/helper/expectLine.ts +20 -0
- package/test/helper/expectPieSectors.ts +80 -0
- package/test/helper/expectScale.ts +37 -0
- package/test/helper/expectScatterPoints.ts +52 -0
- package/test/helper/expectStackGroups.ts +144 -0
- package/test/helper/mockAxes.ts +22 -0
- package/test/helper/mockGetBoundingClientRect.ts +66 -0
- package/test/helper/mockHTMLElementProperty.ts +19 -0
- package/test/helper/mockTouchingElement.ts +27 -0
- package/test/helper/offsetHelpers.ts +19 -0
- package/test/helper/parameterizedTestCases.tsx +99 -0
- package/test/helper/produceState.ts +32 -0
- package/test/helper/selectorTestHelpers.tsx +63 -0
- package/test/helper/trim.spec.ts +35 -0
- package/test/helper/trim.ts +11 -0
- package/test/hooks/useActiveTooltipDataPoints.spec.tsx +358 -0
- package/test/hooks/useAxisDomain.spec.tsx +361 -0
- package/test/hooks/useAxisScale.spec.tsx +283 -0
- package/test/hooks/useAxisTicks.spec.tsx +130 -0
- package/test/hooks/useOffset.spec.tsx +248 -0
- package/test/hooks/useTooltipStateHooks.spec.tsx +109 -0
- package/test/polar/Pie/Pie-TwoLevelPieChart.spec.tsx +135 -0
- package/test/polar/Pie/Pie.spec.tsx +784 -0
- package/test/polar/Pie/Pie.typed.spec.tsx +78 -0
- package/test/polar/Pie.animation.spec.tsx +529 -0
- package/test/polar/PieWithLegend.animation.spec.tsx +142 -0
- package/test/polar/PolarAngleAxis/PolarAngleAxis.events.spec.tsx +76 -0
- package/test/polar/PolarAngleAxis/PolarAngleAxis.spec.tsx +2079 -0
- package/test/polar/PolarAngleAxis/PolarAngleAxis.typed.spec.tsx +102 -0
- package/test/polar/PolarAngleAxis.render.spec.tsx +79 -0
- package/test/polar/PolarGrid.render.spec.tsx +75 -0
- package/test/polar/PolarGrid.spec.tsx +918 -0
- package/test/polar/PolarLegendPerRow.render.spec.tsx +85 -0
- package/test/polar/PolarRadiusAxis.events.spec.tsx +65 -0
- package/test/polar/PolarRadiusAxis.render.spec.tsx +52 -0
- package/test/polar/PolarRadiusAxis.spec.tsx +991 -0
- package/test/polar/PolarRadiusAxis.typed.spec.tsx +84 -0
- package/test/polar/PolarTooltipLegend.render.spec.tsx +80 -0
- package/test/polar/Radar.animation.spec.tsx +570 -0
- package/test/polar/Radar.render.spec.tsx +71 -0
- package/test/polar/Radar.spec.tsx +265 -0
- package/test/polar/Radar.typed.spec.tsx +119 -0
- package/test/polar/RadialBar/RadialBar.spec.tsx +1521 -0
- package/test/polar/RadialBar/RadialBar.typed.spec.tsx +132 -0
- package/test/polar/RadialBar.animation.spec.tsx +375 -0
- package/test/polar/RadialBar.render.spec.tsx +66 -0
- package/test/polar/RadialBar.stacked.spec.tsx +57 -0
- package/test/setup.ts +84 -0
- package/test/shape/ActiveShape.spec.tsx +181 -0
- package/test/shape/Cross.spec.tsx +60 -0
- package/test/shape/Cross.typed.spec.tsx +26 -0
- package/test/shape/Curve.spec.tsx +368 -0
- package/test/shape/Curve.typed.spec.tsx +69 -0
- package/test/shape/Dot.spec.tsx +73 -0
- package/test/shape/Dot.typed.spec.tsx +30 -0
- package/test/shape/Polygon.spec.tsx +357 -0
- package/test/shape/Polygon.typed.spec.tsx +28 -0
- package/test/shape/Rectangle.animation.spec.tsx +451 -0
- package/test/shape/Rectangle.spec.tsx +68 -0
- package/test/shape/Rectangle.typed.spec.tsx +24 -0
- package/test/shape/Sector.spec.tsx +76 -0
- package/test/shape/Sector.typed.spec.tsx +24 -0
- package/test/shape/Symbols.spec.tsx +43 -0
- package/test/shape/Symbols.typed.spec.tsx +24 -0
- package/test/shape/Trapezoid.spec.tsx +50 -0
- package/test/shape/Trapezoid.typed.spec.tsx +24 -0
- package/test/shape/__snapshots__/Cross.spec.tsx.snap +62 -0
- package/test/shape/__snapshots__/Curve.spec.tsx.snap +460 -0
- package/test/shape/__snapshots__/Polygon.spec.tsx.snap +58 -0
- package/test/shape/__snapshots__/Rectangle.spec.tsx.snap +117 -0
- package/test/shape/__snapshots__/Sector.spec.tsx.snap +71 -0
- package/test/shape/__snapshots__/Trapezoid.spec.tsx.snap +64 -0
- package/test/state/chartDataSlice.spec.ts +53 -0
- package/test/state/createCollectionActions.spec.ts +87 -0
- package/test/state/createSelector.spec.ts +158 -0
- package/test/state/externalEventsMiddleware.spec.ts +178 -0
- package/test/state/graphicalItemsSlice.spec.ts +92 -0
- package/test/state/hooks.spec.tsx +68 -0
- package/test/state/legendSlice.spec.ts +44 -0
- package/test/state/mouseEventsMiddleware.spec.ts +75 -0
- package/test/state/optionsSlice.spec.ts +19 -0
- package/test/state/referenceElementsSlice.spec.ts +84 -0
- package/test/state/registerInStore.spec.tsx +101 -0
- package/test/state/selectors/areaSelectors.spec.tsx +77 -0
- package/test/state/selectors/axisSelectors.spec.tsx +1418 -0
- package/test/state/selectors/barStackSelectors.spec.tsx +752 -0
- package/test/state/selectors/brushSelectors.spec.tsx +30 -0
- package/test/state/selectors/cartesianAxisSlice.spec.ts +96 -0
- package/test/state/selectors/combineNiceTicks.spec.ts +207 -0
- package/test/state/selectors/combiners/combineActiveTooltipIndex.spec.ts +61 -0
- package/test/state/selectors/combiners/combineAllBarPositions.spec.ts +39 -0
- package/test/state/selectors/combiners/combineConfiguredScale.spec.ts +56 -0
- package/test/state/selectors/combiners/combineDisplayedStackedData.spec.ts +123 -0
- package/test/state/selectors/combiners/combineRealScaleType.spec.ts +80 -0
- package/test/state/selectors/containerSelectors.spec.tsx +168 -0
- package/test/state/selectors/dataSelectors.spec.tsx +136 -0
- package/test/state/selectors/legendSelectors.spec.tsx +113 -0
- package/test/state/selectors/lineSelectors.spec.tsx +60 -0
- package/test/state/selectors/pieSelectors.spec.tsx +72 -0
- package/test/state/selectors/radarSelectors.spec.tsx +496 -0
- package/test/state/selectors/rootPropsSelectors.spec.tsx +169 -0
- package/test/state/selectors/scatterSelectors.spec.tsx +47 -0
- package/test/state/selectors/selectActiveTooltipIndex.spec.tsx +234 -0
- package/test/state/selectors/selectAllAxes.spec.tsx +18 -0
- package/test/state/selectors/selectAxisDomain.spec.tsx +21 -0
- package/test/state/selectors/selectAxisDomainIncludingNiceTicks.spec.tsx +19 -0
- package/test/state/selectors/selectAxisRangeWithReverse.spec.tsx +22 -0
- package/test/state/selectors/selectAxisScale.spec.tsx +91 -0
- package/test/state/selectors/selectBarRectangles.stackOffset.spec.tsx +503 -0
- package/test/state/selectors/selectBaseAxis.spec.tsx +56 -0
- package/test/state/selectors/selectCartesianItemsSettings.spec.tsx +57 -0
- package/test/state/selectors/selectChartOffset.spec.tsx +26 -0
- package/test/state/selectors/selectDisplayedData.spec.tsx +282 -0
- package/test/state/selectors/selectIsTooltipActive.spec.tsx +231 -0
- package/test/state/selectors/selectNumericalDomain.spec.tsx +21 -0
- package/test/state/selectors/selectRealScaleType.spec.tsx +19 -0
- package/test/state/selectors/selectStackGroups.spec.tsx +322 -0
- package/test/state/selectors/selectXAxisPosition.spec.tsx +22 -0
- package/test/state/selectors/selectYAxisPosition.spec.tsx +22 -0
- package/test/state/selectors/selectorMemoization.spec.tsx +136 -0
- package/test/state/selectors/selectors.spec.tsx +1613 -0
- package/test/state/throttling.spec.ts +200 -0
- package/test/state/zIndexSlice.spec.ts +85 -0
- package/test/synchronisation/useChartSynchronisation.spec.tsx +225 -0
- package/test/util/BarUtils.spec.ts +39 -0
- package/test/util/CartesianUtils/CartesianUtils.spec.ts +261 -0
- package/test/util/CartesianUtils/rectWithPoints.spec.ts +48 -0
- package/test/util/ChartUtils/ChartUtils.spec.ts +491 -0
- package/test/util/ChartUtils/appendOffsetOfLegend.spec.ts +136 -0
- package/test/util/ChartUtils/appendOffsetOfLegend.spec.tsx +133 -0
- package/test/util/ChartUtils/getCateCoordinateOfLine.spec.ts +97 -0
- package/test/util/ChartUtils/getStackedData.spec.ts +416 -0
- package/test/util/ChartUtils/truncateByDomain.spec.ts +70 -0
- package/test/util/DataUtils.spec.ts +385 -0
- package/test/util/DomUtils.spec.tsx +117 -0
- package/test/util/FunnelUtils.spec.tsx +70 -0
- package/test/util/Global.spec.ts +11 -0
- package/test/util/LRUCache.spec.ts +81 -0
- package/test/util/LogUtils.spec.ts +45 -0
- package/test/util/PolarUtils.spec.ts +66 -0
- package/test/util/ReduceCssCalcPrototype.spec.ts +141 -0
- package/test/util/ShallowEqual.spec.ts +102 -0
- package/test/util/TickUtils.spec.ts +29 -0
- package/test/util/createChartHelpers.spec.tsx +210 -0
- package/test/util/cursor/getCursorPoints.spec.ts +136 -0
- package/test/util/cursor/getCursorRectangle.spec.ts +50 -0
- package/test/util/cursor/getRadialCursorPoints.spec.ts +36 -0
- package/test/util/errorValue.spec.ts +69 -0
- package/test/util/getEveryNth.spec.ts +39 -0
- package/test/util/getRadiusAndStrokeWidthFromDot.spec.ts +51 -0
- package/test/util/getRelativeCoordinate.spec.ts +250 -0
- package/test/util/getSliced.spec.ts +45 -0
- package/test/util/isDomainSpecifiedByUser.spec.ts +207 -0
- package/test/util/isWellBehavedNumber.spec.ts +54 -0
- package/test/util/payload/getUniqPayload.spec.ts +56 -0
- package/test/util/propsAreEqual.spec.ts +75 -0
- package/test/util/round.spec.ts +112 -0
- package/test/util/scale/arithmetic.spec.ts +61 -0
- package/test/util/scale/createCategoricalInverse.spec.ts +84 -0
- package/test/util/scale/getNiceTickValues.spec.ts +421 -0
- package/test/util/scale/getTickValuesFixedDomain.spec.ts +155 -0
- package/test/util/svgPropertiesAndEvents.spec.tsx +206 -0
- package/test/util/svgPropertiesNoEvents.spec.tsx +228 -0
- package/test/util/tooltip/translate.spec.ts +396 -0
- package/test/util/useAnimationId.spec.tsx +59 -0
- package/test/util/useElementOffset.spec.tsx +173 -0
- package/test/util/usePrefersReducedMotion.spec.ts +54 -0
- package/test/util/useUniqueId.spec.ts +99 -0
- package/test/utils/diagnostics-allowlist.ts +18 -0
- package/test/utils/diagnostics.ts +58 -0
- package/test/zIndex/AllZIndexPortals.spec.tsx +83 -0
- package/test/zIndex/DefaultZIndexes.spec.ts +80 -0
- package/test/zIndex/DynamicZIndex.spec.tsx +102 -0
- package/test/zIndex/ZIndexLayer.portalOwner.spec.tsx +125 -0
- package/test/zIndex/componentZIndex.spec.tsx +255 -0
- package/test/zIndex/getZIndexFromUnknown.spec.ts +51 -0
- package/test/zIndex/multiChartZIndexIsolation.spec.tsx +90 -0
- package/test/zIndex/zIndexSelectors.spec.ts +172 -0
- package/test-results/.last-run.json +4 -0
- package/tsconfig.json +11 -0
- package/src/util/DirectPortal.tsx +0 -107
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
// Solid-recharts spec: components expose a `zIndex` prop wired to the chart's
|
|
2
|
+
// z-index portal system (ZIndexLayer). A custom zIndex relocates the element into
|
|
3
|
+
// a dedicated `.recharts-zIndex-layer_<n>` portal. recharts supports these props
|
|
4
|
+
// but does not unit-test them on these components.
|
|
5
|
+
import { describe, expect, it } from "vitest";
|
|
6
|
+
import { flush } from "solid-js";
|
|
7
|
+
import {
|
|
8
|
+
Area,
|
|
9
|
+
AreaChart,
|
|
10
|
+
ErrorBar,
|
|
11
|
+
Line,
|
|
12
|
+
LineChart,
|
|
13
|
+
Pie,
|
|
14
|
+
PieChart,
|
|
15
|
+
PolarGrid,
|
|
16
|
+
Radar,
|
|
17
|
+
RadarChart,
|
|
18
|
+
RadialBar,
|
|
19
|
+
RadialBarChart,
|
|
20
|
+
ReferenceArea,
|
|
21
|
+
ReferenceDot,
|
|
22
|
+
ReferenceLine,
|
|
23
|
+
Scatter,
|
|
24
|
+
ScatterChart,
|
|
25
|
+
XAxis,
|
|
26
|
+
YAxis,
|
|
27
|
+
} from "../../src";
|
|
28
|
+
import { render } from "@solidjs/testing-library";
|
|
29
|
+
|
|
30
|
+
const data = [
|
|
31
|
+
{ name: "a", uv: 100 },
|
|
32
|
+
{ name: "b", uv: 200 },
|
|
33
|
+
{ name: "c", uv: 300 },
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
const radarData = [
|
|
37
|
+
{ subject: "Math", v: 120 },
|
|
38
|
+
{ subject: "Eng", v: 98 },
|
|
39
|
+
{ subject: "Hist", v: 86 },
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
function portalContains(container: Element, zIndex: number, childSelector: string): boolean {
|
|
43
|
+
const portal = container.querySelector(`.recharts-zIndex-layer_${zIndex}`);
|
|
44
|
+
return portal != null && portal.querySelector(childSelector) != null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
describe("component zIndex prop", () => {
|
|
48
|
+
it("ReferenceLine relocates into the requested z-index portal", () => {
|
|
49
|
+
const { container } = render(() => (
|
|
50
|
+
<LineChart width={300} height={300} data={data}>
|
|
51
|
+
<XAxis dataKey="name" />
|
|
52
|
+
<YAxis />
|
|
53
|
+
<Line dataKey="uv" />
|
|
54
|
+
<ReferenceLine y={150} zIndex={1201} />
|
|
55
|
+
</LineChart>
|
|
56
|
+
));
|
|
57
|
+
flush();
|
|
58
|
+
expect(portalContains(container, 1201, ".recharts-reference-line")).toBe(true);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("ReferenceDot relocates into the requested z-index portal", () => {
|
|
62
|
+
const { container } = render(() => (
|
|
63
|
+
<LineChart width={300} height={300} data={data}>
|
|
64
|
+
<XAxis dataKey="name" />
|
|
65
|
+
<YAxis />
|
|
66
|
+
<Line dataKey="uv" />
|
|
67
|
+
<ReferenceDot x="b" y={200} r={6} zIndex={1202} />
|
|
68
|
+
</LineChart>
|
|
69
|
+
));
|
|
70
|
+
flush();
|
|
71
|
+
expect(portalContains(container, 1202, ".recharts-reference-dot")).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("ReferenceArea relocates into the requested z-index portal", () => {
|
|
75
|
+
const { container } = render(() => (
|
|
76
|
+
<LineChart width={300} height={300} data={data}>
|
|
77
|
+
<XAxis dataKey="name" />
|
|
78
|
+
<YAxis />
|
|
79
|
+
<Line dataKey="uv" />
|
|
80
|
+
<ReferenceArea x1="a" x2="c" y1={0} y2={300} zIndex={1203} />
|
|
81
|
+
</LineChart>
|
|
82
|
+
));
|
|
83
|
+
flush();
|
|
84
|
+
expect(portalContains(container, 1203, ".recharts-reference-area")).toBe(true);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("ErrorBar relocates into the requested z-index portal", () => {
|
|
88
|
+
const errData = [
|
|
89
|
+
{ name: "a", uv: 100, err: 10 },
|
|
90
|
+
{ name: "b", uv: 200, err: 20 },
|
|
91
|
+
{ name: "c", uv: 300, err: 30 },
|
|
92
|
+
];
|
|
93
|
+
const { container } = render(() => (
|
|
94
|
+
<LineChart width={300} height={300} data={errData}>
|
|
95
|
+
<XAxis dataKey="name" />
|
|
96
|
+
<YAxis />
|
|
97
|
+
<Line dataKey="uv">
|
|
98
|
+
<ErrorBar dataKey="err" zIndex={1205} />
|
|
99
|
+
</Line>
|
|
100
|
+
</LineChart>
|
|
101
|
+
));
|
|
102
|
+
flush();
|
|
103
|
+
expect(portalContains(container, 1205, ".recharts-errorBar")).toBe(true);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("XAxis relocates into the requested z-index portal", () => {
|
|
107
|
+
const { container } = render(() => (
|
|
108
|
+
<LineChart width={300} height={300} data={data}>
|
|
109
|
+
<XAxis dataKey="name" zIndex={1206} />
|
|
110
|
+
<YAxis />
|
|
111
|
+
<Line dataKey="uv" />
|
|
112
|
+
</LineChart>
|
|
113
|
+
));
|
|
114
|
+
flush();
|
|
115
|
+
expect(portalContains(container, 1206, ".recharts-xAxis")).toBe(true);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("PolarGrid relocates into the requested z-index portal", () => {
|
|
119
|
+
const { container } = render(() => (
|
|
120
|
+
<RadarChart width={300} height={300} data={radarData}>
|
|
121
|
+
<PolarGrid zIndex={1204} />
|
|
122
|
+
<Radar dataKey="v" />
|
|
123
|
+
</RadarChart>
|
|
124
|
+
));
|
|
125
|
+
flush();
|
|
126
|
+
expect(portalContains(container, 1204, ".recharts-polar-grid")).toBe(true);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// The graphical items (Line/Area/Scatter/Pie/Radar/RadialBar) each wrap their whole
|
|
131
|
+
// item Layer in <ZIndexLayer> with a non-zero DEFAULT (areas:100, bars:300, lines:400,
|
|
132
|
+
// scatters:600 — Pie/Radar reuse area, RadialBar reuses bar), so a user `zIndex`
|
|
133
|
+
// relayers the entire item into its portal (recharts parity). These assert both the
|
|
134
|
+
// default portal placement AND a custom `zIndex` relocation.
|
|
135
|
+
describe("graphical item zIndex relayering", () => {
|
|
136
|
+
it("Line renders in its default (400) portal and relocates on a custom zIndex", () => {
|
|
137
|
+
const { container: dflt } = render(() => (
|
|
138
|
+
<LineChart width={300} height={300} data={data}>
|
|
139
|
+
<XAxis dataKey="name" />
|
|
140
|
+
<YAxis />
|
|
141
|
+
<Line dataKey="uv" isAnimationActive={false} />
|
|
142
|
+
</LineChart>
|
|
143
|
+
));
|
|
144
|
+
flush();
|
|
145
|
+
expect(portalContains(dflt, 400, ".recharts-line")).toBe(true);
|
|
146
|
+
|
|
147
|
+
const { container } = render(() => (
|
|
148
|
+
<LineChart width={300} height={300} data={data}>
|
|
149
|
+
<XAxis dataKey="name" />
|
|
150
|
+
<YAxis />
|
|
151
|
+
<Line dataKey="uv" zIndex={1210} isAnimationActive={false} />
|
|
152
|
+
</LineChart>
|
|
153
|
+
));
|
|
154
|
+
flush();
|
|
155
|
+
expect(portalContains(container, 1210, ".recharts-line")).toBe(true);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("Area renders in its default (100) portal and relocates on a custom zIndex", () => {
|
|
159
|
+
const { container: dflt } = render(() => (
|
|
160
|
+
<AreaChart width={300} height={300} data={data}>
|
|
161
|
+
<XAxis dataKey="name" />
|
|
162
|
+
<YAxis />
|
|
163
|
+
<Area dataKey="uv" isAnimationActive={false} />
|
|
164
|
+
</AreaChart>
|
|
165
|
+
));
|
|
166
|
+
flush();
|
|
167
|
+
expect(portalContains(dflt, 100, ".recharts-area")).toBe(true);
|
|
168
|
+
|
|
169
|
+
const { container } = render(() => (
|
|
170
|
+
<AreaChart width={300} height={300} data={data}>
|
|
171
|
+
<XAxis dataKey="name" />
|
|
172
|
+
<YAxis />
|
|
173
|
+
<Area dataKey="uv" zIndex={1211} isAnimationActive={false} />
|
|
174
|
+
</AreaChart>
|
|
175
|
+
));
|
|
176
|
+
flush();
|
|
177
|
+
expect(portalContains(container, 1211, ".recharts-area")).toBe(true);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("Scatter renders in its default (600) portal and relocates on a custom zIndex", () => {
|
|
181
|
+
const { container: dflt } = render(() => (
|
|
182
|
+
<ScatterChart width={300} height={300}>
|
|
183
|
+
<XAxis dataKey="name" />
|
|
184
|
+
<YAxis dataKey="uv" />
|
|
185
|
+
<Scatter data={data} dataKey="uv" isAnimationActive={false} />
|
|
186
|
+
</ScatterChart>
|
|
187
|
+
));
|
|
188
|
+
flush();
|
|
189
|
+
expect(portalContains(dflt, 600, ".recharts-scatter")).toBe(true);
|
|
190
|
+
|
|
191
|
+
const { container } = render(() => (
|
|
192
|
+
<ScatterChart width={300} height={300}>
|
|
193
|
+
<XAxis dataKey="name" />
|
|
194
|
+
<YAxis dataKey="uv" />
|
|
195
|
+
<Scatter data={data} dataKey="uv" zIndex={1212} isAnimationActive={false} />
|
|
196
|
+
</ScatterChart>
|
|
197
|
+
));
|
|
198
|
+
flush();
|
|
199
|
+
expect(portalContains(container, 1212, ".recharts-scatter")).toBe(true);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("Pie renders in its default (100) portal and relocates on a custom zIndex", () => {
|
|
203
|
+
const { container: dflt } = render(() => (
|
|
204
|
+
<PieChart width={300} height={300}>
|
|
205
|
+
<Pie data={data} dataKey="uv" isAnimationActive={false} />
|
|
206
|
+
</PieChart>
|
|
207
|
+
));
|
|
208
|
+
flush();
|
|
209
|
+
expect(portalContains(dflt, 100, ".recharts-pie")).toBe(true);
|
|
210
|
+
|
|
211
|
+
const { container } = render(() => (
|
|
212
|
+
<PieChart width={300} height={300}>
|
|
213
|
+
<Pie data={data} dataKey="uv" zIndex={1213} isAnimationActive={false} />
|
|
214
|
+
</PieChart>
|
|
215
|
+
));
|
|
216
|
+
flush();
|
|
217
|
+
expect(portalContains(container, 1213, ".recharts-pie")).toBe(true);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it("Radar renders in its default (100) portal and relocates on a custom zIndex", () => {
|
|
221
|
+
const { container: dflt } = render(() => (
|
|
222
|
+
<RadarChart width={300} height={300} data={radarData}>
|
|
223
|
+
<Radar dataKey="v" isAnimationActive={false} />
|
|
224
|
+
</RadarChart>
|
|
225
|
+
));
|
|
226
|
+
flush();
|
|
227
|
+
expect(portalContains(dflt, 100, ".recharts-radar")).toBe(true);
|
|
228
|
+
|
|
229
|
+
const { container } = render(() => (
|
|
230
|
+
<RadarChart width={300} height={300} data={radarData}>
|
|
231
|
+
<Radar dataKey="v" zIndex={1214} isAnimationActive={false} />
|
|
232
|
+
</RadarChart>
|
|
233
|
+
));
|
|
234
|
+
flush();
|
|
235
|
+
expect(portalContains(container, 1214, ".recharts-radar")).toBe(true);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it("RadialBar renders in its default (300) portal and relocates on a custom zIndex", () => {
|
|
239
|
+
const { container: dflt } = render(() => (
|
|
240
|
+
<RadialBarChart width={300} height={300} data={data}>
|
|
241
|
+
<RadialBar dataKey="uv" isAnimationActive={false} />
|
|
242
|
+
</RadialBarChart>
|
|
243
|
+
));
|
|
244
|
+
flush();
|
|
245
|
+
expect(portalContains(dflt, 300, ".recharts-radial-bar-sectors")).toBe(true);
|
|
246
|
+
|
|
247
|
+
const { container } = render(() => (
|
|
248
|
+
<RadialBarChart width={300} height={300} data={data}>
|
|
249
|
+
<RadialBar dataKey="uv" zIndex={1215} isAnimationActive={false} />
|
|
250
|
+
</RadialBarChart>
|
|
251
|
+
));
|
|
252
|
+
flush();
|
|
253
|
+
expect(portalContains(container, 1215, ".recharts-radial-bar-sectors")).toBe(true);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { DefaultZIndexes } from "../../src/zIndex/DefaultZIndexes";
|
|
3
|
+
import { getZIndexFromUnknown } from "../../src/zIndex/getZIndexFromUnknown";
|
|
4
|
+
|
|
5
|
+
describe("getZIndexFromUnknown", () => {
|
|
6
|
+
it.each([undefined, null, true, false, "invalid", 42, { fill: "#000" }] as const)(
|
|
7
|
+
"should return default zIndex when input is %p",
|
|
8
|
+
(input) => {
|
|
9
|
+
const randomNumber = Math.floor(Math.random() * 1000);
|
|
10
|
+
const result = getZIndexFromUnknown(input, randomNumber);
|
|
11
|
+
expect(result).toBe(randomNumber);
|
|
12
|
+
},
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
it("should return custom zIndex for object with numeric zIndex", () => {
|
|
16
|
+
const customZIndex = 999;
|
|
17
|
+
const result = getZIndexFromUnknown({ fill: "#000", zIndex: customZIndex }, 100);
|
|
18
|
+
expect(result).toBe(customZIndex);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should return custom zIndex of 0 when explicitly set", () => {
|
|
22
|
+
const randomNumber = Math.floor(Math.random() * 1000);
|
|
23
|
+
const result = getZIndexFromUnknown({ zIndex: randomNumber }, 100);
|
|
24
|
+
expect(result).toBe(randomNumber);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it.each([
|
|
28
|
+
"100",
|
|
29
|
+
null,
|
|
30
|
+
undefined,
|
|
31
|
+
NaN,
|
|
32
|
+
Infinity,
|
|
33
|
+
-Infinity,
|
|
34
|
+
() => {},
|
|
35
|
+
[],
|
|
36
|
+
Symbol.for("100"),
|
|
37
|
+
] as const)("should return default zIndex for input={zIndex: %s}", (zIndex) => {
|
|
38
|
+
const randomNumber = Math.floor(Math.random() * 1000);
|
|
39
|
+
const result = getZIndexFromUnknown({ zIndex }, randomNumber);
|
|
40
|
+
expect(result).toBe(randomNumber);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it.each([0, -0, -100, 5000, 123.456, Math.PI, DefaultZIndexes.barBackground] as const)(
|
|
44
|
+
"should handle edge case zIndex values: %p",
|
|
45
|
+
(zIndex) => {
|
|
46
|
+
const randomNumber = Math.floor(Math.random() * 1000);
|
|
47
|
+
const result = getZIndexFromUnknown({ zIndex }, randomNumber);
|
|
48
|
+
expect(result).toBe(zIndex);
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Solid-recharts spec (no recharts counterpart): regression tests for cross-chart
|
|
2
|
+
// z-index portal isolation. Two bugs once compounded here:
|
|
3
|
+
// 1. zIndexSlice shallow-copied the module-level initial map, so every chart
|
|
4
|
+
// store shared the same ZIndexEntry objects — the last chart to register a
|
|
5
|
+
// portal <g> hijacked every other chart's portal target.
|
|
6
|
+
// 2. ZIndexLayer parented its <Portal> to the component owner without disposing
|
|
7
|
+
// it when the keyed target changed, so content ALSO stayed in the stale
|
|
8
|
+
// target — bar rectangles rendered duplicated inside a sibling pie chart.
|
|
9
|
+
import { describe, expect, it } from "vitest";
|
|
10
|
+
import { createSignal, flush, Show } from "solid-js";
|
|
11
|
+
import { Bar, BarChart, Pie, PieChart } from "../../src";
|
|
12
|
+
import { assertNotNull } from "../helper/assertNotNull";
|
|
13
|
+
import { render } from "@solidjs/testing-library";
|
|
14
|
+
|
|
15
|
+
const barData = [
|
|
16
|
+
{ name: "a", uv: 100 },
|
|
17
|
+
{ name: "b", uv: 200 },
|
|
18
|
+
{ name: "c", uv: 300 },
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const pieData = [
|
|
22
|
+
{ name: "x", value: 40 },
|
|
23
|
+
{ name: "y", value: 30 },
|
|
24
|
+
{ name: "z", value: 30 },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
describe("multi-chart zIndex portal isolation", () => {
|
|
28
|
+
it("keeps bar layers in their own chart when two charts mount together", () => {
|
|
29
|
+
const { container } = render(() => (
|
|
30
|
+
<>
|
|
31
|
+
<BarChart width={300} height={300} data={barData}>
|
|
32
|
+
<Bar dataKey="uv" isAnimationActive={false} />
|
|
33
|
+
</BarChart>
|
|
34
|
+
<PieChart width={300} height={300}>
|
|
35
|
+
<Pie data={pieData} dataKey="value" isAnimationActive={false} />
|
|
36
|
+
</PieChart>
|
|
37
|
+
</>
|
|
38
|
+
));
|
|
39
|
+
flush();
|
|
40
|
+
|
|
41
|
+
const surfaces = container.querySelectorAll("svg.recharts-surface");
|
|
42
|
+
expect(surfaces).toHaveLength(2);
|
|
43
|
+
const [barSvg, pieSvg] = Array.from(surfaces);
|
|
44
|
+
assertNotNull(barSvg);
|
|
45
|
+
assertNotNull(pieSvg);
|
|
46
|
+
|
|
47
|
+
expect(barSvg.querySelectorAll(".recharts-bar")).toHaveLength(1);
|
|
48
|
+
expect(barSvg.querySelectorAll(".recharts-sector")).toHaveLength(0);
|
|
49
|
+
expect(pieSvg.querySelectorAll(".recharts-bar")).toHaveLength(0);
|
|
50
|
+
expect(pieSvg.querySelectorAll(".recharts-sector").length).toBeGreaterThan(0);
|
|
51
|
+
|
|
52
|
+
// No duplicated bar layer anywhere (a stale, undisposed portal would leave
|
|
53
|
+
// a second copy behind).
|
|
54
|
+
expect(document.querySelectorAll(".recharts-bar")).toHaveLength(1);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("keeps bar layers in their own chart when a second chart mounts later", () => {
|
|
58
|
+
const [showPie, setShowPie] = createSignal(false);
|
|
59
|
+
const { container } = render(() => (
|
|
60
|
+
<>
|
|
61
|
+
<BarChart width={300} height={300} data={barData}>
|
|
62
|
+
<Bar dataKey="uv" isAnimationActive={false} />
|
|
63
|
+
</BarChart>
|
|
64
|
+
<Show when={showPie()}>
|
|
65
|
+
<PieChart width={300} height={300}>
|
|
66
|
+
<Pie data={pieData} dataKey="value" isAnimationActive={false} />
|
|
67
|
+
</PieChart>
|
|
68
|
+
</Show>
|
|
69
|
+
</>
|
|
70
|
+
));
|
|
71
|
+
flush();
|
|
72
|
+
expect(container.querySelectorAll("svg.recharts-surface")).toHaveLength(1);
|
|
73
|
+
|
|
74
|
+
// Mounting the pie later used to overwrite the bar chart's registered portal
|
|
75
|
+
// element (shared slice state) and re-portal the bars into the pie's svg.
|
|
76
|
+
setShowPie(true);
|
|
77
|
+
flush();
|
|
78
|
+
|
|
79
|
+
const surfaces = container.querySelectorAll("svg.recharts-surface");
|
|
80
|
+
expect(surfaces).toHaveLength(2);
|
|
81
|
+
const [barSvg, pieSvg] = Array.from(surfaces);
|
|
82
|
+
assertNotNull(barSvg);
|
|
83
|
+
assertNotNull(pieSvg);
|
|
84
|
+
|
|
85
|
+
expect(barSvg.querySelectorAll(".recharts-bar")).toHaveLength(1);
|
|
86
|
+
expect(pieSvg.querySelectorAll(".recharts-bar")).toHaveLength(0);
|
|
87
|
+
expect(pieSvg.querySelectorAll(".recharts-sector").length).toBeGreaterThan(0);
|
|
88
|
+
expect(document.querySelectorAll(".recharts-bar")).toHaveLength(1);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { flush } from "solid-js";
|
|
2
|
+
import { describe, it, expect } from "vitest";
|
|
3
|
+
import { createRechartsStore } from "../../src/state/store";
|
|
4
|
+
import {
|
|
5
|
+
selectZIndexPortalElement,
|
|
6
|
+
selectAllRegisteredZIndexes,
|
|
7
|
+
} from "../../src/zIndex/zIndexSelectors";
|
|
8
|
+
|
|
9
|
+
describe("zIndexSelectors", () => {
|
|
10
|
+
describe("selectZIndexPortalElement", () => {
|
|
11
|
+
it("should select zIndex portal elements correctly", () => {
|
|
12
|
+
const store = createRechartsStore();
|
|
13
|
+
|
|
14
|
+
expect(selectZIndexPortalElement(store.state, 1, false)).toBeUndefined();
|
|
15
|
+
expect(selectZIndexPortalElement(store.state, -1, false)).toBeUndefined();
|
|
16
|
+
|
|
17
|
+
const element1 = document.createElement("div");
|
|
18
|
+
const element2 = document.createElement("div");
|
|
19
|
+
store.actions.zIndex.registerZIndexPortalElement({
|
|
20
|
+
zIndex: 1,
|
|
21
|
+
element: element1,
|
|
22
|
+
isPanorama: false,
|
|
23
|
+
});
|
|
24
|
+
store.actions.zIndex.registerZIndexPortalElement({
|
|
25
|
+
zIndex: -1,
|
|
26
|
+
element: element2,
|
|
27
|
+
isPanorama: false,
|
|
28
|
+
});
|
|
29
|
+
flush();
|
|
30
|
+
|
|
31
|
+
expect(selectZIndexPortalElement(store.state, 1, false)).toBe(element1);
|
|
32
|
+
expect(selectZIndexPortalElement(store.state, -1, false)).toBe(element2);
|
|
33
|
+
|
|
34
|
+
store.actions.zIndex.unregisterZIndexPortalElement({ zIndex: 1, isPanorama: false });
|
|
35
|
+
flush();
|
|
36
|
+
expect(selectZIndexPortalElement(store.state, 1, false)).toBeUndefined();
|
|
37
|
+
expect(selectZIndexPortalElement(store.state, -1, false)).toBe(element2);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("should return undefined for undefined zIndex", () => {
|
|
41
|
+
const store = createRechartsStore();
|
|
42
|
+
expect(selectZIndexPortalElement(store.state, undefined, true)).toBeUndefined();
|
|
43
|
+
expect(selectZIndexPortalElement(store.state, undefined, false)).toBeUndefined();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("should differentiate between panorama and main chart", () => {
|
|
47
|
+
const store = createRechartsStore();
|
|
48
|
+
|
|
49
|
+
const mainElement = document.createElement("div");
|
|
50
|
+
const panoramaElement = document.createElement("div");
|
|
51
|
+
store.actions.zIndex.registerZIndexPortalElement({
|
|
52
|
+
zIndex: 10,
|
|
53
|
+
element: mainElement,
|
|
54
|
+
isPanorama: false,
|
|
55
|
+
});
|
|
56
|
+
store.actions.zIndex.registerZIndexPortalElement({
|
|
57
|
+
zIndex: 10,
|
|
58
|
+
element: panoramaElement,
|
|
59
|
+
isPanorama: true,
|
|
60
|
+
});
|
|
61
|
+
flush();
|
|
62
|
+
|
|
63
|
+
expect(selectZIndexPortalElement(store.state, 10, false)).toBe(mainElement);
|
|
64
|
+
expect(selectZIndexPortalElement(store.state, 10, true)).toBe(panoramaElement);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe("selectAllRegisteredZIndexes", () => {
|
|
69
|
+
it("should select all registered zIndexes correctly", () => {
|
|
70
|
+
const store = createRechartsStore();
|
|
71
|
+
|
|
72
|
+
expect(selectAllRegisteredZIndexes(store.state)).toEqual([
|
|
73
|
+
-100, -50, 100, 200, 300, 400, 500, 600, 1000, 1100, 1200, 2000,
|
|
74
|
+
]);
|
|
75
|
+
|
|
76
|
+
store.actions.zIndex.registerZIndexPortal({ zIndex: 2 });
|
|
77
|
+
store.actions.zIndex.registerZIndexPortal({ zIndex: -3 });
|
|
78
|
+
store.actions.zIndex.registerZIndexPortal({ zIndex: 1 });
|
|
79
|
+
|
|
80
|
+
expect(selectAllRegisteredZIndexes(store.state)).toEqual([
|
|
81
|
+
-100, -50, -3, 1, 2, 100, 200, 300, 400, 500, 600, 1000, 1100, 1200, 2000,
|
|
82
|
+
]);
|
|
83
|
+
|
|
84
|
+
store.actions.zIndex.unregisterZIndexPortal({ zIndex: 1 });
|
|
85
|
+
expect(selectAllRegisteredZIndexes(store.state)).toEqual([
|
|
86
|
+
-100, -50, -3, 2, 100, 200, 300, 400, 500, 600, 1000, 1100, 1200, 2000,
|
|
87
|
+
]);
|
|
88
|
+
|
|
89
|
+
store.actions.zIndex.unregisterZIndexPortal({ zIndex: -3 });
|
|
90
|
+
store.actions.zIndex.unregisterZIndexPortal({ zIndex: 2 });
|
|
91
|
+
expect(selectAllRegisteredZIndexes(store.state)).toEqual([
|
|
92
|
+
-100, -50, 100, 200, 300, 400, 500, 600, 1000, 1100, 1200, 2000,
|
|
93
|
+
]);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("should memoize results based on array contents", () => {
|
|
97
|
+
const store = createRechartsStore();
|
|
98
|
+
|
|
99
|
+
store.actions.zIndex.registerZIndexPortal({ zIndex: 5 });
|
|
100
|
+
store.actions.zIndex.registerZIndexPortal({ zIndex: 10 });
|
|
101
|
+
|
|
102
|
+
const firstSelection = selectAllRegisteredZIndexes(store.state);
|
|
103
|
+
const secondSelection = selectAllRegisteredZIndexes(store.state);
|
|
104
|
+
|
|
105
|
+
expect(firstSelection).toBe(secondSelection);
|
|
106
|
+
|
|
107
|
+
store.actions.zIndex.registerZIndexPortal({ zIndex: 15 });
|
|
108
|
+
|
|
109
|
+
const thirdSelection = selectAllRegisteredZIndexes(store.state);
|
|
110
|
+
expect(thirdSelection).not.toBe(firstSelection);
|
|
111
|
+
expect(thirdSelection).toEqual([
|
|
112
|
+
-100, -50, 5, 10, 15, 100, 200, 300, 400, 500, 600, 1000, 1100, 1200, 2000,
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
const element1 = document.createElement("div");
|
|
116
|
+
const element2 = document.createElement("div");
|
|
117
|
+
store.actions.zIndex.registerZIndexPortalElement({
|
|
118
|
+
zIndex: 5,
|
|
119
|
+
element: element1,
|
|
120
|
+
isPanorama: false,
|
|
121
|
+
});
|
|
122
|
+
store.actions.zIndex.registerZIndexPortalElement({
|
|
123
|
+
zIndex: 5,
|
|
124
|
+
element: element2,
|
|
125
|
+
isPanorama: true,
|
|
126
|
+
});
|
|
127
|
+
const fourthSelection = selectAllRegisteredZIndexes(store.state);
|
|
128
|
+
expect(fourthSelection).toBe(thirdSelection);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("should not duplicate zIndex when registered multiple times", () => {
|
|
132
|
+
const store = createRechartsStore();
|
|
133
|
+
|
|
134
|
+
store.actions.zIndex.registerZIndexPortal({ zIndex: 50 });
|
|
135
|
+
const firstSelection = selectAllRegisteredZIndexes(store.state);
|
|
136
|
+
expect(firstSelection).toEqual([
|
|
137
|
+
-100, -50, 50, 100, 200, 300, 400, 500, 600, 1000, 1100, 1200, 2000,
|
|
138
|
+
]);
|
|
139
|
+
|
|
140
|
+
store.actions.zIndex.registerZIndexPortal({ zIndex: 50 });
|
|
141
|
+
const secondSelection = selectAllRegisteredZIndexes(store.state);
|
|
142
|
+
expect(secondSelection).toEqual([
|
|
143
|
+
-100, -50, 50, 100, 200, 300, 400, 500, 600, 1000, 1100, 1200, 2000,
|
|
144
|
+
]);
|
|
145
|
+
expect(secondSelection).toBe(firstSelection);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("should not affect zIndex list when only registering/unregistering portal element", () => {
|
|
149
|
+
const store = createRechartsStore();
|
|
150
|
+
|
|
151
|
+
const initialSelection = selectAllRegisteredZIndexes(store.state);
|
|
152
|
+
expect(initialSelection).toEqual([
|
|
153
|
+
-100, -50, 100, 200, 300, 400, 500, 600, 1000, 1100, 1200, 2000,
|
|
154
|
+
]);
|
|
155
|
+
|
|
156
|
+
const element = document.createElement("div");
|
|
157
|
+
store.actions.zIndex.registerZIndexPortalElement({ zIndex: 100, element, isPanorama: false });
|
|
158
|
+
const afterRegister = selectAllRegisteredZIndexes(store.state);
|
|
159
|
+
expect(afterRegister).toEqual([
|
|
160
|
+
-100, -50, 100, 200, 300, 400, 500, 600, 1000, 1100, 1200, 2000,
|
|
161
|
+
]);
|
|
162
|
+
expect(afterRegister).toBe(initialSelection);
|
|
163
|
+
|
|
164
|
+
store.actions.zIndex.unregisterZIndexPortalElement({ zIndex: 100, isPanorama: false });
|
|
165
|
+
const afterUnregister = selectAllRegisteredZIndexes(store.state);
|
|
166
|
+
expect(afterUnregister).toEqual([
|
|
167
|
+
-100, -50, 100, 200, 300, 400, 500, 600, 1000, 1100, 1200, 2000,
|
|
168
|
+
]);
|
|
169
|
+
expect(afterUnregister).toBe(initialSelection);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// recharts specs rely on vitest globals (we run with `globals: true`) and a
|
|
5
|
+
// few sources read `process.env`; match the reference tsconfig's ambient
|
|
6
|
+
// types. Scoped to this package so app/dev and the testing-library package
|
|
7
|
+
// keep the lean base `types`.
|
|
8
|
+
"types": ["@testing-library/jest-dom", "node", "vitest/globals"]
|
|
9
|
+
},
|
|
10
|
+
"include": ["src", "test"]
|
|
11
|
+
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { createEffect, createRoot, on, onCleanup } from "solid-js";
|
|
2
|
-
import type { JSX } from "solid-js";
|
|
3
|
-
import { insert, isServer } from "solid-js/web";
|
|
4
|
-
|
|
5
|
-
export interface DirectPortalProps {
|
|
6
|
-
mount: Element;
|
|
7
|
-
children: JSX.Element;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface PortalRange {
|
|
11
|
-
placeholder: Text;
|
|
12
|
-
start: Comment;
|
|
13
|
-
end: Comment;
|
|
14
|
-
sequence: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const rangesByMount = new WeakMap<Element, PortalRange[]>();
|
|
18
|
-
let nextSequence = 0;
|
|
19
|
-
|
|
20
|
-
function reorderRanges(mount: Element, ranges: PortalRange[]): void {
|
|
21
|
-
ranges.sort((left, right) => {
|
|
22
|
-
const position = left.placeholder.compareDocumentPosition(right.placeholder);
|
|
23
|
-
if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
|
|
24
|
-
return -1;
|
|
25
|
-
}
|
|
26
|
-
if (position & Node.DOCUMENT_POSITION_PRECEDING) {
|
|
27
|
-
return 1;
|
|
28
|
-
}
|
|
29
|
-
return left.sequence - right.sequence;
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const fragment = document.createDocumentFragment();
|
|
33
|
-
ranges.forEach((range) => {
|
|
34
|
-
let node: Node | null = range.start;
|
|
35
|
-
while (node != null) {
|
|
36
|
-
const next: Node | null = node.nextSibling;
|
|
37
|
-
fragment.append(node);
|
|
38
|
-
if (node === range.end) {
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
node = next;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
mount.append(fragment);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Portal content directly into a target without Solid 1's wrapper div/g.
|
|
49
|
-
*
|
|
50
|
-
* Recharts exposes the portal DOM shape, so the wrapper added by Solid 1's
|
|
51
|
-
* built-in Portal would break direct-child selectors and SVG parity.
|
|
52
|
-
*/
|
|
53
|
-
export function DirectPortal(props: DirectPortalProps): JSX.Element {
|
|
54
|
-
if (isServer) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const placeholder = document.createTextNode("");
|
|
59
|
-
|
|
60
|
-
createEffect(
|
|
61
|
-
on(
|
|
62
|
-
() => props.mount,
|
|
63
|
-
(mount) => {
|
|
64
|
-
const start = document.createComment("solid-recharts-portal-start");
|
|
65
|
-
const end = document.createComment("solid-recharts-portal-end");
|
|
66
|
-
mount.append(start, end);
|
|
67
|
-
|
|
68
|
-
const dispose = createRoot((disposeRoot) => {
|
|
69
|
-
insert(mount, () => props.children, end);
|
|
70
|
-
return disposeRoot;
|
|
71
|
-
});
|
|
72
|
-
const range: PortalRange = {
|
|
73
|
-
placeholder,
|
|
74
|
-
start,
|
|
75
|
-
end,
|
|
76
|
-
sequence: nextSequence,
|
|
77
|
-
};
|
|
78
|
-
nextSequence += 1;
|
|
79
|
-
const ranges = rangesByMount.get(mount) ?? [];
|
|
80
|
-
ranges.push(range);
|
|
81
|
-
rangesByMount.set(mount, ranges);
|
|
82
|
-
reorderRanges(mount, ranges);
|
|
83
|
-
|
|
84
|
-
onCleanup(() => {
|
|
85
|
-
dispose();
|
|
86
|
-
let node: ChildNode | null = start.nextSibling;
|
|
87
|
-
while (node != null && node !== end) {
|
|
88
|
-
const next: ChildNode | null = node.nextSibling;
|
|
89
|
-
node.remove();
|
|
90
|
-
node = next;
|
|
91
|
-
}
|
|
92
|
-
start.remove();
|
|
93
|
-
end.remove();
|
|
94
|
-
const index = ranges.indexOf(range);
|
|
95
|
-
if (index >= 0) {
|
|
96
|
-
ranges.splice(index, 1);
|
|
97
|
-
}
|
|
98
|
-
if (ranges.length === 0) {
|
|
99
|
-
rangesByMount.delete(mount);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
},
|
|
103
|
-
),
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
return placeholder;
|
|
107
|
-
}
|