@mui/x-charts 7.2.0 → 7.3.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.d.ts +1 -0
- package/BarChart/BarChart.js +40 -99
- package/BarChart/BarElement.d.ts +63 -62
- package/BarChart/BarElement.js +1 -2
- package/BarChart/BarPlot.js +14 -7
- package/BarChart/getColor.d.ts +3 -0
- package/BarChart/getColor.js +33 -0
- package/CHANGELOG.md +204 -2
- package/ChartContainer/ChartContainer.js +38 -5
- package/ChartsAxis/ChartsAxis.js +11 -103
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/ChartsClipPath/ChartsClipPath.js +3 -3
- package/ChartsGrid/ChartsGrid.js +1 -1
- package/ChartsLegend/ChartsLegend.js +3 -3
- package/ChartsLegend/DefaultChartsLegend.js +1 -1
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
- package/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/ChartsSurface.js +1 -1
- package/ChartsText/ChartsText.js +1 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +4 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +21 -3
- package/ChartsTooltip/ChartsItemTooltipContent.d.ts +6 -0
- package/ChartsTooltip/ChartsItemTooltipContent.js +32 -2
- package/ChartsTooltip/ChartsTooltip.js +1 -1
- package/ChartsTooltip/ChartsTooltipTable.d.ts +3 -7
- package/ChartsTooltip/ChartsTooltipTable.js +8 -9
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -7
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +15 -8
- package/ChartsTooltip/utils.d.ts +5 -1
- package/ChartsTooltip/utils.js +1 -1
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +7 -7
- package/ChartsXAxis/ChartsXAxis.js +3 -3
- package/ChartsYAxis/ChartsYAxis.js +3 -3
- package/Gauge/Gauge.js +1 -1
- package/Gauge/GaugeContainer.js +1 -1
- package/Gauge/GaugeProvider.js +6 -6
- package/Gauge/GaugeReferenceArc.js +1 -1
- package/Gauge/GaugeValueArc.js +1 -1
- package/Gauge/GaugeValueText.js +1 -1
- package/LineChart/AnimatedArea.d.ts +63 -62
- package/LineChart/AnimatedArea.js +7 -6
- package/LineChart/AnimatedLine.d.ts +63 -62
- package/LineChart/AnimatedLine.js +8 -6
- package/LineChart/AreaElement.d.ts +1 -0
- package/LineChart/AreaElement.js +5 -2
- package/LineChart/AreaPlot.js +8 -2
- package/LineChart/LineChart.d.ts +1 -0
- package/LineChart/LineChart.js +40 -99
- package/LineChart/LineElement.d.ts +1 -0
- package/LineChart/LineElement.js +5 -2
- package/LineChart/LineHighlightElement.js +1 -1
- package/LineChart/LineHighlightPlot.js +5 -2
- package/LineChart/LinePlot.js +8 -2
- package/LineChart/MarkElement.js +1 -1
- package/LineChart/MarkPlot.js +6 -6
- package/LineChart/getColor.d.ts +3 -0
- package/LineChart/getColor.js +31 -0
- package/PieChart/PieArc.d.ts +1 -0
- package/PieChart/PieArc.js +1 -1
- package/PieChart/PieArcLabel.d.ts +1 -0
- package/PieChart/PieArcLabel.js +1 -1
- package/PieChart/PieArcLabelPlot.js +1 -1
- package/PieChart/PieArcPlot.js +1 -1
- package/PieChart/PieChart.d.ts +1 -0
- package/PieChart/PieChart.js +40 -99
- package/PieChart/PiePlot.js +27 -7
- package/PieChart/dataTransform/transition.d.ts +1 -0
- package/PieChart/dataTransform/useTransformData.js +1 -1
- package/PieChart/formatter.js +4 -2
- package/PieChart/getColor.d.ts +2 -0
- package/PieChart/getColor.js +11 -0
- package/PieChart/getPieCoordinates.d.ts +7 -0
- package/PieChart/getPieCoordinates.js +25 -0
- package/PieChart/index.d.ts +1 -0
- package/PieChart/index.js +11 -0
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +35 -3
- package/ResponsiveChartContainer/useChartContainerDimensions.js +1 -1
- package/ScatterChart/Scatter.d.ts +1 -0
- package/ScatterChart/Scatter.js +7 -4
- package/ScatterChart/ScatterChart.d.ts +3 -1
- package/ScatterChart/ScatterChart.js +95 -126
- package/ScatterChart/ScatterPlot.js +11 -1
- package/ScatterChart/getColor.d.ts +4 -0
- package/ScatterChart/getColor.js +48 -0
- package/SparkLineChart/SparkLineChart.js +16 -1
- package/context/CartesianContextProvider.d.ts +4 -3
- package/context/CartesianContextProvider.js +24 -9
- package/context/DrawingProvider.js +1 -1
- package/context/HighlightProvider.js +1 -1
- package/context/InteractionProvider.js +1 -1
- package/context/SeriesContextProvider.js +1 -1
- package/context/ZAxisContextProvider.d.ts +33 -0
- package/context/ZAxisContextProvider.js +98 -0
- package/context/index.d.ts +2 -0
- package/context/index.js +8 -1
- package/esm/BarChart/BarChart.js +40 -100
- package/esm/BarChart/BarElement.js +0 -1
- package/esm/BarChart/BarPlot.js +15 -7
- package/esm/BarChart/getColor.js +27 -0
- package/esm/ChartContainer/ChartContainer.js +38 -5
- package/esm/ChartsAxis/ChartsAxis.js +11 -104
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -2
- package/esm/ChartsClipPath/ChartsClipPath.js +2 -2
- package/esm/ChartsGrid/ChartsGrid.js +1 -2
- package/esm/ChartsLegend/ChartsLegend.js +2 -2
- package/esm/ChartsLegend/DefaultChartsLegend.js +1 -2
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
- package/esm/ChartsSurface.js +1 -2
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +20 -2
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +31 -1
- package/esm/ChartsTooltip/ChartsTooltipTable.js +8 -8
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -8
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +15 -9
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
- package/esm/ChartsXAxis/ChartsXAxis.js +3 -4
- package/esm/ChartsYAxis/ChartsYAxis.js +3 -4
- package/esm/Gauge/Gauge.js +1 -2
- package/esm/Gauge/GaugeProvider.js +5 -5
- package/esm/LineChart/AnimatedArea.js +7 -7
- package/esm/LineChart/AnimatedLine.js +8 -7
- package/esm/LineChart/AreaElement.js +4 -1
- package/esm/LineChart/AreaPlot.js +7 -1
- package/esm/LineChart/LineChart.js +40 -100
- package/esm/LineChart/LineElement.js +4 -1
- package/esm/LineChart/LineHighlightPlot.js +4 -1
- package/esm/LineChart/LinePlot.js +7 -1
- package/esm/LineChart/MarkPlot.js +5 -5
- package/esm/LineChart/getColor.js +25 -0
- package/esm/PieChart/PieChart.js +40 -100
- package/esm/PieChart/PiePlot.js +27 -8
- package/esm/PieChart/formatter.js +4 -2
- package/esm/PieChart/getColor.js +5 -0
- package/esm/PieChart/getPieCoordinates.js +19 -0
- package/esm/PieChart/index.js +2 -1
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +34 -2
- package/esm/ScatterChart/Scatter.js +6 -3
- package/esm/ScatterChart/ScatterChart.js +95 -127
- package/esm/ScatterChart/ScatterPlot.js +10 -0
- package/esm/ScatterChart/getColor.js +42 -0
- package/esm/SparkLineChart/SparkLineChart.js +16 -2
- package/esm/context/CartesianContextProvider.js +23 -8
- package/esm/context/ZAxisContextProvider.js +89 -0
- package/esm/context/index.js +1 -1
- package/esm/hooks/index.js +4 -1
- package/esm/hooks/useAxisEvents.js +7 -6
- package/esm/hooks/useChartId.js +8 -0
- package/esm/hooks/useSeries.js +64 -0
- package/esm/hooks/useSvgRef.js +9 -0
- package/esm/internals/colorGetter.js +22 -0
- package/esm/internals/colorScale.js +16 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +95 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +55 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +40 -0
- package/esm/internals/components/ChartsAxesGradients/index.js +1 -0
- package/esm/models/colorMapping.js +1 -0
- package/esm/models/seriesType/index.js +6 -1
- package/esm/models/z-axis.js +1 -0
- package/hooks/index.d.ts +3 -0
- package/hooks/index.js +65 -1
- package/hooks/useAxisEvents.js +8 -7
- package/hooks/useChartDimensions.js +1 -1
- package/hooks/useChartId.d.ts +1 -0
- package/hooks/useChartId.js +16 -0
- package/hooks/useDrawingArea.js +1 -1
- package/hooks/useInteractionItemProps.js +1 -1
- package/hooks/useMounted.js +1 -1
- package/hooks/useScale.js +1 -1
- package/hooks/useSeries.d.ts +45 -0
- package/hooks/useSeries.js +75 -0
- package/hooks/useSvgRef.d.ts +2 -0
- package/hooks/useSvgRef.js +17 -0
- package/hooks/useTicks.js +1 -1
- package/index.js +1 -1
- package/internals/colorGetter.d.ts +7 -0
- package/internals/colorGetter.js +29 -0
- package/internals/colorScale.d.ts +5 -0
- package/internals/colorScale.js +24 -0
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +3 -0
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +105 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +13 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +63 -0
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.d.ts +12 -0
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +48 -0
- package/internals/components/ChartsAxesGradients/index.d.ts +1 -0
- package/internals/components/ChartsAxesGradients/index.js +16 -0
- package/internals/defaultizeColor.d.ts +5 -4
- package/internals/defaultizeValueFormatter.d.ts +5 -5
- package/internals/getScale.d.ts +2 -2
- package/internals/useAnimatedPath.d.ts +1 -0
- package/internals/useAnimatedPath.js +1 -1
- package/models/axis.d.ts +44 -4
- package/models/colorMapping.d.ts +46 -0
- package/models/colorMapping.js +5 -0
- package/models/index.d.ts +1 -1
- package/models/seriesType/common.d.ts +10 -2
- package/models/seriesType/index.d.ts +2 -0
- package/models/seriesType/index.js +17 -1
- package/models/seriesType/pie.d.ts +5 -0
- package/models/seriesType/scatter.d.ts +5 -0
- package/models/z-axis.d.ts +14 -0
- package/models/z-axis.js +5 -0
- package/modern/BarChart/BarChart.js +40 -100
- package/modern/BarChart/BarElement.js +0 -1
- package/modern/BarChart/BarPlot.js +15 -7
- package/modern/BarChart/getColor.js +27 -0
- package/modern/ChartContainer/ChartContainer.js +38 -5
- package/modern/ChartsAxis/ChartsAxis.js +11 -104
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -2
- package/modern/ChartsClipPath/ChartsClipPath.js +2 -2
- package/modern/ChartsGrid/ChartsGrid.js +1 -2
- package/modern/ChartsLegend/ChartsLegend.js +2 -2
- package/modern/ChartsLegend/DefaultChartsLegend.js +1 -2
- package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
- package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
- package/modern/ChartsSurface.js +1 -2
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +20 -2
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +31 -1
- package/modern/ChartsTooltip/ChartsTooltipTable.js +8 -8
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -8
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +15 -9
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
- package/modern/ChartsXAxis/ChartsXAxis.js +3 -4
- package/modern/ChartsYAxis/ChartsYAxis.js +3 -4
- package/modern/Gauge/Gauge.js +1 -2
- package/modern/Gauge/GaugeProvider.js +5 -5
- package/modern/LineChart/AnimatedArea.js +7 -7
- package/modern/LineChart/AnimatedLine.js +8 -7
- package/modern/LineChart/AreaElement.js +4 -1
- package/modern/LineChart/AreaPlot.js +7 -1
- package/modern/LineChart/LineChart.js +40 -100
- package/modern/LineChart/LineElement.js +4 -1
- package/modern/LineChart/LineHighlightPlot.js +4 -1
- package/modern/LineChart/LinePlot.js +7 -1
- package/modern/LineChart/MarkPlot.js +5 -5
- package/modern/LineChart/getColor.js +25 -0
- package/modern/PieChart/PieChart.js +40 -100
- package/modern/PieChart/PiePlot.js +27 -8
- package/modern/PieChart/formatter.js +4 -2
- package/modern/PieChart/getColor.js +5 -0
- package/modern/PieChart/getPieCoordinates.js +19 -0
- package/modern/PieChart/index.js +2 -1
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +34 -2
- package/modern/ScatterChart/Scatter.js +6 -3
- package/modern/ScatterChart/ScatterChart.js +95 -127
- package/modern/ScatterChart/ScatterPlot.js +10 -0
- package/modern/ScatterChart/getColor.js +42 -0
- package/modern/SparkLineChart/SparkLineChart.js +16 -2
- package/modern/context/CartesianContextProvider.js +23 -8
- package/modern/context/ZAxisContextProvider.js +89 -0
- package/modern/context/index.js +1 -1
- package/modern/hooks/index.js +4 -1
- package/modern/hooks/useAxisEvents.js +7 -6
- package/modern/hooks/useChartId.js +8 -0
- package/modern/hooks/useSeries.js +64 -0
- package/modern/hooks/useSvgRef.js +9 -0
- package/modern/index.js +1 -1
- package/modern/internals/colorGetter.js +22 -0
- package/modern/internals/colorScale.js +16 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +95 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +55 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +40 -0
- package/modern/internals/components/ChartsAxesGradients/index.js +1 -0
- package/modern/models/colorMapping.js +1 -0
- package/modern/models/seriesType/index.js +6 -1
- package/modern/models/z-axis.js +1 -0
- package/package.json +3 -5
|
@@ -9,8 +9,7 @@ import { InteractionContext } from '../context/InteractionProvider';
|
|
|
9
9
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
10
10
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
11
11
|
import { isBandScale } from '../internals/isBandScale';
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
13
|
export function getAxisHighlightUtilityClass(slot) {
|
|
15
14
|
return generateUtilityClass('MuiChartsAxisHighlight', slot);
|
|
16
15
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import {
|
|
4
|
+
import { useDrawingArea } from '../hooks/useDrawingArea';
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
/**
|
|
7
7
|
* API:
|
|
@@ -18,7 +18,7 @@ function ChartsClipPath(props) {
|
|
|
18
18
|
top,
|
|
19
19
|
width,
|
|
20
20
|
height
|
|
21
|
-
} =
|
|
21
|
+
} = useDrawingArea();
|
|
22
22
|
const offset = _extends({
|
|
23
23
|
top: 0,
|
|
24
24
|
right: 0,
|
|
@@ -8,8 +8,7 @@ import { styled } from '@mui/material/styles';
|
|
|
8
8
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
9
9
|
import { useTicks } from '../hooks/useTicks';
|
|
10
10
|
import { getChartsGridUtilityClass, chartsGridClasses } from './chartsGridClasses';
|
|
11
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
12
|
const GridRoot = styled('g', {
|
|
14
13
|
name: 'MuiChartsGrid',
|
|
15
14
|
slot: 'Root',
|
|
@@ -4,11 +4,11 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import { useSlotProps } from '@mui/base/utils';
|
|
5
5
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
6
6
|
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
7
|
-
import { DrawingContext } from '../context/DrawingProvider';
|
|
8
7
|
import { getSeriesToDisplay } from './utils';
|
|
9
8
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
10
9
|
import { getLegendUtilityClass } from './chartsLegendClasses';
|
|
11
10
|
import { DefaultChartsLegend } from './DefaultChartsLegend';
|
|
11
|
+
import { useDrawingArea } from '../hooks';
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
const useUtilityClasses = ownerState => {
|
|
14
14
|
const {
|
|
@@ -46,7 +46,7 @@ function ChartsLegend(inProps) {
|
|
|
46
46
|
const classes = useUtilityClasses(_extends({}, props, {
|
|
47
47
|
theme
|
|
48
48
|
}));
|
|
49
|
-
const drawingArea =
|
|
49
|
+
const drawingArea = useDrawingArea();
|
|
50
50
|
const series = React.useContext(SeriesContext);
|
|
51
51
|
const seriesToDisplay = getSeriesToDisplay(series);
|
|
52
52
|
const ChartLegendRender = slots?.legend ?? DefaultChartsLegend;
|
|
@@ -8,8 +8,7 @@ import { NoSsr } from '@mui/base/NoSsr';
|
|
|
8
8
|
import { useTheme, styled } from '@mui/material/styles';
|
|
9
9
|
import { ChartsText } from '../ChartsText';
|
|
10
10
|
import { getWordsByLines } from '../internals/getWordsByLines';
|
|
11
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
12
|
export const ChartsLegendRoot = styled('g', {
|
|
14
13
|
name: 'MuiChartsLegend',
|
|
15
14
|
slot: 'Root',
|
|
@@ -5,8 +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 { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
9
|
const getTextParams = ({
|
|
11
10
|
top,
|
|
12
11
|
height,
|
|
@@ -5,8 +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 { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
9
|
const getTextParams = ({
|
|
11
10
|
left,
|
|
12
11
|
width,
|
package/esm/ChartsSurface.js
CHANGED
|
@@ -5,8 +5,7 @@ import { styled } from '@mui/material/styles';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { useAxisEvents } from './hooks/useAxisEvents';
|
|
8
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
9
|
const ChartChartsSurfaceStyles = styled('svg', {
|
|
11
10
|
name: 'MuiChartsSurface',
|
|
12
11
|
slot: 'Root'
|
|
@@ -6,6 +6,8 @@ import { SeriesContext } from '../context/SeriesContextProvider';
|
|
|
6
6
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
7
7
|
import { DefaultChartsAxisTooltipContent } from './DefaultChartsAxisTooltipContent';
|
|
8
8
|
import { isCartesianSeriesType } from './utils';
|
|
9
|
+
import colorGetter from '../internals/colorGetter';
|
|
10
|
+
import { ZAxisContext } from '../context/ZAxisContextProvider';
|
|
9
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
12
|
function ChartsAxisTooltipContent(props) {
|
|
11
13
|
const {
|
|
@@ -24,6 +26,10 @@ function ChartsAxisTooltipContent(props) {
|
|
|
24
26
|
yAxisIds,
|
|
25
27
|
yAxis
|
|
26
28
|
} = React.useContext(CartesianContext);
|
|
29
|
+
const {
|
|
30
|
+
zAxisIds,
|
|
31
|
+
zAxis
|
|
32
|
+
} = React.useContext(ZAxisContext);
|
|
27
33
|
const series = React.useContext(SeriesContext);
|
|
28
34
|
const USED_AXIS_ID = isXaxis ? xAxisIds[0] : yAxisIds[0];
|
|
29
35
|
const relevantSeries = React.useMemo(() => {
|
|
@@ -33,12 +39,24 @@ function ChartsAxisTooltipContent(props) {
|
|
|
33
39
|
const item = series[seriesType].series[seriesId];
|
|
34
40
|
const axisKey = isXaxis ? item.xAxisKey : item.yAxisKey;
|
|
35
41
|
if (axisKey === undefined || axisKey === USED_AXIS_ID) {
|
|
36
|
-
|
|
42
|
+
const seriesToAdd = series[seriesType].series[seriesId];
|
|
43
|
+
let getColor;
|
|
44
|
+
switch (seriesToAdd.type) {
|
|
45
|
+
case 'scatter':
|
|
46
|
+
getColor = colorGetter(seriesToAdd, xAxis[seriesToAdd.xAxisKey ?? xAxisIds[0]], yAxis[seriesToAdd.yAxisKey ?? yAxisIds[0]], zAxis[seriesToAdd.zAxisKey ?? zAxisIds[0]]);
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
getColor = colorGetter(seriesToAdd, xAxis[seriesToAdd.xAxisKey ?? xAxisIds[0]], yAxis[seriesToAdd.yAxisKey ?? yAxisIds[0]]);
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
rep.push(_extends({}, seriesToAdd, {
|
|
53
|
+
getColor
|
|
54
|
+
}));
|
|
37
55
|
}
|
|
38
56
|
});
|
|
39
57
|
});
|
|
40
58
|
return rep;
|
|
41
|
-
}, [USED_AXIS_ID, isXaxis, series]);
|
|
59
|
+
}, [USED_AXIS_ID, isXaxis, series, xAxis, xAxisIds, yAxis, yAxisIds, zAxis, zAxisIds]);
|
|
42
60
|
const relevantAxis = React.useMemo(() => {
|
|
43
61
|
return isXaxis ? xAxis[USED_AXIS_ID] : yAxis[USED_AXIS_ID];
|
|
44
62
|
}, [USED_AXIS_ID, isXaxis, xAxis, yAxis]);
|
|
@@ -4,6 +4,9 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import { useSlotProps } from '@mui/base/utils';
|
|
5
5
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
6
6
|
import { DefaultChartsItemTooltipContent } from './DefaultChartsItemTooltipContent';
|
|
7
|
+
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
8
|
+
import colorGetter from '../internals/colorGetter';
|
|
9
|
+
import { ZAxisContext } from '../context/ZAxisContextProvider';
|
|
7
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
11
|
function ChartsItemTooltipContent(props) {
|
|
9
12
|
const {
|
|
@@ -14,6 +17,31 @@ function ChartsItemTooltipContent(props) {
|
|
|
14
17
|
contentProps
|
|
15
18
|
} = props;
|
|
16
19
|
const series = React.useContext(SeriesContext)[itemData.type].series[itemData.seriesId];
|
|
20
|
+
const {
|
|
21
|
+
xAxis,
|
|
22
|
+
yAxis,
|
|
23
|
+
xAxisIds,
|
|
24
|
+
yAxisIds
|
|
25
|
+
} = React.useContext(CartesianContext);
|
|
26
|
+
const {
|
|
27
|
+
zAxis,
|
|
28
|
+
zAxisIds
|
|
29
|
+
} = React.useContext(ZAxisContext);
|
|
30
|
+
const defaultXAxisId = xAxisIds[0];
|
|
31
|
+
const defaultYAxisId = yAxisIds[0];
|
|
32
|
+
const defaultZAxisId = zAxisIds[0];
|
|
33
|
+
let getColor;
|
|
34
|
+
switch (series.type) {
|
|
35
|
+
case 'pie':
|
|
36
|
+
getColor = colorGetter(series);
|
|
37
|
+
break;
|
|
38
|
+
case 'scatter':
|
|
39
|
+
getColor = colorGetter(series, xAxis[series.xAxisKey ?? defaultXAxisId], yAxis[series.yAxisKey ?? defaultYAxisId], zAxis[series.zAxisKey ?? defaultZAxisId]);
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
getColor = colorGetter(series, xAxis[series.xAxisKey ?? defaultXAxisId], yAxis[series.yAxisKey ?? defaultYAxisId]);
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
17
45
|
const Content = content ?? DefaultChartsItemTooltipContent;
|
|
18
46
|
const chartTooltipContentProps = useSlotProps({
|
|
19
47
|
elementType: Content,
|
|
@@ -22,7 +50,8 @@ function ChartsItemTooltipContent(props) {
|
|
|
22
50
|
itemData,
|
|
23
51
|
series,
|
|
24
52
|
sx,
|
|
25
|
-
classes
|
|
53
|
+
classes,
|
|
54
|
+
getColor
|
|
26
55
|
},
|
|
27
56
|
ownerState: {}
|
|
28
57
|
});
|
|
@@ -37,6 +66,7 @@ process.env.NODE_ENV !== "production" ? ChartsItemTooltipContent.propTypes = {
|
|
|
37
66
|
content: PropTypes.elementType,
|
|
38
67
|
contentProps: PropTypes.shape({
|
|
39
68
|
classes: PropTypes.object,
|
|
69
|
+
getColor: PropTypes.func,
|
|
40
70
|
itemData: PropTypes.shape({
|
|
41
71
|
dataIndex: PropTypes.number,
|
|
42
72
|
seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Box from '@mui/system/Box';
|
|
2
1
|
import { styled } from '@mui/material/styles';
|
|
2
|
+
import { shouldForwardProp } from '@mui/system';
|
|
3
3
|
import { chartsTooltipClasses } from './chartsTooltipClasses';
|
|
4
4
|
export const ChartsTooltipPaper = styled('div', {
|
|
5
5
|
name: 'MuiChartsTooltip',
|
|
@@ -7,10 +7,10 @@ export const ChartsTooltipPaper = styled('div', {
|
|
|
7
7
|
})(({
|
|
8
8
|
theme
|
|
9
9
|
}) => ({
|
|
10
|
+
boxShadow: theme.shadows[1],
|
|
10
11
|
backgroundColor: (theme.vars || theme).palette.background.paper,
|
|
11
12
|
color: (theme.vars || theme).palette.text.primary,
|
|
12
13
|
transition: theme.transitions.create('box-shadow'),
|
|
13
|
-
border: `1px solid ${(theme.vars || theme).palette.divider}`,
|
|
14
14
|
borderRadius: theme.shape.borderRadius
|
|
15
15
|
}));
|
|
16
16
|
export const ChartsTooltipTable = styled('table', {
|
|
@@ -59,19 +59,19 @@ export const ChartsTooltipCell = styled('td', {
|
|
|
59
59
|
paddingRight: theme.spacing(2)
|
|
60
60
|
}
|
|
61
61
|
}));
|
|
62
|
-
|
|
63
|
-
// eslint-disable-next-line material-ui/no-styled-box
|
|
64
|
-
export const ChartsTooltipMark = styled(Box, {
|
|
62
|
+
export const ChartsTooltipMark = styled('div', {
|
|
65
63
|
name: 'MuiChartsTooltip',
|
|
66
|
-
slot: 'Mark'
|
|
64
|
+
slot: 'Mark',
|
|
65
|
+
shouldForwardProp: prop => shouldForwardProp(prop) && prop !== 'color'
|
|
67
66
|
})(({
|
|
68
67
|
theme,
|
|
69
|
-
|
|
68
|
+
color
|
|
70
69
|
}) => ({
|
|
71
70
|
width: theme.spacing(1),
|
|
72
71
|
height: theme.spacing(1),
|
|
73
72
|
borderRadius: '50%',
|
|
74
|
-
|
|
73
|
+
boxShadow: theme.shadows[1],
|
|
74
|
+
backgroundColor: color,
|
|
75
75
|
borderColor: (theme.vars || theme).palette.background.paper,
|
|
76
76
|
border: `solid ${(theme.vars || theme).palette.background.paper} ${theme.spacing(0.25)}`,
|
|
77
77
|
boxSizing: 'content-box'
|
|
@@ -4,8 +4,7 @@ import clsx from 'clsx';
|
|
|
4
4
|
import Typography from '@mui/material/Typography';
|
|
5
5
|
import { ChartsTooltipCell, ChartsTooltipPaper, ChartsTooltipTable, ChartsTooltipMark, ChartsTooltipRow } from './ChartsTooltipTable';
|
|
6
6
|
import { isCartesianSeries, utcFormatter } from './utils';
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
8
|
function DefaultChartsAxisTooltipContent(props) {
|
|
10
9
|
const {
|
|
11
10
|
series,
|
|
@@ -41,10 +40,13 @@ function DefaultChartsAxisTooltipContent(props) {
|
|
|
41
40
|
id,
|
|
42
41
|
label,
|
|
43
42
|
valueFormatter,
|
|
44
|
-
data
|
|
43
|
+
data,
|
|
44
|
+
getColor
|
|
45
45
|
}) => {
|
|
46
46
|
// @ts-ignore
|
|
47
|
-
const formattedValue = valueFormatter(data[dataIndex] ?? null
|
|
47
|
+
const formattedValue = valueFormatter(data[dataIndex] ?? null, {
|
|
48
|
+
dataIndex
|
|
49
|
+
});
|
|
48
50
|
if (formattedValue == null) {
|
|
49
51
|
return null;
|
|
50
52
|
}
|
|
@@ -53,10 +55,7 @@ function DefaultChartsAxisTooltipContent(props) {
|
|
|
53
55
|
children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
54
56
|
className: clsx(classes.markCell, classes.cell),
|
|
55
57
|
children: /*#__PURE__*/_jsx(ChartsTooltipMark, {
|
|
56
|
-
|
|
57
|
-
color
|
|
58
|
-
},
|
|
59
|
-
boxShadow: 1,
|
|
58
|
+
color: getColor(dataIndex) ?? color,
|
|
60
59
|
className: classes.mark
|
|
61
60
|
})
|
|
62
61
|
}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
@@ -2,14 +2,14 @@ import * as React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { ChartsTooltipTable, ChartsTooltipCell, ChartsTooltipMark, ChartsTooltipPaper, ChartsTooltipRow } from './ChartsTooltipTable';
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
6
|
function DefaultChartsItemTooltipContent(props) {
|
|
8
7
|
const {
|
|
9
8
|
series,
|
|
10
9
|
itemData,
|
|
11
10
|
sx,
|
|
12
|
-
classes
|
|
11
|
+
classes,
|
|
12
|
+
getColor
|
|
13
13
|
} = props;
|
|
14
14
|
if (itemData.dataIndex === undefined || !series.data[itemData.dataIndex]) {
|
|
15
15
|
return null;
|
|
@@ -18,14 +18,16 @@ function DefaultChartsItemTooltipContent(props) {
|
|
|
18
18
|
displayedLabel,
|
|
19
19
|
color
|
|
20
20
|
} = series.type === 'pie' ? {
|
|
21
|
-
color:
|
|
21
|
+
color: getColor(itemData.dataIndex),
|
|
22
22
|
displayedLabel: series.data[itemData.dataIndex].label
|
|
23
23
|
} : {
|
|
24
|
-
color: series.color,
|
|
24
|
+
color: getColor(itemData.dataIndex) ?? series.color,
|
|
25
25
|
displayedLabel: series.label
|
|
26
26
|
};
|
|
27
27
|
const value = series.data[itemData.dataIndex];
|
|
28
|
-
const formattedValue = series.valueFormatter?.(value
|
|
28
|
+
const formattedValue = series.valueFormatter?.(value, {
|
|
29
|
+
dataIndex: itemData.dataIndex
|
|
30
|
+
});
|
|
29
31
|
return /*#__PURE__*/_jsx(ChartsTooltipPaper, {
|
|
30
32
|
sx: sx,
|
|
31
33
|
className: classes.root,
|
|
@@ -37,9 +39,7 @@ function DefaultChartsItemTooltipContent(props) {
|
|
|
37
39
|
children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
38
40
|
className: clsx(classes.markCell, classes.cell),
|
|
39
41
|
children: /*#__PURE__*/_jsx(ChartsTooltipMark, {
|
|
40
|
-
|
|
41
|
-
color
|
|
42
|
-
},
|
|
42
|
+
color: color,
|
|
43
43
|
className: classes.mark
|
|
44
44
|
})
|
|
45
45
|
}), /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
@@ -63,6 +63,12 @@ process.env.NODE_ENV !== "production" ? DefaultChartsItemTooltipContent.propType
|
|
|
63
63
|
* Override or extend the styles applied to the component.
|
|
64
64
|
*/
|
|
65
65
|
classes: PropTypes.object.isRequired,
|
|
66
|
+
/**
|
|
67
|
+
* Get the color of the item with index `dataIndex`.
|
|
68
|
+
* @param {number} dataIndex The data index of the item.
|
|
69
|
+
* @returns {string} The color to display.
|
|
70
|
+
*/
|
|
71
|
+
getColor: PropTypes.func.isRequired,
|
|
66
72
|
/**
|
|
67
73
|
* The data used to identify the triggered item.
|
|
68
74
|
*/
|
|
@@ -4,23 +4,23 @@ import { Delaunay } from 'd3-delaunay';
|
|
|
4
4
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
5
5
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
6
6
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
7
|
-
import { SvgContext, DrawingContext } from '../context/DrawingProvider';
|
|
8
7
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
9
8
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
10
9
|
import { getSVGPoint } from '../internals/utils';
|
|
10
|
+
import { useDrawingArea, useSvgRef } from '../hooks';
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
function ChartsVoronoiHandler(props) {
|
|
13
13
|
const {
|
|
14
14
|
voronoiMaxRadius,
|
|
15
15
|
onItemClick
|
|
16
16
|
} = props;
|
|
17
|
-
const svgRef =
|
|
17
|
+
const svgRef = useSvgRef();
|
|
18
18
|
const {
|
|
19
|
-
|
|
20
|
-
height,
|
|
19
|
+
left,
|
|
21
20
|
top,
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
width,
|
|
22
|
+
height
|
|
23
|
+
} = useDrawingArea();
|
|
24
24
|
const {
|
|
25
25
|
xAxis,
|
|
26
26
|
yAxis,
|
|
@@ -7,16 +7,15 @@ import { useSlotProps } from '@mui/base/utils';
|
|
|
7
7
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
8
8
|
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
9
9
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
10
|
-
import { DrawingContext } from '../context/DrawingProvider';
|
|
11
10
|
import { useTicks } from '../hooks/useTicks';
|
|
12
11
|
import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
|
|
13
12
|
import { AxisRoot } from '../internals/components/AxisSharedComponents';
|
|
14
13
|
import { ChartsText } from '../ChartsText';
|
|
15
14
|
import { getMinXTranslation } from '../internals/geometry';
|
|
16
15
|
import { useMounted } from '../hooks/useMounted';
|
|
16
|
+
import { useDrawingArea } from '../hooks/useDrawingArea';
|
|
17
17
|
import { getWordsByLines } from '../internals/getWordsByLines';
|
|
18
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
19
|
const useUtilityClasses = ownerState => {
|
|
21
20
|
const {
|
|
22
21
|
classes,
|
|
@@ -153,7 +152,7 @@ function ChartsXAxis(inProps) {
|
|
|
153
152
|
top,
|
|
154
153
|
width,
|
|
155
154
|
height
|
|
156
|
-
} =
|
|
155
|
+
} = useDrawingArea();
|
|
157
156
|
const tickSize = disableTicks ? 4 : tickSizeProp;
|
|
158
157
|
const positionSign = position === 'bottom' ? 1 : -1;
|
|
159
158
|
const Line = slots?.axisLine ?? 'line';
|
|
@@ -7,13 +7,12 @@ import { useSlotProps } from '@mui/base/utils';
|
|
|
7
7
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
8
8
|
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
9
9
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
10
|
-
import { DrawingContext } from '../context/DrawingProvider';
|
|
11
10
|
import { useTicks } from '../hooks/useTicks';
|
|
11
|
+
import { useDrawingArea } from '../hooks/useDrawingArea';
|
|
12
12
|
import { AxisRoot } from '../internals/components/AxisSharedComponents';
|
|
13
13
|
import { ChartsText } from '../ChartsText';
|
|
14
14
|
import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
|
|
15
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
16
|
const useUtilityClasses = ownerState => {
|
|
18
17
|
const {
|
|
19
18
|
classes,
|
|
@@ -94,7 +93,7 @@ function ChartsYAxis(inProps) {
|
|
|
94
93
|
top,
|
|
95
94
|
width,
|
|
96
95
|
height
|
|
97
|
-
} =
|
|
96
|
+
} = useDrawingArea();
|
|
98
97
|
const tickSize = disableTicks ? 4 : tickSizeProp;
|
|
99
98
|
const yTicks = useTicks({
|
|
100
99
|
scale: yScale,
|
package/esm/Gauge/Gauge.js
CHANGED
|
@@ -9,8 +9,7 @@ import { GaugeValueArc } from './GaugeValueArc';
|
|
|
9
9
|
import { GaugeReferenceArc } from './GaugeReferenceArc';
|
|
10
10
|
import { getGaugeUtilityClass } from './gaugeClasses';
|
|
11
11
|
import { GaugeValueText } from './GaugeValueText';
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
13
|
const useUtilityClasses = props => {
|
|
15
14
|
const {
|
|
16
15
|
classes
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @ignore - do not document.
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { DrawingContext } from '../context/DrawingProvider';
|
|
4
3
|
import { getPercentageValue } from '../internals/utils';
|
|
5
4
|
import { getArcRatios, getAvailableRadius } from './utils';
|
|
5
|
+
import { useDrawingArea } from '../hooks/useDrawingArea';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
export const GaugeContext = /*#__PURE__*/React.createContext({
|
|
8
8
|
value: null,
|
|
@@ -36,11 +36,11 @@ export function GaugeProvider(props) {
|
|
|
36
36
|
children
|
|
37
37
|
} = props;
|
|
38
38
|
const {
|
|
39
|
-
|
|
40
|
-
height,
|
|
39
|
+
left,
|
|
41
40
|
top,
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
width,
|
|
42
|
+
height
|
|
43
|
+
} = useDrawingArea();
|
|
44
44
|
const ratios = getArcRatios(startAngle, endAngle);
|
|
45
45
|
const innerCx = cxParam ? getPercentageValue(cxParam, width) : ratios.cx * width;
|
|
46
46
|
const innerCy = cyParam ? getPercentageValue(cyParam, height) : ratios.cy * height;
|
|
@@ -7,10 +7,9 @@ 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 { DrawingContext } from '../context/DrawingProvider';
|
|
11
10
|
import { cleanId } from '../internals/utils';
|
|
12
|
-
import {
|
|
13
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { useChartId, useDrawingArea } from '../hooks';
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
13
|
export const AreaElementPath = styled(animated.path, {
|
|
15
14
|
name: 'MuiAreaElement',
|
|
16
15
|
slot: 'Root',
|
|
@@ -19,7 +18,7 @@ export const AreaElementPath = styled(animated.path, {
|
|
|
19
18
|
ownerState
|
|
20
19
|
}) => ({
|
|
21
20
|
stroke: 'none',
|
|
22
|
-
fill: ownerState.isHighlighted
|
|
21
|
+
fill: ownerState.gradientId && `url(#${ownerState.gradientId})` || ownerState.isHighlighted && d3Color(ownerState.color).brighter(1).formatHex() || d3Color(ownerState.color).brighter(0.5).formatHex(),
|
|
23
22
|
transition: 'opacity 0.2s ease-in, fill 0.2s ease-in',
|
|
24
23
|
opacity: ownerState.isFaded ? 0.3 : 1
|
|
25
24
|
}));
|
|
@@ -46,9 +45,9 @@ function AnimatedArea(props) {
|
|
|
46
45
|
right,
|
|
47
46
|
bottom,
|
|
48
47
|
width,
|
|
49
|
-
height
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
height
|
|
49
|
+
} = useDrawingArea();
|
|
50
|
+
const chartId = useChartId();
|
|
52
51
|
const path = useAnimatedPath(d, skipAnimation);
|
|
53
52
|
const {
|
|
54
53
|
animatedWidth
|
|
@@ -90,6 +89,7 @@ process.env.NODE_ENV !== "production" ? AnimatedArea.propTypes = {
|
|
|
90
89
|
ownerState: PropTypes.shape({
|
|
91
90
|
classes: PropTypes.object,
|
|
92
91
|
color: PropTypes.string.isRequired,
|
|
92
|
+
gradientId: PropTypes.string,
|
|
93
93
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
94
94
|
isFaded: PropTypes.bool.isRequired,
|
|
95
95
|
isHighlighted: PropTypes.bool.isRequired
|
|
@@ -7,10 +7,10 @@ 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 { DrawingContext } from '../context/DrawingProvider';
|
|
11
10
|
import { cleanId } from '../internals/utils';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import { useChartId } from '../hooks/useChartId';
|
|
12
|
+
import { useDrawingArea } from '../hooks/useDrawingArea';
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
export const LineElementPath = styled(animated.path, {
|
|
15
15
|
name: 'MuiLineElement',
|
|
16
16
|
slot: 'Root',
|
|
@@ -21,7 +21,7 @@ export const LineElementPath = styled(animated.path, {
|
|
|
21
21
|
strokeWidth: 2,
|
|
22
22
|
strokeLinejoin: 'round',
|
|
23
23
|
fill: 'none',
|
|
24
|
-
stroke: ownerState.isHighlighted
|
|
24
|
+
stroke: ownerState.gradientId && `url(#${ownerState.gradientId})` || ownerState.isHighlighted && d3Color(ownerState.color).brighter(0.5).formatHex() || ownerState.color,
|
|
25
25
|
transition: 'opacity 0.2s ease-in, stroke 0.2s ease-in',
|
|
26
26
|
opacity: ownerState.isFaded ? 0.3 : 1
|
|
27
27
|
}));
|
|
@@ -48,9 +48,9 @@ function AnimatedLine(props) {
|
|
|
48
48
|
bottom,
|
|
49
49
|
width,
|
|
50
50
|
height,
|
|
51
|
-
right
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
right
|
|
52
|
+
} = useDrawingArea();
|
|
53
|
+
const chartId = useChartId();
|
|
54
54
|
const path = useAnimatedPath(d, skipAnimation);
|
|
55
55
|
const {
|
|
56
56
|
animatedWidth
|
|
@@ -92,6 +92,7 @@ process.env.NODE_ENV !== "production" ? AnimatedLine.propTypes = {
|
|
|
92
92
|
ownerState: PropTypes.shape({
|
|
93
93
|
classes: PropTypes.object,
|
|
94
94
|
color: PropTypes.string.isRequired,
|
|
95
|
+
gradientId: PropTypes.string,
|
|
95
96
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
96
97
|
isFaded: PropTypes.bool.isRequired,
|
|
97
98
|
isHighlighted: PropTypes.bool.isRequired
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps", "onClick"];
|
|
3
|
+
const _excluded = ["id", "classes", "color", "gradientId", "highlightScope", "slots", "slotProps", "onClick"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
@@ -42,6 +42,7 @@ function AreaElement(props) {
|
|
|
42
42
|
id,
|
|
43
43
|
classes: innerClasses,
|
|
44
44
|
color,
|
|
45
|
+
gradientId,
|
|
45
46
|
highlightScope,
|
|
46
47
|
slots,
|
|
47
48
|
slotProps,
|
|
@@ -64,6 +65,7 @@ function AreaElement(props) {
|
|
|
64
65
|
id,
|
|
65
66
|
classes: innerClasses,
|
|
66
67
|
color,
|
|
68
|
+
gradientId,
|
|
67
69
|
isFaded,
|
|
68
70
|
isHighlighted
|
|
69
71
|
};
|
|
@@ -92,6 +94,7 @@ process.env.NODE_ENV !== "production" ? AreaElement.propTypes = {
|
|
|
92
94
|
classes: PropTypes.object,
|
|
93
95
|
color: PropTypes.string.isRequired,
|
|
94
96
|
d: PropTypes.string.isRequired,
|
|
97
|
+
gradientId: PropTypes.string,
|
|
95
98
|
highlightScope: PropTypes.shape({
|
|
96
99
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
97
100
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
@@ -10,6 +10,7 @@ import { AreaElement } from './AreaElement';
|
|
|
10
10
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
11
11
|
import getCurveFactory from '../internals/getCurve';
|
|
12
12
|
import { DEFAULT_X_AXIS_KEY } from '../constants';
|
|
13
|
+
import { useChartGradient } from '../internals/components/ChartsAxesGradients';
|
|
13
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
15
|
const useAggregatedData = () => {
|
|
15
16
|
const seriesData = React.useContext(SeriesContext).line;
|
|
@@ -43,6 +44,7 @@ const useAggregatedData = () => {
|
|
|
43
44
|
const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
44
45
|
const yScale = yAxis[yAxisKey].scale;
|
|
45
46
|
const xData = xAxis[xAxisKey].data;
|
|
47
|
+
const gradientUsed = yAxis[yAxisKey].colorScale && [yAxisKey, 'y'] || xAxis[xAxisKey].colorScale && [xAxisKey, 'x'] || undefined;
|
|
46
48
|
if (process.env.NODE_ENV !== 'production') {
|
|
47
49
|
if (xData === undefined) {
|
|
48
50
|
throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot.`);
|
|
@@ -60,6 +62,7 @@ const useAggregatedData = () => {
|
|
|
60
62
|
const d3Data = connectNulls ? formattedData.filter((_, i) => data[i] != null) : formattedData;
|
|
61
63
|
const d = areaPath.curve(curve)(d3Data) || '';
|
|
62
64
|
return _extends({}, series[seriesId], {
|
|
65
|
+
gradientUsed,
|
|
63
66
|
d,
|
|
64
67
|
seriesId
|
|
65
68
|
});
|
|
@@ -86,6 +89,7 @@ function AreaPlot(props) {
|
|
|
86
89
|
skipAnimation
|
|
87
90
|
} = props,
|
|
88
91
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
92
|
+
const getGradientId = useChartGradient();
|
|
89
93
|
const completedData = useAggregatedData();
|
|
90
94
|
return /*#__PURE__*/_jsx("g", _extends({}, other, {
|
|
91
95
|
children: completedData.reverse().map(({
|
|
@@ -93,11 +97,13 @@ function AreaPlot(props) {
|
|
|
93
97
|
seriesId,
|
|
94
98
|
color,
|
|
95
99
|
highlightScope,
|
|
96
|
-
area
|
|
100
|
+
area,
|
|
101
|
+
gradientUsed
|
|
97
102
|
}) => !!area && /*#__PURE__*/_jsx(AreaElement, {
|
|
98
103
|
id: seriesId,
|
|
99
104
|
d: d,
|
|
100
105
|
color: color,
|
|
106
|
+
gradientId: gradientUsed && getGradientId(...gradientUsed),
|
|
101
107
|
highlightScope: highlightScope,
|
|
102
108
|
slots: slots,
|
|
103
109
|
slotProps: slotProps,
|