@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,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { SizeContext } from "./SizeContext.js";
|
|
5
|
+
import { useChartContainerDimensions } from "./useChartContainerDimensions.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The size provider.
|
|
9
|
+
*
|
|
10
|
+
* This differs from the DrawingProvider in that it provides the full size of the container.
|
|
11
|
+
*
|
|
12
|
+
* This provider is also responsible for resolving the size of the container before rendering and if the parent size changes.
|
|
13
|
+
*/
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
function SizeProvider(props) {
|
|
16
|
+
const dimensions = useChartContainerDimensions(props.width, props.height);
|
|
17
|
+
const value = React.useMemo(() => ({
|
|
18
|
+
isInitialized: true,
|
|
19
|
+
data: dimensions
|
|
20
|
+
}), [dimensions]);
|
|
21
|
+
return /*#__PURE__*/_jsx(SizeContext.Provider, {
|
|
22
|
+
value: value,
|
|
23
|
+
children: props.children
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export { SizeProvider };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export declare const useChartContainerDimensions: (inWidth?: number, inHeight?: number
|
|
2
|
+
export declare const useChartContainerDimensions: (inWidth?: number, inHeight?: number) => {
|
|
3
3
|
containerRef: React.RefObject<HTMLDivElement>;
|
|
4
4
|
width: number;
|
|
5
5
|
height: number;
|
|
6
|
+
hasIntrinsicSize: boolean;
|
|
7
|
+
inWidth: number | undefined;
|
|
8
|
+
inHeight: number | undefined;
|
|
6
9
|
};
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
6
6
|
import ownerWindow from '@mui/utils/ownerWindow';
|
|
7
|
-
|
|
7
|
+
const MAX_COMPUTE_RUN = 10;
|
|
8
|
+
export const useChartContainerDimensions = (inWidth, inHeight) => {
|
|
8
9
|
const hasInSize = inWidth !== undefined && inHeight !== undefined;
|
|
9
10
|
const stateRef = React.useRef({
|
|
10
11
|
displayError: false,
|
|
@@ -42,7 +43,7 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
|
|
|
42
43
|
// https://github.com/mui/mui-x/issues/13477#issuecomment-2336634785
|
|
43
44
|
useEnhancedEffect(() => {
|
|
44
45
|
// computeRun is used to avoid infinite loops.
|
|
45
|
-
if (hasInSize || !
|
|
46
|
+
if (hasInSize || !stateRef.current.initialCompute || stateRef.current.computeRun > MAX_COMPUTE_RUN) {
|
|
46
47
|
return;
|
|
47
48
|
}
|
|
48
49
|
const computedSize = computeSize();
|
|
@@ -51,7 +52,7 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
|
|
|
51
52
|
} else if (stateRef.current.initialCompute) {
|
|
52
53
|
stateRef.current.initialCompute = false;
|
|
53
54
|
}
|
|
54
|
-
}, [width, height, computeSize,
|
|
55
|
+
}, [width, height, computeSize, hasInSize]);
|
|
55
56
|
useEnhancedEffect(() => {
|
|
56
57
|
if (hasInSize) {
|
|
57
58
|
return () => {};
|
|
@@ -90,9 +91,14 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
|
|
|
90
91
|
stateRef.current.displayError = false;
|
|
91
92
|
}
|
|
92
93
|
}
|
|
94
|
+
const finalWidth = inWidth ?? width;
|
|
95
|
+
const finalHeight = inHeight ?? height;
|
|
93
96
|
return {
|
|
94
97
|
containerRef: rootRef,
|
|
95
|
-
width:
|
|
96
|
-
height:
|
|
98
|
+
width: finalWidth,
|
|
99
|
+
height: finalHeight,
|
|
100
|
+
hasIntrinsicSize: finalWidth > 0 && finalHeight > 0,
|
|
101
|
+
inWidth,
|
|
102
|
+
inHeight
|
|
97
103
|
};
|
|
98
104
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { SizeContext } from "./SizeContext.js";
|
|
5
|
+
/**
|
|
6
|
+
* Returns the size of the chart. And the ref of the container element that the chart is rendered in.
|
|
7
|
+
*/
|
|
8
|
+
export const useSize = () => {
|
|
9
|
+
const {
|
|
10
|
+
data
|
|
11
|
+
} = React.useContext(SizeContext);
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
export const SvgRefContext = /*#__PURE__*/React.createContext({
|
|
5
|
+
isInitialized: false,
|
|
6
|
+
data: {
|
|
7
|
+
svgRef: {
|
|
8
|
+
current: null
|
|
9
|
+
},
|
|
10
|
+
surfaceRef: {
|
|
11
|
+
current: null
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
16
|
+
SvgRefContext.displayName = 'SvgRefContext';
|
|
17
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
5
|
+
import { SvgRefContext } from "./SvgRefContext.js";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
export function SvgRefProvider(props) {
|
|
8
|
+
const {
|
|
9
|
+
children
|
|
10
|
+
} = props;
|
|
11
|
+
const svgRef = React.useRef(null);
|
|
12
|
+
const surfaceRef = useForkRef(svgRef);
|
|
13
|
+
const refValue = React.useMemo(() => ({
|
|
14
|
+
isInitialized: true,
|
|
15
|
+
data: {
|
|
16
|
+
svgRef,
|
|
17
|
+
surfaceRef
|
|
18
|
+
}
|
|
19
|
+
}), [svgRef, surfaceRef]);
|
|
20
|
+
return /*#__PURE__*/_jsx(SvgRefContext.Provider, {
|
|
21
|
+
value: refValue,
|
|
22
|
+
children: children
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { SvgRefContext } from "./SvgRefContext.js";
|
|
5
|
+
export function useSurfaceRef() {
|
|
6
|
+
const {
|
|
7
|
+
isInitialized,
|
|
8
|
+
data
|
|
9
|
+
} = React.useContext(SvgRefContext);
|
|
10
|
+
if (!isInitialized) {
|
|
11
|
+
throw new Error(['MUI X: Could not find the svg ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
12
|
+
}
|
|
13
|
+
return data.surfaceRef;
|
|
14
|
+
}
|
package/context/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export * from './HighlightedProvider';
|
|
2
2
|
export { ZAxisContextProvider } from './ZAxisContextProvider';
|
|
3
3
|
export type { ZAxisContextProviderProps } from './ZAxisContextProvider';
|
|
4
|
+
export { ChartDataProvider } from './ChartDataProvider';
|
|
5
|
+
export type { ChartDataProviderProps } from './ChartDataProvider';
|
package/context/index.js
CHANGED
package/hooks/useAxisEvents.js
CHANGED
|
@@ -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
|
-
import { InteractionContext } from "../context/InteractionProvider.js";
|
|
5
5
|
import { useCartesianContext } from "../context/CartesianProvider/index.js";
|
|
6
6
|
import { isBandScale } from "../internals/isBandScale.js";
|
|
7
7
|
import { getSVGPoint } from "../internals/getSVGPoint.js";
|
|
8
8
|
import { useSvgRef } from "./useSvgRef.js";
|
|
9
9
|
import { useDrawingArea } from "./useDrawingArea.js";
|
|
10
|
+
import { useStore } from "../internals/useStore.js";
|
|
10
11
|
function getAsANumber(value) {
|
|
11
12
|
return value instanceof Date ? value.getTime() : value;
|
|
12
13
|
}
|
|
@@ -19,9 +20,7 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
19
20
|
xAxisIds,
|
|
20
21
|
yAxisIds
|
|
21
22
|
} = useCartesianContext();
|
|
22
|
-
const
|
|
23
|
-
dispatch
|
|
24
|
-
} = React.useContext(InteractionContext);
|
|
23
|
+
const store = useStore(disableAxisListener);
|
|
25
24
|
const usedXAxis = xAxisIds[0];
|
|
26
25
|
const usedYAxis = yAxisIds[0];
|
|
27
26
|
|
|
@@ -33,7 +32,7 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
33
32
|
});
|
|
34
33
|
React.useEffect(() => {
|
|
35
34
|
const element = svgRef.current;
|
|
36
|
-
if (element === null || disableAxisListener) {
|
|
35
|
+
if (element === null || disableAxisListener || !store) {
|
|
37
36
|
return () => {};
|
|
38
37
|
}
|
|
39
38
|
function getNewAxisState(axisConfig, mouseValue) {
|
|
@@ -92,9 +91,15 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
92
91
|
x: -1,
|
|
93
92
|
y: -1
|
|
94
93
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
store.update(prev => _extends({}, prev, {
|
|
95
|
+
interaction: {
|
|
96
|
+
item: null,
|
|
97
|
+
axis: {
|
|
98
|
+
x: null,
|
|
99
|
+
y: null
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}));
|
|
98
103
|
};
|
|
99
104
|
const handleMove = event => {
|
|
100
105
|
const target = 'targetTouches' in event ? event.targetTouches[0] : event;
|
|
@@ -105,9 +110,15 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
105
110
|
targetElement: event.target
|
|
106
111
|
})) {
|
|
107
112
|
if (mousePosition.current.isInChart) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
113
|
+
store.update(prev => _extends({}, prev, {
|
|
114
|
+
interaction: {
|
|
115
|
+
item: null,
|
|
116
|
+
axis: {
|
|
117
|
+
x: null,
|
|
118
|
+
y: null
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}));
|
|
111
122
|
mousePosition.current.isInChart = false;
|
|
112
123
|
}
|
|
113
124
|
return;
|
|
@@ -115,13 +126,15 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
115
126
|
mousePosition.current.isInChart = true;
|
|
116
127
|
const newStateX = getNewAxisState(xAxis[usedXAxis], svgPoint.x);
|
|
117
128
|
const newStateY = getNewAxisState(yAxis[usedYAxis], svgPoint.y);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
129
|
+
store.update(prev => _extends({}, prev, {
|
|
130
|
+
interaction: _extends({}, prev.interaction, {
|
|
131
|
+
axis: _extends({}, prev.interaction.axis, prev.interaction.axis.x?.index !== newStateX?.index || prev.interaction.axis.x?.value !== newStateX?.value ? {
|
|
132
|
+
x: newStateX
|
|
133
|
+
} : {}, prev.interaction.axis.y?.index !== newStateY?.index || prev.interaction.axis.y?.value !== newStateY?.value ? {
|
|
134
|
+
y: newStateY
|
|
135
|
+
} : {})
|
|
136
|
+
})
|
|
137
|
+
}));
|
|
125
138
|
};
|
|
126
139
|
const handleDown = event => {
|
|
127
140
|
const target = event.currentTarget;
|
|
@@ -144,5 +157,5 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
144
157
|
element.removeEventListener('pointercancel', handleOut);
|
|
145
158
|
element.removeEventListener('pointerleave', handleOut);
|
|
146
159
|
};
|
|
147
|
-
}, [svgRef,
|
|
160
|
+
}, [svgRef, store, usedYAxis, yAxis, usedXAxis, xAxis, disableAxisListener, drawingArea]);
|
|
148
161
|
};
|
package/hooks/useChartId.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { DrawingAreaContext } from "../context/DrawingAreaProvider/index.js";
|
|
5
5
|
export function useChartId() {
|
|
6
6
|
const {
|
|
7
7
|
chartId
|
|
8
|
-
} = React.useContext(
|
|
8
|
+
} = React.useContext(DrawingAreaContext);
|
|
9
9
|
return React.useMemo(() => chartId, [chartId]);
|
|
10
10
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function useDrawingArea():
|
|
1
|
+
import { DrawingAreaState } from '../context/DrawingAreaProvider';
|
|
2
|
+
export declare function useDrawingArea(): DrawingAreaState;
|
package/hooks/useDrawingArea.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { DrawingAreaContext } from "../context/DrawingAreaProvider/index.js";
|
|
5
5
|
export function useDrawingArea() {
|
|
6
6
|
const {
|
|
7
7
|
left,
|
|
@@ -11,7 +11,7 @@ export function useDrawingArea() {
|
|
|
11
11
|
bottom,
|
|
12
12
|
right,
|
|
13
13
|
isPointInside
|
|
14
|
-
} = React.useContext(
|
|
14
|
+
} = React.useContext(DrawingAreaContext);
|
|
15
15
|
return React.useMemo(() => ({
|
|
16
16
|
left,
|
|
17
17
|
top,
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { InteractionContext } from "../context/InteractionProvider.js";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
4
|
import { useHighlighted } from "../context/index.js";
|
|
5
|
+
import { useStore } from "../internals/useStore.js";
|
|
6
6
|
export const useInteractionItemProps = skip => {
|
|
7
|
-
const
|
|
8
|
-
dispatch: dispatchInteraction
|
|
9
|
-
} = React.useContext(InteractionContext);
|
|
7
|
+
const store = useStore();
|
|
10
8
|
const {
|
|
11
9
|
setHighlighted,
|
|
12
10
|
clearHighlighted
|
|
@@ -21,10 +19,11 @@ export const useInteractionItemProps = skip => {
|
|
|
21
19
|
}
|
|
22
20
|
};
|
|
23
21
|
const onPointerEnter = () => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
store.update(prev => _extends({}, prev, {
|
|
23
|
+
interaction: _extends({}, prev.interaction, {
|
|
24
|
+
item: data
|
|
25
|
+
})
|
|
26
|
+
}));
|
|
28
27
|
setHighlighted({
|
|
29
28
|
seriesId: data.seriesId,
|
|
30
29
|
dataIndex: data.dataIndex
|
|
@@ -32,9 +31,17 @@ export const useInteractionItemProps = skip => {
|
|
|
32
31
|
};
|
|
33
32
|
const onPointerLeave = event => {
|
|
34
33
|
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
data
|
|
34
|
+
store.update(prev => {
|
|
35
|
+
const prevItem = prev.interaction.item;
|
|
36
|
+
if (prevItem === null || Object.keys(data).some(key => data[key] !== prevItem[key])) {
|
|
37
|
+
// The item is already something else, no need to clean it.
|
|
38
|
+
return prev;
|
|
39
|
+
}
|
|
40
|
+
return _extends({}, prev, {
|
|
41
|
+
interaction: _extends({}, prev.interaction, {
|
|
42
|
+
item: null
|
|
43
|
+
})
|
|
44
|
+
});
|
|
38
45
|
});
|
|
39
46
|
clearHighlighted();
|
|
40
47
|
};
|
package/hooks/useSvgRef.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { SvgRefContext } from "../context/SvgRefProvider/index.js";
|
|
5
5
|
export function useSvgRef() {
|
|
6
6
|
const {
|
|
7
7
|
isInitialized,
|
|
8
8
|
data
|
|
9
|
-
} = React.useContext(
|
|
9
|
+
} = React.useContext(SvgRefContext);
|
|
10
10
|
if (!isInitialized) {
|
|
11
11
|
throw new Error(['MUI X: Could not find the svg ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
12
12
|
}
|
|
13
|
-
return data;
|
|
13
|
+
return data.svgRef;
|
|
14
14
|
}
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { AxisId } from '../../../models/axis';
|
|
3
3
|
export declare function useChartGradient(): (axisId: AxisId, direction: "x" | "y") => string;
|
|
4
|
-
export declare function ChartsAxesGradients(): React.JSX.Element;
|
|
4
|
+
export declare function ChartsAxesGradients(): React.JSX.Element | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useCartesianContext } from "../../../context/CartesianProvider/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { DrawingAreaContext } from "../../../context/DrawingAreaProvider/index.js";
|
|
4
4
|
import { useDrawingArea } from "../../../hooks/index.js";
|
|
5
5
|
import ChartsPiecewiseGradient from "./ChartsPiecewiseGradient.js";
|
|
6
6
|
import ChartsContinuousGradient from "./ChartsContinuousGradient.js";
|
|
@@ -8,7 +8,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
8
8
|
export function useChartGradient() {
|
|
9
9
|
const {
|
|
10
10
|
chartId
|
|
11
|
-
} = React.useContext(
|
|
11
|
+
} = React.useContext(DrawingAreaContext);
|
|
12
12
|
return React.useCallback((axisId, direction) => `${chartId}-gradient-${direction}-${axisId}`, [chartId]);
|
|
13
13
|
}
|
|
14
14
|
export function ChartsAxesGradients() {
|
|
@@ -29,8 +29,13 @@ export function ChartsAxesGradients() {
|
|
|
29
29
|
yAxisIds,
|
|
30
30
|
yAxis
|
|
31
31
|
} = useCartesianContext();
|
|
32
|
+
const filteredYAxisIds = yAxisIds.filter(axisId => yAxis[axisId].colorMap !== undefined);
|
|
33
|
+
const filteredXAxisIds = xAxisIds.filter(axisId => xAxis[axisId].colorMap !== undefined);
|
|
34
|
+
if (filteredYAxisIds.length === 0 && filteredXAxisIds.length === 0) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
32
37
|
return /*#__PURE__*/_jsxs("defs", {
|
|
33
|
-
children: [
|
|
38
|
+
children: [filteredYAxisIds.map(axisId => {
|
|
34
39
|
const gradientId = getGradientId(axisId, 'y');
|
|
35
40
|
const {
|
|
36
41
|
colorMap,
|
|
@@ -60,7 +65,7 @@ export function ChartsAxesGradients() {
|
|
|
60
65
|
}, gradientId);
|
|
61
66
|
}
|
|
62
67
|
return null;
|
|
63
|
-
}),
|
|
68
|
+
}), filteredXAxisIds.map(axisId => {
|
|
64
69
|
const gradientId = getGradientId(axisId, 'x');
|
|
65
70
|
const {
|
|
66
71
|
colorMap,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxisConfig, ScaleName } from '../models';
|
|
2
2
|
import { ChartsXAxisProps, ChartsAxisProps, ChartsYAxisProps, ChartsRadiusAxisProps, ChartsRotationAxisProps } from '../models/axis';
|
|
3
3
|
import { CartesianChartSeriesType } from '../models/seriesType/config';
|
|
4
|
-
import {
|
|
4
|
+
import { DrawingAreaState } from '../context/DrawingAreaProvider';
|
|
5
5
|
import { FormattedSeries } from '../context/SeriesProvider';
|
|
6
6
|
import { ExtremumGetter } from '../context/PluginProvider';
|
|
7
7
|
import { DefaultizedAxisConfig, ZoomData, ZoomOptions, GetZoomAxisFilters } from '../context/CartesianProvider/Cartesian.types';
|
|
@@ -10,7 +10,7 @@ type ComputeResult<T extends ChartsAxisProps> = {
|
|
|
10
10
|
axisIds: string[];
|
|
11
11
|
};
|
|
12
12
|
type ComputeCommonParams = {
|
|
13
|
-
drawingArea:
|
|
13
|
+
drawingArea: DrawingAreaState;
|
|
14
14
|
formattedSeries: FormattedSeries;
|
|
15
15
|
extremumGetters: {
|
|
16
16
|
[K in CartesianChartSeriesType]?: ExtremumGetter<K>;
|
package/internals/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export * from './components/ChartsAxesGradients';
|
|
2
|
-
export * from '../ChartContainer/useChartContainerDimensions';
|
|
3
2
|
export * from '../ChartContainer/ResizableContainer';
|
|
4
3
|
export { useSeries } from '../hooks/useSeries';
|
|
5
4
|
export { useInteractionItemProps } from '../hooks/useInteractionItemProps';
|
|
@@ -18,7 +17,7 @@ export { unstable_cleanupDOM } from './domUtils';
|
|
|
18
17
|
export * from './getScale';
|
|
19
18
|
export * from './computeAxisValue';
|
|
20
19
|
export * from '../context/CartesianProvider';
|
|
21
|
-
export * from '../context/
|
|
20
|
+
export * from '../context/DrawingAreaProvider';
|
|
22
21
|
export * from '../context/InteractionProvider';
|
|
23
22
|
export * from '../context/SeriesProvider';
|
|
24
23
|
export * from '../context/ZAxisContextProvider';
|
|
@@ -27,6 +26,8 @@ export * from '../context/AnimationProvider';
|
|
|
27
26
|
export type * from '../context/context.types';
|
|
28
27
|
export { getAxisExtremum } from '../context/CartesianProvider/getAxisExtremum';
|
|
29
28
|
export * from '../context/ChartDataProvider';
|
|
29
|
+
export * from '../context/SizeProvider';
|
|
30
|
+
export * from '../context/SvgRefProvider';
|
|
30
31
|
export * from '../models/seriesType/config';
|
|
31
32
|
export * from '../models/seriesType/common';
|
|
32
33
|
export * from '../models/z-axis';
|
package/internals/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Components
|
|
2
2
|
export * from "./components/ChartsAxesGradients/index.js";
|
|
3
|
-
export * from "../ChartContainer/useChartContainerDimensions.js";
|
|
4
3
|
export * from "../ChartContainer/ResizableContainer.js";
|
|
5
4
|
|
|
6
5
|
// hooks
|
|
@@ -26,7 +25,7 @@ export * from "./computeAxisValue.js";
|
|
|
26
25
|
// contexts
|
|
27
26
|
|
|
28
27
|
export * from "../context/CartesianProvider/index.js";
|
|
29
|
-
export * from "../context/
|
|
28
|
+
export * from "../context/DrawingAreaProvider/index.js";
|
|
30
29
|
export * from "../context/InteractionProvider.js";
|
|
31
30
|
export * from "../context/SeriesProvider/index.js";
|
|
32
31
|
export * from "../context/ZAxisContextProvider.js";
|
|
@@ -34,6 +33,8 @@ export * from "../context/PluginProvider/index.js";
|
|
|
34
33
|
export * from "../context/AnimationProvider/index.js";
|
|
35
34
|
export { getAxisExtremum } from "../context/CartesianProvider/getAxisExtremum.js";
|
|
36
35
|
export * from "../context/ChartDataProvider/index.js";
|
|
36
|
+
export * from "../context/SizeProvider/index.js";
|
|
37
|
+
export * from "../context/SvgRefProvider/index.js";
|
|
37
38
|
|
|
38
39
|
// series configuration
|
|
39
40
|
export * from "../models/seriesType/config.js";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ChartItemIdentifier, ChartSeriesType } from '../../../models/seriesType/config';
|
|
2
|
+
export type ItemInteractionData<T extends ChartSeriesType> = ChartItemIdentifier<T>;
|
|
3
|
+
export type AxisInteractionData = {
|
|
4
|
+
x: null | {
|
|
5
|
+
value: number | Date | string;
|
|
6
|
+
index: number;
|
|
7
|
+
};
|
|
8
|
+
y: null | {
|
|
9
|
+
value: number | Date | string;
|
|
10
|
+
index: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
type InteractionState = {
|
|
14
|
+
/**
|
|
15
|
+
* The item currently interacting.
|
|
16
|
+
*/
|
|
17
|
+
item: null | ItemInteractionData<ChartSeriesType>;
|
|
18
|
+
/**
|
|
19
|
+
* The x- and y-axes currently interacting.
|
|
20
|
+
*/
|
|
21
|
+
axis: AxisInteractionData;
|
|
22
|
+
/**
|
|
23
|
+
* Set to `true` when `VoronoiHandler` is active.
|
|
24
|
+
* Used to prevent collision with mouseEnter events.
|
|
25
|
+
*/
|
|
26
|
+
isVoronoiEnabled?: boolean;
|
|
27
|
+
};
|
|
28
|
+
export type ChartStateCacheKey = {
|
|
29
|
+
id: number;
|
|
30
|
+
};
|
|
31
|
+
export type ChartState = {
|
|
32
|
+
interaction: InteractionState;
|
|
33
|
+
cacheKey: ChartStateCacheKey;
|
|
34
|
+
};
|
|
35
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ChartState } from '../models';
|
|
2
|
+
type Listener<T> = (value: T) => void;
|
|
3
|
+
export type StoreUpdater = (prevState: ChartState) => ChartState;
|
|
4
|
+
export declare class ChartStore {
|
|
5
|
+
value: ChartState;
|
|
6
|
+
private listeners;
|
|
7
|
+
constructor(value: ChartState);
|
|
8
|
+
subscribe: (fn: Listener<ChartState>) => () => void;
|
|
9
|
+
getSnapshot: () => ChartState;
|
|
10
|
+
update: (updater: StoreUpdater) => void;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// For now this is fixed. Will need to support generic if we add plugins
|
|
2
|
+
|
|
3
|
+
export class ChartStore {
|
|
4
|
+
constructor(value) {
|
|
5
|
+
this.value = void 0;
|
|
6
|
+
this.listeners = void 0;
|
|
7
|
+
this.subscribe = fn => {
|
|
8
|
+
this.listeners.add(fn);
|
|
9
|
+
return () => {
|
|
10
|
+
this.listeners.delete(fn);
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
this.getSnapshot = () => {
|
|
14
|
+
return this.value;
|
|
15
|
+
};
|
|
16
|
+
this.update = updater => {
|
|
17
|
+
const newState = updater(this.value);
|
|
18
|
+
if (newState !== this.value) {
|
|
19
|
+
this.value = newState;
|
|
20
|
+
this.listeners.forEach(l => l(newState));
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
this.value = value;
|
|
24
|
+
this.listeners = new Set();
|
|
25
|
+
}
|
|
26
|
+
}
|