@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
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useAnimatePieArc = useAnimatePieArc;
|
|
8
|
+
var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
|
|
9
|
+
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
|
10
|
+
var _d3Interpolate = require("@mui/x-charts-vendor/d3-interpolate");
|
|
11
|
+
var _useAnimate = require("../../internals/animation/useAnimate");
|
|
12
|
+
function pieArcPropsInterpolator(from, to) {
|
|
13
|
+
const interpolateStartAngle = (0, _d3Interpolate.interpolateNumber)(from.startAngle, to.startAngle);
|
|
14
|
+
const interpolateEndAngle = (0, _d3Interpolate.interpolateNumber)(from.endAngle, to.endAngle);
|
|
15
|
+
const interpolateInnerRadius = (0, _d3Interpolate.interpolateNumber)(from.innerRadius, to.innerRadius);
|
|
16
|
+
const interpolateOuterRadius = (0, _d3Interpolate.interpolateNumber)(from.outerRadius, to.outerRadius);
|
|
17
|
+
const interpolatePaddingAngle = (0, _d3Interpolate.interpolateNumber)(from.paddingAngle, to.paddingAngle);
|
|
18
|
+
const interpolateCornerRadius = (0, _d3Interpolate.interpolateNumber)(from.cornerRadius, to.cornerRadius);
|
|
19
|
+
return t => {
|
|
20
|
+
return {
|
|
21
|
+
startAngle: interpolateStartAngle(t),
|
|
22
|
+
endAngle: interpolateEndAngle(t),
|
|
23
|
+
innerRadius: interpolateInnerRadius(t),
|
|
24
|
+
outerRadius: interpolateOuterRadius(t),
|
|
25
|
+
paddingAngle: interpolatePaddingAngle(t),
|
|
26
|
+
cornerRadius: interpolateCornerRadius(t)
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Animates a slice of a pie chart by increasing the start and end angles from the middle angle to their final values.
|
|
32
|
+
* The props object also accepts a `ref` which will be merged with the ref returned from this hook. This means you can
|
|
33
|
+
* pass the ref returned by this hook to the `path` element and the `ref` provided as argument will also be called. */
|
|
34
|
+
function useAnimatePieArc(props) {
|
|
35
|
+
const initialProps = {
|
|
36
|
+
startAngle: (props.startAngle + props.endAngle) / 2,
|
|
37
|
+
endAngle: (props.startAngle + props.endAngle) / 2,
|
|
38
|
+
innerRadius: props.innerRadius,
|
|
39
|
+
outerRadius: props.outerRadius,
|
|
40
|
+
paddingAngle: props.paddingAngle,
|
|
41
|
+
cornerRadius: props.cornerRadius
|
|
42
|
+
};
|
|
43
|
+
const ref = (0, _useAnimate.useAnimate)({
|
|
44
|
+
startAngle: props.startAngle,
|
|
45
|
+
endAngle: props.endAngle,
|
|
46
|
+
innerRadius: props.innerRadius,
|
|
47
|
+
outerRadius: props.outerRadius,
|
|
48
|
+
paddingAngle: props.paddingAngle,
|
|
49
|
+
cornerRadius: props.cornerRadius
|
|
50
|
+
}, {
|
|
51
|
+
createInterpolator: pieArcPropsInterpolator,
|
|
52
|
+
applyProps(element, animatedProps) {
|
|
53
|
+
element.setAttribute('d', (0, _d3Shape.arc)().cornerRadius(animatedProps.cornerRadius)({
|
|
54
|
+
padAngle: animatedProps.paddingAngle,
|
|
55
|
+
innerRadius: animatedProps.innerRadius,
|
|
56
|
+
outerRadius: animatedProps.outerRadius,
|
|
57
|
+
startAngle: animatedProps.startAngle,
|
|
58
|
+
endAngle: animatedProps.endAngle
|
|
59
|
+
}).toString());
|
|
60
|
+
element.setAttribute('visibility', animatedProps.startAngle === animatedProps.endAngle ? 'hidden' : 'visible');
|
|
61
|
+
},
|
|
62
|
+
initialProps,
|
|
63
|
+
skip: props.skipAnimation
|
|
64
|
+
});
|
|
65
|
+
const usedProps = props.skipAnimation ? props : initialProps;
|
|
66
|
+
return {
|
|
67
|
+
ref: (0, _useForkRef.default)(ref, props.ref),
|
|
68
|
+
d: (0, _d3Shape.arc)().cornerRadius(usedProps.cornerRadius)({
|
|
69
|
+
padAngle: usedProps.paddingAngle,
|
|
70
|
+
innerRadius: usedProps.innerRadius,
|
|
71
|
+
outerRadius: usedProps.outerRadius,
|
|
72
|
+
startAngle: usedProps.startAngle,
|
|
73
|
+
endAngle: usedProps.endAngle
|
|
74
|
+
}),
|
|
75
|
+
visibility: usedProps.startAngle === usedProps.endAngle ? 'hidden' : 'visible'
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -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,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useAnimatePieArcLabel = useAnimatePieArcLabel;
|
|
8
|
+
var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
|
|
9
|
+
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
|
10
|
+
var _d3Interpolate = require("@mui/x-charts-vendor/d3-interpolate");
|
|
11
|
+
var _useAnimate = require("../../internals/animation/useAnimate");
|
|
12
|
+
function pieArcLabelPropsInterpolator(from, to) {
|
|
13
|
+
const interpolateStartAngle = (0, _d3Interpolate.interpolateNumber)(from.startAngle, to.startAngle);
|
|
14
|
+
const interpolateEndAngle = (0, _d3Interpolate.interpolateNumber)(from.endAngle, to.endAngle);
|
|
15
|
+
const interpolateInnerRadius = (0, _d3Interpolate.interpolateNumber)(from.innerRadius, to.innerRadius);
|
|
16
|
+
const interpolateOuterRadius = (0, _d3Interpolate.interpolateNumber)(from.outerRadius, to.outerRadius);
|
|
17
|
+
const interpolatePaddingAngle = (0, _d3Interpolate.interpolateNumber)(from.paddingAngle, to.paddingAngle);
|
|
18
|
+
const interpolateCornerRadius = (0, _d3Interpolate.interpolateNumber)(from.cornerRadius, to.cornerRadius);
|
|
19
|
+
return t => {
|
|
20
|
+
return {
|
|
21
|
+
startAngle: interpolateStartAngle(t),
|
|
22
|
+
endAngle: interpolateEndAngle(t),
|
|
23
|
+
innerRadius: interpolateInnerRadius(t),
|
|
24
|
+
outerRadius: interpolateOuterRadius(t),
|
|
25
|
+
paddingAngle: interpolatePaddingAngle(t),
|
|
26
|
+
cornerRadius: interpolateCornerRadius(t)
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Animates the label of pie slice from its middle point to the centroid of the slice.
|
|
32
|
+
* The props object also accepts a `ref` which will be merged with the ref returned from this hook. This means you can
|
|
33
|
+
* pass the ref returned by this hook to the `path` element and the `ref` provided as argument will also be called. */
|
|
34
|
+
function useAnimatePieArcLabel(props) {
|
|
35
|
+
const initialProps = {
|
|
36
|
+
startAngle: (props.startAngle + props.endAngle) / 2,
|
|
37
|
+
endAngle: (props.startAngle + props.endAngle) / 2,
|
|
38
|
+
innerRadius: props.innerRadius,
|
|
39
|
+
outerRadius: props.outerRadius,
|
|
40
|
+
paddingAngle: props.paddingAngle,
|
|
41
|
+
cornerRadius: props.cornerRadius
|
|
42
|
+
};
|
|
43
|
+
const ref = (0, _useAnimate.useAnimate)({
|
|
44
|
+
startAngle: props.startAngle,
|
|
45
|
+
endAngle: props.endAngle,
|
|
46
|
+
innerRadius: props.innerRadius,
|
|
47
|
+
outerRadius: props.outerRadius,
|
|
48
|
+
paddingAngle: props.paddingAngle,
|
|
49
|
+
cornerRadius: props.cornerRadius
|
|
50
|
+
}, {
|
|
51
|
+
createInterpolator: pieArcLabelPropsInterpolator,
|
|
52
|
+
applyProps(element, animatedProps) {
|
|
53
|
+
const [x, y] = (0, _d3Shape.arc)().cornerRadius(animatedProps.cornerRadius).centroid({
|
|
54
|
+
padAngle: animatedProps.paddingAngle,
|
|
55
|
+
startAngle: animatedProps.startAngle,
|
|
56
|
+
endAngle: animatedProps.endAngle,
|
|
57
|
+
innerRadius: animatedProps.innerRadius,
|
|
58
|
+
outerRadius: animatedProps.outerRadius
|
|
59
|
+
});
|
|
60
|
+
element.setAttribute('x', x.toString());
|
|
61
|
+
element.setAttribute('y', y.toString());
|
|
62
|
+
},
|
|
63
|
+
initialProps,
|
|
64
|
+
skip: props.skipAnimation
|
|
65
|
+
});
|
|
66
|
+
const usedProps = props.skipAnimation ? props : initialProps;
|
|
67
|
+
const [x, y] = (0, _d3Shape.arc)().cornerRadius(usedProps.cornerRadius).centroid({
|
|
68
|
+
padAngle: usedProps.paddingAngle,
|
|
69
|
+
startAngle: usedProps.startAngle,
|
|
70
|
+
endAngle: usedProps.endAngle,
|
|
71
|
+
innerRadius: usedProps.innerRadius,
|
|
72
|
+
outerRadius: usedProps.outerRadius
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
ref: (0, _useForkRef.default)(ref, props.ref),
|
|
76
|
+
x,
|
|
77
|
+
y
|
|
78
|
+
};
|
|
79
|
+
}
|
package/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/hooks/index.js
CHANGED
|
@@ -199,4 +199,16 @@ Object.keys(_useLegend).forEach(function (key) {
|
|
|
199
199
|
}
|
|
200
200
|
});
|
|
201
201
|
});
|
|
202
|
-
var _useChartGradientId = require("./useChartGradientId");
|
|
202
|
+
var _useChartGradientId = require("./useChartGradientId");
|
|
203
|
+
var _animation = require("./animation");
|
|
204
|
+
Object.keys(_animation).forEach(function (key) {
|
|
205
|
+
if (key === "default" || key === "__esModule") return;
|
|
206
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
207
|
+
if (key in exports && exports[key] === _animation[key]) return;
|
|
208
|
+
Object.defineProperty(exports, key, {
|
|
209
|
+
enumerable: true,
|
|
210
|
+
get: function () {
|
|
211
|
+
return _animation[key];
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
});
|
|
@@ -17,7 +17,9 @@ const useInteractionItemProps = (data, skip) => {
|
|
|
17
17
|
const {
|
|
18
18
|
instance
|
|
19
19
|
} = (0, _ChartProvider.useChartContext)();
|
|
20
|
+
const interactionActive = React.useRef(false);
|
|
20
21
|
const onPointerEnter = React.useCallback(() => {
|
|
22
|
+
interactionActive.current = true;
|
|
21
23
|
instance.setItemInteraction({
|
|
22
24
|
type: data.type,
|
|
23
25
|
seriesId: data.seriesId,
|
|
@@ -29,6 +31,7 @@ const useInteractionItemProps = (data, skip) => {
|
|
|
29
31
|
});
|
|
30
32
|
}, [instance, data.type, data.seriesId, data.dataIndex]);
|
|
31
33
|
const onPointerLeave = React.useCallback(() => {
|
|
34
|
+
interactionActive.current = false;
|
|
32
35
|
instance.removeItemInteraction({
|
|
33
36
|
type: data.type,
|
|
34
37
|
seriesId: data.seriesId,
|
|
@@ -36,6 +39,14 @@ const useInteractionItemProps = (data, skip) => {
|
|
|
36
39
|
});
|
|
37
40
|
instance.clearHighlight();
|
|
38
41
|
}, [instance, data.type, data.seriesId, data.dataIndex]);
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
return () => {
|
|
44
|
+
/* Clean up state if this item is unmounted while active. */
|
|
45
|
+
if (interactionActive.current) {
|
|
46
|
+
onPointerLeave();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}, [onPointerLeave]);
|
|
39
50
|
if (skip) {
|
|
40
51
|
return {};
|
|
41
52
|
}
|
package/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,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Transition = void 0;
|
|
7
|
+
var _d3Timer = require("@mui/x-charts-vendor/d3-timer");
|
|
8
|
+
/**
|
|
9
|
+
* A resumable transition class inspired by d3-transition.
|
|
10
|
+
* Allows for starting, and stopping and resuming transitions.
|
|
11
|
+
*
|
|
12
|
+
* The transition is started automatically.
|
|
13
|
+
* A transition cannot be restarted after it has finished.
|
|
14
|
+
* Resuming a transition will continue from the point it was stopped, i.e., easing will continue from the point it was
|
|
15
|
+
* stopped.
|
|
16
|
+
*/
|
|
17
|
+
class Transition {
|
|
18
|
+
/**
|
|
19
|
+
* Create a new ResumableTransition.
|
|
20
|
+
* @param duration Duration in milliseconds
|
|
21
|
+
* @param easingFn The easing function
|
|
22
|
+
* @param onTick Callback function called on each animation frame with the eased time in range [0, 1].
|
|
23
|
+
*/
|
|
24
|
+
constructor(duration, easingFn, onTick) {
|
|
25
|
+
this.duration = void 0;
|
|
26
|
+
this.elapsed = 0;
|
|
27
|
+
this.easingFn = void 0;
|
|
28
|
+
this.timer = null;
|
|
29
|
+
this.onTickCallback = void 0;
|
|
30
|
+
this.duration = duration;
|
|
31
|
+
this.easingFn = easingFn;
|
|
32
|
+
this.onTickCallback = onTick;
|
|
33
|
+
this.resume();
|
|
34
|
+
}
|
|
35
|
+
get running() {
|
|
36
|
+
return this.timer !== null;
|
|
37
|
+
}
|
|
38
|
+
timerCallback(elapsed) {
|
|
39
|
+
this.elapsed = Math.min(elapsed, this.duration);
|
|
40
|
+
const t = this.duration === 0 ? 1 : this.elapsed / this.duration;
|
|
41
|
+
const easedT = this.easingFn(t);
|
|
42
|
+
|
|
43
|
+
// Call the tick callback with the current value
|
|
44
|
+
this.onTickCallback(easedT);
|
|
45
|
+
if (this.elapsed >= this.duration) {
|
|
46
|
+
this.stop();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Resume the transition
|
|
52
|
+
*/
|
|
53
|
+
resume() {
|
|
54
|
+
if (this.running || this.elapsed >= this.duration) {
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* If we're resuming the transition, then subtract elapsed to continue the easing. */
|
|
59
|
+
const time = (0, _d3Timer.now)() - this.elapsed;
|
|
60
|
+
this.timer = (0, _d3Timer.timer)(elapsed => this.timerCallback(elapsed), 0, time);
|
|
61
|
+
(0, _d3Timer.timerFlush)();
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Stops the transition.
|
|
67
|
+
*/
|
|
68
|
+
stop() {
|
|
69
|
+
if (!this.running) {
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
if (this.timer) {
|
|
73
|
+
this.timer.stop();
|
|
74
|
+
this.timer = null;
|
|
75
|
+
}
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Immediately finishes the transition and calls the tick callback with the final value.
|
|
81
|
+
*/
|
|
82
|
+
finish() {
|
|
83
|
+
this.stop();
|
|
84
|
+
(0, _d3Timer.timeout)(() => this.timerCallback(this.duration));
|
|
85
|
+
(0, _d3Timer.timerFlush)();
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.Transition = Transition;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ANIMATION_TIMING_FUNCTION_JS = exports.ANIMATION_TIMING_FUNCTION = exports.ANIMATION_DURATION_MS = void 0;
|
|
8
|
+
var _bezierEasing = _interopRequireDefault(require("bezier-easing"));
|
|
9
|
+
const ANIMATION_DURATION_MS = exports.ANIMATION_DURATION_MS = 300;
|
|
10
|
+
const ANIMATION_TIMING_FUNCTION = exports.ANIMATION_TIMING_FUNCTION = 'cubic-bezier(0.66, 0, 0.34, 1)';
|
|
11
|
+
const ANIMATION_TIMING_FUNCTION_JS = exports.ANIMATION_TIMING_FUNCTION_JS = (0, _bezierEasing.default)(0.66, 0, 0.34, 1);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Animates a ref. The animation can be skipped by setting {@link skip} to true.
|
|
2
|
+
*
|
|
3
|
+
* - If {@link skip} is false, a transition will be started.
|
|
4
|
+
* - If {@link skip} is true and no transition is in progress, no transition will be started and {@link applyProps} will
|
|
5
|
+
* never be called.
|
|
6
|
+
* - If {@link skip} becomes true and a transition is in progress, the transition will immediately end and
|
|
7
|
+
* {@link applyProps} be called with the final value.
|
|
8
|
+
* */
|
|
9
|
+
export declare function useAnimate<Props extends {}, Elem extends Element>(props: Props, {
|
|
10
|
+
createInterpolator,
|
|
11
|
+
applyProps,
|
|
12
|
+
skip,
|
|
13
|
+
initialProps
|
|
14
|
+
}: {
|
|
15
|
+
createInterpolator: (lastProps: Props, newProps: Props) => (t: number) => Props;
|
|
16
|
+
applyProps: (element: Elem, props: Props) => void;
|
|
17
|
+
skip?: boolean;
|
|
18
|
+
initialProps?: Props;
|
|
19
|
+
}): (element: Elem | null) => void;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.useAnimate = useAnimate;
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
12
|
+
var _animation = require("./animation");
|
|
13
|
+
var _Transition = require("./Transition");
|
|
14
|
+
var _shallowEqual = require("../shallowEqual");
|
|
15
|
+
/** Animates a ref. The animation can be skipped by setting {@link skip} to true.
|
|
16
|
+
*
|
|
17
|
+
* - If {@link skip} is false, a transition will be started.
|
|
18
|
+
* - If {@link skip} is true and no transition is in progress, no transition will be started and {@link applyProps} will
|
|
19
|
+
* never be called.
|
|
20
|
+
* - If {@link skip} becomes true and a transition is in progress, the transition will immediately end and
|
|
21
|
+
* {@link applyProps} be called with the final value.
|
|
22
|
+
* */
|
|
23
|
+
function useAnimate(props, {
|
|
24
|
+
createInterpolator,
|
|
25
|
+
applyProps,
|
|
26
|
+
skip,
|
|
27
|
+
initialProps = props
|
|
28
|
+
}) {
|
|
29
|
+
const lastInterpolatedPropsRef = React.useRef(initialProps);
|
|
30
|
+
const transitionRef = React.useRef(null);
|
|
31
|
+
const elementRef = React.useRef(null);
|
|
32
|
+
const lastPropsRef = React.useRef(props);
|
|
33
|
+
(0, _useEnhancedEffect.default)(() => {
|
|
34
|
+
lastPropsRef.current = props;
|
|
35
|
+
}, [props]);
|
|
36
|
+
(0, _useEnhancedEffect.default)(() => {
|
|
37
|
+
if (skip) {
|
|
38
|
+
transitionRef.current?.finish();
|
|
39
|
+
transitionRef.current = null;
|
|
40
|
+
elementRef.current = null;
|
|
41
|
+
lastInterpolatedPropsRef.current = props;
|
|
42
|
+
}
|
|
43
|
+
}, [props, skip]);
|
|
44
|
+
const animate = React.useCallback(element => {
|
|
45
|
+
const lastInterpolatedProps = lastInterpolatedPropsRef.current;
|
|
46
|
+
const interpolate = createInterpolator(lastInterpolatedProps, props);
|
|
47
|
+
transitionRef.current = new _Transition.Transition(_animation.ANIMATION_DURATION_MS, _animation.ANIMATION_TIMING_FUNCTION_JS, t => {
|
|
48
|
+
const interpolatedProps = interpolate(t);
|
|
49
|
+
lastInterpolatedPropsRef.current = interpolatedProps;
|
|
50
|
+
applyProps(element, interpolatedProps);
|
|
51
|
+
});
|
|
52
|
+
}, [applyProps, createInterpolator, props]);
|
|
53
|
+
const setRef = React.useCallback(element => {
|
|
54
|
+
if (element === null) {
|
|
55
|
+
transitionRef.current?.stop();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const lastElement = elementRef.current;
|
|
59
|
+
if (lastElement === element) {
|
|
60
|
+
// If it's the same element and same props, resume the transition.
|
|
61
|
+
if ((0, _shallowEqual.shallowEqual)(lastPropsRef.current, props)) {
|
|
62
|
+
transitionRef.current?.resume();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// If props aren't the same, stop the transition and start a new animation.
|
|
67
|
+
transitionRef.current?.stop();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// If it's a different element, stop the transition of the last element and start a new animation.
|
|
71
|
+
if (lastElement) {
|
|
72
|
+
transitionRef.current?.stop();
|
|
73
|
+
}
|
|
74
|
+
elementRef.current = element;
|
|
75
|
+
if (transitionRef.current || !skip) {
|
|
76
|
+
animate(element);
|
|
77
|
+
}
|
|
78
|
+
}, [animate, props, skip]);
|
|
79
|
+
return setRef;
|
|
80
|
+
}
|
|
@@ -6,7 +6,7 @@ import { ChartSeriesConfig } from "../../models/seriesConfig/index.js";
|
|
|
6
6
|
import { DefaultizedAxisConfig, DefaultizedZoomOptions } from "./useChartCartesianAxis.types.js";
|
|
7
7
|
import { ProcessedSeries } from "../../corePlugins/useChartSeries/useChartSeries.types.js";
|
|
8
8
|
import { GetZoomAxisFilters, ZoomData } from "./zoom.types.js";
|
|
9
|
-
type ComputeResult<T extends ChartsAxisProps> = {
|
|
9
|
+
export type ComputeResult<T extends ChartsAxisProps> = {
|
|
10
10
|
axis: DefaultizedAxisConfig<T>;
|
|
11
11
|
axisIds: string[];
|
|
12
12
|
};
|
|
@@ -13,6 +13,7 @@ var _useTicks = require("../../../../hooks/useTicks");
|
|
|
13
13
|
var _getScale = require("../../../getScale");
|
|
14
14
|
var _zoom = require("./zoom");
|
|
15
15
|
var _getAxisExtremum = require("./getAxisExtremum");
|
|
16
|
+
var _getAxisTriggerTooltip = require("./getAxisTriggerTooltip");
|
|
16
17
|
function getRange(drawingArea, axisDirection,
|
|
17
18
|
// | 'rotation' | 'radius',
|
|
18
19
|
axis) {
|
|
@@ -44,6 +45,7 @@ function computeAxisValue({
|
|
|
44
45
|
axisIds: []
|
|
45
46
|
};
|
|
46
47
|
}
|
|
48
|
+
const axisIdsTriggeringTooltip = (0, _getAxisTriggerTooltip.getAxisTriggerTooltip)(axisDirection, seriesConfig, formattedSeries, allAxis[0].id);
|
|
47
49
|
const completeAxis = {};
|
|
48
50
|
allAxis.forEach((eachAxis, axisIndex) => {
|
|
49
51
|
const axis = eachAxis;
|
|
@@ -53,6 +55,7 @@ function computeAxisValue({
|
|
|
53
55
|
const range = getRange(drawingArea, axisDirection, axis);
|
|
54
56
|
const [minData, maxData] = (0, _getAxisExtremum.getAxisExtremum)(axis, axisDirection, seriesConfig, axisIndex, formattedSeries, zoom === undefined && !zoomOption ? getFilters : undefined // Do not apply filtering if zoom is already defined.
|
|
55
57
|
);
|
|
58
|
+
const triggerTooltip = !axis.ignoreTooltip && axisIdsTriggeringTooltip.has(axis.id);
|
|
56
59
|
const data = axis.data ?? [];
|
|
57
60
|
if ((0, _axis.isBandScaleConfig)(axis)) {
|
|
58
61
|
const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
|
|
@@ -64,7 +67,8 @@ function computeAxisValue({
|
|
|
64
67
|
offset: 0,
|
|
65
68
|
height: 0,
|
|
66
69
|
categoryGapRatio,
|
|
67
|
-
barGapRatio
|
|
70
|
+
barGapRatio,
|
|
71
|
+
triggerTooltip
|
|
68
72
|
}, axis, {
|
|
69
73
|
data,
|
|
70
74
|
scale: (0, _d3Scale.scaleBand)(axis.data, zoomedRange).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2),
|
|
@@ -83,7 +87,8 @@ function computeAxisValue({
|
|
|
83
87
|
const zoomedRange = (0, _zoom.zoomScaleRange)(scaleRange, zoomRange);
|
|
84
88
|
completeAxis[axis.id] = (0, _extends2.default)({
|
|
85
89
|
offset: 0,
|
|
86
|
-
height: 0
|
|
90
|
+
height: 0,
|
|
91
|
+
triggerTooltip
|
|
87
92
|
}, axis, {
|
|
88
93
|
data,
|
|
89
94
|
scale: (0, _d3Scale.scalePoint)(axis.data, zoomedRange),
|
|
@@ -124,7 +129,8 @@ function computeAxisValue({
|
|
|
124
129
|
const domain = [axis.min ?? minDomain, axis.max ?? maxDomain];
|
|
125
130
|
completeAxis[axis.id] = (0, _extends2.default)({
|
|
126
131
|
offset: 0,
|
|
127
|
-
height: 0
|
|
132
|
+
height: 0,
|
|
133
|
+
triggerTooltip
|
|
128
134
|
}, axis, {
|
|
129
135
|
data,
|
|
130
136
|
scaleType: scaleType,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CartesianChartSeriesType } from "../../../../models/seriesType/config.js";
|
|
2
|
+
import { ChartSeriesConfig } from "../../models/seriesConfig/index.js";
|
|
3
|
+
import { ProcessedSeries } from "../../corePlugins/useChartSeries/useChartSeries.types.js";
|
|
4
|
+
import { AxisId } from "../../../../models/axis.js";
|
|
5
|
+
export declare const getAxisTriggerTooltip: <TSeriesType extends CartesianChartSeriesType>(axisDirection: "x" | "y", seriesConfig: ChartSeriesConfig<TSeriesType>, formattedSeries: ProcessedSeries<TSeriesType>, defaultAxisId: AxisId) => Set<AxisId>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getAxisTriggerTooltip = void 0;
|
|
7
|
+
var _isCartesian = require("../../../isCartesian");
|
|
8
|
+
const getAxisTriggerTooltip = (axisDirection, seriesConfig, formattedSeries, defaultAxisId) => {
|
|
9
|
+
const tooltipAxesIds = new Set();
|
|
10
|
+
const chartTypes = Object.keys(seriesConfig).filter(_isCartesian.isCartesianSeriesType);
|
|
11
|
+
chartTypes.forEach(chartType => {
|
|
12
|
+
const series = formattedSeries[chartType]?.series ?? {};
|
|
13
|
+
const tooltipAxes = seriesConfig[chartType].axisTooltipGetter?.(series);
|
|
14
|
+
if (tooltipAxes === undefined) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
tooltipAxes.forEach(({
|
|
18
|
+
axisId,
|
|
19
|
+
direction
|
|
20
|
+
}) => {
|
|
21
|
+
if (direction === axisDirection) {
|
|
22
|
+
tooltipAxesIds.add(axisId ?? defaultAxisId);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
return tooltipAxesIds;
|
|
27
|
+
};
|
|
28
|
+
exports.getAxisTriggerTooltip = getAxisTriggerTooltip;
|