@mui/x-charts 8.0.0-beta.2 → 8.0.0-beta.3
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/BarChart/AnimatedBarElement.d.ts +38 -8
- package/BarChart/AnimatedBarElement.js +5 -5
- package/BarChart/BarChart.js +2 -0
- package/BarChart/BarClipPath.d.ts +19 -1
- package/BarChart/BarClipPath.js +84 -17
- package/BarChart/BarElement.d.ts +9 -20
- package/BarChart/BarElement.js +29 -26
- package/BarChart/BarLabel/BarLabel.d.ts +27 -854
- package/BarChart/BarLabel/BarLabel.js +32 -5
- package/BarChart/BarLabel/BarLabel.types.d.ts +2 -0
- package/BarChart/BarLabel/BarLabelItem.d.ts +24 -0
- package/BarChart/BarLabel/BarLabelItem.js +18 -6
- package/BarChart/BarLabel/BarLabelPlot.js +16 -46
- package/BarChart/BarLabel/barLabelClasses.d.ts +3 -1
- package/BarChart/BarLabel/barLabelClasses.js +4 -3
- package/BarChart/BarPlot.js +37 -61
- package/BarChart/barElementClasses.d.ts +21 -0
- package/BarChart/barElementClasses.js +29 -0
- package/BarChart/getRadius.d.ts +1 -1
- package/BarChart/index.d.ts +2 -1
- package/BarChart/index.js +11 -0
- package/BarChart/seriesConfig/index.js +3 -1
- package/BarChart/seriesConfig/tooltip.d.ts +2 -1
- package/BarChart/seriesConfig/tooltip.js +14 -1
- package/BarChart/types.d.ts +2 -2
- package/CHANGELOG.md +141 -0
- package/ChartContainer/ChartContainer.js +4 -0
- package/ChartsLabel/ChartsLabelMark.js +0 -4
- package/ChartsLabel/index.d.ts +1 -0
- package/ChartsLabel/index.js +7 -0
- package/ChartsLegend/continuousColorLegendClasses.d.ts +1 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +47 -55
- package/ChartsTooltip/ChartsItemTooltipContent.js +11 -9
- package/ChartsTooltip/ChartsTooltip.js +2 -2
- package/ChartsTooltip/ChartsTooltipContainer.js +3 -8
- package/ChartsTooltip/ChartsTooltipTable.d.ts +3 -1
- package/ChartsTooltip/ChartsTooltipTable.js +24 -9
- package/ChartsTooltip/chartsTooltipClasses.d.ts +4 -4
- package/ChartsTooltip/chartsTooltipClasses.js +2 -2
- package/ChartsTooltip/index.d.ts +1 -0
- package/ChartsTooltip/index.js +12 -0
- package/ChartsTooltip/useAxesTooltip.d.ts +7 -0
- package/ChartsTooltip/useAxesTooltip.js +18 -0
- package/ChartsTooltip/useAxisTooltip.d.ts +24 -3
- package/ChartsTooltip/useAxisTooltip.js +71 -37
- package/ChartsTooltip/useItemTooltip.js +4 -1
- package/ChartsXAxis/ChartsXAxis.js +5 -2
- package/ChartsYAxis/ChartsYAxis.js +69 -17
- package/LineChart/AnimatedArea.js +5 -22
- package/LineChart/AnimatedLine.d.ts +1 -4
- package/LineChart/AnimatedLine.js +10 -25
- package/LineChart/AppearingMask.d.ts +5 -0
- package/LineChart/AppearingMask.js +25 -18
- package/LineChart/CircleMarkElement.js +16 -22
- package/LineChart/LineChart.js +2 -0
- package/LineChart/LineHighlightPlot.js +2 -3
- package/LineChart/MarkElement.js +16 -27
- package/LineChart/MarkPlot.js +0 -1
- package/LineChart/markElementClasses.d.ts +3 -0
- package/LineChart/markElementClasses.js +4 -3
- package/LineChart/seriesConfig/index.js +3 -1
- package/LineChart/seriesConfig/tooltip.d.ts +2 -1
- package/LineChart/seriesConfig/tooltip.js +8 -1
- package/PieChart/PieArc.d.ts +19 -11
- package/PieChart/PieArc.js +37 -24
- package/PieChart/PieArcLabel.d.ts +22 -13
- package/PieChart/PieArcLabel.js +52 -48
- package/PieChart/PieArcLabelPlot.js +16 -34
- package/PieChart/PieArcPlot.js +21 -34
- package/PieChart/seriesConfig/tooltip.js +3 -0
- package/ScatterChart/ScatterChart.js +2 -0
- package/SparkLineChart/SparkLineChart.js +2 -0
- package/colorPalettes/colorPalettes.js +2 -2
- package/constants/index.d.ts +1 -1
- package/constants/index.js +1 -1
- package/context/AnimationProvider/AnimationProvider.js +4 -6
- package/esm/BarChart/AnimatedBarElement.d.ts +38 -8
- package/esm/BarChart/AnimatedBarElement.js +5 -5
- package/esm/BarChart/BarChart.js +2 -0
- package/esm/BarChart/BarClipPath.d.ts +19 -1
- package/esm/BarChart/BarClipPath.js +84 -17
- package/esm/BarChart/BarElement.d.ts +9 -20
- package/esm/BarChart/BarElement.js +28 -23
- package/esm/BarChart/BarLabel/BarLabel.d.ts +27 -854
- package/esm/BarChart/BarLabel/BarLabel.js +32 -5
- package/esm/BarChart/BarLabel/BarLabel.types.d.ts +2 -0
- package/esm/BarChart/BarLabel/BarLabelItem.d.ts +24 -0
- package/esm/BarChart/BarLabel/BarLabelItem.js +18 -6
- package/esm/BarChart/BarLabel/BarLabelPlot.js +16 -46
- package/esm/BarChart/BarLabel/barLabelClasses.d.ts +3 -1
- package/esm/BarChart/BarLabel/barLabelClasses.js +4 -3
- package/esm/BarChart/BarPlot.js +37 -61
- package/esm/BarChart/barElementClasses.d.ts +21 -0
- package/esm/BarChart/barElementClasses.js +19 -0
- package/esm/BarChart/getRadius.d.ts +1 -1
- package/esm/BarChart/index.d.ts +2 -1
- package/esm/BarChart/index.js +2 -1
- package/esm/BarChart/seriesConfig/index.js +2 -1
- package/esm/BarChart/seriesConfig/tooltip.d.ts +2 -1
- package/esm/BarChart/seriesConfig/tooltip.js +12 -0
- package/esm/BarChart/types.d.ts +2 -2
- package/esm/ChartContainer/ChartContainer.js +4 -0
- package/esm/ChartsLabel/ChartsLabelMark.js +0 -4
- package/esm/ChartsLabel/index.d.ts +1 -0
- package/esm/ChartsLabel/index.js +1 -0
- package/esm/ChartsLegend/continuousColorLegendClasses.d.ts +1 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +47 -55
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +11 -9
- package/esm/ChartsTooltip/ChartsTooltip.js +2 -2
- package/esm/ChartsTooltip/ChartsTooltipContainer.js +4 -9
- package/esm/ChartsTooltip/ChartsTooltipTable.d.ts +3 -1
- package/esm/ChartsTooltip/ChartsTooltipTable.js +23 -9
- package/esm/ChartsTooltip/chartsTooltipClasses.d.ts +4 -4
- package/esm/ChartsTooltip/chartsTooltipClasses.js +2 -2
- package/esm/ChartsTooltip/index.d.ts +1 -0
- package/esm/ChartsTooltip/index.js +1 -0
- package/esm/ChartsTooltip/useAxesTooltip.d.ts +7 -0
- package/esm/ChartsTooltip/useAxesTooltip.js +12 -0
- package/esm/ChartsTooltip/useAxisTooltip.d.ts +24 -3
- package/esm/ChartsTooltip/useAxisTooltip.js +72 -38
- package/esm/ChartsTooltip/useItemTooltip.js +4 -1
- package/esm/ChartsXAxis/ChartsXAxis.js +5 -2
- package/esm/ChartsYAxis/ChartsYAxis.js +69 -17
- package/esm/LineChart/AnimatedArea.js +5 -22
- package/esm/LineChart/AnimatedLine.d.ts +1 -4
- package/esm/LineChart/AnimatedLine.js +9 -24
- package/esm/LineChart/AppearingMask.d.ts +5 -0
- package/esm/LineChart/AppearingMask.js +23 -18
- package/esm/LineChart/CircleMarkElement.js +19 -25
- package/esm/LineChart/LineChart.js +2 -0
- package/esm/LineChart/LineHighlightPlot.js +3 -4
- package/esm/LineChart/MarkElement.js +17 -28
- package/esm/LineChart/MarkPlot.js +0 -1
- package/esm/LineChart/markElementClasses.d.ts +3 -0
- package/esm/LineChart/markElementClasses.js +4 -3
- package/esm/LineChart/seriesConfig/index.js +2 -1
- package/esm/LineChart/seriesConfig/tooltip.d.ts +2 -1
- package/esm/LineChart/seriesConfig/tooltip.js +6 -0
- package/esm/PieChart/PieArc.d.ts +19 -11
- package/esm/PieChart/PieArc.js +36 -23
- package/esm/PieChart/PieArcLabel.d.ts +22 -13
- package/esm/PieChart/PieArcLabel.js +51 -47
- package/esm/PieChart/PieArcLabelPlot.js +16 -34
- package/esm/PieChart/PieArcPlot.js +21 -34
- package/esm/PieChart/seriesConfig/tooltip.js +3 -0
- package/esm/ScatterChart/ScatterChart.js +2 -0
- package/esm/SparkLineChart/SparkLineChart.js +2 -0
- package/esm/colorPalettes/colorPalettes.js +2 -2
- package/esm/constants/index.d.ts +1 -1
- package/esm/constants/index.js +1 -1
- package/esm/context/AnimationProvider/AnimationProvider.js +3 -6
- package/esm/hooks/animation/index.d.ts +6 -0
- package/esm/hooks/animation/index.js +6 -0
- package/esm/hooks/animation/useAnimateArea.d.ts +15 -0
- package/esm/hooks/animation/useAnimateArea.js +27 -0
- package/esm/hooks/animation/useAnimateBar.d.ts +17 -0
- package/esm/hooks/animation/useAnimateBar.js +56 -0
- package/esm/hooks/animation/useAnimateBarLabel.d.ts +19 -0
- package/esm/hooks/animation/useAnimateBarLabel.js +59 -0
- package/esm/hooks/animation/useAnimateLine.d.ts +14 -0
- package/esm/hooks/animation/useAnimateLine.js +26 -0
- package/esm/hooks/animation/useAnimatePieArc.d.ts +15 -0
- package/esm/hooks/animation/useAnimatePieArc.js +70 -0
- package/esm/hooks/animation/useAnimatePieArcLabel.d.ts +15 -0
- package/esm/hooks/animation/useAnimatePieArcLabel.js +72 -0
- package/esm/hooks/index.d.ts +2 -1
- package/esm/hooks/index.js +2 -1
- package/esm/hooks/useInteractionItemProps.js +11 -0
- package/esm/index.js +1 -1
- package/esm/internals/animation/Transition.d.ts +37 -0
- package/esm/internals/animation/Transition.js +83 -0
- package/esm/internals/animation/animation.d.ts +4 -0
- package/esm/internals/animation/animation.js +4 -0
- package/esm/internals/animation/useAnimate.d.ts +19 -0
- package/esm/internals/animation/useAnimate.js +74 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +9 -3
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.d.ts +5 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.js +21 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +8 -32
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +9 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +60 -26
- package/esm/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +3 -1
- package/esm/internals/plugins/models/seriesConfig/tooltipGetter.types.d.ts +10 -4
- package/esm/internals/shallowEqual.d.ts +8 -0
- package/esm/internals/shallowEqual.js +31 -0
- package/esm/models/axis.d.ts +8 -0
- package/esm/themeAugmentation/overrides.d.ts +1 -1
- package/hooks/animation/index.d.ts +6 -0
- package/hooks/animation/index.js +71 -0
- package/hooks/animation/useAnimateArea.d.ts +15 -0
- package/hooks/animation/useAnimateArea.js +34 -0
- package/hooks/animation/useAnimateBar.d.ts +17 -0
- package/hooks/animation/useAnimateBar.js +62 -0
- package/hooks/animation/useAnimateBarLabel.d.ts +19 -0
- package/hooks/animation/useAnimateBarLabel.js +65 -0
- package/hooks/animation/useAnimateLine.d.ts +14 -0
- package/hooks/animation/useAnimateLine.js +33 -0
- package/hooks/animation/useAnimatePieArc.d.ts +15 -0
- package/hooks/animation/useAnimatePieArc.js +77 -0
- package/hooks/animation/useAnimatePieArcLabel.d.ts +15 -0
- package/hooks/animation/useAnimatePieArcLabel.js +79 -0
- package/hooks/index.d.ts +2 -1
- package/hooks/index.js +13 -1
- package/hooks/useInteractionItemProps.js +11 -0
- package/index.js +1 -1
- package/internals/animation/Transition.d.ts +37 -0
- package/internals/animation/Transition.js +89 -0
- package/internals/animation/animation.d.ts +4 -0
- package/internals/animation/animation.js +11 -0
- package/internals/animation/useAnimate.d.ts +19 -0
- package/internals/animation/useAnimate.js +80 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +9 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.d.ts +5 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.js +28 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +8 -32
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +9 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +61 -27
- package/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +3 -1
- package/internals/plugins/models/seriesConfig/tooltipGetter.types.d.ts +10 -4
- package/internals/shallowEqual.d.ts +8 -0
- package/internals/shallowEqual.js +37 -0
- package/models/axis.d.ts +8 -0
- package/modern/BarChart/AnimatedBarElement.d.ts +38 -8
- package/modern/BarChart/AnimatedBarElement.js +5 -5
- package/modern/BarChart/BarChart.js +2 -0
- package/modern/BarChart/BarClipPath.d.ts +19 -1
- package/modern/BarChart/BarClipPath.js +84 -17
- package/modern/BarChart/BarElement.d.ts +9 -20
- package/modern/BarChart/BarElement.js +28 -23
- package/modern/BarChart/BarLabel/BarLabel.d.ts +27 -854
- package/modern/BarChart/BarLabel/BarLabel.js +32 -5
- package/modern/BarChart/BarLabel/BarLabel.types.d.ts +2 -0
- package/modern/BarChart/BarLabel/BarLabelItem.d.ts +24 -0
- package/modern/BarChart/BarLabel/BarLabelItem.js +18 -6
- package/modern/BarChart/BarLabel/BarLabelPlot.js +16 -46
- package/modern/BarChart/BarLabel/barLabelClasses.d.ts +3 -1
- package/modern/BarChart/BarLabel/barLabelClasses.js +4 -3
- package/modern/BarChart/BarPlot.js +37 -61
- package/modern/BarChart/barElementClasses.d.ts +21 -0
- package/modern/BarChart/barElementClasses.js +19 -0
- package/modern/BarChart/getRadius.d.ts +1 -1
- package/modern/BarChart/index.d.ts +2 -1
- package/modern/BarChart/index.js +2 -1
- package/modern/BarChart/seriesConfig/index.js +2 -1
- package/modern/BarChart/seriesConfig/tooltip.d.ts +2 -1
- package/modern/BarChart/seriesConfig/tooltip.js +12 -0
- package/modern/BarChart/types.d.ts +2 -2
- package/modern/ChartContainer/ChartContainer.js +4 -0
- package/modern/ChartsLabel/ChartsLabelMark.js +0 -4
- package/modern/ChartsLabel/index.d.ts +1 -0
- package/modern/ChartsLabel/index.js +1 -0
- package/modern/ChartsLegend/continuousColorLegendClasses.d.ts +1 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +47 -55
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +11 -9
- package/modern/ChartsTooltip/ChartsTooltip.js +2 -2
- package/modern/ChartsTooltip/ChartsTooltipContainer.js +4 -9
- package/modern/ChartsTooltip/ChartsTooltipTable.d.ts +3 -1
- package/modern/ChartsTooltip/ChartsTooltipTable.js +23 -9
- package/modern/ChartsTooltip/chartsTooltipClasses.d.ts +4 -4
- package/modern/ChartsTooltip/chartsTooltipClasses.js +2 -2
- package/modern/ChartsTooltip/index.d.ts +1 -0
- package/modern/ChartsTooltip/index.js +1 -0
- package/modern/ChartsTooltip/useAxesTooltip.d.ts +7 -0
- package/modern/ChartsTooltip/useAxesTooltip.js +12 -0
- package/modern/ChartsTooltip/useAxisTooltip.d.ts +24 -3
- package/modern/ChartsTooltip/useAxisTooltip.js +72 -38
- package/modern/ChartsTooltip/useItemTooltip.js +4 -1
- package/modern/ChartsXAxis/ChartsXAxis.js +5 -2
- package/modern/ChartsYAxis/ChartsYAxis.js +69 -17
- package/modern/LineChart/AnimatedArea.js +5 -22
- package/modern/LineChart/AnimatedLine.d.ts +1 -4
- package/modern/LineChart/AnimatedLine.js +9 -24
- package/modern/LineChart/AppearingMask.d.ts +5 -0
- package/modern/LineChart/AppearingMask.js +23 -18
- package/modern/LineChart/CircleMarkElement.js +19 -25
- package/modern/LineChart/LineChart.js +2 -0
- package/modern/LineChart/LineHighlightPlot.js +3 -4
- package/modern/LineChart/MarkElement.js +17 -28
- package/modern/LineChart/MarkPlot.js +0 -1
- package/modern/LineChart/markElementClasses.d.ts +3 -0
- package/modern/LineChart/markElementClasses.js +4 -3
- package/modern/LineChart/seriesConfig/index.js +2 -1
- package/modern/LineChart/seriesConfig/tooltip.d.ts +2 -1
- package/modern/LineChart/seriesConfig/tooltip.js +6 -0
- package/modern/PieChart/PieArc.d.ts +19 -11
- package/modern/PieChart/PieArc.js +36 -23
- package/modern/PieChart/PieArcLabel.d.ts +22 -13
- package/modern/PieChart/PieArcLabel.js +51 -47
- package/modern/PieChart/PieArcLabelPlot.js +16 -34
- package/modern/PieChart/PieArcPlot.js +21 -34
- package/modern/PieChart/seriesConfig/tooltip.js +3 -0
- package/modern/ScatterChart/ScatterChart.js +2 -0
- package/modern/SparkLineChart/SparkLineChart.js +2 -0
- package/modern/colorPalettes/colorPalettes.js +2 -2
- package/modern/constants/index.d.ts +1 -1
- package/modern/constants/index.js +1 -1
- package/modern/context/AnimationProvider/AnimationProvider.js +3 -6
- package/modern/hooks/animation/index.d.ts +6 -0
- package/modern/hooks/animation/index.js +6 -0
- package/modern/hooks/animation/useAnimateArea.d.ts +15 -0
- package/modern/hooks/animation/useAnimateArea.js +27 -0
- package/modern/hooks/animation/useAnimateBar.d.ts +17 -0
- package/modern/hooks/animation/useAnimateBar.js +56 -0
- package/modern/hooks/animation/useAnimateBarLabel.d.ts +19 -0
- package/modern/hooks/animation/useAnimateBarLabel.js +59 -0
- package/modern/hooks/animation/useAnimateLine.d.ts +14 -0
- package/modern/hooks/animation/useAnimateLine.js +26 -0
- package/modern/hooks/animation/useAnimatePieArc.d.ts +15 -0
- package/modern/hooks/animation/useAnimatePieArc.js +70 -0
- package/modern/hooks/animation/useAnimatePieArcLabel.d.ts +15 -0
- package/modern/hooks/animation/useAnimatePieArcLabel.js +72 -0
- package/modern/hooks/index.d.ts +2 -1
- package/modern/hooks/index.js +2 -1
- package/modern/hooks/useInteractionItemProps.js +11 -0
- package/modern/index.js +1 -1
- package/modern/internals/animation/Transition.d.ts +37 -0
- package/modern/internals/animation/Transition.js +83 -0
- package/modern/internals/animation/animation.d.ts +4 -0
- package/modern/internals/animation/animation.js +4 -0
- package/modern/internals/animation/useAnimate.d.ts +19 -0
- package/modern/internals/animation/useAnimate.js +74 -0
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +1 -1
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +9 -3
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.d.ts +5 -0
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.js +21 -0
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +8 -32
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +9 -1
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +60 -26
- package/modern/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +3 -1
- package/modern/internals/plugins/models/seriesConfig/tooltipGetter.types.d.ts +10 -4
- package/modern/internals/shallowEqual.d.ts +8 -0
- package/modern/internals/shallowEqual.js +31 -0
- package/modern/models/axis.d.ts +8 -0
- package/modern/themeAugmentation/overrides.d.ts +1 -1
- package/package.json +8 -9
- package/themeAugmentation/overrides.d.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/PieChart/dataTransform/transition.d.ts +0 -4
- package/PieChart/dataTransform/transition.js +0 -145
- package/esm/PieChart/dataTransform/transition.d.ts +0 -4
- package/esm/PieChart/dataTransform/transition.js +0 -137
- package/modern/PieChart/dataTransform/transition.d.ts +0 -4
- package/modern/PieChart/dataTransform/transition.js +0 -137
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { Globals, useIsomorphicLayoutEffect } from '@react-spring/web';
|
|
4
3
|
import * as React from 'react';
|
|
4
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
5
5
|
import { AnimationContext } from "./AnimationContext.js";
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
function AnimationProvider(props) {
|
|
@@ -18,7 +18,7 @@ function AnimationProvider(props) {
|
|
|
18
18
|
// We use the value of `isAnimationDisabledEnvironment` as the initial value of `skipAnimation` to avoid
|
|
19
19
|
// re-rendering the component on environments where matchMedia is not supported, hence skipAnimation will always be true.
|
|
20
20
|
const [skipAnimation, setSkipAnimation] = React.useState(process.env.NODE_ENV === 'test' ? isAnimationDisabledEnvironment || undefined : undefined);
|
|
21
|
-
|
|
21
|
+
useEnhancedEffect(() => {
|
|
22
22
|
if (isAnimationDisabledEnvironment) {
|
|
23
23
|
return undefined;
|
|
24
24
|
}
|
|
@@ -26,9 +26,6 @@ function AnimationProvider(props) {
|
|
|
26
26
|
// This hook can remove animation but never activate it.
|
|
27
27
|
const inputValue = event.matches || undefined;
|
|
28
28
|
setSkipAnimation(inputValue);
|
|
29
|
-
Globals.assign({
|
|
30
|
-
skipAnimation: inputValue
|
|
31
|
-
});
|
|
32
29
|
};
|
|
33
30
|
const mql = window.matchMedia('(prefers-reduced-motion)');
|
|
34
31
|
handleMediaChange(mql);
|
|
@@ -38,7 +35,7 @@ function AnimationProvider(props) {
|
|
|
38
35
|
return () => {
|
|
39
36
|
mql?.removeEventListener?.('change', handleMediaChange);
|
|
40
37
|
};
|
|
41
|
-
}, []);
|
|
38
|
+
}, [isAnimationDisabledEnvironment]);
|
|
42
39
|
const value = React.useMemo(() => ({
|
|
43
40
|
isInitialized: true,
|
|
44
41
|
data: {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { AnimatedAreaProps } from '../../LineChart';
|
|
3
|
+
type UseAnimateAreaParams = Pick<AnimatedAreaProps, 'd' | 'skipAnimation'> & {
|
|
4
|
+
ref?: React.Ref<SVGPathElement>;
|
|
5
|
+
};
|
|
6
|
+
type UseAnimatedAreaReturn = {
|
|
7
|
+
ref: React.Ref<SVGPathElement>;
|
|
8
|
+
d: string;
|
|
9
|
+
};
|
|
10
|
+
/** Animates an area of a line chart using a `path` element.
|
|
11
|
+
* The props object also accepts a `ref` which will be merged with the ref returned from this hook. This means you can
|
|
12
|
+
* pass the ref returned by this hook to the `path` element and the `ref` provided as argument will also be called.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useAnimateArea(props: UseAnimateAreaParams): UseAnimatedAreaReturn;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { interpolateString } from '@mui/x-charts-vendor/d3-interpolate';
|
|
2
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
3
|
+
import { useAnimate } from "../../internals/animation/useAnimate.js";
|
|
4
|
+
/** Animates an area of a line chart using a `path` element.
|
|
5
|
+
* The props object also accepts a `ref` which will be merged with the ref returned from this hook. This means you can
|
|
6
|
+
* pass the ref returned by this hook to the `path` element and the `ref` provided as argument will also be called.
|
|
7
|
+
*/
|
|
8
|
+
export function useAnimateArea(props) {
|
|
9
|
+
const ref = useAnimate({
|
|
10
|
+
d: props.d
|
|
11
|
+
}, {
|
|
12
|
+
createInterpolator: (lastProps, newProps) => {
|
|
13
|
+
const interpolate = interpolateString(lastProps.d, newProps.d);
|
|
14
|
+
return t => ({
|
|
15
|
+
d: interpolate(t)
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
applyProps: (element, {
|
|
19
|
+
d
|
|
20
|
+
}) => element.setAttribute('d', d),
|
|
21
|
+
skip: props.skipAnimation
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
ref: useForkRef(ref, props.ref),
|
|
25
|
+
d: props.d
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { BarProps } from '../../BarChart/AnimatedBarElement';
|
|
3
|
+
type UseAnimateBarParams = Pick<BarProps, 'x' | 'y' | 'xOrigin' | 'yOrigin' | 'width' | 'height' | 'skipAnimation' | 'layout'> & {
|
|
4
|
+
ref?: React.Ref<SVGRectElement>;
|
|
5
|
+
};
|
|
6
|
+
type UseAnimateBarReturnValue = {
|
|
7
|
+
ref: React.Ref<SVGRectElement>;
|
|
8
|
+
} & Pick<BarProps, 'x' | 'y' | 'width' | 'height'>;
|
|
9
|
+
/**
|
|
10
|
+
* Animates a bar from the start of the axis (x-axis for vertical layout, y-axis for horizontal layout) to its
|
|
11
|
+
* final position.
|
|
12
|
+
*
|
|
13
|
+
* The props object also accepts a `ref` which will be merged with the ref returned from this hook. This means you can
|
|
14
|
+
* pass the ref returned by this hook to the `path` element and the `ref` provided as argument will also be called.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useAnimateBar(props: UseAnimateBarParams): UseAnimateBarReturnValue;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { interpolateNumber } from '@mui/x-charts-vendor/d3-interpolate';
|
|
2
|
+
import { useAnimate } from "../../internals/animation/useAnimate.js";
|
|
3
|
+
function barPropsInterpolator(from, to) {
|
|
4
|
+
const interpolateX = interpolateNumber(from.x, to.x);
|
|
5
|
+
const interpolateY = interpolateNumber(from.y, to.y);
|
|
6
|
+
const interpolateWidth = interpolateNumber(from.width, to.width);
|
|
7
|
+
const interpolateHeight = interpolateNumber(from.height, to.height);
|
|
8
|
+
return t => {
|
|
9
|
+
return {
|
|
10
|
+
x: interpolateX(t),
|
|
11
|
+
y: interpolateY(t),
|
|
12
|
+
width: interpolateWidth(t),
|
|
13
|
+
height: interpolateHeight(t)
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Animates a bar from the start of the axis (x-axis for vertical layout, y-axis for horizontal layout) to its
|
|
20
|
+
* final position.
|
|
21
|
+
*
|
|
22
|
+
* The props object also accepts a `ref` which will be merged with the ref returned from this hook. This means you can
|
|
23
|
+
* pass the ref returned by this hook to the `path` element and the `ref` provided as argument will also be called.
|
|
24
|
+
*/
|
|
25
|
+
export function useAnimateBar(props) {
|
|
26
|
+
const initialProps = {
|
|
27
|
+
x: props.layout === 'vertical' ? props.x : props.xOrigin,
|
|
28
|
+
y: props.layout === 'vertical' ? props.yOrigin : props.y,
|
|
29
|
+
width: props.layout === 'vertical' ? props.width : 0,
|
|
30
|
+
height: props.layout === 'vertical' ? 0 : props.height
|
|
31
|
+
};
|
|
32
|
+
const ref = useAnimate({
|
|
33
|
+
x: props.x,
|
|
34
|
+
y: props.y,
|
|
35
|
+
width: props.width,
|
|
36
|
+
height: props.height
|
|
37
|
+
}, {
|
|
38
|
+
createInterpolator: barPropsInterpolator,
|
|
39
|
+
applyProps(element, animatedProps) {
|
|
40
|
+
element.setAttribute('x', animatedProps.x.toString());
|
|
41
|
+
element.setAttribute('y', animatedProps.y.toString());
|
|
42
|
+
element.setAttribute('width', animatedProps.width.toString());
|
|
43
|
+
element.setAttribute('height', animatedProps.height.toString());
|
|
44
|
+
},
|
|
45
|
+
initialProps,
|
|
46
|
+
skip: props.skipAnimation
|
|
47
|
+
});
|
|
48
|
+
const usedProps = props.skipAnimation ? props : initialProps;
|
|
49
|
+
return {
|
|
50
|
+
ref,
|
|
51
|
+
x: usedProps.x,
|
|
52
|
+
y: usedProps.y,
|
|
53
|
+
width: usedProps.width,
|
|
54
|
+
height: usedProps.height
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { BarLabelProps } from '../../BarChart';
|
|
3
|
+
type UseAnimateBarLabelParams = Pick<BarLabelProps, 'xOrigin' | 'yOrigin' | 'x' | 'y' | 'width' | 'height' | 'layout' | 'skipAnimation'> & {
|
|
4
|
+
ref?: React.Ref<SVGTextElement>;
|
|
5
|
+
};
|
|
6
|
+
type UseAnimateBarLabelReturn = {
|
|
7
|
+
ref: React.Ref<SVGTextElement>;
|
|
8
|
+
} & Pick<BarLabelProps, 'x' | 'y' | 'width' | 'height'>;
|
|
9
|
+
/**
|
|
10
|
+
* Animates a bar label from the start of the axis (x-axis for vertical layout, y-axis for horizontal layout) to the
|
|
11
|
+
* center of the bar it belongs to.
|
|
12
|
+
* The label is horizontally centered within the bar when the layout is vertical, and vertically centered for laid out
|
|
13
|
+
* horizontally.
|
|
14
|
+
*
|
|
15
|
+
* The props object also accepts a `ref` which will be merged with the ref returned from this hook. This means you can
|
|
16
|
+
* pass the ref returned by this hook to the `path` element and the `ref` provided as argument will also be called.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useAnimateBarLabel(props: UseAnimateBarLabelParams): UseAnimateBarLabelReturn;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { interpolateNumber } from '@mui/x-charts-vendor/d3-interpolate';
|
|
2
|
+
import { useAnimate } from "../../internals/animation/useAnimate.js";
|
|
3
|
+
function barLabelPropsInterpolator(from, to) {
|
|
4
|
+
const interpolateX = interpolateNumber(from.x, to.x);
|
|
5
|
+
const interpolateY = interpolateNumber(from.y, to.y);
|
|
6
|
+
const interpolateWidth = interpolateNumber(from.width, to.width);
|
|
7
|
+
const interpolateHeight = interpolateNumber(from.height, to.height);
|
|
8
|
+
return t => {
|
|
9
|
+
return {
|
|
10
|
+
x: interpolateX(t),
|
|
11
|
+
y: interpolateY(t),
|
|
12
|
+
width: interpolateWidth(t),
|
|
13
|
+
height: interpolateHeight(t)
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Animates a bar label from the start of the axis (x-axis for vertical layout, y-axis for horizontal layout) to the
|
|
20
|
+
* center of the bar it belongs to.
|
|
21
|
+
* The label is horizontally centered within the bar when the layout is vertical, and vertically centered for laid out
|
|
22
|
+
* horizontally.
|
|
23
|
+
*
|
|
24
|
+
* The props object also accepts a `ref` which will be merged with the ref returned from this hook. This means you can
|
|
25
|
+
* pass the ref returned by this hook to the `path` element and the `ref` provided as argument will also be called.
|
|
26
|
+
*/
|
|
27
|
+
export function useAnimateBarLabel(props) {
|
|
28
|
+
const initialProps = {
|
|
29
|
+
x: props.layout === 'vertical' ? props.x + props.width / 2 : props.xOrigin,
|
|
30
|
+
y: props.layout === 'vertical' ? props.yOrigin : props.y + props.height / 2,
|
|
31
|
+
width: props.width,
|
|
32
|
+
height: props.height
|
|
33
|
+
};
|
|
34
|
+
const currentProps = {
|
|
35
|
+
x: props.x + props.width / 2,
|
|
36
|
+
y: props.y + props.height / 2,
|
|
37
|
+
width: props.width,
|
|
38
|
+
height: props.height
|
|
39
|
+
};
|
|
40
|
+
const ref = useAnimate(currentProps, {
|
|
41
|
+
createInterpolator: barLabelPropsInterpolator,
|
|
42
|
+
applyProps(element, animatedProps) {
|
|
43
|
+
element.setAttribute('x', animatedProps.x.toString());
|
|
44
|
+
element.setAttribute('y', animatedProps.y.toString());
|
|
45
|
+
element.setAttribute('width', animatedProps.width.toString());
|
|
46
|
+
element.setAttribute('height', animatedProps.height.toString());
|
|
47
|
+
},
|
|
48
|
+
initialProps,
|
|
49
|
+
skip: props.skipAnimation
|
|
50
|
+
});
|
|
51
|
+
const usedProps = props.skipAnimation ? currentProps : initialProps;
|
|
52
|
+
return {
|
|
53
|
+
ref,
|
|
54
|
+
x: usedProps.x,
|
|
55
|
+
y: usedProps.y,
|
|
56
|
+
width: usedProps.width,
|
|
57
|
+
height: usedProps.height
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { AnimatedLineProps } from '../../LineChart';
|
|
3
|
+
type UseAnimateLineParams = Pick<AnimatedLineProps, 'd' | 'skipAnimation'> & {
|
|
4
|
+
ref?: React.Ref<SVGPathElement>;
|
|
5
|
+
};
|
|
6
|
+
type UseAnimatedReturnValue = {
|
|
7
|
+
ref: React.Ref<SVGPathElement>;
|
|
8
|
+
d: string;
|
|
9
|
+
};
|
|
10
|
+
/** Animates a line of a line chart using a `path` element.
|
|
11
|
+
* The props object also accepts a `ref` which will be merged with the ref returned from this hook. This means you can
|
|
12
|
+
* pass the ref returned by this hook to the `path` element and the `ref` provided as argument will also be called. */
|
|
13
|
+
export declare function useAnimateLine(props: UseAnimateLineParams): UseAnimatedReturnValue;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { interpolateString } from '@mui/x-charts-vendor/d3-interpolate';
|
|
2
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
3
|
+
import { useAnimate } from "../../internals/animation/useAnimate.js";
|
|
4
|
+
/** Animates a line of a line chart using a `path` element.
|
|
5
|
+
* The props object also accepts a `ref` which will be merged with the ref returned from this hook. This means you can
|
|
6
|
+
* pass the ref returned by this hook to the `path` element and the `ref` provided as argument will also be called. */
|
|
7
|
+
export function useAnimateLine(props) {
|
|
8
|
+
const ref = useAnimate({
|
|
9
|
+
d: props.d
|
|
10
|
+
}, {
|
|
11
|
+
createInterpolator: (lastProps, newProps) => {
|
|
12
|
+
const interpolate = interpolateString(lastProps.d, newProps.d);
|
|
13
|
+
return t => ({
|
|
14
|
+
d: interpolate(t)
|
|
15
|
+
});
|
|
16
|
+
},
|
|
17
|
+
applyProps: (element, {
|
|
18
|
+
d
|
|
19
|
+
}) => element.setAttribute('d', d),
|
|
20
|
+
skip: props.skipAnimation
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
ref: useForkRef(ref, props.ref),
|
|
24
|
+
d: props.d
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { PieArcProps } from '../../PieChart';
|
|
3
|
+
type UseAnimatePieArcParams = Pick<PieArcProps, 'startAngle' | 'endAngle' | 'cornerRadius' | 'paddingAngle' | 'innerRadius' | 'outerRadius' | 'skipAnimation'> & {
|
|
4
|
+
ref?: React.Ref<SVGPathElement>;
|
|
5
|
+
};
|
|
6
|
+
type UseAnimatePieArcReturnValue = {
|
|
7
|
+
ref: React.Ref<SVGPathElement>;
|
|
8
|
+
d: string;
|
|
9
|
+
visibility: 'hidden' | 'visible';
|
|
10
|
+
};
|
|
11
|
+
/** Animates a slice of a pie chart by increasing the start and end angles from the middle angle to their final values.
|
|
12
|
+
* The props object also accepts a `ref` which will be merged with the ref returned from this hook. This means you can
|
|
13
|
+
* pass the ref returned by this hook to the `path` element and the `ref` provided as argument will also be called. */
|
|
14
|
+
export declare function useAnimatePieArc(props: UseAnimatePieArcParams): UseAnimatePieArcReturnValue;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { arc as d3Arc } from '@mui/x-charts-vendor/d3-shape';
|
|
2
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
3
|
+
import { interpolateNumber } from '@mui/x-charts-vendor/d3-interpolate';
|
|
4
|
+
import { useAnimate } from "../../internals/animation/useAnimate.js";
|
|
5
|
+
function pieArcPropsInterpolator(from, to) {
|
|
6
|
+
const interpolateStartAngle = interpolateNumber(from.startAngle, to.startAngle);
|
|
7
|
+
const interpolateEndAngle = interpolateNumber(from.endAngle, to.endAngle);
|
|
8
|
+
const interpolateInnerRadius = interpolateNumber(from.innerRadius, to.innerRadius);
|
|
9
|
+
const interpolateOuterRadius = interpolateNumber(from.outerRadius, to.outerRadius);
|
|
10
|
+
const interpolatePaddingAngle = interpolateNumber(from.paddingAngle, to.paddingAngle);
|
|
11
|
+
const interpolateCornerRadius = interpolateNumber(from.cornerRadius, to.cornerRadius);
|
|
12
|
+
return t => {
|
|
13
|
+
return {
|
|
14
|
+
startAngle: interpolateStartAngle(t),
|
|
15
|
+
endAngle: interpolateEndAngle(t),
|
|
16
|
+
innerRadius: interpolateInnerRadius(t),
|
|
17
|
+
outerRadius: interpolateOuterRadius(t),
|
|
18
|
+
paddingAngle: interpolatePaddingAngle(t),
|
|
19
|
+
cornerRadius: interpolateCornerRadius(t)
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Animates a slice of a pie chart by increasing the start and end angles from the middle angle to their final values.
|
|
25
|
+
* The props object also accepts a `ref` which will be merged with the ref returned from this hook. This means you can
|
|
26
|
+
* pass the ref returned by this hook to the `path` element and the `ref` provided as argument will also be called. */
|
|
27
|
+
export function useAnimatePieArc(props) {
|
|
28
|
+
const initialProps = {
|
|
29
|
+
startAngle: (props.startAngle + props.endAngle) / 2,
|
|
30
|
+
endAngle: (props.startAngle + props.endAngle) / 2,
|
|
31
|
+
innerRadius: props.innerRadius,
|
|
32
|
+
outerRadius: props.outerRadius,
|
|
33
|
+
paddingAngle: props.paddingAngle,
|
|
34
|
+
cornerRadius: props.cornerRadius
|
|
35
|
+
};
|
|
36
|
+
const ref = useAnimate({
|
|
37
|
+
startAngle: props.startAngle,
|
|
38
|
+
endAngle: props.endAngle,
|
|
39
|
+
innerRadius: props.innerRadius,
|
|
40
|
+
outerRadius: props.outerRadius,
|
|
41
|
+
paddingAngle: props.paddingAngle,
|
|
42
|
+
cornerRadius: props.cornerRadius
|
|
43
|
+
}, {
|
|
44
|
+
createInterpolator: pieArcPropsInterpolator,
|
|
45
|
+
applyProps(element, animatedProps) {
|
|
46
|
+
element.setAttribute('d', d3Arc().cornerRadius(animatedProps.cornerRadius)({
|
|
47
|
+
padAngle: animatedProps.paddingAngle,
|
|
48
|
+
innerRadius: animatedProps.innerRadius,
|
|
49
|
+
outerRadius: animatedProps.outerRadius,
|
|
50
|
+
startAngle: animatedProps.startAngle,
|
|
51
|
+
endAngle: animatedProps.endAngle
|
|
52
|
+
}).toString());
|
|
53
|
+
element.setAttribute('visibility', animatedProps.startAngle === animatedProps.endAngle ? 'hidden' : 'visible');
|
|
54
|
+
},
|
|
55
|
+
initialProps,
|
|
56
|
+
skip: props.skipAnimation
|
|
57
|
+
});
|
|
58
|
+
const usedProps = props.skipAnimation ? props : initialProps;
|
|
59
|
+
return {
|
|
60
|
+
ref: useForkRef(ref, props.ref),
|
|
61
|
+
d: d3Arc().cornerRadius(usedProps.cornerRadius)({
|
|
62
|
+
padAngle: usedProps.paddingAngle,
|
|
63
|
+
innerRadius: usedProps.innerRadius,
|
|
64
|
+
outerRadius: usedProps.outerRadius,
|
|
65
|
+
startAngle: usedProps.startAngle,
|
|
66
|
+
endAngle: usedProps.endAngle
|
|
67
|
+
}),
|
|
68
|
+
visibility: usedProps.startAngle === usedProps.endAngle ? 'hidden' : 'visible'
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { PieArcLabelProps } from '../../PieChart';
|
|
3
|
+
type UseAnimatePieArcLabelParams = Pick<PieArcLabelProps, 'startAngle' | 'endAngle' | 'cornerRadius' | 'paddingAngle' | 'innerRadius' | 'outerRadius' | 'skipAnimation'> & {
|
|
4
|
+
ref?: React.Ref<SVGTextElement>;
|
|
5
|
+
};
|
|
6
|
+
type UseAnimatePieArcLabelReturn = {
|
|
7
|
+
ref: React.Ref<SVGTextElement>;
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
};
|
|
11
|
+
/** Animates the label of pie slice from its middle point to the centroid of the slice.
|
|
12
|
+
* The props object also accepts a `ref` which will be merged with the ref returned from this hook. This means you can
|
|
13
|
+
* pass the ref returned by this hook to the `path` element and the `ref` provided as argument will also be called. */
|
|
14
|
+
export declare function useAnimatePieArcLabel(props: UseAnimatePieArcLabelParams): UseAnimatePieArcLabelReturn;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { arc as d3Arc } from '@mui/x-charts-vendor/d3-shape';
|
|
2
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
3
|
+
import { interpolateNumber } from '@mui/x-charts-vendor/d3-interpolate';
|
|
4
|
+
import { useAnimate } from "../../internals/animation/useAnimate.js";
|
|
5
|
+
function pieArcLabelPropsInterpolator(from, to) {
|
|
6
|
+
const interpolateStartAngle = interpolateNumber(from.startAngle, to.startAngle);
|
|
7
|
+
const interpolateEndAngle = interpolateNumber(from.endAngle, to.endAngle);
|
|
8
|
+
const interpolateInnerRadius = interpolateNumber(from.innerRadius, to.innerRadius);
|
|
9
|
+
const interpolateOuterRadius = interpolateNumber(from.outerRadius, to.outerRadius);
|
|
10
|
+
const interpolatePaddingAngle = interpolateNumber(from.paddingAngle, to.paddingAngle);
|
|
11
|
+
const interpolateCornerRadius = interpolateNumber(from.cornerRadius, to.cornerRadius);
|
|
12
|
+
return t => {
|
|
13
|
+
return {
|
|
14
|
+
startAngle: interpolateStartAngle(t),
|
|
15
|
+
endAngle: interpolateEndAngle(t),
|
|
16
|
+
innerRadius: interpolateInnerRadius(t),
|
|
17
|
+
outerRadius: interpolateOuterRadius(t),
|
|
18
|
+
paddingAngle: interpolatePaddingAngle(t),
|
|
19
|
+
cornerRadius: interpolateCornerRadius(t)
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Animates the label of pie slice from its middle point to the centroid of the slice.
|
|
25
|
+
* The props object also accepts a `ref` which will be merged with the ref returned from this hook. This means you can
|
|
26
|
+
* pass the ref returned by this hook to the `path` element and the `ref` provided as argument will also be called. */
|
|
27
|
+
export function useAnimatePieArcLabel(props) {
|
|
28
|
+
const initialProps = {
|
|
29
|
+
startAngle: (props.startAngle + props.endAngle) / 2,
|
|
30
|
+
endAngle: (props.startAngle + props.endAngle) / 2,
|
|
31
|
+
innerRadius: props.innerRadius,
|
|
32
|
+
outerRadius: props.outerRadius,
|
|
33
|
+
paddingAngle: props.paddingAngle,
|
|
34
|
+
cornerRadius: props.cornerRadius
|
|
35
|
+
};
|
|
36
|
+
const ref = useAnimate({
|
|
37
|
+
startAngle: props.startAngle,
|
|
38
|
+
endAngle: props.endAngle,
|
|
39
|
+
innerRadius: props.innerRadius,
|
|
40
|
+
outerRadius: props.outerRadius,
|
|
41
|
+
paddingAngle: props.paddingAngle,
|
|
42
|
+
cornerRadius: props.cornerRadius
|
|
43
|
+
}, {
|
|
44
|
+
createInterpolator: pieArcLabelPropsInterpolator,
|
|
45
|
+
applyProps(element, animatedProps) {
|
|
46
|
+
const [x, y] = d3Arc().cornerRadius(animatedProps.cornerRadius).centroid({
|
|
47
|
+
padAngle: animatedProps.paddingAngle,
|
|
48
|
+
startAngle: animatedProps.startAngle,
|
|
49
|
+
endAngle: animatedProps.endAngle,
|
|
50
|
+
innerRadius: animatedProps.innerRadius,
|
|
51
|
+
outerRadius: animatedProps.outerRadius
|
|
52
|
+
});
|
|
53
|
+
element.setAttribute('x', x.toString());
|
|
54
|
+
element.setAttribute('y', y.toString());
|
|
55
|
+
},
|
|
56
|
+
initialProps,
|
|
57
|
+
skip: props.skipAnimation
|
|
58
|
+
});
|
|
59
|
+
const usedProps = props.skipAnimation ? props : initialProps;
|
|
60
|
+
const [x, y] = d3Arc().cornerRadius(usedProps.cornerRadius).centroid({
|
|
61
|
+
padAngle: usedProps.paddingAngle,
|
|
62
|
+
startAngle: usedProps.startAngle,
|
|
63
|
+
endAngle: usedProps.endAngle,
|
|
64
|
+
innerRadius: usedProps.innerRadius,
|
|
65
|
+
outerRadius: usedProps.outerRadius
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
ref: useForkRef(ref, props.ref),
|
|
69
|
+
x,
|
|
70
|
+
y
|
|
71
|
+
};
|
|
72
|
+
}
|
package/modern/hooks/index.d.ts
CHANGED
|
@@ -13,4 +13,5 @@ export * from "./useLineSeries.js";
|
|
|
13
13
|
export * from "./useItemHighlighted.js";
|
|
14
14
|
export * from "./useItemHighlightedGetter.js";
|
|
15
15
|
export * from "./useLegend.js";
|
|
16
|
-
export { useChartGradientId, useChartGradientIdObjectBound } from "./useChartGradientId.js";
|
|
16
|
+
export { useChartGradientId, useChartGradientIdObjectBound } from "./useChartGradientId.js";
|
|
17
|
+
export * from "./animation/index.js";
|
package/modern/hooks/index.js
CHANGED
|
@@ -13,4 +13,5 @@ export * from "./useLineSeries.js";
|
|
|
13
13
|
export * from "./useItemHighlighted.js";
|
|
14
14
|
export * from "./useItemHighlightedGetter.js";
|
|
15
15
|
export * from "./useLegend.js";
|
|
16
|
-
export { useChartGradientId, useChartGradientIdObjectBound } from "./useChartGradientId.js";
|
|
16
|
+
export { useChartGradientId, useChartGradientIdObjectBound } from "./useChartGradientId.js";
|
|
17
|
+
export * from "./animation/index.js";
|
|
@@ -11,7 +11,9 @@ export const useInteractionItemProps = (data, skip) => {
|
|
|
11
11
|
const {
|
|
12
12
|
instance
|
|
13
13
|
} = useChartContext();
|
|
14
|
+
const interactionActive = React.useRef(false);
|
|
14
15
|
const onPointerEnter = React.useCallback(() => {
|
|
16
|
+
interactionActive.current = true;
|
|
15
17
|
instance.setItemInteraction({
|
|
16
18
|
type: data.type,
|
|
17
19
|
seriesId: data.seriesId,
|
|
@@ -23,6 +25,7 @@ export const useInteractionItemProps = (data, skip) => {
|
|
|
23
25
|
});
|
|
24
26
|
}, [instance, data.type, data.seriesId, data.dataIndex]);
|
|
25
27
|
const onPointerLeave = React.useCallback(() => {
|
|
28
|
+
interactionActive.current = false;
|
|
26
29
|
instance.removeItemInteraction({
|
|
27
30
|
type: data.type,
|
|
28
31
|
seriesId: data.seriesId,
|
|
@@ -30,6 +33,14 @@ export const useInteractionItemProps = (data, skip) => {
|
|
|
30
33
|
});
|
|
31
34
|
instance.clearHighlight();
|
|
32
35
|
}, [instance, data.type, data.seriesId, data.dataIndex]);
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
return () => {
|
|
38
|
+
/* Clean up state if this item is unmounted while active. */
|
|
39
|
+
if (interactionActive.current) {
|
|
40
|
+
onPointerLeave();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}, [onPointerLeave]);
|
|
33
44
|
if (skip) {
|
|
34
45
|
return {};
|
|
35
46
|
}
|
package/modern/index.js
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A resumable transition class inspired by d3-transition.
|
|
3
|
+
* Allows for starting, and stopping and resuming transitions.
|
|
4
|
+
*
|
|
5
|
+
* The transition is started automatically.
|
|
6
|
+
* A transition cannot be restarted after it has finished.
|
|
7
|
+
* Resuming a transition will continue from the point it was stopped, i.e., easing will continue from the point it was
|
|
8
|
+
* stopped.
|
|
9
|
+
*/
|
|
10
|
+
export declare class Transition {
|
|
11
|
+
private readonly duration;
|
|
12
|
+
private elapsed;
|
|
13
|
+
private readonly easingFn;
|
|
14
|
+
private timer;
|
|
15
|
+
private readonly onTickCallback;
|
|
16
|
+
/**
|
|
17
|
+
* Create a new ResumableTransition.
|
|
18
|
+
* @param duration Duration in milliseconds
|
|
19
|
+
* @param easingFn The easing function
|
|
20
|
+
* @param onTick Callback function called on each animation frame with the eased time in range [0, 1].
|
|
21
|
+
*/
|
|
22
|
+
constructor(duration: number, easingFn: (t: number) => number, onTick: (easedT: number) => void);
|
|
23
|
+
private get running();
|
|
24
|
+
private timerCallback;
|
|
25
|
+
/**
|
|
26
|
+
* Resume the transition
|
|
27
|
+
*/
|
|
28
|
+
resume(): this;
|
|
29
|
+
/**
|
|
30
|
+
* Stops the transition.
|
|
31
|
+
*/
|
|
32
|
+
stop(): this;
|
|
33
|
+
/**
|
|
34
|
+
* Immediately finishes the transition and calls the tick callback with the final value.
|
|
35
|
+
*/
|
|
36
|
+
finish(): this;
|
|
37
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { timer, now, timeout, timerFlush } from '@mui/x-charts-vendor/d3-timer';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A resumable transition class inspired by d3-transition.
|
|
5
|
+
* Allows for starting, and stopping and resuming transitions.
|
|
6
|
+
*
|
|
7
|
+
* The transition is started automatically.
|
|
8
|
+
* A transition cannot be restarted after it has finished.
|
|
9
|
+
* Resuming a transition will continue from the point it was stopped, i.e., easing will continue from the point it was
|
|
10
|
+
* stopped.
|
|
11
|
+
*/
|
|
12
|
+
export class Transition {
|
|
13
|
+
/**
|
|
14
|
+
* Create a new ResumableTransition.
|
|
15
|
+
* @param duration Duration in milliseconds
|
|
16
|
+
* @param easingFn The easing function
|
|
17
|
+
* @param onTick Callback function called on each animation frame with the eased time in range [0, 1].
|
|
18
|
+
*/
|
|
19
|
+
constructor(duration, easingFn, onTick) {
|
|
20
|
+
this.duration = void 0;
|
|
21
|
+
this.elapsed = 0;
|
|
22
|
+
this.easingFn = void 0;
|
|
23
|
+
this.timer = null;
|
|
24
|
+
this.onTickCallback = void 0;
|
|
25
|
+
this.duration = duration;
|
|
26
|
+
this.easingFn = easingFn;
|
|
27
|
+
this.onTickCallback = onTick;
|
|
28
|
+
this.resume();
|
|
29
|
+
}
|
|
30
|
+
get running() {
|
|
31
|
+
return this.timer !== null;
|
|
32
|
+
}
|
|
33
|
+
timerCallback(elapsed) {
|
|
34
|
+
this.elapsed = Math.min(elapsed, this.duration);
|
|
35
|
+
const t = this.duration === 0 ? 1 : this.elapsed / this.duration;
|
|
36
|
+
const easedT = this.easingFn(t);
|
|
37
|
+
|
|
38
|
+
// Call the tick callback with the current value
|
|
39
|
+
this.onTickCallback(easedT);
|
|
40
|
+
if (this.elapsed >= this.duration) {
|
|
41
|
+
this.stop();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Resume the transition
|
|
47
|
+
*/
|
|
48
|
+
resume() {
|
|
49
|
+
if (this.running || this.elapsed >= this.duration) {
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* If we're resuming the transition, then subtract elapsed to continue the easing. */
|
|
54
|
+
const time = now() - this.elapsed;
|
|
55
|
+
this.timer = timer(elapsed => this.timerCallback(elapsed), 0, time);
|
|
56
|
+
timerFlush();
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Stops the transition.
|
|
62
|
+
*/
|
|
63
|
+
stop() {
|
|
64
|
+
if (!this.running) {
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
if (this.timer) {
|
|
68
|
+
this.timer.stop();
|
|
69
|
+
this.timer = null;
|
|
70
|
+
}
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Immediately finishes the transition and calls the tick callback with the final value.
|
|
76
|
+
*/
|
|
77
|
+
finish() {
|
|
78
|
+
this.stop();
|
|
79
|
+
timeout(() => this.timerCallback(this.duration));
|
|
80
|
+
timerFlush();
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
}
|