@mui/x-charts 8.0.0-alpha.0 → 8.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/AnimatedBarElement.d.ts +15 -0
- package/BarChart/AnimatedBarElement.js +21 -0
- package/BarChart/BarChart.d.ts +4 -9
- package/BarChart/BarChart.js +3 -31
- package/BarChart/BarElement.d.ts +5 -1342
- package/BarChart/BarElement.js +10 -20
- package/BarChart/BarPlot.js +12 -2
- package/BarChart/useBarChartProps.d.ts +0 -2
- package/BarChart/useBarChartProps.js +2 -8
- package/CHANGELOG.md +429 -5
- package/ChartContainer/ChartContainer.d.ts +2 -19
- package/ChartContainer/ChartContainer.js +10 -20
- package/ChartContainer/ResizableContainer.d.ts +17 -4
- package/ChartContainer/ResizableContainer.js +36 -2
- package/ChartContainer/useChartContainerProps.d.ts +6 -7
- package/ChartContainer/useChartContainerProps.js +14 -28
- package/ChartsAxisHighlight/ChartsAxisHighlight.d.ts +1 -17
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +10 -96
- package/ChartsAxisHighlight/ChartsAxisHighlight.types.d.ts +5 -0
- package/ChartsAxisHighlight/ChartsAxisHighlight.types.js +1 -0
- package/ChartsAxisHighlight/ChartsAxisHighlightPath.d.ts +6 -0
- package/ChartsAxisHighlight/ChartsAxisHighlightPath.js +34 -0
- package/ChartsAxisHighlight/ChartsXAxisHighlight.d.ts +10 -0
- package/ChartsAxisHighlight/ChartsXAxisHighlight.js +53 -0
- package/ChartsAxisHighlight/ChartsYAxisHighlight.d.ts +10 -0
- package/ChartsAxisHighlight/ChartsYAxisHighlight.js +53 -0
- package/ChartsAxisHighlight/chartsAxisHighlightClasses.d.ts +7 -0
- package/ChartsAxisHighlight/chartsAxisHighlightClasses.js +6 -0
- package/ChartsAxisHighlight/index.d.ts +3 -0
- package/ChartsAxisHighlight/index.js +4 -1
- package/ChartsGrid/ChartsGrid.js +1 -1
- package/ChartsGrid/ChartsHorizontalGrid.d.ts +2 -2
- package/ChartsGrid/ChartsHorizontalGrid.js +3 -3
- package/ChartsGrid/ChartsVerticalGrid.d.ts +2 -2
- package/ChartsGrid/ChartsVerticalGrid.js +3 -3
- package/ChartsLegend/LegendPerItem.d.ts +2 -2
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +9 -7
- package/ChartsSurface/ChartsSurface.d.ts +0 -15
- package/ChartsSurface/ChartsSurface.js +35 -34
- package/ChartsTooltip/ChartTooltip.types.d.ts +15 -0
- package/ChartsTooltip/ChartTooltip.types.js +1 -0
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +7 -39
- package/ChartsTooltip/ChartsAxisTooltipContent.js +83 -72
- package/ChartsTooltip/ChartsItemTooltipContent.d.ts +5 -28
- package/ChartsTooltip/ChartsItemTooltipContent.js +54 -44
- package/ChartsTooltip/ChartsTooltip.d.ts +3 -69
- package/ChartsTooltip/ChartsTooltip.js +161 -145
- package/ChartsTooltip/ChartsTooltipContainer.d.ts +33 -0
- package/ChartsTooltip/ChartsTooltipContainer.js +298 -0
- package/ChartsTooltip/chartsTooltipClasses.d.ts +1 -0
- package/ChartsTooltip/chartsTooltipClasses.js +18 -2
- package/ChartsTooltip/index.d.ts +3 -3
- package/ChartsTooltip/index.js +2 -3
- package/ChartsTooltip/useAxisTooltip.d.ts +2 -2
- package/ChartsTooltip/useAxisTooltip.js +19 -19
- package/ChartsTooltip/useItemTooltip.d.ts +1 -1
- package/ChartsTooltip/useItemTooltip.js +5 -4
- package/ChartsTooltip/utils.d.ts +0 -3
- package/ChartsTooltip/utils.js +0 -8
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +47 -34
- package/Gauge/Gauge.d.ts +1 -1
- package/Gauge/Gauge.js +0 -6
- package/Gauge/GaugeContainer.d.ts +3 -3
- package/Gauge/GaugeContainer.js +60 -61
- package/LineChart/AnimatedArea.d.ts +0 -1333
- package/LineChart/AnimatedArea.js +9 -18
- package/LineChart/AnimatedLine.d.ts +0 -1333
- package/LineChart/AnimatedLine.js +9 -20
- package/LineChart/AreaPlot.js +12 -2
- package/LineChart/CircleMarkElement.js +6 -5
- package/LineChart/LineChart.d.ts +4 -10
- package/LineChart/LineChart.js +3 -32
- package/LineChart/LineHighlightPlot.js +6 -5
- package/LineChart/LinePlot.js +12 -2
- package/LineChart/MarkElement.js +6 -5
- package/LineChart/useLineChartProps.d.ts +0 -2
- package/LineChart/useLineChartProps.js +2 -8
- package/PieChart/PieChart.d.ts +3 -9
- package/PieChart/PieChart.js +5 -37
- package/PieChart/PiePlot.js +2 -2
- package/PieChart/getPieCoordinates.d.ts +2 -2
- package/README.md +2 -2
- package/ScatterChart/Scatter.js +6 -5
- package/ScatterChart/ScatterChart.d.ts +4 -10
- package/ScatterChart/ScatterChart.js +5 -32
- package/ScatterChart/useScatterChartProps.d.ts +0 -2
- package/ScatterChart/useScatterChartProps.js +1 -9
- package/SparkLineChart/SparkLineChart.d.ts +3 -4
- package/SparkLineChart/SparkLineChart.js +4 -31
- package/context/ChartDataProvider/ChartDataProvider.d.ts +9 -19
- package/context/ChartDataProvider/ChartDataProvider.js +30 -43
- package/context/ChartDataProvider/useChartDataProviderProps.d.ts +7 -10
- package/context/ChartDataProvider/useChartDataProviderProps.js +22 -42
- package/context/{DrawingProvider.d.ts → DrawingAreaProvider/DrawingArea.types.d.ts} +3 -14
- package/context/DrawingAreaProvider/DrawingArea.types.js +1 -0
- package/context/DrawingAreaProvider/DrawingAreaContext.d.ts +8 -0
- package/context/DrawingAreaProvider/DrawingAreaContext.js +16 -0
- package/context/DrawingAreaProvider/DrawingAreaProvider.d.ts +3 -0
- package/context/{DrawingProvider.js → DrawingAreaProvider/DrawingAreaProvider.js} +11 -41
- package/context/DrawingAreaProvider/index.d.ts +3 -0
- package/context/DrawingAreaProvider/index.js +3 -0
- package/context/InteractionProvider.d.ts +5 -48
- package/context/InteractionProvider.js +8 -64
- package/context/InteractionSelectors.d.ts +359 -0
- package/context/InteractionSelectors.js +12 -0
- package/context/SizeProvider/Size.types.d.ts +30 -0
- package/context/SizeProvider/Size.types.js +1 -0
- package/context/SizeProvider/SizeContext.d.ts +4 -0
- package/context/SizeProvider/SizeContext.js +13 -0
- package/context/SizeProvider/SizeProvider.d.ts +11 -0
- package/context/SizeProvider/SizeProvider.js +26 -0
- package/context/SizeProvider/index.d.ts +4 -0
- package/context/SizeProvider/index.js +4 -0
- package/{ChartContainer → context/SizeProvider}/useChartContainerDimensions.d.ts +4 -1
- package/{modern/ChartContainer → context/SizeProvider}/useChartContainerDimensions.js +11 -5
- package/context/SizeProvider/useSize.d.ts +5 -0
- package/context/SizeProvider/useSize.js +13 -0
- package/context/SvgRefProvider/SvgRef.types.d.ts +8 -0
- package/context/SvgRefProvider/SvgRef.types.js +1 -0
- package/context/SvgRefProvider/SvgRefContext.d.ts +4 -0
- package/context/SvgRefProvider/SvgRefContext.js +17 -0
- package/context/SvgRefProvider/SvgRefProvider.d.ts +3 -0
- package/context/SvgRefProvider/SvgRefProvider.js +24 -0
- package/context/SvgRefProvider/index.d.ts +4 -0
- package/context/SvgRefProvider/index.js +4 -0
- package/context/SvgRefProvider/useSurfaceRef.d.ts +2 -0
- package/context/SvgRefProvider/useSurfaceRef.js +14 -0
- package/context/index.d.ts +2 -0
- package/context/index.js +2 -1
- package/hooks/useAxisEvents.js +32 -19
- package/hooks/useChartId.js +2 -2
- package/hooks/useDrawingArea.d.ts +2 -2
- package/hooks/useDrawingArea.js +2 -2
- package/hooks/useInteractionItemProps.js +19 -12
- package/hooks/useSvgRef.js +3 -3
- package/index.js +1 -1
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +1 -1
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +9 -4
- package/internals/computeAxisValue.d.ts +2 -2
- package/internals/index.d.ts +3 -2
- package/internals/index.js +3 -2
- package/internals/plugins/models/index.d.ts +35 -0
- package/internals/plugins/models/index.js +1 -0
- package/internals/plugins/utils/ChartStore.d.ts +12 -0
- package/internals/plugins/utils/ChartStore.js +26 -0
- package/internals/plugins/utils/ChartsStore.d.ts +12 -0
- package/internals/plugins/utils/ChartsStore.js +26 -0
- package/internals/plugins/utils/selectors.d.ts +9 -0
- package/internals/plugins/utils/selectors.js +37 -0
- package/internals/useCharts.d.ts +6 -0
- package/internals/useCharts.js +29 -0
- package/internals/useSelector.d.ts +4 -0
- package/internals/useSelector.js +6 -0
- package/internals/useStore.d.ts +2 -0
- package/internals/useStore.js +17 -0
- package/modern/BarChart/AnimatedBarElement.js +21 -0
- package/modern/BarChart/BarChart.js +3 -31
- package/modern/BarChart/BarElement.js +10 -20
- package/modern/BarChart/BarPlot.js +12 -2
- package/modern/BarChart/useBarChartProps.js +2 -8
- package/modern/ChartContainer/ChartContainer.js +10 -20
- package/modern/ChartContainer/ResizableContainer.js +36 -2
- package/modern/ChartContainer/useChartContainerProps.js +14 -28
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +10 -96
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.types.js +1 -0
- package/modern/ChartsAxisHighlight/ChartsAxisHighlightPath.js +34 -0
- package/modern/ChartsAxisHighlight/ChartsXAxisHighlight.js +53 -0
- package/modern/ChartsAxisHighlight/ChartsYAxisHighlight.js +53 -0
- package/modern/ChartsAxisHighlight/chartsAxisHighlightClasses.js +6 -0
- package/modern/ChartsAxisHighlight/index.js +4 -1
- package/modern/ChartsGrid/ChartsGrid.js +1 -1
- package/modern/ChartsGrid/ChartsHorizontalGrid.js +3 -3
- package/modern/ChartsGrid/ChartsVerticalGrid.js +3 -3
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +9 -7
- package/modern/ChartsSurface/ChartsSurface.js +35 -34
- package/modern/ChartsTooltip/ChartTooltip.types.js +1 -0
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +83 -72
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +54 -44
- package/modern/ChartsTooltip/ChartsTooltip.js +161 -145
- package/modern/ChartsTooltip/ChartsTooltipContainer.js +298 -0
- package/modern/ChartsTooltip/chartsTooltipClasses.js +18 -2
- package/modern/ChartsTooltip/index.js +2 -3
- package/modern/ChartsTooltip/useAxisTooltip.js +19 -19
- package/modern/ChartsTooltip/useItemTooltip.js +5 -4
- package/modern/ChartsTooltip/utils.js +0 -8
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +47 -34
- package/modern/Gauge/Gauge.js +0 -6
- package/modern/Gauge/GaugeContainer.js +60 -61
- package/modern/LineChart/AnimatedArea.js +9 -18
- package/modern/LineChart/AnimatedLine.js +9 -20
- package/modern/LineChart/AreaPlot.js +12 -2
- package/modern/LineChart/CircleMarkElement.js +6 -5
- package/modern/LineChart/LineChart.js +3 -32
- package/modern/LineChart/LineHighlightPlot.js +6 -5
- package/modern/LineChart/LinePlot.js +12 -2
- package/modern/LineChart/MarkElement.js +6 -5
- package/modern/LineChart/useLineChartProps.js +2 -8
- package/modern/PieChart/PieChart.js +5 -37
- package/modern/PieChart/PiePlot.js +2 -2
- package/modern/ScatterChart/Scatter.js +6 -5
- package/modern/ScatterChart/ScatterChart.js +5 -32
- package/modern/ScatterChart/useScatterChartProps.js +1 -9
- package/modern/SparkLineChart/SparkLineChart.js +4 -31
- package/modern/context/ChartDataProvider/ChartDataProvider.js +30 -43
- package/modern/context/ChartDataProvider/useChartDataProviderProps.js +22 -42
- package/modern/context/DrawingAreaProvider/DrawingArea.types.js +1 -0
- package/modern/context/DrawingAreaProvider/DrawingAreaContext.js +16 -0
- package/modern/context/{DrawingProvider.js → DrawingAreaProvider/DrawingAreaProvider.js} +11 -41
- package/modern/context/DrawingAreaProvider/index.js +3 -0
- package/modern/context/InteractionProvider.js +8 -64
- package/modern/context/InteractionSelectors.js +12 -0
- package/modern/context/SizeProvider/Size.types.js +1 -0
- package/modern/context/SizeProvider/SizeContext.js +13 -0
- package/modern/context/SizeProvider/SizeProvider.js +26 -0
- package/modern/context/SizeProvider/index.js +4 -0
- package/{ChartContainer → modern/context/SizeProvider}/useChartContainerDimensions.js +11 -5
- package/modern/context/SizeProvider/useSize.js +13 -0
- package/modern/context/SvgRefProvider/SvgRef.types.js +1 -0
- package/modern/context/SvgRefProvider/SvgRefContext.js +17 -0
- package/modern/context/SvgRefProvider/SvgRefProvider.js +24 -0
- package/modern/context/SvgRefProvider/index.js +4 -0
- package/modern/context/SvgRefProvider/useSurfaceRef.js +14 -0
- package/modern/context/index.js +2 -1
- package/modern/hooks/useAxisEvents.js +32 -19
- package/modern/hooks/useChartId.js +2 -2
- package/modern/hooks/useDrawingArea.js +2 -2
- package/modern/hooks/useInteractionItemProps.js +19 -12
- package/modern/hooks/useSvgRef.js +3 -3
- package/modern/index.js +1 -1
- package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +9 -4
- package/modern/internals/index.js +3 -2
- package/modern/internals/plugins/models/index.js +1 -0
- package/modern/internals/plugins/utils/ChartStore.js +26 -0
- package/modern/internals/plugins/utils/ChartsStore.js +26 -0
- package/modern/internals/plugins/utils/selectors.js +37 -0
- package/modern/internals/useCharts.js +29 -0
- package/modern/internals/useSelector.js +6 -0
- package/modern/internals/useStore.js +17 -0
- package/node/BarChart/AnimatedBarElement.js +28 -0
- package/node/BarChart/BarChart.js +3 -31
- package/node/BarChart/BarElement.js +11 -21
- package/node/BarChart/BarPlot.js +11 -1
- package/node/BarChart/useBarChartProps.js +2 -8
- package/node/ChartContainer/ChartContainer.js +10 -20
- package/node/ChartContainer/ResizableContainer.js +39 -3
- package/node/ChartContainer/useChartContainerProps.js +14 -28
- package/node/ChartsAxisHighlight/ChartsAxisHighlight.js +12 -100
- package/node/ChartsAxisHighlight/ChartsAxisHighlight.types.js +5 -0
- package/node/ChartsAxisHighlight/ChartsAxisHighlightPath.js +40 -0
- package/node/ChartsAxisHighlight/ChartsXAxisHighlight.js +57 -0
- package/node/ChartsAxisHighlight/ChartsYAxisHighlight.js +57 -0
- package/node/ChartsAxisHighlight/chartsAxisHighlightClasses.js +14 -0
- package/node/ChartsAxisHighlight/index.js +33 -0
- package/node/ChartsGrid/ChartsGrid.js +2 -2
- package/node/ChartsGrid/ChartsHorizontalGrid.js +4 -4
- package/node/ChartsGrid/ChartsVerticalGrid.js +4 -4
- package/node/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +9 -7
- package/node/ChartsSurface/ChartsSurface.js +35 -34
- package/node/ChartsTooltip/ChartTooltip.types.js +5 -0
- package/node/ChartsTooltip/ChartsAxisTooltipContent.js +83 -73
- package/node/ChartsTooltip/ChartsItemTooltipContent.js +54 -45
- package/node/ChartsTooltip/ChartsTooltip.js +160 -144
- package/node/ChartsTooltip/ChartsTooltipContainer.js +304 -0
- package/node/ChartsTooltip/chartsTooltipClasses.js +22 -3
- package/node/ChartsTooltip/index.js +19 -28
- package/node/ChartsTooltip/useAxisTooltip.js +19 -19
- package/node/ChartsTooltip/useItemTooltip.js +5 -4
- package/node/ChartsTooltip/utils.js +0 -9
- package/node/ChartsVoronoiHandler/ChartsVoronoiHandler.js +48 -35
- package/node/Gauge/Gauge.js +0 -6
- package/node/Gauge/GaugeContainer.js +60 -61
- package/node/LineChart/AnimatedArea.js +9 -19
- package/node/LineChart/AnimatedLine.js +9 -21
- package/node/LineChart/AreaPlot.js +11 -1
- package/node/LineChart/CircleMarkElement.js +6 -5
- package/node/LineChart/LineChart.js +3 -32
- package/node/LineChart/LineHighlightPlot.js +6 -5
- package/node/LineChart/LinePlot.js +11 -1
- package/node/LineChart/MarkElement.js +6 -5
- package/node/LineChart/useLineChartProps.js +2 -8
- package/node/PieChart/PieChart.js +5 -37
- package/node/PieChart/PiePlot.js +2 -2
- package/node/ScatterChart/Scatter.js +6 -5
- package/node/ScatterChart/ScatterChart.js +5 -32
- package/node/ScatterChart/useScatterChartProps.js +1 -9
- package/node/SparkLineChart/SparkLineChart.js +4 -31
- package/node/context/ChartDataProvider/ChartDataProvider.js +30 -43
- package/node/context/ChartDataProvider/useChartDataProviderProps.js +22 -44
- package/node/context/DrawingAreaProvider/DrawingArea.types.js +5 -0
- package/node/context/DrawingAreaProvider/DrawingAreaContext.js +22 -0
- package/node/context/{DrawingProvider.js → DrawingAreaProvider/DrawingAreaProvider.js} +12 -44
- package/node/context/DrawingAreaProvider/index.js +38 -0
- package/node/context/InteractionProvider.js +9 -66
- package/node/context/InteractionSelectors.js +18 -0
- package/node/context/SizeProvider/Size.types.js +5 -0
- package/node/context/SizeProvider/SizeContext.js +20 -0
- package/node/context/SizeProvider/SizeProvider.js +29 -0
- package/node/context/SizeProvider/index.js +49 -0
- package/node/{ChartContainer → context/SizeProvider}/useChartContainerDimensions.js +11 -5
- package/node/context/SizeProvider/useSize.js +20 -0
- package/node/context/SvgRefProvider/SvgRef.types.js +5 -0
- package/node/context/SvgRefProvider/SvgRefContext.js +23 -0
- package/node/context/SvgRefProvider/SvgRefProvider.js +31 -0
- package/node/context/SvgRefProvider/index.js +49 -0
- package/node/context/SvgRefProvider/useSurfaceRef.js +20 -0
- package/node/context/index.js +10 -2
- package/node/hooks/useAxisEvents.js +33 -19
- package/node/hooks/useChartId.js +2 -2
- package/node/hooks/useDrawingArea.js +2 -2
- package/node/hooks/useInteractionItemProps.js +20 -13
- package/node/hooks/useSvgRef.js +3 -3
- package/node/index.js +1 -1
- package/node/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +9 -4
- package/node/internals/index.js +28 -16
- package/node/internals/plugins/models/index.js +5 -0
- package/node/internals/plugins/utils/ChartStore.js +33 -0
- package/node/internals/plugins/utils/ChartsStore.js +33 -0
- package/node/internals/plugins/utils/selectors.js +44 -0
- package/node/internals/useCharts.js +36 -0
- package/node/internals/useSelector.js +13 -0
- package/node/internals/useStore.js +24 -0
- package/package.json +7 -5
- package/themeAugmentation/props.d.ts +1 -2
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.d.ts +0 -7
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -123
- package/ChartsTooltip/DefaultChartsItemTooltipContent.d.ts +0 -8
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -92
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -123
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -92
- package/node/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -129
- package/node/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -98
- /package/ChartsGrid/{styledCommonents.d.ts → styledComponents.d.ts} +0 -0
- /package/ChartsGrid/{styledCommonents.js → styledComponents.js} +0 -0
- /package/modern/ChartsGrid/{styledCommonents.js → styledComponents.js} +0 -0
- /package/node/ChartsGrid/{styledCommonents.js → styledComponents.js} +0 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
+
const _excluded = ["trigger", "classes", "children"];
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import useLazyRef from '@mui/utils/useLazyRef';
|
|
9
|
+
import { styled, useThemeProps } from '@mui/material/styles';
|
|
10
|
+
import Popper from '@mui/material/Popper';
|
|
11
|
+
import NoSsr from '@mui/material/NoSsr';
|
|
12
|
+
import { useSvgRef } from "../hooks/useSvgRef.js";
|
|
13
|
+
import { usePointerType } from "./utils.js";
|
|
14
|
+
import { useSelector } from "../internals/useSelector.js";
|
|
15
|
+
import { useStore } from "../internals/useStore.js";
|
|
16
|
+
import { useXAxis } from "../hooks/index.js";
|
|
17
|
+
import { selectorChartsInteractionItemIsDefined, selectorChartsInteractionXAxisIsDefined, selectorChartsInteractionYAxisIsDefined } from "../context/InteractionSelectors.js";
|
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
const ChartsTooltipRoot = styled(Popper, {
|
|
20
|
+
name: 'MuiChartsTooltip',
|
|
21
|
+
slot: 'Root',
|
|
22
|
+
overridesResolver: (_, styles) => styles.root
|
|
23
|
+
})(({
|
|
24
|
+
theme
|
|
25
|
+
}) => ({
|
|
26
|
+
pointerEvents: 'none',
|
|
27
|
+
zIndex: theme.zIndex.modal
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Demos:
|
|
32
|
+
*
|
|
33
|
+
* - [ChartsTooltip](https://mui.com/x/react-charts/tooltip/)
|
|
34
|
+
*
|
|
35
|
+
* API:
|
|
36
|
+
*
|
|
37
|
+
* - [ChartsTooltip API](https://mui.com/x/api/charts/charts-tool-tip/)
|
|
38
|
+
*/
|
|
39
|
+
function ChartsTooltipContainer(inProps) {
|
|
40
|
+
const props = useThemeProps({
|
|
41
|
+
props: inProps,
|
|
42
|
+
name: 'MuiChartsTooltipContainer'
|
|
43
|
+
});
|
|
44
|
+
const {
|
|
45
|
+
trigger = 'axis',
|
|
46
|
+
classes,
|
|
47
|
+
children
|
|
48
|
+
} = props,
|
|
49
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
50
|
+
const svgRef = useSvgRef();
|
|
51
|
+
const pointerType = usePointerType();
|
|
52
|
+
const xAxis = useXAxis();
|
|
53
|
+
const xAxisHasData = xAxis.data !== undefined && xAxis.data.length !== 0;
|
|
54
|
+
const popperRef = React.useRef(null);
|
|
55
|
+
const positionRef = useLazyRef(() => ({
|
|
56
|
+
x: 0,
|
|
57
|
+
y: 0
|
|
58
|
+
}));
|
|
59
|
+
const store = useStore();
|
|
60
|
+
const isOpen = useSelector(store,
|
|
61
|
+
// eslint-disable-next-line no-nested-ternary
|
|
62
|
+
trigger === 'axis' ? xAxisHasData ? selectorChartsInteractionXAxisIsDefined : selectorChartsInteractionYAxisIsDefined : selectorChartsInteractionItemIsDefined);
|
|
63
|
+
const popperOpen = pointerType !== null && isOpen; // tooltipHasData;
|
|
64
|
+
|
|
65
|
+
React.useEffect(() => {
|
|
66
|
+
const element = svgRef.current;
|
|
67
|
+
if (element === null) {
|
|
68
|
+
return () => {};
|
|
69
|
+
}
|
|
70
|
+
const handleMove = event => {
|
|
71
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
72
|
+
positionRef.current = {
|
|
73
|
+
x: event.clientX,
|
|
74
|
+
y: event.clientY
|
|
75
|
+
};
|
|
76
|
+
popperRef.current?.update();
|
|
77
|
+
};
|
|
78
|
+
element.addEventListener('pointermove', handleMove);
|
|
79
|
+
return () => {
|
|
80
|
+
element.removeEventListener('pointermove', handleMove);
|
|
81
|
+
};
|
|
82
|
+
}, [svgRef, positionRef]);
|
|
83
|
+
if (trigger === 'none') {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return /*#__PURE__*/_jsx(NoSsr, {
|
|
87
|
+
children: popperOpen && /*#__PURE__*/_jsx(ChartsTooltipRoot, _extends({
|
|
88
|
+
className: classes?.root,
|
|
89
|
+
open: popperOpen,
|
|
90
|
+
placement: pointerType?.pointerType === 'mouse' ? 'right-start' : 'top',
|
|
91
|
+
popperRef: popperRef,
|
|
92
|
+
anchorEl: {
|
|
93
|
+
getBoundingClientRect: () => ({
|
|
94
|
+
x: positionRef.current.x,
|
|
95
|
+
y: positionRef.current.y,
|
|
96
|
+
top: positionRef.current.y,
|
|
97
|
+
left: positionRef.current.x,
|
|
98
|
+
right: positionRef.current.x,
|
|
99
|
+
bottom: positionRef.current.y,
|
|
100
|
+
width: 0,
|
|
101
|
+
height: 0,
|
|
102
|
+
toJSON: () => ''
|
|
103
|
+
})
|
|
104
|
+
},
|
|
105
|
+
modifiers: [{
|
|
106
|
+
name: 'offset',
|
|
107
|
+
options: {
|
|
108
|
+
offset: [0, pointerType?.pointerType === 'touch' ? 40 - pointerType.height : 0]
|
|
109
|
+
}
|
|
110
|
+
}]
|
|
111
|
+
}, other, {
|
|
112
|
+
children: children
|
|
113
|
+
}))
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
process.env.NODE_ENV !== "production" ? ChartsTooltipContainer.propTypes = {
|
|
117
|
+
// ----------------------------- Warning --------------------------------
|
|
118
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
119
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
120
|
+
// ----------------------------------------------------------------------
|
|
121
|
+
/**
|
|
122
|
+
* An HTML element, [virtualElement](https://popper.js.org/docs/v2/virtual-elements/),
|
|
123
|
+
* or a function that returns either.
|
|
124
|
+
* It's used to set the position of the popper.
|
|
125
|
+
* The return value will passed as the reference object of the Popper instance.
|
|
126
|
+
*/
|
|
127
|
+
anchorEl: PropTypes.oneOfType([(props, propName) => {
|
|
128
|
+
if (props[propName] == null) {
|
|
129
|
+
return new Error(`Prop '${propName}' is required but wasn't specified`);
|
|
130
|
+
}
|
|
131
|
+
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
132
|
+
return new Error(`Expected prop '${propName}' to be of type Element`);
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}, PropTypes.func, PropTypes.shape({
|
|
136
|
+
contextElement: (props, propName) => {
|
|
137
|
+
if (props[propName] == null) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
141
|
+
return new Error(`Expected prop '${propName}' to be of type Element`);
|
|
142
|
+
}
|
|
143
|
+
return null;
|
|
144
|
+
},
|
|
145
|
+
getBoundingClientRect: PropTypes.func.isRequired
|
|
146
|
+
})]),
|
|
147
|
+
/**
|
|
148
|
+
* Popper render function or node.
|
|
149
|
+
*/
|
|
150
|
+
children: PropTypes.node,
|
|
151
|
+
/**
|
|
152
|
+
* Override or extend the styles applied to the component.
|
|
153
|
+
*/
|
|
154
|
+
classes: PropTypes.object,
|
|
155
|
+
/**
|
|
156
|
+
* The component used for the root node.
|
|
157
|
+
* Either a string to use a HTML element or a component.
|
|
158
|
+
*/
|
|
159
|
+
component: PropTypes.elementType,
|
|
160
|
+
/**
|
|
161
|
+
* The components used for each slot inside the Popper.
|
|
162
|
+
* Either a string to use a HTML element or a component.
|
|
163
|
+
* @default {}
|
|
164
|
+
*/
|
|
165
|
+
components: PropTypes.shape({
|
|
166
|
+
Root: PropTypes.elementType
|
|
167
|
+
}),
|
|
168
|
+
/**
|
|
169
|
+
* The props used for each slot inside the Popper.
|
|
170
|
+
* @default {}
|
|
171
|
+
*/
|
|
172
|
+
componentsProps: PropTypes.shape({
|
|
173
|
+
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
174
|
+
}),
|
|
175
|
+
/**
|
|
176
|
+
* An HTML element or function that returns one.
|
|
177
|
+
* The `container` will have the portal children appended to it.
|
|
178
|
+
*
|
|
179
|
+
* You can also provide a callback, which is called in a React layout effect.
|
|
180
|
+
* This lets you set the container from a ref, and also makes server-side rendering possible.
|
|
181
|
+
*
|
|
182
|
+
* By default, it uses the body of the top-level document object,
|
|
183
|
+
* so it's simply `document.body` most of the time.
|
|
184
|
+
*/
|
|
185
|
+
container: PropTypes.oneOfType([(props, propName) => {
|
|
186
|
+
if (props[propName] == null) {
|
|
187
|
+
return new Error(`Prop '${propName}' is required but wasn't specified`);
|
|
188
|
+
}
|
|
189
|
+
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
190
|
+
return new Error(`Expected prop '${propName}' to be of type Element`);
|
|
191
|
+
}
|
|
192
|
+
return null;
|
|
193
|
+
}, PropTypes.func]),
|
|
194
|
+
/**
|
|
195
|
+
* The `children` will be under the DOM hierarchy of the parent component.
|
|
196
|
+
* @default false
|
|
197
|
+
*/
|
|
198
|
+
disablePortal: PropTypes.bool,
|
|
199
|
+
/**
|
|
200
|
+
* Always keep the children in the DOM.
|
|
201
|
+
* This prop can be useful in SEO situation or
|
|
202
|
+
* when you want to maximize the responsiveness of the Popper.
|
|
203
|
+
* @default false
|
|
204
|
+
*/
|
|
205
|
+
keepMounted: PropTypes.bool,
|
|
206
|
+
/**
|
|
207
|
+
* Popper.js is based on a "plugin-like" architecture,
|
|
208
|
+
* most of its features are fully encapsulated "modifiers".
|
|
209
|
+
*
|
|
210
|
+
* A modifier is a function that is called each time Popper.js needs to
|
|
211
|
+
* compute the position of the popper.
|
|
212
|
+
* For this reason, modifiers should be very performant to avoid bottlenecks.
|
|
213
|
+
* To learn how to create a modifier, [read the modifiers documentation](https://popper.js.org/docs/v2/modifiers/).
|
|
214
|
+
*/
|
|
215
|
+
modifiers: PropTypes.arrayOf(PropTypes.shape({
|
|
216
|
+
data: PropTypes.object,
|
|
217
|
+
effect: PropTypes.func,
|
|
218
|
+
enabled: PropTypes.bool,
|
|
219
|
+
fn: PropTypes.func,
|
|
220
|
+
name: PropTypes.any,
|
|
221
|
+
options: PropTypes.object,
|
|
222
|
+
phase: PropTypes.oneOf(['afterMain', 'afterRead', 'afterWrite', 'beforeMain', 'beforeRead', 'beforeWrite', 'main', 'read', 'write']),
|
|
223
|
+
requires: PropTypes.arrayOf(PropTypes.string),
|
|
224
|
+
requiresIfExists: PropTypes.arrayOf(PropTypes.string)
|
|
225
|
+
})),
|
|
226
|
+
/**
|
|
227
|
+
* If `true`, the component is shown.
|
|
228
|
+
*/
|
|
229
|
+
open: PropTypes.bool,
|
|
230
|
+
/**
|
|
231
|
+
* Popper placement.
|
|
232
|
+
* @default 'bottom'
|
|
233
|
+
*/
|
|
234
|
+
placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
|
|
235
|
+
/**
|
|
236
|
+
* Options provided to the [`Popper.js`](https://popper.js.org/docs/v2/constructors/#options) instance.
|
|
237
|
+
* @default {}
|
|
238
|
+
*/
|
|
239
|
+
popperOptions: PropTypes.shape({
|
|
240
|
+
modifiers: PropTypes.array,
|
|
241
|
+
onFirstUpdate: PropTypes.func,
|
|
242
|
+
placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
|
|
243
|
+
strategy: PropTypes.oneOf(['absolute', 'fixed'])
|
|
244
|
+
}),
|
|
245
|
+
/**
|
|
246
|
+
* A ref that points to the used popper instance.
|
|
247
|
+
*/
|
|
248
|
+
popperRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
249
|
+
current: PropTypes.shape({
|
|
250
|
+
destroy: PropTypes.func.isRequired,
|
|
251
|
+
forceUpdate: PropTypes.func.isRequired,
|
|
252
|
+
setOptions: PropTypes.func.isRequired,
|
|
253
|
+
state: PropTypes.shape({
|
|
254
|
+
attributes: PropTypes.object.isRequired,
|
|
255
|
+
elements: PropTypes.object.isRequired,
|
|
256
|
+
modifiersData: PropTypes.object.isRequired,
|
|
257
|
+
options: PropTypes.object.isRequired,
|
|
258
|
+
orderedModifiers: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
259
|
+
placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']).isRequired,
|
|
260
|
+
rects: PropTypes.object.isRequired,
|
|
261
|
+
reset: PropTypes.bool.isRequired,
|
|
262
|
+
scrollParents: PropTypes.object.isRequired,
|
|
263
|
+
strategy: PropTypes.oneOf(['absolute', 'fixed']).isRequired,
|
|
264
|
+
styles: PropTypes.object.isRequired
|
|
265
|
+
}).isRequired,
|
|
266
|
+
update: PropTypes.func.isRequired
|
|
267
|
+
})
|
|
268
|
+
})]),
|
|
269
|
+
/**
|
|
270
|
+
* The props used for each slot inside the Popper.
|
|
271
|
+
* @default {}
|
|
272
|
+
*/
|
|
273
|
+
slotProps: PropTypes.object,
|
|
274
|
+
/**
|
|
275
|
+
* The components used for each slot inside the Popper.
|
|
276
|
+
* Either a string to use a HTML element or a component.
|
|
277
|
+
* @default {}
|
|
278
|
+
*/
|
|
279
|
+
slots: PropTypes.object,
|
|
280
|
+
/**
|
|
281
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
282
|
+
*/
|
|
283
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
284
|
+
/**
|
|
285
|
+
* Help supporting a react-transition-group/Transition component.
|
|
286
|
+
* @default false
|
|
287
|
+
*/
|
|
288
|
+
transition: PropTypes.bool,
|
|
289
|
+
/**
|
|
290
|
+
* Select the kind of tooltip to display
|
|
291
|
+
* - 'item': Shows data about the item below the mouse.
|
|
292
|
+
* - 'axis': Shows values associated with the hovered x value
|
|
293
|
+
* - 'none': Does not display tooltip
|
|
294
|
+
* @default 'axis'
|
|
295
|
+
*/
|
|
296
|
+
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
297
|
+
} : void 0;
|
|
298
|
+
export { ChartsTooltipContainer };
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
3
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
2
4
|
export function getChartsTooltipUtilityClass(slot) {
|
|
3
5
|
return generateUtilityClass('MuiChartsTooltip', slot);
|
|
4
6
|
}
|
|
5
|
-
export const chartsTooltipClasses = generateUtilityClasses('MuiChartsTooltip', ['root', 'paper', 'table', 'row', 'cell', 'mark', 'markCell', 'labelCell', 'valueCell']);
|
|
7
|
+
export const chartsTooltipClasses = generateUtilityClasses('MuiChartsTooltip', ['root', 'paper', 'table', 'row', 'cell', 'mark', 'markCell', 'labelCell', 'valueCell']);
|
|
8
|
+
export const useUtilityClasses = classes => {
|
|
9
|
+
const slots = {
|
|
10
|
+
root: ['root'],
|
|
11
|
+
paper: ['paper'],
|
|
12
|
+
table: ['table'],
|
|
13
|
+
row: ['row'],
|
|
14
|
+
cell: ['cell'],
|
|
15
|
+
mark: ['mark'],
|
|
16
|
+
markCell: ['markCell'],
|
|
17
|
+
labelCell: ['labelCell'],
|
|
18
|
+
valueCell: ['valueCell']
|
|
19
|
+
};
|
|
20
|
+
return composeClasses(slots, getChartsTooltipUtilityClass, classes);
|
|
21
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export * from "./ChartsTooltip.js";
|
|
2
|
-
export * from "./
|
|
2
|
+
export * from "./ChartsTooltipContainer.js";
|
|
3
|
+
export { getChartsTooltipUtilityClass, chartsTooltipClasses } from "./chartsTooltipClasses.js";
|
|
3
4
|
export * from "./ChartsAxisTooltipContent.js";
|
|
4
5
|
export * from "./ChartsItemTooltipContent.js";
|
|
5
|
-
export * from "./DefaultChartsAxisTooltipContent.js";
|
|
6
|
-
export * from "./DefaultChartsItemTooltipContent.js";
|
|
7
6
|
export * from "./ChartsTooltipTable.js";
|
|
8
7
|
export * from "./useItemTooltip.js";
|
|
9
8
|
export * from "./useAxisTooltip.js";
|
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { InteractionContext } from "../context/InteractionProvider.js";
|
|
5
4
|
import { useSeries } from "../hooks/useSeries.js";
|
|
6
5
|
import { useCartesianContext } from "../context/CartesianProvider/index.js";
|
|
7
6
|
import { ZAxisContext } from "../context/ZAxisContextProvider.js";
|
|
8
7
|
import { useColorProcessor } from "../context/PluginProvider/useColorProcessor.js";
|
|
8
|
+
import { useStore } from "../internals/useStore.js";
|
|
9
|
+
import { useSelector } from "../internals/useSelector.js";
|
|
9
10
|
import { getLabel } from "../internals/getLabel.js";
|
|
10
11
|
import { isCartesianSeriesType } from "../internals/isCartesian.js";
|
|
11
12
|
import { utcFormatter } from "./utils.js";
|
|
13
|
+
import { useXAxis, useYAxis } from "../hooks/useAxis.js";
|
|
14
|
+
import { selectorChartsInteractionXAxis, selectorChartsInteractionYAxis } from "../context/InteractionSelectors.js";
|
|
12
15
|
export function useAxisTooltip() {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const defaultXAxis = useXAxis();
|
|
17
|
+
const defaultYAxis = useYAxis();
|
|
18
|
+
const xAxisHasData = defaultXAxis.data !== undefined && defaultXAxis.data.length !== 0;
|
|
19
|
+
const store = useStore();
|
|
20
|
+
const axisData = useSelector(store, xAxisHasData ? selectorChartsInteractionXAxis : selectorChartsInteractionYAxis);
|
|
16
21
|
const series = useSeries();
|
|
17
22
|
const {
|
|
18
23
|
xAxis,
|
|
19
|
-
yAxis
|
|
20
|
-
xAxisIds,
|
|
21
|
-
yAxisIds
|
|
24
|
+
yAxis
|
|
22
25
|
} = useCartesianContext();
|
|
23
26
|
const {
|
|
24
27
|
zAxis,
|
|
25
28
|
zAxisIds
|
|
26
29
|
} = React.useContext(ZAxisContext);
|
|
27
30
|
const colorProcessors = useColorProcessor();
|
|
28
|
-
|
|
29
|
-
// By default use the x-axis
|
|
30
|
-
const isXaxis = axis.x !== null && axis.x.index !== -1;
|
|
31
|
-
const axisData = isXaxis ? axis.x && axis.x : axis.y && axis.y;
|
|
32
31
|
if (axisData === null) {
|
|
33
32
|
return null;
|
|
34
33
|
}
|
|
@@ -36,8 +35,8 @@ export function useAxisTooltip() {
|
|
|
36
35
|
index: dataIndex,
|
|
37
36
|
value: axisValue
|
|
38
37
|
} = axisData;
|
|
39
|
-
const USED_AXIS_ID =
|
|
40
|
-
const usedAxis =
|
|
38
|
+
const USED_AXIS_ID = xAxisHasData ? defaultXAxis.id : defaultYAxis.id;
|
|
39
|
+
const usedAxis = xAxisHasData ? defaultXAxis : defaultYAxis;
|
|
41
40
|
const relevantSeries = Object.keys(series).filter(isCartesianSeriesType).flatMap(seriesType => {
|
|
42
41
|
const seriesOfType = series[seriesType];
|
|
43
42
|
if (!seriesOfType) {
|
|
@@ -47,14 +46,14 @@ export function useAxisTooltip() {
|
|
|
47
46
|
const seriesToAdd = seriesOfType.series[seriesId];
|
|
48
47
|
const providedXAxisId = seriesToAdd.xAxisId;
|
|
49
48
|
const providedYAxisId = seriesToAdd.yAxisId;
|
|
50
|
-
const axisKey =
|
|
49
|
+
const axisKey = xAxisHasData ? providedXAxisId : providedYAxisId;
|
|
51
50
|
|
|
52
51
|
// Test if the series uses the default axis
|
|
53
52
|
if (axisKey === undefined || axisKey === USED_AXIS_ID) {
|
|
54
|
-
const xAxisId = providedXAxisId ??
|
|
55
|
-
const yAxisId = providedYAxisId ??
|
|
56
|
-
const zAxisId = seriesToAdd.zAxisId
|
|
57
|
-
const color = colorProcessors[seriesType]?.(seriesToAdd, xAxis[xAxisId], yAxis[yAxisId], zAxisId
|
|
53
|
+
const xAxisId = providedXAxisId ?? defaultXAxis.id;
|
|
54
|
+
const yAxisId = providedYAxisId ?? defaultYAxis.id;
|
|
55
|
+
const zAxisId = 'zAxisId' in seriesToAdd ? seriesToAdd.zAxisId : zAxisIds[0];
|
|
56
|
+
const color = colorProcessors[seriesType]?.(seriesToAdd, xAxis[xAxisId], yAxis[yAxisId], zAxisId ? zAxis[zAxisId] : undefined)(dataIndex) ?? '';
|
|
58
57
|
const value = seriesToAdd.data[dataIndex] ?? null;
|
|
59
58
|
const formattedValue = seriesToAdd.valueFormatter(value, {
|
|
60
59
|
dataIndex
|
|
@@ -76,7 +75,8 @@ export function useAxisTooltip() {
|
|
|
76
75
|
location: 'tooltip'
|
|
77
76
|
});
|
|
78
77
|
return {
|
|
79
|
-
|
|
78
|
+
axisDirection: xAxisHasData ? 'x' : 'y',
|
|
79
|
+
dataIndex,
|
|
80
80
|
seriesItems: relevantSeries,
|
|
81
81
|
axisValue,
|
|
82
82
|
axisFormattedValue
|
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import { InteractionContext } from "../context/InteractionProvider.js";
|
|
6
5
|
import { useSeries } from "../hooks/useSeries.js";
|
|
7
6
|
import { useCartesianContext } from "../context/CartesianProvider/index.js";
|
|
8
7
|
import { ZAxisContext } from "../context/ZAxisContextProvider.js";
|
|
9
8
|
import { useColorProcessor } from "../context/PluginProvider/useColorProcessor.js";
|
|
10
9
|
import { getLabel } from "../internals/getLabel.js";
|
|
10
|
+
import { selectorChartsInteractionItem } from "../context/InteractionSelectors.js";
|
|
11
|
+
import { useSelector } from "../internals/useSelector.js";
|
|
12
|
+
import { useStore } from "../internals/useStore.js";
|
|
11
13
|
export function useItemTooltip() {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
} = React.useContext(InteractionContext);
|
|
14
|
+
const store = useStore();
|
|
15
|
+
const item = useSelector(store, selectorChartsInteractionItem);
|
|
15
16
|
const series = useSeries();
|
|
16
17
|
const {
|
|
17
18
|
xAxis,
|
|
@@ -74,14 +74,6 @@ export function usePointerType() {
|
|
|
74
74
|
}, [svgRef]);
|
|
75
75
|
return pointerType;
|
|
76
76
|
}
|
|
77
|
-
export function getTooltipHasData(trigger, displayedData) {
|
|
78
|
-
if (trigger === 'item') {
|
|
79
|
-
return displayedData !== null;
|
|
80
|
-
}
|
|
81
|
-
const hasAxisXData = displayedData.x !== null;
|
|
82
|
-
const hasAxisYData = displayedData.y !== null;
|
|
83
|
-
return hasAxisXData || hasAxisYData;
|
|
84
|
-
}
|
|
85
77
|
export function utcFormatter(v) {
|
|
86
78
|
if (v instanceof Date) {
|
|
87
79
|
return v.toUTCString();
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
import PropTypes from 'prop-types';
|
|
5
6
|
import { Delaunay } from '@mui/x-charts-vendor/d3-delaunay';
|
|
6
7
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
7
|
-
import { InteractionContext } from "../context/InteractionProvider.js";
|
|
8
8
|
import { useCartesianContext } from "../context/CartesianProvider/index.js";
|
|
9
9
|
import { getValueToPositionMapper } from "../hooks/useScale.js";
|
|
10
|
+
import { useStore } from "../internals/useStore.js";
|
|
10
11
|
import { getSVGPoint } from "../internals/getSVGPoint.js";
|
|
11
12
|
import { useDrawingArea, useSvgRef } from "../hooks/index.js";
|
|
12
13
|
import { useHighlighted } from "../context/index.js";
|
|
@@ -25,9 +26,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
25
26
|
xAxisIds,
|
|
26
27
|
yAxisIds
|
|
27
28
|
} = useCartesianContext();
|
|
28
|
-
const
|
|
29
|
-
dispatch
|
|
30
|
-
} = React.useContext(InteractionContext);
|
|
29
|
+
const store = useStore();
|
|
31
30
|
const {
|
|
32
31
|
series,
|
|
33
32
|
seriesOrder
|
|
@@ -42,17 +41,19 @@ function ChartsVoronoiHandler(props) {
|
|
|
42
41
|
const defaultXAxisId = xAxisIds[0];
|
|
43
42
|
const defaultYAxisId = yAxisIds[0];
|
|
44
43
|
useEnhancedEffect(() => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
store.update(prev => _extends({}, prev, {
|
|
45
|
+
interaction: _extends({}, prev.interaction, {
|
|
46
|
+
useVoronoiInteraction: true
|
|
47
|
+
})
|
|
48
|
+
}));
|
|
49
49
|
return () => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
store.update(prev => _extends({}, prev, {
|
|
51
|
+
interaction: _extends({}, prev.interaction, {
|
|
52
|
+
useVoronoiInteraction: false
|
|
53
|
+
})
|
|
54
|
+
}));
|
|
54
55
|
};
|
|
55
|
-
}, [
|
|
56
|
+
}, [store]);
|
|
56
57
|
useEnhancedEffect(() => {
|
|
57
58
|
// This effect generate and store the Delaunay object that's used to map coordinate to closest point.
|
|
58
59
|
|
|
@@ -141,27 +142,38 @@ function ChartsVoronoiHandler(props) {
|
|
|
141
142
|
};
|
|
142
143
|
}
|
|
143
144
|
const handleMouseLeave = () => {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
store.update(prev => _extends({}, prev, {
|
|
146
|
+
interaction: _extends({}, prev.interaction, {
|
|
147
|
+
axis: {
|
|
148
|
+
x: null,
|
|
149
|
+
y: null
|
|
150
|
+
},
|
|
151
|
+
item: null
|
|
152
|
+
})
|
|
153
|
+
}));
|
|
147
154
|
clearHighlighted();
|
|
148
155
|
};
|
|
149
156
|
const handleMouseMove = event => {
|
|
150
157
|
const closestPoint = getClosestPoint(event);
|
|
151
158
|
if (closestPoint === 'outside-chart') {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
159
|
+
store.update(prev => _extends({}, prev, {
|
|
160
|
+
interaction: _extends({}, prev.interaction, {
|
|
161
|
+
axis: {
|
|
162
|
+
x: null,
|
|
163
|
+
y: null
|
|
164
|
+
},
|
|
165
|
+
item: null
|
|
166
|
+
})
|
|
167
|
+
}));
|
|
155
168
|
clearHighlighted();
|
|
156
169
|
return;
|
|
157
170
|
}
|
|
158
171
|
if (closestPoint === 'outside-voronoi-max-radius' || closestPoint === 'no-point-found') {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
});
|
|
172
|
+
store.update(prev => _extends({}, prev, {
|
|
173
|
+
interaction: _extends({}, prev.interaction, {
|
|
174
|
+
item: null
|
|
175
|
+
})
|
|
176
|
+
}));
|
|
165
177
|
clearHighlighted();
|
|
166
178
|
return;
|
|
167
179
|
}
|
|
@@ -169,14 +181,15 @@ function ChartsVoronoiHandler(props) {
|
|
|
169
181
|
seriesId,
|
|
170
182
|
dataIndex
|
|
171
183
|
} = closestPoint;
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
184
|
+
store.update(prev => _extends({}, prev, {
|
|
185
|
+
interaction: _extends({}, prev.interaction, {
|
|
186
|
+
item: {
|
|
187
|
+
type: 'scatter',
|
|
188
|
+
seriesId,
|
|
189
|
+
dataIndex
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
}));
|
|
180
193
|
setHighlighted({
|
|
181
194
|
seriesId,
|
|
182
195
|
dataIndex
|
|
@@ -209,7 +222,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
209
222
|
element.removeEventListener('pointermove', handleMouseMove);
|
|
210
223
|
element.removeEventListener('click', handleMouseClick);
|
|
211
224
|
};
|
|
212
|
-
}, [svgRef,
|
|
225
|
+
}, [svgRef, yAxis, xAxis, voronoiMaxRadius, onItemClick, setHighlighted, clearHighlighted, drawingArea, store]);
|
|
213
226
|
|
|
214
227
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
215
228
|
return /*#__PURE__*/_jsx(React.Fragment, {});
|
package/modern/Gauge/Gauge.js
CHANGED
|
@@ -137,12 +137,6 @@ process.env.NODE_ENV !== "production" ? Gauge.propTypes = {
|
|
|
137
137
|
* @default 0
|
|
138
138
|
*/
|
|
139
139
|
valueMin: PropTypes.number,
|
|
140
|
-
viewBox: PropTypes.shape({
|
|
141
|
-
height: PropTypes.number,
|
|
142
|
-
width: PropTypes.number,
|
|
143
|
-
x: PropTypes.number,
|
|
144
|
-
y: PropTypes.number
|
|
145
|
-
}),
|
|
146
140
|
/**
|
|
147
141
|
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
148
142
|
*/
|