@mui/x-charts 8.0.0-alpha.5 → 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 +206 -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
|
@@ -1,31 +1,27 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
+
import type { Direction } from './direction';
|
|
4
|
+
import { SeriesLegendItemContext } from './legendContext.types';
|
|
5
|
+
import { type ChartsLegendClasses } from './chartsLegendClasses';
|
|
6
|
+
export interface ChartsLegendProps {
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
8
|
+
* Callback fired when a legend item is clicked.
|
|
9
|
+
* @param {React.MouseEvent<HTMLButtonElement, MouseEvent>} event The click event.
|
|
10
|
+
* @param {SeriesLegendItemContext} legendItem The legend item data.
|
|
11
|
+
* @param {number} index The index of the clicked legend item.
|
|
9
12
|
*/
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
export interface ChartsLegendSlotProps {
|
|
13
|
-
legend?: Partial<LegendRendererProps>;
|
|
14
|
-
}
|
|
15
|
-
export interface ChartsLegendProps extends ChartsLegendPropsBase {
|
|
13
|
+
onItemClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>, legendItem: SeriesLegendItemContext, index: number) => void;
|
|
16
14
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* The direction of the legend layout.
|
|
16
|
+
* The default depends on the chart.
|
|
19
17
|
*/
|
|
20
|
-
|
|
18
|
+
direction?: Direction;
|
|
21
19
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @default {}
|
|
20
|
+
* Override or extend the styles applied to the component.
|
|
24
21
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
declare namespace ChartsLegend {
|
|
29
|
-
var propTypes: any;
|
|
22
|
+
classes?: Partial<ChartsLegendClasses>;
|
|
23
|
+
className?: string;
|
|
24
|
+
sx?: SxProps<Theme>;
|
|
30
25
|
}
|
|
26
|
+
declare const ChartsLegend: React.ForwardRefExoticComponent<ChartsLegendProps & import("./chartsLegend.types").ChartsLegendSlotExtension & React.RefAttributes<{}>>;
|
|
31
27
|
export { ChartsLegend };
|
|
@@ -2,68 +2,105 @@
|
|
|
2
2
|
|
|
3
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
4
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
-
const _excluded = ["
|
|
5
|
+
const _excluded = ["direction", "onItemClick", "className", "classes"];
|
|
6
6
|
import * as React from 'react';
|
|
7
|
+
import { styled } from '@mui/material/styles';
|
|
7
8
|
import PropTypes from 'prop-types';
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
-
const
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
import { useLegend } from "../hooks/useLegend.js";
|
|
11
|
+
import { ChartsLabelMark } from "../ChartsLabel/ChartsLabelMark.js";
|
|
12
|
+
import { seriesContextBuilder } from "./onClickContextBuilder.js";
|
|
13
|
+
import { legendClasses, useUtilityClasses } from "./chartsLegendClasses.js";
|
|
14
|
+
import { consumeSlots } from "../internals/consumeSlots.js";
|
|
15
|
+
import { ChartsLabel } from "../ChartsLabel/ChartsLabel.js";
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
const RootElement = styled('ul', {
|
|
18
|
+
name: 'MuiChartsLegend',
|
|
19
|
+
slot: 'Root',
|
|
20
|
+
overridesResolver: (props, styles) => styles.root
|
|
21
|
+
})(({
|
|
22
|
+
ownerState,
|
|
23
|
+
theme
|
|
24
|
+
}) => _extends({}, theme.typography.caption, {
|
|
25
|
+
color: (theme.vars || theme).palette.text.primary,
|
|
26
|
+
lineHeight: '100%',
|
|
27
|
+
display: 'flex',
|
|
28
|
+
flexDirection: ownerState.direction === 'vertical' ? 'column' : 'row',
|
|
29
|
+
alignItems: ownerState.direction === 'vertical' ? undefined : 'center',
|
|
30
|
+
flexShrink: 0,
|
|
31
|
+
gap: theme.spacing(2),
|
|
32
|
+
listStyleType: 'none',
|
|
33
|
+
paddingInlineStart: 0,
|
|
34
|
+
marginBlock: theme.spacing(1),
|
|
35
|
+
marginInline: theme.spacing(1),
|
|
36
|
+
flexWrap: 'wrap',
|
|
37
|
+
li: {
|
|
38
|
+
display: ownerState.direction === 'horizontal' ? 'inline-flex' : undefined
|
|
39
|
+
},
|
|
40
|
+
[`button.${legendClasses.series}`]: {
|
|
41
|
+
// Reset button styles
|
|
42
|
+
background: 'none',
|
|
43
|
+
border: 'none',
|
|
44
|
+
padding: 0,
|
|
45
|
+
fontFamily: 'inherit',
|
|
46
|
+
fontWeight: 'inherit',
|
|
47
|
+
fontSize: 'inherit',
|
|
48
|
+
letterSpacing: 'inherit',
|
|
49
|
+
color: 'inherit'
|
|
50
|
+
},
|
|
51
|
+
[`& .${legendClasses.series}`]: {
|
|
52
|
+
display: ownerState.direction === 'vertical' ? 'flex' : 'inline-flex',
|
|
53
|
+
alignItems: 'center',
|
|
54
|
+
gap: theme.spacing(1)
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
57
|
+
const ChartsLegend = consumeSlots('MuiChartsLegend', 'legend', {
|
|
58
|
+
defaultProps: {
|
|
59
|
+
direction: 'horizontal'
|
|
60
|
+
},
|
|
61
|
+
// @ts-expect-error position is used only in the slots, but it is passed to the SVG wrapper.
|
|
62
|
+
// We omit it here to avoid passing to slots.
|
|
63
|
+
omitProps: ['position'],
|
|
64
|
+
classesResolver: useUtilityClasses
|
|
65
|
+
}, function ChartsLegend(props, ref) {
|
|
66
|
+
const data = useLegend();
|
|
17
67
|
const {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
68
|
+
onItemClick,
|
|
69
|
+
className,
|
|
70
|
+
classes
|
|
71
|
+
} = props,
|
|
72
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
73
|
+
if (data.items.length === 0) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const Element = onItemClick ? 'button' : 'div';
|
|
77
|
+
return /*#__PURE__*/_jsx(RootElement, _extends({
|
|
78
|
+
className: clsx(classes?.root, className),
|
|
79
|
+
ref: ref
|
|
80
|
+
}, other, {
|
|
81
|
+
ownerState: props,
|
|
82
|
+
children: data.items.map((item, i) => {
|
|
83
|
+
return /*#__PURE__*/_jsx("li", {
|
|
84
|
+
children: /*#__PURE__*/_jsxs(Element, {
|
|
85
|
+
className: classes?.series,
|
|
86
|
+
role: onItemClick ? 'button' : undefined,
|
|
87
|
+
type: onItemClick ? 'button' : undefined,
|
|
88
|
+
onClick: onItemClick ?
|
|
89
|
+
// @ts-ignore onClick is only attached to a button
|
|
90
|
+
event => onItemClick(event, seriesContextBuilder(item), i) : undefined,
|
|
91
|
+
children: [/*#__PURE__*/_jsx(ChartsLabelMark, {
|
|
92
|
+
className: classes?.mark,
|
|
93
|
+
color: item.color,
|
|
94
|
+
type: item.markType
|
|
95
|
+
}), /*#__PURE__*/_jsx(ChartsLabel, {
|
|
96
|
+
className: classes?.label,
|
|
97
|
+
children: item.label
|
|
98
|
+
})]
|
|
99
|
+
})
|
|
100
|
+
}, item.id);
|
|
101
|
+
})
|
|
51
102
|
}));
|
|
52
|
-
|
|
53
|
-
const seriesToDisplay = getSeriesToDisplay(series);
|
|
54
|
-
const ChartLegendRender = slots?.legend ?? DefaultChartsLegend;
|
|
55
|
-
const chartLegendRenderProps = useSlotProps({
|
|
56
|
-
elementType: ChartLegendRender,
|
|
57
|
-
externalSlotProps: slotProps?.legend,
|
|
58
|
-
additionalProps: _extends({}, other, {
|
|
59
|
-
classes,
|
|
60
|
-
series,
|
|
61
|
-
seriesToDisplay
|
|
62
|
-
}),
|
|
63
|
-
ownerState: {}
|
|
64
|
-
});
|
|
65
|
-
return /*#__PURE__*/_jsx(ChartLegendRender, _extends({}, chartLegendRenderProps));
|
|
66
|
-
}
|
|
103
|
+
});
|
|
67
104
|
process.env.NODE_ENV !== "production" ? ChartsLegend.propTypes = {
|
|
68
105
|
// ----------------------------- Warning --------------------------------
|
|
69
106
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -73,66 +110,19 @@ process.env.NODE_ENV !== "production" ? ChartsLegend.propTypes = {
|
|
|
73
110
|
* Override or extend the styles applied to the component.
|
|
74
111
|
*/
|
|
75
112
|
classes: PropTypes.object,
|
|
113
|
+
className: PropTypes.string,
|
|
76
114
|
/**
|
|
77
115
|
* The direction of the legend layout.
|
|
78
116
|
* The default depends on the chart.
|
|
79
117
|
*/
|
|
80
|
-
direction: PropTypes.oneOf(['
|
|
81
|
-
/**
|
|
82
|
-
* Set to true to hide the legend.
|
|
83
|
-
* @default false
|
|
84
|
-
*/
|
|
85
|
-
hidden: PropTypes.bool,
|
|
86
|
-
/**
|
|
87
|
-
* Space between two legend items (in px).
|
|
88
|
-
* @default 10
|
|
89
|
-
*/
|
|
90
|
-
itemGap: PropTypes.number,
|
|
91
|
-
/**
|
|
92
|
-
* Height of the item mark (in px).
|
|
93
|
-
* @default 20
|
|
94
|
-
*/
|
|
95
|
-
itemMarkHeight: PropTypes.number,
|
|
96
|
-
/**
|
|
97
|
-
* Width of the item mark (in px).
|
|
98
|
-
* @default 20
|
|
99
|
-
*/
|
|
100
|
-
itemMarkWidth: PropTypes.number,
|
|
101
|
-
/**
|
|
102
|
-
* Style applied to legend labels.
|
|
103
|
-
* @default theme.typography.subtitle1
|
|
104
|
-
*/
|
|
105
|
-
labelStyle: PropTypes.object,
|
|
106
|
-
/**
|
|
107
|
-
* Space between the mark and the label (in px).
|
|
108
|
-
* @default 5
|
|
109
|
-
*/
|
|
110
|
-
markGap: PropTypes.number,
|
|
118
|
+
direction: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
111
119
|
/**
|
|
112
120
|
* Callback fired when a legend item is clicked.
|
|
113
|
-
* @param {React.MouseEvent<
|
|
121
|
+
* @param {React.MouseEvent<HTMLButtonElement, MouseEvent>} event The click event.
|
|
114
122
|
* @param {SeriesLegendItemContext} legendItem The legend item data.
|
|
115
123
|
* @param {number} index The index of the clicked legend item.
|
|
116
124
|
*/
|
|
117
125
|
onItemClick: PropTypes.func,
|
|
118
|
-
/**
|
|
119
|
-
* Legend padding (in px).
|
|
120
|
-
* Can either be a single number, or an object with top, left, bottom, right properties.
|
|
121
|
-
* @default 10
|
|
122
|
-
*/
|
|
123
|
-
padding: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
124
|
-
bottom: PropTypes.number,
|
|
125
|
-
left: PropTypes.number,
|
|
126
|
-
right: PropTypes.number,
|
|
127
|
-
top: PropTypes.number
|
|
128
|
-
})]),
|
|
129
|
-
/**
|
|
130
|
-
* The position of the legend.
|
|
131
|
-
*/
|
|
132
|
-
position: PropTypes.shape({
|
|
133
|
-
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
134
|
-
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
135
|
-
}),
|
|
136
126
|
/**
|
|
137
127
|
* The props used for each component slot.
|
|
138
128
|
* @default {}
|
|
@@ -142,6 +132,7 @@ process.env.NODE_ENV !== "production" ? ChartsLegend.propTypes = {
|
|
|
142
132
|
* Overridable component slots.
|
|
143
133
|
* @default {}
|
|
144
134
|
*/
|
|
145
|
-
slots: PropTypes.object
|
|
135
|
+
slots: PropTypes.object,
|
|
136
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
146
137
|
} : void 0;
|
|
147
138
|
export { ChartsLegend };
|
|
@@ -1,65 +1,56 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ColorLegendSelector
|
|
2
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
+
import { AppendKeys } from '@mui/x-internals/types';
|
|
4
|
+
import { ColorLegendSelector } from './colorLegend.types';
|
|
5
|
+
import { ChartsLabelGradientProps } from '../ChartsLabel/ChartsLabelGradient';
|
|
6
|
+
import { Direction } from './direction';
|
|
7
|
+
import { ContinuousColorLegendClasses } from './continuousColorLegendClasses';
|
|
5
8
|
type LabelFormatter = (params: {
|
|
6
9
|
value: number | Date;
|
|
7
10
|
formattedValue: string;
|
|
8
11
|
}) => string;
|
|
9
|
-
export interface ContinuousColorLegendProps extends
|
|
12
|
+
export interface ContinuousColorLegendProps extends ColorLegendSelector, AppendKeys<Pick<ChartsLabelGradientProps, 'rotate'>, 'gradient'>, Pick<ChartsLabelGradientProps, 'thickness'> {
|
|
13
|
+
/**
|
|
14
|
+
* The direction of the legend layout.
|
|
15
|
+
* @default 'horizontal'
|
|
16
|
+
*/
|
|
17
|
+
direction?: Direction;
|
|
10
18
|
/**
|
|
11
19
|
* The label to display at the minimum side of the gradient.
|
|
12
20
|
* Can either be a string, or a function.
|
|
13
|
-
* @default
|
|
21
|
+
* @default formattedValue
|
|
14
22
|
*/
|
|
15
23
|
minLabel?: string | LabelFormatter;
|
|
16
24
|
/**
|
|
17
25
|
* The label to display at the maximum side of the gradient.
|
|
18
26
|
* Can either be a string, or a function.
|
|
19
27
|
* If not defined, the formatted maximal value is display.
|
|
20
|
-
* @default
|
|
28
|
+
* @default formattedValue
|
|
21
29
|
*/
|
|
22
30
|
maxLabel?: string | LabelFormatter;
|
|
23
31
|
/**
|
|
24
|
-
*
|
|
32
|
+
* The id for the gradient to use.
|
|
33
|
+
* If not provided, it will use the generated gradient from the axis configuration.
|
|
34
|
+
* The `gradientId` will be used as `fill="url(#gradientId)"`.
|
|
25
35
|
* @default auto-generated id
|
|
26
36
|
*/
|
|
27
|
-
|
|
37
|
+
gradientId?: string;
|
|
28
38
|
/**
|
|
29
|
-
*
|
|
30
|
-
* @default '
|
|
39
|
+
* Where to position the labels relative to the gradient.
|
|
40
|
+
* @default 'end'
|
|
31
41
|
*/
|
|
32
|
-
|
|
42
|
+
labelPosition?: 'start' | 'end' | 'extremes';
|
|
33
43
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* The '100%' is the length of the svg.
|
|
37
|
-
* @default '50%'
|
|
44
|
+
* If `true`, the gradient and labels will be reversed.
|
|
45
|
+
* @default false
|
|
38
46
|
*/
|
|
39
|
-
|
|
47
|
+
reverse?: boolean;
|
|
40
48
|
/**
|
|
41
|
-
*
|
|
42
|
-
* @default 5
|
|
49
|
+
* Override or extend the styles applied to the component.
|
|
43
50
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
* @default 'middle'
|
|
48
|
-
*/
|
|
49
|
-
align?: 'start' | 'middle' | 'end';
|
|
50
|
-
/**
|
|
51
|
-
* The space between the gradient bar and the labels.
|
|
52
|
-
* @default 4
|
|
53
|
-
*/
|
|
54
|
-
spacing?: number;
|
|
55
|
-
/**
|
|
56
|
-
* The style applied to labels.
|
|
57
|
-
* @default theme.typography.subtitle1
|
|
58
|
-
*/
|
|
59
|
-
labelStyle?: ChartsTextProps['style'];
|
|
60
|
-
}
|
|
61
|
-
declare function ContinuousColorLegend(props: ContinuousColorLegendProps): React.JSX.Element | null;
|
|
62
|
-
declare namespace ContinuousColorLegend {
|
|
63
|
-
var propTypes: any;
|
|
51
|
+
classes?: Partial<ContinuousColorLegendClasses>;
|
|
52
|
+
className?: string;
|
|
53
|
+
sx?: SxProps<Theme>;
|
|
64
54
|
}
|
|
55
|
+
declare const ContinuousColorLegend: React.ForwardRefExoticComponent<ContinuousColorLegendProps & import("./chartsLegend.types").ChartsLegendSlotExtension & React.RefAttributes<{}>>;
|
|
65
56
|
export { ContinuousColorLegend };
|