@mui/x-charts 7.0.0-beta.3 → 7.0.0-beta.5

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 (221) hide show
  1. package/BarChart/BarChart.js +0 -2
  2. package/CHANGELOG.md +357 -22
  3. package/ChartsGrid/ChartsGrid.js +2 -2
  4. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
  5. package/ChartsTooltip/utils.js +1 -1
  6. package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +0 -1
  7. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +1 -2
  8. package/ChartsXAxis/ChartsXAxis.js +1 -1
  9. package/ChartsYAxis/ChartsYAxis.js +1 -1
  10. package/Gauge/Gauge.js +0 -2
  11. package/Gauge/GaugeContainer.d.ts +0 -2
  12. package/Gauge/GaugeContainer.js +0 -2
  13. package/Gauge/GaugeProvider.js +3 -0
  14. package/Gauge/GaugeValueText.js +1 -1
  15. package/LineChart/LineChart.js +0 -2
  16. package/PieChart/PieChart.js +0 -2
  17. package/ResponsiveChartContainer/ResponsiveChartContainer.d.ts +0 -2
  18. package/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -2
  19. package/ScatterChart/ScatterChart.js +0 -3
  20. package/SparkLineChart/SparkLineChart.js +0 -2
  21. package/context/CartesianContextProvider.d.ts +0 -8
  22. package/context/CartesianContextProvider.js +4 -89
  23. package/context/DrawingProvider.d.ts +2 -11
  24. package/context/DrawingProvider.js +10 -35
  25. package/context/HighlightProvider.js +3 -0
  26. package/context/InteractionProvider.js +3 -0
  27. package/context/SeriesContextProvider.js +3 -0
  28. package/context/index.d.ts +0 -2
  29. package/context/index.js +1 -15
  30. package/esm/BarChart/BarChart.js +0 -2
  31. package/esm/ChartsGrid/ChartsGrid.js +2 -2
  32. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  33. package/esm/ChartsTooltip/utils.js +2 -2
  34. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -3
  35. package/esm/ChartsXAxis/ChartsXAxis.js +1 -1
  36. package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
  37. package/esm/Gauge/Gauge.js +0 -2
  38. package/esm/Gauge/GaugeContainer.js +0 -2
  39. package/esm/Gauge/GaugeProvider.js +3 -0
  40. package/esm/Gauge/GaugeValueText.js +1 -1
  41. package/esm/LineChart/LineChart.js +0 -2
  42. package/esm/PieChart/PieChart.js +0 -2
  43. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -2
  44. package/esm/ScatterChart/ScatterChart.js +0 -3
  45. package/esm/SparkLineChart/SparkLineChart.js +0 -2
  46. package/esm/context/CartesianContextProvider.js +3 -88
  47. package/esm/context/DrawingProvider.js +10 -36
  48. package/esm/context/HighlightProvider.js +3 -0
  49. package/esm/context/InteractionProvider.js +3 -0
  50. package/esm/context/SeriesContextProvider.js +3 -0
  51. package/esm/context/index.js +1 -2
  52. package/esm/hooks/useAxisEvents.js +2 -2
  53. package/hooks/useAxisEvents.js +1 -1
  54. package/hooks/useTicks.d.ts +1 -1
  55. package/index.js +1 -1
  56. package/modern/BarChart/BarChart.js +0 -2
  57. package/modern/ChartsGrid/ChartsGrid.js +2 -2
  58. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  59. package/modern/ChartsTooltip/utils.js +2 -2
  60. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -3
  61. package/modern/ChartsXAxis/ChartsXAxis.js +1 -1
  62. package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
  63. package/modern/Gauge/Gauge.js +0 -2
  64. package/modern/Gauge/GaugeContainer.js +0 -2
  65. package/modern/Gauge/GaugeProvider.js +3 -0
  66. package/modern/Gauge/GaugeValueText.js +1 -1
  67. package/modern/LineChart/LineChart.js +0 -2
  68. package/modern/PieChart/PieChart.js +0 -2
  69. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -2
  70. package/modern/ScatterChart/ScatterChart.js +0 -3
  71. package/modern/SparkLineChart/SparkLineChart.js +0 -2
  72. package/modern/context/CartesianContextProvider.js +3 -88
  73. package/modern/context/DrawingProvider.js +10 -36
  74. package/modern/context/HighlightProvider.js +3 -0
  75. package/modern/context/InteractionProvider.js +3 -0
  76. package/modern/context/SeriesContextProvider.js +3 -0
  77. package/modern/context/index.js +1 -2
  78. package/modern/hooks/useAxisEvents.js +2 -2
  79. package/modern/index.js +1 -1
  80. package/package.json +1 -1
  81. package/legacy/BarChart/BarChart.js +0 -440
  82. package/legacy/BarChart/BarElement.js +0 -119
  83. package/legacy/BarChart/BarPlot.js +0 -232
  84. package/legacy/BarChart/extremums.js +0 -45
  85. package/legacy/BarChart/formatter.js +0 -78
  86. package/legacy/BarChart/index.js +0 -3
  87. package/legacy/BarChart/legend.js +0 -15
  88. package/legacy/ChartContainer/ChartContainer.js +0 -189
  89. package/legacy/ChartContainer/index.js +0 -1
  90. package/legacy/ChartsAxis/ChartsAxis.js +0 -215
  91. package/legacy/ChartsAxis/axisClasses.js +0 -5
  92. package/legacy/ChartsAxis/index.js +0 -2
  93. package/legacy/ChartsAxisHighlight/ChartsAxisHighlight.js +0 -105
  94. package/legacy/ChartsAxisHighlight/index.js +0 -1
  95. package/legacy/ChartsClipPath/ChartsClipPath.js +0 -48
  96. package/legacy/ChartsClipPath/index.js +0 -1
  97. package/legacy/ChartsGrid/ChartsGrid.js +0 -119
  98. package/legacy/ChartsGrid/chartsGridClasses.js +0 -6
  99. package/legacy/ChartsGrid/index.js +0 -2
  100. package/legacy/ChartsLegend/ChartsLegend.js +0 -100
  101. package/legacy/ChartsLegend/DefaultChartsLegend.js +0 -302
  102. package/legacy/ChartsLegend/chartsLegendClasses.js +0 -5
  103. package/legacy/ChartsLegend/index.js +0 -4
  104. package/legacy/ChartsLegend/utils.js +0 -15
  105. package/legacy/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +0 -75
  106. package/legacy/ChartsOnAxisClickHandler/index.js +0 -1
  107. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +0 -72
  108. package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +0 -105
  109. package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +0 -105
  110. package/legacy/ChartsReferenceLine/chartsReferenceLineClasses.js +0 -6
  111. package/legacy/ChartsReferenceLine/common.js +0 -19
  112. package/legacy/ChartsReferenceLine/index.js +0 -2
  113. package/legacy/ChartsSurface.js +0 -78
  114. package/legacy/ChartsText/ChartsText.js +0 -95
  115. package/legacy/ChartsText/index.js +0 -1
  116. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +0 -96
  117. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +0 -53
  118. package/legacy/ChartsTooltip/ChartsTooltip.js +0 -148
  119. package/legacy/ChartsTooltip/ChartsTooltipTable.js +0 -80
  120. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -118
  121. package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -78
  122. package/legacy/ChartsTooltip/chartsTooltipClasses.js +0 -5
  123. package/legacy/ChartsTooltip/index.js +0 -6
  124. package/legacy/ChartsTooltip/utils.js +0 -103
  125. package/legacy/ChartsVoronoiHandler/ChartsVoronoiHandler.js +0 -206
  126. package/legacy/ChartsVoronoiHandler/index.js +0 -1
  127. package/legacy/ChartsXAxis/ChartsXAxis.js +0 -339
  128. package/legacy/ChartsXAxis/index.js +0 -1
  129. package/legacy/ChartsYAxis/ChartsYAxis.js +0 -267
  130. package/legacy/ChartsYAxis/index.js +0 -1
  131. package/legacy/Gauge/Gauge.js +0 -146
  132. package/legacy/Gauge/GaugeContainer.js +0 -215
  133. package/legacy/Gauge/GaugeProvider.js +0 -87
  134. package/legacy/Gauge/GaugeReferenceArc.js +0 -37
  135. package/legacy/Gauge/GaugeValueArc.js +0 -44
  136. package/legacy/Gauge/GaugeValueText.js +0 -66
  137. package/legacy/Gauge/gaugeClasses.js +0 -7
  138. package/legacy/Gauge/index.js +0 -7
  139. package/legacy/Gauge/utils.js +0 -84
  140. package/legacy/LineChart/AnimatedArea.js +0 -102
  141. package/legacy/LineChart/AnimatedLine.js +0 -104
  142. package/legacy/LineChart/AreaElement.js +0 -112
  143. package/legacy/LineChart/AreaPlot.js +0 -149
  144. package/legacy/LineChart/LineChart.js +0 -452
  145. package/legacy/LineChart/LineElement.js +0 -112
  146. package/legacy/LineChart/LineHighlightElement.js +0 -79
  147. package/legacy/LineChart/LineHighlightPlot.js +0 -97
  148. package/legacy/LineChart/LinePlot.js +0 -144
  149. package/legacy/LineChart/MarkElement.js +0 -153
  150. package/legacy/LineChart/MarkPlot.js +0 -178
  151. package/legacy/LineChart/extremums.js +0 -54
  152. package/legacy/LineChart/formatter.js +0 -82
  153. package/legacy/LineChart/index.js +0 -11
  154. package/legacy/LineChart/legend.js +0 -15
  155. package/legacy/PieChart/PieArc.js +0 -103
  156. package/legacy/PieChart/PieArcLabel.js +0 -112
  157. package/legacy/PieChart/PieArcLabelPlot.js +0 -193
  158. package/legacy/PieChart/PieArcPlot.js +0 -180
  159. package/legacy/PieChart/PieChart.js +0 -404
  160. package/legacy/PieChart/PiePlot.js +0 -137
  161. package/legacy/PieChart/dataTransform/transition.js +0 -149
  162. package/legacy/PieChart/dataTransform/useTransformData.js +0 -63
  163. package/legacy/PieChart/formatter.js +0 -55
  164. package/legacy/PieChart/index.js +0 -6
  165. package/legacy/PieChart/legend.js +0 -16
  166. package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -185
  167. package/legacy/ResponsiveChartContainer/index.js +0 -1
  168. package/legacy/ResponsiveChartContainer/useChartContainerDimensions.js +0 -73
  169. package/legacy/ScatterChart/Scatter.js +0 -110
  170. package/legacy/ScatterChart/ScatterChart.js +0 -395
  171. package/legacy/ScatterChart/ScatterPlot.js +0 -80
  172. package/legacy/ScatterChart/extremums.js +0 -39
  173. package/legacy/ScatterChart/formatter.js +0 -12
  174. package/legacy/ScatterChart/index.js +0 -3
  175. package/legacy/ScatterChart/legend.js +0 -15
  176. package/legacy/SparkLineChart/SparkLineChart.js +0 -266
  177. package/legacy/SparkLineChart/index.js +0 -1
  178. package/legacy/colorPalettes/colorPalettes.js +0 -15
  179. package/legacy/colorPalettes/index.js +0 -1
  180. package/legacy/constants.js +0 -8
  181. package/legacy/context/CartesianContextProvider.js +0 -327
  182. package/legacy/context/DrawingProvider.js +0 -74
  183. package/legacy/context/HighlightProvider.js +0 -56
  184. package/legacy/context/InteractionProvider.js +0 -81
  185. package/legacy/context/SeriesContextProvider.js +0 -74
  186. package/legacy/context/index.js +0 -2
  187. package/legacy/hooks/index.js +0 -2
  188. package/legacy/hooks/useAxisEvents.js +0 -120
  189. package/legacy/hooks/useChartDimensions.js +0 -18
  190. package/legacy/hooks/useDrawingArea.js +0 -21
  191. package/legacy/hooks/useInteractionItemProps.js +0 -71
  192. package/legacy/hooks/useMounted.js +0 -21
  193. package/legacy/hooks/useReducedMotion.js +0 -27
  194. package/legacy/hooks/useScale.js +0 -33
  195. package/legacy/hooks/useTicks.js +0 -65
  196. package/legacy/index.js +0 -33
  197. package/legacy/internals/components/AxisSharedComponents.js +0 -25
  198. package/legacy/internals/defaultizeColor.js +0 -17
  199. package/legacy/internals/defaultizeValueFormatter.js +0 -12
  200. package/legacy/internals/domUtils.js +0 -121
  201. package/legacy/internals/geometry.js +0 -37
  202. package/legacy/internals/getCurve.js +0 -39
  203. package/legacy/internals/getScale.js +0 -17
  204. package/legacy/internals/getWordsByLines.js +0 -15
  205. package/legacy/internals/isBandScale.js +0 -3
  206. package/legacy/internals/stackSeries.js +0 -92
  207. package/legacy/internals/useAnimatedPath.js +0 -32
  208. package/legacy/internals/utils.js +0 -52
  209. package/legacy/models/axis.js +0 -6
  210. package/legacy/models/helpers.js +0 -1
  211. package/legacy/models/index.js +0 -4
  212. package/legacy/models/layout.js +0 -1
  213. package/legacy/models/seriesType/bar.js +0 -1
  214. package/legacy/models/seriesType/common.js +0 -1
  215. package/legacy/models/seriesType/config.js +0 -1
  216. package/legacy/models/seriesType/index.js +0 -5
  217. package/legacy/models/seriesType/line.js +0 -1
  218. package/legacy/models/seriesType/pie.js +0 -1
  219. package/legacy/models/seriesType/scatter.js +0 -1
  220. package/legacy/models/stacking.js +0 -1
  221. package/legacy/themeAugmentation/index.js +0 -3
@@ -1,339 +0,0 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
- import _extends from "@babel/runtime/helpers/esm/extends";
4
- var _excluded = ["scale", "tickNumber", "reverse"];
5
- import * as React from 'react';
6
- import PropTypes from 'prop-types';
7
- import { useSlotProps } from '@mui/base/utils';
8
- import { unstable_composeClasses as composeClasses } from '@mui/utils';
9
- import { useThemeProps, useTheme } from '@mui/material/styles';
10
- import { CartesianContext } from '../context/CartesianContextProvider';
11
- import { DrawingContext } from '../context/DrawingProvider';
12
- import { useTicks } from '../hooks/useTicks';
13
- import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
14
- import { AxisRoot } from '../internals/components/AxisSharedComponents';
15
- import { ChartsText } from '../ChartsText';
16
- import { getMinXTranslation } from '../internals/geometry';
17
- import { useMounted } from '../hooks/useMounted';
18
- import { getWordsByLines } from '../internals/getWordsByLines';
19
- import { jsx as _jsx } from "react/jsx-runtime";
20
- import { jsxs as _jsxs } from "react/jsx-runtime";
21
- var useUtilityClasses = function useUtilityClasses(ownerState) {
22
- var classes = ownerState.classes,
23
- position = ownerState.position;
24
- var slots = {
25
- root: ['root', 'directionX', position],
26
- line: ['line'],
27
- tickContainer: ['tickContainer'],
28
- tick: ['tick'],
29
- tickLabel: ['tickLabel'],
30
- label: ['label']
31
- };
32
- return composeClasses(slots, getAxisUtilityClass, classes);
33
- };
34
- function addLabelDimension(xTicks, _ref) {
35
- var style = _ref.tickLabelStyle,
36
- tickLabelInterval = _ref.tickLabelInterval,
37
- reverse = _ref.reverse,
38
- isMounted = _ref.isMounted;
39
- var withDimension = xTicks.map(function (tick) {
40
- if (!isMounted || tick.formattedValue === undefined) {
41
- return _extends({}, tick, {
42
- width: 0,
43
- height: 0
44
- });
45
- }
46
- var tickSizes = getWordsByLines({
47
- style: style,
48
- needsComputation: true,
49
- text: tick.formattedValue
50
- });
51
- return _extends({}, tick, {
52
- width: Math.max.apply(Math, _toConsumableArray(tickSizes.map(function (size) {
53
- return size.width;
54
- }))),
55
- height: Math.max(tickSizes.length * tickSizes[0].height)
56
- });
57
- });
58
- if (typeof tickLabelInterval === 'function') {
59
- return withDimension.map(function (item, index) {
60
- return _extends({}, item, {
61
- skipLabel: !tickLabelInterval(item.value, index)
62
- });
63
- });
64
- }
65
-
66
- // Filter label to avoid overlap
67
- var currentTextLimit = 0;
68
- var previouseTextLimit = 0;
69
- var direction = reverse ? -1 : 1;
70
- return withDimension.map(function (item, labelIndex) {
71
- var width = item.width,
72
- offset = item.offset,
73
- labelOffset = item.labelOffset,
74
- height = item.height;
75
- var distance = getMinXTranslation(width, height, style == null ? void 0 : style.angle);
76
- var textPosition = offset + labelOffset;
77
- var gapRatio = 1.2; // Ratio applied to the minimal distance to add some margin.
78
-
79
- currentTextLimit = textPosition - direction * (gapRatio * distance) / 2;
80
- if (labelIndex > 0 && direction * currentTextLimit < direction * previouseTextLimit) {
81
- // Except for the first label, we skip all label that overlap with the last accepted.
82
- // Notice that the early return prevents `previouseTextLimit` from being updated.
83
- return _extends({}, item, {
84
- skipLabel: true
85
- });
86
- }
87
- previouseTextLimit = textPosition + direction * (gapRatio * distance) / 2;
88
- return item;
89
- });
90
- }
91
- var defaultProps = {
92
- position: 'bottom',
93
- disableLine: false,
94
- disableTicks: false,
95
- tickSize: 6
96
- };
97
-
98
- /**
99
- * Demos:
100
- *
101
- * - [Axis](https://mui.com/x/react-charts/axis/)
102
- *
103
- * API:
104
- *
105
- * - [ChartsXAxis API](https://mui.com/x/api/charts/charts-x-axis/)
106
- */
107
- function ChartsXAxis(inProps) {
108
- var _props$axisId, _slots$axisLine, _slots$axisTick, _slots$axisTickLabel, _slots$axisLabel;
109
- var props = useThemeProps({
110
- props: _extends({}, defaultProps, inProps),
111
- name: 'MuiChartsXAxis'
112
- });
113
- var _React$useContext = React.useContext(CartesianContext),
114
- xAxisIds = _React$useContext.xAxisIds;
115
- var _React$useContext2 = React.useContext(CartesianContext),
116
- _React$useContext2$xA = _React$useContext2.xAxis[(_props$axisId = props.axisId) != null ? _props$axisId : xAxisIds[0]],
117
- xScale = _React$useContext2$xA.scale,
118
- tickNumber = _React$useContext2$xA.tickNumber,
119
- reverse = _React$useContext2$xA.reverse,
120
- settings = _objectWithoutProperties(_React$useContext2$xA, _excluded);
121
- var isMounted = useMounted();
122
- var defaultizedProps = _extends({}, defaultProps, settings, props);
123
- var position = defaultizedProps.position,
124
- disableLine = defaultizedProps.disableLine,
125
- disableTicks = defaultizedProps.disableTicks,
126
- tickLabelStyle = defaultizedProps.tickLabelStyle,
127
- label = defaultizedProps.label,
128
- labelStyle = defaultizedProps.labelStyle,
129
- tickFontSize = defaultizedProps.tickFontSize,
130
- labelFontSize = defaultizedProps.labelFontSize,
131
- tickSizeProp = defaultizedProps.tickSize,
132
- valueFormatter = defaultizedProps.valueFormatter,
133
- slots = defaultizedProps.slots,
134
- slotProps = defaultizedProps.slotProps,
135
- tickInterval = defaultizedProps.tickInterval,
136
- tickLabelInterval = defaultizedProps.tickLabelInterval;
137
- var theme = useTheme();
138
- var classes = useUtilityClasses(_extends({}, defaultizedProps, {
139
- theme: theme
140
- }));
141
- var _React$useContext3 = React.useContext(DrawingContext),
142
- left = _React$useContext3.left,
143
- top = _React$useContext3.top,
144
- width = _React$useContext3.width,
145
- height = _React$useContext3.height;
146
- var tickSize = disableTicks ? 4 : tickSizeProp;
147
- var positionSign = position === 'bottom' ? 1 : -1;
148
- var Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
149
- var Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : 'line';
150
- var TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsText;
151
- var Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsText;
152
- var axisTickLabelProps = useSlotProps({
153
- elementType: TickLabel,
154
- externalSlotProps: slotProps == null ? void 0 : slotProps.axisTickLabel,
155
- additionalProps: {
156
- style: _extends({
157
- textAnchor: 'middle',
158
- dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
159
- fontSize: tickFontSize != null ? tickFontSize : 12
160
- }, tickLabelStyle),
161
- className: classes.tickLabel
162
- },
163
- className: classes.tickLabel,
164
- ownerState: {}
165
- });
166
- var xTicks = useTicks({
167
- scale: xScale,
168
- tickNumber: tickNumber,
169
- valueFormatter: valueFormatter,
170
- tickInterval: tickInterval
171
- });
172
- var xTicksWithDimension = addLabelDimension(xTicks, {
173
- tickLabelStyle: axisTickLabelProps.style,
174
- tickLabelInterval: tickLabelInterval,
175
- reverse: reverse,
176
- isMounted: isMounted
177
- });
178
- var labelRefPoint = {
179
- x: left + width / 2,
180
- y: positionSign * (tickSize + 22)
181
- };
182
- var axisLabelProps = useSlotProps({
183
- elementType: Label,
184
- externalSlotProps: slotProps == null ? void 0 : slotProps.axisLabel,
185
- additionalProps: {
186
- style: _extends({
187
- fontSize: labelFontSize != null ? labelFontSize : 14,
188
- textAnchor: 'middle',
189
- dominantBaseline: position === 'bottom' ? 'hanging' : 'auto'
190
- }, labelStyle)
191
- },
192
- ownerState: {}
193
- });
194
- return /*#__PURE__*/_jsxs(AxisRoot, {
195
- transform: "translate(0, ".concat(position === 'bottom' ? top + height : top, ")"),
196
- className: classes.root,
197
- children: [!disableLine && /*#__PURE__*/_jsx(Line, _extends({
198
- x1: xScale.range()[0],
199
- x2: xScale.range()[1],
200
- className: classes.line
201
- }, slotProps == null ? void 0 : slotProps.axisLine)), xTicksWithDimension.map(function (_ref2, index) {
202
- var formattedValue = _ref2.formattedValue,
203
- offset = _ref2.offset,
204
- labelOffset = _ref2.labelOffset,
205
- skipLabel = _ref2.skipLabel;
206
- var xTickLabel = labelOffset != null ? labelOffset : 0;
207
- var yTickLabel = positionSign * (tickSize + 3);
208
- return /*#__PURE__*/_jsxs("g", {
209
- transform: "translate(".concat(offset, ", 0)"),
210
- className: classes.tickContainer,
211
- children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
212
- y2: positionSign * tickSize,
213
- className: classes.tick
214
- }, slotProps == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && !skipLabel && /*#__PURE__*/_jsx(TickLabel, _extends({
215
- x: xTickLabel,
216
- y: yTickLabel
217
- }, axisTickLabelProps, {
218
- text: formattedValue.toString()
219
- }))]
220
- }, index);
221
- }), label && /*#__PURE__*/_jsx("g", {
222
- className: classes.label,
223
- children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
224
- text: label
225
- }))
226
- })]
227
- });
228
- }
229
- process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
230
- // ----------------------------- Warning --------------------------------
231
- // | These PropTypes are generated from the TypeScript type definitions |
232
- // | To update them edit the TypeScript types and run "yarn proptypes" |
233
- // ----------------------------------------------------------------------
234
- /**
235
- * The id of the axis to render.
236
- * If undefined, it will be the first defined axis.
237
- */
238
- axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
239
- /**
240
- * Override or extend the styles applied to the component.
241
- */
242
- classes: PropTypes.object,
243
- /**
244
- * If true, the axis line is disabled.
245
- * @default false
246
- */
247
- disableLine: PropTypes.bool,
248
- /**
249
- * If true, the ticks are disabled.
250
- * @default false
251
- */
252
- disableTicks: PropTypes.bool,
253
- /**
254
- * The fill color of the axis text.
255
- * @default 'currentColor'
256
- */
257
- fill: PropTypes.string,
258
- /**
259
- * The label of the axis.
260
- */
261
- label: PropTypes.string,
262
- /**
263
- * The font size of the axis label.
264
- * @default 14
265
- * @deprecated Consider using `labelStyle.fontSize` instead.
266
- */
267
- labelFontSize: PropTypes.number,
268
- /**
269
- * The style applied to the axis label.
270
- */
271
- labelStyle: PropTypes.object,
272
- /**
273
- * Position of the axis.
274
- */
275
- position: PropTypes.oneOf(['bottom', 'top']),
276
- /**
277
- * The props used for each component slot.
278
- * @default {}
279
- */
280
- slotProps: PropTypes.object,
281
- /**
282
- * Overridable component slots.
283
- * @default {}
284
- */
285
- slots: PropTypes.object,
286
- /**
287
- * The stroke color of the axis line.
288
- * @default 'currentColor'
289
- */
290
- stroke: PropTypes.string,
291
- /**
292
- * The font size of the axis ticks text.
293
- * @default 12
294
- * @deprecated Consider using `tickLabelStyle.fontSize` instead.
295
- */
296
- tickFontSize: PropTypes.number,
297
- /**
298
- * Defines which ticks are displayed. Its value can be:
299
- * - 'auto' In such case the ticks are computed based on axis scale and other parameters.
300
- * - a filtering function of the form `(value, index) => boolean` which is available only if the axis has a data property.
301
- * - an array containing the values where ticks should be displayed.
302
- * @default 'auto'
303
- */
304
- tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
305
- /**
306
- * Defines which ticks get its label displayed. Its value can be:
307
- * - 'auto' In such case, labels are displayed if they do not overlap with the previous one.
308
- * - a filtering function of the form (value, index) => boolean. Warning: the index is tick index, not data ones.
309
- * @default 'auto'
310
- */
311
- tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
312
- /**
313
- * The style applied to ticks text.
314
- */
315
- tickLabelStyle: PropTypes.object,
316
- /**
317
- * Maximal step between two ticks.
318
- * When using time data, the value is assumed to be in ms.
319
- * Not supported by categorical axis (band, points).
320
- */
321
- tickMaxStep: PropTypes.number,
322
- /**
323
- * Maximal step between two ticks.
324
- * When using time data, the value is assumed to be in ms.
325
- * Not supported by categorical axis (band, points).
326
- */
327
- tickMinStep: PropTypes.number,
328
- /**
329
- * The number of ticks. This number is not guaranted.
330
- * Not supported by categorical axis (band, points).
331
- */
332
- tickNumber: PropTypes.number,
333
- /**
334
- * The size of the ticks.
335
- * @default 6
336
- */
337
- tickSize: PropTypes.number
338
- } : void 0;
339
- export { ChartsXAxis };
@@ -1 +0,0 @@
1
- export * from './ChartsXAxis';
@@ -1,267 +0,0 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
- import _extends from "@babel/runtime/helpers/esm/extends";
3
- var _excluded = ["scale", "tickNumber"];
4
- import * as React from 'react';
5
- import PropTypes from 'prop-types';
6
- import { useSlotProps } from '@mui/base/utils';
7
- import { unstable_composeClasses as composeClasses } from '@mui/utils';
8
- import { useThemeProps, useTheme } from '@mui/material/styles';
9
- import { CartesianContext } from '../context/CartesianContextProvider';
10
- import { DrawingContext } from '../context/DrawingProvider';
11
- import { useTicks } from '../hooks/useTicks';
12
- import { AxisRoot } from '../internals/components/AxisSharedComponents';
13
- import { ChartsText } from '../ChartsText';
14
- import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
15
- import { jsx as _jsx } from "react/jsx-runtime";
16
- import { jsxs as _jsxs } from "react/jsx-runtime";
17
- var useUtilityClasses = function useUtilityClasses(ownerState) {
18
- var classes = ownerState.classes,
19
- position = ownerState.position;
20
- var slots = {
21
- root: ['root', 'directionY', position],
22
- line: ['line'],
23
- tickContainer: ['tickContainer'],
24
- tick: ['tick'],
25
- tickLabel: ['tickLabel'],
26
- label: ['label']
27
- };
28
- return composeClasses(slots, getAxisUtilityClass, classes);
29
- };
30
- var defaultProps = {
31
- position: 'left',
32
- disableLine: false,
33
- disableTicks: false,
34
- tickFontSize: 12,
35
- labelFontSize: 14,
36
- tickSize: 6
37
- };
38
-
39
- /**
40
- * Demos:
41
- *
42
- * - [Axis](https://mui.com/x/react-charts/axis/)
43
- *
44
- * API:
45
- *
46
- * - [ChartsYAxis API](https://mui.com/x/api/charts/charts-y-axis/)
47
- */
48
- function ChartsYAxis(inProps) {
49
- var _props$axisId, _slots$axisLine, _slots$axisTick, _slots$axisTickLabel, _slots$axisLabel;
50
- var props = useThemeProps({
51
- props: _extends({}, defaultProps, inProps),
52
- name: 'MuiChartsYAxis'
53
- });
54
- var _React$useContext = React.useContext(CartesianContext),
55
- yAxisIds = _React$useContext.yAxisIds;
56
- var _React$useContext2 = React.useContext(CartesianContext),
57
- _React$useContext2$yA = _React$useContext2.yAxis[(_props$axisId = props.axisId) != null ? _props$axisId : yAxisIds[0]],
58
- yScale = _React$useContext2$yA.scale,
59
- tickNumber = _React$useContext2$yA.tickNumber,
60
- settings = _objectWithoutProperties(_React$useContext2$yA, _excluded);
61
- var defaultizedProps = _extends({}, defaultProps, settings, props);
62
- var position = defaultizedProps.position,
63
- disableLine = defaultizedProps.disableLine,
64
- disableTicks = defaultizedProps.disableTicks,
65
- tickFontSize = defaultizedProps.tickFontSize,
66
- label = defaultizedProps.label,
67
- labelFontSize = defaultizedProps.labelFontSize,
68
- labelStyle = defaultizedProps.labelStyle,
69
- tickLabelStyle = defaultizedProps.tickLabelStyle,
70
- tickSizeProp = defaultizedProps.tickSize,
71
- valueFormatter = defaultizedProps.valueFormatter,
72
- slots = defaultizedProps.slots,
73
- slotProps = defaultizedProps.slotProps;
74
- var theme = useTheme();
75
- var classes = useUtilityClasses(_extends({}, defaultizedProps, {
76
- theme: theme
77
- }));
78
- var _React$useContext3 = React.useContext(DrawingContext),
79
- left = _React$useContext3.left,
80
- top = _React$useContext3.top,
81
- width = _React$useContext3.width,
82
- height = _React$useContext3.height;
83
- var tickSize = disableTicks ? 4 : tickSizeProp;
84
- var yTicks = useTicks({
85
- scale: yScale,
86
- tickNumber: tickNumber,
87
- valueFormatter: valueFormatter
88
- });
89
- var positionSign = position === 'right' ? 1 : -1;
90
- var labelRefPoint = {
91
- x: positionSign * (tickFontSize + tickSize + 10),
92
- y: top + height / 2
93
- };
94
- var Line = (_slots$axisLine = slots == null ? void 0 : slots.axisLine) != null ? _slots$axisLine : 'line';
95
- var Tick = (_slots$axisTick = slots == null ? void 0 : slots.axisTick) != null ? _slots$axisTick : 'line';
96
- var TickLabel = (_slots$axisTickLabel = slots == null ? void 0 : slots.axisTickLabel) != null ? _slots$axisTickLabel : ChartsText;
97
- var Label = (_slots$axisLabel = slots == null ? void 0 : slots.axisLabel) != null ? _slots$axisLabel : ChartsText;
98
- var axisTickLabelProps = useSlotProps({
99
- elementType: TickLabel,
100
- externalSlotProps: slotProps == null ? void 0 : slotProps.axisTickLabel,
101
- additionalProps: {
102
- style: _extends({
103
- fontSize: tickFontSize,
104
- textAnchor: position === 'right' ? 'start' : 'end',
105
- dominantBaseline: 'central'
106
- }, tickLabelStyle),
107
- className: classes.tickLabel
108
- },
109
- ownerState: {}
110
- });
111
- var axisLabelProps = useSlotProps({
112
- elementType: Label,
113
- externalSlotProps: slotProps == null ? void 0 : slotProps.axisLabel,
114
- additionalProps: {
115
- style: _extends({
116
- fontSize: labelFontSize,
117
- angle: positionSign * 90,
118
- textAnchor: 'middle',
119
- dominantBaseline: 'auto'
120
- }, labelStyle)
121
- },
122
- ownerState: {}
123
- });
124
- return /*#__PURE__*/_jsxs(AxisRoot, {
125
- transform: "translate(".concat(position === 'right' ? left + width : left, ", 0)"),
126
- className: classes.root,
127
- children: [!disableLine && /*#__PURE__*/_jsx(Line, _extends({
128
- y1: yScale.range()[0],
129
- y2: yScale.range()[1],
130
- className: classes.line
131
- }, slotProps == null ? void 0 : slotProps.axisLine)), yTicks.map(function (_ref, index) {
132
- var formattedValue = _ref.formattedValue,
133
- offset = _ref.offset,
134
- labelOffset = _ref.labelOffset;
135
- var xTickLabel = positionSign * (tickSize + 2);
136
- var yTickLabel = labelOffset;
137
- return /*#__PURE__*/_jsxs("g", {
138
- transform: "translate(0, ".concat(offset, ")"),
139
- className: classes.tickContainer,
140
- children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
141
- x2: positionSign * tickSize,
142
- className: classes.tick
143
- }, slotProps == null ? void 0 : slotProps.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
144
- x: xTickLabel,
145
- y: yTickLabel,
146
- text: formattedValue.toString()
147
- }, axisTickLabelProps))]
148
- }, index);
149
- }), label && /*#__PURE__*/_jsx("g", {
150
- className: classes.label,
151
- children: /*#__PURE__*/_jsx(Label, _extends({}, labelRefPoint, axisLabelProps, {
152
- text: label
153
- }))
154
- })]
155
- });
156
- }
157
- process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
158
- // ----------------------------- Warning --------------------------------
159
- // | These PropTypes are generated from the TypeScript type definitions |
160
- // | To update them edit the TypeScript types and run "yarn proptypes" |
161
- // ----------------------------------------------------------------------
162
- /**
163
- * The id of the axis to render.
164
- * If undefined, it will be the first defined axis.
165
- */
166
- axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
167
- /**
168
- * Override or extend the styles applied to the component.
169
- */
170
- classes: PropTypes.object,
171
- /**
172
- * If true, the axis line is disabled.
173
- * @default false
174
- */
175
- disableLine: PropTypes.bool,
176
- /**
177
- * If true, the ticks are disabled.
178
- * @default false
179
- */
180
- disableTicks: PropTypes.bool,
181
- /**
182
- * The fill color of the axis text.
183
- * @default 'currentColor'
184
- */
185
- fill: PropTypes.string,
186
- /**
187
- * The label of the axis.
188
- */
189
- label: PropTypes.string,
190
- /**
191
- * The font size of the axis label.
192
- * @default 14
193
- * @deprecated Consider using `labelStyle.fontSize` instead.
194
- */
195
- labelFontSize: PropTypes.number,
196
- /**
197
- * The style applied to the axis label.
198
- */
199
- labelStyle: PropTypes.object,
200
- /**
201
- * Position of the axis.
202
- */
203
- position: PropTypes.oneOf(['left', 'right']),
204
- /**
205
- * The props used for each component slot.
206
- * @default {}
207
- */
208
- slotProps: PropTypes.object,
209
- /**
210
- * Overridable component slots.
211
- * @default {}
212
- */
213
- slots: PropTypes.object,
214
- /**
215
- * The stroke color of the axis line.
216
- * @default 'currentColor'
217
- */
218
- stroke: PropTypes.string,
219
- /**
220
- * The font size of the axis ticks text.
221
- * @default 12
222
- * @deprecated Consider using `tickLabelStyle.fontSize` instead.
223
- */
224
- tickFontSize: PropTypes.number,
225
- /**
226
- * Defines which ticks are displayed. Its value can be:
227
- * - 'auto' In such case the ticks are computed based on axis scale and other parameters.
228
- * - a filtering function of the form `(value, index) => boolean` which is available only if the axis has a data property.
229
- * - an array containing the values where ticks should be displayed.
230
- * @default 'auto'
231
- */
232
- tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
233
- /**
234
- * Defines which ticks get its label displayed. Its value can be:
235
- * - 'auto' In such case, labels are displayed if they do not overlap with the previous one.
236
- * - a filtering function of the form (value, index) => boolean. Warning: the index is tick index, not data ones.
237
- * @default 'auto'
238
- */
239
- tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
240
- /**
241
- * The style applied to ticks text.
242
- */
243
- tickLabelStyle: PropTypes.object,
244
- /**
245
- * Maximal step between two ticks.
246
- * When using time data, the value is assumed to be in ms.
247
- * Not supported by categorical axis (band, points).
248
- */
249
- tickMaxStep: PropTypes.number,
250
- /**
251
- * Maximal step between two ticks.
252
- * When using time data, the value is assumed to be in ms.
253
- * Not supported by categorical axis (band, points).
254
- */
255
- tickMinStep: PropTypes.number,
256
- /**
257
- * The number of ticks. This number is not guaranted.
258
- * Not supported by categorical axis (band, points).
259
- */
260
- tickNumber: PropTypes.number,
261
- /**
262
- * The size of the ticks.
263
- * @default 6
264
- */
265
- tickSize: PropTypes.number
266
- } : void 0;
267
- export { ChartsYAxis };
@@ -1 +0,0 @@
1
- export * from './ChartsYAxis';