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

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 (173) hide show
  1. package/BarChart/BarChart.d.ts +13 -2
  2. package/BarChart/BarChart.js +45 -3
  3. package/BarChart/BarElement.d.ts +1318 -3
  4. package/BarChart/BarElement.js +10 -8
  5. package/BarChart/BarPlot.d.ts +17 -1
  6. package/BarChart/BarPlot.js +152 -66
  7. package/CHANGELOG.md +65 -0
  8. package/ChartContainer/index.js +5 -2
  9. package/ChartsAxis/ChartsAxis.js +18 -2
  10. package/ChartsAxis/axisClasses.d.ts +1 -1
  11. package/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
  12. package/ChartsClipPath/ChartsClipPath.js +2 -2
  13. package/ChartsLegend/ChartsLegend.d.ts +2 -1
  14. package/ChartsLegend/ChartsLegend.js +12 -8
  15. package/ChartsSurface.js +2 -2
  16. package/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
  17. package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  18. package/ChartsTooltip/ChartsTooltip.js +2 -2
  19. package/ChartsTooltip/utils.js +2 -2
  20. package/ChartsXAxis/ChartsXAxis.js +123 -35
  21. package/ChartsYAxis/ChartsYAxis.js +38 -16
  22. package/LineChart/AreaElement.d.ts +10 -0
  23. package/LineChart/AreaElement.js +12 -2
  24. package/LineChart/AreaPlot.d.ts +11 -0
  25. package/LineChart/AreaPlot.js +13 -2
  26. package/LineChart/LineChart.d.ts +10 -0
  27. package/LineChart/LineChart.js +36 -2
  28. package/LineChart/LineElement.d.ts +10 -0
  29. package/LineChart/LineElement.js +12 -2
  30. package/LineChart/LineHighlightElement.d.ts +10 -0
  31. package/LineChart/LineHighlightElement.js +12 -2
  32. package/LineChart/LineHighlightPlot.d.ts +10 -0
  33. package/LineChart/LineHighlightPlot.js +12 -2
  34. package/LineChart/LinePlot.d.ts +10 -0
  35. package/LineChart/LinePlot.js +12 -2
  36. package/LineChart/MarkElement.d.ts +10 -0
  37. package/LineChart/MarkElement.js +12 -2
  38. package/LineChart/MarkPlot.d.ts +10 -0
  39. package/LineChart/MarkPlot.js +12 -2
  40. package/PieChart/PieArc.js +2 -2
  41. package/PieChart/PieArcLabel.js +2 -2
  42. package/PieChart/PieChart.d.ts +10 -0
  43. package/PieChart/PieChart.js +37 -2
  44. package/PieChart/PiePlot.d.ts +10 -0
  45. package/PieChart/PiePlot.js +12 -2
  46. package/ResponsiveChartContainer/index.js +4 -4
  47. package/ScatterChart/Scatter.d.ts +10 -0
  48. package/ScatterChart/Scatter.js +12 -2
  49. package/ScatterChart/ScatterChart.d.ts +10 -0
  50. package/ScatterChart/ScatterChart.js +36 -2
  51. package/ScatterChart/ScatterPlot.d.ts +10 -0
  52. package/ScatterChart/ScatterPlot.js +12 -2
  53. package/SparkLineChart/SparkLineChart.d.ts +9 -0
  54. package/SparkLineChart/SparkLineChart.js +16 -2
  55. package/context/CartesianContextProvider.js +10 -2
  56. package/context/DrawingProvider.js +2 -2
  57. package/context/HighlightProvider.js +2 -2
  58. package/context/InteractionProvider.js +2 -2
  59. package/context/SeriesContextProvider.js +2 -2
  60. package/esm/BarChart/BarChart.js +43 -1
  61. package/esm/BarChart/BarElement.js +7 -4
  62. package/esm/BarChart/BarPlot.js +152 -67
  63. package/esm/ChartContainer/index.js +3 -0
  64. package/esm/ChartsAxis/ChartsAxis.js +16 -0
  65. package/esm/ChartsLegend/ChartsLegend.js +10 -6
  66. package/esm/ChartsXAxis/ChartsXAxis.js +122 -34
  67. package/esm/ChartsYAxis/ChartsYAxis.js +36 -14
  68. package/esm/LineChart/AreaElement.js +10 -0
  69. package/esm/LineChart/AreaPlot.js +11 -0
  70. package/esm/LineChart/LineChart.js +34 -0
  71. package/esm/LineChart/LineElement.js +10 -0
  72. package/esm/LineChart/LineHighlightElement.js +10 -0
  73. package/esm/LineChart/LineHighlightPlot.js +10 -0
  74. package/esm/LineChart/LinePlot.js +10 -0
  75. package/esm/LineChart/MarkElement.js +10 -0
  76. package/esm/LineChart/MarkPlot.js +10 -0
  77. package/esm/PieChart/PieChart.js +35 -0
  78. package/esm/PieChart/PiePlot.js +10 -0
  79. package/esm/ResponsiveChartContainer/index.js +2 -2
  80. package/esm/ScatterChart/Scatter.js +10 -0
  81. package/esm/ScatterChart/ScatterChart.js +34 -0
  82. package/esm/ScatterChart/ScatterPlot.js +10 -0
  83. package/esm/SparkLineChart/SparkLineChart.js +14 -0
  84. package/esm/context/CartesianContextProvider.js +8 -0
  85. package/esm/hooks/useMounted.js +16 -0
  86. package/esm/hooks/useReducedMotion.js +27 -0
  87. package/esm/hooks/useTicks.js +12 -6
  88. package/esm/internals/components/ChartsText.js +17 -13
  89. package/esm/internals/geometry.js +36 -0
  90. package/hooks/useAxisEvents.js +2 -2
  91. package/hooks/useChartDimensions.js +2 -2
  92. package/hooks/useDrawingArea.js +2 -2
  93. package/hooks/useInteractionItemProps.js +2 -2
  94. package/hooks/useMounted.d.ts +1 -0
  95. package/hooks/useMounted.js +25 -0
  96. package/hooks/useReducedMotion.d.ts +8 -0
  97. package/hooks/useReducedMotion.js +33 -0
  98. package/hooks/useScale.d.ts +2 -2
  99. package/hooks/useScale.js +2 -2
  100. package/hooks/useTicks.d.ts +18 -9
  101. package/hooks/useTicks.js +14 -8
  102. package/index.js +1 -1
  103. package/internals/components/ChartsText.d.ts +11 -8
  104. package/internals/components/ChartsText.js +19 -15
  105. package/internals/defaultizeColor.d.ts +1 -1
  106. package/internals/domUtils.d.ts +0 -1
  107. package/internals/geometry.d.ts +9 -0
  108. package/internals/geometry.js +42 -0
  109. package/legacy/BarChart/BarChart.js +43 -1
  110. package/legacy/BarChart/BarElement.js +6 -3
  111. package/legacy/BarChart/BarPlot.js +151 -63
  112. package/legacy/ChartContainer/index.js +3 -0
  113. package/legacy/ChartsAxis/ChartsAxis.js +16 -0
  114. package/legacy/ChartsLegend/ChartsLegend.js +14 -7
  115. package/legacy/ChartsXAxis/ChartsXAxis.js +126 -36
  116. package/legacy/ChartsYAxis/ChartsYAxis.js +36 -14
  117. package/legacy/LineChart/AreaElement.js +10 -0
  118. package/legacy/LineChart/AreaPlot.js +11 -0
  119. package/legacy/LineChart/LineChart.js +34 -0
  120. package/legacy/LineChart/LineElement.js +10 -0
  121. package/legacy/LineChart/LineHighlightElement.js +10 -0
  122. package/legacy/LineChart/LineHighlightPlot.js +10 -0
  123. package/legacy/LineChart/LinePlot.js +10 -0
  124. package/legacy/LineChart/MarkElement.js +10 -0
  125. package/legacy/LineChart/MarkPlot.js +10 -0
  126. package/legacy/PieChart/PieChart.js +35 -0
  127. package/legacy/PieChart/PiePlot.js +10 -0
  128. package/legacy/ResponsiveChartContainer/index.js +2 -2
  129. package/legacy/ScatterChart/Scatter.js +10 -0
  130. package/legacy/ScatterChart/ScatterChart.js +34 -0
  131. package/legacy/ScatterChart/ScatterPlot.js +10 -0
  132. package/legacy/SparkLineChart/SparkLineChart.js +14 -0
  133. package/legacy/context/CartesianContextProvider.js +8 -0
  134. package/legacy/hooks/useMounted.js +21 -0
  135. package/legacy/hooks/useReducedMotion.js +27 -0
  136. package/legacy/hooks/useTicks.js +13 -6
  137. package/legacy/index.js +1 -1
  138. package/legacy/internals/components/ChartsText.js +15 -15
  139. package/legacy/internals/geometry.js +37 -0
  140. package/models/axis.d.ts +19 -2
  141. package/models/seriesType/line.d.ts +2 -2
  142. package/modern/BarChart/BarChart.js +43 -1
  143. package/modern/BarChart/BarElement.js +7 -4
  144. package/modern/BarChart/BarPlot.js +149 -65
  145. package/modern/ChartContainer/index.js +3 -0
  146. package/modern/ChartsAxis/ChartsAxis.js +16 -0
  147. package/modern/ChartsLegend/ChartsLegend.js +10 -6
  148. package/modern/ChartsXAxis/ChartsXAxis.js +122 -34
  149. package/modern/ChartsYAxis/ChartsYAxis.js +36 -14
  150. package/modern/LineChart/AreaElement.js +10 -0
  151. package/modern/LineChart/AreaPlot.js +11 -0
  152. package/modern/LineChart/LineChart.js +34 -0
  153. package/modern/LineChart/LineElement.js +10 -0
  154. package/modern/LineChart/LineHighlightElement.js +10 -0
  155. package/modern/LineChart/LineHighlightPlot.js +10 -0
  156. package/modern/LineChart/LinePlot.js +10 -0
  157. package/modern/LineChart/MarkElement.js +10 -0
  158. package/modern/LineChart/MarkPlot.js +10 -0
  159. package/modern/PieChart/PieChart.js +35 -0
  160. package/modern/PieChart/PiePlot.js +10 -0
  161. package/modern/ResponsiveChartContainer/index.js +2 -2
  162. package/modern/ScatterChart/Scatter.js +10 -0
  163. package/modern/ScatterChart/ScatterChart.js +34 -0
  164. package/modern/ScatterChart/ScatterPlot.js +10 -0
  165. package/modern/SparkLineChart/SparkLineChart.js +14 -0
  166. package/modern/context/CartesianContextProvider.js +8 -0
  167. package/modern/hooks/useMounted.js +16 -0
  168. package/modern/hooks/useReducedMotion.js +27 -0
  169. package/modern/hooks/useTicks.js +12 -6
  170. package/modern/index.js +1 -1
  171. package/modern/internals/components/ChartsText.js +17 -13
  172. package/modern/internals/geometry.js +36 -0
  173. package/package.json +5 -3
@@ -11,7 +11,9 @@ import { DrawingContext } from '../context/DrawingProvider';
11
11
  import useTicks from '../hooks/useTicks';
12
12
  import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
13
13
  import { AxisRoot } from '../internals/components/AxisSharedComponents';
14
- import { ChartsText } from '../internals/components/ChartsText';
14
+ import { ChartsText, getWordsByLines } from '../internals/components/ChartsText';
15
+ import { getMinXTranslation } from '../internals/geometry';
16
+ import { useMounted } from '../hooks/useMounted';
15
17
  import { jsx as _jsx } from "react/jsx-runtime";
16
18
  import { jsxs as _jsxs } from "react/jsx-runtime";
17
19
  const useUtilityClasses = ownerState => {
@@ -29,12 +31,64 @@ const useUtilityClasses = ownerState => {
29
31
  };
30
32
  return composeClasses(slots, getAxisUtilityClass, classes);
31
33
  };
34
+ function addLabelDimension(xTicks, {
35
+ tickLabelStyle: style,
36
+ tickLabelInterval,
37
+ isMounted
38
+ }) {
39
+ const withDimension = xTicks.map(tick => {
40
+ if (!isMounted || tick.formattedValue === undefined) {
41
+ return _extends({}, tick, {
42
+ width: 0,
43
+ height: 0
44
+ });
45
+ }
46
+ const tickSizes = getWordsByLines({
47
+ style,
48
+ needsComputation: true,
49
+ text: tick.formattedValue
50
+ });
51
+ return _extends({}, tick, {
52
+ width: Math.max(...tickSizes.map(size => size.width)),
53
+ height: Math.max(tickSizes.length * tickSizes[0].height)
54
+ });
55
+ });
56
+ if (typeof tickLabelInterval === 'function') {
57
+ return withDimension.map((item, index) => _extends({}, item, {
58
+ skipLabel: !tickLabelInterval(item.value, index)
59
+ }));
60
+ }
61
+
62
+ // Filter label to avoid overlap
63
+ let textStart = 0;
64
+ let textEnd = 0;
65
+ return withDimension.map((item, labelIndex) => {
66
+ const {
67
+ width,
68
+ offset,
69
+ labelOffset,
70
+ height
71
+ } = item;
72
+ const distance = getMinXTranslation(width, height, style == null ? void 0 : style.angle);
73
+ const textPosition = offset + labelOffset;
74
+ const gapRatio = 1.2; // Ratio applied to the minimal distance to add some margin.
75
+
76
+ textStart = textPosition - gapRatio * distance / 2;
77
+ if (labelIndex > 0 && textStart < textEnd) {
78
+ // Except for the first label, we skip all label that overlap with the last accepted.
79
+ // Notice that the early return prevents `textEnd` from being updated.
80
+ return _extends({}, item, {
81
+ skipLabel: true
82
+ });
83
+ }
84
+ textEnd = textPosition + gapRatio * distance / 2;
85
+ return item;
86
+ });
87
+ }
32
88
  const defaultProps = {
33
89
  position: 'bottom',
34
90
  disableLine: false,
35
91
  disableTicks: false,
36
- tickFontSize: 12,
37
- labelFontSize: 14,
38
92
  tickSize: 6
39
93
  };
40
94
  function ChartsXAxis(inProps) {
@@ -54,18 +108,23 @@ function ChartsXAxis(inProps) {
54
108
  }
55
109
  } = _React$useContext,
56
110
  settings = _objectWithoutPropertiesLoose(_React$useContext.xAxis[_props$axisId], _excluded);
111
+ const isMounted = useMounted();
57
112
  const defaultizedProps = _extends({}, defaultProps, settings, props);
58
113
  const {
59
114
  position,
60
115
  disableLine,
61
116
  disableTicks,
62
- tickFontSize,
117
+ tickLabelStyle,
63
118
  label,
119
+ labelStyle,
120
+ tickFontSize,
64
121
  labelFontSize,
65
122
  tickSize: tickSizeProp,
66
123
  valueFormatter,
67
124
  slots,
68
- slotProps
125
+ slotProps,
126
+ tickInterval,
127
+ tickLabelInterval
69
128
  } = defaultizedProps;
70
129
  const theme = useTheme();
71
130
  const classes = useUtilityClasses(_extends({}, defaultizedProps, {
@@ -78,16 +137,7 @@ function ChartsXAxis(inProps) {
78
137
  height
79
138
  } = React.useContext(DrawingContext);
80
139
  const tickSize = disableTicks ? 4 : tickSizeProp;
81
- const xTicks = useTicks({
82
- scale: xScale,
83
- tickNumber,
84
- valueFormatter
85
- });
86
- const positionSigne = position === 'bottom' ? 1 : -1;
87
- const labelRefPoint = {
88
- x: left + width / 2,
89
- y: positionSigne * (tickFontSize + tickSize + 10)
90
- };
140
+ const positionSign = position === 'bottom' ? 1 : -1;
91
141
  const Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
92
142
  const Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : 'line';
93
143
  const TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsText;
@@ -96,27 +146,40 @@ function ChartsXAxis(inProps) {
96
146
  elementType: TickLabel,
97
147
  externalSlotProps: slotProps == null ? void 0 : slotProps.axisTickLabel,
98
148
  additionalProps: {
99
- textAnchor: 'middle',
100
- dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
101
- style: {
102
- fontSize: tickFontSize
103
- },
149
+ style: _extends({
150
+ textAnchor: 'middle',
151
+ dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
152
+ fontSize: tickFontSize != null ? tickFontSize : 12
153
+ }, tickLabelStyle),
104
154
  className: classes.tickLabel
105
155
  },
106
156
  className: classes.tickLabel,
107
157
  ownerState: {}
108
158
  });
159
+ const xTicks = useTicks({
160
+ scale: xScale,
161
+ tickNumber,
162
+ valueFormatter,
163
+ tickInterval
164
+ });
165
+ const xTicksWithDimension = addLabelDimension(xTicks, {
166
+ tickLabelStyle: axisTickLabelProps.style,
167
+ tickLabelInterval,
168
+ isMounted
169
+ });
170
+ const labelRefPoint = {
171
+ x: left + width / 2,
172
+ y: positionSign * (tickSize + 22)
173
+ };
109
174
  const axisLabelProps = useSlotProps({
110
175
  elementType: Label,
111
176
  externalSlotProps: slotProps == null ? void 0 : slotProps.axisLabel,
112
177
  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
178
+ style: _extends({
179
+ fontSize: labelFontSize != null ? labelFontSize : 14,
180
+ textAnchor: 'middle',
181
+ dominantBaseline: position === 'bottom' ? 'hanging' : 'auto'
182
+ }, labelStyle)
120
183
  },
121
184
  ownerState: {}
122
185
  });
@@ -127,23 +190,23 @@ function ChartsXAxis(inProps) {
127
190
  x1: xScale.range()[0],
128
191
  x2: xScale.range()[1],
129
192
  className: classes.line
130
- }, slotProps == null ? void 0 : slotProps.axisLine)), xTicks.map(({
193
+ }, slotProps == null ? void 0 : slotProps.axisLine)), xTicksWithDimension.map(({
131
194
  formattedValue,
132
195
  offset,
133
- labelOffset
196
+ labelOffset,
197
+ skipLabel
134
198
  }, index) => {
135
199
  const xTickLabel = labelOffset != null ? labelOffset : 0;
136
- const yTickLabel = positionSigne * (tickSize + 3);
200
+ const yTickLabel = positionSign * (tickSize + 3);
137
201
  return /*#__PURE__*/_jsxs("g", {
138
202
  transform: `translate(${offset}, 0)`,
139
203
  className: classes.tickContainer,
140
204
  children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
141
- y2: positionSigne * tickSize,
205
+ y2: positionSign * tickSize,
142
206
  className: classes.tick
143
- }, slotProps == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
207
+ }, slotProps == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && !skipLabel && /*#__PURE__*/_jsx(TickLabel, _extends({
144
208
  x: xTickLabel,
145
- y: yTickLabel,
146
- "transform-origin": `${xTickLabel}px ${yTickLabel}px`
209
+ y: yTickLabel
147
210
  }, axisTickLabelProps, {
148
211
  text: formattedValue.toString()
149
212
  }))]
@@ -191,8 +254,13 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
191
254
  /**
192
255
  * The font size of the axis label.
193
256
  * @default 14
257
+ * @deprecated Consider using `labelStyle.fontSize` instead.
194
258
  */
195
259
  labelFontSize: PropTypes.number,
260
+ /**
261
+ * The style applied to the axis label.
262
+ */
263
+ labelStyle: PropTypes.object,
196
264
  /**
197
265
  * Position of the axis.
198
266
  */
@@ -215,8 +283,28 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
215
283
  /**
216
284
  * The font size of the axis ticks text.
217
285
  * @default 12
286
+ * @deprecated Consider using `tickLabelStyle.fontSize` instead.
218
287
  */
219
288
  tickFontSize: PropTypes.number,
289
+ /**
290
+ * Defines which ticks are displayed. Its value can be:
291
+ * - 'auto' In such case the ticks are computed based on axis scale and other parameters.
292
+ * - a filtering function of the form `(value, index) => boolean` which is available only if the axis has a data property.
293
+ * - an array containing the values where ticks should be displayed.
294
+ * @default 'auto'
295
+ */
296
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
297
+ /**
298
+ * Defines which ticks get its label displayed. Its value can be:
299
+ * - 'auto' In such case, labels are displayed if they do not overlap with the previous one.
300
+ * - a filtering function of the form (value, index) => boolean. Warning: the index is tick index, not data ones.
301
+ * @default 'auto'
302
+ */
303
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
304
+ /**
305
+ * The style applied to ticks text.
306
+ */
307
+ tickLabelStyle: PropTypes.object,
220
308
  /**
221
309
  * Maximal step between two ticks.
222
310
  * When using time data, the value is assumed to be in ms.
@@ -83,9 +83,9 @@ function ChartsYAxis(inProps) {
83
83
  tickNumber,
84
84
  valueFormatter
85
85
  });
86
- const positionSigne = position === 'right' ? 1 : -1;
86
+ const positionSign = position === 'right' ? 1 : -1;
87
87
  const labelRefPoint = {
88
- x: positionSigne * (tickFontSize + tickSize + 10),
88
+ x: positionSign * (tickFontSize + tickSize + 10),
89
89
  y: top + height / 2
90
90
  };
91
91
  const Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
@@ -96,10 +96,10 @@ function ChartsYAxis(inProps) {
96
96
  elementType: TickLabel,
97
97
  externalSlotProps: slotProps == null ? void 0 : slotProps.axisTickLabel,
98
98
  additionalProps: {
99
- textAnchor: position === 'right' ? 'start' : 'end',
100
- dominantBaseline: 'central',
101
99
  style: {
102
- fontSize: tickFontSize
100
+ fontSize: tickFontSize,
101
+ textAnchor: position === 'right' ? 'start' : 'end',
102
+ dominantBaseline: 'central'
103
103
  },
104
104
  className: classes.tickLabel
105
105
  },
@@ -109,14 +109,12 @@ function ChartsYAxis(inProps) {
109
109
  elementType: Label,
110
110
  externalSlotProps: slotProps == null ? void 0 : slotProps.axisLabel,
111
111
  additionalProps: {
112
- textAnchor: 'middle',
113
- dominantBaseline: 'auto',
114
112
  style: {
115
113
  fontSize: labelFontSize,
116
- transform: `rotate(${positionSigne * 90}deg)`,
117
- transformOrigin: `${labelRefPoint.x}px ${labelRefPoint.y}px`
118
- },
119
- className: classes.label
114
+ angle: positionSign * 90,
115
+ textAnchor: 'middle',
116
+ dominantBaseline: 'auto'
117
+ }
120
118
  },
121
119
  ownerState: {}
122
120
  });
@@ -132,18 +130,17 @@ function ChartsYAxis(inProps) {
132
130
  offset,
133
131
  labelOffset
134
132
  }, index) => {
135
- const xTickLabel = positionSigne * (tickSize + 2);
133
+ const xTickLabel = positionSign * (tickSize + 2);
136
134
  const yTickLabel = labelOffset;
137
135
  return /*#__PURE__*/_jsxs("g", {
138
136
  transform: `translate(0, ${offset})`,
139
137
  className: classes.tickContainer,
140
138
  children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
141
- x2: positionSigne * tickSize,
139
+ x2: positionSign * tickSize,
142
140
  className: classes.tick
143
141
  }, slotProps == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
144
142
  x: xTickLabel,
145
143
  y: yTickLabel,
146
- "transform-origin": `${xTickLabel}px ${yTickLabel}px`,
147
144
  text: formattedValue.toString()
148
145
  }, axisTickLabelProps))]
149
146
  }, index);
@@ -190,8 +187,13 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
190
187
  /**
191
188
  * The font size of the axis label.
192
189
  * @default 14
190
+ * @deprecated Consider using `labelStyle.fontSize` instead.
193
191
  */
194
192
  labelFontSize: PropTypes.number,
193
+ /**
194
+ * The style applied to the axis label.
195
+ */
196
+ labelStyle: PropTypes.object,
195
197
  /**
196
198
  * Position of the axis.
197
199
  */
@@ -214,8 +216,28 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
214
216
  /**
215
217
  * The font size of the axis ticks text.
216
218
  * @default 12
219
+ * @deprecated Consider using `tickLabelStyle.fontSize` instead.
217
220
  */
218
221
  tickFontSize: PropTypes.number,
222
+ /**
223
+ * Defines which ticks are displayed. Its value can be:
224
+ * - 'auto' In such case the ticks are computed based on axis scale and other parameters.
225
+ * - a filtering function of the form `(value, index) => boolean` which is available only if the axis has a data property.
226
+ * - an array containing the values where ticks should be displayed.
227
+ * @default 'auto'
228
+ */
229
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
230
+ /**
231
+ * Defines which ticks get its label displayed. Its value can be:
232
+ * - 'auto' In such case, labels are displayed if they do not overlap with the previous one.
233
+ * - a filtering function of the form (value, index) => boolean. Warning: the index is tick index, not data ones.
234
+ * @default 'auto'
235
+ */
236
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
237
+ /**
238
+ * The style applied to ticks text.
239
+ */
240
+ tickLabelStyle: PropTypes.object,
219
241
  /**
220
242
  * Maximal step between two ticks.
221
243
  * When using time data, the value is assumed to be in ms.
@@ -55,6 +55,16 @@ AreaElementPath.propTypes = {
55
55
  }).isRequired,
56
56
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
57
57
  };
58
+ /**
59
+ * Demos:
60
+ *
61
+ * - [Lines](https://mui.com/x/react-charts/lines/)
62
+ * - [Areas demonstration](https://mui.com/x/react-charts/areas-demo/)
63
+ *
64
+ * API:
65
+ *
66
+ * - [AreaElement API](https://mui.com/x/api/charts/area-element/)
67
+ */
58
68
  function AreaElement(props) {
59
69
  var _slots$area;
60
70
  const {
@@ -10,6 +10,17 @@ import { AreaElement } from './AreaElement';
10
10
  import { getValueToPositionMapper } from '../hooks/useScale';
11
11
  import getCurveFactory from '../internals/getCurve';
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
+ /**
14
+ * Demos:
15
+ *
16
+ * - [Lines](https://mui.com/x/react-charts/lines/)
17
+ * - [Areas demonstration](https://mui.com/x/react-charts/areas-demo/)
18
+ * - [Stacking](https://mui.com/x/react-charts/stacking/)
19
+ *
20
+ * API:
21
+ *
22
+ * - [AreaPlot API](https://mui.com/x/api/charts/area-plot/)
23
+ */
13
24
  function AreaPlot(props) {
14
25
  const {
15
26
  slots,
@@ -15,6 +15,16 @@ import { ChartsClipPath } from '../ChartsClipPath';
15
15
  import { LineHighlightPlot } from './LineHighlightPlot';
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
17
  import { jsxs as _jsxs } from "react/jsx-runtime";
18
+ /**
19
+ * Demos:
20
+ *
21
+ * - [Lines](https://mui.com/x/react-charts/lines/)
22
+ * - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
23
+ *
24
+ * API:
25
+ *
26
+ * - [LineChart API](https://mui.com/x/api/charts/line-chart/)
27
+ */
18
28
  const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
19
29
  const {
20
30
  xAxis,
@@ -121,11 +131,15 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
121
131
  fill: PropTypes.string,
122
132
  label: PropTypes.string,
123
133
  labelFontSize: PropTypes.number,
134
+ labelStyle: PropTypes.object,
124
135
  position: PropTypes.oneOf(['bottom', 'top']),
125
136
  slotProps: PropTypes.object,
126
137
  slots: PropTypes.object,
127
138
  stroke: PropTypes.string,
128
139
  tickFontSize: PropTypes.number,
140
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
141
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
142
+ tickLabelStyle: PropTypes.object,
129
143
  tickMaxStep: PropTypes.number,
130
144
  tickMinStep: PropTypes.number,
131
145
  tickNumber: PropTypes.number,
@@ -158,11 +172,15 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
158
172
  fill: PropTypes.string,
159
173
  label: PropTypes.string,
160
174
  labelFontSize: PropTypes.number,
175
+ labelStyle: PropTypes.object,
161
176
  position: PropTypes.oneOf(['left', 'right']),
162
177
  slotProps: PropTypes.object,
163
178
  slots: PropTypes.object,
164
179
  stroke: PropTypes.string,
165
180
  tickFontSize: PropTypes.number,
181
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
182
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
183
+ tickLabelStyle: PropTypes.object,
166
184
  tickMaxStep: PropTypes.number,
167
185
  tickMinStep: PropTypes.number,
168
186
  tickNumber: PropTypes.number,
@@ -201,11 +219,15 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
201
219
  fill: PropTypes.string,
202
220
  label: PropTypes.string,
203
221
  labelFontSize: PropTypes.number,
222
+ labelStyle: PropTypes.object,
204
223
  position: PropTypes.oneOf(['left', 'right']),
205
224
  slotProps: PropTypes.object,
206
225
  slots: PropTypes.object,
207
226
  stroke: PropTypes.string,
208
227
  tickFontSize: PropTypes.number,
228
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
229
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
230
+ tickLabelStyle: PropTypes.object,
209
231
  tickMaxStep: PropTypes.number,
210
232
  tickMinStep: PropTypes.number,
211
233
  tickNumber: PropTypes.number,
@@ -266,11 +288,15 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
266
288
  fill: PropTypes.string,
267
289
  label: PropTypes.string,
268
290
  labelFontSize: PropTypes.number,
291
+ labelStyle: PropTypes.object,
269
292
  position: PropTypes.oneOf(['bottom', 'top']),
270
293
  slotProps: PropTypes.object,
271
294
  slots: PropTypes.object,
272
295
  stroke: PropTypes.string,
273
296
  tickFontSize: PropTypes.number,
297
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
298
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
299
+ tickLabelStyle: PropTypes.object,
274
300
  tickMaxStep: PropTypes.number,
275
301
  tickMinStep: PropTypes.number,
276
302
  tickNumber: PropTypes.number,
@@ -295,6 +321,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
295
321
  id: PropTypes.string,
296
322
  label: PropTypes.string,
297
323
  labelFontSize: PropTypes.number,
324
+ labelStyle: PropTypes.object,
298
325
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
299
326
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
300
327
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
@@ -303,6 +330,9 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
303
330
  slots: PropTypes.object,
304
331
  stroke: PropTypes.string,
305
332
  tickFontSize: PropTypes.number,
333
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
334
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
335
+ tickLabelStyle: PropTypes.object,
306
336
  tickMaxStep: PropTypes.number,
307
337
  tickMinStep: PropTypes.number,
308
338
  tickNumber: PropTypes.number,
@@ -321,6 +351,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
321
351
  id: PropTypes.string,
322
352
  label: PropTypes.string,
323
353
  labelFontSize: PropTypes.number,
354
+ labelStyle: PropTypes.object,
324
355
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
325
356
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
326
357
  position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
@@ -329,6 +360,9 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
329
360
  slots: PropTypes.object,
330
361
  stroke: PropTypes.string,
331
362
  tickFontSize: PropTypes.number,
363
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
364
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
365
+ tickLabelStyle: PropTypes.object,
332
366
  tickMaxStep: PropTypes.number,
333
367
  tickMinStep: PropTypes.number,
334
368
  tickNumber: PropTypes.number,
@@ -57,6 +57,16 @@ LineElementPath.propTypes = {
57
57
  }).isRequired,
58
58
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
59
59
  };
60
+ /**
61
+ * Demos:
62
+ *
63
+ * - [Lines](https://mui.com/x/react-charts/lines/)
64
+ * - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
65
+ *
66
+ * API:
67
+ *
68
+ * - [LineElement API](https://mui.com/x/api/charts/line-element/)
69
+ */
60
70
  function LineElement(props) {
61
71
  var _slots$line;
62
72
  const {
@@ -33,6 +33,16 @@ const HighlightElement = styled('circle', {
33
33
  transformOrigin: `${ownerState.x}px ${ownerState.y}px`,
34
34
  fill: ownerState.color
35
35
  }));
36
+ /**
37
+ * Demos:
38
+ *
39
+ * - [Lines](https://mui.com/x/react-charts/lines/)
40
+ * - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
41
+ *
42
+ * API:
43
+ *
44
+ * - [LineHighlightElement API](https://mui.com/x/api/charts/line-highlight-element/)
45
+ */
36
46
  function LineHighlightElement(props) {
37
47
  const {
38
48
  x,
@@ -9,6 +9,16 @@ import { LineHighlightElement } from './LineHighlightElement';
9
9
  import { getValueToPositionMapper } from '../hooks/useScale';
10
10
  import { InteractionContext } from '../context/InteractionProvider';
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
+ /**
13
+ * Demos:
14
+ *
15
+ * - [Lines](https://mui.com/x/react-charts/lines/)
16
+ * - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
17
+ *
18
+ * API:
19
+ *
20
+ * - [LineHighlightPlot API](https://mui.com/x/api/charts/line-highlight-plot/)
21
+ */
12
22
  function LineHighlightPlot(props) {
13
23
  var _axis$x, _slots$lineHighlight;
14
24
  const {
@@ -10,6 +10,16 @@ import { LineElement } from './LineElement';
10
10
  import { getValueToPositionMapper } from '../hooks/useScale';
11
11
  import getCurveFactory from '../internals/getCurve';
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
+ /**
14
+ * Demos:
15
+ *
16
+ * - [Lines](https://mui.com/x/react-charts/lines/)
17
+ * - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
18
+ *
19
+ * API:
20
+ *
21
+ * - [LinePlot API](https://mui.com/x/api/charts/line-plot/)
22
+ */
13
23
  function LinePlot(props) {
14
24
  const {
15
25
  slots,
@@ -59,6 +59,16 @@ MarkElementPath.propTypes = {
59
59
  }).isRequired,
60
60
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
61
61
  };
62
+ /**
63
+ * Demos:
64
+ *
65
+ * - [Lines](https://mui.com/x/react-charts/lines/)
66
+ * - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
67
+ *
68
+ * API:
69
+ *
70
+ * - [MarkElement API](https://mui.com/x/api/charts/mark-element/)
71
+ */
62
72
  function MarkElement(props) {
63
73
  var _axis$x;
64
74
  const {
@@ -8,6 +8,16 @@ import { CartesianContext } from '../context/CartesianContextProvider';
8
8
  import { MarkElement } from './MarkElement';
9
9
  import { getValueToPositionMapper } from '../hooks/useScale';
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
+ /**
12
+ * Demos:
13
+ *
14
+ * - [Lines](https://mui.com/x/react-charts/lines/)
15
+ * - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
16
+ *
17
+ * API:
18
+ *
19
+ * - [MarkPlot API](https://mui.com/x/api/charts/mark-plot/)
20
+ */
11
21
  function MarkPlot(props) {
12
22
  var _slots$mark;
13
23
  const {