@mui/x-charts 6.0.0-alpha.13 → 6.0.0-alpha.15

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 (139) hide show
  1. package/BarChart/BarChart.d.ts +6 -3
  2. package/BarChart/BarChart.js +7 -10
  3. package/BarChart/BarElement.js +2 -4
  4. package/BarChart/formatter.js +1 -2
  5. package/BarChart/legend.js +1 -2
  6. package/CHANGELOG.md +165 -1
  7. package/ChartContainer/index.js +2 -3
  8. package/ChartsAxis/axisClasses.js +1 -2
  9. package/ChartsLegend/ChartsLegend.d.ts +43 -24
  10. package/ChartsLegend/ChartsLegend.js +186 -148
  11. package/ChartsLegend/chartsLegendClasses.js +1 -2
  12. package/ChartsLegend/utils.d.ts +1 -6
  13. package/ChartsSurface.js +5 -14
  14. package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +1 -0
  15. package/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
  16. package/ChartsTooltip/ChartsItemTooltipContent.d.ts +3 -2
  17. package/ChartsTooltip/ChartsItemTooltipContent.js +16 -6
  18. package/ChartsTooltip/ChartsTooltip.d.ts +23 -0
  19. package/ChartsTooltip/ChartsTooltip.js +47 -13
  20. package/ChartsTooltip/ChartsTooltipTable.js +6 -11
  21. package/ChartsTooltip/tooltipClasses.js +1 -2
  22. package/ChartsXAxis/ChartsXAxis.js +48 -25
  23. package/ChartsYAxis/ChartsYAxis.js +47 -26
  24. package/LineChart/AreaElement.js +2 -4
  25. package/LineChart/LineChart.d.ts +6 -3
  26. package/LineChart/LineChart.js +11 -11
  27. package/LineChart/LineElement.js +2 -4
  28. package/LineChart/LineHighlightElement.js +1 -2
  29. package/LineChart/MarkElement.js +1 -2
  30. package/LineChart/formatter.js +1 -2
  31. package/LineChart/legend.js +1 -2
  32. package/PieChart/PieArc.d.ts +1 -0
  33. package/PieChart/PieArc.js +6 -4
  34. package/PieChart/PieArcLabel.js +1 -2
  35. package/PieChart/PieChart.d.ts +8 -4
  36. package/PieChart/PieChart.js +11 -10
  37. package/PieChart/PiePlot.d.ts +8 -0
  38. package/PieChart/PiePlot.js +21 -5
  39. package/PieChart/formatter.js +1 -2
  40. package/PieChart/legend.js +1 -2
  41. package/ResponsiveChartContainer/index.js +2 -3
  42. package/ScatterChart/ScatterChart.d.ts +6 -3
  43. package/ScatterChart/ScatterChart.js +7 -10
  44. package/ScatterChart/formatter.js +1 -2
  45. package/ScatterChart/legend.js +1 -2
  46. package/SparkLineChart/SparkLineChart.d.ts +3 -3
  47. package/SparkLineChart/SparkLineChart.js +7 -3
  48. package/colorPalettes/colorPalettes.js +6 -12
  49. package/constants.js +5 -8
  50. package/context/CartesianContextProvider.js +11 -12
  51. package/context/DrawingProvider.d.ts +2 -0
  52. package/context/DrawingProvider.js +4 -4
  53. package/context/HighlightProvider.js +1 -2
  54. package/context/InteractionProvider.js +1 -2
  55. package/context/SeriesContextProvider.js +1 -2
  56. package/esm/BarChart/BarChart.js +6 -8
  57. package/esm/ChartsLegend/ChartsLegend.js +184 -142
  58. package/esm/ChartsSurface.js +3 -11
  59. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
  60. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +15 -6
  61. package/esm/ChartsTooltip/ChartsTooltip.js +47 -12
  62. package/esm/ChartsXAxis/ChartsXAxis.js +47 -24
  63. package/esm/ChartsYAxis/ChartsYAxis.js +46 -25
  64. package/esm/LineChart/LineChart.js +10 -9
  65. package/esm/PieChart/PieArc.js +5 -2
  66. package/esm/PieChart/PieChart.js +11 -10
  67. package/esm/PieChart/PiePlot.js +17 -2
  68. package/esm/ScatterChart/ScatterChart.js +6 -8
  69. package/esm/SparkLineChart/SparkLineChart.js +6 -1
  70. package/esm/constants.js +1 -1
  71. package/esm/context/CartesianContextProvider.js +11 -11
  72. package/esm/context/DrawingProvider.js +2 -0
  73. package/esm/hooks/useChartDimensions.js +2 -0
  74. package/esm/hooks/useTicks.js +5 -5
  75. package/esm/internals/components/AxisSharedComponents.js +15 -70
  76. package/esm/internals/components/ChartsText.js +71 -0
  77. package/esm/internals/domUtils.js +113 -0
  78. package/hooks/useChartDimensions.d.ts +2 -0
  79. package/hooks/useChartDimensions.js +3 -2
  80. package/hooks/useTicks.d.ts +2 -3
  81. package/hooks/useTicks.js +7 -8
  82. package/index.js +1 -1
  83. package/internals/components/AxisSharedComponents.d.ts +0 -4
  84. package/internals/components/AxisSharedComponents.js +18 -78
  85. package/internals/components/ChartsText.d.ts +32 -0
  86. package/internals/components/ChartsText.js +81 -0
  87. package/internals/defaultizeValueFormatter.js +1 -2
  88. package/internals/domUtils.d.ts +14 -0
  89. package/internals/domUtils.js +122 -0
  90. package/internals/stackSeries.js +2 -4
  91. package/legacy/BarChart/BarChart.js +6 -8
  92. package/legacy/ChartsLegend/ChartsLegend.js +196 -140
  93. package/legacy/ChartsSurface.js +2 -11
  94. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
  95. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +15 -6
  96. package/legacy/ChartsTooltip/ChartsTooltip.js +50 -12
  97. package/legacy/ChartsXAxis/ChartsXAxis.js +47 -24
  98. package/legacy/ChartsYAxis/ChartsYAxis.js +46 -25
  99. package/legacy/LineChart/LineChart.js +10 -9
  100. package/legacy/PieChart/PieArc.js +4 -1
  101. package/legacy/PieChart/PieChart.js +11 -10
  102. package/legacy/PieChart/PiePlot.js +17 -2
  103. package/legacy/ScatterChart/ScatterChart.js +6 -8
  104. package/legacy/SparkLineChart/SparkLineChart.js +6 -1
  105. package/legacy/constants.js +1 -1
  106. package/legacy/context/CartesianContextProvider.js +11 -11
  107. package/legacy/context/DrawingProvider.js +2 -0
  108. package/legacy/hooks/useChartDimensions.js +2 -0
  109. package/legacy/hooks/useTicks.js +5 -5
  110. package/legacy/index.js +1 -1
  111. package/legacy/internals/components/AxisSharedComponents.js +9 -63
  112. package/legacy/internals/components/ChartsText.js +77 -0
  113. package/legacy/internals/domUtils.js +121 -0
  114. package/models/axis.d.ts +6 -5
  115. package/models/layout.d.ts +7 -6
  116. package/modern/BarChart/BarChart.js +6 -8
  117. package/modern/ChartsLegend/ChartsLegend.js +184 -142
  118. package/modern/ChartsSurface.js +3 -11
  119. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +17 -8
  120. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +15 -6
  121. package/modern/ChartsTooltip/ChartsTooltip.js +46 -12
  122. package/modern/ChartsXAxis/ChartsXAxis.js +47 -24
  123. package/modern/ChartsYAxis/ChartsYAxis.js +46 -25
  124. package/modern/LineChart/LineChart.js +10 -9
  125. package/modern/PieChart/PieArc.js +5 -2
  126. package/modern/PieChart/PieChart.js +11 -10
  127. package/modern/PieChart/PiePlot.js +17 -2
  128. package/modern/ScatterChart/ScatterChart.js +6 -8
  129. package/modern/SparkLineChart/SparkLineChart.js +6 -1
  130. package/modern/constants.js +1 -1
  131. package/modern/context/CartesianContextProvider.js +11 -11
  132. package/modern/context/DrawingProvider.js +2 -0
  133. package/modern/hooks/useChartDimensions.js +2 -0
  134. package/modern/hooks/useTicks.js +5 -5
  135. package/modern/index.js +1 -1
  136. package/modern/internals/components/AxisSharedComponents.js +15 -70
  137. package/modern/internals/components/ChartsText.js +71 -0
  138. package/modern/internals/domUtils.js +113 -0
  139. package/package.json +3 -3
@@ -1,15 +1,17 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["scale", "ticksNumber"];
3
+ const _excluded = ["scale", "tickNumber"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
+ import { useSlotProps } from '@mui/base/utils';
6
7
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
7
8
  import { useThemeProps, useTheme } from '@mui/material/styles';
8
9
  import { CartesianContext } from '../context/CartesianContextProvider';
9
10
  import { DrawingContext } from '../context/DrawingProvider';
10
11
  import useTicks from '../hooks/useTicks';
11
12
  import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
12
- import { ChartsLine, ChartsTick, ChartsTickLabel, ChartsLabel, AxisRoot } from '../internals/components/AxisSharedComponents';
13
+ import { AxisRoot } from '../internals/components/AxisSharedComponents';
14
+ import { ChartsText } from '../internals/components/ChartsText';
13
15
  import { jsx as _jsx } from "react/jsx-runtime";
14
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
17
  const useUtilityClasses = ownerState => {
@@ -46,7 +48,7 @@ function ChartsXAxis(inProps) {
46
48
  xAxis: {
47
49
  [_props$axisId]: {
48
50
  scale: xScale,
49
- ticksNumber
51
+ tickNumber
50
52
  }
51
53
  }
52
54
  } = _React$useContext,
@@ -77,7 +79,7 @@ function ChartsXAxis(inProps) {
77
79
  const tickSize = disableTicks ? 4 : tickSizeProp;
78
80
  const xTicks = useTicks({
79
81
  scale: xScale,
80
- ticksNumber,
82
+ tickNumber,
81
83
  valueFormatter
82
84
  });
83
85
  const positionSigne = position === 'bottom' ? 1 : -1;
@@ -85,10 +87,38 @@ function ChartsXAxis(inProps) {
85
87
  x: left + width / 2,
86
88
  y: positionSigne * (tickFontSize + tickSize + 10)
87
89
  };
88
- const Line = slots?.axisLine ?? ChartsLine;
89
- const Tick = slots?.axisTick ?? ChartsTick;
90
- const TickLabel = slots?.axisTickLabel ?? ChartsTickLabel;
91
- const Label = slots?.axisLabel ?? ChartsLabel;
90
+ const Line = slots?.axisLine ?? 'line';
91
+ const Tick = slots?.axisTick ?? 'line';
92
+ const TickLabel = slots?.axisTickLabel ?? ChartsText;
93
+ const Label = slots?.axisLabel ?? ChartsText;
94
+ const axisTickLabelProps = useSlotProps({
95
+ elementType: TickLabel,
96
+ externalSlotProps: slotProps?.axisTickLabel,
97
+ additionalProps: {
98
+ textAnchor: 'middle',
99
+ dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
100
+ style: {
101
+ fontSize: tickFontSize
102
+ },
103
+ className: classes.tickLabel
104
+ },
105
+ className: classes.tickLabel,
106
+ ownerState: {}
107
+ });
108
+ const axisLabelProps = useSlotProps({
109
+ elementType: Label,
110
+ externalSlotProps: slotProps?.axisLabel,
111
+ additionalProps: {
112
+ textAnchor: 'middle',
113
+ dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
114
+ style: {
115
+ fontSize: labelFontSize,
116
+ transformOrigin: `${labelRefPoint.x}px ${labelRefPoint.y}px`
117
+ },
118
+ className: classes.label
119
+ },
120
+ ownerState: {}
121
+ });
92
122
  return /*#__PURE__*/_jsxs(AxisRoot, {
93
123
  transform: `translate(0, ${position === 'bottom' ? top + height : top})`,
94
124
  className: classes.root,
@@ -112,24 +142,17 @@ function ChartsXAxis(inProps) {
112
142
  }, slotProps?.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
113
143
  x: xTickLabel,
114
144
  y: yTickLabel,
115
- "transform-origin": `${xTickLabel}px ${yTickLabel}px`,
116
- sx: {
117
- fontSize: tickFontSize
118
- },
119
- className: classes.tickLabel
120
- }, slotProps?.axisTickLabel, {
121
- children: formattedValue
145
+ "transform-origin": `${xTickLabel}px ${yTickLabel}px`
146
+ }, axisTickLabelProps, {
147
+ text: formattedValue.toString()
122
148
  }))]
123
149
  }, index);
124
- }), label && /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, {
125
- sx: {
126
- fontSize: labelFontSize,
127
- transformOrigin: `${labelRefPoint.x}px ${labelRefPoint.y}px`
128
- },
129
- className: classes.label
130
- }, slotProps?.axisLabel, {
131
- children: label
132
- }))]
150
+ }), label && /*#__PURE__*/_jsx("g", {
151
+ className: classes.label,
152
+ children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
153
+ text: label
154
+ }))
155
+ })]
133
156
  });
134
157
  }
135
158
  process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
@@ -1,14 +1,16 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["scale", "ticksNumber"];
3
+ const _excluded = ["scale", "tickNumber"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
+ import { useSlotProps } from '@mui/base/utils';
6
7
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
7
8
  import { useThemeProps, useTheme } from '@mui/material/styles';
8
9
  import { CartesianContext } from '../context/CartesianContextProvider';
9
10
  import { DrawingContext } from '../context/DrawingProvider';
10
11
  import useTicks from '../hooks/useTicks';
11
- import { ChartsLine, ChartsTick, ChartsTickLabel, ChartsLabel, AxisRoot } from '../internals/components/AxisSharedComponents';
12
+ import { AxisRoot } from '../internals/components/AxisSharedComponents';
13
+ import { ChartsText } from '../internals/components/ChartsText';
12
14
  import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
13
15
  import { jsx as _jsx } from "react/jsx-runtime";
14
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -46,7 +48,7 @@ function ChartsYAxis(inProps) {
46
48
  yAxis: {
47
49
  [_props$axisId]: {
48
50
  scale: yScale,
49
- ticksNumber
51
+ tickNumber
50
52
  }
51
53
  }
52
54
  } = _React$useContext,
@@ -77,7 +79,7 @@ function ChartsYAxis(inProps) {
77
79
  const tickSize = disableTicks ? 4 : tickSizeProp;
78
80
  const yTicks = useTicks({
79
81
  scale: yScale,
80
- ticksNumber,
82
+ tickNumber,
81
83
  valueFormatter
82
84
  });
83
85
  const positionSigne = position === 'right' ? 1 : -1;
@@ -85,10 +87,38 @@ function ChartsYAxis(inProps) {
85
87
  x: positionSigne * (tickFontSize + tickSize + 10),
86
88
  y: top + height / 2
87
89
  };
88
- const Line = slots?.axisLine ?? ChartsLine;
89
- const Tick = slots?.axisTick ?? ChartsTick;
90
- const TickLabel = slots?.axisTickLabel ?? ChartsTickLabel;
91
- const Label = slots?.axisLabel ?? ChartsLabel;
90
+ const Line = slots?.axisLine ?? 'line';
91
+ const Tick = slots?.axisTick ?? 'line';
92
+ const TickLabel = slots?.axisTickLabel ?? ChartsText;
93
+ const Label = slots?.axisLabel ?? ChartsText;
94
+ const axisTickLabelProps = useSlotProps({
95
+ elementType: TickLabel,
96
+ externalSlotProps: slotProps?.axisTickLabel,
97
+ additionalProps: {
98
+ textAnchor: position === 'right' ? 'start' : 'end',
99
+ dominantBaseline: 'central',
100
+ style: {
101
+ fontSize: tickFontSize
102
+ },
103
+ className: classes.tickLabel
104
+ },
105
+ ownerState: {}
106
+ });
107
+ const axisLabelProps = useSlotProps({
108
+ elementType: Label,
109
+ externalSlotProps: slotProps?.axisLabel,
110
+ additionalProps: {
111
+ textAnchor: 'middle',
112
+ dominantBaseline: 'auto',
113
+ style: {
114
+ fontSize: labelFontSize,
115
+ transform: `rotate(${positionSigne * 90}deg)`,
116
+ transformOrigin: `${labelRefPoint.x}px ${labelRefPoint.y}px`
117
+ },
118
+ className: classes.label
119
+ },
120
+ ownerState: {}
121
+ });
92
122
  return /*#__PURE__*/_jsxs(AxisRoot, {
93
123
  transform: `translate(${position === 'right' ? left + width : left}, 0)`,
94
124
  className: classes.root,
@@ -113,24 +143,15 @@ function ChartsYAxis(inProps) {
113
143
  x: xTickLabel,
114
144
  y: yTickLabel,
115
145
  "transform-origin": `${xTickLabel}px ${yTickLabel}px`,
116
- sx: {
117
- fontSize: tickFontSize
118
- },
119
- className: classes.tickLabel
120
- }, slotProps?.axisTickLabel, {
121
- children: formattedValue.toLocaleString()
122
- }))]
146
+ text: formattedValue.toString()
147
+ }, axisTickLabelProps))]
123
148
  }, index);
124
- }), label && /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, {
125
- sx: {
126
- fontSize: labelFontSize,
127
- transform: `rotate(${positionSigne * 90}deg)`,
128
- transformOrigin: `${labelRefPoint.x}px ${labelRefPoint.y}px`
129
- },
130
- className: classes.label
131
- }, slotProps?.axisLabel, {
132
- children: label
133
- }))]
149
+ }), label && /*#__PURE__*/_jsx("g", {
150
+ className: classes.label,
151
+ children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
152
+ text: label
153
+ }))
154
+ })]
134
155
  });
135
156
  }
136
157
  process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
@@ -88,7 +88,10 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
88
88
  }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
89
89
  slots: slots,
90
90
  slotProps: slotProps
91
- })), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, {
91
+ })), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
92
+ slots: slots,
93
+ slotProps: slotProps
94
+ })), /*#__PURE__*/_jsx(ChartsClipPath, {
92
95
  id: clipPathId
93
96
  }), children]
94
97
  });
@@ -162,23 +165,19 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
162
165
  tickNumber: PropTypes.number,
163
166
  tickSize: PropTypes.number
164
167
  }), PropTypes.string]),
168
+ /**
169
+ * @deprecated Consider using `slotProps.legend` instead.
170
+ */
165
171
  legend: PropTypes.shape({
166
172
  classes: PropTypes.object,
167
173
  direction: PropTypes.oneOf(['column', 'row']),
168
174
  hidden: PropTypes.bool,
169
- itemWidth: PropTypes.number,
170
- markSize: PropTypes.number,
171
- offset: PropTypes.shape({
172
- x: PropTypes.number,
173
- y: PropTypes.number
174
- }),
175
175
  position: PropTypes.shape({
176
176
  horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
177
177
  vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
178
178
  }),
179
179
  slotProps: PropTypes.object,
180
- slots: PropTypes.object,
181
- spacing: PropTypes.number
180
+ slots: PropTypes.object
182
181
  }),
183
182
  margin: PropTypes.shape({
184
183
  bottom: PropTypes.number,
@@ -247,6 +246,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
247
246
  axisContent: PropTypes.elementType,
248
247
  classes: PropTypes.object,
249
248
  itemContent: PropTypes.elementType,
249
+ slotProps: PropTypes.object,
250
+ slots: PropTypes.object,
250
251
  trigger: PropTypes.oneOf(['axis', 'item', 'none'])
251
252
  }),
252
253
  /**
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "innerRadius", "outerRadius", "cornerRadius", "highlighted", "faded"];
3
+ const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "innerRadius", "outerRadius", "cornerRadius", "highlighted", "faded", "onClick"];
4
4
  import * as React from 'react';
5
5
  import { arc as d3Arc } from 'd3-shape';
6
6
  import PropTypes from 'prop-types';
@@ -54,7 +54,8 @@ export default function PieArc(props) {
54
54
  highlighted,
55
55
  faded = {
56
56
  additionalRadius: -5
57
- }
57
+ },
58
+ onClick
58
59
  } = props,
59
60
  other = _objectWithoutPropertiesLoose(props, _excluded);
60
61
  const getInteractionItemProps = useInteractionItemProps(highlightScope);
@@ -91,6 +92,8 @@ export default function PieArc(props) {
91
92
  innerRadius,
92
93
  outerRadius
93
94
  })),
95
+ onClick: onClick,
96
+ cursor: onClick ? 'pointer' : 'unset',
94
97
  ownerState: ownerState,
95
98
  className: classes.root
96
99
  }, getInteractionItemProps({
@@ -46,7 +46,8 @@ function PieChart(props) {
46
46
  bottomAxis = null,
47
47
  children,
48
48
  slots,
49
- slotProps
49
+ slotProps,
50
+ onClick
50
51
  } = props;
51
52
  const margin = _extends({}, defaultMargin, marginProps);
52
53
  return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
@@ -74,7 +75,8 @@ function PieChart(props) {
74
75
  slotProps: slotProps
75
76
  }), /*#__PURE__*/_jsx(PiePlot, {
76
77
  slots: slots,
77
- slotProps: slotProps
78
+ slotProps: slotProps,
79
+ onClick: onClick
78
80
  }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
79
81
  slots: slots,
80
82
  slotProps: slotProps
@@ -146,23 +148,19 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
146
148
  tickNumber: PropTypes.number,
147
149
  tickSize: PropTypes.number
148
150
  }), PropTypes.string]),
151
+ /**
152
+ * @deprecated Consider using `slotProps.legend` instead.
153
+ */
149
154
  legend: PropTypes.shape({
150
155
  classes: PropTypes.object,
151
156
  direction: PropTypes.oneOf(['column', 'row']),
152
157
  hidden: PropTypes.bool,
153
- itemWidth: PropTypes.number,
154
- markSize: PropTypes.number,
155
- offset: PropTypes.shape({
156
- x: PropTypes.number,
157
- y: PropTypes.number
158
- }),
159
158
  position: PropTypes.shape({
160
159
  horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
161
160
  vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
162
161
  }),
163
162
  slotProps: PropTypes.object,
164
- slots: PropTypes.object,
165
- spacing: PropTypes.number
163
+ slots: PropTypes.object
166
164
  }),
167
165
  margin: PropTypes.shape({
168
166
  bottom: PropTypes.number,
@@ -170,6 +168,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
170
168
  right: PropTypes.number,
171
169
  top: PropTypes.number
172
170
  }),
171
+ onClick: PropTypes.func,
173
172
  /**
174
173
  * Indicate which axis to display the right of the charts.
175
174
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
@@ -244,6 +243,8 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
244
243
  axisContent: PropTypes.elementType,
245
244
  classes: PropTypes.object,
246
245
  itemContent: PropTypes.elementType,
246
+ slotProps: PropTypes.object,
247
+ slots: PropTypes.object,
247
248
  trigger: PropTypes.oneOf(['axis', 'item', 'none'])
248
249
  }),
249
250
  /**
@@ -25,7 +25,8 @@ function getItemLabel(arcLabel, arcLabelMinAngle, item) {
25
25
  function PiePlot(props) {
26
26
  const {
27
27
  slots,
28
- slotProps
28
+ slotProps,
29
+ onClick
29
30
  } = props;
30
31
  const seriesData = React.useContext(SeriesContext).pie;
31
32
  const {
@@ -76,7 +77,14 @@ function PiePlot(props) {
76
77
  dataIndex: index,
77
78
  highlightScope: series[seriesId].highlightScope,
78
79
  highlighted: highlighted,
79
- faded: faded
80
+ faded: faded,
81
+ onClick: onClick && (event => {
82
+ onClick(event, {
83
+ type: 'pie',
84
+ seriesId,
85
+ dataIndex: index
86
+ }, item);
87
+ })
80
88
  }, slotProps?.pieArc));
81
89
  }), data.map((item, index) => {
82
90
  return /*#__PURE__*/_createElement(ArcLabel, _extends({}, item, {
@@ -101,6 +109,13 @@ process.env.NODE_ENV !== "production" ? PiePlot.propTypes = {
101
109
  // | These PropTypes are generated from the TypeScript type definitions |
102
110
  // | To update them edit the TypeScript types and run "yarn proptypes" |
103
111
  // ----------------------------------------------------------------------
112
+ /**
113
+ * Callback fired when a pie item is clicked.
114
+ * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
115
+ * @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
116
+ * @param {DefaultizedPieValueType} item The pie item.
117
+ */
118
+ onClick: PropTypes.func,
104
119
  /**
105
120
  * The props used for each component slot.
106
121
  * @default {}
@@ -128,23 +128,19 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
128
128
  tickNumber: PropTypes.number,
129
129
  tickSize: PropTypes.number
130
130
  }), PropTypes.string]),
131
+ /**
132
+ * @deprecated Consider using `slotProps.legend` instead.
133
+ */
131
134
  legend: PropTypes.shape({
132
135
  classes: PropTypes.object,
133
136
  direction: PropTypes.oneOf(['column', 'row']),
134
137
  hidden: PropTypes.bool,
135
- itemWidth: PropTypes.number,
136
- markSize: PropTypes.number,
137
- offset: PropTypes.shape({
138
- x: PropTypes.number,
139
- y: PropTypes.number
140
- }),
141
138
  position: PropTypes.shape({
142
139
  horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
143
140
  vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
144
141
  }),
145
142
  slotProps: PropTypes.object,
146
- slots: PropTypes.object,
147
- spacing: PropTypes.number
143
+ slots: PropTypes.object
148
144
  }),
149
145
  margin: PropTypes.shape({
150
146
  bottom: PropTypes.number,
@@ -210,6 +206,8 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
210
206
  axisContent: PropTypes.elementType,
211
207
  classes: PropTypes.object,
212
208
  itemContent: PropTypes.elementType,
209
+ slotProps: PropTypes.object,
210
+ slots: PropTypes.object,
213
211
  trigger: PropTypes.oneOf(['axis', 'item', 'none'])
214
212
  }),
215
213
  /**
@@ -84,7 +84,10 @@ const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(pro
84
84
  slots: slots,
85
85
  slotProps: slotProps
86
86
  })]
87
- }), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), showTooltip && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), children]
87
+ }), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), showTooltip && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
88
+ slotProps: slotProps,
89
+ slots: slots
90
+ })), children]
88
91
  });
89
92
  });
90
93
  process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
@@ -159,6 +162,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
159
162
  axisContent: PropTypes.elementType,
160
163
  classes: PropTypes.object,
161
164
  itemContent: PropTypes.elementType,
165
+ slotProps: PropTypes.object,
166
+ slots: PropTypes.object,
162
167
  trigger: PropTypes.oneOf(['axis', 'item', 'none'])
163
168
  }),
164
169
  /**
@@ -1,7 +1,7 @@
1
1
  export const DEFAULT_X_AXIS_KEY = 'DEFAULT_X_AXIS_KEY';
2
2
  export const DEFAULT_Y_AXIS_KEY = 'DEFAULT_Y_AXIS_KEY';
3
3
  export const DEFAULT_MARGINS = {
4
- top: 100,
4
+ top: 50,
5
5
  bottom: 50,
6
6
  left: 50,
7
7
  right: 50
@@ -10,7 +10,7 @@ import { getScale } from '../internals/getScale';
10
10
  import { DrawingContext } from './DrawingProvider';
11
11
  import { SeriesContext } from './SeriesContextProvider';
12
12
  import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
13
- import { getTicksNumber } from '../hooks/useTicks';
13
+ import { getTickNumber } from '../hooks/useTicks';
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
15
  const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
16
16
  const DEFAULT_BAR_GAP_RATIO = 0.1;
@@ -109,13 +109,13 @@ function CartesianContextProvider({
109
109
  barGapRatio
110
110
  }, axis, {
111
111
  scale: scaleBand(axis.data, range).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2),
112
- ticksNumber: axis.data.length
112
+ tickNumber: axis.data.length
113
113
  });
114
114
  }
115
115
  if (isPointScaleConfig(axis)) {
116
116
  completedXAxis[axis.id] = _extends({}, axis, {
117
117
  scale: scalePoint(axis.data, range),
118
- ticksNumber: axis.data.length
118
+ tickNumber: axis.data.length
119
119
  });
120
120
  }
121
121
  if (axis.scaleType === 'band' || axis.scaleType === 'point') {
@@ -124,17 +124,17 @@ function CartesianContextProvider({
124
124
  }
125
125
  const scaleType = axis.scaleType ?? 'linear';
126
126
  const extremums = [axis.min ?? minData, axis.max ?? maxData];
127
- const ticksNumber = getTicksNumber(_extends({}, axis, {
127
+ const tickNumber = getTickNumber(_extends({}, axis, {
128
128
  range,
129
129
  domain: extremums
130
130
  }));
131
- const niceScale = getScale(scaleType, extremums, range).nice(ticksNumber);
131
+ const niceScale = getScale(scaleType, extremums, range).nice(tickNumber);
132
132
  const niceDomain = niceScale.domain();
133
133
  const domain = [axis.min ?? niceDomain[0], axis.max ?? niceDomain[1]];
134
134
  completedXAxis[axis.id] = _extends({}, axis, {
135
135
  scaleType,
136
136
  scale: niceScale.domain(domain),
137
- ticksNumber
137
+ tickNumber
138
138
  });
139
139
  });
140
140
  const allYAxis = [...(yAxis?.map((axis, index) => _extends({
@@ -157,13 +157,13 @@ function CartesianContextProvider({
157
157
  barGapRatio: 0
158
158
  }, axis, {
159
159
  scale: scaleBand(axis.data, [range[1], range[0]]).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2),
160
- ticksNumber: axis.data.length
160
+ tickNumber: axis.data.length
161
161
  });
162
162
  }
163
163
  if (isPointScaleConfig(axis)) {
164
164
  completedYAxis[axis.id] = _extends({}, axis, {
165
165
  scale: scalePoint(axis.data, [range[1], range[0]]),
166
- ticksNumber: axis.data.length
166
+ tickNumber: axis.data.length
167
167
  });
168
168
  }
169
169
  if (axis.scaleType === 'band' || axis.scaleType === 'point') {
@@ -172,17 +172,17 @@ function CartesianContextProvider({
172
172
  }
173
173
  const scaleType = axis.scaleType ?? 'linear';
174
174
  const extremums = [axis.min ?? minData, axis.max ?? maxData];
175
- const ticksNumber = getTicksNumber(_extends({}, axis, {
175
+ const tickNumber = getTickNumber(_extends({}, axis, {
176
176
  range,
177
177
  domain: extremums
178
178
  }));
179
- const niceScale = getScale(scaleType, extremums, range).nice(ticksNumber);
179
+ const niceScale = getScale(scaleType, extremums, range).nice(tickNumber);
180
180
  const niceDomain = niceScale.domain();
181
181
  const domain = [axis.min ?? niceDomain[0], axis.max ?? niceDomain[1]];
182
182
  completedYAxis[axis.id] = _extends({}, axis, {
183
183
  scaleType,
184
184
  scale: niceScale.domain(domain),
185
- ticksNumber
185
+ tickNumber
186
186
  });
187
187
  });
188
188
  return {
@@ -9,6 +9,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
9
9
  export const DrawingContext = /*#__PURE__*/React.createContext({
10
10
  top: 0,
11
11
  left: 0,
12
+ bottom: 0,
13
+ right: 0,
12
14
  height: 300,
13
15
  width: 400
14
16
  });
@@ -6,6 +6,8 @@ const useChartDimensions = (width, height, margin) => {
6
6
  const drawingArea = React.useMemo(() => ({
7
7
  left: defaultizedMargin.left,
8
8
  top: defaultizedMargin.top,
9
+ right: defaultizedMargin.right,
10
+ bottom: defaultizedMargin.bottom,
9
11
  width: Math.max(0, width - defaultizedMargin.left - defaultizedMargin.right),
10
12
  height: Math.max(0, height - defaultizedMargin.top - defaultizedMargin.bottom)
11
13
  }), [width, height, defaultizedMargin.top, defaultizedMargin.bottom, defaultizedMargin.left, defaultizedMargin.right]);
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { isBandScale } from '../internals/isBandScale';
3
- export function getTicksNumber(params) {
3
+ export function getTickNumber(params) {
4
4
  const {
5
5
  tickMaxStep,
6
6
  tickMinStep,
@@ -16,7 +16,7 @@ export function getTicksNumber(params) {
16
16
  function useTicks(options) {
17
17
  const {
18
18
  scale,
19
- ticksNumber,
19
+ tickNumber,
20
20
  valueFormatter
21
21
  } = options;
22
22
  return React.useMemo(() => {
@@ -43,11 +43,11 @@ function useTicks(options) {
43
43
  labelOffset: 0
44
44
  }));
45
45
  }
46
- return scale.ticks(ticksNumber).map(value => ({
47
- formattedValue: valueFormatter?.(value) ?? scale.tickFormat(ticksNumber)(value),
46
+ return scale.ticks(tickNumber).map(value => ({
47
+ formattedValue: valueFormatter?.(value) ?? scale.tickFormat(tickNumber)(value),
48
48
  offset: scale(value),
49
49
  labelOffset: 0
50
50
  }));
51
- }, [ticksNumber, scale, valueFormatter]);
51
+ }, [tickNumber, scale, valueFormatter]);
52
52
  }
53
53
  export default useTicks;
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v6.0.0-alpha.13
2
+ * @mui/x-charts v6.0.0-alpha.15
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the