@mui/x-charts 8.0.0-alpha.6 → 8.0.0-alpha.7
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/AnimatedBarElement.js +1 -0
- package/BarChart/BarChart.js +17 -7
- package/BarChart/BarLabel/BarLabel.d.ts +1 -479
- package/BarChart/BarLabel/barLabelClasses.d.ts +1 -1
- package/BarChart/legend.js +1 -0
- package/BarChart/useBarChartProps.d.ts +4 -2
- package/BarChart/useBarChartProps.js +16 -3
- package/CHANGELOG.md +127 -1
- package/ChartsLabel/ChartsLabel.d.ts +2 -3
- package/ChartsLabel/ChartsLabel.js +3 -18
- package/ChartsLabel/ChartsLabelGradient.d.ts +9 -8
- package/ChartsLabel/ChartsLabelGradient.js +21 -18
- package/ChartsLabel/ChartsLabelMark.d.ts +2 -3
- package/ChartsLabel/ChartsLabelMark.js +5 -2
- package/ChartsLabel/index.d.ts +7 -0
- package/ChartsLabel/index.js +6 -0
- package/ChartsLabel/labelClasses.d.ts +0 -1
- package/ChartsLabel/labelGradientClasses.d.ts +5 -4
- package/ChartsLabel/labelGradientClasses.js +3 -2
- package/ChartsLabel/labelMarkClasses.d.ts +3 -2
- package/ChartsLabel/labelMarkClasses.js +3 -2
- package/ChartsLabel/package.json +6 -0
- package/ChartsLegend/ChartsLegend.d.ts +18 -22
- package/ChartsLegend/ChartsLegend.js +100 -109
- package/ChartsLegend/ContinuousColorLegend.d.ts +29 -38
- package/ChartsLegend/ContinuousColorLegend.js +198 -321
- package/ChartsLegend/PiecewiseColorLegend.d.ts +27 -19
- package/ChartsLegend/PiecewiseColorLegend.js +201 -111
- package/ChartsLegend/chartsLegend.types.d.ts +17 -60
- package/ChartsLegend/chartsLegendClasses.d.ts +7 -8
- package/ChartsLegend/chartsLegendClasses.js +16 -2
- package/ChartsLegend/colorLegend.types.d.ts +13 -0
- package/ChartsLegend/colorLegend.types.js +1 -0
- package/ChartsLegend/continuousColorLegendClasses.d.ts +26 -0
- package/ChartsLegend/continuousColorLegendClasses.js +23 -0
- package/ChartsLegend/direction.d.ts +1 -0
- package/ChartsLegend/direction.js +1 -0
- package/ChartsLegend/index.d.ts +13 -3
- package/ChartsLegend/index.js +9 -3
- package/ChartsLegend/legend.types.d.ts +10 -54
- package/ChartsLegend/legendContext.types.d.ts +55 -0
- package/ChartsLegend/legendContext.types.js +1 -0
- package/ChartsLegend/onClickContextBuilder.d.ts +2 -0
- package/ChartsLegend/onClickContextBuilder.js +7 -0
- package/ChartsLegend/piecewiseColorDefaultLabelFormatter.d.ts +2 -0
- package/ChartsLegend/piecewiseColorDefaultLabelFormatter.js +9 -0
- package/ChartsLegend/piecewiseColorLegend.types.d.ts +26 -0
- package/ChartsLegend/piecewiseColorLegend.types.js +1 -0
- package/ChartsLegend/piecewiseColorLegendClasses.d.ts +28 -0
- package/ChartsLegend/piecewiseColorLegendClasses.js +23 -0
- package/ChartsLegend/useAxis.d.ts +1 -1
- package/ChartsLegend/useAxis.js +0 -1
- package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
- package/ChartsSurface/ChartsSurface.js +0 -1
- package/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
- package/LineChart/AnimatedArea.js +1 -0
- package/LineChart/AnimatedLine.js +1 -0
- package/LineChart/AppearingMask.js +1 -0
- package/LineChart/CircleMarkElement.js +1 -0
- package/LineChart/LineChart.js +20 -10
- package/LineChart/MarkElement.js +3 -1
- package/LineChart/legend.js +1 -0
- package/LineChart/useLineChartProps.d.ts +4 -2
- package/LineChart/useLineChartProps.js +15 -2
- package/PieChart/PieArc.js +3 -1
- package/PieChart/PieArcLabel.js +13 -9
- package/PieChart/PieArcLabelPlot.js +1 -0
- package/PieChart/PieArcPlot.js +1 -0
- package/PieChart/PieChart.js +42 -41
- package/PieChart/legend.js +1 -0
- package/ScatterChart/ScatterChart.js +21 -11
- package/ScatterChart/legend.js +1 -0
- package/ScatterChart/useScatterChartProps.d.ts +4 -2
- package/ScatterChart/useScatterChartProps.js +15 -2
- package/SparkLineChart/SparkLineChart.js +1 -4
- package/constants/index.d.ts +1 -0
- package/constants/index.js +2 -1
- package/context/CartesianProvider/defaultizeAxis.d.ts +9 -9
- package/context/ChartDataProvider/useChartDataProviderProps.d.ts +18 -18
- package/context/ChartDataProvider/useDefaultizeAxis.d.ts +9 -9
- package/context/ChartProvider/ChartProvider.types.d.ts +1 -1
- package/context/InteractionSelectors.d.ts +11 -11
- package/context/PluginProvider/SeriesFormatter.types.d.ts +1 -1
- package/context/PluginProvider/mergePlugins.d.ts +8 -8
- package/context/SizeProvider/Size.types.d.ts +1 -1
- package/context/SizeProvider/useChartContainerDimensions.d.ts +1 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +2 -1
- package/hooks/useLegend.d.ts +13 -0
- package/{modern/ChartsLegend/utils.js → hooks/useLegend.js} +20 -1
- package/hooks/useSvgRef.d.ts +1 -1
- package/index.d.ts +1 -0
- package/index.js +2 -1
- package/internals/calculateMargins.d.ts +7 -0
- package/internals/calculateMargins.js +25 -0
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +2 -1
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +60 -16
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +6 -6
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.d.ts +13 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.js +61 -0
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -0
- package/internals/components/ChartsWrapper/ChartsWrapper.d.ts +17 -0
- package/internals/components/ChartsWrapper/ChartsWrapper.js +66 -0
- package/internals/components/ChartsWrapper/index.d.ts +1 -0
- package/internals/components/ChartsWrapper/index.js +1 -0
- package/internals/consumeSlots.d.ts +48 -0
- package/internals/consumeSlots.js +101 -0
- package/internals/consumeThemeProps.d.ts +3 -7
- package/internals/consumeThemeProps.js +18 -27
- package/internals/defaultizeColor.d.ts +6 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +11 -11
- package/internals/plugins/models/plugin.d.ts +1 -1
- package/internals/store/useCharts.d.ts +2 -2
- package/internals/store/useCharts.types.d.ts +1 -1
- package/models/seriesType/common.d.ts +9 -0
- package/models/seriesType/pie.d.ts +9 -0
- package/modern/BarChart/AnimatedBarElement.js +1 -0
- package/modern/BarChart/BarChart.js +17 -7
- package/modern/BarChart/legend.js +1 -0
- package/modern/BarChart/useBarChartProps.js +16 -3
- package/modern/ChartsLabel/ChartsLabel.js +3 -18
- package/modern/ChartsLabel/ChartsLabelGradient.js +21 -18
- package/modern/ChartsLabel/ChartsLabelMark.js +5 -2
- package/modern/ChartsLabel/index.js +6 -0
- package/modern/ChartsLabel/labelGradientClasses.js +3 -2
- package/modern/ChartsLabel/labelMarkClasses.js +3 -2
- package/modern/ChartsLegend/ChartsLegend.js +100 -109
- package/modern/ChartsLegend/ContinuousColorLegend.js +198 -321
- package/modern/ChartsLegend/PiecewiseColorLegend.js +201 -111
- package/modern/ChartsLegend/chartsLegendClasses.js +16 -2
- package/modern/ChartsLegend/colorLegend.types.js +1 -0
- package/modern/ChartsLegend/continuousColorLegendClasses.js +23 -0
- package/modern/ChartsLegend/direction.js +1 -0
- package/modern/ChartsLegend/index.js +9 -3
- package/modern/ChartsLegend/legendContext.types.js +1 -0
- package/modern/ChartsLegend/onClickContextBuilder.js +7 -0
- package/modern/ChartsLegend/piecewiseColorDefaultLabelFormatter.js +9 -0
- package/modern/ChartsLegend/piecewiseColorLegend.types.js +1 -0
- package/modern/ChartsLegend/piecewiseColorLegendClasses.js +23 -0
- package/modern/ChartsLegend/useAxis.js +0 -1
- package/modern/ChartsSurface/ChartsSurface.js +0 -1
- package/modern/LineChart/AnimatedArea.js +1 -0
- package/modern/LineChart/AnimatedLine.js +1 -0
- package/modern/LineChart/AppearingMask.js +1 -0
- package/modern/LineChart/CircleMarkElement.js +1 -0
- package/modern/LineChart/LineChart.js +20 -10
- package/modern/LineChart/MarkElement.js +3 -1
- package/modern/LineChart/legend.js +1 -0
- package/modern/LineChart/useLineChartProps.js +15 -2
- package/modern/PieChart/PieArc.js +3 -1
- package/modern/PieChart/PieArcLabel.js +13 -9
- package/modern/PieChart/PieArcLabelPlot.js +1 -0
- package/modern/PieChart/PieArcPlot.js +1 -0
- package/modern/PieChart/PieChart.js +42 -41
- package/modern/PieChart/legend.js +1 -0
- package/modern/ScatterChart/ScatterChart.js +21 -11
- package/modern/ScatterChart/legend.js +1 -0
- package/modern/ScatterChart/useScatterChartProps.js +15 -2
- package/modern/SparkLineChart/SparkLineChart.js +1 -4
- package/modern/constants/index.js +2 -1
- package/modern/hooks/index.js +2 -1
- package/{ChartsLegend/utils.js → modern/hooks/useLegend.js} +20 -1
- package/modern/index.js +2 -1
- package/modern/internals/calculateMargins.js +25 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +60 -16
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +6 -6
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.js +61 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -0
- package/modern/internals/components/ChartsWrapper/ChartsWrapper.js +66 -0
- package/modern/internals/components/ChartsWrapper/index.js +1 -0
- package/modern/internals/consumeSlots.js +101 -0
- package/modern/internals/consumeThemeProps.js +18 -27
- package/modern/internals/index.js +1 -0
- package/node/BarChart/AnimatedBarElement.js +1 -0
- package/node/BarChart/BarChart.js +17 -7
- package/node/BarChart/legend.js +1 -0
- package/node/BarChart/useBarChartProps.js +15 -3
- package/node/ChartsLabel/ChartsLabel.js +3 -18
- package/node/ChartsLabel/ChartsLabelGradient.js +21 -18
- package/node/ChartsLabel/ChartsLabelMark.js +5 -2
- package/node/ChartsLabel/index.js +26 -0
- package/node/ChartsLabel/labelGradientClasses.js +3 -2
- package/node/ChartsLabel/labelMarkClasses.js +3 -2
- package/node/ChartsLegend/ChartsLegend.js +99 -108
- package/node/ChartsLegend/ContinuousColorLegend.js +199 -322
- package/node/ChartsLegend/PiecewiseColorLegend.js +201 -111
- package/node/ChartsLegend/chartsLegendClasses.js +17 -3
- package/node/ChartsLegend/colorLegend.types.js +5 -0
- package/node/ChartsLegend/continuousColorLegendClasses.js +31 -0
- package/node/ChartsLegend/direction.js +5 -0
- package/node/ChartsLegend/index.js +80 -16
- package/node/ChartsLegend/legendContext.types.js +5 -0
- package/node/ChartsLegend/onClickContextBuilder.js +14 -0
- package/node/ChartsLegend/piecewiseColorDefaultLabelFormatter.js +15 -0
- package/node/ChartsLegend/piecewiseColorLegend.types.js +5 -0
- package/node/ChartsLegend/piecewiseColorLegendClasses.js +31 -0
- package/node/ChartsSurface/ChartsSurface.js +0 -1
- package/node/LineChart/AnimatedArea.js +1 -0
- package/node/LineChart/AnimatedLine.js +1 -0
- package/node/LineChart/AppearingMask.js +1 -0
- package/node/LineChart/CircleMarkElement.js +1 -0
- package/node/LineChart/LineChart.js +20 -10
- package/node/LineChart/MarkElement.js +3 -1
- package/node/LineChart/legend.js +1 -0
- package/node/LineChart/useLineChartProps.js +14 -2
- package/node/PieChart/PieArc.js +3 -1
- package/node/PieChart/PieArcLabel.js +13 -9
- package/node/PieChart/PieArcLabelPlot.js +1 -0
- package/node/PieChart/PieArcPlot.js +1 -0
- package/node/PieChart/PieChart.js +42 -41
- package/node/PieChart/legend.js +1 -0
- package/node/ScatterChart/ScatterChart.js +21 -11
- package/node/ScatterChart/legend.js +1 -0
- package/node/ScatterChart/useScatterChartProps.js +14 -2
- package/node/SparkLineChart/SparkLineChart.js +1 -4
- package/node/constants/index.js +3 -2
- package/node/hooks/index.js +13 -1
- package/node/{ChartsLegend/utils.js → hooks/useLegend.js} +19 -1
- package/node/index.js +12 -1
- package/node/internals/calculateMargins.js +33 -0
- package/node/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +61 -16
- package/node/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +6 -6
- package/node/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.js +69 -0
- package/node/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -0
- package/node/internals/components/ChartsWrapper/ChartsWrapper.js +72 -0
- package/node/internals/components/ChartsWrapper/index.js +16 -0
- package/node/internals/consumeSlots.js +109 -0
- package/node/internals/consumeThemeProps.js +18 -27
- package/node/internals/index.js +12 -0
- package/package.json +4 -4
- package/ChartsLegend/ChartsLegendItem.d.ts +0 -26
- package/ChartsLegend/ChartsLegendItem.js +0 -65
- package/ChartsLegend/DefaultChartsLegend.d.ts +0 -25
- package/ChartsLegend/DefaultChartsLegend.js +0 -112
- package/ChartsLegend/LegendPerItem.d.ts +0 -65
- package/ChartsLegend/LegendPerItem.js +0 -129
- package/ChartsLegend/legendItemsPlacement.d.ts +0 -3
- package/ChartsLegend/legendItemsPlacement.js +0 -72
- package/ChartsLegend/utils.d.ts +0 -2
- package/modern/ChartsLegend/ChartsLegendItem.js +0 -65
- package/modern/ChartsLegend/DefaultChartsLegend.js +0 -112
- package/modern/ChartsLegend/LegendPerItem.js +0 -129
- package/modern/ChartsLegend/legendItemsPlacement.js +0 -72
- package/node/ChartsLegend/ChartsLegendItem.js +0 -72
- package/node/ChartsLegend/DefaultChartsLegend.js +0 -118
- package/node/ChartsLegend/LegendPerItem.js +0 -137
- package/node/ChartsLegend/legendItemsPlacement.js +0 -79
package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { interpolateDate, interpolateNumber } from '@mui/x-charts-vendor/d3-interpolate';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
const PX_PRECISION = 10;
|
|
6
|
+
const getDirection = isReversed => {
|
|
7
|
+
if (isReversed) {
|
|
8
|
+
return {
|
|
9
|
+
x1: '1',
|
|
10
|
+
x2: '0',
|
|
11
|
+
y1: '0',
|
|
12
|
+
y2: '0'
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
x1: '0',
|
|
17
|
+
x2: '1',
|
|
18
|
+
y1: '0',
|
|
19
|
+
y2: '0'
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Generates gradients to be used in tooltips and legends.
|
|
25
|
+
*/
|
|
26
|
+
export default function ChartsContinuousGradientObjectBound(props) {
|
|
27
|
+
const {
|
|
28
|
+
isReversed,
|
|
29
|
+
gradientId,
|
|
30
|
+
colorScale,
|
|
31
|
+
colorMap
|
|
32
|
+
} = props;
|
|
33
|
+
const extremumValues = [colorMap.min ?? 0, colorMap.max ?? 100];
|
|
34
|
+
const interpolator = typeof extremumValues[0] === 'number' ? interpolateNumber(extremumValues[0], extremumValues[1]) : interpolateDate(extremumValues[0], extremumValues[1]);
|
|
35
|
+
const numberOfPoints = PX_PRECISION;
|
|
36
|
+
const keyPrefix = `${extremumValues[0]}-${extremumValues[1]}-`;
|
|
37
|
+
return /*#__PURE__*/_jsx("linearGradient", _extends({
|
|
38
|
+
id: gradientId
|
|
39
|
+
}, getDirection(isReversed), {
|
|
40
|
+
gradientUnits: 'objectBoundingBox' // Use the SVG coordinate instead of the component ones.
|
|
41
|
+
,
|
|
42
|
+
children: Array.from({
|
|
43
|
+
length: numberOfPoints + 1
|
|
44
|
+
}, (_, index) => {
|
|
45
|
+
const offset = index / numberOfPoints;
|
|
46
|
+
const value = interpolator(offset);
|
|
47
|
+
if (value === undefined) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const color = colorScale(value);
|
|
51
|
+
if (color === null) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return /*#__PURE__*/_jsx("stop", {
|
|
55
|
+
offset: offset,
|
|
56
|
+
stopColor: color,
|
|
57
|
+
stopOpacity: 1
|
|
58
|
+
}, keyPrefix + index);
|
|
59
|
+
})
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
@@ -24,6 +24,9 @@ export default function ChartsPiecewiseGradient(props) {
|
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
26
|
const offset = isReversed ? 1 - x / size : x / size;
|
|
27
|
+
if (Number.isNaN(offset)) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
27
30
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
28
31
|
children: [/*#__PURE__*/_jsx("stop", {
|
|
29
32
|
offset: offset,
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
const getDirection = (direction, position) => {
|
|
5
|
+
if (direction === 'vertical') {
|
|
6
|
+
if (position?.horizontal === 'left') {
|
|
7
|
+
return 'row';
|
|
8
|
+
}
|
|
9
|
+
return 'row-reverse';
|
|
10
|
+
}
|
|
11
|
+
if (position?.vertical === 'bottom') {
|
|
12
|
+
return 'column-reverse';
|
|
13
|
+
}
|
|
14
|
+
return 'column';
|
|
15
|
+
};
|
|
16
|
+
const getAlign = (direction, position) => {
|
|
17
|
+
if (direction === 'vertical') {
|
|
18
|
+
if (position?.vertical === 'top') {
|
|
19
|
+
return 'flex-start';
|
|
20
|
+
}
|
|
21
|
+
if (position?.vertical === 'bottom') {
|
|
22
|
+
return 'flex-end';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (direction === 'horizontal') {
|
|
26
|
+
if (position?.horizontal === 'left') {
|
|
27
|
+
return 'flex-start';
|
|
28
|
+
}
|
|
29
|
+
if (position?.horizontal === 'right') {
|
|
30
|
+
return 'flex-end';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return 'center';
|
|
34
|
+
};
|
|
35
|
+
const Root = styled('div', {
|
|
36
|
+
name: 'MuiChartsWrapper',
|
|
37
|
+
slot: 'Root',
|
|
38
|
+
overridesResolver: (props, styles) => styles.root
|
|
39
|
+
})(({
|
|
40
|
+
ownerState
|
|
41
|
+
}) => ({
|
|
42
|
+
display: 'flex',
|
|
43
|
+
flexDirection: getDirection(ownerState.legendDirection, ownerState.legendPosition),
|
|
44
|
+
flex: 1,
|
|
45
|
+
justifyContent: 'center',
|
|
46
|
+
alignItems: getAlign(ownerState.legendDirection, ownerState.legendPosition)
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @ignore - internal component.
|
|
51
|
+
*
|
|
52
|
+
* Wrapper for the charts components.
|
|
53
|
+
* Its main purpose is to position the HTML legend in the correct place.
|
|
54
|
+
*/
|
|
55
|
+
function ChartsWrapper(props) {
|
|
56
|
+
const {
|
|
57
|
+
children,
|
|
58
|
+
sx
|
|
59
|
+
} = props;
|
|
60
|
+
return /*#__PURE__*/_jsx(Root, {
|
|
61
|
+
ownerState: props,
|
|
62
|
+
sx: sx,
|
|
63
|
+
children: children
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export { ChartsWrapper };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ChartsWrapper.js";
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["slots", "slotProps"],
|
|
4
|
+
_excluded2 = ["ownerState"];
|
|
5
|
+
import { useTheme, useThemeProps } from '@mui/material/styles';
|
|
6
|
+
import resolveProps from '@mui/utils/resolveProps';
|
|
7
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A higher order component that consumes a slot from the props and renders the component provided in the slot.
|
|
12
|
+
*
|
|
13
|
+
* This HOC will wrap a single component, and will render the component provided in the slot, if it exists.
|
|
14
|
+
*
|
|
15
|
+
* If you need to render multiple components, you can manually consume the slots from the props and render them in your component instead of using this HOC.
|
|
16
|
+
*
|
|
17
|
+
* In the example below, `MyComponent` will render the component provided in `mySlot` slot, if it exists. Otherwise, it will render the `DefaultComponent`.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
*
|
|
21
|
+
* ```tsx
|
|
22
|
+
* type MyComponentProps = {
|
|
23
|
+
* direction: 'row' | 'column';
|
|
24
|
+
* slots?: {
|
|
25
|
+
* mySlot?: React.JSXElementConstructor<{ direction: 'row' | 'column' }>;
|
|
26
|
+
* }
|
|
27
|
+
* };
|
|
28
|
+
*
|
|
29
|
+
* const MyComponent = consumeSlots(
|
|
30
|
+
* 'MuiMyComponent',
|
|
31
|
+
* 'mySlot',
|
|
32
|
+
* function DefaultComponent(props: MyComponentProps) {
|
|
33
|
+
* return (
|
|
34
|
+
* <div className={props.classes.root}>
|
|
35
|
+
* {props.direction}
|
|
36
|
+
* </div>
|
|
37
|
+
* );
|
|
38
|
+
* }
|
|
39
|
+
* );
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @param {string} name The mui component name.
|
|
43
|
+
* @param {string} slotPropName The name of the prop to retrieve the slot from.
|
|
44
|
+
* @param {object} options Options for the HOC.
|
|
45
|
+
* @param {boolean} options.propagateSlots Whether to propagate the slots to the component, this is always false if the slot is provided.
|
|
46
|
+
* @param {Record<string, any>} options.defaultProps A set of defaults for the component, will be deep merged with the props.
|
|
47
|
+
* @param {Array<keyof Props>} options.omitProps An array of props to omit from the component.
|
|
48
|
+
* @param {Function} options.classesResolver A function that returns the classes for the component. It receives the props, after theme props and defaults have been applied. And the theme object as the second argument.
|
|
49
|
+
* @param InComponent The component to render if the slot is not provided.
|
|
50
|
+
*/
|
|
51
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
52
|
+
export const consumeSlots = (name, slotPropName, options, InComponent) => {
|
|
53
|
+
function ConsumeSlotsInternal(props, ref) {
|
|
54
|
+
const themedProps = useThemeProps({
|
|
55
|
+
props,
|
|
56
|
+
// eslint-disable-next-line material-ui/mui-name-matches-component-name
|
|
57
|
+
name
|
|
58
|
+
});
|
|
59
|
+
const defaultProps = typeof options.defaultProps === 'function' ? options.defaultProps(themedProps) : options.defaultProps ?? {};
|
|
60
|
+
const defaultizedProps = resolveProps(defaultProps, themedProps);
|
|
61
|
+
const _ref = defaultizedProps,
|
|
62
|
+
{
|
|
63
|
+
slots,
|
|
64
|
+
slotProps
|
|
65
|
+
} = _ref,
|
|
66
|
+
other = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
67
|
+
const theme = useTheme();
|
|
68
|
+
const classes = options.classesResolver?.(defaultizedProps, theme);
|
|
69
|
+
|
|
70
|
+
// Can be a function component or a forward ref component.
|
|
71
|
+
const Component = slots?.[slotPropName] ?? InComponent;
|
|
72
|
+
const propagateSlots = options.propagateSlots && !slots?.[slotPropName];
|
|
73
|
+
const _useSlotProps = useSlotProps({
|
|
74
|
+
elementType: Component,
|
|
75
|
+
externalSlotProps: slotProps?.[slotPropName],
|
|
76
|
+
additionalProps: _extends({}, other, {
|
|
77
|
+
classes
|
|
78
|
+
}, propagateSlots && {
|
|
79
|
+
slots,
|
|
80
|
+
slotProps
|
|
81
|
+
}),
|
|
82
|
+
ownerState: {}
|
|
83
|
+
}),
|
|
84
|
+
originalOutProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded2);
|
|
85
|
+
const outProps = _extends({}, originalOutProps);
|
|
86
|
+
for (const prop of options.omitProps ?? []) {
|
|
87
|
+
delete outProps[prop];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Component can be wrapped in React.forwardRef or just a function that accepts (props, ref).
|
|
91
|
+
// If it is a plain function which accepts two arguments, we need to wrap it in React.forwardRef.
|
|
92
|
+
const OutComponent = Component.length >= 2 ? /*#__PURE__*/React.forwardRef(Component) : Component;
|
|
93
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
94
|
+
OutComponent.displayName = `${name}.slots.${slotPropName}`;
|
|
95
|
+
}
|
|
96
|
+
return /*#__PURE__*/_jsx(OutComponent, _extends({}, outProps, {
|
|
97
|
+
ref: ref
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
return /*#__PURE__*/React.forwardRef(ConsumeSlotsInternal);
|
|
101
|
+
};
|
|
@@ -2,7 +2,6 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import { useTheme, useThemeProps } from '@mui/material/styles';
|
|
3
3
|
import resolveProps from '@mui/utils/resolveProps';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import * as ReactIs from 'react-is';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* A higher order component that consumes and merges the theme `defaultProps` and handles the `classes` and renders the component.
|
|
@@ -50,30 +49,22 @@ import * as ReactIs from 'react-is';
|
|
|
50
49
|
* @param InComponent The component to render if the slot is not provided.
|
|
51
50
|
*/
|
|
52
51
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
53
|
-
export const consumeThemeProps = (name, options, InComponent) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
InComponent.displayName = name;
|
|
67
|
-
}
|
|
68
|
-
const OutComponent = ReactIs.isForwardRef(InComponent) ? InComponent :
|
|
69
|
-
/*#__PURE__*/
|
|
70
|
-
// InComponent needs to be a function that accepts `(props, ref)`
|
|
71
|
-
// @ts-expect-error
|
|
72
|
-
React.forwardRef(InComponent);
|
|
73
|
-
return /*#__PURE__*/_jsx(OutComponent, _extends({}, outProps, {
|
|
74
|
-
classes: classes,
|
|
75
|
-
ref: ref
|
|
76
|
-
}));
|
|
52
|
+
export const consumeThemeProps = (name, options, InComponent) => /*#__PURE__*/React.forwardRef(function ConsumeThemeInternal(props, ref) {
|
|
53
|
+
const themedProps = useThemeProps({
|
|
54
|
+
props,
|
|
55
|
+
// eslint-disable-next-line material-ui/mui-name-matches-component-name
|
|
56
|
+
name
|
|
57
|
+
});
|
|
58
|
+
const defaultProps = typeof options.defaultProps === 'function' ? options.defaultProps(themedProps) : options.defaultProps ?? {};
|
|
59
|
+
const outProps = resolveProps(defaultProps, themedProps);
|
|
60
|
+
const theme = useTheme();
|
|
61
|
+
const classes = options.classesResolver?.(outProps, theme);
|
|
62
|
+
const OutComponent = /*#__PURE__*/React.forwardRef(InComponent);
|
|
63
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
64
|
+
OutComponent.displayName = `consumeThemeProps(${name})`;
|
|
77
65
|
}
|
|
78
|
-
return /*#__PURE__*/
|
|
79
|
-
|
|
66
|
+
return /*#__PURE__*/_jsx(OutComponent, _extends({}, outProps, {
|
|
67
|
+
classes: classes,
|
|
68
|
+
ref: ref
|
|
69
|
+
}));
|
|
70
|
+
});
|
|
@@ -22,6 +22,7 @@ function AnimatedBarElement(props) {
|
|
|
22
22
|
} = props,
|
|
23
23
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
24
24
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_web.animated.rect, (0, _extends2.default)({}, other, {
|
|
25
|
+
// @ts-expect-error
|
|
25
26
|
filter: ownerState.isHighlighted ? 'brightness(120%)' : undefined,
|
|
26
27
|
opacity: ownerState.isFaded ? 0.3 : 1
|
|
27
28
|
}));
|
|
@@ -12,7 +12,6 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
13
|
var _styles = require("@mui/material/styles");
|
|
14
14
|
var _BarPlot = require("./BarPlot");
|
|
15
|
-
var _ChartContainer = require("../ChartContainer");
|
|
16
15
|
var _ChartsAxis = require("../ChartsAxis");
|
|
17
16
|
var _ChartsTooltip = require("../ChartsTooltip");
|
|
18
17
|
var _ChartsLegend = require("../ChartsLegend");
|
|
@@ -22,6 +21,10 @@ var _ChartsGrid = require("../ChartsGrid");
|
|
|
22
21
|
var _ChartsOnAxisClickHandler = require("../ChartsOnAxisClickHandler");
|
|
23
22
|
var _ChartsOverlay = require("../ChartsOverlay/ChartsOverlay");
|
|
24
23
|
var _useBarChartProps = require("./useBarChartProps");
|
|
24
|
+
var _context = require("../context");
|
|
25
|
+
var _ChartsSurface = require("../ChartsSurface");
|
|
26
|
+
var _useChartContainerProps = require("../ChartContainer/useChartContainerProps");
|
|
27
|
+
var _ChartsWrapper = require("../internals/components/ChartsWrapper");
|
|
25
28
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
29
|
/**
|
|
27
30
|
* Demos:
|
|
@@ -40,6 +43,7 @@ const BarChart = exports.BarChart = /*#__PURE__*/React.forwardRef(function BarCh
|
|
|
40
43
|
name: 'MuiBarChart'
|
|
41
44
|
});
|
|
42
45
|
const {
|
|
46
|
+
chartsWrapperProps,
|
|
43
47
|
chartContainerProps,
|
|
44
48
|
barPlotProps,
|
|
45
49
|
axisClickHandlerProps,
|
|
@@ -52,13 +56,19 @@ const BarChart = exports.BarChart = /*#__PURE__*/React.forwardRef(function BarCh
|
|
|
52
56
|
legendProps,
|
|
53
57
|
children
|
|
54
58
|
} = (0, _useBarChartProps.useBarChartProps)(props);
|
|
59
|
+
const {
|
|
60
|
+
chartDataProviderProps,
|
|
61
|
+
chartsSurfaceProps
|
|
62
|
+
} = (0, _useChartContainerProps.useChartContainerProps)(chartContainerProps, ref);
|
|
55
63
|
const Tooltip = props.slots?.tooltip ?? _ChartsTooltip.ChartsTooltip;
|
|
56
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_context.ChartDataProvider, (0, _extends2.default)({}, chartDataProviderProps, {
|
|
65
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsWrapper.ChartsWrapper, (0, _extends2.default)({}, chartsWrapperProps, {
|
|
66
|
+
children: [!props.hideLegend && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legendProps)), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsSurface.ChartsSurface, (0, _extends2.default)({}, chartsSurfaceProps, {
|
|
67
|
+
children: [props.onAxisClick && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOnAxisClickHandler.ChartsOnAxisClickHandler, (0, _extends2.default)({}, axisClickHandlerProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, (0, _extends2.default)({}, gridProps)), /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", (0, _extends2.default)({}, clipPathGroupProps, {
|
|
68
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_BarPlot.BarPlot, (0, _extends2.default)({}, barPlotProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, (0, _extends2.default)({}, overlayProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({}, axisHighlightProps))]
|
|
69
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), !props.loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(Tooltip, (0, _extends2.default)({}, props.slotProps?.tooltip)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsClipPath.ChartsClipPath, (0, _extends2.default)({}, clipPathProps)), children]
|
|
70
|
+
}))]
|
|
71
|
+
}))
|
|
62
72
|
}));
|
|
63
73
|
});
|
|
64
74
|
process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
package/node/BarChart/legend.js
CHANGED
|
@@ -10,6 +10,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
10
10
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
11
|
var _useId = _interopRequireDefault(require("@mui/utils/useId"));
|
|
12
12
|
var _constants = require("../constants");
|
|
13
|
+
var _calculateMargins = require("../internals/calculateMargins");
|
|
13
14
|
const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "onAxisClick", "axisHighlight", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "children", "slots", "slotProps", "skipAnimation", "loading", "layout", "onItemClick", "highlightedItem", "onHighlightChange", "borderRadius", "barLabel", "className", "hideLegend"];
|
|
14
15
|
/**
|
|
15
16
|
* A helper function that extracts BarChartProps from the input props
|
|
@@ -47,7 +48,8 @@ const useBarChartProps = props => {
|
|
|
47
48
|
onHighlightChange,
|
|
48
49
|
borderRadius,
|
|
49
50
|
barLabel,
|
|
50
|
-
className
|
|
51
|
+
className,
|
|
52
|
+
hideLegend
|
|
51
53
|
} = props,
|
|
52
54
|
rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
53
55
|
const id = (0, _useId.default)();
|
|
@@ -67,7 +69,12 @@ const useBarChartProps = props => {
|
|
|
67
69
|
})),
|
|
68
70
|
width,
|
|
69
71
|
height,
|
|
70
|
-
margin,
|
|
72
|
+
margin: (0, _calculateMargins.calculateMargins)({
|
|
73
|
+
margin,
|
|
74
|
+
hideLegend,
|
|
75
|
+
slotProps,
|
|
76
|
+
series
|
|
77
|
+
}),
|
|
71
78
|
colors,
|
|
72
79
|
dataset,
|
|
73
80
|
xAxis: xAxis ?? (hasHorizontalSeries ? undefined : [(0, _extends2.default)({
|
|
@@ -76,7 +83,6 @@ const useBarChartProps = props => {
|
|
|
76
83
|
yAxis: yAxis ?? (hasHorizontalSeries ? [(0, _extends2.default)({
|
|
77
84
|
id: _constants.DEFAULT_Y_AXIS_KEY
|
|
78
85
|
}, defaultAxisConfig)] : undefined),
|
|
79
|
-
sx,
|
|
80
86
|
highlightedItem,
|
|
81
87
|
onHighlightChange,
|
|
82
88
|
disableAxisListener: slotProps?.tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
|
|
@@ -125,7 +131,13 @@ const useBarChartProps = props => {
|
|
|
125
131
|
slots,
|
|
126
132
|
slotProps
|
|
127
133
|
};
|
|
134
|
+
const chartsWrapperProps = {
|
|
135
|
+
sx,
|
|
136
|
+
legendPosition: props.slotProps?.legend?.position,
|
|
137
|
+
legendDirection: props.slotProps?.legend?.direction
|
|
138
|
+
};
|
|
128
139
|
return {
|
|
140
|
+
chartsWrapperProps,
|
|
129
141
|
chartContainerProps,
|
|
130
142
|
barPlotProps,
|
|
131
143
|
axisClickHandlerProps,
|
|
@@ -7,32 +7,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
9
|
exports.ChartsLabel = void 0;
|
|
10
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
|
-
var _styles = require("@mui/material/styles");
|
|
15
14
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
16
15
|
var _labelClasses = require("./labelClasses");
|
|
17
16
|
var _consumeThemeProps = require("../internals/consumeThemeProps");
|
|
18
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
18
|
const _excluded = ["children", "className", "classes"];
|
|
20
|
-
const Root = (0, _styles.styled)('span', {
|
|
21
|
-
name: 'MuiChartsLabel',
|
|
22
|
-
slot: 'Root',
|
|
23
|
-
overridesResolver: (props, styles) => styles.root
|
|
24
|
-
})(({
|
|
25
|
-
theme
|
|
26
|
-
}) => (0, _extends2.default)({}, theme.typography.caption, {
|
|
27
|
-
color: (theme.vars || theme).palette.text.primary,
|
|
28
|
-
lineHeight: undefined,
|
|
29
|
-
display: 'flex'
|
|
30
|
-
}));
|
|
31
|
-
|
|
32
19
|
/**
|
|
33
|
-
* @ignore - internal component.
|
|
34
|
-
*
|
|
35
20
|
* Generates the label mark for the tooltip and legend.
|
|
21
|
+
* @ignore - internal component.
|
|
36
22
|
*/
|
|
37
23
|
const ChartsLabel = exports.ChartsLabel = (0, _consumeThemeProps.consumeThemeProps)('MuiChartsLabel', {
|
|
38
24
|
classesResolver: _labelClasses.useUtilityClasses
|
|
@@ -43,9 +29,8 @@ const ChartsLabel = exports.ChartsLabel = (0, _consumeThemeProps.consumeThemePro
|
|
|
43
29
|
classes
|
|
44
30
|
} = props,
|
|
45
31
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
46
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
32
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", (0, _extends2.default)({
|
|
47
33
|
className: (0, _clsx.default)(classes?.root, className),
|
|
48
|
-
ownerState: props,
|
|
49
34
|
ref: ref
|
|
50
35
|
}, other, {
|
|
51
36
|
children: children
|
|
@@ -16,18 +16,18 @@ var _clsx = _interopRequireDefault(require("clsx"));
|
|
|
16
16
|
var _labelGradientClasses = require("./labelGradientClasses");
|
|
17
17
|
var _consumeThemeProps = require("../internals/consumeThemeProps");
|
|
18
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
-
const _excluded = ["gradientId", "direction", "classes", "className"];
|
|
19
|
+
const _excluded = ["gradientId", "direction", "classes", "className", "rotate", "reverse", "thickness"];
|
|
20
20
|
const getRotation = (direction, reverse, rotate) => {
|
|
21
21
|
if (!rotate && reverse) {
|
|
22
|
-
return direction === '
|
|
22
|
+
return direction === 'vertical' ? 90 : 180;
|
|
23
23
|
}
|
|
24
24
|
if (rotate && !reverse) {
|
|
25
|
-
return direction === '
|
|
25
|
+
return direction === 'vertical' ? 0 : 90;
|
|
26
26
|
}
|
|
27
27
|
if (rotate && reverse) {
|
|
28
|
-
return direction === '
|
|
28
|
+
return direction === 'vertical' ? 180 : -90;
|
|
29
29
|
}
|
|
30
|
-
return direction === '
|
|
30
|
+
return direction === 'vertical' ? -90 : 0;
|
|
31
31
|
};
|
|
32
32
|
const Root = (0, _styles.styled)('div', {
|
|
33
33
|
name: 'MuiChartsLabelGradient',
|
|
@@ -45,17 +45,17 @@ const Root = (0, _styles.styled)('div', {
|
|
|
45
45
|
borderRadius: 2,
|
|
46
46
|
overflow: 'hidden'
|
|
47
47
|
},
|
|
48
|
-
[`&.${_labelGradientClasses.labelGradientClasses.
|
|
48
|
+
[`&.${_labelGradientClasses.labelGradientClasses.horizontal}`]: {
|
|
49
49
|
width: '100%',
|
|
50
50
|
[`.${_labelGradientClasses.labelGradientClasses.mask}`]: {
|
|
51
|
-
height:
|
|
51
|
+
height: ownerState.thickness,
|
|
52
52
|
width: '100%'
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
|
-
[`&.${_labelGradientClasses.labelGradientClasses.
|
|
55
|
+
[`&.${_labelGradientClasses.labelGradientClasses.vertical}`]: {
|
|
56
56
|
height: '100%',
|
|
57
57
|
[`.${_labelGradientClasses.labelGradientClasses.mask}`]: {
|
|
58
|
-
width:
|
|
58
|
+
width: ownerState.thickness,
|
|
59
59
|
height: '100%',
|
|
60
60
|
'> svg': {
|
|
61
61
|
height: '100%'
|
|
@@ -70,13 +70,13 @@ const Root = (0, _styles.styled)('div', {
|
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
* @ignore - internal component.
|
|
74
|
-
*
|
|
75
73
|
* Generates the label Gradient for the tooltip and legend.
|
|
74
|
+
* @ignore - internal component.
|
|
76
75
|
*/
|
|
77
76
|
const ChartsLabelGradient = exports.ChartsLabelGradient = (0, _consumeThemeProps.consumeThemeProps)('MuiChartsLabelGradient', {
|
|
78
77
|
defaultProps: {
|
|
79
|
-
direction: '
|
|
78
|
+
direction: 'horizontal',
|
|
79
|
+
thickness: 12
|
|
80
80
|
},
|
|
81
81
|
classesResolver: _labelGradientClasses.useUtilityClasses
|
|
82
82
|
}, function ChartsLabelGradient(props, ref) {
|
|
@@ -97,6 +97,7 @@ const ChartsLabelGradient = exports.ChartsLabelGradient = (0, _consumeThemeProps
|
|
|
97
97
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
|
|
98
98
|
viewBox: "0 0 24 24",
|
|
99
99
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("rect", {
|
|
100
|
+
className: classes?.fill,
|
|
100
101
|
width: "24",
|
|
101
102
|
height: "24",
|
|
102
103
|
fill: `url(#${gradientId})`
|
|
@@ -116,13 +117,11 @@ process.env.NODE_ENV !== "production" ? ChartsLabelGradient.propTypes = {
|
|
|
116
117
|
classes: _propTypes.default.object,
|
|
117
118
|
/**
|
|
118
119
|
* The direction of the gradient.
|
|
119
|
-
*
|
|
120
|
-
* @default 'row'
|
|
120
|
+
* @default 'horizontal'
|
|
121
121
|
*/
|
|
122
|
-
direction: _propTypes.default.oneOf(['
|
|
122
|
+
direction: _propTypes.default.oneOf(['vertical', 'horizontal']),
|
|
123
123
|
/**
|
|
124
124
|
* A unique identifier for the gradient.
|
|
125
|
-
*
|
|
126
125
|
* The `gradientId` will be used as `fill="url(#gradientId)"`.
|
|
127
126
|
*/
|
|
128
127
|
gradientId: _propTypes.default.string.isRequired,
|
|
@@ -132,8 +131,12 @@ process.env.NODE_ENV !== "production" ? ChartsLabelGradient.propTypes = {
|
|
|
132
131
|
reverse: _propTypes.default.bool,
|
|
133
132
|
/**
|
|
134
133
|
* If provided, the gradient will be rotated by 90deg.
|
|
135
|
-
*
|
|
136
134
|
* Useful for linear gradients that are not in the correct orientation.
|
|
137
135
|
*/
|
|
138
|
-
rotate: _propTypes.default.bool
|
|
136
|
+
rotate: _propTypes.default.bool,
|
|
137
|
+
/**
|
|
138
|
+
* The thickness of the gradient
|
|
139
|
+
* @default 12
|
|
140
|
+
*/
|
|
141
|
+
thickness: _propTypes.default.number
|
|
139
142
|
} : void 0;
|
|
@@ -59,11 +59,13 @@ const Root = (0, _styles.styled)('div', {
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* @ignore - internal component.
|
|
63
|
-
*
|
|
64
62
|
* Generates the label mark for the tooltip and legend.
|
|
63
|
+
* @ignore - internal component.
|
|
65
64
|
*/
|
|
66
65
|
const ChartsLabelMark = exports.ChartsLabelMark = (0, _consumeThemeProps.consumeThemeProps)('MuiChartsLabelMark', {
|
|
66
|
+
defaultProps: {
|
|
67
|
+
type: 'square'
|
|
68
|
+
},
|
|
67
69
|
classesResolver: _labelMarkClasses.useUtilityClasses
|
|
68
70
|
}, function ChartsLabelMark(props, ref) {
|
|
69
71
|
const {
|
|
@@ -85,6 +87,7 @@ const ChartsLabelMark = exports.ChartsLabelMark = (0, _consumeThemeProps.consume
|
|
|
85
87
|
viewBox: "0 0 24 24",
|
|
86
88
|
preserveAspectRatio: type === 'line' ? 'none' : undefined,
|
|
87
89
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("rect", {
|
|
90
|
+
className: classes?.fill,
|
|
88
91
|
width: "24",
|
|
89
92
|
height: "24",
|
|
90
93
|
fill: color
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "labelClasses", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _labelClasses.labelClasses;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "labelGradientClasses", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _labelGradientClasses.labelGradientClasses;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "labelMarkClasses", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _labelMarkClasses.labelMarkClasses;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var _labelClasses = require("./labelClasses");
|
|
25
|
+
var _labelMarkClasses = require("./labelMarkClasses");
|
|
26
|
+
var _labelGradientClasses = require("./labelGradientClasses");
|
|
@@ -12,14 +12,15 @@ var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generat
|
|
|
12
12
|
function getLabelGradientUtilityClass(slot) {
|
|
13
13
|
return (0, _generateUtilityClass.default)('MuiChartsLabelGradient', slot);
|
|
14
14
|
}
|
|
15
|
-
const labelGradientClasses = exports.labelGradientClasses = (0, _generateUtilityClasses.default)('MuiChartsLabelGradient', ['root', '
|
|
15
|
+
const labelGradientClasses = exports.labelGradientClasses = (0, _generateUtilityClasses.default)('MuiChartsLabelGradient', ['root', 'vertical', 'horizontal', 'mask', 'fill']);
|
|
16
16
|
const useUtilityClasses = props => {
|
|
17
17
|
const {
|
|
18
18
|
direction
|
|
19
19
|
} = props;
|
|
20
20
|
const slots = {
|
|
21
21
|
root: ['root', direction],
|
|
22
|
-
mask: ['mask']
|
|
22
|
+
mask: ['mask'],
|
|
23
|
+
fill: ['fill']
|
|
23
24
|
};
|
|
24
25
|
return (0, _composeClasses.default)(slots, getLabelGradientUtilityClass, props.classes);
|
|
25
26
|
};
|