@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 => {
@@ -47,7 +49,7 @@ function ChartsXAxis(inProps) {
47
49
  xAxis: {
48
50
  [_props$axisId]: {
49
51
  scale: xScale,
50
- ticksNumber
52
+ tickNumber
51
53
  }
52
54
  }
53
55
  } = _React$useContext,
@@ -78,7 +80,7 @@ function ChartsXAxis(inProps) {
78
80
  const tickSize = disableTicks ? 4 : tickSizeProp;
79
81
  const xTicks = useTicks({
80
82
  scale: xScale,
81
- ticksNumber,
83
+ tickNumber,
82
84
  valueFormatter
83
85
  });
84
86
  const positionSigne = position === 'bottom' ? 1 : -1;
@@ -86,10 +88,38 @@ function ChartsXAxis(inProps) {
86
88
  x: left + width / 2,
87
89
  y: positionSigne * (tickFontSize + tickSize + 10)
88
90
  };
89
- const Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : ChartsLine;
90
- const Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : ChartsTick;
91
- const TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsTickLabel;
92
- const Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsLabel;
91
+ const Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
92
+ const Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : 'line';
93
+ const TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsText;
94
+ const Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsText;
95
+ const axisTickLabelProps = useSlotProps({
96
+ elementType: TickLabel,
97
+ externalSlotProps: slotProps == null ? void 0 : slotProps.axisTickLabel,
98
+ additionalProps: {
99
+ textAnchor: 'middle',
100
+ dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
101
+ style: {
102
+ fontSize: tickFontSize
103
+ },
104
+ className: classes.tickLabel
105
+ },
106
+ className: classes.tickLabel,
107
+ ownerState: {}
108
+ });
109
+ const axisLabelProps = useSlotProps({
110
+ elementType: Label,
111
+ externalSlotProps: slotProps == null ? void 0 : slotProps.axisLabel,
112
+ additionalProps: {
113
+ textAnchor: 'middle',
114
+ dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
115
+ style: {
116
+ fontSize: labelFontSize,
117
+ transformOrigin: `${labelRefPoint.x}px ${labelRefPoint.y}px`
118
+ },
119
+ className: classes.label
120
+ },
121
+ ownerState: {}
122
+ });
93
123
  return /*#__PURE__*/_jsxs(AxisRoot, {
94
124
  transform: `translate(0, ${position === 'bottom' ? top + height : top})`,
95
125
  className: classes.root,
@@ -113,24 +143,17 @@ function ChartsXAxis(inProps) {
113
143
  }, slotProps == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
114
144
  x: xTickLabel,
115
145
  y: yTickLabel,
116
- "transform-origin": `${xTickLabel}px ${yTickLabel}px`,
117
- sx: {
118
- fontSize: tickFontSize
119
- },
120
- className: classes.tickLabel
121
- }, slotProps == null ? void 0 : slotProps.axisTickLabel, {
122
- children: formattedValue
146
+ "transform-origin": `${xTickLabel}px ${yTickLabel}px`
147
+ }, axisTickLabelProps, {
148
+ text: formattedValue.toString()
123
149
  }))]
124
150
  }, index);
125
- }), label && /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, {
126
- sx: {
127
- fontSize: labelFontSize,
128
- transformOrigin: `${labelRefPoint.x}px ${labelRefPoint.y}px`
129
- },
130
- className: classes.label
131
- }, slotProps == null ? void 0 : slotProps.axisLabel, {
132
- children: label
133
- }))]
151
+ }), label && /*#__PURE__*/_jsx("g", {
152
+ className: classes.label,
153
+ children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
154
+ text: label
155
+ }))
156
+ })]
134
157
  });
135
158
  }
136
159
  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";
@@ -47,7 +49,7 @@ function ChartsYAxis(inProps) {
47
49
  yAxis: {
48
50
  [_props$axisId]: {
49
51
  scale: yScale,
50
- ticksNumber
52
+ tickNumber
51
53
  }
52
54
  }
53
55
  } = _React$useContext,
@@ -78,7 +80,7 @@ function ChartsYAxis(inProps) {
78
80
  const tickSize = disableTicks ? 4 : tickSizeProp;
79
81
  const yTicks = useTicks({
80
82
  scale: yScale,
81
- ticksNumber,
83
+ tickNumber,
82
84
  valueFormatter
83
85
  });
84
86
  const positionSigne = position === 'right' ? 1 : -1;
@@ -86,10 +88,38 @@ function ChartsYAxis(inProps) {
86
88
  x: positionSigne * (tickFontSize + tickSize + 10),
87
89
  y: top + height / 2
88
90
  };
89
- const Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : ChartsLine;
90
- const Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : ChartsTick;
91
- const TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsTickLabel;
92
- const Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsLabel;
91
+ const Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
92
+ const Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : 'line';
93
+ const TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsText;
94
+ const Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsText;
95
+ const axisTickLabelProps = useSlotProps({
96
+ elementType: TickLabel,
97
+ externalSlotProps: slotProps == null ? void 0 : slotProps.axisTickLabel,
98
+ additionalProps: {
99
+ textAnchor: position === 'right' ? 'start' : 'end',
100
+ dominantBaseline: 'central',
101
+ style: {
102
+ fontSize: tickFontSize
103
+ },
104
+ className: classes.tickLabel
105
+ },
106
+ ownerState: {}
107
+ });
108
+ const axisLabelProps = useSlotProps({
109
+ elementType: Label,
110
+ externalSlotProps: slotProps == null ? void 0 : slotProps.axisLabel,
111
+ additionalProps: {
112
+ textAnchor: 'middle',
113
+ dominantBaseline: 'auto',
114
+ style: {
115
+ fontSize: labelFontSize,
116
+ transform: `rotate(${positionSigne * 90}deg)`,
117
+ transformOrigin: `${labelRefPoint.x}px ${labelRefPoint.y}px`
118
+ },
119
+ className: classes.label
120
+ },
121
+ ownerState: {}
122
+ });
93
123
  return /*#__PURE__*/_jsxs(AxisRoot, {
94
124
  transform: `translate(${position === 'right' ? left + width : left}, 0)`,
95
125
  className: classes.root,
@@ -114,24 +144,15 @@ function ChartsYAxis(inProps) {
114
144
  x: xTickLabel,
115
145
  y: yTickLabel,
116
146
  "transform-origin": `${xTickLabel}px ${yTickLabel}px`,
117
- sx: {
118
- fontSize: tickFontSize
119
- },
120
- className: classes.tickLabel
121
- }, slotProps == null ? void 0 : slotProps.axisTickLabel, {
122
- children: formattedValue.toLocaleString()
123
- }))]
147
+ text: formattedValue.toString()
148
+ }, axisTickLabelProps))]
124
149
  }, index);
125
- }), label && /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, {
126
- sx: {
127
- fontSize: labelFontSize,
128
- transform: `rotate(${positionSigne * 90}deg)`,
129
- transformOrigin: `${labelRefPoint.x}px ${labelRefPoint.y}px`
130
- },
131
- className: classes.label
132
- }, slotProps == null ? void 0 : slotProps.axisLabel, {
133
- children: label
134
- }))]
150
+ }), label && /*#__PURE__*/_jsx("g", {
151
+ className: classes.label,
152
+ children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
153
+ text: label
154
+ }))
155
+ })]
135
156
  });
136
157
  }
137
158
  process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
@@ -91,7 +91,10 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
91
91
  }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
92
92
  slots: slots,
93
93
  slotProps: slotProps
94
- })), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, {
94
+ })), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
95
+ slots: slots,
96
+ slotProps: slotProps
97
+ })), /*#__PURE__*/_jsx(ChartsClipPath, {
95
98
  id: clipPathId
96
99
  }), children]
97
100
  });
@@ -165,23 +168,19 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
165
168
  tickNumber: PropTypes.number,
166
169
  tickSize: PropTypes.number
167
170
  }), PropTypes.string]),
171
+ /**
172
+ * @deprecated Consider using `slotProps.legend` instead.
173
+ */
168
174
  legend: PropTypes.shape({
169
175
  classes: PropTypes.object,
170
176
  direction: PropTypes.oneOf(['column', 'row']),
171
177
  hidden: PropTypes.bool,
172
- itemWidth: PropTypes.number,
173
- markSize: PropTypes.number,
174
- offset: PropTypes.shape({
175
- x: PropTypes.number,
176
- y: PropTypes.number
177
- }),
178
178
  position: PropTypes.shape({
179
179
  horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
180
180
  vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
181
181
  }),
182
182
  slotProps: PropTypes.object,
183
- slots: PropTypes.object,
184
- spacing: PropTypes.number
183
+ slots: PropTypes.object
185
184
  }),
186
185
  margin: PropTypes.shape({
187
186
  bottom: PropTypes.number,
@@ -250,6 +249,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
250
249
  axisContent: PropTypes.elementType,
251
250
  classes: PropTypes.object,
252
251
  itemContent: PropTypes.elementType,
252
+ slotProps: PropTypes.object,
253
+ slots: PropTypes.object,
253
254
  trigger: PropTypes.oneOf(['axis', 'item', 'none'])
254
255
  }),
255
256
  /**
@@ -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';
@@ -55,7 +55,8 @@ export default function PieArc(props) {
55
55
  highlighted,
56
56
  faded = {
57
57
  additionalRadius: -5
58
- }
58
+ },
59
+ onClick
59
60
  } = props,
60
61
  other = _objectWithoutPropertiesLoose(props, _excluded);
61
62
  const getInteractionItemProps = useInteractionItemProps(highlightScope);
@@ -92,6 +93,8 @@ export default function PieArc(props) {
92
93
  innerRadius,
93
94
  outerRadius
94
95
  })),
96
+ onClick: onClick,
97
+ cursor: onClick ? 'pointer' : 'unset',
95
98
  ownerState: ownerState,
96
99
  className: classes.root
97
100
  }, 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
  /**
@@ -27,7 +27,8 @@ function PiePlot(props) {
27
27
  var _slots$pieArc, _slots$pieArcLabel;
28
28
  const {
29
29
  slots,
30
- slotProps
30
+ slotProps,
31
+ onClick
31
32
  } = props;
32
33
  const seriesData = React.useContext(SeriesContext).pie;
33
34
  const {
@@ -78,7 +79,14 @@ function PiePlot(props) {
78
79
  dataIndex: index,
79
80
  highlightScope: series[seriesId].highlightScope,
80
81
  highlighted: highlighted,
81
- faded: faded
82
+ faded: faded,
83
+ onClick: onClick && (event => {
84
+ onClick(event, {
85
+ type: 'pie',
86
+ seriesId,
87
+ dataIndex: index
88
+ }, item);
89
+ })
82
90
  }, slotProps == null ? void 0 : slotProps.pieArc));
83
91
  }), data.map((item, index) => {
84
92
  return /*#__PURE__*/_createElement(ArcLabel, _extends({}, item, {
@@ -103,6 +111,13 @@ process.env.NODE_ENV !== "production" ? PiePlot.propTypes = {
103
111
  // | These PropTypes are generated from the TypeScript type definitions |
104
112
  // | To update them edit the TypeScript types and run "yarn proptypes" |
105
113
  // ----------------------------------------------------------------------
114
+ /**
115
+ * Callback fired when a pie item is clicked.
116
+ * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
117
+ * @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
118
+ * @param {DefaultizedPieValueType} item The pie item.
119
+ */
120
+ onClick: PropTypes.func,
106
121
  /**
107
122
  * The props used for each component slot.
108
123
  * @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
  /**
package/esm/constants.js CHANGED
@@ -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;
@@ -113,13 +113,13 @@ function CartesianContextProvider({
113
113
  barGapRatio
114
114
  }, axis, {
115
115
  scale: scaleBand(axis.data, range).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2),
116
- ticksNumber: axis.data.length
116
+ tickNumber: axis.data.length
117
117
  });
118
118
  }
119
119
  if (isPointScaleConfig(axis)) {
120
120
  completedXAxis[axis.id] = _extends({}, axis, {
121
121
  scale: scalePoint(axis.data, range),
122
- ticksNumber: axis.data.length
122
+ tickNumber: axis.data.length
123
123
  });
124
124
  }
125
125
  if (axis.scaleType === 'band' || axis.scaleType === 'point') {
@@ -128,17 +128,17 @@ function CartesianContextProvider({
128
128
  }
129
129
  const scaleType = (_axis$scaleType = axis.scaleType) != null ? _axis$scaleType : 'linear';
130
130
  const extremums = [(_axis$min = axis.min) != null ? _axis$min : minData, (_axis$max = axis.max) != null ? _axis$max : maxData];
131
- const ticksNumber = getTicksNumber(_extends({}, axis, {
131
+ const tickNumber = getTickNumber(_extends({}, axis, {
132
132
  range,
133
133
  domain: extremums
134
134
  }));
135
- const niceScale = getScale(scaleType, extremums, range).nice(ticksNumber);
135
+ const niceScale = getScale(scaleType, extremums, range).nice(tickNumber);
136
136
  const niceDomain = niceScale.domain();
137
137
  const domain = [(_axis$min2 = axis.min) != null ? _axis$min2 : niceDomain[0], (_axis$max2 = axis.max) != null ? _axis$max2 : niceDomain[1]];
138
138
  completedXAxis[axis.id] = _extends({}, axis, {
139
139
  scaleType,
140
140
  scale: niceScale.domain(domain),
141
- ticksNumber
141
+ tickNumber
142
142
  });
143
143
  });
144
144
  const allYAxis = [...((_yAxis$map = yAxis == null ? void 0 : yAxis.map((axis, index) => _extends({
@@ -163,13 +163,13 @@ function CartesianContextProvider({
163
163
  barGapRatio: 0
164
164
  }, axis, {
165
165
  scale: scaleBand(axis.data, [range[1], range[0]]).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2),
166
- ticksNumber: axis.data.length
166
+ tickNumber: axis.data.length
167
167
  });
168
168
  }
169
169
  if (isPointScaleConfig(axis)) {
170
170
  completedYAxis[axis.id] = _extends({}, axis, {
171
171
  scale: scalePoint(axis.data, [range[1], range[0]]),
172
- ticksNumber: axis.data.length
172
+ tickNumber: axis.data.length
173
173
  });
174
174
  }
175
175
  if (axis.scaleType === 'band' || axis.scaleType === 'point') {
@@ -178,17 +178,17 @@ function CartesianContextProvider({
178
178
  }
179
179
  const scaleType = (_axis$scaleType2 = axis.scaleType) != null ? _axis$scaleType2 : 'linear';
180
180
  const extremums = [(_axis$min3 = axis.min) != null ? _axis$min3 : minData, (_axis$max3 = axis.max) != null ? _axis$max3 : maxData];
181
- const ticksNumber = getTicksNumber(_extends({}, axis, {
181
+ const tickNumber = getTickNumber(_extends({}, axis, {
182
182
  range,
183
183
  domain: extremums
184
184
  }));
185
- const niceScale = getScale(scaleType, extremums, range).nice(ticksNumber);
185
+ const niceScale = getScale(scaleType, extremums, range).nice(tickNumber);
186
186
  const niceDomain = niceScale.domain();
187
187
  const domain = [(_axis$min4 = axis.min) != null ? _axis$min4 : niceDomain[0], (_axis$max4 = axis.max) != null ? _axis$max4 : niceDomain[1]];
188
188
  completedYAxis[axis.id] = _extends({}, axis, {
189
189
  scaleType,
190
190
  scale: niceScale.domain(domain),
191
- ticksNumber
191
+ tickNumber
192
192
  });
193
193
  });
194
194
  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(() => {
@@ -49,14 +49,14 @@ function useTicks(options) {
49
49
  };
50
50
  });
51
51
  }
52
- return scale.ticks(ticksNumber).map(value => {
52
+ return scale.ticks(tickNumber).map(value => {
53
53
  var _valueFormatter3;
54
54
  return {
55
- formattedValue: (_valueFormatter3 = valueFormatter == null ? void 0 : valueFormatter(value)) != null ? _valueFormatter3 : scale.tickFormat(ticksNumber)(value),
55
+ formattedValue: (_valueFormatter3 = valueFormatter == null ? void 0 : valueFormatter(value)) != null ? _valueFormatter3 : scale.tickFormat(tickNumber)(value),
56
56
  offset: scale(value),
57
57
  labelOffset: 0
58
58
  };
59
59
  });
60
- }, [ticksNumber, scale, valueFormatter]);
60
+ }, [tickNumber, scale, valueFormatter]);
61
61
  }
62
62
  export default useTicks;