@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.
Files changed (251) hide show
  1. package/BarChart/AnimatedBarElement.js +1 -0
  2. package/BarChart/BarChart.js +17 -7
  3. package/BarChart/BarLabel/BarLabel.d.ts +1 -479
  4. package/BarChart/BarLabel/barLabelClasses.d.ts +1 -1
  5. package/BarChart/legend.js +1 -0
  6. package/BarChart/useBarChartProps.d.ts +4 -2
  7. package/BarChart/useBarChartProps.js +16 -3
  8. package/CHANGELOG.md +127 -1
  9. package/ChartsLabel/ChartsLabel.d.ts +2 -3
  10. package/ChartsLabel/ChartsLabel.js +3 -18
  11. package/ChartsLabel/ChartsLabelGradient.d.ts +9 -8
  12. package/ChartsLabel/ChartsLabelGradient.js +21 -18
  13. package/ChartsLabel/ChartsLabelMark.d.ts +2 -3
  14. package/ChartsLabel/ChartsLabelMark.js +5 -2
  15. package/ChartsLabel/index.d.ts +7 -0
  16. package/ChartsLabel/index.js +6 -0
  17. package/ChartsLabel/labelClasses.d.ts +0 -1
  18. package/ChartsLabel/labelGradientClasses.d.ts +5 -4
  19. package/ChartsLabel/labelGradientClasses.js +3 -2
  20. package/ChartsLabel/labelMarkClasses.d.ts +3 -2
  21. package/ChartsLabel/labelMarkClasses.js +3 -2
  22. package/ChartsLabel/package.json +6 -0
  23. package/ChartsLegend/ChartsLegend.d.ts +18 -22
  24. package/ChartsLegend/ChartsLegend.js +100 -109
  25. package/ChartsLegend/ContinuousColorLegend.d.ts +29 -38
  26. package/ChartsLegend/ContinuousColorLegend.js +198 -321
  27. package/ChartsLegend/PiecewiseColorLegend.d.ts +27 -19
  28. package/ChartsLegend/PiecewiseColorLegend.js +201 -111
  29. package/ChartsLegend/chartsLegend.types.d.ts +17 -60
  30. package/ChartsLegend/chartsLegendClasses.d.ts +7 -8
  31. package/ChartsLegend/chartsLegendClasses.js +16 -2
  32. package/ChartsLegend/colorLegend.types.d.ts +13 -0
  33. package/ChartsLegend/colorLegend.types.js +1 -0
  34. package/ChartsLegend/continuousColorLegendClasses.d.ts +26 -0
  35. package/ChartsLegend/continuousColorLegendClasses.js +23 -0
  36. package/ChartsLegend/direction.d.ts +1 -0
  37. package/ChartsLegend/direction.js +1 -0
  38. package/ChartsLegend/index.d.ts +13 -3
  39. package/ChartsLegend/index.js +9 -3
  40. package/ChartsLegend/legend.types.d.ts +10 -54
  41. package/ChartsLegend/legendContext.types.d.ts +55 -0
  42. package/ChartsLegend/legendContext.types.js +1 -0
  43. package/ChartsLegend/onClickContextBuilder.d.ts +2 -0
  44. package/ChartsLegend/onClickContextBuilder.js +7 -0
  45. package/ChartsLegend/piecewiseColorDefaultLabelFormatter.d.ts +2 -0
  46. package/ChartsLegend/piecewiseColorDefaultLabelFormatter.js +9 -0
  47. package/ChartsLegend/piecewiseColorLegend.types.d.ts +26 -0
  48. package/ChartsLegend/piecewiseColorLegend.types.js +1 -0
  49. package/ChartsLegend/piecewiseColorLegendClasses.d.ts +28 -0
  50. package/ChartsLegend/piecewiseColorLegendClasses.js +23 -0
  51. package/ChartsLegend/useAxis.d.ts +1 -1
  52. package/ChartsLegend/useAxis.js +0 -1
  53. package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
  54. package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
  55. package/ChartsSurface/ChartsSurface.js +0 -1
  56. package/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
  57. package/LineChart/AnimatedArea.js +1 -0
  58. package/LineChart/AnimatedLine.js +1 -0
  59. package/LineChart/AppearingMask.js +1 -0
  60. package/LineChart/CircleMarkElement.js +1 -0
  61. package/LineChart/LineChart.js +20 -10
  62. package/LineChart/MarkElement.js +3 -1
  63. package/LineChart/legend.js +1 -0
  64. package/LineChart/useLineChartProps.d.ts +4 -2
  65. package/LineChart/useLineChartProps.js +15 -2
  66. package/PieChart/PieArc.js +3 -1
  67. package/PieChart/PieArcLabel.js +13 -9
  68. package/PieChart/PieArcLabelPlot.js +1 -0
  69. package/PieChart/PieArcPlot.js +1 -0
  70. package/PieChart/PieChart.js +42 -41
  71. package/PieChart/legend.js +1 -0
  72. package/ScatterChart/ScatterChart.js +21 -11
  73. package/ScatterChart/legend.js +1 -0
  74. package/ScatterChart/useScatterChartProps.d.ts +4 -2
  75. package/ScatterChart/useScatterChartProps.js +15 -2
  76. package/SparkLineChart/SparkLineChart.js +1 -4
  77. package/constants/index.d.ts +1 -0
  78. package/constants/index.js +2 -1
  79. package/context/CartesianProvider/defaultizeAxis.d.ts +9 -9
  80. package/context/ChartDataProvider/useChartDataProviderProps.d.ts +18 -18
  81. package/context/ChartDataProvider/useDefaultizeAxis.d.ts +9 -9
  82. package/context/ChartProvider/ChartProvider.types.d.ts +1 -1
  83. package/context/InteractionSelectors.d.ts +11 -11
  84. package/context/PluginProvider/SeriesFormatter.types.d.ts +1 -1
  85. package/context/PluginProvider/mergePlugins.d.ts +8 -8
  86. package/context/SizeProvider/Size.types.d.ts +1 -1
  87. package/context/SizeProvider/useChartContainerDimensions.d.ts +1 -1
  88. package/hooks/index.d.ts +1 -0
  89. package/hooks/index.js +2 -1
  90. package/hooks/useLegend.d.ts +13 -0
  91. package/{modern/ChartsLegend/utils.js → hooks/useLegend.js} +20 -1
  92. package/hooks/useSvgRef.d.ts +1 -1
  93. package/index.d.ts +1 -0
  94. package/index.js +2 -1
  95. package/internals/calculateMargins.d.ts +7 -0
  96. package/internals/calculateMargins.js +25 -0
  97. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +2 -1
  98. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +60 -16
  99. package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +6 -6
  100. package/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.d.ts +13 -0
  101. package/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.js +61 -0
  102. package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -0
  103. package/internals/components/ChartsWrapper/ChartsWrapper.d.ts +17 -0
  104. package/internals/components/ChartsWrapper/ChartsWrapper.js +66 -0
  105. package/internals/components/ChartsWrapper/index.d.ts +1 -0
  106. package/internals/components/ChartsWrapper/index.js +1 -0
  107. package/internals/consumeSlots.d.ts +48 -0
  108. package/internals/consumeSlots.js +101 -0
  109. package/internals/consumeThemeProps.d.ts +3 -7
  110. package/internals/consumeThemeProps.js +18 -27
  111. package/internals/defaultizeColor.d.ts +6 -1
  112. package/internals/index.d.ts +1 -0
  113. package/internals/index.js +1 -0
  114. package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
  115. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +11 -11
  116. package/internals/plugins/models/plugin.d.ts +1 -1
  117. package/internals/store/useCharts.d.ts +2 -2
  118. package/internals/store/useCharts.types.d.ts +1 -1
  119. package/models/seriesType/common.d.ts +9 -0
  120. package/models/seriesType/pie.d.ts +9 -0
  121. package/modern/BarChart/AnimatedBarElement.js +1 -0
  122. package/modern/BarChart/BarChart.js +17 -7
  123. package/modern/BarChart/legend.js +1 -0
  124. package/modern/BarChart/useBarChartProps.js +16 -3
  125. package/modern/ChartsLabel/ChartsLabel.js +3 -18
  126. package/modern/ChartsLabel/ChartsLabelGradient.js +21 -18
  127. package/modern/ChartsLabel/ChartsLabelMark.js +5 -2
  128. package/modern/ChartsLabel/index.js +6 -0
  129. package/modern/ChartsLabel/labelGradientClasses.js +3 -2
  130. package/modern/ChartsLabel/labelMarkClasses.js +3 -2
  131. package/modern/ChartsLegend/ChartsLegend.js +100 -109
  132. package/modern/ChartsLegend/ContinuousColorLegend.js +198 -321
  133. package/modern/ChartsLegend/PiecewiseColorLegend.js +201 -111
  134. package/modern/ChartsLegend/chartsLegendClasses.js +16 -2
  135. package/modern/ChartsLegend/colorLegend.types.js +1 -0
  136. package/modern/ChartsLegend/continuousColorLegendClasses.js +23 -0
  137. package/modern/ChartsLegend/direction.js +1 -0
  138. package/modern/ChartsLegend/index.js +9 -3
  139. package/modern/ChartsLegend/legendContext.types.js +1 -0
  140. package/modern/ChartsLegend/onClickContextBuilder.js +7 -0
  141. package/modern/ChartsLegend/piecewiseColorDefaultLabelFormatter.js +9 -0
  142. package/modern/ChartsLegend/piecewiseColorLegend.types.js +1 -0
  143. package/modern/ChartsLegend/piecewiseColorLegendClasses.js +23 -0
  144. package/modern/ChartsLegend/useAxis.js +0 -1
  145. package/modern/ChartsSurface/ChartsSurface.js +0 -1
  146. package/modern/LineChart/AnimatedArea.js +1 -0
  147. package/modern/LineChart/AnimatedLine.js +1 -0
  148. package/modern/LineChart/AppearingMask.js +1 -0
  149. package/modern/LineChart/CircleMarkElement.js +1 -0
  150. package/modern/LineChart/LineChart.js +20 -10
  151. package/modern/LineChart/MarkElement.js +3 -1
  152. package/modern/LineChart/legend.js +1 -0
  153. package/modern/LineChart/useLineChartProps.js +15 -2
  154. package/modern/PieChart/PieArc.js +3 -1
  155. package/modern/PieChart/PieArcLabel.js +13 -9
  156. package/modern/PieChart/PieArcLabelPlot.js +1 -0
  157. package/modern/PieChart/PieArcPlot.js +1 -0
  158. package/modern/PieChart/PieChart.js +42 -41
  159. package/modern/PieChart/legend.js +1 -0
  160. package/modern/ScatterChart/ScatterChart.js +21 -11
  161. package/modern/ScatterChart/legend.js +1 -0
  162. package/modern/ScatterChart/useScatterChartProps.js +15 -2
  163. package/modern/SparkLineChart/SparkLineChart.js +1 -4
  164. package/modern/constants/index.js +2 -1
  165. package/modern/hooks/index.js +2 -1
  166. package/{ChartsLegend/utils.js → modern/hooks/useLegend.js} +20 -1
  167. package/modern/index.js +2 -1
  168. package/modern/internals/calculateMargins.js +25 -0
  169. package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +60 -16
  170. package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +6 -6
  171. package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.js +61 -0
  172. package/modern/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -0
  173. package/modern/internals/components/ChartsWrapper/ChartsWrapper.js +66 -0
  174. package/modern/internals/components/ChartsWrapper/index.js +1 -0
  175. package/modern/internals/consumeSlots.js +101 -0
  176. package/modern/internals/consumeThemeProps.js +18 -27
  177. package/modern/internals/index.js +1 -0
  178. package/node/BarChart/AnimatedBarElement.js +1 -0
  179. package/node/BarChart/BarChart.js +17 -7
  180. package/node/BarChart/legend.js +1 -0
  181. package/node/BarChart/useBarChartProps.js +15 -3
  182. package/node/ChartsLabel/ChartsLabel.js +3 -18
  183. package/node/ChartsLabel/ChartsLabelGradient.js +21 -18
  184. package/node/ChartsLabel/ChartsLabelMark.js +5 -2
  185. package/node/ChartsLabel/index.js +26 -0
  186. package/node/ChartsLabel/labelGradientClasses.js +3 -2
  187. package/node/ChartsLabel/labelMarkClasses.js +3 -2
  188. package/node/ChartsLegend/ChartsLegend.js +99 -108
  189. package/node/ChartsLegend/ContinuousColorLegend.js +199 -322
  190. package/node/ChartsLegend/PiecewiseColorLegend.js +201 -111
  191. package/node/ChartsLegend/chartsLegendClasses.js +17 -3
  192. package/node/ChartsLegend/colorLegend.types.js +5 -0
  193. package/node/ChartsLegend/continuousColorLegendClasses.js +31 -0
  194. package/node/ChartsLegend/direction.js +5 -0
  195. package/node/ChartsLegend/index.js +80 -16
  196. package/node/ChartsLegend/legendContext.types.js +5 -0
  197. package/node/ChartsLegend/onClickContextBuilder.js +14 -0
  198. package/node/ChartsLegend/piecewiseColorDefaultLabelFormatter.js +15 -0
  199. package/node/ChartsLegend/piecewiseColorLegend.types.js +5 -0
  200. package/node/ChartsLegend/piecewiseColorLegendClasses.js +31 -0
  201. package/node/ChartsSurface/ChartsSurface.js +0 -1
  202. package/node/LineChart/AnimatedArea.js +1 -0
  203. package/node/LineChart/AnimatedLine.js +1 -0
  204. package/node/LineChart/AppearingMask.js +1 -0
  205. package/node/LineChart/CircleMarkElement.js +1 -0
  206. package/node/LineChart/LineChart.js +20 -10
  207. package/node/LineChart/MarkElement.js +3 -1
  208. package/node/LineChart/legend.js +1 -0
  209. package/node/LineChart/useLineChartProps.js +14 -2
  210. package/node/PieChart/PieArc.js +3 -1
  211. package/node/PieChart/PieArcLabel.js +13 -9
  212. package/node/PieChart/PieArcLabelPlot.js +1 -0
  213. package/node/PieChart/PieArcPlot.js +1 -0
  214. package/node/PieChart/PieChart.js +42 -41
  215. package/node/PieChart/legend.js +1 -0
  216. package/node/ScatterChart/ScatterChart.js +21 -11
  217. package/node/ScatterChart/legend.js +1 -0
  218. package/node/ScatterChart/useScatterChartProps.js +14 -2
  219. package/node/SparkLineChart/SparkLineChart.js +1 -4
  220. package/node/constants/index.js +3 -2
  221. package/node/hooks/index.js +13 -1
  222. package/node/{ChartsLegend/utils.js → hooks/useLegend.js} +19 -1
  223. package/node/index.js +12 -1
  224. package/node/internals/calculateMargins.js +33 -0
  225. package/node/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +61 -16
  226. package/node/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +6 -6
  227. package/node/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.js +69 -0
  228. package/node/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -0
  229. package/node/internals/components/ChartsWrapper/ChartsWrapper.js +72 -0
  230. package/node/internals/components/ChartsWrapper/index.js +16 -0
  231. package/node/internals/consumeSlots.js +109 -0
  232. package/node/internals/consumeThemeProps.js +18 -27
  233. package/node/internals/index.js +12 -0
  234. package/package.json +4 -4
  235. package/ChartsLegend/ChartsLegendItem.d.ts +0 -26
  236. package/ChartsLegend/ChartsLegendItem.js +0 -65
  237. package/ChartsLegend/DefaultChartsLegend.d.ts +0 -25
  238. package/ChartsLegend/DefaultChartsLegend.js +0 -112
  239. package/ChartsLegend/LegendPerItem.d.ts +0 -65
  240. package/ChartsLegend/LegendPerItem.js +0 -129
  241. package/ChartsLegend/legendItemsPlacement.d.ts +0 -3
  242. package/ChartsLegend/legendItemsPlacement.js +0 -72
  243. package/ChartsLegend/utils.d.ts +0 -2
  244. package/modern/ChartsLegend/ChartsLegendItem.js +0 -65
  245. package/modern/ChartsLegend/DefaultChartsLegend.js +0 -112
  246. package/modern/ChartsLegend/LegendPerItem.js +0 -129
  247. package/modern/ChartsLegend/legendItemsPlacement.js +0 -72
  248. package/node/ChartsLegend/ChartsLegendItem.js +0 -72
  249. package/node/ChartsLegend/DefaultChartsLegend.js +0 -118
  250. package/node/ChartsLegend/LegendPerItem.js +0 -137
  251. package/node/ChartsLegend/legendItemsPlacement.js +0 -79
@@ -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 = ["slots", "slotProps"];
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 useSlotProps from '@mui/utils/useSlotProps';
9
- import composeClasses from '@mui/utils/composeClasses';
10
- import { useThemeProps, useTheme } from '@mui/material/styles';
11
- import { getSeriesToDisplay } from "./utils.js";
12
- import { getLegendUtilityClass } from "./chartsLegendClasses.js";
13
- import { DefaultChartsLegend } from "./DefaultChartsLegend.js";
14
- import { useSeries } from "../hooks/useSeries.js";
15
- import { jsx as _jsx } from "react/jsx-runtime";
16
- const useUtilityClasses = ownerState => {
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
- classes,
19
- direction
20
- } = ownerState;
21
- const slots = {
22
- root: ['root', direction],
23
- mark: ['mark'],
24
- label: ['label'],
25
- series: ['series'],
26
- itemBackground: ['itemBackground']
27
- };
28
- return composeClasses(slots, getLegendUtilityClass, classes);
29
- };
30
- function ChartsLegend(inProps) {
31
- const props = useThemeProps({
32
- props: inProps,
33
- name: 'MuiChartsLegend'
34
- });
35
- const defaultizedProps = _extends({
36
- direction: 'row'
37
- }, props, {
38
- position: _extends({
39
- horizontal: 'middle',
40
- vertical: 'top'
41
- }, props.position)
42
- });
43
- const {
44
- slots,
45
- slotProps
46
- } = defaultizedProps,
47
- other = _objectWithoutPropertiesLoose(defaultizedProps, _excluded);
48
- const theme = useTheme();
49
- const classes = useUtilityClasses(_extends({}, defaultizedProps, {
50
- theme
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
- const series = useSeries();
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(['column', 'row']),
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<SVGRectElement, MouseEvent>} event The click event.
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 { ContinuousScaleName } from '../models/axis';
3
- import { ChartsTextProps } from '../ChartsText';
4
- import { ColorLegendSelector, LegendPlacement } from './legend.types';
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 LegendPlacement, ColorLegendSelector {
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 ({ formattedValue }) => formattedValue
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 ({ formattedValue }) => formattedValue
28
+ * @default formattedValue
21
29
  */
22
30
  maxLabel?: string | LabelFormatter;
23
31
  /**
24
- * A unique identifier for the gradient.
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
- id?: string;
37
+ gradientId?: string;
28
38
  /**
29
- * The scale used to display gradient colors.
30
- * @default 'linear'
39
+ * Where to position the labels relative to the gradient.
40
+ * @default 'end'
31
41
  */
32
- scaleType?: ContinuousScaleName;
42
+ labelPosition?: 'start' | 'end' | 'extremes';
33
43
  /**
34
- * The length of the gradient bar.
35
- * Can be a number (in px) or a string with a percentage such as '50%'.
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
- length?: number | string;
47
+ reverse?: boolean;
40
48
  /**
41
- * The thickness of the gradient bar.
42
- * @default 5
49
+ * Override or extend the styles applied to the component.
43
50
  */
44
- thickness?: number;
45
- /**
46
- * The alignment of the texts with the gradient bar.
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 };