@mui/x-charts 7.7.0 → 7.8.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 +21 -104
- package/BarChart/BarElement.d.ts +225 -228
- package/BarChart/BarLabel/BarLabel.d.ts +225 -228
- package/BarChart/BarLabel/BarLabelPlot.d.ts +0 -3
- package/BarChart/BarLabel/BarLabelPlot.js +1 -24
- package/BarChart/BarLabel/getBarLabel.d.ts +1 -1
- package/BarChart/BarPlot.js +2 -2
- package/BarChart/checkScaleErrors.d.ts +5 -9
- package/BarChart/types.d.ts +2 -2
- package/BarChart/useBarChartProps.d.ts +34 -0
- package/BarChart/useBarChartProps.js +143 -0
- package/CHANGELOG.md +181 -0
- package/ChartContainer/ChartContainer.d.ts +2 -2
- package/ChartContainer/ChartContainer.js +6 -10
- package/ChartContainer/useChartContainerHooks.d.ts +11 -0
- package/ChartContainer/useChartContainerHooks.js +34 -0
- package/ChartContainer/usePluginsMerge.d.ts +1 -2
- package/ChartsAxis/ChartsAxis.js +2 -2
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +21 -6
- package/ChartsGrid/ChartsGrid.js +2 -2
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
- package/ChartsReferenceLine/common.d.ts +0 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
- package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/ChartsTooltip/ChartsTooltipTable.d.ts +0 -1
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +4 -4
- package/ChartsXAxis/ChartsXAxis.js +2 -2
- package/ChartsYAxis/ChartsYAxis.js +5 -3
- package/Gauge/GaugeProvider.d.ts +1 -1
- package/LineChart/AnimatedArea.d.ts +225 -228
- package/LineChart/AnimatedLine.d.ts +225 -228
- package/LineChart/AreaPlot.js +2 -2
- package/LineChart/LineChart.js +24 -106
- package/LineChart/LineHighlightPlot.js +2 -2
- package/LineChart/LinePlot.js +2 -2
- package/LineChart/MarkPlot.js +2 -2
- package/LineChart/useLineChartProps.d.ts +40 -0
- package/LineChart/useLineChartProps.js +152 -0
- package/PieChart/PieArc.d.ts +0 -1
- package/PieChart/PieArcLabel.d.ts +0 -1
- package/PieChart/dataTransform/transition.d.ts +0 -1
- package/ResponsiveChartContainer/ResizableContainer.d.ts +1 -2
- package/ScatterChart/ScatterChart.js +20 -75
- package/ScatterChart/ScatterPlot.js +2 -2
- package/ScatterChart/useScatterChartProps.d.ts +31 -0
- package/ScatterChart/useScatterChartProps.js +116 -0
- package/context/CartesianProvider/CartesianContext.d.ts +25 -0
- package/context/CartesianProvider/CartesianContext.js +21 -0
- package/context/CartesianProvider/CartesianProvider.d.ts +34 -0
- package/context/CartesianProvider/CartesianProvider.js +44 -0
- package/context/CartesianProvider/computeValue.d.ts +19 -0
- package/context/CartesianProvider/computeValue.js +104 -0
- package/context/CartesianProvider/getAxisExtremum.d.ts +4 -0
- package/context/CartesianProvider/getAxisExtremum.js +28 -0
- package/context/CartesianProvider/index.d.ts +9 -0
- package/context/CartesianProvider/index.js +51 -0
- package/context/CartesianProvider/normalizeAxis.d.ts +5 -0
- package/context/CartesianProvider/normalizeAxis.js +23 -0
- package/context/CartesianProvider/useCartesianContext.d.ts +2 -0
- package/context/CartesianProvider/useCartesianContext.js +17 -0
- package/context/ColorProvider.d.ts +2 -2
- package/esm/BarChart/BarChart.js +21 -104
- package/esm/BarChart/BarLabel/BarLabelPlot.js +0 -23
- package/esm/BarChart/BarPlot.js +2 -2
- package/esm/BarChart/useBarChartProps.js +135 -0
- package/esm/ChartContainer/ChartContainer.js +5 -9
- package/esm/ChartContainer/useChartContainerHooks.js +24 -0
- package/esm/ChartsAxis/ChartsAxis.js +2 -2
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +21 -6
- package/esm/ChartsGrid/ChartsGrid.js +2 -2
- package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -3
- package/esm/ChartsXAxis/ChartsXAxis.js +2 -2
- package/esm/ChartsYAxis/ChartsYAxis.js +5 -3
- package/esm/LineChart/AreaPlot.js +2 -2
- package/esm/LineChart/LineChart.js +24 -106
- package/esm/LineChart/LineHighlightPlot.js +2 -2
- package/esm/LineChart/LinePlot.js +2 -2
- package/esm/LineChart/MarkPlot.js +2 -2
- package/esm/LineChart/useLineChartProps.js +144 -0
- package/esm/ScatterChart/ScatterChart.js +20 -75
- package/esm/ScatterChart/ScatterPlot.js +2 -2
- package/esm/ScatterChart/useScatterChartProps.js +108 -0
- package/esm/context/CartesianProvider/CartesianContext.js +13 -0
- package/esm/context/CartesianProvider/CartesianProvider.js +37 -0
- package/esm/context/CartesianProvider/computeValue.js +97 -0
- package/esm/context/CartesianProvider/getAxisExtremum.js +21 -0
- package/esm/context/CartesianProvider/index.js +10 -0
- package/esm/context/CartesianProvider/normalizeAxis.js +15 -0
- package/esm/context/CartesianProvider/useCartesianContext.js +8 -0
- package/esm/hooks/useAxisEvents.js +7 -10
- package/esm/hooks/useColorScale.js +3 -3
- package/esm/hooks/useScale.js +4 -5
- package/esm/hooks/useTicks.js +2 -1
- package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
- package/esm/internals/getSVGPoint.js +11 -0
- package/esm/internals/index.js +8 -2
- package/esm/internals/utils.js +0 -12
- package/hooks/useAxisEvents.js +8 -11
- package/hooks/useChartDimensions.d.ts +1 -1
- package/hooks/useColor.d.ts +1 -1
- package/hooks/useColorScale.js +3 -3
- package/hooks/useDrawingArea.d.ts +2 -8
- package/hooks/useScale.js +4 -7
- package/hooks/useTicks.js +2 -1
- package/index.js +1 -1
- package/internals/components/AxisSharedComponents.d.ts +0 -1
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +2 -1
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
- package/internals/defaultizeColor.d.ts +68 -68
- package/internals/getSVGPoint.d.ts +6 -0
- package/internals/getSVGPoint.js +17 -0
- package/internals/getWordsByLines.d.ts +0 -1
- package/internals/index.d.ts +9 -1
- package/internals/index.js +69 -5
- package/internals/useAnimatedPath.d.ts +0 -1
- package/internals/utils.d.ts +0 -6
- package/internals/utils.js +0 -13
- package/models/axis.d.ts +1 -2
- package/models/plugin.d.ts +4 -1
- package/modern/BarChart/BarChart.js +21 -104
- package/modern/BarChart/BarLabel/BarLabelPlot.js +0 -23
- package/modern/BarChart/BarPlot.js +2 -2
- package/modern/BarChart/useBarChartProps.js +135 -0
- package/modern/ChartContainer/ChartContainer.js +5 -9
- package/modern/ChartContainer/useChartContainerHooks.js +24 -0
- package/modern/ChartsAxis/ChartsAxis.js +2 -2
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +21 -6
- package/modern/ChartsGrid/ChartsGrid.js +2 -2
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -3
- package/modern/ChartsXAxis/ChartsXAxis.js +2 -2
- package/modern/ChartsYAxis/ChartsYAxis.js +5 -3
- package/modern/LineChart/AreaPlot.js +2 -2
- package/modern/LineChart/LineChart.js +24 -106
- package/modern/LineChart/LineHighlightPlot.js +2 -2
- package/modern/LineChart/LinePlot.js +2 -2
- package/modern/LineChart/MarkPlot.js +2 -2
- package/modern/LineChart/useLineChartProps.js +144 -0
- package/modern/ScatterChart/ScatterChart.js +20 -75
- package/modern/ScatterChart/ScatterPlot.js +2 -2
- package/modern/ScatterChart/useScatterChartProps.js +108 -0
- package/modern/context/CartesianProvider/CartesianContext.js +13 -0
- package/modern/context/CartesianProvider/CartesianProvider.js +37 -0
- package/modern/context/CartesianProvider/computeValue.js +97 -0
- package/modern/context/CartesianProvider/getAxisExtremum.js +21 -0
- package/modern/context/CartesianProvider/index.js +10 -0
- package/modern/context/CartesianProvider/normalizeAxis.js +15 -0
- package/modern/context/CartesianProvider/useCartesianContext.js +8 -0
- package/modern/hooks/useAxisEvents.js +7 -10
- package/modern/hooks/useColorScale.js +3 -3
- package/modern/hooks/useScale.js +4 -5
- package/modern/hooks/useTicks.js +2 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
- package/modern/internals/getSVGPoint.js +11 -0
- package/modern/internals/index.js +8 -2
- package/modern/internals/utils.js +0 -12
- package/package.json +3 -3
- package/context/CartesianContextProvider.d.ts +0 -61
- package/context/CartesianContextProvider.js +0 -220
- package/esm/context/CartesianContextProvider.js +0 -211
- package/modern/context/CartesianContextProvider.js +0 -211
|
@@ -8,7 +8,6 @@ exports.BarLabelPlot = BarLabelPlot;
|
|
|
8
8
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
11
|
var _web = require("@react-spring/web");
|
|
13
12
|
var _BarLabelItem = require("./BarLabelItem");
|
|
14
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -81,26 +80,4 @@ function BarLabelPlot(props) {
|
|
|
81
80
|
style: style
|
|
82
81
|
})))
|
|
83
82
|
});
|
|
84
|
-
}
|
|
85
|
-
process.env.NODE_ENV !== "production" ? BarLabelPlot.propTypes = {
|
|
86
|
-
// ----------------------------- Warning --------------------------------
|
|
87
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
88
|
-
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
89
|
-
// ----------------------------------------------------------------------
|
|
90
|
-
barLabel: _propTypes.default.oneOfType([_propTypes.default.oneOf(['value']), _propTypes.default.func]),
|
|
91
|
-
bars: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
92
|
-
color: _propTypes.default.string.isRequired,
|
|
93
|
-
dataIndex: _propTypes.default.number.isRequired,
|
|
94
|
-
height: _propTypes.default.number.isRequired,
|
|
95
|
-
layout: _propTypes.default.oneOf(['horizontal', 'vertical']),
|
|
96
|
-
maskId: _propTypes.default.string.isRequired,
|
|
97
|
-
seriesId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
98
|
-
value: _propTypes.default.number,
|
|
99
|
-
width: _propTypes.default.number.isRequired,
|
|
100
|
-
x: _propTypes.default.number.isRequired,
|
|
101
|
-
xOrigin: _propTypes.default.number.isRequired,
|
|
102
|
-
y: _propTypes.default.number.isRequired,
|
|
103
|
-
yOrigin: _propTypes.default.number.isRequired
|
|
104
|
-
})).isRequired,
|
|
105
|
-
skipAnimation: _propTypes.default.bool
|
|
106
|
-
} : void 0;
|
|
83
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SeriesId } from '../../models/seriesType/common';
|
|
2
2
|
import { BarLabelFunction } from './BarLabel.types';
|
|
3
3
|
export declare const getBarLabel: (options: {
|
|
4
|
-
barLabel:
|
|
4
|
+
barLabel: "value" | BarLabelFunction;
|
|
5
5
|
value: number | null;
|
|
6
6
|
dataIndex: number;
|
|
7
7
|
seriesId: SeriesId;
|
package/BarChart/BarPlot.js
CHANGED
|
@@ -10,7 +10,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
12
|
var _web = require("@react-spring/web");
|
|
13
|
-
var
|
|
13
|
+
var _CartesianProvider = require("../context/CartesianProvider");
|
|
14
14
|
var _BarElement = require("./BarElement");
|
|
15
15
|
var _getColor = _interopRequireDefault(require("./getColor"));
|
|
16
16
|
var _hooks = require("../hooks");
|
|
@@ -55,7 +55,7 @@ const useAggregatedData = () => {
|
|
|
55
55
|
stackingGroups: [],
|
|
56
56
|
seriesOrder: []
|
|
57
57
|
};
|
|
58
|
-
const axisData =
|
|
58
|
+
const axisData = (0, _CartesianProvider.useCartesianContext)();
|
|
59
59
|
const chartId = (0, _hooks.useChartId)();
|
|
60
60
|
const {
|
|
61
61
|
series,
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { AxisDefaultized } from '../models/axis';
|
|
1
|
+
import { AxisDefaultized, AxisId } from '../models/axis';
|
|
2
2
|
import { SeriesId } from '../models/seriesType/common';
|
|
3
|
-
export declare function checkScaleErrors(verticalLayout: boolean, seriesId: SeriesId, xAxisKey:
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
[axisKey:
|
|
7
|
-
}, yAxisKey: string, yAxis: {
|
|
8
|
-
DEFAULT_X_AXIS_KEY: AxisDefaultized;
|
|
9
|
-
} & {
|
|
10
|
-
[axisKey: string]: AxisDefaultized;
|
|
3
|
+
export declare function checkScaleErrors(verticalLayout: boolean, seriesId: SeriesId, xAxisKey: AxisId, xAxis: {
|
|
4
|
+
[axisKey: AxisId]: AxisDefaultized;
|
|
5
|
+
}, yAxisKey: AxisId, yAxis: {
|
|
6
|
+
[axisKey: AxisId]: AxisDefaultized;
|
|
11
7
|
}): void;
|
package/BarChart/types.d.ts
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { BarChartProps } from './BarChart';
|
|
2
|
+
import { ResponsiveChartContainerProps } from '../ResponsiveChartContainer';
|
|
3
|
+
import { BarPlotProps } from './BarPlot';
|
|
4
|
+
import { ChartsOnAxisClickHandlerProps } from '../ChartsOnAxisClickHandler';
|
|
5
|
+
import { ChartsGridProps } from '../ChartsGrid';
|
|
6
|
+
import { ChartsClipPathProps } from '../ChartsClipPath';
|
|
7
|
+
import { ChartsOverlayProps } from '../ChartsOverlay';
|
|
8
|
+
import { ChartsAxisProps } from '../ChartsAxis';
|
|
9
|
+
import { ChartsAxisHighlightProps } from '../ChartsAxisHighlight';
|
|
10
|
+
import { ChartsLegendProps } from '../ChartsLegend';
|
|
11
|
+
import { ChartsTooltipProps } from '../ChartsTooltip';
|
|
12
|
+
/**
|
|
13
|
+
* A helper function that extracts BarChartProps from the input props
|
|
14
|
+
* and returns an object with props for the children components of BarChart.
|
|
15
|
+
*
|
|
16
|
+
* @param props The input props for BarChart
|
|
17
|
+
* @returns An object with props for the children components of BarChart
|
|
18
|
+
*/
|
|
19
|
+
export declare const useBarChartProps: (props: BarChartProps) => {
|
|
20
|
+
chartContainerProps: ResponsiveChartContainerProps;
|
|
21
|
+
barPlotProps: BarPlotProps;
|
|
22
|
+
axisClickHandlerProps: ChartsOnAxisClickHandlerProps;
|
|
23
|
+
gridProps: ChartsGridProps;
|
|
24
|
+
clipPathProps: ChartsClipPathProps;
|
|
25
|
+
clipPathGroupProps: {
|
|
26
|
+
clipPath: string;
|
|
27
|
+
};
|
|
28
|
+
overlayProps: ChartsOverlayProps;
|
|
29
|
+
chartsAxisProps: ChartsAxisProps;
|
|
30
|
+
axisHighlightProps: ChartsAxisHighlightProps;
|
|
31
|
+
legendProps: ChartsLegendProps;
|
|
32
|
+
tooltipProps: ChartsTooltipProps;
|
|
33
|
+
children: import("react").ReactNode;
|
|
34
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useBarChartProps = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _useId = _interopRequireDefault(require("@mui/utils/useId"));
|
|
10
|
+
var _constants = require("../constants");
|
|
11
|
+
/**
|
|
12
|
+
* A helper function that extracts BarChartProps from the input props
|
|
13
|
+
* and returns an object with props for the children components of BarChart.
|
|
14
|
+
*
|
|
15
|
+
* @param props The input props for BarChart
|
|
16
|
+
* @returns An object with props for the children components of BarChart
|
|
17
|
+
*/
|
|
18
|
+
const useBarChartProps = props => {
|
|
19
|
+
const {
|
|
20
|
+
xAxis,
|
|
21
|
+
yAxis,
|
|
22
|
+
series,
|
|
23
|
+
width,
|
|
24
|
+
height,
|
|
25
|
+
margin,
|
|
26
|
+
colors,
|
|
27
|
+
dataset,
|
|
28
|
+
sx,
|
|
29
|
+
tooltip,
|
|
30
|
+
onAxisClick,
|
|
31
|
+
axisHighlight,
|
|
32
|
+
legend,
|
|
33
|
+
grid,
|
|
34
|
+
topAxis,
|
|
35
|
+
leftAxis,
|
|
36
|
+
rightAxis,
|
|
37
|
+
bottomAxis,
|
|
38
|
+
children,
|
|
39
|
+
slots,
|
|
40
|
+
slotProps,
|
|
41
|
+
skipAnimation,
|
|
42
|
+
loading,
|
|
43
|
+
layout,
|
|
44
|
+
onItemClick,
|
|
45
|
+
highlightedItem,
|
|
46
|
+
onHighlightChange,
|
|
47
|
+
borderRadius,
|
|
48
|
+
barLabel
|
|
49
|
+
} = props;
|
|
50
|
+
const id = (0, _useId.default)();
|
|
51
|
+
const clipPathId = `${id}-clip-path`;
|
|
52
|
+
const hasHorizontalSeries = layout === 'horizontal' || layout === undefined && series.some(item => item.layout === 'horizontal');
|
|
53
|
+
const defaultAxisConfig = {
|
|
54
|
+
scaleType: 'band',
|
|
55
|
+
data: Array.from({
|
|
56
|
+
length: Math.max(...series.map(s => (s.data ?? dataset ?? []).length))
|
|
57
|
+
}, (_, index) => index)
|
|
58
|
+
};
|
|
59
|
+
const chartContainerProps = {
|
|
60
|
+
series: series.map(s => (0, _extends2.default)({
|
|
61
|
+
type: 'bar'
|
|
62
|
+
}, s, {
|
|
63
|
+
layout: hasHorizontalSeries ? 'horizontal' : 'vertical'
|
|
64
|
+
})),
|
|
65
|
+
width,
|
|
66
|
+
height,
|
|
67
|
+
margin,
|
|
68
|
+
colors,
|
|
69
|
+
dataset,
|
|
70
|
+
xAxis: xAxis ?? (hasHorizontalSeries ? undefined : [(0, _extends2.default)({
|
|
71
|
+
id: _constants.DEFAULT_X_AXIS_KEY
|
|
72
|
+
}, defaultAxisConfig)]),
|
|
73
|
+
yAxis: yAxis ?? (hasHorizontalSeries ? [(0, _extends2.default)({
|
|
74
|
+
id: _constants.DEFAULT_Y_AXIS_KEY
|
|
75
|
+
}, defaultAxisConfig)] : undefined),
|
|
76
|
+
sx,
|
|
77
|
+
highlightedItem,
|
|
78
|
+
onHighlightChange,
|
|
79
|
+
disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick
|
|
80
|
+
};
|
|
81
|
+
const barPlotProps = {
|
|
82
|
+
onItemClick,
|
|
83
|
+
slots,
|
|
84
|
+
slotProps,
|
|
85
|
+
skipAnimation,
|
|
86
|
+
borderRadius,
|
|
87
|
+
barLabel
|
|
88
|
+
};
|
|
89
|
+
const axisClickHandlerProps = {
|
|
90
|
+
onAxisClick
|
|
91
|
+
};
|
|
92
|
+
const gridProps = {
|
|
93
|
+
vertical: grid?.vertical,
|
|
94
|
+
horizontal: grid?.horizontal
|
|
95
|
+
};
|
|
96
|
+
const clipPathGroupProps = {
|
|
97
|
+
clipPath: `url(#${clipPathId})`
|
|
98
|
+
};
|
|
99
|
+
const clipPathProps = {
|
|
100
|
+
id: clipPathId
|
|
101
|
+
};
|
|
102
|
+
const overlayProps = {
|
|
103
|
+
slots,
|
|
104
|
+
slotProps,
|
|
105
|
+
loading
|
|
106
|
+
};
|
|
107
|
+
const chartsAxisProps = {
|
|
108
|
+
topAxis,
|
|
109
|
+
leftAxis,
|
|
110
|
+
rightAxis,
|
|
111
|
+
bottomAxis,
|
|
112
|
+
slots,
|
|
113
|
+
slotProps
|
|
114
|
+
};
|
|
115
|
+
const axisHighlightProps = (0, _extends2.default)({}, hasHorizontalSeries ? {
|
|
116
|
+
y: 'band'
|
|
117
|
+
} : {
|
|
118
|
+
x: 'band'
|
|
119
|
+
}, axisHighlight);
|
|
120
|
+
const legendProps = (0, _extends2.default)({}, legend, {
|
|
121
|
+
slots,
|
|
122
|
+
slotProps
|
|
123
|
+
});
|
|
124
|
+
const tooltipProps = (0, _extends2.default)({}, tooltip, {
|
|
125
|
+
slots,
|
|
126
|
+
slotProps
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
chartContainerProps,
|
|
130
|
+
barPlotProps,
|
|
131
|
+
axisClickHandlerProps,
|
|
132
|
+
gridProps,
|
|
133
|
+
clipPathProps,
|
|
134
|
+
clipPathGroupProps,
|
|
135
|
+
overlayProps,
|
|
136
|
+
chartsAxisProps,
|
|
137
|
+
axisHighlightProps,
|
|
138
|
+
legendProps,
|
|
139
|
+
tooltipProps,
|
|
140
|
+
children
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
exports.useBarChartProps = useBarChartProps;
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,187 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 7.8.0
|
|
7
|
+
|
|
8
|
+
_Jun 28, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🛰 Introduce server-side data source for improved server integration in the Data Grid.
|
|
13
|
+
|
|
14
|
+
Supports server-side pagination, sorting and filtering on plain and tree data, and automatic caching.
|
|
15
|
+
|
|
16
|
+
To enable, provide a `getRows` function to the `unstable_dataSource` prop on the Data Grid component.
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
const dataSource = {
|
|
20
|
+
getRows: async (params: GridServerGetRowsParams) => {
|
|
21
|
+
const data = await fetch(
|
|
22
|
+
`https://api.example.com/data?${new URLSearchParams({
|
|
23
|
+
page: params.page,
|
|
24
|
+
pageSize: params.pageSize,
|
|
25
|
+
sortModel: JSON.stringify(params.sortModel),
|
|
26
|
+
filterModel: JSON.stringify(params.filterModel),
|
|
27
|
+
}).toString()}`,
|
|
28
|
+
);
|
|
29
|
+
return {
|
|
30
|
+
rows: data.rows,
|
|
31
|
+
totalRows: data.totalRows,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
<DataGridPro
|
|
36
|
+
unstable_dataSource={dataSource}
|
|
37
|
+
{...otherProps}
|
|
38
|
+
/>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
See [server-side data documentation](https://mui.com/x/react-data-grid/server-side-data/) for more details.
|
|
42
|
+
|
|
43
|
+
- 📈 Support Date data on the BarChart component
|
|
44
|
+
- ↕️ Support custom column sort icons on the Data Grid
|
|
45
|
+
- 🖱️ Support modifying the expansion trigger on the Tree View components
|
|
46
|
+
|
|
47
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
48
|
+
|
|
49
|
+
### Data Grid
|
|
50
|
+
|
|
51
|
+
#### `@mui/x-data-grid@7.8.0`
|
|
52
|
+
|
|
53
|
+
- [DataGrid] Add `columnHeaderSortIcon` slot (#13563) @arminmeh
|
|
54
|
+
- [DataGrid] Fix dimensions lag issue after autosize (#13587) @MBilalShafi
|
|
55
|
+
- [DataGrid] Fix print export failure when `hideFooter` option is set (#13034) @tarunrajput
|
|
56
|
+
|
|
57
|
+
#### `@mui/x-data-grid-pro@7.8.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
58
|
+
|
|
59
|
+
Same changes as in `@mui/x-data-grid@7.8.0`, plus:
|
|
60
|
+
|
|
61
|
+
- [DataGridPro] Fix multi-sorting indicator being cut off (#13625) @KenanYusuf
|
|
62
|
+
- [DataGridPro] Server-side tree data support (#12317) @MBilalShafi
|
|
63
|
+
|
|
64
|
+
#### `@mui/x-data-grid-premium@7.8.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
65
|
+
|
|
66
|
+
Same changes as in `@mui/x-data-grid-pro@7.8.0`.
|
|
67
|
+
|
|
68
|
+
### Date and Time Pickers
|
|
69
|
+
|
|
70
|
+
#### `@mui/x-date-pickers@7.8.0`
|
|
71
|
+
|
|
72
|
+
- [fields] Fix section clearing behavior on Android (#13652) @LukasTy
|
|
73
|
+
|
|
74
|
+
#### `@mui/x-date-pickers-pro@7.8.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
75
|
+
|
|
76
|
+
Same changes as in `@mui/x-date-pickers@7.8.0`.
|
|
77
|
+
|
|
78
|
+
### Charts
|
|
79
|
+
|
|
80
|
+
#### `@mui/x-charts@7.8.0`
|
|
81
|
+
|
|
82
|
+
- [charts] Fix line chart props not passing correct event handlers (#13609) @JCQuintas
|
|
83
|
+
- [charts] Support BarChart with `Date` data (#13471) @alexfauquette
|
|
84
|
+
- [charts] Support RTL for y-axis (#13614) @alexfauquette
|
|
85
|
+
- [charts] Use default values instead of non-null assertion to prevent error being thrown (#13637) @JCQuintas
|
|
86
|
+
|
|
87
|
+
### Tree View
|
|
88
|
+
|
|
89
|
+
#### `@mui/x-tree-view@7.8.0`
|
|
90
|
+
|
|
91
|
+
- [TreeView] Add `expansionTrigger` prop (#13533) @noraleonte
|
|
92
|
+
- [TreeView] Support experimental features from plugin's dependencies (#13632) @flaviendelangle
|
|
93
|
+
|
|
94
|
+
### Docs
|
|
95
|
+
|
|
96
|
+
- [docs] Add callout for `Luxon` `throwOnInvalid` support (#13621) @LukasTy
|
|
97
|
+
- [docs] Add "Overlays" section to the Data Grid documentation (#13624) @KenanYusuf
|
|
98
|
+
|
|
99
|
+
### Core
|
|
100
|
+
|
|
101
|
+
- [core] Add eslint rule to restrict import from `../internals` root (#13633) @JCQuintas
|
|
102
|
+
- [docs-infra] Sync `\_app` folder with monorepo (#13582) @Janpot
|
|
103
|
+
- [license] Allow usage of charts and tree view pro package for old premium licenses (#13619) @flaviendelangle
|
|
104
|
+
|
|
105
|
+
## 7.7.1
|
|
106
|
+
|
|
107
|
+
_Jun 21, 2024_
|
|
108
|
+
|
|
109
|
+
We'd like to offer a big thanks to the 14 contributors who made this release possible. Here are some highlights ✨:
|
|
110
|
+
|
|
111
|
+
- 🌍 Improve Portuguese (pt-PT) locale on the Data Grid
|
|
112
|
+
- 🌍 Improve Danish (da-DK) locale on the Date and Time Pickers
|
|
113
|
+
- 🐞 Bugfixes
|
|
114
|
+
- 📚 Documentation improvements
|
|
115
|
+
|
|
116
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
117
|
+
|
|
118
|
+
### Data Grid
|
|
119
|
+
|
|
120
|
+
#### `@mui/x-data-grid@7.7.1`
|
|
121
|
+
|
|
122
|
+
- [DataGrid][docs] Clarify enabling pagination (#13350) @oliviertassinari
|
|
123
|
+
- [DataGrid] Fix CSV export escaping for non-string values (#13560) @joeycumines-scw
|
|
124
|
+
- [l10n] Improve Portuguese (pt-PT) locale (#13348) @joaosreis
|
|
125
|
+
|
|
126
|
+
#### `@mui/x-data-grid-pro@7.7.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
127
|
+
|
|
128
|
+
Same changes as in `@mui/x-data-grid@7.7.1`, plus:
|
|
129
|
+
|
|
130
|
+
- [DataGrid] Warn about `getTreeDataPath` reference (#13519) @cherniavskii
|
|
131
|
+
|
|
132
|
+
#### `@mui/x-data-grid-premium@7.7.1` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
133
|
+
|
|
134
|
+
Same changes as in `@mui/x-data-grid-pro@7.7.1`.
|
|
135
|
+
|
|
136
|
+
### Date and Time Pickers
|
|
137
|
+
|
|
138
|
+
#### `@mui/x-date-pickers@7.7.1`
|
|
139
|
+
|
|
140
|
+
- [fields] Prevent digit editing on the `Space` key down (#13510) @flaviendelangle
|
|
141
|
+
- [l10n] Improve Danish (da-DK) locale (#13375) @jacrowland1
|
|
142
|
+
- [pickers] Add context to `onAccept` callback (#13511) @flaviendelangle
|
|
143
|
+
- [pickers] Always use the same timezone in the field, the view and the layout components (#13481) @flaviendelangle
|
|
144
|
+
- [pickers] Fix `AdapterDateFnsV3` generated method types (#13464) @alexey-kozlenkov
|
|
145
|
+
- [pickers] Fix controlled `view` behavior (#13552) @LukasTy
|
|
146
|
+
- [TimePicker] Improves RTL verification for the time pickers default views (#13447) @arthurbalduini
|
|
147
|
+
|
|
148
|
+
#### `@mui/x-date-pickers-pro@7.7.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
149
|
+
|
|
150
|
+
Same changes as in `@mui/x-date-pickers@7.7.1`, plus:
|
|
151
|
+
|
|
152
|
+
- [DateRangePicker] Add accessible name to calendar grid (#13538) @LukasTy
|
|
153
|
+
|
|
154
|
+
### Charts
|
|
155
|
+
|
|
156
|
+
#### `@mui/x-charts@7.7.1`
|
|
157
|
+
|
|
158
|
+
- [charts] Divide `CartesianProvider` to use logic in Pro package (#13531) @JCQuintas
|
|
159
|
+
- [charts] Do not publish the pro package (#13539) @alexfauquette
|
|
160
|
+
- [charts] Export `Pro` versions of regular charts (#13547) @JCQuintas
|
|
161
|
+
- [charts] Prepare `ChartContainerPro` for future Zoom changes (#13532) @JCQuintas
|
|
162
|
+
- [charts] Remove unnecessary proptypes from internal component (#13518) @JCQuintas
|
|
163
|
+
|
|
164
|
+
### Tree View
|
|
165
|
+
|
|
166
|
+
#### `@mui/x-tree-view@7.7.1`
|
|
167
|
+
|
|
168
|
+
- [TreeView] Improve typing to support optional dependencies in plugins and in the item (#13523) @flaviendelangle
|
|
169
|
+
- [TreeView] Move `useTreeViewId` to the core plugins (#13566) @flaviendelangle
|
|
170
|
+
- [TreeView] Remove unused state from `useTreeViewId` (#13579) @flaviendelangle
|
|
171
|
+
- [TreeView] Support `itemId` with escaping characters when using `SimpleTreeView` (#13487) @oukunan
|
|
172
|
+
|
|
173
|
+
### Docs
|
|
174
|
+
|
|
175
|
+
- [docs] Add section about the new uncovered product watermark (#13568) @michelengelen
|
|
176
|
+
- [docs] Document the `PickerValidDate` type override (#13476) @flaviendelangle
|
|
177
|
+
- [docs] Fix typo (#13507) @anshtiwatne
|
|
178
|
+
- [docs] Remove "-" in heat-map and tree-map urls (#13569) @alexfauquette
|
|
179
|
+
- [docs] Use dedicated tab for weather dataset (#13513) @alexfauquette
|
|
180
|
+
- [x-license] license update proposal (#13459) @michelengelen
|
|
181
|
+
|
|
182
|
+
### Core
|
|
183
|
+
|
|
184
|
+
- [core] Fix failing CI test (#13574) @alexfauquette
|
|
185
|
+
- [infra] Remove explicit `@testing-library/react` dependency (#13478) @LukasTy
|
|
186
|
+
|
|
6
187
|
## 7.7.0
|
|
7
188
|
|
|
8
189
|
_Jun 13, 2024_
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { DrawingProviderProps } from '../context/DrawingProvider';
|
|
3
3
|
import { SeriesContextProviderProps } from '../context/SeriesContextProvider';
|
|
4
4
|
import { ChartsSurfaceProps } from '../ChartsSurface';
|
|
5
|
-
import { CartesianContextProviderProps } from '../context/
|
|
5
|
+
import { CartesianContextProviderProps } from '../context/CartesianProvider';
|
|
6
6
|
import { HighlightedProviderProps, ZAxisContextProviderProps } from '../context';
|
|
7
7
|
import { ChartsPluginType } from '../models/plugin';
|
|
8
8
|
import { ChartSeriesType } from '../models/seriesType/config';
|
|
@@ -20,6 +20,6 @@ declare const ChartContainer: React.ForwardRefExoticComponent<Omit<ChartsSurface
|
|
|
20
20
|
* An array of plugins defining how to preprocess data.
|
|
21
21
|
* If not provided, the container supports line, bar, scatter and pie charts.
|
|
22
22
|
*/
|
|
23
|
-
plugins?: ChartsPluginType<
|
|
23
|
+
plugins?: ChartsPluginType<ChartSeriesType>[];
|
|
24
24
|
} & React.RefAttributes<unknown>>;
|
|
25
25
|
export { ChartContainer };
|
|
@@ -7,17 +7,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.ChartContainer = void 0;
|
|
8
8
|
var React = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
-
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
|
11
10
|
var _DrawingProvider = require("../context/DrawingProvider");
|
|
12
11
|
var _SeriesContextProvider = require("../context/SeriesContextProvider");
|
|
13
12
|
var _InteractionProvider = require("../context/InteractionProvider");
|
|
14
13
|
var _ColorProvider = require("../context/ColorProvider");
|
|
15
|
-
var _useReducedMotion = require("../hooks/useReducedMotion");
|
|
16
14
|
var _ChartsSurface = require("../ChartsSurface");
|
|
17
|
-
var
|
|
15
|
+
var _CartesianProvider = require("../context/CartesianProvider");
|
|
18
16
|
var _ChartsAxesGradients = require("../internals/components/ChartsAxesGradients");
|
|
19
17
|
var _context = require("../context");
|
|
20
|
-
var
|
|
18
|
+
var _useChartContainerHooks = require("./useChartContainerHooks");
|
|
21
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
20
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
23
21
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -41,16 +39,14 @@ const ChartContainer = exports.ChartContainer = /*#__PURE__*/React.forwardRef(fu
|
|
|
41
39
|
plugins,
|
|
42
40
|
children
|
|
43
41
|
} = props;
|
|
44
|
-
const svgRef = React.useRef(null);
|
|
45
|
-
const handleRef = (0, _useForkRef.default)(ref, svgRef);
|
|
46
42
|
const {
|
|
43
|
+
svgRef,
|
|
44
|
+
handleRef,
|
|
47
45
|
xExtremumGetters,
|
|
48
46
|
yExtremumGetters,
|
|
49
47
|
seriesFormatters,
|
|
50
48
|
colorProcessors
|
|
51
|
-
} = (0,
|
|
52
|
-
(0, _useReducedMotion.useReducedMotion)(); // a11y reduce motion (see: https://react-spring.dev/docs/utilities/use-reduced-motion)
|
|
53
|
-
|
|
49
|
+
} = (0, _useChartContainerHooks.useChartContainerHooks)(ref, plugins);
|
|
54
50
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DrawingProvider.DrawingProvider, {
|
|
55
51
|
width: width,
|
|
56
52
|
height: height,
|
|
@@ -63,7 +59,7 @@ const ChartContainer = exports.ChartContainer = /*#__PURE__*/React.forwardRef(fu
|
|
|
63
59
|
colors: colors,
|
|
64
60
|
dataset: dataset,
|
|
65
61
|
seriesFormatters: seriesFormatters,
|
|
66
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
62
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CartesianProvider.CartesianContextProvider, {
|
|
67
63
|
xAxis: xAxis,
|
|
68
64
|
yAxis: yAxis,
|
|
69
65
|
dataset: dataset,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChartsPluginType } from '../models';
|
|
3
|
+
import { ChartSeriesType } from '../models/seriesType/config';
|
|
4
|
+
export declare const useChartContainerHooks: (ref: React.ForwardedRef<unknown> | null, plugins?: ChartsPluginType<ChartSeriesType>[]) => {
|
|
5
|
+
svgRef: React.RefObject<SVGSVGElement>;
|
|
6
|
+
handleRef: ((instance: unknown) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | null;
|
|
7
|
+
xExtremumGetters: import("../models").ExtremumGettersConfig<keyof import("../models/seriesType/config").ChartsSeriesConfig>;
|
|
8
|
+
yExtremumGetters: import("../models").ExtremumGettersConfig<keyof import("../models/seriesType/config").ChartsSeriesConfig>;
|
|
9
|
+
seriesFormatters: import("../internals").SeriesFormatterConfig<keyof import("../models/seriesType/config").ChartsSeriesConfig>;
|
|
10
|
+
colorProcessors: import("../models").ColorProcessorsConfig<keyof import("../models/seriesType/config").ChartsSeriesConfig>;
|
|
11
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useChartContainerHooks = void 0;
|
|
8
|
+
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _usePluginsMerge = require("./usePluginsMerge");
|
|
11
|
+
var _useReducedMotion = require("../hooks/useReducedMotion");
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
|
+
const useChartContainerHooks = (ref, plugins) => {
|
|
15
|
+
const svgRef = React.useRef(null);
|
|
16
|
+
const handleRef = (0, _useForkRef.default)(ref, svgRef);
|
|
17
|
+
const {
|
|
18
|
+
xExtremumGetters,
|
|
19
|
+
yExtremumGetters,
|
|
20
|
+
seriesFormatters,
|
|
21
|
+
colorProcessors
|
|
22
|
+
} = (0, _usePluginsMerge.usePluginsMerge)(plugins);
|
|
23
|
+
(0, _useReducedMotion.useReducedMotion)(); // a11y reduce motion (see: https://react-spring.dev/docs/utilities/use-reduced-motion)
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
svgRef,
|
|
27
|
+
handleRef,
|
|
28
|
+
xExtremumGetters,
|
|
29
|
+
yExtremumGetters,
|
|
30
|
+
seriesFormatters,
|
|
31
|
+
colorProcessors
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
exports.useChartContainerHooks = useChartContainerHooks;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ChartsPluginType, ColorProcessorsConfig } from '../models';
|
|
1
|
+
import { ChartsPluginType, ColorProcessorsConfig, ExtremumGettersConfig } from '../models';
|
|
2
2
|
import { ChartSeriesType } from '../models/seriesType/config';
|
|
3
|
-
import { ExtremumGettersConfig } from '../context/CartesianContextProvider';
|
|
4
3
|
import { SeriesFormatterConfig } from '../context/SeriesContextProvider';
|
|
5
4
|
export declare function usePluginsMerge<T extends ChartSeriesType>(plugins?: ChartsPluginType<T>[]): {
|
|
6
5
|
seriesFormatters: SeriesFormatterConfig<keyof import("../models/seriesType/config").ChartsSeriesConfig>;
|
package/ChartsAxis/ChartsAxis.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.ChartsAxis = ChartsAxis;
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
var
|
|
11
|
+
var _CartesianProvider = require("../context/CartesianProvider");
|
|
12
12
|
var _ChartsXAxis = require("../ChartsXAxis");
|
|
13
13
|
var _ChartsYAxis = require("../ChartsYAxis");
|
|
14
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -56,7 +56,7 @@ function ChartsAxis(props) {
|
|
|
56
56
|
xAxisIds,
|
|
57
57
|
yAxis,
|
|
58
58
|
yAxisIds
|
|
59
|
-
} =
|
|
59
|
+
} = (0, _CartesianProvider.useCartesianContext)();
|
|
60
60
|
|
|
61
61
|
// TODO: use for plotting line without ticks or any thing
|
|
62
62
|
// const drawingArea = React.useContext(DrawingContext);
|
|
@@ -15,7 +15,7 @@ var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateU
|
|
|
15
15
|
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
|
16
16
|
var _styles = require("@mui/material/styles");
|
|
17
17
|
var _InteractionProvider = require("../context/InteractionProvider");
|
|
18
|
-
var
|
|
18
|
+
var _CartesianProvider = require("../context/CartesianProvider");
|
|
19
19
|
var _useScale = require("../hooks/useScale");
|
|
20
20
|
var _isBandScale = require("../internals/isBandScale");
|
|
21
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -66,7 +66,7 @@ function ChartsAxisHighlight(props) {
|
|
|
66
66
|
xAxis,
|
|
67
67
|
yAxisIds,
|
|
68
68
|
yAxis
|
|
69
|
-
} =
|
|
69
|
+
} = (0, _CartesianProvider.useCartesianContext)();
|
|
70
70
|
const classes = useUtilityClasses();
|
|
71
71
|
const USED_X_AXIS_ID = xAxisIds[0];
|
|
72
72
|
const USED_Y_AXIS_ID = yAxisIds[0];
|
|
@@ -77,15 +77,30 @@ function ChartsAxisHighlight(props) {
|
|
|
77
77
|
} = React.useContext(_InteractionProvider.InteractionContext);
|
|
78
78
|
const getXPosition = (0, _useScale.getValueToPositionMapper)(xScale);
|
|
79
79
|
const getYPosition = (0, _useScale.getValueToPositionMapper)(yScale);
|
|
80
|
+
const axisX = axis.x;
|
|
81
|
+
const axisY = axis.y;
|
|
82
|
+
const isBandScaleX = xAxisHighlight === 'band' && axisX !== null && (0, _isBandScale.isBandScale)(xScale);
|
|
83
|
+
const isBandScaleY = yAxisHighlight === 'band' && axisY !== null && (0, _isBandScale.isBandScale)(yScale);
|
|
84
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
85
|
+
const isXError = isBandScaleX && xScale(axisX.value) === undefined;
|
|
86
|
+
const isYError = isBandScaleY && yScale(axisY.value) === undefined;
|
|
87
|
+
if (isXError || isYError) {
|
|
88
|
+
console.error([`MUI X Charts: The position value provided for the axis is not valid for the current scale.`, `This probably means something is wrong with the data passed to the chart.`, `The ChartsAxisHighlight component will not be displayed.`].join('\n'));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
80
91
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
81
|
-
children: [
|
|
82
|
-
|
|
92
|
+
children: [isBandScaleX && xScale(axisX.value) !== undefined && /*#__PURE__*/(0, _jsxRuntime.jsx)(ChartsAxisHighlightPath
|
|
93
|
+
// @ts-expect-error, xScale value is checked in the statement above
|
|
94
|
+
, {
|
|
95
|
+
d: `M ${xScale(axisX.value) - (xScale.step() - xScale.bandwidth()) / 2} ${yScale.range()[0]} l ${xScale.step()} 0 l 0 ${yScale.range()[1] - yScale.range()[0]} l ${-xScale.step()} 0 Z`,
|
|
83
96
|
className: classes.root,
|
|
84
97
|
ownerState: {
|
|
85
98
|
axisHighlight: 'band'
|
|
86
99
|
}
|
|
87
|
-
}),
|
|
88
|
-
d: `M ${xScale.range()[0]} ${
|
|
100
|
+
}), isBandScaleY && yScale(axisY.value) === undefined && /*#__PURE__*/(0, _jsxRuntime.jsx)(ChartsAxisHighlightPath, {
|
|
101
|
+
d: `M ${xScale.range()[0]} ${
|
|
102
|
+
// @ts-expect-error, yScale value is checked in the statement above
|
|
103
|
+
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`,
|
|
89
104
|
className: classes.root,
|
|
90
105
|
ownerState: {
|
|
91
106
|
axisHighlight: 'band'
|