@mui/x-charts 8.0.0-alpha.1 → 8.0.0-alpha.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/BarChart.js +0 -4
- package/BarChart/BarLabel/BarLabel.d.ts +298 -298
- package/CHANGELOG.md +330 -7
- package/ChartContainer/ChartContainer.d.ts +24 -0
- package/ChartContainer/ChartContainer.js +26 -10
- package/ChartContainer/useChartContainerProps.d.ts +0 -1
- package/ChartContainer/useChartContainerProps.js +3 -4
- package/ChartsAxis/axisClasses.js +2 -1
- package/ChartsAxisHighlight/ChartsXAxisHighlight.js +3 -3
- package/ChartsAxisHighlight/ChartsYAxisHighlight.js +3 -3
- package/ChartsLegend/chartsLegendClasses.js +2 -1
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
- package/ChartsSurface/ChartsSurface.d.ts +14 -0
- package/ChartsSurface/ChartsSurface.js +38 -6
- package/ChartsTooltip/ChartsTooltip.js +2 -20
- package/ChartsTooltip/ChartsTooltipContainer.js +5 -23
- package/ChartsTooltip/ChartsTooltipTable.js +2 -2
- package/ChartsTooltip/useAxisTooltip.js +3 -3
- package/ChartsTooltip/useItemTooltip.d.ts +2 -3
- package/ChartsTooltip/useItemTooltip.js +3 -3
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -3
- package/ChartsXAxis/ChartsXAxis.js +3 -17
- package/ChartsYAxis/ChartsYAxis.js +2 -17
- package/Gauge/Gauge.d.ts +1 -1
- package/Gauge/GaugeContainer.d.ts +2 -2
- package/Gauge/GaugeContainer.js +14 -47
- package/LineChart/CircleMarkElement.js +3 -3
- package/LineChart/LineChart.js +0 -4
- package/LineChart/LineHighlightPlot.js +3 -3
- package/LineChart/MarkElement.js +3 -3
- package/PieChart/PieArc.js +11 -5
- package/PieChart/PieArcPlot.js +9 -13
- package/PieChart/PieChart.js +0 -4
- package/ScatterChart/Scatter.js +3 -3
- package/ScatterChart/ScatterChart.js +0 -4
- package/SparkLineChart/SparkLineChart.js +0 -4
- package/context/CartesianProvider/defaultizeAxis.d.ts +9 -11
- package/context/ChartDataProvider/ChartDataProvider.d.ts +27 -0
- package/context/ChartDataProvider/ChartDataProvider.js +38 -18
- package/context/ChartDataProvider/useChartDataProviderProps.d.ts +18 -22
- package/context/ChartDataProvider/useDefaultizeAxis.d.ts +9 -11
- package/context/ChartProvider/ChartContext.d.ts +6 -0
- package/context/ChartProvider/ChartContext.js +8 -0
- package/context/ChartProvider/ChartProvider.d.ts +4 -0
- package/context/ChartProvider/ChartProvider.js +19 -0
- package/context/ChartProvider/ChartProvider.types.d.ts +24 -0
- package/context/ChartProvider/index.d.ts +3 -0
- package/context/ChartProvider/index.js +3 -0
- package/context/ChartProvider/useChartContext.d.ts +3 -0
- package/context/ChartProvider/useChartContext.js +11 -0
- package/context/DrawingAreaProvider/DrawingAreaContext.d.ts +1 -6
- package/context/DrawingAreaProvider/DrawingAreaContext.js +0 -1
- package/context/InteractionSelectors.d.ts +72 -49
- package/context/SizeProvider/Size.types.d.ts +2 -2
- package/context/SizeProvider/SizeContext.js +3 -1
- package/context/SizeProvider/useChartContainerDimensions.d.ts +1 -1
- package/context/SizeProvider/useChartContainerDimensions.js +5 -1
- package/hooks/useAxisEvents.js +1 -1
- package/hooks/useChartId.js +5 -6
- package/hooks/useInteractionItemProps.js +4 -2
- package/hooks/useSvgRef.d.ts +1 -1
- package/hooks/useSvgRef.js +4 -8
- package/index.js +1 -1
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -5
- package/internals/defaultizeColor.d.ts +1 -1
- package/internals/index.d.ts +1 -3
- package/internals/index.js +1 -3
- package/internals/plugins/allPlugins.d.ts +1 -0
- package/internals/plugins/allPlugins.js +3 -0
- package/internals/plugins/corePlugins/corePlugins.d.ts +10 -0
- package/internals/plugins/corePlugins/corePlugins.js +7 -0
- package/internals/plugins/corePlugins/index.d.ts +2 -0
- package/internals/plugins/corePlugins/index.js +1 -0
- package/internals/plugins/corePlugins/useChartId/index.d.ts +2 -0
- package/internals/plugins/corePlugins/useChartId/index.js +1 -0
- package/internals/plugins/corePlugins/useChartId/useChartId.d.ts +3 -0
- package/internals/plugins/corePlugins/useChartId/useChartId.js +32 -0
- package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +36 -0
- package/internals/plugins/corePlugins/useChartId/useChartId.selectors.js +9 -0
- package/internals/plugins/corePlugins/useChartId/useChartId.types.d.ts +20 -0
- package/internals/plugins/corePlugins/useChartId/useChartId.utils.d.ts +1 -0
- package/internals/plugins/corePlugins/useChartId/useChartId.utils.js +5 -0
- package/internals/plugins/featurePlugins/useChartInteraction/index.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartInteraction/index.js +2 -0
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +73 -0
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +376 -0
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +10 -0
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +57 -0
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.js +1 -0
- package/internals/plugins/models/chart.d.ts +14 -0
- package/internals/plugins/models/chart.js +1 -0
- package/internals/plugins/models/helpers.d.ts +7 -0
- package/internals/plugins/models/helpers.js +1 -0
- package/internals/plugins/models/index.d.ts +3 -35
- package/internals/plugins/models/index.js +3 -1
- package/internals/plugins/models/plugin.d.ts +75 -0
- package/internals/plugins/models/plugin.js +1 -0
- package/internals/plugins/utils/ChartStore.d.ts +9 -8
- package/internals/plugins/utils/ChartStore.js +0 -2
- package/internals/plugins/utils/selectors.d.ts +2 -2
- package/internals/store/useCharts.d.ts +14 -0
- package/internals/store/useCharts.js +72 -0
- package/internals/store/useCharts.types.d.ts +5 -0
- package/internals/store/useCharts.types.js +1 -0
- package/internals/store/useSelector.d.ts +4 -0
- package/internals/store/useStore.d.ts +3 -0
- package/{modern/internals → internals/store}/useStore.js +6 -6
- package/models/axis.d.ts +1 -13
- package/modern/BarChart/BarChart.js +0 -4
- package/modern/ChartContainer/ChartContainer.js +26 -10
- package/modern/ChartContainer/useChartContainerProps.js +3 -4
- package/modern/ChartsAxis/axisClasses.js +2 -1
- package/modern/ChartsAxisHighlight/ChartsXAxisHighlight.js +3 -3
- package/modern/ChartsAxisHighlight/ChartsYAxisHighlight.js +3 -3
- package/modern/ChartsLegend/chartsLegendClasses.js +2 -1
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
- package/modern/ChartsSurface/ChartsSurface.js +38 -6
- package/modern/ChartsTooltip/ChartsTooltip.js +2 -20
- package/modern/ChartsTooltip/ChartsTooltipContainer.js +5 -23
- package/modern/ChartsTooltip/ChartsTooltipTable.js +2 -2
- package/modern/ChartsTooltip/useAxisTooltip.js +3 -3
- package/modern/ChartsTooltip/useItemTooltip.js +3 -3
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -3
- package/modern/ChartsXAxis/ChartsXAxis.js +3 -17
- package/modern/ChartsYAxis/ChartsYAxis.js +2 -17
- package/modern/Gauge/GaugeContainer.js +14 -47
- package/modern/LineChart/CircleMarkElement.js +3 -3
- package/modern/LineChart/LineChart.js +0 -4
- package/modern/LineChart/LineHighlightPlot.js +3 -3
- package/modern/LineChart/MarkElement.js +3 -3
- package/modern/PieChart/PieArc.js +11 -5
- package/modern/PieChart/PieArcPlot.js +9 -13
- package/modern/PieChart/PieChart.js +0 -4
- package/modern/ScatterChart/Scatter.js +3 -3
- package/modern/ScatterChart/ScatterChart.js +0 -4
- package/modern/SparkLineChart/SparkLineChart.js +0 -4
- package/modern/context/ChartDataProvider/ChartDataProvider.js +38 -18
- package/modern/context/ChartProvider/ChartContext.js +8 -0
- package/modern/context/ChartProvider/ChartProvider.js +19 -0
- package/modern/context/ChartProvider/ChartProvider.types.js +1 -0
- package/modern/context/ChartProvider/index.js +3 -0
- package/modern/context/ChartProvider/useChartContext.js +11 -0
- package/modern/context/DrawingAreaProvider/DrawingAreaContext.js +0 -1
- package/modern/context/SizeProvider/SizeContext.js +3 -1
- package/modern/context/SizeProvider/useChartContainerDimensions.js +5 -1
- package/modern/hooks/useAxisEvents.js +1 -1
- package/modern/hooks/useChartId.js +5 -6
- package/modern/hooks/useInteractionItemProps.js +4 -2
- package/modern/hooks/useSvgRef.js +4 -8
- package/modern/index.js +1 -1
- package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -5
- package/modern/internals/index.js +1 -3
- package/modern/internals/plugins/allPlugins.js +3 -0
- package/modern/internals/plugins/corePlugins/corePlugins.js +7 -0
- package/modern/internals/plugins/corePlugins/index.js +1 -0
- package/modern/internals/plugins/corePlugins/useChartId/index.js +1 -0
- package/modern/internals/plugins/corePlugins/useChartId/useChartId.js +32 -0
- package/modern/internals/plugins/corePlugins/useChartId/useChartId.selectors.js +9 -0
- package/modern/internals/plugins/corePlugins/useChartId/useChartId.types.js +1 -0
- package/modern/internals/plugins/corePlugins/useChartId/useChartId.utils.js +5 -0
- package/modern/internals/plugins/featurePlugins/useChartInteraction/index.js +2 -0
- package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +73 -0
- package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +10 -0
- package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.js +1 -0
- package/modern/internals/plugins/models/chart.js +1 -0
- package/modern/internals/plugins/models/helpers.js +1 -0
- package/modern/internals/plugins/models/index.js +3 -1
- package/modern/internals/plugins/models/plugin.js +1 -0
- package/modern/internals/plugins/utils/ChartStore.js +0 -2
- package/modern/internals/store/useCharts.js +72 -0
- package/modern/internals/store/useCharts.types.js +1 -0
- package/{internals → modern/internals/store}/useStore.js +6 -6
- package/node/BarChart/BarChart.js +0 -4
- package/node/ChartContainer/ChartContainer.js +26 -10
- package/node/ChartContainer/useChartContainerProps.js +3 -4
- package/node/ChartsAxis/axisClasses.js +5 -3
- package/node/ChartsAxisHighlight/ChartsXAxisHighlight.js +4 -4
- package/node/ChartsAxisHighlight/ChartsYAxisHighlight.js +4 -4
- package/node/ChartsLegend/chartsLegendClasses.js +5 -3
- package/node/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
- package/node/ChartsSurface/ChartsSurface.js +37 -5
- package/node/ChartsTooltip/ChartsTooltip.js +2 -20
- package/node/ChartsTooltip/ChartsTooltipContainer.js +6 -24
- package/node/ChartsTooltip/ChartsTooltipTable.js +3 -3
- package/node/ChartsTooltip/useAxisTooltip.js +4 -4
- package/node/ChartsTooltip/useItemTooltip.js +4 -4
- package/node/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -3
- package/node/ChartsXAxis/ChartsXAxis.js +3 -17
- package/node/ChartsYAxis/ChartsYAxis.js +2 -17
- package/node/Gauge/GaugeContainer.js +13 -46
- package/node/LineChart/CircleMarkElement.js +4 -4
- package/node/LineChart/LineChart.js +0 -4
- package/node/LineChart/LineHighlightPlot.js +4 -4
- package/node/LineChart/MarkElement.js +4 -4
- package/node/PieChart/PieArc.js +11 -5
- package/node/PieChart/PieArcPlot.js +9 -13
- package/node/PieChart/PieChart.js +0 -4
- package/node/ScatterChart/Scatter.js +4 -4
- package/node/ScatterChart/ScatterChart.js +0 -4
- package/node/SparkLineChart/SparkLineChart.js +0 -4
- package/node/context/ChartDataProvider/ChartDataProvider.js +38 -18
- package/node/context/ChartProvider/ChartContext.js +15 -0
- package/node/context/ChartProvider/ChartProvider.js +24 -0
- package/node/context/ChartProvider/index.js +38 -0
- package/node/context/ChartProvider/useChartContext.js +18 -0
- package/node/context/DrawingAreaProvider/DrawingAreaContext.js +0 -1
- package/node/context/SizeProvider/SizeContext.js +3 -1
- package/node/context/SizeProvider/useChartContainerDimensions.js +5 -1
- package/node/hooks/useAxisEvents.js +1 -1
- package/node/hooks/useChartId.js +5 -7
- package/node/hooks/useInteractionItemProps.js +4 -2
- package/node/hooks/useSvgRef.js +4 -9
- package/node/index.js +1 -1
- package/node/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +1 -4
- package/node/internals/index.js +4 -28
- package/node/internals/plugins/allPlugins.js +10 -0
- package/node/internals/plugins/corePlugins/corePlugins.js +12 -0
- package/node/internals/plugins/corePlugins/index.js +12 -0
- package/node/internals/plugins/corePlugins/useChartId/index.js +12 -0
- package/node/internals/plugins/corePlugins/useChartId/useChartId.js +41 -0
- package/node/internals/plugins/corePlugins/useChartId/useChartId.selectors.js +15 -0
- package/node/internals/plugins/corePlugins/useChartId/useChartId.types.js +5 -0
- package/node/internals/plugins/corePlugins/useChartId/useChartId.utils.js +12 -0
- package/node/internals/plugins/featurePlugins/useChartInteraction/index.js +27 -0
- package/node/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +81 -0
- package/node/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +16 -0
- package/node/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.js +5 -0
- package/node/internals/plugins/models/chart.js +5 -0
- package/node/internals/plugins/models/helpers.js +5 -0
- package/node/internals/plugins/models/index.js +33 -0
- package/node/internals/plugins/models/plugin.js +5 -0
- package/node/internals/plugins/utils/ChartStore.js +0 -2
- package/node/internals/store/useCharts.js +80 -0
- package/node/internals/store/useCharts.types.js +5 -0
- package/node/internals/{useStore.js → store/useStore.js} +6 -7
- package/package.json +4 -4
- package/ChartContainer/ResizableContainer.d.ts +0 -22
- package/ChartContainer/ResizableContainer.js +0 -60
- package/context/InteractionProvider.d.ts +0 -7
- package/context/InteractionProvider.js +0 -22
- package/context/SvgRefProvider/SvgRef.types.d.ts +0 -8
- package/context/SvgRefProvider/SvgRefContext.d.ts +0 -4
- package/context/SvgRefProvider/SvgRefContext.js +0 -17
- package/context/SvgRefProvider/SvgRefProvider.d.ts +0 -3
- package/context/SvgRefProvider/SvgRefProvider.js +0 -24
- package/context/SvgRefProvider/index.d.ts +0 -4
- package/context/SvgRefProvider/index.js +0 -4
- package/context/SvgRefProvider/useSurfaceRef.d.ts +0 -2
- package/context/SvgRefProvider/useSurfaceRef.js +0 -14
- package/internals/plugins/utils/ChartsStore.d.ts +0 -12
- package/internals/plugins/utils/ChartsStore.js +0 -26
- package/internals/useCharts.d.ts +0 -6
- package/internals/useCharts.js +0 -29
- package/internals/useSelector.d.ts +0 -4
- package/internals/useStore.d.ts +0 -2
- package/modern/ChartContainer/ResizableContainer.js +0 -60
- package/modern/context/InteractionProvider.js +0 -22
- package/modern/context/SvgRefProvider/SvgRefContext.js +0 -17
- package/modern/context/SvgRefProvider/SvgRefProvider.js +0 -24
- package/modern/context/SvgRefProvider/index.js +0 -4
- package/modern/context/SvgRefProvider/useSurfaceRef.js +0 -14
- package/modern/internals/plugins/utils/ChartsStore.js +0 -26
- package/modern/internals/useCharts.js +0 -29
- package/node/ChartContainer/ResizableContainer.js +0 -68
- package/node/context/InteractionProvider.js +0 -28
- package/node/context/SvgRefProvider/SvgRefContext.js +0 -23
- package/node/context/SvgRefProvider/SvgRefProvider.js +0 -31
- package/node/context/SvgRefProvider/index.js +0 -49
- package/node/context/SvgRefProvider/useSurfaceRef.js +0 -20
- package/node/internals/plugins/utils/ChartsStore.js +0 -33
- package/node/internals/useCharts.js +0 -36
- /package/context/{SvgRefProvider/SvgRef.types.js → ChartProvider/ChartProvider.types.js} +0 -0
- /package/{modern/context/SvgRefProvider/SvgRef.types.js → internals/plugins/corePlugins/useChartId/useChartId.types.js} +0 -0
- /package/internals/{useSelector.js → store/useSelector.js} +0 -0
- /package/modern/internals/{useSelector.js → store/useSelector.js} +0 -0
- /package/node/context/{SvgRefProvider/SvgRef.types.js → ChartProvider/ChartProvider.types.js} +0 -0
- /package/node/internals/{useSelector.js → store/useSelector.js} +0 -0
|
@@ -27,6 +27,10 @@ const useChartContainerDimensions = (inWidth, inHeight) => {
|
|
|
27
27
|
const computeSize = React.useCallback(() => {
|
|
28
28
|
const mainEl = rootRef?.current;
|
|
29
29
|
if (!mainEl) {
|
|
30
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
31
|
+
// This is mostly for internal use.
|
|
32
|
+
throw new Error([`MUI X: ChartContainer does not have a valid reference to the <svg /> element.`, 'This may be caused by a ref forwarding issue.', 'Make sure that the ref from SizedProvider is forwarded correctly.'].join('\n'));
|
|
33
|
+
}
|
|
30
34
|
return {};
|
|
31
35
|
}
|
|
32
36
|
const win = (0, _ownerWindow.default)(mainEl);
|
|
@@ -101,7 +105,7 @@ const useChartContainerDimensions = (inWidth, inHeight) => {
|
|
|
101
105
|
const finalWidth = inWidth ?? width;
|
|
102
106
|
const finalHeight = inHeight ?? height;
|
|
103
107
|
return {
|
|
104
|
-
|
|
108
|
+
svgRef: rootRef,
|
|
105
109
|
width: finalWidth,
|
|
106
110
|
height: finalHeight,
|
|
107
111
|
hasIntrinsicSize: finalWidth > 0 && finalHeight > 0,
|
|
@@ -14,7 +14,7 @@ var _isBandScale = require("../internals/isBandScale");
|
|
|
14
14
|
var _getSVGPoint = require("../internals/getSVGPoint");
|
|
15
15
|
var _useSvgRef = require("./useSvgRef");
|
|
16
16
|
var _useDrawingArea = require("./useDrawingArea");
|
|
17
|
-
var _useStore = require("../internals/useStore");
|
|
17
|
+
var _useStore = require("../internals/store/useStore");
|
|
18
18
|
function getAsANumber(value) {
|
|
19
19
|
return value instanceof Date ? value.getTime() : value;
|
|
20
20
|
}
|
package/node/hooks/useChartId.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.useChartId = useChartId;
|
|
9
|
-
var
|
|
10
|
-
var
|
|
8
|
+
var _useStore = require("../internals/store/useStore");
|
|
9
|
+
var _useSelector = require("../internals/store/useSelector");
|
|
10
|
+
var _useChartId = require("../internals/plugins/corePlugins/useChartId/useChartId.selectors");
|
|
11
11
|
function useChartId() {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
} = React.useContext(_DrawingAreaProvider.DrawingAreaContext);
|
|
15
|
-
return React.useMemo(() => chartId, [chartId]);
|
|
12
|
+
const store = (0, _useStore.useStore)();
|
|
13
|
+
return (0, _useSelector.useSelector)(store, _useChartId.selectorChartId);
|
|
16
14
|
}
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.useInteractionItemProps = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _context = require("../context");
|
|
11
|
-
var _useStore = require("../internals/useStore");
|
|
11
|
+
var _useStore = require("../internals/store/useStore");
|
|
12
12
|
const useInteractionItemProps = skip => {
|
|
13
13
|
const store = (0, _useStore.useStore)();
|
|
14
14
|
const {
|
|
@@ -36,7 +36,9 @@ const useInteractionItemProps = skip => {
|
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
38
|
const onPointerLeave = event => {
|
|
39
|
-
event.currentTarget.
|
|
39
|
+
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
|
|
40
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
41
|
+
}
|
|
40
42
|
store.update(prev => {
|
|
41
43
|
const prevItem = prev.interaction.item;
|
|
42
44
|
if (prevItem === null || Object.keys(data).some(key => data[key] !== prevItem[key])) {
|
package/node/hooks/useSvgRef.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.useSvgRef = useSvgRef;
|
|
9
|
-
var
|
|
10
|
-
var _SvgRefProvider = require("../context/SvgRefProvider");
|
|
8
|
+
var _ChartProvider = require("../context/ChartProvider");
|
|
11
9
|
function useSvgRef() {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
data
|
|
15
|
-
} = React.useContext(_SvgRefProvider.SvgRefContext);
|
|
16
|
-
if (!isInitialized) {
|
|
10
|
+
const context = (0, _ChartProvider.useChartContext)();
|
|
11
|
+
if (!context) {
|
|
17
12
|
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'));
|
|
18
13
|
}
|
|
19
|
-
return
|
|
14
|
+
return context.svgRef;
|
|
20
15
|
}
|
package/node/index.js
CHANGED
|
@@ -9,15 +9,12 @@ exports.ChartsAxesGradients = ChartsAxesGradients;
|
|
|
9
9
|
exports.useChartGradient = useChartGradient;
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _CartesianProvider = require("../../../context/CartesianProvider");
|
|
12
|
-
var _DrawingAreaProvider = require("../../../context/DrawingAreaProvider");
|
|
13
12
|
var _hooks = require("../../../hooks");
|
|
14
13
|
var _ChartsPiecewiseGradient = _interopRequireDefault(require("./ChartsPiecewiseGradient"));
|
|
15
14
|
var _ChartsContinuousGradient = _interopRequireDefault(require("./ChartsContinuousGradient"));
|
|
16
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
16
|
function useChartGradient() {
|
|
18
|
-
const
|
|
19
|
-
chartId
|
|
20
|
-
} = React.useContext(_DrawingAreaProvider.DrawingAreaContext);
|
|
17
|
+
const chartId = (0, _hooks.useChartId)();
|
|
21
18
|
return React.useCallback((axisId, direction) => `${chartId}-gradient-${direction}-${axisId}`, [chartId]);
|
|
22
19
|
}
|
|
23
20
|
function ChartsAxesGradients() {
|
package/node/internals/index.js
CHANGED
|
@@ -73,18 +73,6 @@ Object.keys(_ChartsAxesGradients).forEach(function (key) {
|
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
|
-
var _ResizableContainer = require("../ChartContainer/ResizableContainer");
|
|
77
|
-
Object.keys(_ResizableContainer).forEach(function (key) {
|
|
78
|
-
if (key === "default" || key === "__esModule") return;
|
|
79
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
80
|
-
if (key in exports && exports[key] === _ResizableContainer[key]) return;
|
|
81
|
-
Object.defineProperty(exports, key, {
|
|
82
|
-
enumerable: true,
|
|
83
|
-
get: function () {
|
|
84
|
-
return _ResizableContainer[key];
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
76
|
var _useSeries = require("../hooks/useSeries");
|
|
89
77
|
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
90
78
|
var _useDrawingArea = require("../hooks/useDrawingArea");
|
|
@@ -224,18 +212,6 @@ Object.keys(_DrawingAreaProvider).forEach(function (key) {
|
|
|
224
212
|
}
|
|
225
213
|
});
|
|
226
214
|
});
|
|
227
|
-
var _InteractionProvider = require("../context/InteractionProvider");
|
|
228
|
-
Object.keys(_InteractionProvider).forEach(function (key) {
|
|
229
|
-
if (key === "default" || key === "__esModule") return;
|
|
230
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
231
|
-
if (key in exports && exports[key] === _InteractionProvider[key]) return;
|
|
232
|
-
Object.defineProperty(exports, key, {
|
|
233
|
-
enumerable: true,
|
|
234
|
-
get: function () {
|
|
235
|
-
return _InteractionProvider[key];
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
215
|
var _SeriesProvider = require("../context/SeriesProvider");
|
|
240
216
|
Object.keys(_SeriesProvider).forEach(function (key) {
|
|
241
217
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -309,15 +285,15 @@ Object.keys(_SizeProvider).forEach(function (key) {
|
|
|
309
285
|
}
|
|
310
286
|
});
|
|
311
287
|
});
|
|
312
|
-
var
|
|
313
|
-
Object.keys(
|
|
288
|
+
var _ChartProvider = require("../context/ChartProvider");
|
|
289
|
+
Object.keys(_ChartProvider).forEach(function (key) {
|
|
314
290
|
if (key === "default" || key === "__esModule") return;
|
|
315
291
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
316
|
-
if (key in exports && exports[key] ===
|
|
292
|
+
if (key in exports && exports[key] === _ChartProvider[key]) return;
|
|
317
293
|
Object.defineProperty(exports, key, {
|
|
318
294
|
enumerable: true,
|
|
319
295
|
get: function () {
|
|
320
|
-
return
|
|
296
|
+
return _ChartProvider[key];
|
|
321
297
|
}
|
|
322
298
|
});
|
|
323
299
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ALL_PLUGINS = void 0;
|
|
7
|
+
var _useChartInteraction = require("./featurePlugins/useChartInteraction");
|
|
8
|
+
// This file should be removed after creating all plugins in favor of a file per chart type.
|
|
9
|
+
|
|
10
|
+
const ALL_PLUGINS = exports.ALL_PLUGINS = [_useChartInteraction.useChartInteraction];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CHART_CORE_PLUGINS = void 0;
|
|
7
|
+
var _useChartId = require("./useChartId");
|
|
8
|
+
/**
|
|
9
|
+
* Internal plugins that create the tools used by the other plugins.
|
|
10
|
+
* These plugins are used by the Charts components.
|
|
11
|
+
*/
|
|
12
|
+
const CHART_CORE_PLUGINS = exports.CHART_CORE_PLUGINS = [_useChartId.useChartId];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "CHART_CORE_PLUGINS", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _corePlugins.CHART_CORE_PLUGINS;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _corePlugins = require("./corePlugins");
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "useChartId", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useChartId.useChartId;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _useChartId = require("./useChartId");
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useChartId = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _useChartId = require("./useChartId.utils");
|
|
12
|
+
const useChartId = ({
|
|
13
|
+
params,
|
|
14
|
+
store
|
|
15
|
+
}) => {
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
store.update(prevState => {
|
|
18
|
+
if (params.id === prevState.id.providedChartId && prevState.id.chartId !== undefined) {
|
|
19
|
+
return prevState;
|
|
20
|
+
}
|
|
21
|
+
return (0, _extends2.default)({}, prevState, {
|
|
22
|
+
id: (0, _extends2.default)({}, prevState.id, {
|
|
23
|
+
chartId: params.id ?? (0, _useChartId.createChartDefaultId)()
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}, [store, params.id]);
|
|
28
|
+
return {};
|
|
29
|
+
};
|
|
30
|
+
exports.useChartId = useChartId;
|
|
31
|
+
useChartId.params = {
|
|
32
|
+
id: true
|
|
33
|
+
};
|
|
34
|
+
useChartId.getInitialState = ({
|
|
35
|
+
id
|
|
36
|
+
}) => ({
|
|
37
|
+
id: {
|
|
38
|
+
chartId: (0, _useChartId.createChartDefaultId)(),
|
|
39
|
+
providedChartId: id
|
|
40
|
+
}
|
|
41
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.selectorChartId = void 0;
|
|
7
|
+
var _selectors = require("../../utils/selectors");
|
|
8
|
+
const selectorChartIdState = state => state.id;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Get the id attribute of the chart.
|
|
12
|
+
* @param {ChartState<[UseChartIdSignature]>} state The state of the chart.
|
|
13
|
+
* @returns {string} The id attribute of the chart.
|
|
14
|
+
*/
|
|
15
|
+
const selectorChartId = exports.selectorChartId = (0, _selectors.createSelector)(selectorChartIdState, idState => idState.chartId);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createChartDefaultId = void 0;
|
|
7
|
+
let globalChartDefaultId = 0;
|
|
8
|
+
const createChartDefaultId = () => {
|
|
9
|
+
globalChartDefaultId += 1;
|
|
10
|
+
return `mui-chart-${globalChartDefaultId}`;
|
|
11
|
+
};
|
|
12
|
+
exports.createChartDefaultId = createChartDefaultId;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
useChartInteraction: true
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "useChartInteraction", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _useChartInteraction.useChartInteraction;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
var _useChartInteraction = require("./useChartInteraction");
|
|
16
|
+
var _useChartInteraction2 = require("./useChartInteraction.selectors");
|
|
17
|
+
Object.keys(_useChartInteraction2).forEach(function (key) {
|
|
18
|
+
if (key === "default" || key === "__esModule") return;
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
20
|
+
if (key in exports && exports[key] === _useChartInteraction2[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _useChartInteraction2[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useChartInteraction = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
10
|
+
const useChartInteraction = ({
|
|
11
|
+
store
|
|
12
|
+
}) => {
|
|
13
|
+
const cleanInteraction = (0, _useEventCallback.default)(() => {
|
|
14
|
+
store.update(prev => (0, _extends2.default)({}, prev, {
|
|
15
|
+
interaction: (0, _extends2.default)({}, prev.interaction, {
|
|
16
|
+
axis: {
|
|
17
|
+
x: null,
|
|
18
|
+
y: null
|
|
19
|
+
},
|
|
20
|
+
item: null
|
|
21
|
+
})
|
|
22
|
+
}));
|
|
23
|
+
});
|
|
24
|
+
const setItemInteraction = (0, _useEventCallback.default)(newItem => {
|
|
25
|
+
store.update(prev => (0, _extends2.default)({}, prev, {
|
|
26
|
+
interaction: (0, _extends2.default)({}, prev.interaction, {
|
|
27
|
+
item: newItem
|
|
28
|
+
})
|
|
29
|
+
}));
|
|
30
|
+
});
|
|
31
|
+
const setAxisInteraction = (0, _useEventCallback.default)(({
|
|
32
|
+
x: newStateX,
|
|
33
|
+
y: newStateY
|
|
34
|
+
}) => {
|
|
35
|
+
store.update(prev => (0, _extends2.default)({}, prev, {
|
|
36
|
+
interaction: (0, _extends2.default)({}, prev.interaction, {
|
|
37
|
+
axis: (0, _extends2.default)({}, prev.interaction.axis, prev.interaction.axis.x?.index !== newStateX?.index || prev.interaction.axis.x?.value !== newStateX?.value ? {
|
|
38
|
+
x: newStateX
|
|
39
|
+
} : {}, prev.interaction.axis.y?.index !== newStateY?.index || prev.interaction.axis.y?.value !== newStateY?.value ? {
|
|
40
|
+
y: newStateY
|
|
41
|
+
} : {})
|
|
42
|
+
})
|
|
43
|
+
}));
|
|
44
|
+
});
|
|
45
|
+
const enableVoronoid = (0, _useEventCallback.default)(() => {
|
|
46
|
+
store.update(prev => (0, _extends2.default)({}, prev, {
|
|
47
|
+
interaction: (0, _extends2.default)({}, prev.interaction, {
|
|
48
|
+
isVoronoiEnabled: true
|
|
49
|
+
})
|
|
50
|
+
}));
|
|
51
|
+
});
|
|
52
|
+
const disableVoronoid = (0, _useEventCallback.default)(() => {
|
|
53
|
+
store.update(prev => (0, _extends2.default)({}, prev, {
|
|
54
|
+
interaction: (0, _extends2.default)({}, prev.interaction, {
|
|
55
|
+
isVoronoiEnabled: false
|
|
56
|
+
})
|
|
57
|
+
}));
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
params: {},
|
|
61
|
+
instance: {
|
|
62
|
+
cleanInteraction,
|
|
63
|
+
setItemInteraction,
|
|
64
|
+
setAxisInteraction,
|
|
65
|
+
enableVoronoid,
|
|
66
|
+
disableVoronoid
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
exports.useChartInteraction = useChartInteraction;
|
|
71
|
+
useChartInteraction.getInitialState = () => ({
|
|
72
|
+
interaction: {
|
|
73
|
+
item: null,
|
|
74
|
+
axis: {
|
|
75
|
+
x: null,
|
|
76
|
+
y: null
|
|
77
|
+
},
|
|
78
|
+
isVoronoiEnabled: false
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
useChartInteraction.params = {};
|
package/node/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.selectorChartsInteractionYAxisIsDefined = exports.selectorChartsInteractionYAxis = exports.selectorChartsInteractionXAxisIsDefined = exports.selectorChartsInteractionXAxis = exports.selectorChartsInteractionItemIsDefined = exports.selectorChartsInteractionItem = exports.selectorChartsInteractionIsVoronoiEnabled = exports.selectorChartsInteractionAxis = void 0;
|
|
7
|
+
var _selectors = require("../../utils/selectors");
|
|
8
|
+
const selectInteraction = state => state.interaction;
|
|
9
|
+
const selectorChartsInteractionItem = exports.selectorChartsInteractionItem = (0, _selectors.createSelector)(selectInteraction, interaction => interaction.item);
|
|
10
|
+
const selectorChartsInteractionAxis = exports.selectorChartsInteractionAxis = (0, _selectors.createSelector)(selectInteraction, interaction => interaction.axis);
|
|
11
|
+
const selectorChartsInteractionXAxis = exports.selectorChartsInteractionXAxis = (0, _selectors.createSelector)(selectInteraction, interaction => interaction.axis.x);
|
|
12
|
+
const selectorChartsInteractionYAxis = exports.selectorChartsInteractionYAxis = (0, _selectors.createSelector)(selectInteraction, interaction => interaction.axis.y);
|
|
13
|
+
const selectorChartsInteractionItemIsDefined = exports.selectorChartsInteractionItemIsDefined = (0, _selectors.createSelector)(selectorChartsInteractionItem, item => item !== null);
|
|
14
|
+
const selectorChartsInteractionXAxisIsDefined = exports.selectorChartsInteractionXAxisIsDefined = (0, _selectors.createSelector)(selectorChartsInteractionXAxis, x => x !== null);
|
|
15
|
+
const selectorChartsInteractionYAxisIsDefined = exports.selectorChartsInteractionYAxisIsDefined = (0, _selectors.createSelector)(selectorChartsInteractionYAxis, y => y !== null);
|
|
16
|
+
const selectorChartsInteractionIsVoronoiEnabled = exports.selectorChartsInteractionIsVoronoiEnabled = (0, _selectors.createSelector)(selectInteraction, interaction => interaction.isVoronoiEnabled);
|
|
@@ -2,4 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
+
});
|
|
6
|
+
var _helpers = require("./helpers");
|
|
7
|
+
Object.keys(_helpers).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _helpers[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _helpers[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _plugin = require("./plugin");
|
|
18
|
+
Object.keys(_plugin).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _plugin[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _plugin[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _chart = require("./chart");
|
|
29
|
+
Object.keys(_chart).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _chart[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _chart[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
5
38
|
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useChartApiInitialization = useChartApiInitialization;
|
|
8
|
+
exports.useCharts = useCharts;
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _ChartStore = require("../plugins/utils/ChartStore");
|
|
11
|
+
var _corePlugins = require("../plugins/corePlugins");
|
|
12
|
+
function useChartApiInitialization(inputApiRef) {
|
|
13
|
+
const fallbackPublicApiRef = React.useRef({});
|
|
14
|
+
if (inputApiRef) {
|
|
15
|
+
if (inputApiRef.current == null) {
|
|
16
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
17
|
+
inputApiRef.current = {};
|
|
18
|
+
}
|
|
19
|
+
return inputApiRef.current;
|
|
20
|
+
}
|
|
21
|
+
return fallbackPublicApiRef.current;
|
|
22
|
+
}
|
|
23
|
+
let globalId = 0;
|
|
24
|
+
function useCharts(inPlugins, props) {
|
|
25
|
+
const plugins = React.useMemo(() => [..._corePlugins.CHART_CORE_PLUGINS, ...inPlugins], [inPlugins]);
|
|
26
|
+
const pluginParams = {}; // To generate when plugins use params.
|
|
27
|
+
const instanceRef = React.useRef({});
|
|
28
|
+
const instance = instanceRef.current;
|
|
29
|
+
const publicAPI = useChartApiInitialization(props.apiRef);
|
|
30
|
+
const innerSvgRef = React.useRef(null);
|
|
31
|
+
const storeRef = React.useRef(null);
|
|
32
|
+
if (storeRef.current == null) {
|
|
33
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
34
|
+
globalId += 1;
|
|
35
|
+
const initialState = {
|
|
36
|
+
// TODO remove when the interaction moves to plugin
|
|
37
|
+
interaction: {
|
|
38
|
+
item: null,
|
|
39
|
+
axis: {
|
|
40
|
+
x: null,
|
|
41
|
+
y: null
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
cacheKey: {
|
|
45
|
+
id: globalId
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
plugins.forEach(plugin => {
|
|
49
|
+
if (plugin.getInitialState) {
|
|
50
|
+
Object.assign(initialState, plugin.getInitialState({}));
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
storeRef.current = new _ChartStore.ChartStore(initialState);
|
|
54
|
+
}
|
|
55
|
+
const runPlugin = plugin => {
|
|
56
|
+
const pluginResponse = plugin({
|
|
57
|
+
instance,
|
|
58
|
+
params: pluginParams,
|
|
59
|
+
plugins: plugins,
|
|
60
|
+
store: storeRef.current,
|
|
61
|
+
svgRef: innerSvgRef
|
|
62
|
+
});
|
|
63
|
+
if (pluginResponse.publicAPI) {
|
|
64
|
+
Object.assign(publicAPI, pluginResponse.publicAPI);
|
|
65
|
+
}
|
|
66
|
+
if (pluginResponse.instance) {
|
|
67
|
+
Object.assign(instance, pluginResponse.instance);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
plugins.forEach(runPlugin);
|
|
71
|
+
const contextValue = React.useMemo(() => ({
|
|
72
|
+
store: storeRef.current,
|
|
73
|
+
publicAPI,
|
|
74
|
+
instance,
|
|
75
|
+
svgRef: innerSvgRef
|
|
76
|
+
}), [instance, publicAPI]);
|
|
77
|
+
return {
|
|
78
|
+
contextValue
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.useStore = useStore;
|
|
8
|
-
var
|
|
9
|
-
|
|
7
|
+
var _ChartProvider = require("../../context/ChartProvider");
|
|
8
|
+
// This hook should be removed because user and us should not interact with the store directly, but with public/private APIs
|
|
10
9
|
function useStore(skipError) {
|
|
11
|
-
const
|
|
10
|
+
const context = (0, _ChartProvider.useChartContext)();
|
|
12
11
|
if (skipError) {
|
|
13
12
|
// TODO: Remove once store is used by all charts.
|
|
14
13
|
// This line is only for `useAxisEvents` which is in the surface of the Gauge.
|
|
15
14
|
// But the Gauge don't have store yet because it does not need the interaction provider.
|
|
16
15
|
// Will be fixed when every thing move to the store since every component will have access to it.
|
|
17
16
|
// @ts-ignore
|
|
18
|
-
return
|
|
17
|
+
return context?.store;
|
|
19
18
|
}
|
|
20
|
-
if (!
|
|
19
|
+
if (!context) {
|
|
21
20
|
throw new Error(['MUI X: Could not find the charts context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
22
21
|
}
|
|
23
|
-
return
|
|
22
|
+
return context.store;
|
|
24
23
|
}
|