@mui/x-charts 7.8.0 → 7.10.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.d.ts +3 -3
- package/BarChart/useBarChartProps.d.ts +1 -1
- package/CHANGELOG.md +140 -0
- package/ChartContainer/ChartContainer.js +3 -1
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/ChartsSurface.js +5 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +3 -3
- package/ChartsTooltip/ChartsAxisTooltipContent.js +4 -39
- package/ChartsTooltip/ChartsItemTooltipContent.d.ts +7 -6
- package/ChartsTooltip/ChartsItemTooltipContent.js +4 -27
- package/ChartsTooltip/ChartsTooltip.d.ts +10 -9
- package/ChartsTooltip/ChartsTooltip.js +8 -2
- package/ChartsTooltip/ChartsTooltipTable.d.ts +15 -0
- package/ChartsTooltip/ChartsTooltipTable.js +19 -0
- package/ChartsTooltip/index.d.ts +1 -0
- package/ChartsTooltip/index.js +11 -0
- package/ChartsTooltip/utils.d.ts +7 -6
- package/ChartsTooltip/utils.js +24 -30
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +5 -5
- package/ChartsXAxis/ChartsXAxis.js +7 -5
- package/LineChart/AreaPlot.js +7 -1
- package/LineChart/LineChart.d.ts +3 -3
- package/LineChart/MarkPlot.js +6 -2
- package/LineChart/extremums.js +1 -1
- package/LineChart/useLineChartProps.d.ts +1 -1
- package/PieChart/PieChart.d.ts +3 -3
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +3 -1
- package/ScatterChart/Scatter.js +7 -5
- package/ScatterChart/ScatterChart.d.ts +3 -3
- package/ScatterChart/ScatterChart.js +3 -1
- package/ScatterChart/useScatterChartProps.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.d.ts +3 -3
- package/context/CartesianProvider/computeValue.d.ts +2 -2
- package/context/CartesianProvider/computeValue.js +21 -5
- package/context/ZAxisContextProvider.js +7 -2
- package/esm/ChartContainer/ChartContainer.js +3 -1
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/esm/ChartsSurface.js +5 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +3 -38
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +3 -26
- package/esm/ChartsTooltip/ChartsTooltip.js +8 -2
- package/esm/ChartsTooltip/ChartsTooltipTable.js +20 -0
- package/esm/ChartsTooltip/index.js +2 -1
- package/esm/ChartsTooltip/utils.js +23 -30
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +5 -5
- package/esm/ChartsXAxis/ChartsXAxis.js +7 -5
- package/esm/LineChart/AreaPlot.js +7 -1
- package/esm/LineChart/MarkPlot.js +6 -2
- package/esm/LineChart/extremums.js +1 -1
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +3 -1
- package/esm/ScatterChart/Scatter.js +7 -5
- package/esm/ScatterChart/ScatterChart.js +3 -1
- package/esm/context/CartesianProvider/computeValue.js +21 -5
- package/esm/context/ZAxisContextProvider.js +7 -2
- package/esm/hooks/index.js +1 -0
- package/esm/hooks/useAxis.js +17 -0
- package/esm/hooks/useAxisEvents.js +20 -9
- package/esm/hooks/useInteractionItemProps.js +11 -4
- package/esm/hooks/useScale.js +6 -13
- package/esm/internals/index.js +2 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +12 -0
- package/hooks/useAxis.d.ts +2 -0
- package/hooks/useAxis.js +24 -0
- package/hooks/useAxisEvents.js +20 -9
- package/hooks/useInteractionItemProps.d.ts +4 -2
- package/hooks/useInteractionItemProps.js +11 -4
- package/hooks/useScale.js +5 -13
- package/index.js +1 -1
- package/internals/index.d.ts +2 -0
- package/internals/index.js +20 -0
- package/models/colorMapping.d.ts +1 -1
- package/models/z-axis.d.ts +8 -0
- package/modern/ChartContainer/ChartContainer.js +3 -1
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/modern/ChartsSurface.js +5 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +3 -38
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +3 -26
- package/modern/ChartsTooltip/ChartsTooltip.js +8 -2
- package/modern/ChartsTooltip/ChartsTooltipTable.js +20 -0
- package/modern/ChartsTooltip/index.js +2 -1
- package/modern/ChartsTooltip/utils.js +23 -30
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +5 -5
- package/modern/ChartsXAxis/ChartsXAxis.js +7 -5
- package/modern/LineChart/AreaPlot.js +7 -1
- package/modern/LineChart/MarkPlot.js +6 -2
- package/modern/LineChart/extremums.js +1 -1
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +3 -1
- package/modern/ScatterChart/Scatter.js +7 -5
- package/modern/ScatterChart/ScatterChart.js +3 -1
- package/modern/context/CartesianProvider/computeValue.js +21 -5
- package/modern/context/ZAxisContextProvider.js +7 -2
- package/modern/hooks/index.js +1 -0
- package/modern/hooks/useAxis.js +17 -0
- package/modern/hooks/useAxisEvents.js +20 -9
- package/modern/hooks/useInteractionItemProps.js +11 -4
- package/modern/hooks/useScale.js +6 -13
- package/modern/index.js +1 -1
- package/modern/internals/index.js +2 -0
- package/package.json +3 -3
- package/themeAugmentation/props.d.ts +2 -1
package/hooks/useAxisEvents.js
CHANGED
|
@@ -106,7 +106,7 @@ const useAxisEvents = disableAxisListener => {
|
|
|
106
106
|
};
|
|
107
107
|
const handleMove = event => {
|
|
108
108
|
const target = 'targetTouches' in event ? event.targetTouches[0] : event;
|
|
109
|
-
const svgPoint = (0, _getSVGPoint.getSVGPoint)(
|
|
109
|
+
const svgPoint = (0, _getSVGPoint.getSVGPoint)(element, target);
|
|
110
110
|
mousePosition.current = {
|
|
111
111
|
x: svgPoint.x,
|
|
112
112
|
y: svgPoint.y
|
|
@@ -129,15 +129,26 @@ const useAxisEvents = disableAxisListener => {
|
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
131
|
};
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
const handleDown = event => {
|
|
133
|
+
const target = event.currentTarget;
|
|
134
|
+
if (!target) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (target.hasPointerCapture(event.pointerId)) {
|
|
138
|
+
target.releasePointerCapture(event.pointerId);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
element.addEventListener('pointerdown', handleDown);
|
|
142
|
+
element.addEventListener('pointermove', handleMove);
|
|
143
|
+
element.addEventListener('pointerout', handleOut);
|
|
144
|
+
element.addEventListener('pointercancel', handleOut);
|
|
145
|
+
element.addEventListener('pointerleave', handleOut);
|
|
136
146
|
return () => {
|
|
137
|
-
element.removeEventListener('
|
|
138
|
-
element.removeEventListener('
|
|
139
|
-
element.removeEventListener('
|
|
140
|
-
element.removeEventListener('
|
|
147
|
+
element.removeEventListener('pointerdown', handleDown);
|
|
148
|
+
element.removeEventListener('pointermove', handleMove);
|
|
149
|
+
element.removeEventListener('pointerout', handleOut);
|
|
150
|
+
element.removeEventListener('pointercancel', handleOut);
|
|
151
|
+
element.removeEventListener('pointerleave', handleOut);
|
|
141
152
|
};
|
|
142
153
|
}, [svgRef, dispatch, left, width, top, height, usedYAxis, yAxis, usedXAxis, xAxis, disableAxisListener]);
|
|
143
154
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import { SeriesItemIdentifier } from '../models';
|
|
2
3
|
export declare const useInteractionItemProps: (skip?: boolean) => (() => {}) | ((data: SeriesItemIdentifier) => {
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
onPointerEnter: () => void;
|
|
5
|
+
onPointerLeave: (event: React.PointerEvent) => void;
|
|
6
|
+
onPointerDown: (event: React.PointerEvent) => void;
|
|
5
7
|
});
|
|
@@ -21,7 +21,12 @@ const useInteractionItemProps = skip => {
|
|
|
21
21
|
return () => ({});
|
|
22
22
|
}
|
|
23
23
|
const getInteractionItemProps = data => {
|
|
24
|
-
const
|
|
24
|
+
const onPointerDown = event => {
|
|
25
|
+
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
|
|
26
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const onPointerEnter = () => {
|
|
25
30
|
dispatchInteraction({
|
|
26
31
|
type: 'enterItem',
|
|
27
32
|
data
|
|
@@ -31,7 +36,8 @@ const useInteractionItemProps = skip => {
|
|
|
31
36
|
dataIndex: data.dataIndex
|
|
32
37
|
});
|
|
33
38
|
};
|
|
34
|
-
const
|
|
39
|
+
const onPointerLeave = event => {
|
|
40
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
35
41
|
dispatchInteraction({
|
|
36
42
|
type: 'leaveItem',
|
|
37
43
|
data
|
|
@@ -39,8 +45,9 @@ const useInteractionItemProps = skip => {
|
|
|
39
45
|
clearHighlighted();
|
|
40
46
|
};
|
|
41
47
|
return {
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
onPointerEnter,
|
|
49
|
+
onPointerLeave,
|
|
50
|
+
onPointerDown
|
|
44
51
|
};
|
|
45
52
|
};
|
|
46
53
|
return getInteractionItemProps;
|
package/hooks/useScale.js
CHANGED
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getValueToPositionMapper = getValueToPositionMapper;
|
|
7
7
|
exports.useXScale = useXScale;
|
|
8
8
|
exports.useYScale = useYScale;
|
|
9
|
-
var _CartesianProvider = require("../context/CartesianProvider");
|
|
10
9
|
var _isBandScale = require("../internals/isBandScale");
|
|
10
|
+
var _useAxis = require("./useAxis");
|
|
11
11
|
/**
|
|
12
12
|
* For a given scale return a function that map value to their position.
|
|
13
13
|
* Useful when dealing with specific scale such as band.
|
|
@@ -21,18 +21,10 @@ function getValueToPositionMapper(scale) {
|
|
|
21
21
|
return value => scale(value);
|
|
22
22
|
}
|
|
23
23
|
function useXScale(identifier) {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
xAxisIds
|
|
27
|
-
} = (0, _CartesianProvider.useCartesianContext)();
|
|
28
|
-
const id = typeof identifier === 'string' ? identifier : xAxisIds[identifier ?? 0];
|
|
29
|
-
return xAxis[id].scale;
|
|
24
|
+
const axis = (0, _useAxis.useXAxis)(identifier);
|
|
25
|
+
return axis.scale;
|
|
30
26
|
}
|
|
31
27
|
function useYScale(identifier) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
yAxisIds
|
|
35
|
-
} = (0, _CartesianProvider.useCartesianContext)();
|
|
36
|
-
const id = typeof identifier === 'string' ? identifier : yAxisIds[identifier ?? 0];
|
|
37
|
-
return yAxis[id].scale;
|
|
28
|
+
const axis = (0, _useAxis.useYAxis)(identifier);
|
|
29
|
+
return axis.scale;
|
|
38
30
|
}
|
package/index.js
CHANGED
package/internals/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from '../ResponsiveChartContainer/useChartContainerDimensions';
|
|
|
3
3
|
export * from '../ResponsiveChartContainer/ResizableContainer';
|
|
4
4
|
export { useReducedMotion } from '../hooks/useReducedMotion';
|
|
5
5
|
export { useSeries } from '../hooks/useSeries';
|
|
6
|
+
export { useInteractionItemProps } from '../hooks/useInteractionItemProps';
|
|
6
7
|
export { useDrawingArea } from '../hooks/useDrawingArea';
|
|
7
8
|
export { useChartContainerHooks } from '../ChartContainer/useChartContainerHooks';
|
|
8
9
|
export { useScatterChartProps } from '../ScatterChart/useScatterChartProps';
|
|
@@ -10,6 +11,7 @@ export { useLineChartProps } from '../LineChart/useLineChartProps';
|
|
|
10
11
|
export { useBarChartProps } from '../BarChart/useBarChartProps';
|
|
11
12
|
export * from './defaultizeValueFormatter';
|
|
12
13
|
export * from './configInit';
|
|
14
|
+
export * from './getLabel';
|
|
13
15
|
export * from './getSVGPoint';
|
|
14
16
|
export * from '../context/CartesianProvider';
|
|
15
17
|
export * from '../context/DrawingProvider';
|
package/internals/index.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
useReducedMotion: true,
|
|
8
8
|
useSeries: true,
|
|
9
|
+
useInteractionItemProps: true,
|
|
9
10
|
useDrawingArea: true,
|
|
10
11
|
useChartContainerHooks: true,
|
|
11
12
|
useScatterChartProps: true,
|
|
@@ -30,6 +31,12 @@ Object.defineProperty(exports, "useDrawingArea", {
|
|
|
30
31
|
return _useDrawingArea.useDrawingArea;
|
|
31
32
|
}
|
|
32
33
|
});
|
|
34
|
+
Object.defineProperty(exports, "useInteractionItemProps", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () {
|
|
37
|
+
return _useInteractionItemProps.useInteractionItemProps;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
33
40
|
Object.defineProperty(exports, "useLineChartProps", {
|
|
34
41
|
enumerable: true,
|
|
35
42
|
get: function () {
|
|
@@ -92,6 +99,7 @@ Object.keys(_ResizableContainer).forEach(function (key) {
|
|
|
92
99
|
});
|
|
93
100
|
var _useReducedMotion = require("../hooks/useReducedMotion");
|
|
94
101
|
var _useSeries = require("../hooks/useSeries");
|
|
102
|
+
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
95
103
|
var _useDrawingArea = require("../hooks/useDrawingArea");
|
|
96
104
|
var _useChartContainerHooks = require("../ChartContainer/useChartContainerHooks");
|
|
97
105
|
var _useScatterChartProps = require("../ScatterChart/useScatterChartProps");
|
|
@@ -121,6 +129,18 @@ Object.keys(_configInit).forEach(function (key) {
|
|
|
121
129
|
}
|
|
122
130
|
});
|
|
123
131
|
});
|
|
132
|
+
var _getLabel = require("./getLabel");
|
|
133
|
+
Object.keys(_getLabel).forEach(function (key) {
|
|
134
|
+
if (key === "default" || key === "__esModule") return;
|
|
135
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
136
|
+
if (key in exports && exports[key] === _getLabel[key]) return;
|
|
137
|
+
Object.defineProperty(exports, key, {
|
|
138
|
+
enumerable: true,
|
|
139
|
+
get: function () {
|
|
140
|
+
return _getLabel[key];
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
124
144
|
var _getSVGPoint = require("./getSVGPoint");
|
|
125
145
|
Object.keys(_getSVGPoint).forEach(function (key) {
|
|
126
146
|
if (key === "default" || key === "__esModule") return;
|
package/models/colorMapping.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface ContinuousColorConfig<Value = number | Date> {
|
|
|
13
13
|
/**
|
|
14
14
|
* The colors to render. It can be an array with the extremum colors, or an interpolation function.
|
|
15
15
|
*/
|
|
16
|
-
color: [string, string] | ((t: number) => string);
|
|
16
|
+
color: readonly [string, string] | ((t: number) => string);
|
|
17
17
|
}
|
|
18
18
|
export interface PiecewiseColorConfig<Value = number | Date> {
|
|
19
19
|
type: 'piecewise';
|
package/models/z-axis.d.ts
CHANGED
|
@@ -7,6 +7,14 @@ export interface ZAxisConfig<V = any> {
|
|
|
7
7
|
* The key used to retrieve `data` from the `dataset` prop.
|
|
8
8
|
*/
|
|
9
9
|
dataKey?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The minimal value of the scale.
|
|
12
|
+
*/
|
|
13
|
+
min?: number;
|
|
14
|
+
/**
|
|
15
|
+
* The maximal value of the scale.
|
|
16
|
+
*/
|
|
17
|
+
max?: number;
|
|
10
18
|
colorMap?: OrdinalColorConfig | ContinuousColorConfig | PiecewiseColorConfig;
|
|
11
19
|
}
|
|
12
20
|
export interface ZAxisDefaultized extends ZAxisConfig {
|
|
@@ -283,7 +283,9 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
283
283
|
})]),
|
|
284
284
|
data: PropTypes.array,
|
|
285
285
|
dataKey: PropTypes.string,
|
|
286
|
-
id: PropTypes.string
|
|
286
|
+
id: PropTypes.string,
|
|
287
|
+
max: PropTypes.number,
|
|
288
|
+
min: PropTypes.number
|
|
287
289
|
}))
|
|
288
290
|
} : void 0;
|
|
289
291
|
export { ChartContainer };
|
|
@@ -86,7 +86,7 @@ function ChartsAxisHighlight(props) {
|
|
|
86
86
|
ownerState: {
|
|
87
87
|
axisHighlight: 'band'
|
|
88
88
|
}
|
|
89
|
-
}), isBandScaleY && yScale(axisY.value)
|
|
89
|
+
}), isBandScaleY && yScale(axisY.value) !== undefined && /*#__PURE__*/_jsx(ChartsAxisHighlightPath, {
|
|
90
90
|
d: `M ${xScale.range()[0]} ${
|
|
91
91
|
// @ts-expect-error, yScale value is checked in the statement above
|
|
92
92
|
yScale(axisY.value) - (yScale.step() - yScale.bandwidth()) / 2} l 0 ${yScale.step()} l ${xScale.range()[1] - xScale.range()[0]} 0 l 0 ${-yScale.step()} Z`,
|
package/modern/ChartsSurface.js
CHANGED
|
@@ -9,7 +9,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
9
9
|
const ChartChartsSurfaceStyles = styled('svg', {
|
|
10
10
|
name: 'MuiChartsSurface',
|
|
11
11
|
slot: 'Root'
|
|
12
|
-
})(() => ({
|
|
12
|
+
})(() => ({
|
|
13
|
+
// This prevents default touch actions when using the svg on mobile devices.
|
|
14
|
+
// For example, prevent page scroll & zoom.
|
|
15
|
+
touchAction: 'none'
|
|
16
|
+
}));
|
|
13
17
|
const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props, ref) {
|
|
14
18
|
const {
|
|
15
19
|
children,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
3
|
import { useSlotProps } from '@mui/base/utils';
|
|
5
4
|
import { useCartesianContext } from '../context/CartesianProvider';
|
|
6
5
|
import { DefaultChartsAxisTooltipContent } from './DefaultChartsAxisTooltipContent';
|
|
@@ -9,6 +8,9 @@ import { useColorProcessor } from '../hooks/useColor';
|
|
|
9
8
|
import { isCartesianSeriesType } from '../internals/isCartesian';
|
|
10
9
|
import { useSeries } from '../hooks/useSeries';
|
|
11
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
/**
|
|
12
|
+
* @ignore - internal component.
|
|
13
|
+
*/
|
|
12
14
|
function ChartsAxisTooltipContent(props) {
|
|
13
15
|
const {
|
|
14
16
|
content,
|
|
@@ -71,41 +73,4 @@ function ChartsAxisTooltipContent(props) {
|
|
|
71
73
|
});
|
|
72
74
|
return /*#__PURE__*/_jsx(Content, _extends({}, chartTooltipContentProps));
|
|
73
75
|
}
|
|
74
|
-
process.env.NODE_ENV !== "production" ? ChartsAxisTooltipContent.propTypes = {
|
|
75
|
-
// ----------------------------- Warning --------------------------------
|
|
76
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
77
|
-
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
78
|
-
// ----------------------------------------------------------------------
|
|
79
|
-
axisData: PropTypes.shape({
|
|
80
|
-
x: PropTypes.shape({
|
|
81
|
-
index: PropTypes.number,
|
|
82
|
-
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
|
|
83
|
-
}),
|
|
84
|
-
y: PropTypes.shape({
|
|
85
|
-
index: PropTypes.number,
|
|
86
|
-
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
|
|
87
|
-
})
|
|
88
|
-
}).isRequired,
|
|
89
|
-
classes: PropTypes.object.isRequired,
|
|
90
|
-
content: PropTypes.elementType,
|
|
91
|
-
contentProps: PropTypes.shape({
|
|
92
|
-
axis: PropTypes.object,
|
|
93
|
-
axisData: PropTypes.shape({
|
|
94
|
-
x: PropTypes.shape({
|
|
95
|
-
index: PropTypes.number,
|
|
96
|
-
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
|
|
97
|
-
}),
|
|
98
|
-
y: PropTypes.shape({
|
|
99
|
-
index: PropTypes.number,
|
|
100
|
-
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
|
|
101
|
-
})
|
|
102
|
-
}),
|
|
103
|
-
axisValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]),
|
|
104
|
-
classes: PropTypes.object,
|
|
105
|
-
dataIndex: PropTypes.number,
|
|
106
|
-
series: PropTypes.arrayOf(PropTypes.object),
|
|
107
|
-
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
108
|
-
}),
|
|
109
|
-
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
110
|
-
} : void 0;
|
|
111
76
|
export { ChartsAxisTooltipContent };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
3
|
import { useSlotProps } from '@mui/base/utils';
|
|
5
4
|
import { DefaultChartsItemTooltipContent } from './DefaultChartsItemTooltipContent';
|
|
6
5
|
import { useCartesianContext } from '../context/CartesianProvider';
|
|
@@ -8,6 +7,9 @@ import { ZAxisContext } from '../context/ZAxisContextProvider';
|
|
|
8
7
|
import { useColorProcessor } from '../hooks/useColor';
|
|
9
8
|
import { useSeries } from '../hooks/useSeries';
|
|
10
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
/**
|
|
11
|
+
* @ignore - internal component.
|
|
12
|
+
*/
|
|
11
13
|
function ChartsItemTooltipContent(props) {
|
|
12
14
|
const {
|
|
13
15
|
content,
|
|
@@ -47,29 +49,4 @@ function ChartsItemTooltipContent(props) {
|
|
|
47
49
|
});
|
|
48
50
|
return /*#__PURE__*/_jsx(Content, _extends({}, chartTooltipContentProps));
|
|
49
51
|
}
|
|
50
|
-
process.env.NODE_ENV !== "production" ? ChartsItemTooltipContent.propTypes = {
|
|
51
|
-
// ----------------------------- Warning --------------------------------
|
|
52
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
53
|
-
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
54
|
-
// ----------------------------------------------------------------------
|
|
55
|
-
classes: PropTypes.object.isRequired,
|
|
56
|
-
content: PropTypes.elementType,
|
|
57
|
-
contentProps: PropTypes.shape({
|
|
58
|
-
classes: PropTypes.object,
|
|
59
|
-
getColor: PropTypes.func,
|
|
60
|
-
itemData: PropTypes.shape({
|
|
61
|
-
dataIndex: PropTypes.number,
|
|
62
|
-
seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
63
|
-
type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired
|
|
64
|
-
}),
|
|
65
|
-
series: PropTypes.object,
|
|
66
|
-
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
67
|
-
}),
|
|
68
|
-
itemData: PropTypes.shape({
|
|
69
|
-
dataIndex: PropTypes.number,
|
|
70
|
-
seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
71
|
-
type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired
|
|
72
|
-
}).isRequired,
|
|
73
|
-
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
74
|
-
} : void 0;
|
|
75
52
|
export { ChartsItemTooltipContent };
|
|
@@ -77,8 +77,14 @@ function ChartsTooltip(props) {
|
|
|
77
77
|
externalSlotProps: slotProps?.popper,
|
|
78
78
|
additionalProps: {
|
|
79
79
|
open: popperOpen,
|
|
80
|
-
placement: 'right-start',
|
|
81
|
-
anchorEl: generateVirtualElement(mousePosition)
|
|
80
|
+
placement: mousePosition?.pointerType === 'mouse' ? 'right-start' : 'top',
|
|
81
|
+
anchorEl: generateVirtualElement(mousePosition),
|
|
82
|
+
modifiers: [{
|
|
83
|
+
name: 'offset',
|
|
84
|
+
options: {
|
|
85
|
+
offset: [0, mousePosition?.pointerType === 'touch' ? 40 - mousePosition.height : 0]
|
|
86
|
+
}
|
|
87
|
+
}]
|
|
82
88
|
},
|
|
83
89
|
ownerState: {}
|
|
84
90
|
});
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { styled } from '@mui/material/styles';
|
|
2
2
|
import { shouldForwardProp } from '@mui/system';
|
|
3
3
|
import { chartsTooltipClasses } from './chartsTooltipClasses';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @ignore - internal component.
|
|
7
|
+
*/
|
|
4
8
|
export const ChartsTooltipPaper = styled('div', {
|
|
5
9
|
name: 'MuiChartsTooltip',
|
|
6
10
|
slot: 'Container'
|
|
@@ -13,6 +17,10 @@ export const ChartsTooltipPaper = styled('div', {
|
|
|
13
17
|
transition: theme.transitions.create('box-shadow'),
|
|
14
18
|
borderRadius: theme.shape.borderRadius
|
|
15
19
|
}));
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @ignore - internal component.
|
|
23
|
+
*/
|
|
16
24
|
export const ChartsTooltipTable = styled('table', {
|
|
17
25
|
name: 'MuiChartsTooltip',
|
|
18
26
|
slot: 'Table'
|
|
@@ -24,6 +32,10 @@ export const ChartsTooltipTable = styled('table', {
|
|
|
24
32
|
borderBottom: `solid ${(theme.vars || theme).palette.divider} 1px`
|
|
25
33
|
}
|
|
26
34
|
}));
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @ignore - internal component.
|
|
38
|
+
*/
|
|
27
39
|
export const ChartsTooltipRow = styled('tr', {
|
|
28
40
|
name: 'MuiChartsTooltip',
|
|
29
41
|
slot: 'Row'
|
|
@@ -37,6 +49,10 @@ export const ChartsTooltipRow = styled('tr', {
|
|
|
37
49
|
paddingBottom: theme.spacing(1)
|
|
38
50
|
}
|
|
39
51
|
}));
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @ignore - internal component.
|
|
55
|
+
*/
|
|
40
56
|
export const ChartsTooltipCell = styled('td', {
|
|
41
57
|
name: 'MuiChartsTooltip',
|
|
42
58
|
slot: 'Cell'
|
|
@@ -59,6 +75,10 @@ export const ChartsTooltipCell = styled('td', {
|
|
|
59
75
|
paddingRight: theme.spacing(2)
|
|
60
76
|
}
|
|
61
77
|
}));
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @ignore - internal component.
|
|
81
|
+
*/
|
|
62
82
|
export const ChartsTooltipMark = styled('div', {
|
|
63
83
|
name: 'MuiChartsTooltip',
|
|
64
84
|
slot: 'Mark',
|
|
@@ -3,4 +3,5 @@ export * from './chartsTooltipClasses';
|
|
|
3
3
|
export * from './ChartsAxisTooltipContent';
|
|
4
4
|
export * from './ChartsItemTooltipContent';
|
|
5
5
|
export * from './DefaultChartsAxisTooltipContent';
|
|
6
|
-
export * from './DefaultChartsItemTooltipContent';
|
|
6
|
+
export * from './DefaultChartsItemTooltipContent';
|
|
7
|
+
export * from './ChartsTooltipTable';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import { useSvgRef } from '../hooks';
|
|
3
4
|
export function generateVirtualElement(mousePosition) {
|
|
@@ -20,26 +21,19 @@ export function generateVirtualElement(mousePosition) {
|
|
|
20
21
|
x,
|
|
21
22
|
y
|
|
22
23
|
} = mousePosition;
|
|
24
|
+
const boundingBox = {
|
|
25
|
+
width: 0,
|
|
26
|
+
height: 0,
|
|
27
|
+
x,
|
|
28
|
+
y,
|
|
29
|
+
top: y,
|
|
30
|
+
right: x,
|
|
31
|
+
bottom: y,
|
|
32
|
+
left: x
|
|
33
|
+
};
|
|
23
34
|
return {
|
|
24
|
-
getBoundingClientRect: () => ({
|
|
25
|
-
|
|
26
|
-
height: 0,
|
|
27
|
-
x,
|
|
28
|
-
y,
|
|
29
|
-
top: y,
|
|
30
|
-
right: x,
|
|
31
|
-
bottom: y,
|
|
32
|
-
left: x,
|
|
33
|
-
toJSON: () => JSON.stringify({
|
|
34
|
-
width: 0,
|
|
35
|
-
height: 0,
|
|
36
|
-
x,
|
|
37
|
-
y,
|
|
38
|
-
top: y,
|
|
39
|
-
right: x,
|
|
40
|
-
bottom: y,
|
|
41
|
-
left: x
|
|
42
|
-
})
|
|
35
|
+
getBoundingClientRect: () => _extends({}, boundingBox, {
|
|
36
|
+
toJSON: () => JSON.stringify(boundingBox)
|
|
43
37
|
})
|
|
44
38
|
};
|
|
45
39
|
}
|
|
@@ -57,21 +51,20 @@ export function useMouseTracker() {
|
|
|
57
51
|
setMousePosition(null);
|
|
58
52
|
};
|
|
59
53
|
const handleMove = event => {
|
|
60
|
-
const target = 'targetTouches' in event ? event.targetTouches[0] : event;
|
|
61
54
|
setMousePosition({
|
|
62
|
-
x:
|
|
63
|
-
y:
|
|
55
|
+
x: event.clientX,
|
|
56
|
+
y: event.clientY,
|
|
57
|
+
height: event.height,
|
|
58
|
+
pointerType: event.pointerType
|
|
64
59
|
});
|
|
65
60
|
};
|
|
66
|
-
element.addEventListener('
|
|
67
|
-
element.addEventListener('
|
|
68
|
-
element.addEventListener('
|
|
69
|
-
element.addEventListener('touchmove', handleMove);
|
|
61
|
+
element.addEventListener('pointerdown', handleMove);
|
|
62
|
+
element.addEventListener('pointermove', handleMove);
|
|
63
|
+
element.addEventListener('pointerup', handleOut);
|
|
70
64
|
return () => {
|
|
71
|
-
element.removeEventListener('
|
|
72
|
-
element.removeEventListener('
|
|
73
|
-
element.
|
|
74
|
-
element.addEventListener('touchmove', handleMove);
|
|
65
|
+
element.removeEventListener('pointerdown', handleMove);
|
|
66
|
+
element.removeEventListener('pointermove', handleMove);
|
|
67
|
+
element.removeEventListener('pointerup', handleOut);
|
|
75
68
|
};
|
|
76
69
|
}, [svgRef]);
|
|
77
70
|
return mousePosition;
|
|
@@ -96,7 +96,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
96
96
|
// TODO: A perf optimisation of voronoi could be to use the last point as the initial point for the next search.
|
|
97
97
|
function getClosestPoint(event) {
|
|
98
98
|
// Get mouse coordinate in global SVG space
|
|
99
|
-
const svgPoint = getSVGPoint(
|
|
99
|
+
const svgPoint = getSVGPoint(element, event);
|
|
100
100
|
const outsideX = svgPoint.x < left || svgPoint.x > left + width;
|
|
101
101
|
const outsideY = svgPoint.y < top || svgPoint.y > top + height;
|
|
102
102
|
if (outsideX || outsideY) {
|
|
@@ -191,12 +191,12 @@ function ChartsVoronoiHandler(props) {
|
|
|
191
191
|
dataIndex
|
|
192
192
|
});
|
|
193
193
|
};
|
|
194
|
-
element.addEventListener('
|
|
195
|
-
element.addEventListener('
|
|
194
|
+
element.addEventListener('pointerout', handleMouseOut);
|
|
195
|
+
element.addEventListener('pointermove', handleMouseMove);
|
|
196
196
|
element.addEventListener('click', handleMouseClick);
|
|
197
197
|
return () => {
|
|
198
|
-
element.removeEventListener('
|
|
199
|
-
element.removeEventListener('
|
|
198
|
+
element.removeEventListener('pointerout', handleMouseOut);
|
|
199
|
+
element.removeEventListener('pointermove', handleMouseMove);
|
|
200
200
|
element.removeEventListener('click', handleMouseClick);
|
|
201
201
|
};
|
|
202
202
|
}, [svgRef, dispatch, left, width, top, height, yAxis, xAxis, voronoiMaxRadius, onItemClick, setHighlighted, clearHighlighted]);
|
|
@@ -209,10 +209,10 @@ function ChartsXAxis(inProps) {
|
|
|
209
209
|
transform: `translate(0, ${position === 'bottom' ? top + height : top})`,
|
|
210
210
|
className: classes.root,
|
|
211
211
|
children: [!disableLine && /*#__PURE__*/_jsx(Line, _extends({
|
|
212
|
-
x1:
|
|
213
|
-
x2:
|
|
212
|
+
x1: left,
|
|
213
|
+
x2: left + width,
|
|
214
214
|
className: classes.line
|
|
215
|
-
}, slotProps?.axisLine)), xTicksWithDimension.map(({
|
|
215
|
+
}, slotProps?.axisLine)), xTicksWithDimension.filter(tick => tick.offset >= left - 1 && tick.offset <= left + width + 1).map(({
|
|
216
216
|
formattedValue,
|
|
217
217
|
offset,
|
|
218
218
|
labelOffset,
|
|
@@ -220,13 +220,15 @@ function ChartsXAxis(inProps) {
|
|
|
220
220
|
}, index) => {
|
|
221
221
|
const xTickLabel = labelOffset ?? 0;
|
|
222
222
|
const yTickLabel = positionSign * (tickSize + 3);
|
|
223
|
+
const showTick = offset >= left - 1 && offset <= left + width + 1;
|
|
224
|
+
const showTickLabel = offset + xTickLabel >= left - 1 && offset + xTickLabel <= left + width + 1;
|
|
223
225
|
return /*#__PURE__*/_jsxs("g", {
|
|
224
226
|
transform: `translate(${offset}, 0)`,
|
|
225
227
|
className: classes.tickContainer,
|
|
226
|
-
children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
|
|
228
|
+
children: [!disableTicks && showTick && /*#__PURE__*/_jsx(Tick, _extends({
|
|
227
229
|
y2: positionSign * tickSize,
|
|
228
230
|
className: classes.tick
|
|
229
|
-
}, slotProps?.axisTick)), formattedValue !== undefined && !skipLabel && /*#__PURE__*/_jsx(TickLabel, _extends({
|
|
231
|
+
}, slotProps?.axisTick)), formattedValue !== undefined && !skipLabel && showTickLabel && /*#__PURE__*/_jsx(TickLabel, _extends({
|
|
230
232
|
x: xTickLabel,
|
|
231
233
|
y: yTickLabel
|
|
232
234
|
}, axisTickLabelProps, {
|
|
@@ -54,7 +54,13 @@ const useAggregatedData = () => {
|
|
|
54
54
|
throw new Error(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
const areaPath = d3Area().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y0(d =>
|
|
57
|
+
const areaPath = d3Area().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y0(d => {
|
|
58
|
+
const value = d.y && yScale(d.y[0]);
|
|
59
|
+
if (Number.isNaN(value)) {
|
|
60
|
+
return yScale.range()[0];
|
|
61
|
+
}
|
|
62
|
+
return value;
|
|
63
|
+
}).y1(d => d.y && yScale(d.y[1]));
|
|
58
64
|
const curve = getCurveFactory(series[seriesId].curve);
|
|
59
65
|
const formattedData = xData?.map((x, index) => ({
|
|
60
66
|
x,
|
|
@@ -11,6 +11,7 @@ import { DEFAULT_X_AXIS_KEY } from '../constants';
|
|
|
11
11
|
import { cleanId } from '../internals/utils';
|
|
12
12
|
import getColor from './getColor';
|
|
13
13
|
import { useLineSeries } from '../hooks/useSeries';
|
|
14
|
+
import { useDrawingArea } from '../hooks/useDrawingArea';
|
|
14
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
16
|
/**
|
|
16
17
|
* Demos:
|
|
@@ -33,6 +34,10 @@ function MarkPlot(props) {
|
|
|
33
34
|
const seriesData = useLineSeries();
|
|
34
35
|
const axisData = useCartesianContext();
|
|
35
36
|
const chartId = useChartId();
|
|
37
|
+
const {
|
|
38
|
+
left,
|
|
39
|
+
width
|
|
40
|
+
} = useDrawingArea();
|
|
36
41
|
const Mark = slots?.mark ?? MarkElement;
|
|
37
42
|
if (seriesData === undefined) {
|
|
38
43
|
return null;
|
|
@@ -67,13 +72,12 @@ function MarkPlot(props) {
|
|
|
67
72
|
const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
68
73
|
const yScale = yAxis[yAxisKey].scale;
|
|
69
74
|
const xData = xAxis[xAxisKey].data;
|
|
70
|
-
const xRange = xAxis[xAxisKey].scale.range();
|
|
71
75
|
const yRange = yScale.range();
|
|
72
76
|
const isInRange = ({
|
|
73
77
|
x,
|
|
74
78
|
y
|
|
75
79
|
}) => {
|
|
76
|
-
if (x <
|
|
80
|
+
if (x < left || x > left + width) {
|
|
77
81
|
return false;
|
|
78
82
|
}
|
|
79
83
|
if (y < Math.min(...yRange) || y > Math.max(...yRange)) {
|
|
@@ -30,7 +30,7 @@ export const getExtremumY = params => {
|
|
|
30
30
|
stackedData
|
|
31
31
|
} = series[seriesId];
|
|
32
32
|
const isArea = area !== undefined;
|
|
33
|
-
const getValues = isArea ? d => d : d => [d[1], d[1]]; // Since this series is not used to display an area, we do not consider the base (the d[0]).
|
|
33
|
+
const getValues = isArea && axis.scaleType !== 'log' ? d => d : d => [d[1], d[1]]; // Since this series is not used to display an area, we do not consider the base (the d[0]).
|
|
34
34
|
|
|
35
35
|
const seriesExtremums = getSeriesExtremums(getValues, stackedData);
|
|
36
36
|
if (acc[0] === null) {
|
|
@@ -229,7 +229,9 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
229
229
|
})]),
|
|
230
230
|
data: PropTypes.array,
|
|
231
231
|
dataKey: PropTypes.string,
|
|
232
|
-
id: PropTypes.string
|
|
232
|
+
id: PropTypes.string,
|
|
233
|
+
max: PropTypes.number,
|
|
234
|
+
min: PropTypes.number
|
|
233
235
|
}))
|
|
234
236
|
} : void 0;
|
|
235
237
|
export { ResponsiveChartContainer };
|