@mui/x-charts 7.7.0 → 7.7.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/BarChart.js +21 -104
- package/BarChart/BarLabel/BarLabelPlot.d.ts +0 -3
- package/BarChart/BarLabel/BarLabelPlot.js +1 -24
- package/BarChart/BarPlot.js +2 -2
- package/BarChart/checkScaleErrors.d.ts +5 -9
- package/BarChart/types.d.ts +2 -2
- package/BarChart/useBarChartProps.d.ts +102 -0
- package/BarChart/useBarChartProps.js +143 -0
- package/CHANGELOG.md +82 -0
- package/ChartContainer/ChartContainer.d.ts +1 -1
- package/ChartContainer/ChartContainer.js +6 -10
- package/ChartContainer/useChartContainerHooks.d.ts +11 -0
- package/ChartContainer/useChartContainerHooks.js +34 -0
- package/ChartContainer/usePluginsMerge.d.ts +1 -2
- package/ChartsAxis/ChartsAxis.js +2 -2
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
- package/ChartsGrid/ChartsGrid.js +2 -2
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
- package/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
- package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
- package/ChartsXAxis/ChartsXAxis.js +2 -2
- package/ChartsYAxis/ChartsYAxis.js +2 -2
- package/LineChart/AreaPlot.js +2 -2
- package/LineChart/LineChart.js +24 -106
- package/LineChart/LineHighlightPlot.js +2 -2
- package/LineChart/LinePlot.js +2 -2
- package/LineChart/MarkPlot.js +2 -2
- package/LineChart/useLineChartProps.d.ts +117 -0
- package/LineChart/useLineChartProps.js +152 -0
- package/ScatterChart/ScatterChart.js +20 -75
- package/ScatterChart/ScatterPlot.js +2 -2
- package/ScatterChart/useScatterChartProps.d.ts +86 -0
- package/ScatterChart/useScatterChartProps.js +116 -0
- package/context/CartesianProvider/CartesianContext.d.ts +25 -0
- package/context/CartesianProvider/CartesianContext.js +21 -0
- package/context/CartesianProvider/CartesianProvider.d.ts +34 -0
- package/context/CartesianProvider/CartesianProvider.js +44 -0
- package/context/CartesianProvider/computeValue.d.ts +19 -0
- package/context/CartesianProvider/computeValue.js +89 -0
- package/context/CartesianProvider/getAxisExtremum.d.ts +4 -0
- package/context/CartesianProvider/getAxisExtremum.js +28 -0
- package/context/CartesianProvider/index.d.ts +9 -0
- package/context/CartesianProvider/index.js +51 -0
- package/context/CartesianProvider/normalizeAxis.d.ts +5 -0
- package/context/CartesianProvider/normalizeAxis.js +23 -0
- package/context/CartesianProvider/useCartesianContext.d.ts +2 -0
- package/context/CartesianProvider/useCartesianContext.js +17 -0
- package/context/ColorProvider.d.ts +2 -2
- package/esm/BarChart/BarChart.js +21 -104
- package/esm/BarChart/BarLabel/BarLabelPlot.js +0 -23
- package/esm/BarChart/BarPlot.js +2 -2
- package/esm/BarChart/useBarChartProps.js +136 -0
- package/esm/ChartContainer/ChartContainer.js +5 -9
- package/esm/ChartContainer/useChartContainerHooks.js +24 -0
- package/esm/ChartsAxis/ChartsAxis.js +2 -2
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
- package/esm/ChartsGrid/ChartsGrid.js +2 -2
- package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
- package/esm/ChartsXAxis/ChartsXAxis.js +2 -2
- package/esm/ChartsYAxis/ChartsYAxis.js +2 -2
- package/esm/LineChart/AreaPlot.js +2 -2
- package/esm/LineChart/LineChart.js +24 -106
- package/esm/LineChart/LineHighlightPlot.js +2 -2
- package/esm/LineChart/LinePlot.js +2 -2
- package/esm/LineChart/MarkPlot.js +2 -2
- package/esm/LineChart/useLineChartProps.js +144 -0
- package/esm/ScatterChart/ScatterChart.js +20 -75
- package/esm/ScatterChart/ScatterPlot.js +2 -2
- package/esm/ScatterChart/useScatterChartProps.js +108 -0
- package/esm/context/CartesianProvider/CartesianContext.js +13 -0
- package/esm/context/CartesianProvider/CartesianProvider.js +37 -0
- package/esm/context/CartesianProvider/computeValue.js +82 -0
- package/esm/context/CartesianProvider/getAxisExtremum.js +21 -0
- package/esm/context/CartesianProvider/index.js +10 -0
- package/esm/context/CartesianProvider/normalizeAxis.js +15 -0
- package/esm/context/CartesianProvider/useCartesianContext.js +8 -0
- package/esm/hooks/useAxisEvents.js +2 -2
- package/esm/hooks/useColorScale.js +3 -3
- package/esm/hooks/useScale.js +3 -4
- package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
- package/esm/internals/index.js +6 -2
- package/hooks/useAxisEvents.js +2 -2
- package/hooks/useColorScale.js +3 -3
- package/hooks/useDrawingArea.d.ts +2 -8
- package/hooks/useScale.js +3 -6
- package/index.js +1 -1
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +2 -1
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
- package/internals/index.d.ts +7 -1
- package/internals/index.js +49 -5
- package/models/plugin.d.ts +4 -1
- package/modern/BarChart/BarChart.js +21 -104
- package/modern/BarChart/BarLabel/BarLabelPlot.js +0 -23
- package/modern/BarChart/BarPlot.js +2 -2
- package/modern/BarChart/useBarChartProps.js +136 -0
- package/modern/ChartContainer/ChartContainer.js +5 -9
- package/modern/ChartContainer/useChartContainerHooks.js +24 -0
- package/modern/ChartsAxis/ChartsAxis.js +2 -2
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
- package/modern/ChartsGrid/ChartsGrid.js +2 -2
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
- package/modern/ChartsXAxis/ChartsXAxis.js +2 -2
- package/modern/ChartsYAxis/ChartsYAxis.js +2 -2
- package/modern/LineChart/AreaPlot.js +2 -2
- package/modern/LineChart/LineChart.js +24 -106
- package/modern/LineChart/LineHighlightPlot.js +2 -2
- package/modern/LineChart/LinePlot.js +2 -2
- package/modern/LineChart/MarkPlot.js +2 -2
- package/modern/LineChart/useLineChartProps.js +144 -0
- package/modern/ScatterChart/ScatterChart.js +20 -75
- package/modern/ScatterChart/ScatterPlot.js +2 -2
- package/modern/ScatterChart/useScatterChartProps.js +108 -0
- package/modern/context/CartesianProvider/CartesianContext.js +13 -0
- package/modern/context/CartesianProvider/CartesianProvider.js +37 -0
- package/modern/context/CartesianProvider/computeValue.js +82 -0
- package/modern/context/CartesianProvider/getAxisExtremum.js +21 -0
- package/modern/context/CartesianProvider/index.js +10 -0
- package/modern/context/CartesianProvider/normalizeAxis.js +15 -0
- package/modern/context/CartesianProvider/useCartesianContext.js +8 -0
- package/modern/hooks/useAxisEvents.js +2 -2
- package/modern/hooks/useColorScale.js +3 -3
- package/modern/hooks/useScale.js +3 -4
- package/modern/index.js +1 -1
- package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
- package/modern/internals/index.js +6 -2
- package/package.json +3 -3
- package/context/CartesianContextProvider.d.ts +0 -61
- package/context/CartesianContextProvider.js +0 -220
- package/esm/context/CartesianContextProvider.js +0 -211
- package/modern/context/CartesianContextProvider.js +0 -211
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useLineChartProps = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _useId = _interopRequireDefault(require("@mui/utils/useId"));
|
|
10
|
+
var _constants = require("../constants");
|
|
11
|
+
/**
|
|
12
|
+
* A helper function that extracts LineChartProps from the input props
|
|
13
|
+
* and returns an object with props for the children components of LineChart.
|
|
14
|
+
*
|
|
15
|
+
* @param props The input props for LineChart
|
|
16
|
+
* @returns An object with props for the children components of LineChart
|
|
17
|
+
*/
|
|
18
|
+
const useLineChartProps = props => {
|
|
19
|
+
const {
|
|
20
|
+
xAxis,
|
|
21
|
+
yAxis,
|
|
22
|
+
series,
|
|
23
|
+
width,
|
|
24
|
+
height,
|
|
25
|
+
margin,
|
|
26
|
+
colors,
|
|
27
|
+
dataset,
|
|
28
|
+
sx,
|
|
29
|
+
tooltip,
|
|
30
|
+
onAxisClick,
|
|
31
|
+
onAreaClick,
|
|
32
|
+
onLineClick,
|
|
33
|
+
onMarkClick,
|
|
34
|
+
axisHighlight,
|
|
35
|
+
disableLineItemHighlight,
|
|
36
|
+
legend,
|
|
37
|
+
grid,
|
|
38
|
+
topAxis,
|
|
39
|
+
leftAxis,
|
|
40
|
+
rightAxis,
|
|
41
|
+
bottomAxis,
|
|
42
|
+
children,
|
|
43
|
+
slots,
|
|
44
|
+
slotProps,
|
|
45
|
+
skipAnimation,
|
|
46
|
+
loading,
|
|
47
|
+
highlightedItem,
|
|
48
|
+
onHighlightChange
|
|
49
|
+
} = props;
|
|
50
|
+
const id = (0, _useId.default)();
|
|
51
|
+
const clipPathId = `${id}-clip-path`;
|
|
52
|
+
const chartContainerProps = {
|
|
53
|
+
series: series.map(s => (0, _extends2.default)({
|
|
54
|
+
disableHighlight: !!disableLineItemHighlight,
|
|
55
|
+
type: 'line'
|
|
56
|
+
}, s)),
|
|
57
|
+
width,
|
|
58
|
+
height,
|
|
59
|
+
margin,
|
|
60
|
+
colors,
|
|
61
|
+
dataset,
|
|
62
|
+
xAxis: xAxis ?? [{
|
|
63
|
+
id: _constants.DEFAULT_X_AXIS_KEY,
|
|
64
|
+
scaleType: 'point',
|
|
65
|
+
data: Array.from({
|
|
66
|
+
length: Math.max(...series.map(s => (s.data ?? dataset ?? []).length))
|
|
67
|
+
}, (_, index) => index)
|
|
68
|
+
}],
|
|
69
|
+
yAxis,
|
|
70
|
+
sx,
|
|
71
|
+
highlightedItem,
|
|
72
|
+
onHighlightChange,
|
|
73
|
+
disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick
|
|
74
|
+
};
|
|
75
|
+
const axisClickHandlerProps = {
|
|
76
|
+
onAxisClick
|
|
77
|
+
};
|
|
78
|
+
const gridProps = {
|
|
79
|
+
vertical: grid?.vertical,
|
|
80
|
+
horizontal: grid?.horizontal
|
|
81
|
+
};
|
|
82
|
+
const clipPathGroupProps = {
|
|
83
|
+
clipPath: `url(#${clipPathId})`
|
|
84
|
+
};
|
|
85
|
+
const clipPathProps = {
|
|
86
|
+
id: clipPathId
|
|
87
|
+
};
|
|
88
|
+
const areaPlotProps = {
|
|
89
|
+
slots,
|
|
90
|
+
slotProps,
|
|
91
|
+
onAreaClick,
|
|
92
|
+
skipAnimation
|
|
93
|
+
};
|
|
94
|
+
const linePlotProps = {
|
|
95
|
+
slots,
|
|
96
|
+
slotProps,
|
|
97
|
+
onLineClick,
|
|
98
|
+
skipAnimation
|
|
99
|
+
};
|
|
100
|
+
const markPlotProps = {
|
|
101
|
+
slots,
|
|
102
|
+
slotProps,
|
|
103
|
+
onMarkClick,
|
|
104
|
+
skipAnimation
|
|
105
|
+
};
|
|
106
|
+
const overlayProps = {
|
|
107
|
+
slots,
|
|
108
|
+
slotProps,
|
|
109
|
+
loading
|
|
110
|
+
};
|
|
111
|
+
const chartsAxisProps = {
|
|
112
|
+
topAxis,
|
|
113
|
+
leftAxis,
|
|
114
|
+
rightAxis,
|
|
115
|
+
bottomAxis,
|
|
116
|
+
slots,
|
|
117
|
+
slotProps
|
|
118
|
+
};
|
|
119
|
+
const axisHighlightProps = (0, _extends2.default)({
|
|
120
|
+
x: 'line'
|
|
121
|
+
}, axisHighlight);
|
|
122
|
+
const lineHighlightPlotProps = {
|
|
123
|
+
slots,
|
|
124
|
+
slotProps
|
|
125
|
+
};
|
|
126
|
+
const legendProps = (0, _extends2.default)({}, legend, {
|
|
127
|
+
slots,
|
|
128
|
+
slotProps
|
|
129
|
+
});
|
|
130
|
+
const tooltipProps = (0, _extends2.default)({}, tooltip, {
|
|
131
|
+
slots,
|
|
132
|
+
slotProps
|
|
133
|
+
});
|
|
134
|
+
return {
|
|
135
|
+
chartContainerProps,
|
|
136
|
+
axisClickHandlerProps,
|
|
137
|
+
gridProps,
|
|
138
|
+
clipPathProps,
|
|
139
|
+
clipPathGroupProps,
|
|
140
|
+
areaPlotProps,
|
|
141
|
+
linePlotProps,
|
|
142
|
+
markPlotProps,
|
|
143
|
+
overlayProps,
|
|
144
|
+
chartsAxisProps,
|
|
145
|
+
axisHighlightProps,
|
|
146
|
+
lineHighlightPlotProps,
|
|
147
|
+
legendProps,
|
|
148
|
+
tooltipProps,
|
|
149
|
+
children
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
exports.useLineChartProps = useLineChartProps;
|
|
@@ -18,6 +18,7 @@ var _ChartsAxisHighlight = require("../ChartsAxisHighlight");
|
|
|
18
18
|
var _ChartsVoronoiHandler = require("../ChartsVoronoiHandler/ChartsVoronoiHandler");
|
|
19
19
|
var _ChartsGrid = require("../ChartsGrid");
|
|
20
20
|
var _ZAxisContextProvider = require("../context/ZAxisContextProvider");
|
|
21
|
+
var _useScatterChartProps = require("./useScatterChartProps");
|
|
21
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
23
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
23
24
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -33,81 +34,25 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
33
34
|
*/
|
|
34
35
|
const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props, ref) {
|
|
35
36
|
const {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
onItemClick,
|
|
56
|
-
children,
|
|
57
|
-
slots,
|
|
58
|
-
slotProps,
|
|
59
|
-
loading,
|
|
60
|
-
highlightedItem,
|
|
61
|
-
onHighlightChange
|
|
62
|
-
} = props;
|
|
63
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ResponsiveChartContainer.ResponsiveChartContainer, {
|
|
64
|
-
ref: ref,
|
|
65
|
-
series: series.map(s => (0, _extends2.default)({
|
|
66
|
-
type: 'scatter'
|
|
67
|
-
}, s)),
|
|
68
|
-
width: width,
|
|
69
|
-
height: height,
|
|
70
|
-
margin: margin,
|
|
71
|
-
colors: colors,
|
|
72
|
-
xAxis: xAxis,
|
|
73
|
-
yAxis: yAxis,
|
|
74
|
-
sx: sx,
|
|
75
|
-
highlightedItem: highlightedItem,
|
|
76
|
-
onHighlightChange: onHighlightChange,
|
|
77
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ZAxisContextProvider.ZAxisContextProvider, {
|
|
78
|
-
zAxis: zAxis,
|
|
79
|
-
children: [!disableVoronoi && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsVoronoiHandler.ChartsVoronoiHandler, {
|
|
80
|
-
voronoiMaxRadius: voronoiMaxRadius,
|
|
81
|
-
onItemClick: onItemClick
|
|
82
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, {
|
|
83
|
-
topAxis: topAxis,
|
|
84
|
-
leftAxis: leftAxis,
|
|
85
|
-
rightAxis: rightAxis,
|
|
86
|
-
bottomAxis: bottomAxis,
|
|
87
|
-
slots: slots,
|
|
88
|
-
slotProps: slotProps
|
|
89
|
-
}), grid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, {
|
|
90
|
-
vertical: grid.vertical,
|
|
91
|
-
horizontal: grid.horizontal
|
|
92
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScatterPlot.ScatterPlot, {
|
|
93
|
-
slots: slots,
|
|
94
|
-
slotProps: slotProps,
|
|
95
|
-
onItemClick: disableVoronoi ? onItemClick : undefined
|
|
96
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, {
|
|
97
|
-
loading: loading,
|
|
98
|
-
slots: slots,
|
|
99
|
-
slotProps: slotProps
|
|
100
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legend, {
|
|
101
|
-
slots: slots,
|
|
102
|
-
slotProps: slotProps
|
|
103
|
-
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({
|
|
104
|
-
x: "none",
|
|
105
|
-
y: "none"
|
|
106
|
-
}, axisHighlight)), !loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltip, (0, _extends2.default)({
|
|
107
|
-
trigger: "item"
|
|
108
|
-
}, tooltip)), children]
|
|
109
|
-
})
|
|
110
|
-
});
|
|
37
|
+
chartContainerProps,
|
|
38
|
+
zAxisProps,
|
|
39
|
+
voronoiHandlerProps,
|
|
40
|
+
chartsAxisProps,
|
|
41
|
+
gridProps,
|
|
42
|
+
scatterPlotProps,
|
|
43
|
+
overlayProps,
|
|
44
|
+
legendProps,
|
|
45
|
+
axisHighlightProps,
|
|
46
|
+
tooltipProps,
|
|
47
|
+
children
|
|
48
|
+
} = (0, _useScatterChartProps.useScatterChartProps)(props);
|
|
49
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ResponsiveChartContainer.ResponsiveChartContainer, (0, _extends2.default)({
|
|
50
|
+
ref: ref
|
|
51
|
+
}, chartContainerProps, {
|
|
52
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ZAxisContextProvider.ZAxisContextProvider, (0, _extends2.default)({}, zAxisProps, {
|
|
53
|
+
children: [!props.disableVoronoi && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsVoronoiHandler.ChartsVoronoiHandler, (0, _extends2.default)({}, voronoiHandlerProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), props.grid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, (0, _extends2.default)({}, gridProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScatterPlot.ScatterPlot, (0, _extends2.default)({}, scatterPlotProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, (0, _extends2.default)({}, overlayProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legendProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({}, axisHighlightProps)), !props.loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltip, (0, _extends2.default)({}, tooltipProps)), children]
|
|
54
|
+
}))
|
|
55
|
+
}));
|
|
111
56
|
});
|
|
112
57
|
process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
113
58
|
// ----------------------------- Warning --------------------------------
|
|
@@ -9,7 +9,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
var _Scatter = require("./Scatter");
|
|
12
|
-
var
|
|
12
|
+
var _CartesianProvider = require("../context/CartesianProvider");
|
|
13
13
|
var _getColor = _interopRequireDefault(require("./getColor"));
|
|
14
14
|
var _ZAxisContextProvider = require("../context/ZAxisContextProvider");
|
|
15
15
|
var _useSeries = require("../hooks/useSeries");
|
|
@@ -33,7 +33,7 @@ function ScatterPlot(props) {
|
|
|
33
33
|
onItemClick
|
|
34
34
|
} = props;
|
|
35
35
|
const seriesData = (0, _useSeries.useScatterSeries)();
|
|
36
|
-
const axisData =
|
|
36
|
+
const axisData = (0, _CartesianProvider.useCartesianContext)();
|
|
37
37
|
const {
|
|
38
38
|
zAxis,
|
|
39
39
|
zAxisIds
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ScatterChartProps } from './ScatterChart';
|
|
3
|
+
/**
|
|
4
|
+
* A helper function that extracts ScatterChartProps from the input props
|
|
5
|
+
* and returns an object with props for the children components of ScatterChart.
|
|
6
|
+
*
|
|
7
|
+
* @param props The input props for ScatterChart
|
|
8
|
+
* @returns An object with props for the children components of ScatterChart
|
|
9
|
+
*/
|
|
10
|
+
export declare const useScatterChartProps: (props: ScatterChartProps) => {
|
|
11
|
+
chartContainerProps: {
|
|
12
|
+
series: {
|
|
13
|
+
color?: string | undefined;
|
|
14
|
+
data: import("..").ScatterValueType[];
|
|
15
|
+
label?: string | ((location: "tooltip" | "legend") => string) | undefined;
|
|
16
|
+
id?: import("../internals").SeriesId | undefined;
|
|
17
|
+
valueFormatter?: import("../internals").SeriesValueFormatter<import("..").ScatterValueType> | undefined;
|
|
18
|
+
highlightScope?: Partial<import("..").HighlightScope> | undefined;
|
|
19
|
+
xAxisKey?: string | undefined;
|
|
20
|
+
yAxisKey?: string | undefined;
|
|
21
|
+
markerSize?: number | undefined;
|
|
22
|
+
disableHover?: boolean | undefined;
|
|
23
|
+
zAxisKey?: string | undefined;
|
|
24
|
+
type: "scatter";
|
|
25
|
+
}[];
|
|
26
|
+
width: number | undefined;
|
|
27
|
+
height: number | undefined;
|
|
28
|
+
margin: Partial<import("..").CardinalDirections<number>> | undefined;
|
|
29
|
+
colors: import("..").ChartsColorPalette | undefined;
|
|
30
|
+
xAxis: import("../internals").MakeOptional<import("..").AxisConfig<import("..").ScaleName, any, import("..").ChartsXAxisProps>, "id">[] | undefined;
|
|
31
|
+
yAxis: import("../internals").MakeOptional<import("..").AxisConfig<import("..").ScaleName, any, import("..").ChartsYAxisProps>, "id">[] | undefined;
|
|
32
|
+
sx: import("@mui/system").SxProps<import("@mui/material").Theme> | undefined;
|
|
33
|
+
highlightedItem: import("..").HighlightItemData | null | undefined;
|
|
34
|
+
onHighlightChange: ((highlightedItem: import("..").HighlightItemData | null) => void) | undefined;
|
|
35
|
+
};
|
|
36
|
+
zAxisProps: {
|
|
37
|
+
zAxis: import("../internals").MakeOptional<import("../internals").ZAxisConfig<any>, "id">[] | undefined;
|
|
38
|
+
};
|
|
39
|
+
voronoiHandlerProps: {
|
|
40
|
+
voronoiMaxRadius: number | undefined;
|
|
41
|
+
onItemClick: ((event: MouseEvent, scatterItemIdentifier: import("..").ScatterItemIdentifier) => void) | undefined;
|
|
42
|
+
};
|
|
43
|
+
chartsAxisProps: {
|
|
44
|
+
topAxis: string | import("..").ChartsXAxisProps | null | undefined;
|
|
45
|
+
leftAxis: string | import("..").ChartsYAxisProps | null | undefined;
|
|
46
|
+
rightAxis: string | import("..").ChartsYAxisProps | null | undefined;
|
|
47
|
+
bottomAxis: string | import("..").ChartsXAxisProps | null | undefined;
|
|
48
|
+
slots: import("./ScatterChart").ScatterChartSlots | undefined;
|
|
49
|
+
slotProps: import("./ScatterChart").ScatterChartSlotProps | undefined;
|
|
50
|
+
};
|
|
51
|
+
gridProps: {
|
|
52
|
+
vertical: boolean | undefined;
|
|
53
|
+
horizontal: boolean | undefined;
|
|
54
|
+
};
|
|
55
|
+
scatterPlotProps: {
|
|
56
|
+
onItemClick: ((event: import("react").MouseEvent<SVGElement, MouseEvent>, scatterItemIdentifier: import("..").ScatterItemIdentifier) => void) | undefined;
|
|
57
|
+
slots: import("./ScatterChart").ScatterChartSlots | undefined;
|
|
58
|
+
slotProps: import("./ScatterChart").ScatterChartSlotProps | undefined;
|
|
59
|
+
};
|
|
60
|
+
overlayProps: {
|
|
61
|
+
loading: boolean | undefined;
|
|
62
|
+
slots: import("./ScatterChart").ScatterChartSlots | undefined;
|
|
63
|
+
slotProps: import("./ScatterChart").ScatterChartSlotProps | undefined;
|
|
64
|
+
};
|
|
65
|
+
legendProps: {
|
|
66
|
+
slots: import("./ScatterChart").ScatterChartSlots | undefined;
|
|
67
|
+
slotProps: import("./ScatterChart").ScatterChartSlotProps | undefined;
|
|
68
|
+
position?: import("..").AnchorPosition | undefined;
|
|
69
|
+
classes?: Partial<import("..").ChartsLegendClasses> | undefined;
|
|
70
|
+
hidden?: boolean | undefined;
|
|
71
|
+
direction?: import("..").Direction | undefined;
|
|
72
|
+
};
|
|
73
|
+
axisHighlightProps: {
|
|
74
|
+
x: "none" | "line" | "band";
|
|
75
|
+
y: "none" | "line" | "band";
|
|
76
|
+
};
|
|
77
|
+
tooltipProps: {
|
|
78
|
+
slots: import("./ScatterChart").ScatterChartSlots | undefined;
|
|
79
|
+
slotProps: import("./ScatterChart").ScatterChartSlotProps | undefined;
|
|
80
|
+
trigger: import("../ChartsTooltip/utils").TriggerOptions;
|
|
81
|
+
itemContent?: import("react").ElementType<import("..").ChartsItemContentProps<any>, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
82
|
+
axisContent?: import("react").ElementType<import("..").ChartsAxisContentProps, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
83
|
+
classes?: Partial<import("..").ChartsTooltipClasses> | undefined;
|
|
84
|
+
};
|
|
85
|
+
children: import("react").ReactNode;
|
|
86
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useScatterChartProps = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
/**
|
|
10
|
+
* A helper function that extracts ScatterChartProps from the input props
|
|
11
|
+
* and returns an object with props for the children components of ScatterChart.
|
|
12
|
+
*
|
|
13
|
+
* @param props The input props for ScatterChart
|
|
14
|
+
* @returns An object with props for the children components of ScatterChart
|
|
15
|
+
*/
|
|
16
|
+
const useScatterChartProps = props => {
|
|
17
|
+
const {
|
|
18
|
+
xAxis,
|
|
19
|
+
yAxis,
|
|
20
|
+
zAxis,
|
|
21
|
+
series,
|
|
22
|
+
tooltip,
|
|
23
|
+
axisHighlight,
|
|
24
|
+
voronoiMaxRadius,
|
|
25
|
+
disableVoronoi,
|
|
26
|
+
legend,
|
|
27
|
+
width,
|
|
28
|
+
height,
|
|
29
|
+
margin,
|
|
30
|
+
colors,
|
|
31
|
+
sx,
|
|
32
|
+
grid,
|
|
33
|
+
topAxis,
|
|
34
|
+
leftAxis,
|
|
35
|
+
rightAxis,
|
|
36
|
+
bottomAxis,
|
|
37
|
+
onItemClick,
|
|
38
|
+
children,
|
|
39
|
+
slots,
|
|
40
|
+
slotProps,
|
|
41
|
+
loading,
|
|
42
|
+
highlightedItem,
|
|
43
|
+
onHighlightChange
|
|
44
|
+
} = props;
|
|
45
|
+
const chartContainerProps = {
|
|
46
|
+
series: series.map(s => (0, _extends2.default)({
|
|
47
|
+
type: 'scatter'
|
|
48
|
+
}, s)),
|
|
49
|
+
width,
|
|
50
|
+
height,
|
|
51
|
+
margin,
|
|
52
|
+
colors,
|
|
53
|
+
xAxis,
|
|
54
|
+
yAxis,
|
|
55
|
+
sx,
|
|
56
|
+
highlightedItem,
|
|
57
|
+
onHighlightChange
|
|
58
|
+
};
|
|
59
|
+
const zAxisProps = {
|
|
60
|
+
zAxis
|
|
61
|
+
};
|
|
62
|
+
const voronoiHandlerProps = {
|
|
63
|
+
voronoiMaxRadius,
|
|
64
|
+
onItemClick: onItemClick
|
|
65
|
+
};
|
|
66
|
+
const chartsAxisProps = {
|
|
67
|
+
topAxis,
|
|
68
|
+
leftAxis,
|
|
69
|
+
rightAxis,
|
|
70
|
+
bottomAxis,
|
|
71
|
+
slots,
|
|
72
|
+
slotProps
|
|
73
|
+
};
|
|
74
|
+
const gridProps = {
|
|
75
|
+
vertical: grid?.vertical,
|
|
76
|
+
horizontal: grid?.horizontal
|
|
77
|
+
};
|
|
78
|
+
const scatterPlotProps = {
|
|
79
|
+
onItemClick: disableVoronoi ? onItemClick : undefined,
|
|
80
|
+
slots,
|
|
81
|
+
slotProps
|
|
82
|
+
};
|
|
83
|
+
const overlayProps = {
|
|
84
|
+
loading,
|
|
85
|
+
slots,
|
|
86
|
+
slotProps
|
|
87
|
+
};
|
|
88
|
+
const legendProps = (0, _extends2.default)({}, legend, {
|
|
89
|
+
slots,
|
|
90
|
+
slotProps
|
|
91
|
+
});
|
|
92
|
+
const axisHighlightProps = (0, _extends2.default)({
|
|
93
|
+
y: 'none',
|
|
94
|
+
x: 'none'
|
|
95
|
+
}, axisHighlight);
|
|
96
|
+
const tooltipProps = (0, _extends2.default)({
|
|
97
|
+
trigger: 'item'
|
|
98
|
+
}, tooltip, {
|
|
99
|
+
slots,
|
|
100
|
+
slotProps
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
chartContainerProps,
|
|
104
|
+
zAxisProps,
|
|
105
|
+
voronoiHandlerProps,
|
|
106
|
+
chartsAxisProps,
|
|
107
|
+
gridProps,
|
|
108
|
+
scatterPlotProps,
|
|
109
|
+
overlayProps,
|
|
110
|
+
legendProps,
|
|
111
|
+
axisHighlightProps,
|
|
112
|
+
tooltipProps,
|
|
113
|
+
children
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
exports.useScatterChartProps = useScatterChartProps;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Initializable } from '../context.types';
|
|
3
|
+
import { AxisDefaultized, ScaleName, ChartsXAxisProps, ChartsYAxisProps, AxisId } from '../../models/axis';
|
|
4
|
+
export type DefaultizedAxisConfig<AxisProps> = {
|
|
5
|
+
[axisKey: AxisId]: AxisDefaultized<ScaleName, any, AxisProps>;
|
|
6
|
+
};
|
|
7
|
+
export type CartesianContextState = {
|
|
8
|
+
/**
|
|
9
|
+
* Mapping from x-axis key to scaling configuration.
|
|
10
|
+
*/
|
|
11
|
+
xAxis: DefaultizedAxisConfig<ChartsXAxisProps>;
|
|
12
|
+
/**
|
|
13
|
+
* Mapping from y-axis key to scaling configuration.
|
|
14
|
+
*/
|
|
15
|
+
yAxis: DefaultizedAxisConfig<ChartsYAxisProps>;
|
|
16
|
+
/**
|
|
17
|
+
* The x-axes IDs sorted by order they got provided.
|
|
18
|
+
*/
|
|
19
|
+
xAxisIds: AxisId[];
|
|
20
|
+
/**
|
|
21
|
+
* The y-axes IDs sorted by order they got provided.
|
|
22
|
+
*/
|
|
23
|
+
yAxisIds: AxisId[];
|
|
24
|
+
};
|
|
25
|
+
export declare const CartesianContext: React.Context<Initializable<CartesianContextState>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CartesianContext = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
|
+
const CartesianContext = exports.CartesianContext = /*#__PURE__*/React.createContext({
|
|
11
|
+
isInitialized: false,
|
|
12
|
+
data: {
|
|
13
|
+
xAxis: {},
|
|
14
|
+
yAxis: {},
|
|
15
|
+
xAxisIds: [],
|
|
16
|
+
yAxisIds: []
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
20
|
+
CartesianContext.displayName = 'CartesianContext';
|
|
21
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { AxisConfig, ChartsXAxisProps, ChartsYAxisProps, ScaleName } from '../../models/axis';
|
|
3
|
+
import { DatasetType } from '../../models/seriesType/config';
|
|
4
|
+
import { MakeOptional } from '../../models/helpers';
|
|
5
|
+
import { ExtremumGettersConfig } from '../../models';
|
|
6
|
+
export type CartesianContextProviderProps = {
|
|
7
|
+
/**
|
|
8
|
+
* The configuration of the x-axes.
|
|
9
|
+
* If not provided, a default axis config is used.
|
|
10
|
+
* An array of [[AxisConfig]] objects.
|
|
11
|
+
*/
|
|
12
|
+
xAxis?: MakeOptional<AxisConfig<ScaleName, any, ChartsXAxisProps>, 'id'>[];
|
|
13
|
+
/**
|
|
14
|
+
* The configuration of the y-axes.
|
|
15
|
+
* If not provided, a default axis config is used.
|
|
16
|
+
* An array of [[AxisConfig]] objects.
|
|
17
|
+
*/
|
|
18
|
+
yAxis?: MakeOptional<AxisConfig<ScaleName, any, ChartsYAxisProps>, 'id'>[];
|
|
19
|
+
/**
|
|
20
|
+
* An array of objects that can be used to populate series and axes data using their `dataKey` property.
|
|
21
|
+
*/
|
|
22
|
+
dataset?: DatasetType;
|
|
23
|
+
/**
|
|
24
|
+
* An object with x-axis extremum getters per series type.
|
|
25
|
+
*/
|
|
26
|
+
xExtremumGetters: ExtremumGettersConfig;
|
|
27
|
+
/**
|
|
28
|
+
* An object with y-axis extremum getters per series type.
|
|
29
|
+
*/
|
|
30
|
+
yExtremumGetters: ExtremumGettersConfig;
|
|
31
|
+
children: React.ReactNode;
|
|
32
|
+
};
|
|
33
|
+
declare function CartesianContextProvider(props: CartesianContextProviderProps): React.JSX.Element;
|
|
34
|
+
export { CartesianContextProvider };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CartesianContextProvider = CartesianContextProvider;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _useDrawingArea = require("../../hooks/useDrawingArea");
|
|
9
|
+
var _useSeries = require("../../hooks/useSeries");
|
|
10
|
+
var _CartesianContext = require("./CartesianContext");
|
|
11
|
+
var _normalizeAxis = require("./normalizeAxis");
|
|
12
|
+
var _computeValue = require("./computeValue");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
function CartesianContextProvider(props) {
|
|
17
|
+
const {
|
|
18
|
+
xAxis: inXAxis,
|
|
19
|
+
yAxis: inYAxis,
|
|
20
|
+
dataset,
|
|
21
|
+
xExtremumGetters,
|
|
22
|
+
yExtremumGetters,
|
|
23
|
+
children
|
|
24
|
+
} = props;
|
|
25
|
+
const formattedSeries = (0, _useSeries.useSeries)();
|
|
26
|
+
const drawingArea = (0, _useDrawingArea.useDrawingArea)();
|
|
27
|
+
const xAxis = React.useMemo(() => (0, _normalizeAxis.normalizeAxis)(inXAxis, dataset, 'x'), [inXAxis, dataset]);
|
|
28
|
+
const yAxis = React.useMemo(() => (0, _normalizeAxis.normalizeAxis)(inYAxis, dataset, 'y'), [inYAxis, dataset]);
|
|
29
|
+
const xValues = React.useMemo(() => (0, _computeValue.computeValue)(drawingArea, formattedSeries, xAxis, xExtremumGetters, 'x'), [drawingArea, formattedSeries, xAxis, xExtremumGetters]);
|
|
30
|
+
const yValues = React.useMemo(() => (0, _computeValue.computeValue)(drawingArea, formattedSeries, yAxis, yExtremumGetters, 'y'), [drawingArea, formattedSeries, yAxis, yExtremumGetters]);
|
|
31
|
+
const value = React.useMemo(() => ({
|
|
32
|
+
isInitialized: true,
|
|
33
|
+
data: {
|
|
34
|
+
xAxis: xValues.axis,
|
|
35
|
+
yAxis: yValues.axis,
|
|
36
|
+
xAxisIds: xValues.axisIds,
|
|
37
|
+
yAxisIds: yValues.axisIds
|
|
38
|
+
}
|
|
39
|
+
}), [xValues, yValues]);
|
|
40
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CartesianContext.CartesianContext.Provider, {
|
|
41
|
+
value: value,
|
|
42
|
+
children: children
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AxisConfig, ScaleName } from '../../models';
|
|
2
|
+
import { ChartsXAxisProps, ChartsAxisProps, ChartsYAxisProps } from '../../models/axis';
|
|
3
|
+
import { CartesianChartSeriesType, ExtremumGetter } from '../../models/seriesType/config';
|
|
4
|
+
import { DefaultizedAxisConfig } from './CartesianContext';
|
|
5
|
+
import { DrawingArea } from '../DrawingProvider';
|
|
6
|
+
import { FormattedSeries } from '../SeriesContextProvider';
|
|
7
|
+
import { MakeOptional } from '../../models/helpers';
|
|
8
|
+
export declare function computeValue(drawingArea: DrawingArea, formattedSeries: FormattedSeries, axis: MakeOptional<AxisConfig<ScaleName, any, ChartsYAxisProps>, 'id'>[] | undefined, extremumGetters: {
|
|
9
|
+
[K in CartesianChartSeriesType]?: ExtremumGetter<K>;
|
|
10
|
+
}, axisName: 'y'): {
|
|
11
|
+
axis: DefaultizedAxisConfig<ChartsYAxisProps>;
|
|
12
|
+
axisIds: string[];
|
|
13
|
+
};
|
|
14
|
+
export declare function computeValue(drawingArea: DrawingArea, formattedSeries: FormattedSeries, inAxis: MakeOptional<AxisConfig<ScaleName, any, ChartsXAxisProps>, 'id'>[] | undefined, extremumGetters: {
|
|
15
|
+
[K in CartesianChartSeriesType]?: ExtremumGetter<K>;
|
|
16
|
+
}, axisName: 'x'): {
|
|
17
|
+
axis: DefaultizedAxisConfig<ChartsAxisProps>;
|
|
18
|
+
axisIds: string[];
|
|
19
|
+
};
|