@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
|
@@ -5,7 +5,7 @@ import { useDrawingArea, useXScale } from '../hooks';
|
|
|
5
5
|
import { ReferenceLineRoot } from './common';
|
|
6
6
|
import { ChartsText } from '../ChartsText';
|
|
7
7
|
import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
|
|
8
|
-
import {
|
|
8
|
+
import { warnOnce } from '../internals/warning';
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
const getTextParams = ({
|
|
11
11
|
top,
|
|
@@ -47,7 +47,6 @@ export function getXReferenceLineClasses(classes) {
|
|
|
47
47
|
label: ['label']
|
|
48
48
|
}, getReferenceLineUtilityClass, classes);
|
|
49
49
|
}
|
|
50
|
-
const valueError = buildWarning((value, id) => `MUI X Charts: the value ${value} does not exist in the data of x axis with id ${id}.`, 'error');
|
|
51
50
|
function ChartsXReferenceLine(props) {
|
|
52
51
|
const {
|
|
53
52
|
x,
|
|
@@ -67,7 +66,7 @@ function ChartsXReferenceLine(props) {
|
|
|
67
66
|
const xPosition = xAxisScale(x);
|
|
68
67
|
if (xPosition === undefined) {
|
|
69
68
|
if (process.env.NODE_ENV !== 'production') {
|
|
70
|
-
|
|
69
|
+
warnOnce(`MUI X: the value ${x} does not exist in the data of x axis with id ${axisId}.`, 'error');
|
|
71
70
|
}
|
|
72
71
|
return null;
|
|
73
72
|
}
|
|
@@ -5,7 +5,7 @@ import { useDrawingArea, useYScale } from '../hooks';
|
|
|
5
5
|
import { ReferenceLineRoot } from './common';
|
|
6
6
|
import { ChartsText } from '../ChartsText';
|
|
7
7
|
import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
|
|
8
|
-
import {
|
|
8
|
+
import { warnOnce } from '../internals/warning';
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
const getTextParams = ({
|
|
11
11
|
left,
|
|
@@ -47,7 +47,6 @@ export function getYReferenceLineClasses(classes) {
|
|
|
47
47
|
label: ['label']
|
|
48
48
|
}, getReferenceLineUtilityClass, classes);
|
|
49
49
|
}
|
|
50
|
-
const valueError = buildWarning((value, id) => `MUI X Charts: the value ${value} does not exist in the data of y axis with id ${id}.`, 'error');
|
|
51
50
|
function ChartsYReferenceLine(props) {
|
|
52
51
|
const {
|
|
53
52
|
y,
|
|
@@ -67,7 +66,7 @@ function ChartsYReferenceLine(props) {
|
|
|
67
66
|
const yPosition = yAxisScale(y);
|
|
68
67
|
if (yPosition === undefined) {
|
|
69
68
|
if (process.env.NODE_ENV !== 'production') {
|
|
70
|
-
|
|
69
|
+
warnOnce(`MUI X: the value ${y} does not exist in the data of y axis with id ${axisId}.`, 'error');
|
|
71
70
|
}
|
|
72
71
|
return null;
|
|
73
72
|
}
|
package/esm/ChartsSurface.js
CHANGED
|
@@ -21,6 +21,7 @@ const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props
|
|
|
21
21
|
height,
|
|
22
22
|
viewBox,
|
|
23
23
|
disableAxisListener = false,
|
|
24
|
+
className,
|
|
24
25
|
title,
|
|
25
26
|
desc
|
|
26
27
|
} = props,
|
|
@@ -36,7 +37,8 @@ const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props
|
|
|
36
37
|
width: width,
|
|
37
38
|
height: height,
|
|
38
39
|
viewBox: `${svgView.x} ${svgView.y} ${svgView.width} ${svgView.height}`,
|
|
39
|
-
ref: ref
|
|
40
|
+
ref: ref,
|
|
41
|
+
className: className
|
|
40
42
|
}, other, {
|
|
41
43
|
children: [/*#__PURE__*/_jsx("title", {
|
|
42
44
|
children: title
|
|
@@ -40,11 +40,15 @@ function ChartsAxisTooltipContent(props) {
|
|
|
40
40
|
Object.keys(series).filter(isCartesianSeriesType).forEach(seriesType => {
|
|
41
41
|
series[seriesType].seriesOrder.forEach(seriesId => {
|
|
42
42
|
const item = series[seriesType].series[seriesId];
|
|
43
|
-
const
|
|
43
|
+
const providedXAxisId = item.xAxisId ?? item.xAxisKey;
|
|
44
|
+
const providedYAxisId = item.yAxisId ?? item.yAxisKey;
|
|
45
|
+
const axisKey = isXaxis ? providedXAxisId : providedYAxisId;
|
|
44
46
|
if (axisKey === undefined || axisKey === USED_AXIS_ID) {
|
|
45
47
|
const seriesToAdd = series[seriesType].series[seriesId];
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
+
const xAxisId = providedXAxisId ?? xAxisIds[0];
|
|
49
|
+
const yAxisId = providedYAxisId ?? yAxisIds[0];
|
|
50
|
+
const zAxisId = seriesToAdd.zAxisId ?? seriesToAdd.zAxisKey ?? zAxisIds[0];
|
|
51
|
+
const getColor = colorProcessors[seriesType]?.(seriesToAdd, xAxis[xAxisId], yAxis[yAxisId], zAxisId && zAxis[zAxisId]) ?? (() => '');
|
|
48
52
|
rep.push(_extends({}, seriesToAdd, {
|
|
49
53
|
getColor
|
|
50
54
|
}));
|
|
@@ -30,10 +30,10 @@ function ChartsItemTooltipContent(props) {
|
|
|
30
30
|
zAxisIds
|
|
31
31
|
} = React.useContext(ZAxisContext);
|
|
32
32
|
const colorProcessors = useColorProcessor();
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const getColor = colorProcessors[series.type]?.(series,
|
|
33
|
+
const xAxisId = series.xAxisId ?? series.xAxisKey ?? xAxisIds[0];
|
|
34
|
+
const yAxisId = series.yAxisId ?? series.yAxisKey ?? yAxisIds[0];
|
|
35
|
+
const zAxisId = series.zAxisId ?? series.zAxisKey ?? zAxisIds[0];
|
|
36
|
+
const getColor = colorProcessors[series.type]?.(series, xAxisId && xAxis[xAxisId], yAxisId && yAxis[yAxisId], zAxisId && zAxis[zAxisId]) ?? (() => '');
|
|
37
37
|
const Content = content ?? DefaultChartsItemTooltipContent;
|
|
38
38
|
const chartTooltipContentProps = useSlotProps({
|
|
39
39
|
elementType: Content,
|
|
@@ -16,12 +16,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
16
16
|
onItemClick
|
|
17
17
|
} = props;
|
|
18
18
|
const svgRef = useSvgRef();
|
|
19
|
-
const
|
|
20
|
-
left,
|
|
21
|
-
top,
|
|
22
|
-
width,
|
|
23
|
-
height
|
|
24
|
-
} = useDrawingArea();
|
|
19
|
+
const drawingArea = useDrawingArea();
|
|
25
20
|
const {
|
|
26
21
|
xAxis,
|
|
27
22
|
yAxis,
|
|
@@ -37,6 +32,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
37
32
|
} = useScatterSeries() ?? {};
|
|
38
33
|
const voronoiRef = React.useRef({});
|
|
39
34
|
const delauneyRef = React.useRef(undefined);
|
|
35
|
+
const lastFind = React.useRef(undefined);
|
|
40
36
|
const {
|
|
41
37
|
setHighlighted,
|
|
42
38
|
clearHighlighted
|
|
@@ -67,17 +63,32 @@ function ChartsVoronoiHandler(props) {
|
|
|
67
63
|
seriesOrder.forEach(seriesId => {
|
|
68
64
|
const {
|
|
69
65
|
data,
|
|
66
|
+
xAxisId,
|
|
67
|
+
yAxisId,
|
|
70
68
|
xAxisKey,
|
|
71
69
|
yAxisKey
|
|
72
70
|
} = series[seriesId];
|
|
73
|
-
const xScale = xAxis[xAxisKey ?? defaultXAxisId].scale;
|
|
74
|
-
const yScale = yAxis[yAxisKey ?? defaultYAxisId].scale;
|
|
71
|
+
const xScale = xAxis[xAxisId ?? xAxisKey ?? defaultXAxisId].scale;
|
|
72
|
+
const yScale = yAxis[yAxisId ?? yAxisKey ?? defaultYAxisId].scale;
|
|
75
73
|
const getXPosition = getValueToPositionMapper(xScale);
|
|
76
74
|
const getYPosition = getValueToPositionMapper(yScale);
|
|
77
75
|
const seriesPoints = data.flatMap(({
|
|
78
76
|
x,
|
|
79
77
|
y
|
|
80
|
-
}) =>
|
|
78
|
+
}) => {
|
|
79
|
+
const pointX = getXPosition(x);
|
|
80
|
+
const pointY = getYPosition(y);
|
|
81
|
+
if (!drawingArea.isPointInside({
|
|
82
|
+
x: pointX,
|
|
83
|
+
y: pointY
|
|
84
|
+
})) {
|
|
85
|
+
// If the point is not displayed we move them to a trash coordinate.
|
|
86
|
+
// This avoids managing index mapping before/after filtering.
|
|
87
|
+
// The trash point is far enough such that any point in the drawing area will be closer to the mouse than the trash coordinate.
|
|
88
|
+
return [-drawingArea.width, -drawingArea.height];
|
|
89
|
+
}
|
|
90
|
+
return [pointX, pointY];
|
|
91
|
+
});
|
|
81
92
|
voronoiRef.current[seriesId] = {
|
|
82
93
|
seriesId,
|
|
83
94
|
startIndex: points.length,
|
|
@@ -86,29 +97,28 @@ function ChartsVoronoiHandler(props) {
|
|
|
86
97
|
points = points.concat(seriesPoints);
|
|
87
98
|
});
|
|
88
99
|
delauneyRef.current = new Delaunay(points);
|
|
89
|
-
|
|
100
|
+
lastFind.current = undefined;
|
|
101
|
+
}, [defaultXAxisId, defaultYAxisId, series, seriesOrder, xAxis, yAxis, drawingArea]);
|
|
90
102
|
React.useEffect(() => {
|
|
91
103
|
const element = svgRef.current;
|
|
92
104
|
if (element === null) {
|
|
93
105
|
return undefined;
|
|
94
106
|
}
|
|
95
|
-
|
|
96
|
-
// TODO: A perf optimisation of voronoi could be to use the last point as the initial point for the next search.
|
|
97
107
|
function getClosestPoint(event) {
|
|
98
108
|
// Get mouse coordinate in global SVG space
|
|
99
109
|
const svgPoint = getSVGPoint(element, event);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (outsideX || outsideY) {
|
|
110
|
+
if (!drawingArea.isPointInside(svgPoint)) {
|
|
111
|
+
lastFind.current = undefined;
|
|
103
112
|
return 'outside-chart';
|
|
104
113
|
}
|
|
105
114
|
if (!delauneyRef.current) {
|
|
106
115
|
return 'no-point-found';
|
|
107
116
|
}
|
|
108
|
-
const closestPointIndex = delauneyRef.current.find(svgPoint.x, svgPoint.y);
|
|
117
|
+
const closestPointIndex = delauneyRef.current.find(svgPoint.x, svgPoint.y, lastFind.current);
|
|
109
118
|
if (closestPointIndex === undefined) {
|
|
110
119
|
return 'no-point-found';
|
|
111
120
|
}
|
|
121
|
+
lastFind.current = closestPointIndex;
|
|
112
122
|
const closestSeries = Object.values(voronoiRef.current).find(value => {
|
|
113
123
|
return 2 * closestPointIndex >= value.startIndex && 2 * closestPointIndex < value.endIndex;
|
|
114
124
|
});
|
|
@@ -130,7 +140,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
130
140
|
dataIndex
|
|
131
141
|
};
|
|
132
142
|
}
|
|
133
|
-
const
|
|
143
|
+
const handleMouseLeave = () => {
|
|
134
144
|
dispatch({
|
|
135
145
|
type: 'exitChart'
|
|
136
146
|
});
|
|
@@ -191,15 +201,15 @@ function ChartsVoronoiHandler(props) {
|
|
|
191
201
|
dataIndex
|
|
192
202
|
});
|
|
193
203
|
};
|
|
194
|
-
element.addEventListener('
|
|
204
|
+
element.addEventListener('pointerleave', handleMouseLeave);
|
|
195
205
|
element.addEventListener('pointermove', handleMouseMove);
|
|
196
206
|
element.addEventListener('click', handleMouseClick);
|
|
197
207
|
return () => {
|
|
198
|
-
element.removeEventListener('
|
|
208
|
+
element.removeEventListener('pointerleave', handleMouseLeave);
|
|
199
209
|
element.removeEventListener('pointermove', handleMouseMove);
|
|
200
210
|
element.removeEventListener('click', handleMouseClick);
|
|
201
211
|
};
|
|
202
|
-
}, [svgRef, dispatch,
|
|
212
|
+
}, [svgRef, dispatch, yAxis, xAxis, voronoiMaxRadius, onItemClick, setHighlighted, clearHighlighted, drawingArea]);
|
|
203
213
|
|
|
204
214
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
205
215
|
return /*#__PURE__*/_jsx(React.Fragment, {});
|
|
@@ -212,7 +212,7 @@ function ChartsXAxis(inProps) {
|
|
|
212
212
|
x1: left,
|
|
213
213
|
x2: left + width,
|
|
214
214
|
className: classes.line
|
|
215
|
-
}, slotProps?.axisLine)), xTicksWithDimension.
|
|
215
|
+
}, slotProps?.axisLine)), xTicksWithDimension.map(({
|
|
216
216
|
formattedValue,
|
|
217
217
|
offset,
|
|
218
218
|
labelOffset,
|
|
@@ -136,6 +136,14 @@ function ChartsYAxis(inProps) {
|
|
|
136
136
|
},
|
|
137
137
|
ownerState: {}
|
|
138
138
|
});
|
|
139
|
+
const lineSlotProps = useSlotProps({
|
|
140
|
+
elementType: Line,
|
|
141
|
+
externalSlotProps: slotProps?.axisLine,
|
|
142
|
+
additionalProps: {
|
|
143
|
+
strokeLinecap: 'square'
|
|
144
|
+
},
|
|
145
|
+
ownerState: {}
|
|
146
|
+
});
|
|
139
147
|
const domain = yScale.domain();
|
|
140
148
|
if (domain.length === 0 || domain[0] === domain[1]) {
|
|
141
149
|
// Skip axis rendering if
|
|
@@ -147,10 +155,10 @@ function ChartsYAxis(inProps) {
|
|
|
147
155
|
transform: `translate(${position === 'right' ? left + width : left}, 0)`,
|
|
148
156
|
className: classes.root,
|
|
149
157
|
children: [!disableLine && /*#__PURE__*/_jsx(Line, _extends({
|
|
150
|
-
y1:
|
|
151
|
-
y2:
|
|
158
|
+
y1: top,
|
|
159
|
+
y2: top + height,
|
|
152
160
|
className: classes.line
|
|
153
|
-
},
|
|
161
|
+
}, lineSlotProps)), yTicks.map(({
|
|
154
162
|
formattedValue,
|
|
155
163
|
offset,
|
|
156
164
|
labelOffset,
|
|
@@ -159,6 +167,10 @@ function ChartsYAxis(inProps) {
|
|
|
159
167
|
const xTickLabel = positionSign * (tickSize + 2);
|
|
160
168
|
const yTickLabel = labelOffset;
|
|
161
169
|
const skipLabel = typeof tickLabelInterval === 'function' && !tickLabelInterval?.(value, index);
|
|
170
|
+
const showLabel = offset >= top - 1 && offset <= height + top + 1;
|
|
171
|
+
if (!showLabel) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
162
174
|
return /*#__PURE__*/_jsxs("g", {
|
|
163
175
|
transform: `translate(0, ${offset})`,
|
|
164
176
|
className: classes.tickContainer,
|
package/esm/Gauge/Gauge.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["text", "children", "classes"];
|
|
3
|
+
const _excluded = ["text", "children", "classes", "className"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
7
|
+
import clsx from 'clsx';
|
|
7
8
|
import { GaugeContainer } from './GaugeContainer';
|
|
8
9
|
import { GaugeValueArc } from './GaugeValueArc';
|
|
9
10
|
import { GaugeReferenceArc } from './GaugeReferenceArc';
|
|
@@ -22,15 +23,17 @@ const useUtilityClasses = props => {
|
|
|
22
23
|
};
|
|
23
24
|
return composeClasses(slots, getGaugeUtilityClass, classes);
|
|
24
25
|
};
|
|
25
|
-
function Gauge(props) {
|
|
26
|
+
const Gauge = /*#__PURE__*/React.forwardRef(function Gauge(props, ref) {
|
|
26
27
|
const {
|
|
27
28
|
text,
|
|
28
|
-
children
|
|
29
|
+
children,
|
|
30
|
+
className
|
|
29
31
|
} = props,
|
|
30
32
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
31
33
|
const classes = useUtilityClasses(props);
|
|
32
34
|
return /*#__PURE__*/_jsxs(GaugeContainer, _extends({}, other, {
|
|
33
|
-
className: classes.root,
|
|
35
|
+
className: clsx(classes.root, className),
|
|
36
|
+
ref: ref,
|
|
34
37
|
children: [/*#__PURE__*/_jsx(GaugeReferenceArc, {
|
|
35
38
|
className: classes.referenceArc
|
|
36
39
|
}), /*#__PURE__*/_jsx(GaugeValueArc, {
|
|
@@ -40,7 +43,7 @@ function Gauge(props) {
|
|
|
40
43
|
text: text
|
|
41
44
|
}), children]
|
|
42
45
|
}));
|
|
43
|
-
}
|
|
46
|
+
});
|
|
44
47
|
process.env.NODE_ENV !== "production" ? Gauge.propTypes = {
|
|
45
48
|
// ----------------------------- Warning --------------------------------
|
|
46
49
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -3,8 +3,8 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["width", "height", "margin", "title", "desc", "value", "valueMin", "valueMax", "startAngle", "endAngle", "outerRadius", "innerRadius", "cornerRadius", "cx", "cy", "children"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import useForkRef from '@mui/utils/useForkRef';
|
|
7
6
|
import { styled } from '@mui/material/styles';
|
|
7
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
8
8
|
import { useChartContainerDimensions } from '../ResponsiveChartContainer/useChartContainerDimensions';
|
|
9
9
|
import { ChartsSurface } from '../ChartsSurface';
|
|
10
10
|
import { DrawingProvider } from '../context/DrawingProvider';
|
|
@@ -54,9 +54,13 @@ const GaugeContainer = /*#__PURE__*/React.forwardRef(function GaugeContainer(pro
|
|
|
54
54
|
children
|
|
55
55
|
} = props,
|
|
56
56
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
57
|
-
const
|
|
57
|
+
const {
|
|
58
|
+
containerRef,
|
|
59
|
+
width,
|
|
60
|
+
height
|
|
61
|
+
} = useChartContainerDimensions(inWidth, inHeight);
|
|
58
62
|
const svgRef = React.useRef(null);
|
|
59
|
-
const
|
|
63
|
+
const chartSurfaceRef = useForkRef(ref, svgRef);
|
|
60
64
|
return /*#__PURE__*/_jsx(ResizableContainer, _extends({
|
|
61
65
|
ref: containerRef,
|
|
62
66
|
ownerState: {
|
|
@@ -92,7 +96,7 @@ const GaugeContainer = /*#__PURE__*/React.forwardRef(function GaugeContainer(pro
|
|
|
92
96
|
children: /*#__PURE__*/_jsx(ChartsSurface, {
|
|
93
97
|
width: width,
|
|
94
98
|
height: height,
|
|
95
|
-
ref:
|
|
99
|
+
ref: chartSurfaceRef,
|
|
96
100
|
title: title,
|
|
97
101
|
desc: desc,
|
|
98
102
|
disableAxisListener: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ignore - do not document.
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { getPercentageValue } from '../internals/
|
|
3
|
+
import { getPercentageValue } from '../internals/getPercentageValue';
|
|
4
4
|
import { getArcRatios, getAvailableRadius } from './utils';
|
|
5
5
|
import { useDrawingArea } from '../hooks/useDrawingArea';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -7,7 +7,7 @@ import { styled } from '@mui/material/styles';
|
|
|
7
7
|
import { color as d3Color } from 'd3-color';
|
|
8
8
|
import { animated, useSpring } from '@react-spring/web';
|
|
9
9
|
import { useAnimatedPath } from '../internals/useAnimatedPath';
|
|
10
|
-
import { cleanId } from '../internals/
|
|
10
|
+
import { cleanId } from '../internals/cleanId';
|
|
11
11
|
import { useChartId, useDrawingArea } from '../hooks';
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
export const AreaElementPath = styled(animated.path, {
|
|
@@ -7,7 +7,7 @@ import { animated, useSpring } from '@react-spring/web';
|
|
|
7
7
|
import { color as d3Color } from 'd3-color';
|
|
8
8
|
import { styled } from '@mui/material/styles';
|
|
9
9
|
import { useAnimatedPath } from '../internals/useAnimatedPath';
|
|
10
|
-
import { cleanId } from '../internals/
|
|
10
|
+
import { cleanId } from '../internals/cleanId';
|
|
11
11
|
import { useChartId } from '../hooks/useChartId';
|
|
12
12
|
import { useDrawingArea } from '../hooks/useDrawingArea';
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -36,22 +36,26 @@ const useAggregatedData = () => {
|
|
|
36
36
|
return [...groupIds].reverse() // Revert stacked area for a more pleasant animation
|
|
37
37
|
.map(seriesId => {
|
|
38
38
|
const {
|
|
39
|
+
xAxisId: xAxisIdProp,
|
|
40
|
+
yAxisId: yAxisIdProp,
|
|
39
41
|
xAxisKey = defaultXAxisId,
|
|
40
42
|
yAxisKey = defaultYAxisId,
|
|
41
43
|
stackedData,
|
|
42
44
|
data,
|
|
43
45
|
connectNulls
|
|
44
46
|
} = series[seriesId];
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
47
|
+
const xAxisId = xAxisIdProp ?? xAxisKey;
|
|
48
|
+
const yAxisId = yAxisIdProp ?? yAxisKey;
|
|
49
|
+
const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
|
|
50
|
+
const yScale = yAxis[yAxisId].scale;
|
|
51
|
+
const xData = xAxis[xAxisId].data;
|
|
52
|
+
const gradientUsed = yAxis[yAxisId].colorScale && [yAxisId, 'y'] || xAxis[xAxisId].colorScale && [xAxisId, 'x'] || undefined;
|
|
49
53
|
if (process.env.NODE_ENV !== 'production') {
|
|
50
54
|
if (xData === undefined) {
|
|
51
|
-
throw new Error(`MUI X
|
|
55
|
+
throw new Error(`MUI X: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
|
|
52
56
|
}
|
|
53
57
|
if (xData.length < stackedData.length) {
|
|
54
|
-
throw new Error(`MUI X
|
|
58
|
+
throw new Error(`MUI X: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
const areaPath = d3Area().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y0(d => {
|
|
@@ -48,8 +48,11 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
48
48
|
ref: ref
|
|
49
49
|
}, chartContainerProps, {
|
|
50
50
|
children: [props.onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, _extends({}, axisClickHandlerProps)), props.grid && /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsxs("g", _extends({}, clipPathGroupProps, {
|
|
51
|
-
children: [/*#__PURE__*/_jsx(AreaPlot, _extends({}, areaPlotProps)), /*#__PURE__*/_jsx(LinePlot, _extends({}, linePlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps))]
|
|
52
|
-
})), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(
|
|
51
|
+
children: [/*#__PURE__*/_jsx(AreaPlot, _extends({}, areaPlotProps)), /*#__PURE__*/_jsx(LinePlot, _extends({}, linePlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps))]
|
|
52
|
+
})), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx("g", {
|
|
53
|
+
"data-drawing-container": true,
|
|
54
|
+
children: /*#__PURE__*/_jsx(MarkPlot, _extends({}, markPlotProps))
|
|
55
|
+
}), /*#__PURE__*/_jsx(LineHighlightPlot, _extends({}, lineHighlightPlotProps)), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), !props.loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltipProps)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), children]
|
|
53
56
|
}));
|
|
54
57
|
});
|
|
55
58
|
process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
@@ -10,6 +10,7 @@ import { InteractionContext } from '../context/InteractionProvider';
|
|
|
10
10
|
import { DEFAULT_X_AXIS_KEY } from '../constants';
|
|
11
11
|
import getColor from './getColor';
|
|
12
12
|
import { useLineSeries } from '../hooks/useSeries';
|
|
13
|
+
import { useDrawingArea } from '../hooks/useDrawingArea';
|
|
13
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
15
|
/**
|
|
15
16
|
* Demos:
|
|
@@ -29,6 +30,7 @@ function LineHighlightPlot(props) {
|
|
|
29
30
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
30
31
|
const seriesData = useLineSeries();
|
|
31
32
|
const axisData = useCartesianContext();
|
|
33
|
+
const drawingArea = useDrawingArea();
|
|
32
34
|
const {
|
|
33
35
|
axis
|
|
34
36
|
} = React.useContext(InteractionContext);
|
|
@@ -58,25 +60,35 @@ function LineHighlightPlot(props) {
|
|
|
58
60
|
}) => {
|
|
59
61
|
return groupIds.flatMap(seriesId => {
|
|
60
62
|
const {
|
|
63
|
+
xAxisId: xAxisIdProp,
|
|
64
|
+
yAxisId: yAxisIdProp,
|
|
61
65
|
xAxisKey = defaultXAxisId,
|
|
62
66
|
yAxisKey = defaultYAxisId,
|
|
63
67
|
stackedData,
|
|
64
68
|
data,
|
|
65
69
|
disableHighlight
|
|
66
70
|
} = series[seriesId];
|
|
71
|
+
const xAxisId = xAxisIdProp ?? xAxisKey;
|
|
72
|
+
const yAxisId = yAxisIdProp ?? yAxisKey;
|
|
67
73
|
if (disableHighlight || data[highlightedIndex] == null) {
|
|
68
74
|
return null;
|
|
69
75
|
}
|
|
70
|
-
const xScale = getValueToPositionMapper(xAxis[
|
|
71
|
-
const yScale = yAxis[
|
|
72
|
-
const xData = xAxis[
|
|
76
|
+
const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
|
|
77
|
+
const yScale = yAxis[yAxisId].scale;
|
|
78
|
+
const xData = xAxis[xAxisId].data;
|
|
73
79
|
if (xData === undefined) {
|
|
74
|
-
throw new Error(`MUI X
|
|
80
|
+
throw new Error(`MUI X: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
|
|
75
81
|
}
|
|
76
82
|
const x = xScale(xData[highlightedIndex]);
|
|
77
83
|
const y = yScale(stackedData[highlightedIndex][1]); // This should not be undefined since y should not be a band scale
|
|
78
84
|
|
|
79
|
-
|
|
85
|
+
if (!drawingArea.isPointInside({
|
|
86
|
+
x,
|
|
87
|
+
y
|
|
88
|
+
})) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const colorGetter = getColor(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
|
|
80
92
|
return /*#__PURE__*/_jsx(Element, _extends({
|
|
81
93
|
id: seriesId,
|
|
82
94
|
color: colorGetter(highlightedIndex),
|
|
@@ -35,22 +35,26 @@ const useAggregatedData = () => {
|
|
|
35
35
|
}) => {
|
|
36
36
|
return groupIds.flatMap(seriesId => {
|
|
37
37
|
const {
|
|
38
|
+
xAxisId: xAxisIdProp,
|
|
39
|
+
yAxisId: yAxisIdProp,
|
|
38
40
|
xAxisKey = defaultXAxisId,
|
|
39
41
|
yAxisKey = defaultYAxisId,
|
|
40
42
|
stackedData,
|
|
41
43
|
data,
|
|
42
44
|
connectNulls
|
|
43
45
|
} = series[seriesId];
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
46
|
+
const xAxisId = xAxisIdProp ?? xAxisKey;
|
|
47
|
+
const yAxisId = yAxisIdProp ?? yAxisKey;
|
|
48
|
+
const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
|
|
49
|
+
const yScale = yAxis[yAxisId].scale;
|
|
50
|
+
const xData = xAxis[xAxisId].data;
|
|
51
|
+
const gradientUsed = yAxis[yAxisId].colorScale && [yAxisId, 'y'] || xAxis[xAxisId].colorScale && [xAxisId, 'x'] || undefined;
|
|
48
52
|
if (process.env.NODE_ENV !== 'production') {
|
|
49
53
|
if (xData === undefined) {
|
|
50
|
-
throw new Error(`MUI X
|
|
54
|
+
throw new Error(`MUI X: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
|
|
51
55
|
}
|
|
52
56
|
if (xData.length < stackedData.length) {
|
|
53
|
-
throw new Error(`MUI X
|
|
57
|
+
throw new Error(`MUI X: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
60
|
const linePath = d3Line().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y(d => yScale(d.y[1]));
|
|
@@ -9,7 +9,7 @@ import { styled } from '@mui/material/styles';
|
|
|
9
9
|
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
10
10
|
import { symbol as d3Symbol, symbolsFill as d3SymbolsFill } from 'd3-shape';
|
|
11
11
|
import { animated, to, useSpring } from '@react-spring/web';
|
|
12
|
-
import { getSymbol } from '../internals/
|
|
12
|
+
import { getSymbol } from '../internals/getSymbol';
|
|
13
13
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
14
14
|
import { useInteractionItemProps } from '../hooks/useInteractionItemProps';
|
|
15
15
|
import { useItemHighlighted } from '../context';
|
|
@@ -8,7 +8,7 @@ import { MarkElement } from './MarkElement';
|
|
|
8
8
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
9
9
|
import { useChartId } from '../hooks/useChartId';
|
|
10
10
|
import { DEFAULT_X_AXIS_KEY } from '../constants';
|
|
11
|
-
import { cleanId } from '../internals/
|
|
11
|
+
import { cleanId } from '../internals/cleanId';
|
|
12
12
|
import getColor from './getColor';
|
|
13
13
|
import { useLineSeries } from '../hooks/useSeries';
|
|
14
14
|
import { useDrawingArea } from '../hooks/useDrawingArea';
|
|
@@ -34,10 +34,7 @@ function MarkPlot(props) {
|
|
|
34
34
|
const seriesData = useLineSeries();
|
|
35
35
|
const axisData = useCartesianContext();
|
|
36
36
|
const chartId = useChartId();
|
|
37
|
-
const
|
|
38
|
-
left,
|
|
39
|
-
width
|
|
40
|
-
} = useDrawingArea();
|
|
37
|
+
const drawingArea = useDrawingArea();
|
|
41
38
|
const Mark = slots?.mark ?? MarkElement;
|
|
42
39
|
if (seriesData === undefined) {
|
|
43
40
|
return null;
|
|
@@ -60,6 +57,8 @@ function MarkPlot(props) {
|
|
|
60
57
|
}) => {
|
|
61
58
|
return groupIds.map(seriesId => {
|
|
62
59
|
const {
|
|
60
|
+
xAxisId: xAxisIdProp,
|
|
61
|
+
yAxisId: yAxisIdProp,
|
|
63
62
|
xAxisKey = defaultXAxisId,
|
|
64
63
|
yAxisKey = defaultYAxisId,
|
|
65
64
|
stackedData,
|
|
@@ -69,28 +68,17 @@ function MarkPlot(props) {
|
|
|
69
68
|
if (showMark === false) {
|
|
70
69
|
return null;
|
|
71
70
|
}
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
x,
|
|
78
|
-
y
|
|
79
|
-
}) => {
|
|
80
|
-
if (x < left || x > left + width) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
if (y < Math.min(...yRange) || y > Math.max(...yRange)) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
return true;
|
|
87
|
-
};
|
|
71
|
+
const xAxisId = xAxisIdProp ?? xAxisKey;
|
|
72
|
+
const yAxisId = yAxisIdProp ?? yAxisKey;
|
|
73
|
+
const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
|
|
74
|
+
const yScale = yAxis[yAxisId].scale;
|
|
75
|
+
const xData = xAxis[xAxisId].data;
|
|
88
76
|
if (xData === undefined) {
|
|
89
|
-
throw new Error(`MUI X
|
|
77
|
+
throw new Error(`MUI X: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
|
|
90
78
|
}
|
|
91
79
|
const clipId = cleanId(`${chartId}-${seriesId}-line-clip`); // We assume that if displaying line mark, the line will also be rendered
|
|
92
80
|
|
|
93
|
-
const colorGetter = getColor(series[seriesId], xAxis[
|
|
81
|
+
const colorGetter = getColor(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
|
|
94
82
|
return /*#__PURE__*/_jsx("g", {
|
|
95
83
|
clipPath: `url(#${clipId})`,
|
|
96
84
|
children: xData?.map((x, index) => {
|
|
@@ -113,7 +101,7 @@ function MarkPlot(props) {
|
|
|
113
101
|
// Remove missing data point
|
|
114
102
|
return false;
|
|
115
103
|
}
|
|
116
|
-
if (!
|
|
104
|
+
if (!drawingArea.isPointInside({
|
|
117
105
|
x,
|
|
118
106
|
y
|
|
119
107
|
})) {
|
|
@@ -24,7 +24,10 @@ export const getExtremumY = params => {
|
|
|
24
24
|
axis,
|
|
25
25
|
isDefaultAxis
|
|
26
26
|
} = params;
|
|
27
|
-
return Object.keys(series).filter(seriesId =>
|
|
27
|
+
return Object.keys(series).filter(seriesId => {
|
|
28
|
+
const yAxisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey;
|
|
29
|
+
return yAxisId === axis.id || isDefaultAxis && yAxisId === undefined;
|
|
30
|
+
}).reduce((acc, seriesId) => {
|
|
28
31
|
const {
|
|
29
32
|
area,
|
|
30
33
|
stackedData
|
|
@@ -31,7 +31,7 @@ const formatter = (params, dataset) => {
|
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
} else if (dataset === undefined && process.env.NODE_ENV !== 'production') {
|
|
34
|
-
throw new Error([`MUI X
|
|
34
|
+
throw new Error([`MUI X: line series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
const completedSeries = {};
|
|
@@ -56,7 +56,7 @@ const formatter = (params, dataset) => {
|
|
|
56
56
|
if (typeof value !== 'number') {
|
|
57
57
|
if (process.env.NODE_ENV !== 'production' && !warnedOnce && value !== null) {
|
|
58
58
|
warnedOnce = true;
|
|
59
|
-
console.error([`MUI
|
|
59
|
+
console.error([`MUI X: Your dataset key "${dataKey}" is used for plotting line, but contains nonnumerical elements.`, 'Line plots only support numbers and null values.']);
|
|
60
60
|
}
|
|
61
61
|
return null;
|
|
62
62
|
}
|