@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,4 +1,6 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import * as React from 'react';
3
+ import { useSlotProps } from '@mui/base/utils';
2
4
  import { SeriesContext } from '../context/SeriesContextProvider';
3
5
  import { ChartsTooltipTable, ChartsTooltipCell, ChartsTooltipMark, ChartsTooltipPaper, ChartsTooltipRow } from './ChartsTooltipTable';
4
6
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -53,13 +55,20 @@ export function ChartsItemTooltipContent(props) {
53
55
  var content = props.content,
54
56
  itemData = props.itemData,
55
57
  sx = props.sx,
56
- classes = props.classes;
58
+ classes = props.classes,
59
+ contentProps = props.contentProps;
57
60
  var series = React.useContext(SeriesContext)[itemData.type].series[itemData.seriesId];
58
61
  var Content = content != null ? content : DefaultChartsItemContent;
59
- return /*#__PURE__*/_jsx(Content, {
60
- itemData: itemData,
61
- series: series,
62
- sx: sx,
63
- classes: classes
62
+ var chartTooltipContentProps = useSlotProps({
63
+ elementType: Content,
64
+ externalSlotProps: contentProps,
65
+ additionalProps: {
66
+ itemData: itemData,
67
+ series: series,
68
+ sx: sx,
69
+ classes: classes
70
+ },
71
+ ownerState: {}
64
72
  });
73
+ return /*#__PURE__*/_jsx(Content, _extends({}, chartTooltipContentProps));
65
74
  }
@@ -1,8 +1,11 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import * as React from 'react';
2
3
  import PropTypes from 'prop-types';
3
- import { unstable_composeClasses as composeClasses } from '@mui/utils';
4
+ import composeClasses from '@mui/utils/composeClasses';
5
+ import { styled } from '@mui/material/styles';
4
6
  import { Popper } from '@mui/base/Popper';
5
7
  import { NoSsr } from '@mui/base/NoSsr';
8
+ import { useSlotProps } from '@mui/base/utils';
6
9
  import { InteractionContext } from '../context/InteractionProvider';
7
10
  import { generateVirtualElement, useMouseTracker, getTootipHasData } from './utils';
8
11
  import { ChartsItemTooltipContent } from './ChartsItemTooltipContent';
@@ -19,11 +22,27 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
19
22
  };
20
23
  return composeClasses(slots, getTooltipUtilityClass, classes);
21
24
  };
25
+ var ChartsTooltipRoot = styled(Popper, {
26
+ name: 'MuiChartsTooltip',
27
+ slot: 'Root',
28
+ overridesResolver: function overridesResolver(_, styles) {
29
+ return styles.root;
30
+ }
31
+ })(function (_ref) {
32
+ var theme = _ref.theme;
33
+ return {
34
+ pointerEvents: 'none',
35
+ zIndex: theme.zIndex.modal
36
+ };
37
+ });
22
38
  function ChartsTooltip(props) {
39
+ var _slots$popper, _slots$itemContent, _slots$axisContent;
23
40
  var _props$trigger = props.trigger,
24
41
  trigger = _props$trigger === void 0 ? 'axis' : _props$trigger,
25
42
  itemContent = props.itemContent,
26
- axisContent = props.axisContent;
43
+ axisContent = props.axisContent,
44
+ slots = props.slots,
45
+ slotProps = props.slotProps;
27
46
  var mousePosition = useMouseTracker();
28
47
  var _React$useContext = React.useContext(InteractionContext),
29
48
  item = _React$useContext.item,
@@ -34,33 +53,40 @@ function ChartsTooltip(props) {
34
53
  var classes = useUtilityClasses({
35
54
  classes: props.classes
36
55
  });
56
+ var PopperComponent = (_slots$popper = slots == null ? void 0 : slots.popper) != null ? _slots$popper : ChartsTooltipRoot;
57
+ var popperProps = useSlotProps({
58
+ elementType: PopperComponent,
59
+ externalSlotProps: slotProps == null ? void 0 : slotProps.popper,
60
+ additionalProps: {
61
+ open: popperOpen,
62
+ placement: 'right-start',
63
+ anchorEl: generateVirtualElement(mousePosition)
64
+ },
65
+ ownerState: {}
66
+ });
37
67
  if (trigger === 'none') {
38
68
  return null;
39
69
  }
40
70
  return /*#__PURE__*/_jsx(NoSsr, {
41
- children: popperOpen && /*#__PURE__*/_jsx(Popper, {
42
- open: popperOpen,
43
- placement: "right-start",
44
- anchorEl: generateVirtualElement(mousePosition),
45
- style: {
46
- pointerEvents: 'none'
47
- },
71
+ children: popperOpen && /*#__PURE__*/_jsx(PopperComponent, _extends({}, popperProps, {
48
72
  children: trigger === 'item' ? /*#__PURE__*/_jsx(ChartsItemTooltipContent, {
49
73
  itemData: displayedData,
50
- content: itemContent,
74
+ content: (_slots$itemContent = slots == null ? void 0 : slots.itemContent) != null ? _slots$itemContent : itemContent,
75
+ contentProps: slotProps == null ? void 0 : slotProps.itemContent,
51
76
  sx: {
52
77
  mx: 2
53
78
  },
54
79
  classes: classes
55
80
  }) : /*#__PURE__*/_jsx(ChartsAxisTooltipContent, {
56
81
  axisData: displayedData,
57
- content: axisContent,
82
+ content: (_slots$axisContent = slots == null ? void 0 : slots.axisContent) != null ? _slots$axisContent : axisContent,
83
+ contentProps: slotProps == null ? void 0 : slotProps.axisContent,
58
84
  sx: {
59
85
  mx: 2
60
86
  },
61
87
  classes: classes
62
88
  })
63
- })
89
+ }))
64
90
  });
65
91
  }
66
92
  process.env.NODE_ENV !== "production" ? ChartsTooltip.propTypes = {
@@ -70,6 +96,7 @@ process.env.NODE_ENV !== "production" ? ChartsTooltip.propTypes = {
70
96
  // ----------------------------------------------------------------------
71
97
  /**
72
98
  * Component to override the tooltip content when triger is set to 'axis'.
99
+ * @deprecated Use slots.axisContent instead
73
100
  */
74
101
  axisContent: PropTypes.elementType,
75
102
  /**
@@ -78,8 +105,19 @@ process.env.NODE_ENV !== "production" ? ChartsTooltip.propTypes = {
78
105
  classes: PropTypes.object,
79
106
  /**
80
107
  * Component to override the tooltip content when triger is set to 'item'.
108
+ * @deprecated Use slots.itemContent instead
81
109
  */
82
110
  itemContent: PropTypes.elementType,
111
+ /**
112
+ * The props used for each component slot.
113
+ * @default {}
114
+ */
115
+ slotProps: PropTypes.object,
116
+ /**
117
+ * Overridable component slots.
118
+ * @default {}
119
+ */
120
+ slots: PropTypes.object,
83
121
  /**
84
122
  * Select the kind of tooltip to display
85
123
  * - 'item': Shows data about the item below the mouse.
@@ -1,15 +1,17 @@
1
1
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- var _excluded = ["scale", "ticksNumber"];
3
+ var _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
  var useUtilityClasses = function useUtilityClasses(ownerState) {
@@ -42,7 +44,7 @@ function ChartsXAxis(inProps) {
42
44
  var _React$useContext = React.useContext(CartesianContext),
43
45
  _React$useContext$xAx = _React$useContext.xAxis[props.axisId],
44
46
  xScale = _React$useContext$xAx.scale,
45
- ticksNumber = _React$useContext$xAx.ticksNumber,
47
+ tickNumber = _React$useContext$xAx.tickNumber,
46
48
  settings = _objectWithoutProperties(_React$useContext$xAx, _excluded);
47
49
  var defaultizedProps = _extends({}, defaultProps, settings, props);
48
50
  var position = defaultizedProps.position,
@@ -67,7 +69,7 @@ function ChartsXAxis(inProps) {
67
69
  var tickSize = disableTicks ? 4 : tickSizeProp;
68
70
  var xTicks = useTicks({
69
71
  scale: xScale,
70
- ticksNumber: ticksNumber,
72
+ tickNumber: tickNumber,
71
73
  valueFormatter: valueFormatter
72
74
  });
73
75
  var positionSigne = position === 'bottom' ? 1 : -1;
@@ -75,10 +77,38 @@ function ChartsXAxis(inProps) {
75
77
  x: left + width / 2,
76
78
  y: positionSigne * (tickFontSize + tickSize + 10)
77
79
  };
78
- var Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : ChartsLine;
79
- var Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : ChartsTick;
80
- var TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsTickLabel;
81
- var Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsLabel;
80
+ var Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
81
+ var Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : 'line';
82
+ var TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsText;
83
+ var Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsText;
84
+ var axisTickLabelProps = useSlotProps({
85
+ elementType: TickLabel,
86
+ externalSlotProps: slotProps == null ? void 0 : slotProps.axisTickLabel,
87
+ additionalProps: {
88
+ textAnchor: 'middle',
89
+ dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
90
+ style: {
91
+ fontSize: tickFontSize
92
+ },
93
+ className: classes.tickLabel
94
+ },
95
+ className: classes.tickLabel,
96
+ ownerState: {}
97
+ });
98
+ var axisLabelProps = useSlotProps({
99
+ elementType: Label,
100
+ externalSlotProps: slotProps == null ? void 0 : slotProps.axisLabel,
101
+ additionalProps: {
102
+ textAnchor: 'middle',
103
+ dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
104
+ style: {
105
+ fontSize: labelFontSize,
106
+ transformOrigin: "".concat(labelRefPoint.x, "px ").concat(labelRefPoint.y, "px")
107
+ },
108
+ className: classes.label
109
+ },
110
+ ownerState: {}
111
+ });
82
112
  return /*#__PURE__*/_jsxs(AxisRoot, {
83
113
  transform: "translate(0, ".concat(position === 'bottom' ? top + height : top, ")"),
84
114
  className: classes.root,
@@ -101,24 +131,17 @@ function ChartsXAxis(inProps) {
101
131
  }, slotProps == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
102
132
  x: xTickLabel,
103
133
  y: yTickLabel,
104
- "transform-origin": "".concat(xTickLabel, "px ").concat(yTickLabel, "px"),
105
- sx: {
106
- fontSize: tickFontSize
107
- },
108
- className: classes.tickLabel
109
- }, slotProps == null ? void 0 : slotProps.axisTickLabel, {
110
- children: formattedValue
134
+ "transform-origin": "".concat(xTickLabel, "px ").concat(yTickLabel, "px")
135
+ }, axisTickLabelProps, {
136
+ text: formattedValue.toString()
111
137
  }))]
112
138
  }, index);
113
- }), label && /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, {
114
- sx: {
115
- fontSize: labelFontSize,
116
- transformOrigin: "".concat(labelRefPoint.x, "px ").concat(labelRefPoint.y, "px")
117
- },
118
- className: classes.label
119
- }, slotProps == null ? void 0 : slotProps.axisLabel, {
120
- children: label
121
- }))]
139
+ }), label && /*#__PURE__*/_jsx("g", {
140
+ className: classes.label,
141
+ children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
142
+ text: label
143
+ }))
144
+ })]
122
145
  });
123
146
  }
124
147
  process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
@@ -1,14 +1,16 @@
1
1
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- var _excluded = ["scale", "ticksNumber"];
3
+ var _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";
@@ -42,7 +44,7 @@ function ChartsYAxis(inProps) {
42
44
  var _React$useContext = React.useContext(CartesianContext),
43
45
  _React$useContext$yAx = _React$useContext.yAxis[props.axisId],
44
46
  yScale = _React$useContext$yAx.scale,
45
- ticksNumber = _React$useContext$yAx.ticksNumber,
47
+ tickNumber = _React$useContext$yAx.tickNumber,
46
48
  settings = _objectWithoutProperties(_React$useContext$yAx, _excluded);
47
49
  var defaultizedProps = _extends({}, defaultProps, settings, props);
48
50
  var position = defaultizedProps.position,
@@ -67,7 +69,7 @@ function ChartsYAxis(inProps) {
67
69
  var tickSize = disableTicks ? 4 : tickSizeProp;
68
70
  var yTicks = useTicks({
69
71
  scale: yScale,
70
- ticksNumber: ticksNumber,
72
+ tickNumber: tickNumber,
71
73
  valueFormatter: valueFormatter
72
74
  });
73
75
  var positionSigne = position === 'right' ? 1 : -1;
@@ -75,10 +77,38 @@ function ChartsYAxis(inProps) {
75
77
  x: positionSigne * (tickFontSize + tickSize + 10),
76
78
  y: top + height / 2
77
79
  };
78
- var Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : ChartsLine;
79
- var Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : ChartsTick;
80
- var TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsTickLabel;
81
- var Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsLabel;
80
+ var Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
81
+ var Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : 'line';
82
+ var TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsText;
83
+ var Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsText;
84
+ var axisTickLabelProps = useSlotProps({
85
+ elementType: TickLabel,
86
+ externalSlotProps: slotProps == null ? void 0 : slotProps.axisTickLabel,
87
+ additionalProps: {
88
+ textAnchor: position === 'right' ? 'start' : 'end',
89
+ dominantBaseline: 'central',
90
+ style: {
91
+ fontSize: tickFontSize
92
+ },
93
+ className: classes.tickLabel
94
+ },
95
+ ownerState: {}
96
+ });
97
+ var axisLabelProps = useSlotProps({
98
+ elementType: Label,
99
+ externalSlotProps: slotProps == null ? void 0 : slotProps.axisLabel,
100
+ additionalProps: {
101
+ textAnchor: 'middle',
102
+ dominantBaseline: 'auto',
103
+ style: {
104
+ fontSize: labelFontSize,
105
+ transform: "rotate(".concat(positionSigne * 90, "deg)"),
106
+ transformOrigin: "".concat(labelRefPoint.x, "px ").concat(labelRefPoint.y, "px")
107
+ },
108
+ className: classes.label
109
+ },
110
+ ownerState: {}
111
+ });
82
112
  return /*#__PURE__*/_jsxs(AxisRoot, {
83
113
  transform: "translate(".concat(position === 'right' ? left + width : left, ", 0)"),
84
114
  className: classes.root,
@@ -102,24 +132,15 @@ function ChartsYAxis(inProps) {
102
132
  x: xTickLabel,
103
133
  y: yTickLabel,
104
134
  "transform-origin": "".concat(xTickLabel, "px ").concat(yTickLabel, "px"),
105
- sx: {
106
- fontSize: tickFontSize
107
- },
108
- className: classes.tickLabel
109
- }, slotProps == null ? void 0 : slotProps.axisTickLabel, {
110
- children: formattedValue.toLocaleString()
111
- }))]
135
+ text: formattedValue.toString()
136
+ }, axisTickLabelProps))]
112
137
  }, index);
113
- }), label && /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, {
114
- sx: {
115
- fontSize: labelFontSize,
116
- transform: "rotate(".concat(positionSigne * 90, "deg)"),
117
- transformOrigin: "".concat(labelRefPoint.x, "px ").concat(labelRefPoint.y, "px")
118
- },
119
- className: classes.label
120
- }, slotProps == null ? void 0 : slotProps.axisLabel, {
121
- children: label
122
- }))]
138
+ }), label && /*#__PURE__*/_jsx("g", {
139
+ className: classes.label,
140
+ children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
141
+ text: label
142
+ }))
143
+ })]
123
144
  });
124
145
  }
125
146
  process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
@@ -95,7 +95,10 @@ var LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
95
95
  }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
96
96
  slots: slots,
97
97
  slotProps: slotProps
98
- })), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, {
98
+ })), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
99
+ slots: slots,
100
+ slotProps: slotProps
101
+ })), /*#__PURE__*/_jsx(ChartsClipPath, {
99
102
  id: clipPathId
100
103
  }), children]
101
104
  });
@@ -169,23 +172,19 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
169
172
  tickNumber: PropTypes.number,
170
173
  tickSize: PropTypes.number
171
174
  }), PropTypes.string]),
175
+ /**
176
+ * @deprecated Consider using `slotProps.legend` instead.
177
+ */
172
178
  legend: PropTypes.shape({
173
179
  classes: PropTypes.object,
174
180
  direction: PropTypes.oneOf(['column', 'row']),
175
181
  hidden: PropTypes.bool,
176
- itemWidth: PropTypes.number,
177
- markSize: PropTypes.number,
178
- offset: PropTypes.shape({
179
- x: PropTypes.number,
180
- y: PropTypes.number
181
- }),
182
182
  position: PropTypes.shape({
183
183
  horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
184
184
  vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
185
185
  }),
186
186
  slotProps: PropTypes.object,
187
- slots: PropTypes.object,
188
- spacing: PropTypes.number
187
+ slots: PropTypes.object
189
188
  }),
190
189
  margin: PropTypes.shape({
191
190
  bottom: PropTypes.number,
@@ -254,6 +253,8 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
254
253
  axisContent: PropTypes.elementType,
255
254
  classes: PropTypes.object,
256
255
  itemContent: PropTypes.elementType,
256
+ slotProps: PropTypes.object,
257
+ slots: PropTypes.object,
257
258
  trigger: PropTypes.oneOf(['axis', 'item', 'none'])
258
259
  }),
259
260
  /**
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "innerRadius", "outerRadius", "cornerRadius", "highlighted", "faded"];
3
+ var _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';
@@ -59,6 +59,7 @@ export default function PieArc(props) {
59
59
  faded = _props$faded === void 0 ? {
60
60
  additionalRadius: -5
61
61
  } : _props$faded,
62
+ onClick = props.onClick,
62
63
  other = _objectWithoutProperties(props, _excluded);
63
64
  var getInteractionItemProps = useInteractionItemProps(highlightScope);
64
65
  var _React$useContext = React.useContext(InteractionContext),
@@ -93,6 +94,8 @@ export default function PieArc(props) {
93
94
  innerRadius: innerRadius,
94
95
  outerRadius: outerRadius
95
96
  })),
97
+ onClick: onClick,
98
+ cursor: onClick ? 'pointer' : 'unset',
96
99
  ownerState: ownerState,
97
100
  className: classes.root
98
101
  }, getInteractionItemProps({
@@ -53,7 +53,8 @@ function PieChart(props) {
53
53
  bottomAxis = _props$bottomAxis === void 0 ? null : _props$bottomAxis,
54
54
  children = props.children,
55
55
  slots = props.slots,
56
- slotProps = props.slotProps;
56
+ slotProps = props.slotProps,
57
+ onClick = props.onClick;
57
58
  var margin = _extends({}, defaultMargin, marginProps);
58
59
  return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
59
60
  series: series.map(function (s) {
@@ -86,7 +87,8 @@ function PieChart(props) {
86
87
  slotProps: slotProps
87
88
  }), /*#__PURE__*/_jsx(PiePlot, {
88
89
  slots: slots,
89
- slotProps: slotProps
90
+ slotProps: slotProps,
91
+ onClick: onClick
90
92
  }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
91
93
  slots: slots,
92
94
  slotProps: slotProps
@@ -158,23 +160,19 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
158
160
  tickNumber: PropTypes.number,
159
161
  tickSize: PropTypes.number
160
162
  }), PropTypes.string]),
163
+ /**
164
+ * @deprecated Consider using `slotProps.legend` instead.
165
+ */
161
166
  legend: PropTypes.shape({
162
167
  classes: PropTypes.object,
163
168
  direction: PropTypes.oneOf(['column', 'row']),
164
169
  hidden: PropTypes.bool,
165
- itemWidth: PropTypes.number,
166
- markSize: PropTypes.number,
167
- offset: PropTypes.shape({
168
- x: PropTypes.number,
169
- y: PropTypes.number
170
- }),
171
170
  position: PropTypes.shape({
172
171
  horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
173
172
  vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
174
173
  }),
175
174
  slotProps: PropTypes.object,
176
- slots: PropTypes.object,
177
- spacing: PropTypes.number
175
+ slots: PropTypes.object
178
176
  }),
179
177
  margin: PropTypes.shape({
180
178
  bottom: PropTypes.number,
@@ -182,6 +180,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
182
180
  right: PropTypes.number,
183
181
  top: PropTypes.number
184
182
  }),
183
+ onClick: PropTypes.func,
185
184
  /**
186
185
  * Indicate which axis to display the right of the charts.
187
186
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
@@ -256,6 +255,8 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
256
255
  axisContent: PropTypes.elementType,
257
256
  classes: PropTypes.object,
258
257
  itemContent: PropTypes.elementType,
258
+ slotProps: PropTypes.object,
259
+ slots: PropTypes.object,
259
260
  trigger: PropTypes.oneOf(['axis', 'item', 'none'])
260
261
  }),
261
262
  /**
@@ -26,7 +26,8 @@ function getItemLabel(arcLabel, arcLabelMinAngle, item) {
26
26
  function PiePlot(props) {
27
27
  var _slots$pieArc, _slots$pieArcLabel;
28
28
  var slots = props.slots,
29
- slotProps = props.slotProps;
29
+ slotProps = props.slotProps,
30
+ onClick = props.onClick;
30
31
  var seriesData = React.useContext(SeriesContext).pie;
31
32
  var _React$useContext = React.useContext(DrawingContext),
32
33
  left = _React$useContext.left,
@@ -73,7 +74,14 @@ function PiePlot(props) {
73
74
  dataIndex: index,
74
75
  highlightScope: series[seriesId].highlightScope,
75
76
  highlighted: highlighted,
76
- faded: faded
77
+ faded: faded,
78
+ onClick: onClick && function (event) {
79
+ onClick(event, {
80
+ type: 'pie',
81
+ seriesId: seriesId,
82
+ dataIndex: index
83
+ }, item);
84
+ }
77
85
  }, slotProps == null ? void 0 : slotProps.pieArc));
78
86
  }), data.map(function (item, index) {
79
87
  return /*#__PURE__*/_createElement(ArcLabel, _extends({}, item, {
@@ -98,6 +106,13 @@ process.env.NODE_ENV !== "production" ? PiePlot.propTypes = {
98
106
  // | These PropTypes are generated from the TypeScript type definitions |
99
107
  // | To update them edit the TypeScript types and run "yarn proptypes" |
100
108
  // ----------------------------------------------------------------------
109
+ /**
110
+ * Callback fired when a pie item is clicked.
111
+ * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
112
+ * @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
113
+ * @param {DefaultizedPieValueType} item The pie item.
114
+ */
115
+ onClick: PropTypes.func,
101
116
  /**
102
117
  * The props used for each component slot.
103
118
  * @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
  /**
@@ -90,7 +90,10 @@ var SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(props
90
90
  slots: slots,
91
91
  slotProps: slotProps
92
92
  })]
93
- }), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), showTooltip && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), children]
93
+ }), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), showTooltip && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
94
+ slotProps: slotProps,
95
+ slots: slots
96
+ })), children]
94
97
  });
95
98
  });
96
99
  process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
@@ -165,6 +168,8 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
165
168
  axisContent: PropTypes.elementType,
166
169
  classes: PropTypes.object,
167
170
  itemContent: PropTypes.elementType,
171
+ slotProps: PropTypes.object,
172
+ slots: PropTypes.object,
168
173
  trigger: PropTypes.oneOf(['axis', 'item', 'none'])
169
174
  }),
170
175
  /**
@@ -1,7 +1,7 @@
1
1
  export var DEFAULT_X_AXIS_KEY = 'DEFAULT_X_AXIS_KEY';
2
2
  export var DEFAULT_Y_AXIS_KEY = 'DEFAULT_Y_AXIS_KEY';
3
3
  export var DEFAULT_MARGINS = {
4
- top: 100,
4
+ top: 50,
5
5
  bottom: 50,
6
6
  left: 50,
7
7
  right: 50