@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
|
@@ -3,4 +3,4 @@ import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
|
3
3
|
export function getAxisUtilityClass(slot) {
|
|
4
4
|
return generateUtilityClass('MuiChartsAxis', slot);
|
|
5
5
|
}
|
|
6
|
-
export const axisClasses = generateUtilityClasses('MuiChartsAxis', ['root', 'line', 'tickContainer', 'tick', 'tickLabel', 'label', 'directionX', 'directionY', 'top', 'bottom', 'left', 'right']);
|
|
6
|
+
export const axisClasses = generateUtilityClasses('MuiChartsAxis', ['root', 'line', 'tickContainer', 'tick', 'tickLabel', 'label', 'directionX', 'directionY', 'top', 'bottom', 'left', 'right', 'id']);
|
|
@@ -100,6 +100,7 @@ const ChartsLegend = consumeSlots('MuiChartsLegend', 'legend', {
|
|
|
100
100
|
})
|
|
101
101
|
}));
|
|
102
102
|
}));
|
|
103
|
+
if (process.env.NODE_ENV !== "production") ChartsLegend.displayName = "ChartsLegend";
|
|
103
104
|
process.env.NODE_ENV !== "production" ? ChartsLegend.propTypes = {
|
|
104
105
|
// ----------------------------- Warning --------------------------------
|
|
105
106
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -9,9 +9,7 @@ import { useThemeProps } from '@mui/material/styles';
|
|
|
9
9
|
import { DEFAULT_LOCALE } from "../locales/enUS.js";
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
export const ChartsLocalizationContext = /*#__PURE__*/React.createContext(null);
|
|
12
|
-
if (process.env.NODE_ENV !==
|
|
13
|
-
ChartsLocalizationContext.displayName = 'ChartsLocalizationContext';
|
|
14
|
-
}
|
|
12
|
+
if (process.env.NODE_ENV !== "production") ChartsLocalizationContext.displayName = "ChartsLocalizationContext";
|
|
15
13
|
/**
|
|
16
14
|
* Demos:
|
|
17
15
|
*
|
|
@@ -86,6 +86,7 @@ const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(inPro
|
|
|
86
86
|
}), /*#__PURE__*/_jsx(ChartsAxesGradients, {}), hasIntrinsicSize && children]
|
|
87
87
|
}));
|
|
88
88
|
});
|
|
89
|
+
if (process.env.NODE_ENV !== "production") ChartsSurface.displayName = "ChartsSurface";
|
|
89
90
|
process.env.NODE_ENV !== "production" ? ChartsSurface.propTypes = {
|
|
90
91
|
// ----------------------------- Warning --------------------------------
|
|
91
92
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -31,10 +31,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
31
31
|
const useUtilityClasses = ownerState => {
|
|
32
32
|
const {
|
|
33
33
|
classes,
|
|
34
|
-
position
|
|
34
|
+
position,
|
|
35
|
+
id
|
|
35
36
|
} = ownerState;
|
|
36
37
|
const slots = {
|
|
37
|
-
root: ['root', 'directionX', position],
|
|
38
|
+
root: ['root', 'directionX', position, `id-${id}`],
|
|
38
39
|
line: ['line'],
|
|
39
40
|
tickContainer: ['tickContainer'],
|
|
40
41
|
tick: ['tick'],
|
|
@@ -56,7 +57,7 @@ function getVisibleLabels(xTicks, {
|
|
|
56
57
|
tickLabelMinGap,
|
|
57
58
|
reverse,
|
|
58
59
|
isMounted,
|
|
59
|
-
|
|
60
|
+
isXInside
|
|
60
61
|
}) {
|
|
61
62
|
const getTickLabelSize = tick => {
|
|
62
63
|
if (!isMounted || tick.formattedValue === undefined) {
|
|
@@ -91,7 +92,7 @@ function getVisibleLabels(xTicks, {
|
|
|
91
92
|
if (labelIndex > 0 && direction * textPosition < direction * (previousTextLimit + tickLabelMinGap)) {
|
|
92
93
|
return false;
|
|
93
94
|
}
|
|
94
|
-
if (!
|
|
95
|
+
if (!isXInside(textPosition)) {
|
|
95
96
|
return false;
|
|
96
97
|
}
|
|
97
98
|
|
|
@@ -259,12 +260,7 @@ function ChartsXAxis(inProps) {
|
|
|
259
260
|
tickLabelMinGap,
|
|
260
261
|
reverse,
|
|
261
262
|
isMounted,
|
|
262
|
-
|
|
263
|
-
x,
|
|
264
|
-
y: -1
|
|
265
|
-
}, {
|
|
266
|
-
direction: 'x'
|
|
267
|
-
})
|
|
263
|
+
isXInside: instance.isXInside
|
|
268
264
|
});
|
|
269
265
|
const axisLabelProps = useSlotProps({
|
|
270
266
|
elementType: Label,
|
|
@@ -312,12 +308,7 @@ function ChartsXAxis(inProps) {
|
|
|
312
308
|
} = item;
|
|
313
309
|
const xTickLabel = labelOffset ?? 0;
|
|
314
310
|
const yTickLabel = positionSign * (tickSize + TICK_LABEL_GAP);
|
|
315
|
-
const showTick = instance.
|
|
316
|
-
x: tickOffset,
|
|
317
|
-
y: -1
|
|
318
|
-
}, {
|
|
319
|
-
direction: 'x'
|
|
320
|
-
});
|
|
311
|
+
const showTick = instance.isXInside(tickOffset);
|
|
321
312
|
const tickLabel = tickLabels.get(item);
|
|
322
313
|
const showTickLabel = visibleLabels.has(item);
|
|
323
314
|
return /*#__PURE__*/_jsxs("g", {
|
|
@@ -28,10 +28,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
28
28
|
const useUtilityClasses = ownerState => {
|
|
29
29
|
const {
|
|
30
30
|
classes,
|
|
31
|
-
position
|
|
31
|
+
position,
|
|
32
|
+
id
|
|
32
33
|
} = ownerState;
|
|
33
34
|
const slots = {
|
|
34
|
-
root: ['root', 'directionY', position],
|
|
35
|
+
root: ['root', 'directionY', position, `id-${id}`],
|
|
35
36
|
line: ['line'],
|
|
36
37
|
tickContainer: ['tickContainer'],
|
|
37
38
|
tick: ['tick'],
|
|
@@ -236,12 +237,7 @@ function ChartsYAxis(inProps) {
|
|
|
236
237
|
const xTickLabel = positionSign * (tickSize + TICK_LABEL_GAP);
|
|
237
238
|
const yTickLabel = labelOffset;
|
|
238
239
|
const skipLabel = typeof tickLabelInterval === 'function' && !tickLabelInterval?.(value, index);
|
|
239
|
-
const showLabel = instance.
|
|
240
|
-
x: -1,
|
|
241
|
-
y: tickOffset
|
|
242
|
-
}, {
|
|
243
|
-
direction: 'y'
|
|
244
|
-
});
|
|
240
|
+
const showLabel = instance.isYInside(tickOffset);
|
|
245
241
|
const tickLabel = tickLabels.get(item);
|
|
246
242
|
if (!showLabel) {
|
|
247
243
|
return null;
|
package/esm/Gauge/Gauge.js
CHANGED
|
@@ -48,6 +48,7 @@ const Gauge = /*#__PURE__*/React.forwardRef(function Gauge(props, ref) {
|
|
|
48
48
|
}), children]
|
|
49
49
|
}));
|
|
50
50
|
});
|
|
51
|
+
if (process.env.NODE_ENV !== "production") Gauge.displayName = "Gauge";
|
|
51
52
|
process.env.NODE_ENV !== "production" ? Gauge.propTypes = {
|
|
52
53
|
// ----------------------------- Warning --------------------------------
|
|
53
54
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -78,6 +78,7 @@ const GaugeContainer = /*#__PURE__*/React.forwardRef(function GaugeContainer(pro
|
|
|
78
78
|
})
|
|
79
79
|
});
|
|
80
80
|
});
|
|
81
|
+
if (process.env.NODE_ENV !== "production") GaugeContainer.displayName = "GaugeContainer";
|
|
81
82
|
process.env.NODE_ENV !== "production" ? GaugeContainer.propTypes = {
|
|
82
83
|
// ----------------------------- Warning --------------------------------
|
|
83
84
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -21,9 +21,7 @@ export const GaugeContext = /*#__PURE__*/React.createContext({
|
|
|
21
21
|
maxRadius: 0,
|
|
22
22
|
valueAngle: null
|
|
23
23
|
});
|
|
24
|
-
if (process.env.NODE_ENV !==
|
|
25
|
-
GaugeContext.displayName = 'GaugeContext';
|
|
26
|
-
}
|
|
24
|
+
if (process.env.NODE_ENV !== "production") GaugeContext.displayName = "GaugeContext";
|
|
27
25
|
export function GaugeProvider(props) {
|
|
28
26
|
const {
|
|
29
27
|
value = null,
|
|
@@ -40,6 +40,7 @@ const AnimatedLine = /*#__PURE__*/React.forwardRef(function AnimatedLine(props,
|
|
|
40
40
|
}, other, animateProps))
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
|
+
if (process.env.NODE_ENV !== "production") AnimatedLine.displayName = "AnimatedLine";
|
|
43
44
|
process.env.NODE_ENV !== "production" ? AnimatedLine.propTypes = {
|
|
44
45
|
// ----------------------------- Warning --------------------------------
|
|
45
46
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -65,11 +65,12 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(inProps, ref)
|
|
|
65
65
|
})), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx("g", {
|
|
66
66
|
"data-drawing-container": true,
|
|
67
67
|
children: /*#__PURE__*/_jsx(MarkPlot, _extends({}, markPlotProps))
|
|
68
|
-
}), /*#__PURE__*/_jsx(LineHighlightPlot, _extends({}, lineHighlightPlotProps)),
|
|
69
|
-
}))]
|
|
68
|
+
}), /*#__PURE__*/_jsx(LineHighlightPlot, _extends({}, lineHighlightPlotProps)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), children]
|
|
69
|
+
})), !props.loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, props.slotProps?.tooltip))]
|
|
70
70
|
}))
|
|
71
71
|
}));
|
|
72
72
|
});
|
|
73
|
+
if (process.env.NODE_ENV !== "production") LineChart.displayName = "LineChart";
|
|
73
74
|
process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
74
75
|
// ----------------------------- Warning --------------------------------
|
|
75
76
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -84,10 +84,7 @@ function LineHighlightPlot(props) {
|
|
|
84
84
|
const x = xScale(xData[highlightedIndex]);
|
|
85
85
|
const y = yScale(stackedData[highlightedIndex][1]); // This should not be undefined since y should not be a band scale
|
|
86
86
|
|
|
87
|
-
if (!instance.isPointInside({
|
|
88
|
-
x,
|
|
89
|
-
y
|
|
90
|
-
})) {
|
|
87
|
+
if (!instance.isPointInside(x, y)) {
|
|
91
88
|
return null;
|
|
92
89
|
}
|
|
93
90
|
const colorGetter = getColor(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
|
package/esm/PieChart/PieArc.js
CHANGED
|
@@ -97,6 +97,7 @@ const PieArc = /*#__PURE__*/React.forwardRef(function PieArc(props, ref) {
|
|
|
97
97
|
strokeLinejoin: "round"
|
|
98
98
|
}, other, interactionProps, animatedProps));
|
|
99
99
|
});
|
|
100
|
+
if (process.env.NODE_ENV !== "production") PieArc.displayName = "PieArc";
|
|
100
101
|
process.env.NODE_ENV !== "production" ? PieArc.propTypes = {
|
|
101
102
|
// ----------------------------- Warning --------------------------------
|
|
102
103
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -92,6 +92,7 @@ const PieArcLabel = /*#__PURE__*/React.forwardRef(function PieArcLabel(props, re
|
|
|
92
92
|
children: formattedArcLabel
|
|
93
93
|
}));
|
|
94
94
|
});
|
|
95
|
+
if (process.env.NODE_ENV !== "production") PieArcLabel.displayName = "PieArcLabel";
|
|
95
96
|
process.env.NODE_ENV !== "production" ? PieArcLabel.propTypes = {
|
|
96
97
|
// ----------------------------- Warning --------------------------------
|
|
97
98
|
// | These PropTypes are generated from the TypeScript type definitions |
|
package/esm/PieChart/PieChart.js
CHANGED
|
@@ -95,13 +95,14 @@ const PieChart = /*#__PURE__*/React.forwardRef(function PieChart(inProps, ref) {
|
|
|
95
95
|
loading: loading,
|
|
96
96
|
slots: slots,
|
|
97
97
|
slotProps: slotProps
|
|
98
|
-
}),
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}))]
|
|
98
|
+
}), children]
|
|
99
|
+
})), !loading && /*#__PURE__*/_jsx(Tooltip, _extends({
|
|
100
|
+
trigger: "item"
|
|
101
|
+
}, slotProps?.tooltip))]
|
|
102
102
|
})
|
|
103
103
|
}));
|
|
104
104
|
});
|
|
105
|
+
if (process.env.NODE_ENV !== "production") PieChart.displayName = "PieChart";
|
|
105
106
|
process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
106
107
|
// ----------------------------- Warning --------------------------------
|
|
107
108
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -36,11 +36,12 @@ const RadarChart = /*#__PURE__*/React.forwardRef(function RadarChart(inProps, re
|
|
|
36
36
|
children: /*#__PURE__*/_jsxs(ChartsWrapper, _extends({}, chartsWrapperProps, {
|
|
37
37
|
children: [!props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
38
38
|
ref: ref,
|
|
39
|
-
children: [/*#__PURE__*/_jsx(RadarGrid, _extends({}, radarGrid)), /*#__PURE__*/_jsx(RadarMetricLabels, {}), /*#__PURE__*/_jsx(RadarSeriesArea, {}), highlight === 'axis' && /*#__PURE__*/_jsx(RadarAxisHighlight, {}), /*#__PURE__*/_jsx(RadarSeriesMarks, {}), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)),
|
|
40
|
-
}))]
|
|
39
|
+
children: [/*#__PURE__*/_jsx(RadarGrid, _extends({}, radarGrid)), /*#__PURE__*/_jsx(RadarMetricLabels, {}), /*#__PURE__*/_jsx(RadarSeriesArea, {}), highlight === 'axis' && /*#__PURE__*/_jsx(RadarAxisHighlight, {}), /*#__PURE__*/_jsx(RadarSeriesMarks, {}), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), children]
|
|
40
|
+
})), !props.loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, props.slotProps?.tooltip))]
|
|
41
41
|
}))
|
|
42
42
|
}));
|
|
43
43
|
});
|
|
44
|
+
if (process.env.NODE_ENV !== "production") RadarChart.displayName = "RadarChart";
|
|
44
45
|
process.env.NODE_ENV !== "production" ? RadarChart.propTypes = {
|
|
45
46
|
// ----------------------------- Warning --------------------------------
|
|
46
47
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -54,19 +54,11 @@ function Scatter(props) {
|
|
|
54
54
|
const scatterPoint = series.data[i];
|
|
55
55
|
const x = getXPosition(scatterPoint.x);
|
|
56
56
|
const y = getYPosition(scatterPoint.y);
|
|
57
|
-
const isInRange = instance.isPointInside(
|
|
58
|
-
x,
|
|
59
|
-
y
|
|
60
|
-
});
|
|
61
|
-
const pointCtx = {
|
|
62
|
-
type: 'scatter',
|
|
63
|
-
seriesId: series.id,
|
|
64
|
-
dataIndex: i
|
|
65
|
-
};
|
|
57
|
+
const isInRange = instance.isPointInside(x, y);
|
|
66
58
|
if (isInRange) {
|
|
67
59
|
const currentItem = {
|
|
68
|
-
seriesId:
|
|
69
|
-
dataIndex:
|
|
60
|
+
seriesId: series.id,
|
|
61
|
+
dataIndex: i
|
|
70
62
|
};
|
|
71
63
|
const isItemHighlighted = isHighlighted(currentItem);
|
|
72
64
|
temp.push({
|
|
@@ -54,13 +54,14 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(inProps
|
|
|
54
54
|
children: [/*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsx("g", {
|
|
55
55
|
"data-drawing-container": true,
|
|
56
56
|
children: /*#__PURE__*/_jsx(ScatterPlot, _extends({}, scatterPlotProps))
|
|
57
|
-
}), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps)),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}))]
|
|
57
|
+
}), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps)), children]
|
|
58
|
+
})), !props.loading && /*#__PURE__*/_jsx(Tooltip, _extends({
|
|
59
|
+
trigger: "item"
|
|
60
|
+
}, props.slotProps?.tooltip))]
|
|
61
61
|
}))
|
|
62
62
|
}));
|
|
63
63
|
});
|
|
64
|
+
if (process.env.NODE_ENV !== "production") ScatterChart.displayName = "ScatterChart";
|
|
64
65
|
process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
65
66
|
// ----------------------------- Warning --------------------------------
|
|
66
67
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -9,7 +9,8 @@ import useId from '@mui/utils/useId';
|
|
|
9
9
|
import { ChartsClipPath } from "../ChartsClipPath/index.js";
|
|
10
10
|
import { BarPlot } from "../BarChart/index.js";
|
|
11
11
|
import { LinePlot, AreaPlot, LineHighlightPlot } from "../LineChart/index.js";
|
|
12
|
-
import {
|
|
12
|
+
import { ChartDataProvider } from "../ChartDataProvider/index.js";
|
|
13
|
+
import { ChartsSurface } from "../ChartsSurface/index.js";
|
|
13
14
|
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from "../constants/index.js";
|
|
14
15
|
import { ChartsTooltip } from "../ChartsTooltip/index.js";
|
|
15
16
|
import { ChartsAxisHighlight } from "../ChartsAxisHighlight/index.js";
|
|
@@ -71,8 +72,7 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
|
|
|
71
72
|
}
|
|
72
73
|
return typeof color === 'function' ? mode => [color(mode)] : [color];
|
|
73
74
|
}, [color]);
|
|
74
|
-
return /*#__PURE__*/_jsxs(
|
|
75
|
-
ref: ref,
|
|
75
|
+
return /*#__PURE__*/_jsxs(ChartDataProvider, {
|
|
76
76
|
series: [_extends({
|
|
77
77
|
type: plotType,
|
|
78
78
|
data,
|
|
@@ -85,7 +85,6 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
|
|
|
85
85
|
width: width,
|
|
86
86
|
height: height,
|
|
87
87
|
margin: margin,
|
|
88
|
-
className: className,
|
|
89
88
|
xAxis: [_extends({
|
|
90
89
|
id: DEFAULT_X_AXIS_KEY,
|
|
91
90
|
scaleType: plotType === 'bar' ? 'band' : 'point',
|
|
@@ -102,34 +101,40 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
|
|
|
102
101
|
position: 'none'
|
|
103
102
|
})],
|
|
104
103
|
colors: colors,
|
|
105
|
-
sx: sx,
|
|
106
104
|
disableAxisListener: (!showTooltip || slotProps?.tooltip?.trigger !== 'axis') && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
|
|
107
|
-
children: [/*#__PURE__*/_jsxs(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
children: [/*#__PURE__*/_jsx(
|
|
115
|
-
skipAnimation: true,
|
|
116
|
-
slots: slots,
|
|
117
|
-
slotProps: slotProps
|
|
118
|
-
}), /*#__PURE__*/_jsx(LinePlot, {
|
|
105
|
+
children: [/*#__PURE__*/_jsxs(ChartsSurface, _extends({
|
|
106
|
+
className: className,
|
|
107
|
+
ref: ref,
|
|
108
|
+
sx: sx
|
|
109
|
+
}, other, {
|
|
110
|
+
children: [/*#__PURE__*/_jsxs("g", {
|
|
111
|
+
clipPath: `url(#${clipPathId})`,
|
|
112
|
+
children: [plotType === 'bar' && /*#__PURE__*/_jsx(BarPlot, {
|
|
119
113
|
skipAnimation: true,
|
|
120
114
|
slots: slots,
|
|
121
115
|
slotProps: slotProps
|
|
116
|
+
}), plotType === 'line' && /*#__PURE__*/_jsxs(React.Fragment, {
|
|
117
|
+
children: [/*#__PURE__*/_jsx(AreaPlot, {
|
|
118
|
+
skipAnimation: true,
|
|
119
|
+
slots: slots,
|
|
120
|
+
slotProps: slotProps
|
|
121
|
+
}), /*#__PURE__*/_jsx(LinePlot, {
|
|
122
|
+
skipAnimation: true,
|
|
123
|
+
slots: slots,
|
|
124
|
+
slotProps: slotProps
|
|
125
|
+
})]
|
|
122
126
|
})]
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
})
|
|
131
|
-
})
|
|
127
|
+
}), plotType === 'line' && /*#__PURE__*/_jsx(LineHighlightPlot, {
|
|
128
|
+
slots: slots,
|
|
129
|
+
slotProps: slotProps
|
|
130
|
+
}), disableClipping ? null : /*#__PURE__*/_jsx(ChartsClipPath, {
|
|
131
|
+
id: clipPathId,
|
|
132
|
+
offset: clipPathOffset
|
|
133
|
+
}), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), children]
|
|
134
|
+
})), showTooltip && /*#__PURE__*/_jsx(Tooltip, _extends({}, props.slotProps?.tooltip))]
|
|
135
|
+
});
|
|
132
136
|
});
|
|
137
|
+
if (process.env.NODE_ENV !== "production") SparkLineChart.displayName = "SparkLineChart";
|
|
133
138
|
process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
134
139
|
// ----------------------------- Warning --------------------------------
|
|
135
140
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -9,6 +9,7 @@ const ToolbarButton = /*#__PURE__*/React.forwardRef(function ToolbarButton(props
|
|
|
9
9
|
ref: ref
|
|
10
10
|
}, props));
|
|
11
11
|
});
|
|
12
|
+
if (process.env.NODE_ENV !== "production") ToolbarButton.displayName = "ToolbarButton";
|
|
12
13
|
process.env.NODE_ENV !== "production" ? ToolbarButton.propTypes = {
|
|
13
14
|
// ----------------------------- Warning --------------------------------
|
|
14
15
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -3,6 +3,4 @@ import * as React from 'react';
|
|
|
3
3
|
* @ignore - internal component.
|
|
4
4
|
*/
|
|
5
5
|
export const ChartContext = /*#__PURE__*/React.createContext(null);
|
|
6
|
-
if (process.env.NODE_ENV !==
|
|
7
|
-
ChartContext.displayName = 'ChartContext';
|
|
8
|
-
}
|
|
6
|
+
if (process.env.NODE_ENV !== "production") ChartContext.displayName = "ChartContext";
|
package/esm/hooks/useTicks.js
CHANGED
|
@@ -72,12 +72,8 @@ export function useTicks(options) {
|
|
|
72
72
|
for (let i = 0; i < ticks.length; i += 1) {
|
|
73
73
|
const value = ticks[i];
|
|
74
74
|
const offset = scale(value);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
y: offset
|
|
78
|
-
}, {
|
|
79
|
-
direction
|
|
80
|
-
})) {
|
|
75
|
+
const isInside = direction === 'x' ? instance.isXInside(offset) : instance.isYInside(offset);
|
|
76
|
+
if (isInside) {
|
|
81
77
|
visibleTicks.push({
|
|
82
78
|
value,
|
|
83
79
|
formattedValue: valueFormatter?.(value, {
|
package/esm/index.js
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;
|
|
@@ -60,6 +60,7 @@ export const consumeThemeProps = (name, options, InComponent) => /*#__PURE__*/Re
|
|
|
60
60
|
const theme = useTheme();
|
|
61
61
|
const classes = options.classesResolver?.(outProps, theme);
|
|
62
62
|
const OutComponent = /*#__PURE__*/React.forwardRef(InComponent);
|
|
63
|
+
if (process.env.NODE_ENV !== "production") OutComponent.displayName = "OutComponent";
|
|
63
64
|
if (process.env.NODE_ENV !== 'production') {
|
|
64
65
|
OutComponent.displayName = `consumeThemeProps(${name})`;
|
|
65
66
|
}
|
|
@@ -67,4 +68,5 @@ export const consumeThemeProps = (name, options, InComponent) => /*#__PURE__*/Re
|
|
|
67
68
|
classes: classes,
|
|
68
69
|
ref: ref
|
|
69
70
|
}));
|
|
70
|
-
});
|
|
71
|
+
});
|
|
72
|
+
if (process.env.NODE_ENV !== "production") consumeThemeProps.displayName = "consumeThemeProps";
|
|
@@ -4,6 +4,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
6
6
|
import ownerWindow from '@mui/utils/ownerWindow';
|
|
7
|
+
import { useSelector } from "../../../store/useSelector.js";
|
|
7
8
|
import { DEFAULT_MARGINS } from "../../../../constants/index.js";
|
|
8
9
|
import { selectorChartDrawingArea } from "./useChartDimensions.selectors.js";
|
|
9
10
|
import { defaultizeMargin } from "../../../defaultizeMargin.js";
|
|
@@ -143,28 +144,21 @@ export const useChartDimensions = ({
|
|
|
143
144
|
stateRef.current.displayError = false;
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
const drawingArea = useSelector(store, selectorChartDrawingArea);
|
|
148
|
+
const isXInside = React.useCallback(x => x >= drawingArea.left - 1 && x <= drawingArea.left + drawingArea.width, [drawingArea.left, drawingArea.width]);
|
|
149
|
+
const isYInside = React.useCallback(y => y >= drawingArea.top - 1 && y <= drawingArea.top + drawingArea.height, [drawingArea.height, drawingArea.top]);
|
|
150
|
+
const isPointInside = React.useCallback((x, y, targetElement) => {
|
|
150
151
|
// For element allowed to overflow, wrapping them in <g data-drawing-container /> make them fully part of the drawing area.
|
|
151
|
-
if (
|
|
152
|
+
if (targetElement && targetElement.closest('[data-drawing-container]')) {
|
|
152
153
|
return true;
|
|
153
154
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const isInsideY = y >= drawingArea.top - 1 && y <= drawingArea.top + drawingArea.height;
|
|
157
|
-
if (options?.direction === 'x') {
|
|
158
|
-
return isInsideX;
|
|
159
|
-
}
|
|
160
|
-
if (options?.direction === 'y') {
|
|
161
|
-
return isInsideY;
|
|
162
|
-
}
|
|
163
|
-
return isInsideX && isInsideY;
|
|
164
|
-
}, [store.value]);
|
|
155
|
+
return isXInside(x) && isYInside(y);
|
|
156
|
+
}, [isXInside, isYInside]);
|
|
165
157
|
return {
|
|
166
158
|
instance: {
|
|
167
|
-
isPointInside
|
|
159
|
+
isPointInside,
|
|
160
|
+
isXInside,
|
|
161
|
+
isYInside
|
|
168
162
|
}
|
|
169
163
|
};
|
|
170
164
|
};
|
|
@@ -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;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { ZOOM_SLIDER_SIZE } from "../../../constants.js";
|
|
3
2
|
import { defaultizeZoom } from "./defaultizeZoom.js";
|
|
4
3
|
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY, DEFAULT_AXIS_SIZE_HEIGHT, DEFAULT_AXIS_SIZE_WIDTH, AXIS_LABEL_DEFAULT_HEIGHT } from "../../../../constants/index.js";
|
|
5
4
|
export function defaultizeXAxis(inAxes, dataset) {
|
|
@@ -33,7 +32,7 @@ export function defaultizeXAxis(inAxes, dataset) {
|
|
|
33
32
|
if (position !== 'none') {
|
|
34
33
|
offsets[position] += sharedConfig.height;
|
|
35
34
|
if (sharedConfig.zoom?.slider.enabled) {
|
|
36
|
-
offsets[position] +=
|
|
35
|
+
offsets[position] += sharedConfig.zoom.slider.size;
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
|
|
@@ -83,7 +82,7 @@ export function defaultizeYAxis(inAxes, dataset) {
|
|
|
83
82
|
if (position !== 'none') {
|
|
84
83
|
offsets[position] += sharedConfig.width;
|
|
85
84
|
if (sharedConfig.zoom?.slider.enabled) {
|
|
86
|
-
offsets[position] +=
|
|
85
|
+
offsets[position] += sharedConfig.zoom.slider.size;
|
|
87
86
|
}
|
|
88
87
|
}
|
|
89
88
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { DEFAULT_ZOOM_SLIDER_SIZE } from "../../../constants.js";
|
|
2
3
|
const defaultZoomOptions = {
|
|
3
4
|
minStart: 0,
|
|
4
5
|
maxEnd: 100,
|
|
@@ -8,7 +9,8 @@ const defaultZoomOptions = {
|
|
|
8
9
|
panning: true,
|
|
9
10
|
filterMode: 'keep',
|
|
10
11
|
slider: {
|
|
11
|
-
enabled: false
|
|
12
|
+
enabled: false,
|
|
13
|
+
size: DEFAULT_ZOOM_SLIDER_SIZE
|
|
12
14
|
}
|
|
13
15
|
};
|
|
14
16
|
export const defaultizeZoom = (zoom, axisId, axisDirection) => {
|
package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { ZOOM_SLIDER_SIZE } from "../../../constants.js";
|
|
2
1
|
import { selectorChartRawXAxis, selectorChartRawYAxis } from "./useChartCartesianAxisLayout.selectors.js";
|
|
3
2
|
import { createSelector } from "../../utils/selectors.js";
|
|
4
|
-
export const selectorChartLeftAxisSize = createSelector([selectorChartRawYAxis], yAxis => (yAxis ?? []).reduce((acc, axis) => axis.position === 'left' ? acc + (axis.width || 0) + (axis.zoom?.slider.enabled ?
|
|
5
|
-
export const selectorChartRightAxisSize = createSelector([selectorChartRawYAxis], yAxis => (yAxis ?? []).reduce((acc, axis) => axis.position === 'right' ? acc + (axis.width || 0) + (axis.zoom?.slider.enabled ?
|
|
6
|
-
export const selectorChartTopAxisSize = createSelector([selectorChartRawXAxis], xAxis => (xAxis ?? []).reduce((acc, axis) => axis.position === 'top' ? acc + (axis.height || 0) + (axis.zoom?.slider.enabled ?
|
|
7
|
-
export const selectorChartBottomAxisSize = createSelector([selectorChartRawXAxis], xAxis => (xAxis ?? []).reduce((acc, axis) => axis.position === 'bottom' ? acc + (axis.height || 0) + (axis.zoom?.slider.enabled ?
|
|
3
|
+
export const selectorChartLeftAxisSize = createSelector([selectorChartRawYAxis], yAxis => (yAxis ?? []).reduce((acc, axis) => axis.position === 'left' ? acc + (axis.width || 0) + (axis.zoom?.slider.enabled ? axis.zoom.slider.size : 0) : acc, 0));
|
|
4
|
+
export const selectorChartRightAxisSize = createSelector([selectorChartRawYAxis], yAxis => (yAxis ?? []).reduce((acc, axis) => axis.position === 'right' ? acc + (axis.width || 0) + (axis.zoom?.slider.enabled ? axis.zoom.slider.size : 0) : acc, 0));
|
|
5
|
+
export const selectorChartTopAxisSize = createSelector([selectorChartRawXAxis], xAxis => (xAxis ?? []).reduce((acc, axis) => axis.position === 'top' ? acc + (axis.height || 0) + (axis.zoom?.slider.enabled ? axis.zoom.slider.size : 0) : acc, 0));
|
|
6
|
+
export const selectorChartBottomAxisSize = createSelector([selectorChartRawXAxis], xAxis => (xAxis ?? []).reduce((acc, axis) => axis.position === 'bottom' ? acc + (axis.height || 0) + (axis.zoom?.slider.enabled ? axis.zoom.slider.size : 0) : acc, 0));
|