@mui/x-charts 7.10.0 → 7.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.js +2 -2
- package/BarChart/BarElement.d.ts +2 -1
- package/BarChart/BarLabel/BarLabelItem.d.ts +2 -1
- package/BarChart/BarPlot.js +8 -8
- package/BarChart/checkScaleErrors.d.ts +4 -4
- package/BarChart/checkScaleErrors.js +11 -11
- package/BarChart/extremums.js +4 -1
- package/BarChart/formatter.js +2 -2
- package/BarChart/useBarChartProps.js +38 -33
- package/CHANGELOG.md +169 -0
- package/ChartContainer/ChartContainer.d.ts +28 -2
- package/ChartContainer/ChartContainer.js +25 -66
- package/ChartContainer/useChartContainerHooks.d.ts +1 -1
- package/ChartContainer/useChartContainerHooks.js +2 -2
- package/ChartContainer/useChartContainerProps.d.ts +86 -0
- package/ChartContainer/useChartContainerProps.js +95 -0
- package/ChartContainer/useDefaultizeAxis.d.ts +36 -0
- package/ChartContainer/useDefaultizeAxis.js +29 -0
- package/ChartsAxis/ChartsAxis.js +4 -4
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/ChartsLegend/ChartsLegend.d.ts +3 -12
- package/ChartsLegend/ContinuousColorLegend.d.ts +65 -0
- package/ChartsLegend/ContinuousColorLegend.js +398 -0
- package/ChartsLegend/DefaultChartsLegend.d.ts +7 -50
- package/ChartsLegend/DefaultChartsLegend.js +13 -198
- package/ChartsLegend/LegendPerItem.d.ts +61 -0
- package/ChartsLegend/LegendPerItem.js +151 -0
- package/ChartsLegend/PiecewiseColorLegend.d.ts +26 -0
- package/ChartsLegend/PiecewiseColorLegend.js +169 -0
- package/ChartsLegend/chartsLegend.types.d.ts +31 -0
- package/ChartsLegend/chartsLegend.types.js +5 -0
- package/ChartsLegend/index.d.ts +2 -0
- package/ChartsLegend/index.js +22 -0
- package/ChartsLegend/legend.types.d.ts +62 -0
- package/ChartsLegend/legend.types.js +5 -0
- package/ChartsLegend/legendItemsPlacement.d.ts +3 -0
- package/ChartsLegend/legendItemsPlacement.js +79 -0
- package/ChartsLegend/useAxis.d.ts +7 -0
- package/ChartsLegend/useAxis.js +47 -0
- package/ChartsLegend/utils.d.ts +1 -8
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
- package/ChartsOverlay/ChartsOverlay.d.ts +3 -2
- package/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
- package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
- package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
- package/ChartsSurface.js +3 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
- package/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
- package/ChartsXAxis/ChartsXAxis.js +1 -1
- package/ChartsYAxis/ChartsYAxis.js +15 -3
- package/Gauge/Gauge.d.ts +1 -4
- package/Gauge/Gauge.js +9 -6
- package/Gauge/GaugeContainer.js +8 -4
- package/Gauge/GaugeProvider.js +9 -9
- package/LineChart/AnimatedArea.js +2 -2
- package/LineChart/AnimatedLine.js +2 -2
- package/LineChart/AreaElement.d.ts +2 -1
- package/LineChart/AreaPlot.js +10 -6
- package/LineChart/LineChart.js +5 -2
- package/LineChart/LineElement.d.ts +2 -1
- package/LineChart/LineHighlightPlot.d.ts +2 -1
- package/LineChart/LineHighlightPlot.js +17 -5
- package/LineChart/LinePlot.js +10 -6
- package/LineChart/MarkElement.js +2 -2
- package/LineChart/MarkPlot.js +13 -25
- package/LineChart/extremums.js +4 -1
- package/LineChart/formatter.js +2 -2
- package/LineChart/useLineChartProps.js +38 -33
- package/PieChart/PieArc.js +1 -0
- package/PieChart/PieChart.d.ts +1 -4
- package/PieChart/PieChart.js +40 -34
- package/PieChart/PiePlot.js +6 -6
- package/PieChart/getPieCoordinates.js +3 -3
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
- package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +5 -1
- package/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +20 -0
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +73 -0
- package/ScatterChart/Scatter.js +6 -9
- package/ScatterChart/ScatterChart.js +4 -1
- package/ScatterChart/ScatterPlot.js +6 -3
- package/ScatterChart/extremums.js +8 -2
- package/ScatterChart/useScatterChartProps.js +35 -30
- package/SparkLineChart/SparkLineChart.js +27 -22
- package/context/CartesianProvider/CartesianContext.d.ts +1 -1
- package/context/CartesianProvider/CartesianProvider.d.ts +2 -3
- package/context/CartesianProvider/CartesianProvider.js +18 -7
- package/context/CartesianProvider/computeValue.d.ts +32 -9
- package/context/CartesianProvider/computeValue.js +20 -16
- package/context/CartesianProvider/defaultizeAxis.d.ts +36 -0
- package/context/CartesianProvider/defaultizeAxis.js +21 -0
- package/context/CartesianProvider/index.d.ts +0 -1
- package/context/CartesianProvider/index.js +1 -3
- package/context/CartesianProvider/normalizeAxis.d.ts +1 -1
- package/context/CartesianProvider/normalizeAxis.js +2 -2
- package/context/DrawingProvider.d.ts +12 -0
- package/context/DrawingProvider.js +15 -2
- package/context/HighlightedProvider/HighlightedProvider.js +2 -2
- package/context/SeriesContextProvider.js +1 -1
- package/context/ZAxisContextProvider.d.ts +1 -1
- package/context/ZAxisContextProvider.js +1 -1
- package/esm/BarChart/BarChart.js +2 -2
- package/esm/BarChart/BarPlot.js +8 -8
- package/esm/BarChart/checkScaleErrors.js +11 -11
- package/esm/BarChart/extremums.js +4 -1
- package/esm/BarChart/formatter.js +2 -2
- package/esm/BarChart/useBarChartProps.js +38 -33
- package/esm/ChartContainer/ChartContainer.js +25 -66
- package/esm/ChartContainer/useChartContainerHooks.js +2 -2
- package/esm/ChartContainer/useChartContainerProps.js +87 -0
- package/esm/ChartContainer/useDefaultizeAxis.js +19 -0
- package/esm/ChartsAxis/ChartsAxis.js +4 -4
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/esm/ChartsLegend/ContinuousColorLegend.js +390 -0
- package/esm/ChartsLegend/DefaultChartsLegend.js +14 -198
- package/esm/ChartsLegend/LegendPerItem.js +141 -0
- package/esm/ChartsLegend/PiecewiseColorLegend.js +161 -0
- package/esm/ChartsLegend/chartsLegend.types.js +1 -0
- package/esm/ChartsLegend/index.js +2 -0
- package/esm/ChartsLegend/legend.types.js +1 -0
- package/esm/ChartsLegend/legendItemsPlacement.js +72 -0
- package/esm/ChartsLegend/useAxis.js +39 -0
- package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
- package/esm/ChartsSurface.js +3 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
- package/esm/ChartsXAxis/ChartsXAxis.js +1 -1
- package/esm/ChartsYAxis/ChartsYAxis.js +15 -3
- package/esm/Gauge/Gauge.js +8 -5
- package/esm/Gauge/GaugeContainer.js +8 -4
- package/esm/Gauge/GaugeProvider.js +1 -1
- package/esm/LineChart/AnimatedArea.js +1 -1
- package/esm/LineChart/AnimatedLine.js +1 -1
- package/esm/LineChart/AreaPlot.js +10 -6
- package/esm/LineChart/LineChart.js +5 -2
- package/esm/LineChart/LineHighlightPlot.js +17 -5
- package/esm/LineChart/LinePlot.js +10 -6
- package/esm/LineChart/MarkElement.js +1 -1
- package/esm/LineChart/MarkPlot.js +12 -24
- package/esm/LineChart/extremums.js +4 -1
- package/esm/LineChart/formatter.js +2 -2
- package/esm/LineChart/useLineChartProps.js +38 -33
- package/esm/PieChart/PieArc.js +1 -0
- package/esm/PieChart/PieChart.js +39 -33
- package/esm/PieChart/PiePlot.js +1 -1
- package/esm/PieChart/getPieCoordinates.js +1 -1
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
- package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
- package/esm/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
- package/esm/ScatterChart/Scatter.js +6 -9
- package/esm/ScatterChart/ScatterChart.js +4 -1
- package/esm/ScatterChart/ScatterPlot.js +6 -3
- package/esm/ScatterChart/extremums.js +8 -2
- package/esm/ScatterChart/useScatterChartProps.js +35 -30
- package/esm/SparkLineChart/SparkLineChart.js +27 -22
- package/esm/context/CartesianProvider/CartesianProvider.js +18 -7
- package/esm/context/CartesianProvider/computeValue.js +20 -16
- package/esm/context/CartesianProvider/defaultizeAxis.js +13 -0
- package/esm/context/CartesianProvider/index.js +1 -3
- package/esm/context/CartesianProvider/normalizeAxis.js +2 -2
- package/esm/context/DrawingProvider.js +15 -2
- package/esm/context/HighlightedProvider/HighlightedProvider.js +2 -2
- package/esm/context/SeriesContextProvider.js +1 -1
- package/esm/context/ZAxisContextProvider.js +1 -1
- package/esm/hooks/useAxisEvents.js +14 -17
- package/esm/hooks/useDrawingArea.js +5 -3
- package/esm/hooks/useReducedMotion.js +4 -2
- package/esm/internals/SlotComponentPropsFromProps.js +1 -0
- package/esm/internals/cleanId.js +6 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
- package/esm/internals/geometry.js +1 -1
- package/esm/internals/{utils.js → getPercentageValue.js} +1 -13
- package/esm/internals/getSymbol.js +5 -0
- package/esm/internals/index.js +3 -1
- package/esm/internals/isDefined.js +3 -0
- package/esm/internals/notNull.js +3 -0
- package/esm/internals/ts-generic.js +1 -0
- package/esm/internals/warning.js +19 -11
- package/hooks/useAxisEvents.js +14 -17
- package/hooks/useDrawingArea.js +5 -3
- package/hooks/useReducedMotion.js +4 -2
- package/index.js +1 -1
- package/internals/SlotComponentPropsFromProps.d.ts +1 -0
- package/internals/SlotComponentPropsFromProps.js +5 -0
- package/internals/cleanId.d.ts +4 -0
- package/internals/cleanId.js +12 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +6 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
- package/internals/defaultizeColor.d.ts +7 -0
- package/internals/geometry.js +1 -1
- package/internals/getPercentageValue.d.ts +7 -0
- package/internals/{utils.js → getPercentageValue.js} +1 -15
- package/internals/getSymbol.d.ts +2 -0
- package/internals/getSymbol.js +11 -0
- package/internals/index.d.ts +3 -1
- package/internals/index.js +25 -5
- package/internals/isDefined.d.ts +1 -0
- package/internals/isDefined.js +9 -0
- package/internals/notNull.d.ts +1 -0
- package/internals/notNull.js +9 -0
- package/internals/ts-generic.d.ts +5 -0
- package/internals/ts-generic.js +5 -0
- package/internals/warning.d.ts +2 -1
- package/internals/warning.js +21 -12
- package/models/axis.d.ts +5 -2
- package/models/helpers.d.ts +1 -0
- package/models/seriesType/common.d.ts +10 -0
- package/models/seriesType/config.d.ts +2 -16
- package/models/seriesType/scatter.d.ts +5 -0
- package/modern/BarChart/BarChart.js +2 -2
- package/modern/BarChart/BarPlot.js +8 -8
- package/modern/BarChart/checkScaleErrors.js +11 -11
- package/modern/BarChart/extremums.js +4 -1
- package/modern/BarChart/formatter.js +2 -2
- package/modern/BarChart/useBarChartProps.js +38 -33
- package/modern/ChartContainer/ChartContainer.js +25 -66
- package/modern/ChartContainer/useChartContainerHooks.js +2 -2
- package/modern/ChartContainer/useChartContainerProps.js +87 -0
- package/modern/ChartContainer/useDefaultizeAxis.js +19 -0
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/modern/ChartsLegend/ContinuousColorLegend.js +390 -0
- package/modern/ChartsLegend/DefaultChartsLegend.js +14 -198
- package/modern/ChartsLegend/LegendPerItem.js +141 -0
- package/modern/ChartsLegend/PiecewiseColorLegend.js +161 -0
- package/modern/ChartsLegend/chartsLegend.types.js +1 -0
- package/modern/ChartsLegend/index.js +2 -0
- package/modern/ChartsLegend/legend.types.js +1 -0
- package/modern/ChartsLegend/legendItemsPlacement.js +72 -0
- package/modern/ChartsLegend/useAxis.js +39 -0
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
- package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
- package/modern/ChartsSurface.js +3 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
- package/modern/ChartsXAxis/ChartsXAxis.js +1 -1
- package/modern/ChartsYAxis/ChartsYAxis.js +15 -3
- package/modern/Gauge/Gauge.js +8 -5
- package/modern/Gauge/GaugeContainer.js +8 -4
- package/modern/Gauge/GaugeProvider.js +1 -1
- package/modern/LineChart/AnimatedArea.js +1 -1
- package/modern/LineChart/AnimatedLine.js +1 -1
- package/modern/LineChart/AreaPlot.js +10 -6
- package/modern/LineChart/LineChart.js +5 -2
- package/modern/LineChart/LineHighlightPlot.js +17 -5
- package/modern/LineChart/LinePlot.js +10 -6
- package/modern/LineChart/MarkElement.js +1 -1
- package/modern/LineChart/MarkPlot.js +12 -24
- package/modern/LineChart/extremums.js +4 -1
- package/modern/LineChart/formatter.js +2 -2
- package/modern/LineChart/useLineChartProps.js +38 -33
- package/modern/PieChart/PieArc.js +1 -0
- package/modern/PieChart/PieChart.js +39 -33
- package/modern/PieChart/PiePlot.js +1 -1
- package/modern/PieChart/getPieCoordinates.js +1 -1
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
- package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
- package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
- package/modern/ScatterChart/Scatter.js +6 -9
- package/modern/ScatterChart/ScatterChart.js +4 -1
- package/modern/ScatterChart/ScatterPlot.js +6 -3
- package/modern/ScatterChart/extremums.js +8 -2
- package/modern/ScatterChart/useScatterChartProps.js +35 -30
- package/modern/SparkLineChart/SparkLineChart.js +27 -22
- package/modern/context/CartesianProvider/CartesianProvider.js +18 -7
- package/modern/context/CartesianProvider/computeValue.js +20 -16
- package/modern/context/CartesianProvider/defaultizeAxis.js +13 -0
- package/modern/context/CartesianProvider/index.js +1 -3
- package/modern/context/CartesianProvider/normalizeAxis.js +2 -2
- package/modern/context/DrawingProvider.js +15 -2
- package/modern/context/HighlightedProvider/HighlightedProvider.js +2 -2
- package/modern/context/SeriesContextProvider.js +1 -1
- package/modern/context/ZAxisContextProvider.js +1 -1
- package/modern/hooks/useAxisEvents.js +14 -17
- package/modern/hooks/useDrawingArea.js +5 -3
- package/modern/hooks/useReducedMotion.js +4 -2
- package/modern/index.js +1 -1
- package/modern/internals/SlotComponentPropsFromProps.js +1 -0
- package/modern/internals/cleanId.js +6 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
- package/modern/internals/geometry.js +1 -1
- package/modern/internals/{utils.js → getPercentageValue.js} +1 -13
- package/modern/internals/getSymbol.js +5 -0
- package/modern/internals/index.js +3 -1
- package/modern/internals/isDefined.js +3 -0
- package/modern/internals/notNull.js +3 -0
- package/modern/internals/ts-generic.js +1 -0
- package/modern/internals/warning.js +19 -11
- package/package.json +4 -4
- package/internals/utils.d.ts +0 -18
|
@@ -2,13 +2,12 @@ import * as React from 'react';
|
|
|
2
2
|
import { useDrawingArea } from '../../hooks/useDrawingArea';
|
|
3
3
|
import { useSeries } from '../../hooks/useSeries';
|
|
4
4
|
import { CartesianContext } from './CartesianContext';
|
|
5
|
-
import { normalizeAxis } from './normalizeAxis';
|
|
6
5
|
import { computeValue } from './computeValue';
|
|
7
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
7
|
function CartesianContextProvider(props) {
|
|
9
8
|
const {
|
|
10
|
-
xAxis
|
|
11
|
-
yAxis
|
|
9
|
+
xAxis,
|
|
10
|
+
yAxis,
|
|
12
11
|
dataset,
|
|
13
12
|
xExtremumGetters,
|
|
14
13
|
yExtremumGetters,
|
|
@@ -16,10 +15,22 @@ function CartesianContextProvider(props) {
|
|
|
16
15
|
} = props;
|
|
17
16
|
const formattedSeries = useSeries();
|
|
18
17
|
const drawingArea = useDrawingArea();
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const xValues = React.useMemo(() => computeValue({
|
|
19
|
+
drawingArea,
|
|
20
|
+
formattedSeries,
|
|
21
|
+
axis: xAxis,
|
|
22
|
+
extremumGetters: xExtremumGetters,
|
|
23
|
+
dataset,
|
|
24
|
+
axisDirection: 'x'
|
|
25
|
+
}), [drawingArea, formattedSeries, xAxis, xExtremumGetters, dataset]);
|
|
26
|
+
const yValues = React.useMemo(() => computeValue({
|
|
27
|
+
drawingArea,
|
|
28
|
+
formattedSeries,
|
|
29
|
+
axis: yAxis,
|
|
30
|
+
extremumGetters: yExtremumGetters,
|
|
31
|
+
dataset,
|
|
32
|
+
axisDirection: 'y'
|
|
33
|
+
}), [drawingArea, formattedSeries, yAxis, yExtremumGetters, dataset]);
|
|
23
34
|
const value = React.useMemo(() => ({
|
|
24
35
|
isInitialized: true,
|
|
25
36
|
data: {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { scaleBand, scalePoint, scaleTime } from 'd3-scale';
|
|
3
|
-
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../../constants';
|
|
4
3
|
import { isBandScaleConfig, isPointScaleConfig } from '../../models/axis';
|
|
5
4
|
import { getColorScale, getOrdinalColorScale } from '../../internals/colorScale';
|
|
6
5
|
import { getTickNumber } from '../../hooks/useTicks';
|
|
7
6
|
import { getScale } from '../../internals/getScale';
|
|
8
7
|
import { getAxisExtremum } from './getAxisExtremum';
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import { normalizeAxis } from './normalizeAxis';
|
|
9
|
+
const getRange = (drawingArea, axisDirection, isReverse) => {
|
|
10
|
+
const range = axisDirection === 'x' ? [drawingArea.left, drawingArea.left + drawingArea.width] : [drawingArea.top + drawingArea.height, drawingArea.top];
|
|
11
11
|
return isReverse ? range.reverse() : range;
|
|
12
12
|
};
|
|
13
13
|
const zoomedScaleRange = (scaleRange, zoomRange) => {
|
|
@@ -29,26 +29,30 @@ function createDateFormatter(axis, range) {
|
|
|
29
29
|
}
|
|
30
30
|
const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
|
|
31
31
|
const DEFAULT_BAR_GAP_RATIO = 0.1;
|
|
32
|
-
export function computeValue(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
export function computeValue({
|
|
33
|
+
drawingArea,
|
|
34
|
+
formattedSeries,
|
|
35
|
+
axis: inAxis,
|
|
36
|
+
extremumGetters,
|
|
37
|
+
dataset,
|
|
38
|
+
axisDirection,
|
|
39
|
+
zoomData
|
|
40
|
+
}) {
|
|
41
|
+
const allAxis = normalizeAxis(inAxis, dataset, axisDirection);
|
|
42
42
|
const completeAxis = {};
|
|
43
43
|
allAxis.forEach((axis, axisIndex) => {
|
|
44
44
|
const isDefaultAxis = axisIndex === 0;
|
|
45
45
|
const [minData, maxData] = getAxisExtremum(axis, extremumGetters, isDefaultAxis, formattedSeries);
|
|
46
|
-
const
|
|
46
|
+
const zoom = zoomData?.find(({
|
|
47
|
+
axisId
|
|
48
|
+
}) => axisId === axis.id);
|
|
49
|
+
const zoomRange = zoom ? [zoom.start, zoom.end] : [0, 100];
|
|
50
|
+
const range = getRange(drawingArea, axisDirection, axis.reverse);
|
|
47
51
|
if (isBandScaleConfig(axis)) {
|
|
48
52
|
const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
|
|
49
53
|
const barGapRatio = axis.barGapRatio ?? DEFAULT_BAR_GAP_RATIO;
|
|
50
54
|
// Reverse range because ordinal scales are presented from top to bottom on y-axis
|
|
51
|
-
const scaleRange =
|
|
55
|
+
const scaleRange = axisDirection === 'x' ? range : [range[1], range[0]];
|
|
52
56
|
const zoomedRange = zoomedScaleRange(scaleRange, zoomRange);
|
|
53
57
|
completeAxis[axis.id] = _extends({
|
|
54
58
|
categoryGapRatio,
|
|
@@ -66,7 +70,7 @@ export function computeValue(drawingArea, formattedSeries, inAxis, extremumGette
|
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
if (isPointScaleConfig(axis)) {
|
|
69
|
-
const scaleRange =
|
|
73
|
+
const scaleRange = axisDirection === 'x' ? range : [...range].reverse();
|
|
70
74
|
const zoomedRange = zoomedScaleRange(scaleRange, zoomRange);
|
|
71
75
|
completeAxis[axis.id] = _extends({}, axis, {
|
|
72
76
|
scale: scalePoint(axis.data, zoomedRange),
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../../constants';
|
|
3
|
+
export const defaultizeAxis = (inAxis, axisName) => {
|
|
4
|
+
const DEFAULT_AXIS_KEY = axisName === 'x' ? DEFAULT_X_AXIS_KEY : DEFAULT_Y_AXIS_KEY;
|
|
5
|
+
return [...(inAxis?.map((axis, index) => _extends({
|
|
6
|
+
id: `defaultized-${axisName}-axis-${index}`
|
|
7
|
+
}, axis)) ?? []), ...(inAxis === undefined || inAxis.findIndex(({
|
|
8
|
+
id
|
|
9
|
+
}) => id === DEFAULT_AXIS_KEY) === -1 ? [{
|
|
10
|
+
id: DEFAULT_AXIS_KEY,
|
|
11
|
+
scaleType: 'linear'
|
|
12
|
+
}] : [])];
|
|
13
|
+
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { computeValue } from './computeValue';
|
|
2
|
-
import { normalizeAxis } from './normalizeAxis';
|
|
3
2
|
export * from './CartesianProvider';
|
|
4
3
|
export * from './CartesianContext';
|
|
5
4
|
export * from './useCartesianContext';
|
|
6
5
|
const cartesianProviderUtils = {
|
|
7
|
-
computeValue
|
|
8
|
-
normalizeAxis
|
|
6
|
+
computeValue
|
|
9
7
|
};
|
|
10
8
|
export { cartesianProviderUtils };
|
|
@@ -6,10 +6,10 @@ export const normalizeAxis = (axis, dataset, axisName) => {
|
|
|
6
6
|
return axisConfig;
|
|
7
7
|
}
|
|
8
8
|
if (dataset === undefined) {
|
|
9
|
-
throw Error(`MUI X
|
|
9
|
+
throw Error(`MUI X: ${axisName}-axis uses \`dataKey\` but no \`dataset\` is provided.`);
|
|
10
10
|
}
|
|
11
11
|
return _extends({}, axisConfig, {
|
|
12
12
|
data: dataset.map(d => d[dataKey])
|
|
13
13
|
});
|
|
14
|
-
});
|
|
14
|
+
}) ?? [];
|
|
15
15
|
};
|
|
@@ -14,7 +14,8 @@ export const DrawingContext = /*#__PURE__*/React.createContext({
|
|
|
14
14
|
right: 0,
|
|
15
15
|
height: 300,
|
|
16
16
|
width: 400,
|
|
17
|
-
chartId: ''
|
|
17
|
+
chartId: '',
|
|
18
|
+
isPointInside: () => false
|
|
18
19
|
});
|
|
19
20
|
if (process.env.NODE_ENV !== 'production') {
|
|
20
21
|
DrawingContext.displayName = 'DrawingContext';
|
|
@@ -38,9 +39,21 @@ export function DrawingProvider(props) {
|
|
|
38
39
|
} = props;
|
|
39
40
|
const drawingArea = useChartDimensions(width, height, margin);
|
|
40
41
|
const chartId = useId();
|
|
42
|
+
const isPointInside = React.useCallback(({
|
|
43
|
+
x,
|
|
44
|
+
y
|
|
45
|
+
}, targetElement) => {
|
|
46
|
+
// For element allowed to overflow, wrapping them in <g data-drawing-container /> make them fully part of the drawing area.
|
|
47
|
+
if (targetElement && targetElement.closest('[data-drawing-container]')) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return x >= drawingArea.left && x <= drawingArea.left + drawingArea.width && y >= drawingArea.top && y <= drawingArea.top + drawingArea.height;
|
|
51
|
+
}, [drawingArea]);
|
|
41
52
|
const value = React.useMemo(() => _extends({
|
|
42
53
|
chartId: chartId ?? ''
|
|
43
|
-
}, drawingArea
|
|
54
|
+
}, drawingArea, {
|
|
55
|
+
isPointInside
|
|
56
|
+
}), [chartId, drawingArea, isPointInside]);
|
|
44
57
|
const refValue = React.useMemo(() => ({
|
|
45
58
|
isInitialized: true,
|
|
46
59
|
data: svgRef
|
|
@@ -15,11 +15,11 @@ const mergeDeprecatedOptions = options => {
|
|
|
15
15
|
highlighted,
|
|
16
16
|
faded
|
|
17
17
|
} = _ref,
|
|
18
|
-
|
|
18
|
+
other = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
19
19
|
return _extends({
|
|
20
20
|
highlight: highlighted,
|
|
21
21
|
fade: faded
|
|
22
|
-
},
|
|
22
|
+
}, other);
|
|
23
23
|
};
|
|
24
24
|
function HighlightedProvider({
|
|
25
25
|
children,
|
|
@@ -34,7 +34,7 @@ const preprocessSeries = (series, colors, seriesFormatters, dataset) => {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
if (seriesGroups[type]?.series[id] !== undefined) {
|
|
37
|
-
throw new Error(`MUI X
|
|
37
|
+
throw new Error(`MUI X: series' id "${id}" is not unique.`);
|
|
38
38
|
}
|
|
39
39
|
seriesGroups[type].series[id] = _extends({
|
|
40
40
|
id
|
|
@@ -22,7 +22,7 @@ function ZAxisContextProvider(props) {
|
|
|
22
22
|
return axisConfig;
|
|
23
23
|
}
|
|
24
24
|
if (dataset === undefined) {
|
|
25
|
-
throw Error('MUI X
|
|
25
|
+
throw Error('MUI X: z-axis uses `dataKey` but no `dataset` is provided.');
|
|
26
26
|
}
|
|
27
27
|
return _extends({}, axisConfig, {
|
|
28
28
|
data: dataset.map(d => d[dataKey])
|
|
@@ -10,12 +10,7 @@ function getAsANumber(value) {
|
|
|
10
10
|
}
|
|
11
11
|
export const useAxisEvents = disableAxisListener => {
|
|
12
12
|
const svgRef = useSvgRef();
|
|
13
|
-
const
|
|
14
|
-
left,
|
|
15
|
-
top,
|
|
16
|
-
width,
|
|
17
|
-
height
|
|
18
|
-
} = useDrawingArea();
|
|
13
|
+
const drawingArea = useDrawingArea();
|
|
19
14
|
const {
|
|
20
15
|
xAxis,
|
|
21
16
|
yAxis,
|
|
@@ -30,6 +25,7 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
30
25
|
|
|
31
26
|
// Use a ref to avoid rerendering on every mousemove event.
|
|
32
27
|
const mousePosition = React.useRef({
|
|
28
|
+
isInChart: false,
|
|
33
29
|
x: -1,
|
|
34
30
|
y: -1
|
|
35
31
|
});
|
|
@@ -89,6 +85,7 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
89
85
|
}
|
|
90
86
|
const handleOut = () => {
|
|
91
87
|
mousePosition.current = {
|
|
88
|
+
isInChart: false,
|
|
92
89
|
x: -1,
|
|
93
90
|
y: -1
|
|
94
91
|
};
|
|
@@ -99,18 +96,18 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
99
96
|
const handleMove = event => {
|
|
100
97
|
const target = 'targetTouches' in event ? event.targetTouches[0] : event;
|
|
101
98
|
const svgPoint = getSVGPoint(element, target);
|
|
102
|
-
mousePosition.current =
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
});
|
|
99
|
+
mousePosition.current.x = svgPoint.x;
|
|
100
|
+
mousePosition.current.y = svgPoint.y;
|
|
101
|
+
if (!drawingArea.isPointInside(svgPoint, event.target)) {
|
|
102
|
+
if (mousePosition.current.isInChart) {
|
|
103
|
+
dispatch({
|
|
104
|
+
type: 'exitChart'
|
|
105
|
+
});
|
|
106
|
+
mousePosition.current.isInChart = false;
|
|
107
|
+
}
|
|
112
108
|
return;
|
|
113
109
|
}
|
|
110
|
+
mousePosition.current.isInChart = true;
|
|
114
111
|
const newStateX = getNewAxisState(xAxis[usedXAxis], svgPoint.x);
|
|
115
112
|
const newStateY = getNewAxisState(yAxis[usedYAxis], svgPoint.y);
|
|
116
113
|
dispatch({
|
|
@@ -142,5 +139,5 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
142
139
|
element.removeEventListener('pointercancel', handleOut);
|
|
143
140
|
element.removeEventListener('pointerleave', handleOut);
|
|
144
141
|
};
|
|
145
|
-
}, [svgRef, dispatch,
|
|
142
|
+
}, [svgRef, dispatch, usedYAxis, yAxis, usedXAxis, xAxis, disableAxisListener, drawingArea]);
|
|
146
143
|
};
|
|
@@ -7,7 +7,8 @@ export function useDrawingArea() {
|
|
|
7
7
|
width,
|
|
8
8
|
height,
|
|
9
9
|
bottom,
|
|
10
|
-
right
|
|
10
|
+
right,
|
|
11
|
+
isPointInside
|
|
11
12
|
} = React.useContext(DrawingContext);
|
|
12
13
|
return React.useMemo(() => ({
|
|
13
14
|
left,
|
|
@@ -15,6 +16,7 @@ export function useDrawingArea() {
|
|
|
15
16
|
width,
|
|
16
17
|
height,
|
|
17
18
|
bottom,
|
|
18
|
-
right
|
|
19
|
-
|
|
19
|
+
right,
|
|
20
|
+
isPointInside
|
|
21
|
+
}), [height, left, top, width, bottom, right, isPointInside]);
|
|
20
22
|
}
|
|
@@ -26,9 +26,11 @@ export const useReducedMotion = () => {
|
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
28
|
handleMediaChange(mql);
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
// MatchMedia is not fully supported in all environments, so we need to check if it exists before calling addEventListener
|
|
31
|
+
mql.addEventListener?.('change', handleMediaChange);
|
|
30
32
|
return () => {
|
|
31
|
-
mql.removeEventListener('change', handleMediaChange);
|
|
33
|
+
mql.removeEventListener?.('change', handleMediaChange);
|
|
32
34
|
};
|
|
33
35
|
}, []);
|
|
34
36
|
};
|
package/modern/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,6 +4,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
const PX_PRECISION = 10;
|
|
5
5
|
export default function ChartsContinuousGradient(props) {
|
|
6
6
|
const {
|
|
7
|
+
gradientUnits,
|
|
7
8
|
isReversed,
|
|
8
9
|
gradientId,
|
|
9
10
|
size,
|
|
@@ -26,8 +27,8 @@ export default function ChartsContinuousGradient(props) {
|
|
|
26
27
|
x2: "0",
|
|
27
28
|
y1: "0",
|
|
28
29
|
y2: "0",
|
|
29
|
-
[`${direction}${isReversed ? 1 : 2}`]: `${size}px`,
|
|
30
|
-
gradientUnits:
|
|
30
|
+
[`${direction}${isReversed ? 1 : 2}`]: gradientUnits === 'objectBoundingBox' ? 1 : `${size}px`,
|
|
31
|
+
gradientUnits: gradientUnits ?? 'userSpaceOnUse' // Use the SVG coordinate instead of the component ones.
|
|
31
32
|
,
|
|
32
33
|
children: Array.from({
|
|
33
34
|
length: numberOfPoints + 1
|
|
@@ -14,7 +14,7 @@ export function getMinXTranslation(width, height, angle = 0) {
|
|
|
14
14
|
if (process.env.NODE_ENV !== 'production') {
|
|
15
15
|
if (!warnedOnce && angle > 90 && angle < -90) {
|
|
16
16
|
warnedOnce = true;
|
|
17
|
-
console.warn([`MUI X
|
|
17
|
+
console.warn([`MUI X: It seems you applied an angle larger than 90° or smaller than -90° to an axis text.`, `This could cause some text overlapping.`, `If you encounter a use case where it's needed, please open an issue.`].join('\n'));
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
const standardAngle = Math.min(Math.abs(angle) % 180, Math.abs(Math.abs(angle) % 180 - 180) % 180); // Map from R to [0, 90]
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
// Returns the index of a defined shape
|
|
2
|
-
export function getSymbol(shape) {
|
|
3
|
-
const symbolNames = 'circle cross diamond square star triangle wye'.split(/ /);
|
|
4
|
-
return symbolNames.indexOf(shape) || 0;
|
|
5
|
-
}
|
|
6
1
|
/**
|
|
7
2
|
* Helper that converts values and percentages into values.
|
|
8
3
|
* @param value The value provided by the developer. Can either be a number or a string with '%' or 'px'.
|
|
@@ -29,12 +24,5 @@ export function getPercentageValue(value, refValue) {
|
|
|
29
24
|
return val;
|
|
30
25
|
}
|
|
31
26
|
}
|
|
32
|
-
throw Error(`MUI
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Remove spaces to have viable ids
|
|
37
|
-
*/
|
|
38
|
-
export function cleanId(id) {
|
|
39
|
-
return id.replace(' ', '_');
|
|
27
|
+
throw Error(`MUI X: Received an unknown value "${value}". It should be a number, or a string with a percentage value.`);
|
|
40
28
|
}
|
|
@@ -8,16 +8,18 @@ export { useReducedMotion } from '../hooks/useReducedMotion';
|
|
|
8
8
|
export { useSeries } from '../hooks/useSeries';
|
|
9
9
|
export { useInteractionItemProps } from '../hooks/useInteractionItemProps';
|
|
10
10
|
export { useDrawingArea } from '../hooks/useDrawingArea';
|
|
11
|
-
export { useChartContainerHooks } from '../ChartContainer/useChartContainerHooks';
|
|
12
11
|
export { useScatterChartProps } from '../ScatterChart/useScatterChartProps';
|
|
13
12
|
export { useLineChartProps } from '../LineChart/useLineChartProps';
|
|
14
13
|
export { useBarChartProps } from '../BarChart/useBarChartProps';
|
|
14
|
+
export { useResponsiveChartContainerProps } from '../ResponsiveChartContainer/useResponsiveChartContainerProps';
|
|
15
|
+
export { useChartContainerProps } from '../ChartContainer/useChartContainerProps';
|
|
15
16
|
|
|
16
17
|
// utils
|
|
17
18
|
export * from './defaultizeValueFormatter';
|
|
18
19
|
export * from './configInit';
|
|
19
20
|
export * from './getLabel';
|
|
20
21
|
export * from './getSVGPoint';
|
|
22
|
+
export * from './isDefined';
|
|
21
23
|
|
|
22
24
|
// contexts
|
|
23
25
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
const warnedOnceCache = new Set();
|
|
2
|
+
|
|
3
|
+
// TODO move to @mui/x-internals
|
|
4
|
+
// TODO eventually move to @base_ui/internals. Base UI, etc. too need this helper.
|
|
5
|
+
export function warnOnce(message, gravity = 'warning') {
|
|
6
|
+
if (process.env.NODE_ENV === 'production') {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const cleanMessage = Array.isArray(message) ? message.join('\n') : message;
|
|
10
|
+
if (!warnedOnceCache.has(cleanMessage)) {
|
|
11
|
+
warnedOnceCache.add(cleanMessage);
|
|
12
|
+
if (gravity === 'error') {
|
|
13
|
+
console.error(cleanMessage);
|
|
14
|
+
} else {
|
|
15
|
+
console.warn(cleanMessage);
|
|
11
16
|
}
|
|
12
|
-
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function clearWarningsCache() {
|
|
20
|
+
warnedOnceCache.clear();
|
|
13
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-charts",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.11.1",
|
|
4
4
|
"description": "The community edition of the Charts components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"directory": "packages/x-charts"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@babel/runtime": "^7.24.
|
|
32
|
+
"@babel/runtime": "^7.24.8",
|
|
33
33
|
"@mui/base": "^5.0.0-beta.40",
|
|
34
|
-
"@mui/system": "^5.16.
|
|
35
|
-
"@mui/utils": "^5.16.
|
|
34
|
+
"@mui/system": "^5.16.5",
|
|
35
|
+
"@mui/utils": "^5.16.5",
|
|
36
36
|
"@react-spring/rafz": "^9.7.3",
|
|
37
37
|
"@react-spring/web": "^9.7.3",
|
|
38
38
|
"clsx": "^2.1.1",
|
package/internals/utils.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type SymbolsTypes = 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye';
|
|
2
|
-
export declare function getSymbol(shape: SymbolsTypes): number;
|
|
3
|
-
type Without<T, U> = {
|
|
4
|
-
[P in Exclude<keyof T, keyof U>]?: never;
|
|
5
|
-
};
|
|
6
|
-
export type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
|
|
7
|
-
/**
|
|
8
|
-
* Helper that converts values and percentages into values.
|
|
9
|
-
* @param value The value provided by the developer. Can either be a number or a string with '%' or 'px'.
|
|
10
|
-
* @param refValue The numerical value associated to 100%.
|
|
11
|
-
* @returns The numerical value associated to the provided value.
|
|
12
|
-
*/
|
|
13
|
-
export declare function getPercentageValue(value: number | string, refValue: number): number;
|
|
14
|
-
/**
|
|
15
|
-
* Remove spaces to have viable ids
|
|
16
|
-
*/
|
|
17
|
-
export declare function cleanId(id: string): string;
|
|
18
|
-
export {};
|