@mui/x-charts 8.3.1 → 8.4.0
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 +3 -2
- package/CHANGELOG.md +110 -0
- package/ChartContainer/ChartContainer.js +1 -1
- package/ChartsAxis/axisClasses.d.ts +5 -0
- package/ChartsAxis/axisClasses.js +1 -1
- package/ChartsLegend/ChartsLegend.js +1 -0
- package/ChartsLocalizationProvider/ChartsLocalizationProvider.js +1 -3
- package/ChartsSurface/ChartsSurface.js +1 -0
- package/ChartsXAxis/ChartsXAxis.js +7 -16
- package/ChartsYAxis/ChartsYAxis.js +4 -8
- package/Gauge/Gauge.js +1 -0
- package/Gauge/GaugeContainer.js +1 -0
- package/Gauge/GaugeProvider.js +1 -3
- package/LineChart/AnimatedLine.js +1 -0
- package/LineChart/LineChart.js +3 -2
- package/LineChart/LineHighlightPlot.js +1 -4
- package/LineChart/MarkPlot.js +1 -4
- package/PieChart/PieArc.js +1 -0
- package/PieChart/PieArcLabel.js +1 -0
- package/PieChart/PieChart.js +7 -6
- package/RadarChart/RadarChart.js +3 -2
- package/ScatterChart/Scatter.js +3 -11
- package/ScatterChart/ScatterChart.js +5 -4
- package/SparkLineChart/SparkLineChart.js +31 -26
- package/Toolbar/ToolbarButton.js +1 -0
- package/context/ChartProvider/ChartContext.js +1 -3
- package/esm/BarChart/BarChart.js +3 -2
- package/esm/ChartContainer/ChartContainer.js +1 -1
- package/esm/ChartsAxis/axisClasses.d.ts +5 -0
- package/esm/ChartsAxis/axisClasses.js +1 -1
- package/esm/ChartsLegend/ChartsLegend.js +1 -0
- package/esm/ChartsLocalizationProvider/ChartsLocalizationProvider.js +1 -3
- package/esm/ChartsSurface/ChartsSurface.js +1 -0
- package/esm/ChartsXAxis/ChartsXAxis.js +7 -16
- package/esm/ChartsYAxis/ChartsYAxis.js +4 -8
- package/esm/Gauge/Gauge.js +1 -0
- package/esm/Gauge/GaugeContainer.js +1 -0
- package/esm/Gauge/GaugeProvider.js +1 -3
- package/esm/LineChart/AnimatedLine.js +1 -0
- package/esm/LineChart/LineChart.js +3 -2
- package/esm/LineChart/LineHighlightPlot.js +1 -4
- package/esm/LineChart/MarkPlot.js +1 -4
- package/esm/PieChart/PieArc.js +1 -0
- package/esm/PieChart/PieArcLabel.js +1 -0
- package/esm/PieChart/PieChart.js +5 -4
- package/esm/RadarChart/RadarChart.js +3 -2
- package/esm/ScatterChart/Scatter.js +3 -11
- package/esm/ScatterChart/ScatterChart.js +5 -4
- package/esm/SparkLineChart/SparkLineChart.js +31 -26
- package/esm/Toolbar/ToolbarButton.js +1 -0
- package/esm/context/ChartProvider/ChartContext.js +1 -3
- package/esm/hooks/useTicks.js +2 -6
- package/esm/index.js +1 -1
- package/esm/internals/constants.d.ts +1 -1
- package/esm/internals/constants.js +1 -1
- package/esm/internals/consumeSlots.js +2 -1
- package/esm/internals/consumeThemeProps.js +3 -1
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +11 -17
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +16 -13
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +2 -3
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +3 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.js +4 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +1 -3
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +8 -0
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +1 -3
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +2 -5
- package/hooks/useTicks.js +2 -6
- package/index.js +1 -1
- package/internals/constants.d.ts +1 -1
- package/internals/constants.js +2 -2
- package/internals/consumeSlots.js +2 -1
- package/internals/consumeThemeProps.js +3 -1
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +11 -17
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +16 -13
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +7 -8
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +3 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.js +4 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +1 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +8 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +1 -3
- package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +2 -5
- package/package.json +3 -3
|
@@ -71,9 +71,7 @@ export const useChartCartesianAxis = ({
|
|
|
71
71
|
const handleMove = event => {
|
|
72
72
|
const target = 'targetTouches' in event ? event.targetTouches[0] : event;
|
|
73
73
|
const svgPoint = getSVGPoint(element, target);
|
|
74
|
-
if (!instance.isPointInside(svgPoint, {
|
|
75
|
-
targetElement: event.target
|
|
76
|
-
})) {
|
|
74
|
+
if (!instance.isPointInside(svgPoint.x, svgPoint.y, event.target)) {
|
|
77
75
|
instance.cleanInteraction?.();
|
|
78
76
|
return;
|
|
79
77
|
}
|
|
@@ -77,6 +77,14 @@ export interface ZoomSliderOptions {
|
|
|
77
77
|
* If `true`, the slider will be shown.
|
|
78
78
|
*/
|
|
79
79
|
enabled?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* The size reserved for the zoom slider. The actual size of the slider might be smaller, so
|
|
82
|
+
* increasing this value effectively increases the margin around the slider.
|
|
83
|
+
* This means the height for the x-axis and the width for the y-axis.
|
|
84
|
+
*
|
|
85
|
+
* @default 28
|
|
86
|
+
*/
|
|
87
|
+
size?: number;
|
|
80
88
|
}
|
|
81
89
|
export type ZoomAxisFilters = Record<AxisId, ExtremumFilter>;
|
|
82
90
|
export type GetZoomAxisFilters = (params: {
|
|
@@ -97,9 +97,7 @@ export const useChartPolarAxis = ({
|
|
|
97
97
|
mousePosition.current.y = svgPoint.y;
|
|
98
98
|
|
|
99
99
|
// Test if it's in the drawing area
|
|
100
|
-
if (!instance.isPointInside(svgPoint, {
|
|
101
|
-
targetElement: event.target
|
|
102
|
-
})) {
|
|
100
|
+
if (!instance.isPointInside(svgPoint.x, svgPoint.y, event.target)) {
|
|
103
101
|
if (mousePosition.current.isInChart) {
|
|
104
102
|
instance?.cleanInteraction();
|
|
105
103
|
mousePosition.current.isInChart = false;
|
|
@@ -71,10 +71,7 @@ export const useChartVoronoi = ({
|
|
|
71
71
|
}) => {
|
|
72
72
|
const pointX = getXPosition(x);
|
|
73
73
|
const pointY = getYPosition(y);
|
|
74
|
-
if (!instance.isPointInside({
|
|
75
|
-
x: pointX,
|
|
76
|
-
y: pointY
|
|
77
|
-
})) {
|
|
74
|
+
if (!instance.isPointInside(pointX, pointY)) {
|
|
78
75
|
// If the point is not displayed we move them to a trash coordinate.
|
|
79
76
|
// This avoids managing index mapping before/after filtering.
|
|
80
77
|
// The trash point is far enough such that any point in the drawing area will be closer to the mouse than the trash coordinate.
|
|
@@ -100,7 +97,7 @@ export const useChartVoronoi = ({
|
|
|
100
97
|
function getClosestPoint(event) {
|
|
101
98
|
// Get mouse coordinate in global SVG space
|
|
102
99
|
const svgPoint = getSVGPoint(element, event);
|
|
103
|
-
if (!instance.isPointInside(svgPoint)) {
|
|
100
|
+
if (!instance.isPointInside(svgPoint.x, svgPoint.y)) {
|
|
104
101
|
lastFind.current = undefined;
|
|
105
102
|
return 'outside-chart';
|
|
106
103
|
}
|
package/hooks/useTicks.js
CHANGED
|
@@ -78,12 +78,8 @@ function useTicks(options) {
|
|
|
78
78
|
for (let i = 0; i < ticks.length; i += 1) {
|
|
79
79
|
const value = ticks[i];
|
|
80
80
|
const offset = scale(value);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
y: offset
|
|
84
|
-
}, {
|
|
85
|
-
direction
|
|
86
|
-
})) {
|
|
81
|
+
const isInside = direction === 'x' ? instance.isXInside(offset) : instance.isYInside(offset);
|
|
82
|
+
if (isInside) {
|
|
87
83
|
visibleTicks.push({
|
|
88
84
|
value,
|
|
89
85
|
formattedValue: valueFormatter?.(value, {
|
package/index.js
CHANGED
package/internals/constants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** Margin in the opposite direction of the axis, i.e., horizontal if the axis is vertical and vice versa. */
|
|
2
2
|
export declare const ZOOM_SLIDER_MARGIN = 4;
|
|
3
3
|
/** Size reserved for the zoom slider. The actual size of the slider might be smaller. */
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const DEFAULT_ZOOM_SLIDER_SIZE: number;
|
package/internals/constants.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.ZOOM_SLIDER_MARGIN = exports.DEFAULT_ZOOM_SLIDER_SIZE = void 0;
|
|
7
7
|
/** Margin in the opposite direction of the axis, i.e., horizontal if the axis is vertical and vice versa. */
|
|
8
8
|
const ZOOM_SLIDER_MARGIN = exports.ZOOM_SLIDER_MARGIN = 4;
|
|
9
9
|
|
|
10
10
|
/** Size reserved for the zoom slider. The actual size of the slider might be smaller. */
|
|
11
|
-
const
|
|
11
|
+
const DEFAULT_ZOOM_SLIDER_SIZE = exports.DEFAULT_ZOOM_SLIDER_SIZE = 20 + 2 * ZOOM_SLIDER_MARGIN;
|
|
@@ -102,4 +102,5 @@ const consumeSlots = (name, slotPropName, options, InComponent) => {
|
|
|
102
102
|
}
|
|
103
103
|
return /*#__PURE__*/React.forwardRef(ConsumeSlotsInternal);
|
|
104
104
|
};
|
|
105
|
-
exports.consumeSlots = consumeSlots;
|
|
105
|
+
exports.consumeSlots = consumeSlots;
|
|
106
|
+
if (process.env.NODE_ENV !== "production") consumeSlots.displayName = "consumeSlots";
|
|
@@ -67,6 +67,7 @@ const consumeThemeProps = (name, options, InComponent) => /*#__PURE__*/React.for
|
|
|
67
67
|
const theme = (0, _styles.useTheme)();
|
|
68
68
|
const classes = options.classesResolver?.(outProps, theme);
|
|
69
69
|
const OutComponent = /*#__PURE__*/React.forwardRef(InComponent);
|
|
70
|
+
if (process.env.NODE_ENV !== "production") OutComponent.displayName = "OutComponent";
|
|
70
71
|
if (process.env.NODE_ENV !== 'production') {
|
|
71
72
|
OutComponent.displayName = `consumeThemeProps(${name})`;
|
|
72
73
|
}
|
|
@@ -75,4 +76,5 @@ const consumeThemeProps = (name, options, InComponent) => /*#__PURE__*/React.for
|
|
|
75
76
|
ref: ref
|
|
76
77
|
}));
|
|
77
78
|
});
|
|
78
|
-
exports.consumeThemeProps = consumeThemeProps;
|
|
79
|
+
exports.consumeThemeProps = consumeThemeProps;
|
|
80
|
+
if (process.env.NODE_ENV !== "production") consumeThemeProps.displayName = "consumeThemeProps";
|
|
@@ -11,6 +11,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
13
13
|
var _ownerWindow = _interopRequireDefault(require("@mui/utils/ownerWindow"));
|
|
14
|
+
var _useSelector = require("../../../store/useSelector");
|
|
14
15
|
var _constants = require("../../../../constants");
|
|
15
16
|
var _useChartDimensions = require("./useChartDimensions.selectors");
|
|
16
17
|
var _defaultizeMargin = require("../../../defaultizeMargin");
|
|
@@ -150,28 +151,21 @@ const useChartDimensions = ({
|
|
|
150
151
|
stateRef.current.displayError = false;
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
const drawingArea = (0, _useSelector.useSelector)(store, _useChartDimensions.selectorChartDrawingArea);
|
|
155
|
+
const isXInside = React.useCallback(x => x >= drawingArea.left - 1 && x <= drawingArea.left + drawingArea.width, [drawingArea.left, drawingArea.width]);
|
|
156
|
+
const isYInside = React.useCallback(y => y >= drawingArea.top - 1 && y <= drawingArea.top + drawingArea.height, [drawingArea.height, drawingArea.top]);
|
|
157
|
+
const isPointInside = React.useCallback((x, y, targetElement) => {
|
|
157
158
|
// For element allowed to overflow, wrapping them in <g data-drawing-container /> make them fully part of the drawing area.
|
|
158
|
-
if (
|
|
159
|
+
if (targetElement && targetElement.closest('[data-drawing-container]')) {
|
|
159
160
|
return true;
|
|
160
161
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const isInsideY = y >= drawingArea.top - 1 && y <= drawingArea.top + drawingArea.height;
|
|
164
|
-
if (options?.direction === 'x') {
|
|
165
|
-
return isInsideX;
|
|
166
|
-
}
|
|
167
|
-
if (options?.direction === 'y') {
|
|
168
|
-
return isInsideY;
|
|
169
|
-
}
|
|
170
|
-
return isInsideX && isInsideY;
|
|
171
|
-
}, [store.value]);
|
|
162
|
+
return isXInside(x) && isYInside(y);
|
|
163
|
+
}, [isXInside, isYInside]);
|
|
172
164
|
return {
|
|
173
165
|
instance: {
|
|
174
|
-
isPointInside
|
|
166
|
+
isPointInside,
|
|
167
|
+
isXInside,
|
|
168
|
+
isYInside
|
|
175
169
|
}
|
|
176
170
|
};
|
|
177
171
|
};
|
|
@@ -65,21 +65,24 @@ export interface UseChartDimensionsState {
|
|
|
65
65
|
export interface UseChartDimensionsInstance {
|
|
66
66
|
/**
|
|
67
67
|
* Checks if a point is inside the drawing area.
|
|
68
|
-
* @param {
|
|
69
|
-
* @param {number}
|
|
70
|
-
* @param {
|
|
71
|
-
* @param {Object} options The options of the check.
|
|
72
|
-
* @param {Element} [options.targetElement] The element to check if it is allowed to overflow the drawing area.
|
|
73
|
-
* @param {'x' | 'y'} [options.direction] The direction to check.
|
|
68
|
+
* @param {number} x The x coordinate of the point.
|
|
69
|
+
* @param {number} y The y coordinate of the point.
|
|
70
|
+
* @param {Element} targetElement The element to check if it is allowed to overflow the drawing area.
|
|
74
71
|
* @returns {boolean} `true` if the point is inside the drawing area, `false` otherwise.
|
|
75
72
|
*/
|
|
76
|
-
isPointInside: (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
isPointInside: (x: number, y: number, targetElement?: Element) => boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Checks if the x coordinate is inside the drawing area.
|
|
76
|
+
* @param {number} x The x coordinate of the point.
|
|
77
|
+
* @returns {boolean} `true` if the point is inside the drawing area, `false` otherwise.
|
|
78
|
+
*/
|
|
79
|
+
isXInside: (x: number) => boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Checks if the y coordinate is inside the drawing area.
|
|
82
|
+
* @param {number} y The y coordinate of the point.
|
|
83
|
+
* @returns {boolean} `true` if the point is inside the drawing area, `false` otherwise.
|
|
84
|
+
*/
|
|
85
|
+
isYInside: (y: number) => boolean;
|
|
83
86
|
}
|
|
84
87
|
export type UseChartDimensionsSignature = ChartPluginSignature<{
|
|
85
88
|
params: UseChartDimensionsParameters;
|
|
@@ -7,9 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.defaultizeXAxis = defaultizeXAxis;
|
|
8
8
|
exports.defaultizeYAxis = defaultizeYAxis;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
-
var _constants = require("../../../constants");
|
|
11
10
|
var _defaultizeZoom = require("./defaultizeZoom");
|
|
12
|
-
var
|
|
11
|
+
var _constants = require("../../../../constants");
|
|
13
12
|
function defaultizeXAxis(inAxes, dataset) {
|
|
14
13
|
const offsets = {
|
|
15
14
|
top: 0,
|
|
@@ -17,7 +16,7 @@ function defaultizeXAxis(inAxes, dataset) {
|
|
|
17
16
|
none: 0
|
|
18
17
|
};
|
|
19
18
|
const inputAxes = inAxes && inAxes.length > 0 ? inAxes : [{
|
|
20
|
-
id:
|
|
19
|
+
id: _constants.DEFAULT_X_AXIS_KEY,
|
|
21
20
|
scaleType: 'linear'
|
|
22
21
|
}];
|
|
23
22
|
const parsedAxes = inputAxes.map((axisConfig, index) => {
|
|
@@ -26,7 +25,7 @@ function defaultizeXAxis(inAxes, dataset) {
|
|
|
26
25
|
// The first x-axis is defaultized to the bottom
|
|
27
26
|
const defaultPosition = index === 0 ? 'bottom' : 'none';
|
|
28
27
|
const position = axisConfig.position ?? defaultPosition;
|
|
29
|
-
const defaultHeight =
|
|
28
|
+
const defaultHeight = _constants.DEFAULT_AXIS_SIZE_HEIGHT + (axisConfig.label ? _constants.AXIS_LABEL_DEFAULT_HEIGHT : 0);
|
|
30
29
|
const id = axisConfig.id ?? `defaultized-x-axis-${index}`;
|
|
31
30
|
const sharedConfig = (0, _extends2.default)({
|
|
32
31
|
offset: offsets[position]
|
|
@@ -41,7 +40,7 @@ function defaultizeXAxis(inAxes, dataset) {
|
|
|
41
40
|
if (position !== 'none') {
|
|
42
41
|
offsets[position] += sharedConfig.height;
|
|
43
42
|
if (sharedConfig.zoom?.slider.enabled) {
|
|
44
|
-
offsets[position] +=
|
|
43
|
+
offsets[position] += sharedConfig.zoom.slider.size;
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
|
|
@@ -67,7 +66,7 @@ function defaultizeYAxis(inAxes, dataset) {
|
|
|
67
66
|
none: 0
|
|
68
67
|
};
|
|
69
68
|
const inputAxes = inAxes && inAxes.length > 0 ? inAxes : [{
|
|
70
|
-
id:
|
|
69
|
+
id: _constants.DEFAULT_Y_AXIS_KEY,
|
|
71
70
|
scaleType: 'linear'
|
|
72
71
|
}];
|
|
73
72
|
const parsedAxes = inputAxes.map((axisConfig, index) => {
|
|
@@ -76,7 +75,7 @@ function defaultizeYAxis(inAxes, dataset) {
|
|
|
76
75
|
// The first y-axis is defaultized to the left
|
|
77
76
|
const defaultPosition = index === 0 ? 'left' : 'none';
|
|
78
77
|
const position = axisConfig.position ?? defaultPosition;
|
|
79
|
-
const defaultWidth =
|
|
78
|
+
const defaultWidth = _constants.DEFAULT_AXIS_SIZE_WIDTH + (axisConfig.label ? _constants.AXIS_LABEL_DEFAULT_HEIGHT : 0);
|
|
80
79
|
const id = axisConfig.id ?? `defaultized-y-axis-${index}`;
|
|
81
80
|
const sharedConfig = (0, _extends2.default)({
|
|
82
81
|
offset: offsets[position]
|
|
@@ -91,7 +90,7 @@ function defaultizeYAxis(inAxes, dataset) {
|
|
|
91
90
|
if (position !== 'none') {
|
|
92
91
|
offsets[position] += sharedConfig.width;
|
|
93
92
|
if (sharedConfig.zoom?.slider.enabled) {
|
|
94
|
-
offsets[position] +=
|
|
93
|
+
offsets[position] += sharedConfig.zoom.slider.size;
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
96
|
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.defaultizeZoom = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _constants = require("../../../constants");
|
|
9
10
|
const defaultZoomOptions = {
|
|
10
11
|
minStart: 0,
|
|
11
12
|
maxEnd: 100,
|
|
@@ -15,7 +16,8 @@ const defaultZoomOptions = {
|
|
|
15
16
|
panning: true,
|
|
16
17
|
filterMode: 'keep',
|
|
17
18
|
slider: {
|
|
18
|
-
enabled: false
|
|
19
|
+
enabled: false,
|
|
20
|
+
size: _constants.DEFAULT_ZOOM_SLIDER_SIZE
|
|
19
21
|
}
|
|
20
22
|
};
|
|
21
23
|
const defaultizeZoom = (zoom, axisId, axisDirection) => {
|
package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.js
CHANGED
|
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.selectorChartTopAxisSize = exports.selectorChartRightAxisSize = exports.selectorChartLeftAxisSize = exports.selectorChartBottomAxisSize = void 0;
|
|
7
|
-
var _constants = require("../../../constants");
|
|
8
7
|
var _useChartCartesianAxisLayout = require("./useChartCartesianAxisLayout.selectors");
|
|
9
8
|
var _selectors = require("../../utils/selectors");
|
|
10
|
-
const selectorChartLeftAxisSize = exports.selectorChartLeftAxisSize = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawYAxis], yAxis => (yAxis ?? []).reduce((acc, axis) => axis.position === 'left' ? acc + (axis.width || 0) + (axis.zoom?.slider.enabled ?
|
|
11
|
-
const selectorChartRightAxisSize = exports.selectorChartRightAxisSize = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawYAxis], yAxis => (yAxis ?? []).reduce((acc, axis) => axis.position === 'right' ? acc + (axis.width || 0) + (axis.zoom?.slider.enabled ?
|
|
12
|
-
const selectorChartTopAxisSize = exports.selectorChartTopAxisSize = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawXAxis], xAxis => (xAxis ?? []).reduce((acc, axis) => axis.position === 'top' ? acc + (axis.height || 0) + (axis.zoom?.slider.enabled ?
|
|
13
|
-
const selectorChartBottomAxisSize = exports.selectorChartBottomAxisSize = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawXAxis], xAxis => (xAxis ?? []).reduce((acc, axis) => axis.position === 'bottom' ? acc + (axis.height || 0) + (axis.zoom?.slider.enabled ?
|
|
9
|
+
const selectorChartLeftAxisSize = exports.selectorChartLeftAxisSize = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawYAxis], yAxis => (yAxis ?? []).reduce((acc, axis) => axis.position === 'left' ? acc + (axis.width || 0) + (axis.zoom?.slider.enabled ? axis.zoom.slider.size : 0) : acc, 0));
|
|
10
|
+
const selectorChartRightAxisSize = exports.selectorChartRightAxisSize = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawYAxis], yAxis => (yAxis ?? []).reduce((acc, axis) => axis.position === 'right' ? acc + (axis.width || 0) + (axis.zoom?.slider.enabled ? axis.zoom.slider.size : 0) : acc, 0));
|
|
11
|
+
const selectorChartTopAxisSize = exports.selectorChartTopAxisSize = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawXAxis], xAxis => (xAxis ?? []).reduce((acc, axis) => axis.position === 'top' ? acc + (axis.height || 0) + (axis.zoom?.slider.enabled ? axis.zoom.slider.size : 0) : acc, 0));
|
|
12
|
+
const selectorChartBottomAxisSize = exports.selectorChartBottomAxisSize = (0, _selectors.createSelector)([_useChartCartesianAxisLayout.selectorChartRawXAxis], xAxis => (xAxis ?? []).reduce((acc, axis) => axis.position === 'bottom' ? acc + (axis.height || 0) + (axis.zoom?.slider.enabled ? axis.zoom.slider.size : 0) : acc, 0));
|
|
@@ -78,9 +78,7 @@ const useChartCartesianAxis = ({
|
|
|
78
78
|
const handleMove = event => {
|
|
79
79
|
const target = 'targetTouches' in event ? event.targetTouches[0] : event;
|
|
80
80
|
const svgPoint = (0, _getSVGPoint.getSVGPoint)(element, target);
|
|
81
|
-
if (!instance.isPointInside(svgPoint, {
|
|
82
|
-
targetElement: event.target
|
|
83
|
-
})) {
|
|
81
|
+
if (!instance.isPointInside(svgPoint.x, svgPoint.y, event.target)) {
|
|
84
82
|
instance.cleanInteraction?.();
|
|
85
83
|
return;
|
|
86
84
|
}
|
|
@@ -77,6 +77,14 @@ export interface ZoomSliderOptions {
|
|
|
77
77
|
* If `true`, the slider will be shown.
|
|
78
78
|
*/
|
|
79
79
|
enabled?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* The size reserved for the zoom slider. The actual size of the slider might be smaller, so
|
|
82
|
+
* increasing this value effectively increases the margin around the slider.
|
|
83
|
+
* This means the height for the x-axis and the width for the y-axis.
|
|
84
|
+
*
|
|
85
|
+
* @default 28
|
|
86
|
+
*/
|
|
87
|
+
size?: number;
|
|
80
88
|
}
|
|
81
89
|
export type ZoomAxisFilters = Record<AxisId, ExtremumFilter>;
|
|
82
90
|
export type GetZoomAxisFilters = (params: {
|
|
@@ -104,9 +104,7 @@ const useChartPolarAxis = ({
|
|
|
104
104
|
mousePosition.current.y = svgPoint.y;
|
|
105
105
|
|
|
106
106
|
// Test if it's in the drawing area
|
|
107
|
-
if (!instance.isPointInside(svgPoint, {
|
|
108
|
-
targetElement: event.target
|
|
109
|
-
})) {
|
|
107
|
+
if (!instance.isPointInside(svgPoint.x, svgPoint.y, event.target)) {
|
|
110
108
|
if (mousePosition.current.isInChart) {
|
|
111
109
|
instance?.cleanInteraction();
|
|
112
110
|
mousePosition.current.isInChart = false;
|
|
@@ -79,10 +79,7 @@ const useChartVoronoi = ({
|
|
|
79
79
|
}) => {
|
|
80
80
|
const pointX = getXPosition(x);
|
|
81
81
|
const pointY = getYPosition(y);
|
|
82
|
-
if (!instance.isPointInside({
|
|
83
|
-
x: pointX,
|
|
84
|
-
y: pointY
|
|
85
|
-
})) {
|
|
82
|
+
if (!instance.isPointInside(pointX, pointY)) {
|
|
86
83
|
// If the point is not displayed we move them to a trash coordinate.
|
|
87
84
|
// This avoids managing index mapping before/after filtering.
|
|
88
85
|
// The trash point is far enough such that any point in the drawing area will be closer to the mouse than the trash coordinate.
|
|
@@ -108,7 +105,7 @@ const useChartVoronoi = ({
|
|
|
108
105
|
function getClosestPoint(event) {
|
|
109
106
|
// Get mouse coordinate in global SVG space
|
|
110
107
|
const svgPoint = (0, _getSVGPoint.getSVGPoint)(element, event);
|
|
111
|
-
if (!instance.isPointInside(svgPoint)) {
|
|
108
|
+
if (!instance.isPointInside(svgPoint.x, svgPoint.y)) {
|
|
112
109
|
lastFind.current = undefined;
|
|
113
110
|
return 'outside-chart';
|
|
114
111
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-charts",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.0",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "The community edition of MUI X Charts components.",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"prop-types": "^15.8.1",
|
|
37
37
|
"reselect": "^5.1.1",
|
|
38
38
|
"use-sync-external-store": "^1.5.0",
|
|
39
|
-
"@mui/x-
|
|
40
|
-
"@mui/x-
|
|
39
|
+
"@mui/x-charts-vendor": "8.4.0",
|
|
40
|
+
"@mui/x-internals": "8.4.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@emotion/react": "^11.9.0",
|