@mui/x-charts 8.0.0-alpha.1 → 8.0.0-alpha.2
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 +228 -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 +1 -1
- 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/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 +1 -1
- 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/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 +2 -2
- 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/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
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MergeSignaturesProperty, OptionalIfEmpty } from './helpers';
|
|
3
|
+
import type { ChartCorePluginSignatures } from '../corePlugins';
|
|
4
|
+
import { ChartStore } from '../utils/ChartStore';
|
|
5
|
+
export interface ChartPluginOptions<TSignature extends ChartAnyPluginSignature> {
|
|
6
|
+
instance: ChartUsedInstance<TSignature>;
|
|
7
|
+
params: ChartUsedDefaultizedParams<TSignature>;
|
|
8
|
+
store: ChartUsedStore<TSignature>;
|
|
9
|
+
svgRef: React.RefObject<SVGSVGElement>;
|
|
10
|
+
plugins: ChartPlugin<ChartAnyPluginSignature>[];
|
|
11
|
+
}
|
|
12
|
+
type ChartResponse<TSignature extends ChartAnyPluginSignature> = OptionalIfEmpty<'publicAPI', TSignature['publicAPI']> & OptionalIfEmpty<'instance', TSignature['instance']>;
|
|
13
|
+
export type ChartPluginSignature<T extends {
|
|
14
|
+
params?: {};
|
|
15
|
+
defaultizedParams?: {};
|
|
16
|
+
instance?: {};
|
|
17
|
+
publicAPI?: {};
|
|
18
|
+
state?: {};
|
|
19
|
+
dependencies?: readonly ChartAnyPluginSignature[];
|
|
20
|
+
optionalDependencies?: readonly ChartAnyPluginSignature[];
|
|
21
|
+
}> = {
|
|
22
|
+
params: T extends {
|
|
23
|
+
params: {};
|
|
24
|
+
} ? T['params'] : {};
|
|
25
|
+
defaultizedParams: T extends {
|
|
26
|
+
defaultizedParams: {};
|
|
27
|
+
} ? T['defaultizedParams'] : {};
|
|
28
|
+
instance: T extends {
|
|
29
|
+
instance: {};
|
|
30
|
+
} ? T['instance'] : {};
|
|
31
|
+
state: T extends {
|
|
32
|
+
state: {};
|
|
33
|
+
} ? T['state'] : {};
|
|
34
|
+
publicAPI: T extends {
|
|
35
|
+
publicAPI: {};
|
|
36
|
+
} ? T['publicAPI'] : {};
|
|
37
|
+
dependencies: T extends {
|
|
38
|
+
dependencies: Array<any>;
|
|
39
|
+
} ? T['dependencies'] : [];
|
|
40
|
+
optionalDependencies: T extends {
|
|
41
|
+
optionalDependencies: Array<any>;
|
|
42
|
+
} ? T['optionalDependencies'] : [];
|
|
43
|
+
};
|
|
44
|
+
export type ChartAnyPluginSignature = {
|
|
45
|
+
state: any;
|
|
46
|
+
instance: any;
|
|
47
|
+
params: any;
|
|
48
|
+
defaultizedParams: any;
|
|
49
|
+
dependencies: any;
|
|
50
|
+
optionalDependencies: any;
|
|
51
|
+
publicAPI: any;
|
|
52
|
+
};
|
|
53
|
+
type ChartRequiredPlugins<TSignature extends ChartAnyPluginSignature> = [
|
|
54
|
+
...ChartCorePluginSignatures,
|
|
55
|
+
...TSignature['dependencies']
|
|
56
|
+
];
|
|
57
|
+
type PluginPropertyWithDependencies<TSignature extends ChartAnyPluginSignature, TProperty extends keyof ChartAnyPluginSignature> = TSignature[TProperty] & MergeSignaturesProperty<ChartRequiredPlugins<TSignature>, TProperty> & Partial<MergeSignaturesProperty<TSignature['optionalDependencies'], TProperty>>;
|
|
58
|
+
export type ChartUsedParams<TSignature extends ChartAnyPluginSignature> = PluginPropertyWithDependencies<TSignature, 'params'>;
|
|
59
|
+
type ChartUsedDefaultizedParams<TSignature extends ChartAnyPluginSignature> = PluginPropertyWithDependencies<TSignature, 'defaultizedParams'>;
|
|
60
|
+
export type ChartUsedInstance<TSignature extends ChartAnyPluginSignature> = PluginPropertyWithDependencies<TSignature, 'instance'> & {
|
|
61
|
+
/**
|
|
62
|
+
* Private property only defined in TypeScript to be able to access the plugin signature from the instance object.
|
|
63
|
+
*/
|
|
64
|
+
$$signature: TSignature;
|
|
65
|
+
};
|
|
66
|
+
export type ChartUsedStore<TSignature extends ChartAnyPluginSignature> = ChartStore<[
|
|
67
|
+
TSignature,
|
|
68
|
+
...TSignature['dependencies']
|
|
69
|
+
]>;
|
|
70
|
+
export type ChartPlugin<TSignature extends ChartAnyPluginSignature> = {
|
|
71
|
+
(options: ChartPluginOptions<TSignature>): ChartResponse<TSignature>;
|
|
72
|
+
getInitialState?: (params: ChartUsedDefaultizedParams<TSignature>) => TSignature['state'];
|
|
73
|
+
params: Record<keyof TSignature['params'], true>;
|
|
74
|
+
};
|
|
75
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { ChartState } from '../models';
|
|
1
|
+
import type { ChartState } from '../models/chart';
|
|
2
|
+
import type { ChartAnyPluginSignature } from '../models/plugin';
|
|
2
3
|
type Listener<T> = (value: T) => void;
|
|
3
|
-
export type StoreUpdater = (prevState: ChartState) => ChartState
|
|
4
|
-
export declare class ChartStore {
|
|
5
|
-
value: ChartState
|
|
4
|
+
export type StoreUpdater<TSignatures extends readonly ChartAnyPluginSignature[]> = (prevState: ChartState<TSignatures>) => ChartState<TSignatures>;
|
|
5
|
+
export declare class ChartStore<TSignatures extends readonly ChartAnyPluginSignature[]> {
|
|
6
|
+
value: ChartState<TSignatures>;
|
|
6
7
|
private listeners;
|
|
7
|
-
constructor(value: ChartState);
|
|
8
|
-
subscribe: (fn: Listener<ChartState
|
|
9
|
-
getSnapshot: () => ChartState
|
|
10
|
-
update: (updater: StoreUpdater) => void;
|
|
8
|
+
constructor(value: ChartState<TSignatures>);
|
|
9
|
+
subscribe: (fn: Listener<ChartState<TSignatures>>) => () => void;
|
|
10
|
+
getSnapshot: () => ChartState<TSignatures>;
|
|
11
|
+
update: (updater: StoreUpdater<TSignatures>) => void;
|
|
11
12
|
}
|
|
12
13
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CreateSelectorFunction } from 'reselect';
|
|
2
|
-
import { ChartState } from '../models';
|
|
3
|
-
export type
|
|
2
|
+
import { ChartAnyPluginSignature, ChartState } from '../models';
|
|
3
|
+
export type ChartRootSelector<TSignature extends ChartAnyPluginSignature> = <TSignatures extends [TSignature]>(state: ChartState<TSignatures>) => TSignature['state'][keyof TSignature['state']];
|
|
4
4
|
export type ChartsSelector<TState, TArgs, TResult> = (state: TState, args: TArgs) => TResult;
|
|
5
5
|
/**
|
|
6
6
|
* Method wrapping reselect's createSelector to provide caching for chart instances.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChartStore } from '../plugins/utils/ChartStore';
|
|
3
|
+
import { ChartAnyPluginSignature, ChartInstance, ChartPublicAPI, ConvertSignaturesIntoPlugins } from '../plugins/models';
|
|
4
|
+
import { UseChartBaseProps } from './useCharts.types';
|
|
5
|
+
import { UseChartInteractionState } from '../plugins/featurePlugins/useChartInteraction/useChartInteraction.types';
|
|
6
|
+
export declare function useChartApiInitialization<T>(inputApiRef: React.MutableRefObject<T | undefined> | undefined): T;
|
|
7
|
+
export declare function useCharts<TSignatures extends readonly ChartAnyPluginSignature[], TProps extends Partial<UseChartBaseProps<TSignatures>>>(inPlugins: ConvertSignaturesIntoPlugins<TSignatures>, props: TProps): {
|
|
8
|
+
contextValue: {
|
|
9
|
+
store: ChartStore<readonly [import("../plugins/corePlugins/useChartId").UseChartIdSignature, ...TSignatures]> & UseChartInteractionState;
|
|
10
|
+
publicAPI: ChartPublicAPI<TSignatures>;
|
|
11
|
+
instance: ChartInstance<TSignatures>;
|
|
12
|
+
svgRef: React.RefObject<SVGSVGElement>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChartStore } from "../plugins/utils/ChartStore.js";
|
|
3
|
+
import { CHART_CORE_PLUGINS } from "../plugins/corePlugins/index.js";
|
|
4
|
+
export function useChartApiInitialization(inputApiRef) {
|
|
5
|
+
const fallbackPublicApiRef = React.useRef({});
|
|
6
|
+
if (inputApiRef) {
|
|
7
|
+
if (inputApiRef.current == null) {
|
|
8
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
9
|
+
inputApiRef.current = {};
|
|
10
|
+
}
|
|
11
|
+
return inputApiRef.current;
|
|
12
|
+
}
|
|
13
|
+
return fallbackPublicApiRef.current;
|
|
14
|
+
}
|
|
15
|
+
let globalId = 0;
|
|
16
|
+
export function useCharts(inPlugins, props) {
|
|
17
|
+
const plugins = React.useMemo(() => [...CHART_CORE_PLUGINS, ...inPlugins], [inPlugins]);
|
|
18
|
+
const pluginParams = {}; // To generate when plugins use params.
|
|
19
|
+
const instanceRef = React.useRef({});
|
|
20
|
+
const instance = instanceRef.current;
|
|
21
|
+
const publicAPI = useChartApiInitialization(props.apiRef);
|
|
22
|
+
const innerSvgRef = React.useRef(null);
|
|
23
|
+
const storeRef = React.useRef(null);
|
|
24
|
+
if (storeRef.current == null) {
|
|
25
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
26
|
+
globalId += 1;
|
|
27
|
+
const initialState = {
|
|
28
|
+
// TODO remove when the interaction moves to plugin
|
|
29
|
+
interaction: {
|
|
30
|
+
item: null,
|
|
31
|
+
axis: {
|
|
32
|
+
x: null,
|
|
33
|
+
y: null
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
cacheKey: {
|
|
37
|
+
id: globalId
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
plugins.forEach(plugin => {
|
|
41
|
+
if (plugin.getInitialState) {
|
|
42
|
+
Object.assign(initialState, plugin.getInitialState({}));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
storeRef.current = new ChartStore(initialState);
|
|
46
|
+
}
|
|
47
|
+
const runPlugin = plugin => {
|
|
48
|
+
const pluginResponse = plugin({
|
|
49
|
+
instance,
|
|
50
|
+
params: pluginParams,
|
|
51
|
+
plugins: plugins,
|
|
52
|
+
store: storeRef.current,
|
|
53
|
+
svgRef: innerSvgRef
|
|
54
|
+
});
|
|
55
|
+
if (pluginResponse.publicAPI) {
|
|
56
|
+
Object.assign(publicAPI, pluginResponse.publicAPI);
|
|
57
|
+
}
|
|
58
|
+
if (pluginResponse.instance) {
|
|
59
|
+
Object.assign(instance, pluginResponse.instance);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
plugins.forEach(runPlugin);
|
|
63
|
+
const contextValue = React.useMemo(() => ({
|
|
64
|
+
store: storeRef.current,
|
|
65
|
+
publicAPI,
|
|
66
|
+
instance,
|
|
67
|
+
svgRef: innerSvgRef
|
|
68
|
+
}), [instance, publicAPI]);
|
|
69
|
+
return {
|
|
70
|
+
contextValue
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChartAnyPluginSignature, ChartPublicAPI } from '../plugins/models';
|
|
3
|
+
export interface UseChartBaseProps<TSignatures extends readonly ChartAnyPluginSignature[]> {
|
|
4
|
+
apiRef: React.MutableRefObject<ChartPublicAPI<TSignatures> | undefined> | undefined;
|
|
5
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ChartAnyPluginSignature, ChartState } from '../plugins/models';
|
|
2
|
+
import { ChartsSelector } from '../plugins/utils/selectors';
|
|
3
|
+
import { ChartStore } from '../plugins/utils/ChartStore';
|
|
4
|
+
export declare const useSelector: <TSignatures extends readonly ChartAnyPluginSignature[], TArgs, TValue>(store: ChartStore<TSignatures>, selector: ChartsSelector<ChartState<TSignatures>, TArgs, TValue>, args?: TArgs, equals?: (a: TValue, b: TValue) => boolean) => TValue;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ChartStore } from '../plugins/utils/ChartStore';
|
|
2
|
+
import { UseChartInteractionSignature } from '../plugins/featurePlugins/useChartInteraction/useChartInteraction.types';
|
|
3
|
+
export declare function useStore(skipError?: boolean): ChartStore<[UseChartInteractionSignature]>;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { useChartContext } from "../../context/ChartProvider/index.js";
|
|
2
|
+
// This hook should be removed because user and us should not interact with the store directly, but with public/private APIs
|
|
3
3
|
export function useStore(skipError) {
|
|
4
|
-
const
|
|
4
|
+
const context = useChartContext();
|
|
5
5
|
if (skipError) {
|
|
6
6
|
// TODO: Remove once store is used by all charts.
|
|
7
7
|
// This line is only for `useAxisEvents` which is in the surface of the Gauge.
|
|
8
8
|
// But the Gauge don't have store yet because it does not need the interaction provider.
|
|
9
9
|
// Will be fixed when every thing move to the store since every component will have access to it.
|
|
10
10
|
// @ts-ignore
|
|
11
|
-
return
|
|
11
|
+
return context?.store;
|
|
12
12
|
}
|
|
13
|
-
if (!
|
|
13
|
+
if (!context) {
|
|
14
14
|
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'));
|
|
15
15
|
}
|
|
16
|
-
return
|
|
16
|
+
return context.store;
|
|
17
17
|
}
|
package/models/axis.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ScaleBand, ScaleLogarithmic, ScalePower, ScaleTime, ScaleLinear, ScalePoint, ScaleOrdinal, ScaleSequential, ScaleThreshold } from '@mui/x-charts-vendor/d3-scale';
|
|
2
|
-
import { SxProps } from '@mui/system';
|
|
2
|
+
import { SxProps } from '@mui/system/styleFunctionSx';
|
|
3
3
|
import { ChartsAxisClasses } from '../ChartsAxis/axisClasses';
|
|
4
4
|
import type { TickParams } from '../hooks/useTicks';
|
|
5
5
|
import { ChartsTextProps } from '../ChartsText';
|
|
@@ -58,12 +58,6 @@ export interface ChartsAxisProps extends TickParams {
|
|
|
58
58
|
* @default 'currentColor'
|
|
59
59
|
*/
|
|
60
60
|
fill?: string;
|
|
61
|
-
/**
|
|
62
|
-
* The font size of the axis ticks text.
|
|
63
|
-
* @default 12
|
|
64
|
-
* @deprecated Consider using `tickLabelStyle.fontSize` instead.
|
|
65
|
-
*/
|
|
66
|
-
tickFontSize?: number;
|
|
67
61
|
/**
|
|
68
62
|
* The style applied to ticks text.
|
|
69
63
|
*/
|
|
@@ -83,12 +77,6 @@ export interface ChartsAxisProps extends TickParams {
|
|
|
83
77
|
* The label of the axis.
|
|
84
78
|
*/
|
|
85
79
|
label?: string;
|
|
86
|
-
/**
|
|
87
|
-
* The font size of the axis label.
|
|
88
|
-
* @default 14
|
|
89
|
-
* @deprecated Consider using `labelStyle.fontSize` instead.
|
|
90
|
-
*/
|
|
91
|
-
labelFontSize?: number;
|
|
92
80
|
/**
|
|
93
81
|
* The stroke color of the axis line.
|
|
94
82
|
* @default 'currentColor'
|
|
@@ -243,7 +243,6 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
243
243
|
hideTooltip: PropTypes.bool,
|
|
244
244
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
245
245
|
label: PropTypes.string,
|
|
246
|
-
labelFontSize: PropTypes.number,
|
|
247
246
|
labelStyle: PropTypes.object,
|
|
248
247
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
249
248
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -254,7 +253,6 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
254
253
|
slots: PropTypes.object,
|
|
255
254
|
stroke: PropTypes.string,
|
|
256
255
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
257
|
-
tickFontSize: PropTypes.number,
|
|
258
256
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
259
257
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
260
258
|
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
@@ -297,7 +295,6 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
297
295
|
hideTooltip: PropTypes.bool,
|
|
298
296
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
299
297
|
label: PropTypes.string,
|
|
300
|
-
labelFontSize: PropTypes.number,
|
|
301
298
|
labelStyle: PropTypes.object,
|
|
302
299
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
303
300
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -308,7 +305,6 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
308
305
|
slots: PropTypes.object,
|
|
309
306
|
stroke: PropTypes.string,
|
|
310
307
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
311
|
-
tickFontSize: PropTypes.number,
|
|
312
308
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
313
309
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
314
310
|
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
@@ -4,22 +4,42 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { ChartDataProvider } from "../context/ChartDataProvider/index.js";
|
|
7
|
-
import { ResizableContainer } from "./ResizableContainer.js";
|
|
8
7
|
import { useChartContainerProps } from "./useChartContainerProps.js";
|
|
9
8
|
import { ChartsSurface } from "../ChartsSurface/index.js";
|
|
10
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
/**
|
|
11
|
+
* It sets up the data providers as well as the `<svg>` for the chart.
|
|
12
|
+
*
|
|
13
|
+
* This is a combination of both the `ChartDataProvider` and `ChartsSurface` components.
|
|
14
|
+
*
|
|
15
|
+
* Demos:
|
|
16
|
+
*
|
|
17
|
+
* - [Composition](http://localhost:3001/x/react-charts/composition/)
|
|
18
|
+
*
|
|
19
|
+
* API:
|
|
20
|
+
*
|
|
21
|
+
* - [ChartContainer API](https://mui.com/x/api/charts/chart-container/)
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```jsx
|
|
25
|
+
* <ChartContainer
|
|
26
|
+
* series={[{ label: "Label", type: "bar", data: [10, 20] }]}
|
|
27
|
+
* xAxis={[{ data: ["A", "B"], scaleType: "band", id: "x-axis" }]}
|
|
28
|
+
* >
|
|
29
|
+
* <BarPlot />
|
|
30
|
+
* <ChartsXAxis position="bottom" axisId="x-axis" />
|
|
31
|
+
* </ChartContainer>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
11
34
|
const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(props, ref) {
|
|
12
35
|
const {
|
|
13
36
|
chartDataProviderProps,
|
|
14
37
|
children,
|
|
15
|
-
resizableContainerProps,
|
|
16
38
|
chartsSurfaceProps
|
|
17
39
|
} = useChartContainerProps(props, ref);
|
|
18
40
|
return /*#__PURE__*/_jsx(ChartDataProvider, _extends({}, chartDataProviderProps, {
|
|
19
|
-
children: /*#__PURE__*/_jsx(
|
|
20
|
-
children:
|
|
21
|
-
children: children
|
|
22
|
-
}))
|
|
41
|
+
children: /*#__PURE__*/_jsx(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
42
|
+
children: children
|
|
23
43
|
}))
|
|
24
44
|
}));
|
|
25
45
|
});
|
|
@@ -128,7 +148,6 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
128
148
|
hideTooltip: PropTypes.bool,
|
|
129
149
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
130
150
|
label: PropTypes.string,
|
|
131
|
-
labelFontSize: PropTypes.number,
|
|
132
151
|
labelStyle: PropTypes.object,
|
|
133
152
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
134
153
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -139,7 +158,6 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
139
158
|
slots: PropTypes.object,
|
|
140
159
|
stroke: PropTypes.string,
|
|
141
160
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
142
|
-
tickFontSize: PropTypes.number,
|
|
143
161
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
144
162
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
145
163
|
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
@@ -182,7 +200,6 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
182
200
|
hideTooltip: PropTypes.bool,
|
|
183
201
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
184
202
|
label: PropTypes.string,
|
|
185
|
-
labelFontSize: PropTypes.number,
|
|
186
203
|
labelStyle: PropTypes.object,
|
|
187
204
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
188
205
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
@@ -193,7 +210,6 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
193
210
|
slots: PropTypes.object,
|
|
194
211
|
stroke: PropTypes.string,
|
|
195
212
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
196
|
-
tickFontSize: PropTypes.number,
|
|
197
213
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
198
214
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
199
215
|
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
5
|
const _excluded = ["width", "height", "margin", "children", "series", "colors", "dataset", "desc", "disableAxisListener", "highlightedItem", "onHighlightChange", "plugins", "sx", "title", "xAxis", "yAxis", "zAxis", "skipAnimation"];
|
|
5
6
|
export const useChartContainerProps = (props, ref) => {
|
|
@@ -24,14 +25,13 @@ export const useChartContainerProps = (props, ref) => {
|
|
|
24
25
|
skipAnimation
|
|
25
26
|
} = props,
|
|
26
27
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
27
|
-
const
|
|
28
|
-
const chartsSurfaceProps = {
|
|
28
|
+
const chartsSurfaceProps = _extends({
|
|
29
29
|
title,
|
|
30
30
|
desc,
|
|
31
31
|
sx,
|
|
32
32
|
disableAxisListener,
|
|
33
33
|
ref
|
|
34
|
-
};
|
|
34
|
+
}, other);
|
|
35
35
|
const chartDataProviderProps = {
|
|
36
36
|
margin,
|
|
37
37
|
series,
|
|
@@ -49,7 +49,6 @@ export const useChartContainerProps = (props, ref) => {
|
|
|
49
49
|
};
|
|
50
50
|
return {
|
|
51
51
|
chartDataProviderProps,
|
|
52
|
-
resizableContainerProps,
|
|
53
52
|
chartsSurfaceProps,
|
|
54
53
|
children
|
|
55
54
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
2
3
|
export function getAxisUtilityClass(slot) {
|
|
3
4
|
return generateUtilityClass('MuiChartsAxis', slot);
|
|
4
5
|
}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { getValueToPositionMapper, useXScale } from "../hooks/useScale.js";
|
|
5
5
|
import { isBandScale } from "../internals/isBandScale.js";
|
|
6
|
-
import { useSelector } from "../internals/useSelector.js";
|
|
7
|
-
import { useStore } from "../internals/useStore.js";
|
|
8
|
-
import { selectorChartsInteractionXAxis } from "../
|
|
6
|
+
import { useSelector } from "../internals/store/useSelector.js";
|
|
7
|
+
import { useStore } from "../internals/store/useStore.js";
|
|
8
|
+
import { selectorChartsInteractionXAxis } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
|
|
9
9
|
import { useDrawingArea } from "../hooks/index.js";
|
|
10
10
|
import { ChartsAxisHighlightPath } from "./ChartsAxisHighlightPath.js";
|
|
11
11
|
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { getValueToPositionMapper, useYScale } from "../hooks/useScale.js";
|
|
5
5
|
import { isBandScale } from "../internals/isBandScale.js";
|
|
6
|
-
import { useSelector } from "../internals/useSelector.js";
|
|
7
|
-
import { useStore } from "../internals/useStore.js";
|
|
8
|
-
import { selectorChartsInteractionYAxis } from "../
|
|
6
|
+
import { useSelector } from "../internals/store/useSelector.js";
|
|
7
|
+
import { useStore } from "../internals/store/useStore.js";
|
|
8
|
+
import { selectorChartsInteractionYAxis } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
|
|
9
9
|
import { useDrawingArea } from "../hooks/index.js";
|
|
10
10
|
import { ChartsAxisHighlightPath } from "./ChartsAxisHighlightPath.js";
|
|
11
11
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
2
3
|
export function getLegendUtilityClass(slot) {
|
|
3
4
|
return generateUtilityClass('MuiChartsLegend', slot);
|
|
4
5
|
}
|
|
@@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
|
|
|
5
5
|
import { useSeries } from "../hooks/useSeries.js";
|
|
6
6
|
import { useSvgRef } from "../hooks/index.js";
|
|
7
7
|
import { useCartesianContext } from "../context/CartesianProvider/index.js";
|
|
8
|
-
import { useStore } from "../internals/useStore.js";
|
|
8
|
+
import { useStore } from "../internals/store/useStore.js";
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
function ChartsOnAxisClickHandler(props) {
|
|
11
11
|
const {
|
|
@@ -9,18 +9,43 @@ import * as React from 'react';
|
|
|
9
9
|
import useForkRef from '@mui/utils/useForkRef';
|
|
10
10
|
import { useAxisEvents } from "../hooks/useAxisEvents.js";
|
|
11
11
|
import { ChartsAxesGradients } from "../internals/components/ChartsAxesGradients/index.js";
|
|
12
|
-
import { useDrawingArea } from "../hooks/index.js";
|
|
13
|
-
import { useSurfaceRef } from "../context/SvgRefProvider/index.js";
|
|
12
|
+
import { useDrawingArea, useSvgRef } from "../hooks/index.js";
|
|
14
13
|
import { useSize } from "../context/SizeProvider/index.js";
|
|
15
14
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
15
|
const ChartsSurfaceStyles = styled('svg', {
|
|
17
16
|
name: 'MuiChartsSurface',
|
|
18
17
|
slot: 'Root'
|
|
19
|
-
})((
|
|
18
|
+
})(({
|
|
19
|
+
ownerState
|
|
20
|
+
}) => ({
|
|
21
|
+
width: ownerState.width ?? '100%',
|
|
22
|
+
height: ownerState.height ?? '100%',
|
|
23
|
+
display: 'flex',
|
|
24
|
+
position: 'relative',
|
|
25
|
+
flexGrow: 1,
|
|
26
|
+
flexDirection: 'column',
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
justifyContent: 'center',
|
|
29
|
+
overflow: 'hidden',
|
|
20
30
|
// This prevents default touch actions when using the svg on mobile devices.
|
|
21
31
|
// For example, prevent page scroll & zoom.
|
|
22
32
|
touchAction: 'none'
|
|
23
33
|
}));
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* It provides the drawing area for the chart elements.
|
|
37
|
+
* It is the root `<svg>` of all the chart elements.
|
|
38
|
+
*
|
|
39
|
+
* It also provides the `title` and `desc` elements for the chart.
|
|
40
|
+
*
|
|
41
|
+
* Demos:
|
|
42
|
+
*
|
|
43
|
+
* - [Composition](http://localhost:3001/x/react-charts/composition/)
|
|
44
|
+
*
|
|
45
|
+
* API:
|
|
46
|
+
*
|
|
47
|
+
* - [ChartsSurface API](https://mui.com/x/api/charts/charts-surface/)
|
|
48
|
+
*/
|
|
24
49
|
const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(inProps, ref) {
|
|
25
50
|
const {
|
|
26
51
|
width,
|
|
@@ -31,10 +56,13 @@ const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(inPro
|
|
|
31
56
|
bottom
|
|
32
57
|
} = useDrawingArea();
|
|
33
58
|
const {
|
|
34
|
-
hasIntrinsicSize
|
|
59
|
+
hasIntrinsicSize,
|
|
60
|
+
svgRef: containerRef,
|
|
61
|
+
inHeight,
|
|
62
|
+
inWidth
|
|
35
63
|
} = useSize();
|
|
36
|
-
const
|
|
37
|
-
const handleRef = useForkRef(
|
|
64
|
+
const svgRef = useSvgRef();
|
|
65
|
+
const handleRef = useForkRef(containerRef, svgRef, ref);
|
|
38
66
|
const themeProps = useThemeProps({
|
|
39
67
|
props: inProps,
|
|
40
68
|
name: 'MuiChartsSurface'
|
|
@@ -57,6 +85,10 @@ const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(inPro
|
|
|
57
85
|
};
|
|
58
86
|
useAxisEvents(disableAxisListener);
|
|
59
87
|
return /*#__PURE__*/_jsxs(ChartsSurfaceStyles, _extends({
|
|
88
|
+
ownerState: {
|
|
89
|
+
width: inWidth,
|
|
90
|
+
height: inHeight
|
|
91
|
+
},
|
|
60
92
|
viewBox: `${svgView.x} ${svgView.y} ${svgView.width} ${svgView.height}`,
|
|
61
93
|
className: className
|
|
62
94
|
}, other, {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
+
import HTMLElementType from '@mui/utils/HTMLElementType';
|
|
6
7
|
import { ChartsItemTooltipContent } from "./ChartsItemTooltipContent.js";
|
|
7
8
|
import { ChartsAxisTooltipContent } from "./ChartsAxisTooltipContent.js";
|
|
8
9
|
import { ChartsTooltipContainer } from "./ChartsTooltipContainer.js";
|
|
@@ -43,26 +44,7 @@ process.env.NODE_ENV !== "production" ? ChartsTooltip.propTypes = {
|
|
|
43
44
|
* It's used to set the position of the popper.
|
|
44
45
|
* The return value will passed as the reference object of the Popper instance.
|
|
45
46
|
*/
|
|
46
|
-
anchorEl: PropTypes
|
|
47
|
-
if (props[propName] == null) {
|
|
48
|
-
return new Error(`Prop '${propName}' is required but wasn't specified`);
|
|
49
|
-
}
|
|
50
|
-
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
51
|
-
return new Error(`Expected prop '${propName}' to be of type Element`);
|
|
52
|
-
}
|
|
53
|
-
return null;
|
|
54
|
-
}, PropTypes.func, PropTypes.shape({
|
|
55
|
-
contextElement: (props, propName) => {
|
|
56
|
-
if (props[propName] == null) {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
60
|
-
return new Error(`Expected prop '${propName}' to be of type Element`);
|
|
61
|
-
}
|
|
62
|
-
return null;
|
|
63
|
-
},
|
|
64
|
-
getBoundingClientRect: PropTypes.func.isRequired
|
|
65
|
-
})]),
|
|
47
|
+
anchorEl: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([HTMLElementType, PropTypes.object, PropTypes.func]),
|
|
66
48
|
/**
|
|
67
49
|
* Override or extend the styles applied to the component.
|
|
68
50
|
*/
|
|
@@ -5,16 +5,17 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
5
5
|
const _excluded = ["trigger", "classes", "children"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
+
import HTMLElementType from '@mui/utils/HTMLElementType';
|
|
8
9
|
import useLazyRef from '@mui/utils/useLazyRef';
|
|
9
10
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
10
11
|
import Popper from '@mui/material/Popper';
|
|
11
12
|
import NoSsr from '@mui/material/NoSsr';
|
|
12
13
|
import { useSvgRef } from "../hooks/useSvgRef.js";
|
|
13
14
|
import { usePointerType } from "./utils.js";
|
|
14
|
-
import { useSelector } from "../internals/useSelector.js";
|
|
15
|
-
import { useStore } from "../internals/useStore.js";
|
|
15
|
+
import { useSelector } from "../internals/store/useSelector.js";
|
|
16
|
+
import { useStore } from "../internals/store/useStore.js";
|
|
16
17
|
import { useXAxis } from "../hooks/index.js";
|
|
17
|
-
import { selectorChartsInteractionItemIsDefined, selectorChartsInteractionXAxisIsDefined, selectorChartsInteractionYAxisIsDefined } from "../
|
|
18
|
+
import { selectorChartsInteractionItemIsDefined, selectorChartsInteractionXAxisIsDefined, selectorChartsInteractionYAxisIsDefined } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
|
|
18
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
20
|
const ChartsTooltipRoot = styled(Popper, {
|
|
20
21
|
name: 'MuiChartsTooltip',
|
|
@@ -124,26 +125,7 @@ process.env.NODE_ENV !== "production" ? ChartsTooltipContainer.propTypes = {
|
|
|
124
125
|
* It's used to set the position of the popper.
|
|
125
126
|
* The return value will passed as the reference object of the Popper instance.
|
|
126
127
|
*/
|
|
127
|
-
anchorEl: PropTypes
|
|
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
|
-
})]),
|
|
128
|
+
anchorEl: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([HTMLElementType, PropTypes.object, PropTypes.func]),
|
|
147
129
|
/**
|
|
148
130
|
* Popper render function or node.
|
|
149
131
|
*/
|