@mui/x-charts 7.0.0-beta.2 → 7.0.0-beta.4

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 (265) hide show
  1. package/BarChart/BarChart.d.ts +21 -5
  2. package/BarChart/BarChart.js +27 -7
  3. package/CHANGELOG.md +298 -23
  4. package/ChartsGrid/ChartsGrid.d.ts +30 -0
  5. package/ChartsGrid/ChartsGrid.js +128 -0
  6. package/ChartsGrid/chartsGridClasses.d.ts +13 -0
  7. package/ChartsGrid/chartsGridClasses.js +14 -0
  8. package/ChartsGrid/index.d.ts +2 -0
  9. package/ChartsGrid/index.js +27 -0
  10. package/ChartsGrid/package.json +6 -0
  11. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +1 -1
  12. package/ChartsSurface.js +6 -4
  13. package/ChartsTooltip/utils.js +1 -1
  14. package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +0 -1
  15. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +1 -2
  16. package/ChartsXAxis/ChartsXAxis.js +3 -3
  17. package/ChartsYAxis/ChartsYAxis.js +3 -3
  18. package/Gauge/Gauge.d.ts +13 -0
  19. package/Gauge/Gauge.js +154 -0
  20. package/Gauge/GaugeContainer.d.ts +17 -0
  21. package/Gauge/GaugeContainer.js +214 -0
  22. package/Gauge/GaugeProvider.d.ts +117 -0
  23. package/Gauge/GaugeProvider.js +99 -0
  24. package/Gauge/GaugeReferenceArc.d.ts +2 -0
  25. package/Gauge/GaugeReferenceArc.js +44 -0
  26. package/Gauge/GaugeValueArc.d.ts +2 -0
  27. package/Gauge/GaugeValueArc.js +51 -0
  28. package/Gauge/GaugeValueText.d.ts +15 -0
  29. package/Gauge/GaugeValueText.js +77 -0
  30. package/Gauge/gaugeClasses.d.ts +14 -0
  31. package/Gauge/gaugeClasses.js +15 -0
  32. package/Gauge/index.d.ts +7 -0
  33. package/Gauge/index.js +87 -0
  34. package/Gauge/package.json +6 -0
  35. package/Gauge/utils.d.ts +19 -0
  36. package/Gauge/utils.js +75 -0
  37. package/LineChart/LineChart.d.ts +24 -5
  38. package/LineChart/LineChart.js +31 -7
  39. package/PieChart/PieArc.d.ts +4 -4
  40. package/PieChart/PieArc.js +9 -9
  41. package/PieChart/PieArcLabelPlot.js +13 -13
  42. package/PieChart/PieChart.d.ts +22 -0
  43. package/PieChart/PieChart.js +22 -2
  44. package/ResponsiveChartContainer/ResponsiveChartContainer.d.ts +0 -2
  45. package/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -68
  46. package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +2 -0
  47. package/ResponsiveChartContainer/useChartContainerDimensions.js +76 -0
  48. package/ScatterChart/ScatterChart.d.ts +18 -0
  49. package/ScatterChart/ScatterChart.js +25 -3
  50. package/SparkLineChart/SparkLineChart.js +0 -2
  51. package/context/CartesianContextProvider.d.ts +0 -8
  52. package/context/CartesianContextProvider.js +4 -89
  53. package/context/DrawingProvider.d.ts +2 -11
  54. package/context/DrawingProvider.js +10 -35
  55. package/context/HighlightProvider.js +3 -0
  56. package/context/InteractionProvider.js +3 -0
  57. package/context/SeriesContextProvider.js +3 -0
  58. package/context/index.d.ts +0 -2
  59. package/context/index.js +1 -15
  60. package/esm/BarChart/BarChart.js +27 -7
  61. package/esm/ChartsGrid/ChartsGrid.js +121 -0
  62. package/esm/ChartsGrid/chartsGridClasses.js +6 -0
  63. package/esm/ChartsGrid/index.js +2 -0
  64. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  65. package/esm/ChartsSurface.js +6 -4
  66. package/esm/ChartsTooltip/utils.js +2 -2
  67. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -3
  68. package/esm/ChartsXAxis/ChartsXAxis.js +2 -2
  69. package/esm/ChartsYAxis/ChartsYAxis.js +2 -2
  70. package/esm/Gauge/Gauge.js +147 -0
  71. package/esm/Gauge/GaugeContainer.js +209 -0
  72. package/esm/Gauge/GaugeProvider.js +88 -0
  73. package/esm/Gauge/GaugeReferenceArc.js +35 -0
  74. package/esm/Gauge/GaugeValueArc.js +42 -0
  75. package/esm/Gauge/GaugeValueText.js +69 -0
  76. package/esm/Gauge/gaugeClasses.js +7 -0
  77. package/esm/Gauge/index.js +7 -0
  78. package/esm/Gauge/utils.js +68 -0
  79. package/esm/LineChart/LineChart.js +31 -7
  80. package/esm/PieChart/PieArc.js +9 -9
  81. package/esm/PieChart/PieArcLabelPlot.js +13 -13
  82. package/esm/PieChart/PieChart.js +22 -2
  83. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -68
  84. package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
  85. package/esm/ScatterChart/ScatterChart.js +25 -3
  86. package/esm/SparkLineChart/SparkLineChart.js +0 -2
  87. package/esm/context/CartesianContextProvider.js +3 -88
  88. package/esm/context/DrawingProvider.js +10 -36
  89. package/esm/context/HighlightProvider.js +3 -0
  90. package/esm/context/InteractionProvider.js +3 -0
  91. package/esm/context/SeriesContextProvider.js +3 -0
  92. package/esm/context/index.js +1 -2
  93. package/esm/hooks/useAxisEvents.js +2 -2
  94. package/esm/hooks/useTicks.js +2 -3
  95. package/esm/index.js +2 -0
  96. package/hooks/useAxisEvents.js +1 -1
  97. package/hooks/useTicks.d.ts +2 -3
  98. package/hooks/useTicks.js +2 -3
  99. package/index.d.ts +2 -0
  100. package/index.js +23 -1
  101. package/modern/BarChart/BarChart.js +27 -7
  102. package/modern/ChartsGrid/ChartsGrid.js +121 -0
  103. package/modern/ChartsGrid/chartsGridClasses.js +6 -0
  104. package/modern/ChartsGrid/index.js +2 -0
  105. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  106. package/modern/ChartsSurface.js +6 -4
  107. package/modern/ChartsTooltip/utils.js +2 -2
  108. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -3
  109. package/modern/ChartsXAxis/ChartsXAxis.js +2 -2
  110. package/modern/ChartsYAxis/ChartsYAxis.js +2 -2
  111. package/modern/Gauge/Gauge.js +147 -0
  112. package/modern/Gauge/GaugeContainer.js +206 -0
  113. package/modern/Gauge/GaugeProvider.js +88 -0
  114. package/modern/Gauge/GaugeReferenceArc.js +35 -0
  115. package/modern/Gauge/GaugeValueArc.js +42 -0
  116. package/modern/Gauge/GaugeValueText.js +69 -0
  117. package/modern/Gauge/gaugeClasses.js +7 -0
  118. package/modern/Gauge/index.js +7 -0
  119. package/modern/Gauge/utils.js +68 -0
  120. package/modern/LineChart/LineChart.js +31 -7
  121. package/modern/PieChart/PieArc.js +9 -9
  122. package/modern/PieChart/PieArcLabelPlot.js +13 -13
  123. package/modern/PieChart/PieChart.js +22 -2
  124. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -68
  125. package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
  126. package/modern/ScatterChart/ScatterChart.js +25 -3
  127. package/modern/SparkLineChart/SparkLineChart.js +0 -2
  128. package/modern/context/CartesianContextProvider.js +3 -88
  129. package/modern/context/DrawingProvider.js +10 -36
  130. package/modern/context/HighlightProvider.js +3 -0
  131. package/modern/context/InteractionProvider.js +3 -0
  132. package/modern/context/SeriesContextProvider.js +3 -0
  133. package/modern/context/index.js +1 -2
  134. package/modern/hooks/useAxisEvents.js +2 -2
  135. package/modern/hooks/useTicks.js +2 -3
  136. package/modern/index.js +3 -1
  137. package/package.json +4 -4
  138. package/legacy/BarChart/BarChart.js +0 -418
  139. package/legacy/BarChart/BarElement.js +0 -119
  140. package/legacy/BarChart/BarPlot.js +0 -232
  141. package/legacy/BarChart/extremums.js +0 -45
  142. package/legacy/BarChart/formatter.js +0 -78
  143. package/legacy/BarChart/index.js +0 -3
  144. package/legacy/BarChart/legend.js +0 -15
  145. package/legacy/ChartContainer/ChartContainer.js +0 -189
  146. package/legacy/ChartContainer/index.js +0 -1
  147. package/legacy/ChartsAxis/ChartsAxis.js +0 -215
  148. package/legacy/ChartsAxis/axisClasses.js +0 -5
  149. package/legacy/ChartsAxis/index.js +0 -2
  150. package/legacy/ChartsAxisHighlight/ChartsAxisHighlight.js +0 -105
  151. package/legacy/ChartsAxisHighlight/index.js +0 -1
  152. package/legacy/ChartsClipPath/ChartsClipPath.js +0 -48
  153. package/legacy/ChartsClipPath/index.js +0 -1
  154. package/legacy/ChartsLegend/ChartsLegend.js +0 -100
  155. package/legacy/ChartsLegend/DefaultChartsLegend.js +0 -302
  156. package/legacy/ChartsLegend/chartsLegendClasses.js +0 -5
  157. package/legacy/ChartsLegend/index.js +0 -4
  158. package/legacy/ChartsLegend/utils.js +0 -15
  159. package/legacy/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +0 -75
  160. package/legacy/ChartsOnAxisClickHandler/index.js +0 -1
  161. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +0 -72
  162. package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +0 -105
  163. package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +0 -105
  164. package/legacy/ChartsReferenceLine/chartsReferenceLineClasses.js +0 -6
  165. package/legacy/ChartsReferenceLine/common.js +0 -19
  166. package/legacy/ChartsReferenceLine/index.js +0 -2
  167. package/legacy/ChartsSurface.js +0 -76
  168. package/legacy/ChartsText/ChartsText.js +0 -95
  169. package/legacy/ChartsText/index.js +0 -1
  170. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +0 -96
  171. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +0 -53
  172. package/legacy/ChartsTooltip/ChartsTooltip.js +0 -148
  173. package/legacy/ChartsTooltip/ChartsTooltipTable.js +0 -80
  174. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -118
  175. package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -78
  176. package/legacy/ChartsTooltip/chartsTooltipClasses.js +0 -5
  177. package/legacy/ChartsTooltip/index.js +0 -6
  178. package/legacy/ChartsTooltip/utils.js +0 -103
  179. package/legacy/ChartsVoronoiHandler/ChartsVoronoiHandler.js +0 -206
  180. package/legacy/ChartsVoronoiHandler/index.js +0 -1
  181. package/legacy/ChartsXAxis/ChartsXAxis.js +0 -339
  182. package/legacy/ChartsXAxis/index.js +0 -1
  183. package/legacy/ChartsYAxis/ChartsYAxis.js +0 -267
  184. package/legacy/ChartsYAxis/index.js +0 -1
  185. package/legacy/LineChart/AnimatedArea.js +0 -102
  186. package/legacy/LineChart/AnimatedLine.js +0 -104
  187. package/legacy/LineChart/AreaElement.js +0 -112
  188. package/legacy/LineChart/AreaPlot.js +0 -149
  189. package/legacy/LineChart/LineChart.js +0 -426
  190. package/legacy/LineChart/LineElement.js +0 -112
  191. package/legacy/LineChart/LineHighlightElement.js +0 -79
  192. package/legacy/LineChart/LineHighlightPlot.js +0 -97
  193. package/legacy/LineChart/LinePlot.js +0 -144
  194. package/legacy/LineChart/MarkElement.js +0 -153
  195. package/legacy/LineChart/MarkPlot.js +0 -178
  196. package/legacy/LineChart/extremums.js +0 -54
  197. package/legacy/LineChart/formatter.js +0 -82
  198. package/legacy/LineChart/index.js +0 -11
  199. package/legacy/LineChart/legend.js +0 -15
  200. package/legacy/PieChart/PieArc.js +0 -103
  201. package/legacy/PieChart/PieArcLabel.js +0 -112
  202. package/legacy/PieChart/PieArcLabelPlot.js +0 -193
  203. package/legacy/PieChart/PieArcPlot.js +0 -180
  204. package/legacy/PieChart/PieChart.js +0 -382
  205. package/legacy/PieChart/PiePlot.js +0 -137
  206. package/legacy/PieChart/dataTransform/transition.js +0 -149
  207. package/legacy/PieChart/dataTransform/useTransformData.js +0 -63
  208. package/legacy/PieChart/formatter.js +0 -55
  209. package/legacy/PieChart/index.js +0 -6
  210. package/legacy/PieChart/legend.js +0 -16
  211. package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -255
  212. package/legacy/ResponsiveChartContainer/index.js +0 -1
  213. package/legacy/ScatterChart/Scatter.js +0 -110
  214. package/legacy/ScatterChart/ScatterChart.js +0 -370
  215. package/legacy/ScatterChart/ScatterPlot.js +0 -80
  216. package/legacy/ScatterChart/extremums.js +0 -39
  217. package/legacy/ScatterChart/formatter.js +0 -12
  218. package/legacy/ScatterChart/index.js +0 -3
  219. package/legacy/ScatterChart/legend.js +0 -15
  220. package/legacy/SparkLineChart/SparkLineChart.js +0 -266
  221. package/legacy/SparkLineChart/index.js +0 -1
  222. package/legacy/colorPalettes/colorPalettes.js +0 -15
  223. package/legacy/colorPalettes/index.js +0 -1
  224. package/legacy/constants.js +0 -8
  225. package/legacy/context/CartesianContextProvider.js +0 -327
  226. package/legacy/context/DrawingProvider.js +0 -74
  227. package/legacy/context/HighlightProvider.js +0 -56
  228. package/legacy/context/InteractionProvider.js +0 -81
  229. package/legacy/context/SeriesContextProvider.js +0 -74
  230. package/legacy/context/index.js +0 -2
  231. package/legacy/hooks/index.js +0 -2
  232. package/legacy/hooks/useAxisEvents.js +0 -120
  233. package/legacy/hooks/useChartDimensions.js +0 -18
  234. package/legacy/hooks/useDrawingArea.js +0 -21
  235. package/legacy/hooks/useInteractionItemProps.js +0 -71
  236. package/legacy/hooks/useMounted.js +0 -21
  237. package/legacy/hooks/useReducedMotion.js +0 -27
  238. package/legacy/hooks/useScale.js +0 -33
  239. package/legacy/hooks/useTicks.js +0 -66
  240. package/legacy/index.js +0 -31
  241. package/legacy/internals/components/AxisSharedComponents.js +0 -25
  242. package/legacy/internals/defaultizeColor.js +0 -17
  243. package/legacy/internals/defaultizeValueFormatter.js +0 -12
  244. package/legacy/internals/domUtils.js +0 -121
  245. package/legacy/internals/geometry.js +0 -37
  246. package/legacy/internals/getCurve.js +0 -39
  247. package/legacy/internals/getScale.js +0 -17
  248. package/legacy/internals/getWordsByLines.js +0 -15
  249. package/legacy/internals/isBandScale.js +0 -3
  250. package/legacy/internals/stackSeries.js +0 -92
  251. package/legacy/internals/useAnimatedPath.js +0 -32
  252. package/legacy/internals/utils.js +0 -52
  253. package/legacy/models/axis.js +0 -6
  254. package/legacy/models/helpers.js +0 -1
  255. package/legacy/models/index.js +0 -4
  256. package/legacy/models/layout.js +0 -1
  257. package/legacy/models/seriesType/bar.js +0 -1
  258. package/legacy/models/seriesType/common.js +0 -1
  259. package/legacy/models/seriesType/config.js +0 -1
  260. package/legacy/models/seriesType/index.js +0 -5
  261. package/legacy/models/seriesType/line.js +0 -1
  262. package/legacy/models/seriesType/pie.js +0 -1
  263. package/legacy/models/seriesType/scatter.js +0 -1
  264. package/legacy/models/stacking.js +0 -1
  265. 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';