@mui/x-charts 6.0.0-alpha.9 → 6.18.1

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 (325) hide show
  1. package/BarChart/BarChart.d.ts +26 -5
  2. package/BarChart/BarChart.js +93 -17
  3. package/BarChart/BarElement.d.ts +1319 -4
  4. package/BarChart/BarElement.js +10 -10
  5. package/BarChart/BarPlot.d.ts +17 -1
  6. package/BarChart/BarPlot.js +152 -66
  7. package/BarChart/formatter.js +2 -3
  8. package/BarChart/legend.js +1 -2
  9. package/CHANGELOG.md +797 -59
  10. package/ChartContainer/index.js +7 -5
  11. package/ChartsAxis/ChartsAxis.d.ts +9 -0
  12. package/ChartsAxis/ChartsAxis.js +33 -7
  13. package/ChartsAxis/axisClasses.d.ts +3 -3
  14. package/ChartsAxis/axisClasses.js +1 -2
  15. package/ChartsAxisHighlight/ChartsAxisHighlight.d.ts +21 -0
  16. package/ChartsAxisHighlight/ChartsAxisHighlight.js +61 -22
  17. package/ChartsClipPath/ChartsClipPath.d.ts +5 -0
  18. package/ChartsClipPath/ChartsClipPath.js +7 -2
  19. package/ChartsLegend/ChartsLegend.d.ts +45 -24
  20. package/ChartsLegend/ChartsLegend.js +193 -151
  21. package/ChartsLegend/chartsLegendClasses.d.ts +1 -1
  22. package/ChartsLegend/chartsLegendClasses.js +3 -4
  23. package/ChartsLegend/utils.d.ts +1 -6
  24. package/ChartsReferenceLine/ChartsReferenceLine.d.ts +10 -0
  25. package/ChartsReferenceLine/ChartsReferenceLine.js +78 -0
  26. package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +13 -0
  27. package/ChartsReferenceLine/ChartsXReferenceLine.js +112 -0
  28. package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +13 -0
  29. package/ChartsReferenceLine/ChartsYReferenceLine.js +112 -0
  30. package/ChartsReferenceLine/chartsReferenceLineClasses.d.ts +15 -0
  31. package/ChartsReferenceLine/chartsReferenceLineClasses.js +14 -0
  32. package/ChartsReferenceLine/common.d.ts +41 -0
  33. package/ChartsReferenceLine/common.js +27 -0
  34. package/ChartsReferenceLine/index.d.ts +2 -0
  35. package/ChartsReferenceLine/index.js +27 -0
  36. package/ChartsReferenceLine/package.json +6 -0
  37. package/ChartsSurface.d.ts +12 -1
  38. package/ChartsSurface.js +9 -18
  39. package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +1 -0
  40. package/ChartsTooltip/ChartsAxisTooltipContent.js +46 -32
  41. package/ChartsTooltip/ChartsItemTooltipContent.d.ts +3 -2
  42. package/ChartsTooltip/ChartsItemTooltipContent.js +18 -9
  43. package/ChartsTooltip/ChartsTooltip.d.ts +32 -0
  44. package/ChartsTooltip/ChartsTooltip.js +62 -18
  45. package/ChartsTooltip/ChartsTooltipTable.d.ts +3 -10
  46. package/ChartsTooltip/ChartsTooltipTable.js +22 -20
  47. package/ChartsTooltip/tooltipClasses.js +1 -2
  48. package/ChartsTooltip/utils.js +2 -2
  49. package/ChartsXAxis/ChartsXAxis.d.ts +9 -0
  50. package/ChartsXAxis/ChartsXAxis.js +170 -45
  51. package/ChartsYAxis/ChartsYAxis.d.ts +9 -0
  52. package/ChartsYAxis/ChartsYAxis.js +95 -38
  53. package/LineChart/AreaElement.d.ts +11 -1
  54. package/LineChart/AreaElement.js +14 -6
  55. package/LineChart/AreaPlot.d.ts +11 -0
  56. package/LineChart/AreaPlot.js +27 -8
  57. package/LineChart/LineChart.d.ts +23 -3
  58. package/LineChart/LineChart.js +89 -17
  59. package/LineChart/LineElement.d.ts +11 -1
  60. package/LineChart/LineElement.js +14 -6
  61. package/LineChart/LineHighlightElement.d.ts +10 -0
  62. package/LineChart/LineHighlightElement.js +13 -4
  63. package/LineChart/LineHighlightPlot.d.ts +10 -0
  64. package/LineChart/LineHighlightPlot.js +15 -4
  65. package/LineChart/LinePlot.d.ts +10 -0
  66. package/LineChart/LinePlot.js +25 -12
  67. package/LineChart/MarkElement.d.ts +10 -0
  68. package/LineChart/MarkElement.js +14 -5
  69. package/LineChart/MarkPlot.d.ts +10 -0
  70. package/LineChart/MarkPlot.js +42 -10
  71. package/LineChart/formatter.js +5 -5
  72. package/LineChart/legend.js +1 -2
  73. package/PieChart/PieArc.d.ts +11 -13
  74. package/PieChart/PieArc.js +28 -60
  75. package/PieChart/PieArcLabel.d.ts +8 -9
  76. package/PieChart/PieArcLabel.js +46 -38
  77. package/PieChart/PieArcLabelPlot.d.ts +28 -0
  78. package/PieChart/PieArcLabelPlot.js +99 -0
  79. package/PieChart/PieArcPlot.d.ts +35 -0
  80. package/PieChart/PieArcPlot.js +92 -0
  81. package/PieChart/PieChart.d.ts +19 -5
  82. package/PieChart/PieChart.js +95 -18
  83. package/PieChart/PiePlot.d.ts +15 -9
  84. package/PieChart/PiePlot.js +77 -55
  85. package/PieChart/dataTransform/transition.d.ts +4 -0
  86. package/PieChart/dataTransform/transition.js +136 -0
  87. package/PieChart/dataTransform/useTransformData.d.ts +15 -0
  88. package/PieChart/dataTransform/useTransformData.js +67 -0
  89. package/PieChart/formatter.js +1 -2
  90. package/PieChart/legend.js +1 -2
  91. package/README.md +8 -14
  92. package/ResponsiveChartContainer/index.d.ts +13 -3
  93. package/ResponsiveChartContainer/index.js +7 -8
  94. package/ScatterChart/Scatter.d.ts +10 -0
  95. package/ScatterChart/Scatter.js +12 -2
  96. package/ScatterChart/ScatterChart.d.ts +16 -3
  97. package/ScatterChart/ScatterChart.js +77 -16
  98. package/ScatterChart/ScatterPlot.d.ts +10 -0
  99. package/ScatterChart/ScatterPlot.js +12 -2
  100. package/ScatterChart/formatter.js +1 -2
  101. package/ScatterChart/legend.js +1 -2
  102. package/SparkLineChart/SparkLineChart.d.ts +12 -3
  103. package/SparkLineChart/SparkLineChart.js +50 -7
  104. package/colorPalettes/colorPalettes.js +6 -12
  105. package/constants.js +5 -8
  106. package/context/CartesianContextProvider.d.ts +26 -1
  107. package/context/CartesianContextProvider.js +42 -16
  108. package/context/DrawingProvider.d.ts +25 -0
  109. package/context/DrawingProvider.js +18 -6
  110. package/context/HighlightProvider.d.ts +17 -0
  111. package/context/HighlightProvider.js +3 -4
  112. package/context/InteractionProvider.d.ts +6 -0
  113. package/context/InteractionProvider.js +3 -4
  114. package/context/SeriesContextProvider.d.ts +5 -0
  115. package/context/SeriesContextProvider.js +3 -4
  116. package/esm/BarChart/BarChart.js +90 -13
  117. package/esm/BarChart/BarElement.js +7 -4
  118. package/esm/BarChart/BarPlot.js +152 -67
  119. package/esm/BarChart/formatter.js +1 -1
  120. package/esm/ChartContainer/index.js +3 -0
  121. package/esm/ChartsAxis/ChartsAxis.js +32 -5
  122. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +57 -20
  123. package/esm/ChartsClipPath/ChartsClipPath.js +5 -0
  124. package/esm/ChartsLegend/ChartsLegend.js +190 -144
  125. package/esm/ChartsLegend/chartsLegendClasses.js +1 -1
  126. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
  127. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +105 -0
  128. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +105 -0
  129. package/esm/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
  130. package/esm/ChartsReferenceLine/common.js +20 -0
  131. package/esm/ChartsReferenceLine/index.js +2 -0
  132. package/esm/ChartsSurface.js +4 -12
  133. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +44 -30
  134. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +15 -7
  135. package/esm/ChartsTooltip/ChartsTooltip.js +59 -14
  136. package/esm/ChartsTooltip/ChartsTooltipTable.js +17 -10
  137. package/esm/ChartsXAxis/ChartsXAxis.js +168 -43
  138. package/esm/ChartsYAxis/ChartsYAxis.js +93 -36
  139. package/esm/LineChart/AreaElement.js +10 -0
  140. package/esm/LineChart/AreaPlot.js +26 -6
  141. package/esm/LineChart/LineChart.js +86 -13
  142. package/esm/LineChart/LineElement.js +10 -0
  143. package/esm/LineChart/LineHighlightElement.js +10 -0
  144. package/esm/LineChart/LineHighlightPlot.js +13 -2
  145. package/esm/LineChart/LinePlot.js +25 -14
  146. package/esm/LineChart/MarkElement.js +11 -1
  147. package/esm/LineChart/MarkPlot.js +40 -8
  148. package/esm/LineChart/formatter.js +7 -3
  149. package/esm/PieChart/PieArc.js +26 -58
  150. package/esm/PieChart/PieArcLabel.js +43 -34
  151. package/esm/PieChart/PieArcLabelPlot.js +92 -0
  152. package/esm/PieChart/PieArcPlot.js +84 -0
  153. package/esm/PieChart/PieChart.js +93 -16
  154. package/esm/PieChart/PiePlot.js +76 -57
  155. package/esm/PieChart/dataTransform/transition.js +130 -0
  156. package/esm/PieChart/dataTransform/useTransformData.js +59 -0
  157. package/esm/ResponsiveChartContainer/index.js +3 -3
  158. package/esm/ScatterChart/Scatter.js +10 -0
  159. package/esm/ScatterChart/ScatterChart.js +74 -12
  160. package/esm/ScatterChart/ScatterPlot.js +10 -0
  161. package/esm/SparkLineChart/SparkLineChart.js +47 -3
  162. package/esm/constants.js +1 -1
  163. package/esm/context/CartesianContextProvider.js +41 -14
  164. package/esm/context/DrawingProvider.js +14 -0
  165. package/esm/hooks/useChartDimensions.js +2 -0
  166. package/esm/hooks/useMounted.js +16 -0
  167. package/esm/hooks/useReducedMotion.js +27 -0
  168. package/esm/hooks/useTicks.js +15 -9
  169. package/esm/index.js +1 -0
  170. package/esm/internals/components/AxisSharedComponents.js +15 -70
  171. package/esm/internals/components/ChartsText.js +77 -0
  172. package/esm/internals/domUtils.js +113 -0
  173. package/esm/internals/geometry.js +36 -0
  174. package/hooks/useAxisEvents.js +2 -2
  175. package/hooks/useChartDimensions.d.ts +2 -0
  176. package/hooks/useChartDimensions.js +5 -4
  177. package/hooks/useDrawingArea.js +2 -2
  178. package/hooks/useInteractionItemProps.js +2 -2
  179. package/hooks/useMounted.d.ts +1 -0
  180. package/hooks/useMounted.js +25 -0
  181. package/hooks/useReducedMotion.d.ts +8 -0
  182. package/hooks/useReducedMotion.js +33 -0
  183. package/hooks/useScale.d.ts +2 -2
  184. package/hooks/useScale.js +2 -2
  185. package/hooks/useTicks.d.ts +19 -11
  186. package/hooks/useTicks.js +19 -14
  187. package/index.d.ts +1 -0
  188. package/index.js +12 -1
  189. package/internals/components/AxisSharedComponents.d.ts +0 -4
  190. package/internals/components/AxisSharedComponents.js +18 -78
  191. package/internals/components/ChartsText.d.ts +35 -0
  192. package/internals/components/ChartsText.js +87 -0
  193. package/internals/defaultizeColor.d.ts +7 -2
  194. package/internals/defaultizeValueFormatter.js +1 -2
  195. package/internals/domUtils.d.ts +13 -0
  196. package/internals/domUtils.js +122 -0
  197. package/internals/geometry.d.ts +9 -0
  198. package/internals/geometry.js +42 -0
  199. package/internals/isBandScale.d.ts +3 -1
  200. package/internals/stackSeries.js +2 -4
  201. package/internals/utils.d.ts +5 -0
  202. package/legacy/BarChart/BarChart.js +90 -13
  203. package/legacy/BarChart/BarElement.js +6 -3
  204. package/legacy/BarChart/BarPlot.js +151 -63
  205. package/legacy/BarChart/formatter.js +1 -1
  206. package/legacy/ChartContainer/index.js +3 -0
  207. package/legacy/ChartsAxis/ChartsAxis.js +32 -5
  208. package/legacy/ChartsAxisHighlight/ChartsAxisHighlight.js +60 -20
  209. package/legacy/ChartsClipPath/ChartsClipPath.js +5 -0
  210. package/legacy/ChartsLegend/ChartsLegend.js +205 -142
  211. package/legacy/ChartsLegend/chartsLegendClasses.js +1 -1
  212. package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
  213. package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +105 -0
  214. package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +105 -0
  215. package/legacy/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
  216. package/legacy/ChartsReferenceLine/common.js +20 -0
  217. package/legacy/ChartsReferenceLine/index.js +2 -0
  218. package/legacy/ChartsSurface.js +3 -12
  219. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +22 -10
  220. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +15 -7
  221. package/legacy/ChartsTooltip/ChartsTooltip.js +62 -14
  222. package/legacy/ChartsTooltip/ChartsTooltipTable.js +34 -26
  223. package/legacy/ChartsXAxis/ChartsXAxis.js +176 -50
  224. package/legacy/ChartsYAxis/ChartsYAxis.js +97 -41
  225. package/legacy/LineChart/AreaElement.js +10 -0
  226. package/legacy/LineChart/AreaPlot.js +31 -7
  227. package/legacy/LineChart/LineChart.js +86 -13
  228. package/legacy/LineChart/LineElement.js +10 -0
  229. package/legacy/LineChart/LineHighlightElement.js +10 -0
  230. package/legacy/LineChart/LineHighlightPlot.js +13 -2
  231. package/legacy/LineChart/LinePlot.js +29 -12
  232. package/legacy/LineChart/MarkElement.js +11 -1
  233. package/legacy/LineChart/MarkPlot.js +39 -8
  234. package/legacy/LineChart/formatter.js +7 -3
  235. package/legacy/PieChart/PieArc.js +30 -62
  236. package/legacy/PieChart/PieArcLabel.js +48 -34
  237. package/legacy/PieChart/PieArcLabelPlot.js +93 -0
  238. package/legacy/PieChart/PieArcPlot.js +84 -0
  239. package/legacy/PieChart/PieChart.js +93 -16
  240. package/legacy/PieChart/PiePlot.js +76 -59
  241. package/legacy/PieChart/dataTransform/transition.js +142 -0
  242. package/legacy/PieChart/dataTransform/useTransformData.js +60 -0
  243. package/legacy/ResponsiveChartContainer/index.js +3 -3
  244. package/legacy/ScatterChart/Scatter.js +10 -0
  245. package/legacy/ScatterChart/ScatterChart.js +74 -12
  246. package/legacy/ScatterChart/ScatterPlot.js +10 -0
  247. package/legacy/SparkLineChart/SparkLineChart.js +47 -3
  248. package/legacy/constants.js +1 -1
  249. package/legacy/context/CartesianContextProvider.js +41 -14
  250. package/legacy/context/DrawingProvider.js +14 -0
  251. package/legacy/hooks/useChartDimensions.js +2 -0
  252. package/legacy/hooks/useMounted.js +21 -0
  253. package/legacy/hooks/useReducedMotion.js +27 -0
  254. package/legacy/hooks/useTicks.js +16 -9
  255. package/legacy/index.js +2 -1
  256. package/legacy/internals/components/AxisSharedComponents.js +11 -65
  257. package/legacy/internals/components/ChartsText.js +79 -0
  258. package/legacy/internals/domUtils.js +121 -0
  259. package/legacy/internals/geometry.js +37 -0
  260. package/models/axis.d.ts +58 -20
  261. package/models/layout.d.ts +13 -6
  262. package/models/seriesType/common.d.ts +16 -0
  263. package/models/seriesType/line.d.ts +8 -3
  264. package/models/seriesType/pie.d.ts +5 -1
  265. package/modern/BarChart/BarChart.js +90 -13
  266. package/modern/BarChart/BarElement.js +7 -4
  267. package/modern/BarChart/BarPlot.js +149 -65
  268. package/modern/BarChart/formatter.js +1 -1
  269. package/modern/ChartContainer/index.js +3 -0
  270. package/modern/ChartsAxis/ChartsAxis.js +31 -5
  271. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +57 -20
  272. package/modern/ChartsClipPath/ChartsClipPath.js +5 -0
  273. package/modern/ChartsLegend/ChartsLegend.js +190 -144
  274. package/modern/ChartsLegend/chartsLegendClasses.js +1 -1
  275. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
  276. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +104 -0
  277. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +104 -0
  278. package/modern/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
  279. package/modern/ChartsReferenceLine/common.js +20 -0
  280. package/modern/ChartsReferenceLine/index.js +2 -0
  281. package/modern/ChartsSurface.js +4 -12
  282. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +44 -30
  283. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +15 -7
  284. package/modern/ChartsTooltip/ChartsTooltip.js +58 -14
  285. package/modern/ChartsTooltip/ChartsTooltipTable.js +17 -10
  286. package/modern/ChartsXAxis/ChartsXAxis.js +167 -42
  287. package/modern/ChartsYAxis/ChartsYAxis.js +92 -35
  288. package/modern/LineChart/AreaElement.js +10 -0
  289. package/modern/LineChart/AreaPlot.js +25 -6
  290. package/modern/LineChart/LineChart.js +86 -13
  291. package/modern/LineChart/LineElement.js +10 -0
  292. package/modern/LineChart/LineHighlightElement.js +10 -0
  293. package/modern/LineChart/LineHighlightPlot.js +13 -2
  294. package/modern/LineChart/LinePlot.js +23 -10
  295. package/modern/LineChart/MarkElement.js +11 -1
  296. package/modern/LineChart/MarkPlot.js +40 -8
  297. package/modern/LineChart/formatter.js +4 -3
  298. package/modern/PieChart/PieArc.js +26 -57
  299. package/modern/PieChart/PieArcLabel.js +43 -34
  300. package/modern/PieChart/PieArcLabelPlot.js +90 -0
  301. package/modern/PieChart/PieArcPlot.js +83 -0
  302. package/modern/PieChart/PieChart.js +93 -16
  303. package/modern/PieChart/PiePlot.js +76 -55
  304. package/modern/PieChart/dataTransform/transition.js +130 -0
  305. package/modern/PieChart/dataTransform/useTransformData.js +58 -0
  306. package/modern/ResponsiveChartContainer/index.js +3 -3
  307. package/modern/ScatterChart/Scatter.js +10 -0
  308. package/modern/ScatterChart/ScatterChart.js +74 -12
  309. package/modern/ScatterChart/ScatterPlot.js +10 -0
  310. package/modern/SparkLineChart/SparkLineChart.js +47 -3
  311. package/modern/constants.js +1 -1
  312. package/modern/context/CartesianContextProvider.js +40 -13
  313. package/modern/context/DrawingProvider.js +14 -0
  314. package/modern/hooks/useChartDimensions.js +2 -0
  315. package/modern/hooks/useMounted.js +16 -0
  316. package/modern/hooks/useReducedMotion.js +27 -0
  317. package/modern/hooks/useTicks.js +15 -9
  318. package/modern/index.js +2 -1
  319. package/modern/internals/components/AxisSharedComponents.js +15 -70
  320. package/modern/internals/components/ChartsText.js +77 -0
  321. package/modern/internals/domUtils.js +113 -0
  322. package/modern/internals/geometry.js +36 -0
  323. package/package.json +9 -6
  324. package/themeAugmentation/components.d.ts +1 -0
  325. package/themeAugmentation/overrides.d.ts +2 -0
@@ -0,0 +1,27 @@
1
+ import { useIsomorphicLayoutEffect, Globals } from '@react-spring/web';
2
+
3
+ /**
4
+ * Returns `boolean` or `null`, used to automatically
5
+ * set skipAnimations to the value of the user's
6
+ * `prefers-reduced-motion` query.
7
+ *
8
+ * The return value, post-effect, is the value of their prefered setting
9
+ */
10
+ export var useReducedMotion = function useReducedMotion() {
11
+ // Taken from: https://github.com/pmndrs/react-spring/blob/02ec877bbfab0df46da0e4a47d5f68d3e731206a/packages/shared/src/hooks/useReducedMotion.ts#L13
12
+
13
+ useIsomorphicLayoutEffect(function () {
14
+ var mql = window.matchMedia('(prefers-reduced-motion)');
15
+ var handleMediaChange = function handleMediaChange(e) {
16
+ Globals.assign({
17
+ // Modification such the react-spring implementation such that this hook can remove animation but never activate animation.
18
+ skipAnimation: e.matches || undefined
19
+ });
20
+ };
21
+ handleMediaChange(mql);
22
+ mql.addEventListener('change', handleMediaChange);
23
+ return function () {
24
+ mql.removeEventListener('change', handleMediaChange);
25
+ };
26
+ }, []);
27
+ };
@@ -1,7 +1,8 @@
1
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
1
2
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
3
  import * as React from 'react';
3
4
  import { isBandScale } from '../internals/isBandScale';
4
- export function getTicksNumber(params) {
5
+ export function getTickNumber(params) {
5
6
  var tickMaxStep = params.tickMaxStep,
6
7
  tickMinStep = params.tickMinStep,
7
8
  tickNumber = params.tickNumber,
@@ -14,8 +15,9 @@ export function getTicksNumber(params) {
14
15
  }
15
16
  function useTicks(options) {
16
17
  var scale = options.scale,
17
- ticksNumber = options.ticksNumber,
18
- valueFormatter = options.valueFormatter;
18
+ tickNumber = options.tickNumber,
19
+ valueFormatter = options.valueFormatter,
20
+ tickInterval = options.tickInterval;
19
21
  return React.useMemo(function () {
20
22
  // band scale
21
23
  if (isBandScale(scale)) {
@@ -25,7 +27,8 @@ function useTicks(options) {
25
27
  return [].concat(_toConsumableArray(domain.map(function (value) {
26
28
  var _valueFormatter;
27
29
  return {
28
- formattedValue: (_valueFormatter = valueFormatter == null ? void 0 : valueFormatter(value)) != null ? _valueFormatter : value,
30
+ value: value,
31
+ formattedValue: (_valueFormatter = valueFormatter == null ? void 0 : valueFormatter(value)) != null ? _valueFormatter : "".concat(value),
29
32
  offset: scale(value) - (scale.step() - scale.bandwidth()) / 2,
30
33
  labelOffset: scale.step() / 2
31
34
  };
@@ -37,23 +40,27 @@ function useTicks(options) {
37
40
  }
38
41
 
39
42
  // scale type = 'point'
40
- return domain.map(function (value) {
43
+ var filteredDomain = typeof tickInterval === 'function' && domain.filter(tickInterval) || _typeof(tickInterval) === 'object' && tickInterval || domain;
44
+ return filteredDomain.map(function (value) {
41
45
  var _valueFormatter2;
42
46
  return {
43
- formattedValue: (_valueFormatter2 = valueFormatter == null ? void 0 : valueFormatter(value)) != null ? _valueFormatter2 : value,
47
+ value: value,
48
+ formattedValue: (_valueFormatter2 = valueFormatter == null ? void 0 : valueFormatter(value)) != null ? _valueFormatter2 : "".concat(value),
44
49
  offset: scale(value),
45
50
  labelOffset: 0
46
51
  };
47
52
  });
48
53
  }
49
- return scale.ticks(ticksNumber).map(function (value) {
54
+ var ticks = _typeof(tickInterval) === 'object' ? tickInterval : scale.ticks(tickNumber);
55
+ return ticks.map(function (value) {
50
56
  var _valueFormatter3;
51
57
  return {
52
- formattedValue: (_valueFormatter3 = valueFormatter == null ? void 0 : valueFormatter(value)) != null ? _valueFormatter3 : scale.tickFormat(ticksNumber)(value),
58
+ value: value,
59
+ formattedValue: (_valueFormatter3 = valueFormatter == null ? void 0 : valueFormatter(value)) != null ? _valueFormatter3 : scale.tickFormat(tickNumber)(value),
53
60
  offset: scale(value),
54
61
  labelOffset: 0
55
62
  };
56
63
  });
57
- }, [ticksNumber, scale, valueFormatter]);
64
+ }, [tickNumber, scale, valueFormatter, tickInterval]);
58
65
  }
59
66
  export default useTicks;
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v6.0.0-alpha.9
2
+ * @mui/x-charts v6.18.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -11,6 +11,7 @@ export * from './hooks';
11
11
  export * from './colorPalettes';
12
12
  export * from './models';
13
13
  export * from './ChartsClipPath';
14
+ export * from './ChartsReferenceLine';
14
15
  export * from './ChartsAxis';
15
16
  export * from './ChartsXAxis';
16
17
  export * from './ChartsYAxis';
@@ -1,6 +1,5 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
- var _$concat, _styled;
2
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
3
  import { styled } from '@mui/material/styles';
5
4
  import { axisClasses } from '../../ChartsAxis/axisClasses';
6
5
  export var AxisRoot = styled('g', {
@@ -9,72 +8,19 @@ export var AxisRoot = styled('g', {
9
8
  overridesResolver: function overridesResolver(props, styles) {
10
9
  return styles.root;
11
10
  }
12
- })((_styled = {}, _defineProperty(_styled, "&.".concat(axisClasses.directionY), (_$concat = {}, _defineProperty(_$concat, ".".concat(axisClasses.tickLabel), {
13
- dominantBaseline: 'middle'
14
- }), _defineProperty(_$concat, ".".concat(axisClasses.label), {
15
- dominantBaseline: 'auto',
16
- textAnchor: 'middle'
17
- }), _$concat)), _defineProperty(_styled, "&.".concat(axisClasses.left), _defineProperty({}, ".".concat(axisClasses.tickLabel), {
18
- dominantBaseline: 'central',
19
- textAnchor: 'end'
20
- })), _defineProperty(_styled, "&.".concat(axisClasses.right), _defineProperty({}, ".".concat(axisClasses.tickLabel), {
21
- dominantBaseline: 'central',
22
- textAnchor: 'start'
23
- })), _defineProperty(_styled, "&.".concat(axisClasses.bottom), _defineProperty({}, ".".concat(axisClasses.tickLabel, ", .").concat(axisClasses.label), {
24
- dominantBaseline: 'hanging',
25
- textAnchor: 'middle'
26
- })), _defineProperty(_styled, "&.".concat(axisClasses.top), _defineProperty({}, ".".concat(axisClasses.tickLabel, ", .").concat(axisClasses.label), {
27
- dominantBaseline: 'baseline',
28
- textAnchor: 'middle'
29
- })), _styled));
30
- export var ChartsLine = styled('line', {
31
- name: 'MuiChartsAxis',
32
- slot: 'Line',
33
- overridesResolver: function overridesResolver(props, styles) {
34
- return styles.line;
35
- }
36
11
  })(function (_ref) {
12
+ var _ref2;
37
13
  var theme = _ref.theme;
38
- return {
39
- stroke: theme.palette.text.primary,
14
+ return _ref2 = {}, _defineProperty(_ref2, "& .".concat(axisClasses.tickLabel), _extends({}, theme.typography.caption, {
15
+ fill: (theme.vars || theme).palette.text.primary
16
+ })), _defineProperty(_ref2, "& .".concat(axisClasses.label), _extends({}, theme.typography.body1, {
17
+ fill: (theme.vars || theme).palette.text.primary
18
+ })), _defineProperty(_ref2, "& .".concat(axisClasses.line), {
19
+ stroke: (theme.vars || theme).palette.text.primary,
40
20
  shapeRendering: 'crispEdges',
41
21
  strokeWidth: 1
42
- };
43
- });
44
- export var ChartsTick = styled('line', {
45
- name: 'MuiChartsAxis',
46
- slot: 'Tick',
47
- overridesResolver: function overridesResolver(props, styles) {
48
- return styles.tick;
49
- }
50
- })(function (_ref2) {
51
- var theme = _ref2.theme;
52
- return {
53
- stroke: theme.palette.text.primary,
22
+ }), _defineProperty(_ref2, "& .".concat(axisClasses.tick), {
23
+ stroke: (theme.vars || theme).palette.text.primary,
54
24
  shapeRendering: 'crispEdges'
55
- };
56
- });
57
- export var ChartsTickLabel = styled('text', {
58
- name: 'MuiChartsAxis',
59
- slot: 'TickLabel',
60
- overridesResolver: function overridesResolver(props, styles) {
61
- return styles.tickLabel;
62
- }
63
- })(function (_ref3) {
64
- var theme = _ref3.theme;
65
- return _extends({}, theme.typography.caption, {
66
- fill: theme.palette.text.primary
67
- });
68
- });
69
- export var ChartsLabel = styled('text', {
70
- name: 'MuiChartsAxis',
71
- slot: 'Label',
72
- overridesResolver: function overridesResolver(props, styles) {
73
- return styles.label;
74
- }
75
- })(function (_ref4) {
76
- var theme = _ref4.theme;
77
- return _extends({}, theme.typography.body1, {
78
- fill: theme.palette.text.primary
79
- });
25
+ }), _ref2;
80
26
  });
@@ -0,0 +1,79 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ import _extends from "@babel/runtime/helpers/esm/extends";
3
+ var _excluded = ["x", "y", "style", "text", "ownerState"],
4
+ _excluded2 = ["angle", "textAnchor", "dominantBaseline"];
5
+ import * as React from 'react';
6
+ import { getStringSize } from '../domUtils';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ export function getWordsByLines(_ref) {
9
+ var style = _ref.style,
10
+ needsComputation = _ref.needsComputation,
11
+ text = _ref.text;
12
+ return text.split('\n').map(function (subText) {
13
+ return _extends({
14
+ text: subText
15
+ }, needsComputation ? getStringSize(subText, style) : {
16
+ width: 0,
17
+ height: 0
18
+ });
19
+ });
20
+ }
21
+ export function ChartsText(props) {
22
+ var x = props.x,
23
+ y = props.y,
24
+ styleProps = props.style,
25
+ text = props.text,
26
+ ownerState = props.ownerState,
27
+ textProps = _objectWithoutProperties(props, _excluded);
28
+ var _ref2 = styleProps != null ? styleProps : {},
29
+ angle = _ref2.angle,
30
+ textAnchor = _ref2.textAnchor,
31
+ dominantBaseline = _ref2.dominantBaseline,
32
+ style = _objectWithoutProperties(_ref2, _excluded2);
33
+ var wordsByLines = React.useMemo(function () {
34
+ return getWordsByLines({
35
+ style: style,
36
+ needsComputation: text.includes('\n'),
37
+ text: text
38
+ });
39
+ }, [style, text]);
40
+ var startDy;
41
+ switch (dominantBaseline) {
42
+ case 'hanging':
43
+ startDy = 0;
44
+ break;
45
+ case 'central':
46
+ startDy = (wordsByLines.length - 1) / 2 * -wordsByLines[0].height;
47
+ break;
48
+ default:
49
+ startDy = (wordsByLines.length - 1) * -wordsByLines[0].height;
50
+ break;
51
+ }
52
+ var transforms = [];
53
+ // if (scaleToFit) {
54
+ // const lineWidth = wordsByLines[0].width;
55
+ // transforms.push(`scale(${(isNumber(width as number) ? (width as number) / lineWidth : 1) / lineWidth})`);
56
+ // }
57
+ if (angle) {
58
+ transforms.push("rotate(".concat(angle, ", ").concat(x, ", ").concat(y, ")"));
59
+ }
60
+ if (transforms.length) {
61
+ textProps.transform = transforms.join(' ');
62
+ }
63
+ return /*#__PURE__*/_jsx("text", _extends({}, textProps, {
64
+ x: x,
65
+ y: y,
66
+ textAnchor: textAnchor,
67
+ dominantBaseline: dominantBaseline,
68
+ style: style,
69
+ children: wordsByLines.map(function (line, index) {
70
+ return /*#__PURE__*/_jsx("tspan", {
71
+ x: x,
72
+ dy: "".concat(index === 0 ? startDy : wordsByLines[0].height, "px"),
73
+ dominantBaseline: dominantBaseline // Propagated to fix Safari issue: https://github.com/mui/mui-x/issues/10808
74
+ ,
75
+ children: line.text
76
+ }, index);
77
+ })
78
+ }));
79
+ }
@@ -0,0 +1,121 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
+ // DOM utils taken from
4
+ // https://github.com/recharts/recharts/blob/master/src/util/DOMUtils.ts
5
+
6
+ var isSsr = function isSsr() {
7
+ return !(typeof window !== 'undefined' && window.document && window.setTimeout);
8
+ };
9
+ var stringCache = {
10
+ widthCache: {},
11
+ cacheCount: 0
12
+ };
13
+ var MAX_CACHE_NUM = 2000;
14
+ var SPAN_STYLE = {
15
+ position: 'absolute',
16
+ top: '-20000px',
17
+ left: 0,
18
+ padding: 0,
19
+ margin: 0,
20
+ border: 'none',
21
+ whiteSpace: 'pre'
22
+ };
23
+ var STYLE_LIST = ['minWidth', 'maxWidth', 'width', 'minHeight', 'maxHeight', 'height', 'top', 'left', 'fontSize', 'padding', 'margin', 'paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom', 'marginLeft', 'marginRight', 'marginTop', 'marginBottom'];
24
+ var MEASUREMENT_SPAN_ID = 'mui_measurement_span';
25
+
26
+ /**
27
+ *
28
+ * @param name CSS property name
29
+ * @param value
30
+ * @returns add 'px' for distance properties
31
+ */
32
+ function autoCompleteStyle(name, value) {
33
+ if (STYLE_LIST.indexOf(name) >= 0 && value === +value) {
34
+ return "".concat(value, "px");
35
+ }
36
+ return value;
37
+ }
38
+
39
+ /**
40
+ *
41
+ * @param text camelcase css property
42
+ * @returns css property
43
+ */
44
+ function camelToMiddleLine(text) {
45
+ var strs = text.split('');
46
+ var formatStrs = strs.reduce(function (result, entry) {
47
+ if (entry === entry.toUpperCase()) {
48
+ return [].concat(_toConsumableArray(result), ['-', entry.toLowerCase()]);
49
+ }
50
+ return [].concat(_toConsumableArray(result), [entry]);
51
+ }, []);
52
+ return formatStrs.join('');
53
+ }
54
+
55
+ /**
56
+ *
57
+ * @param style React style object
58
+ * @returns CSS styling string
59
+ */
60
+ export var getStyleString = function getStyleString(style) {
61
+ return Object.keys(style).sort().reduce(function (result, s) {
62
+ return "".concat(result).concat(camelToMiddleLine(s), ":").concat(autoCompleteStyle(s, style[s]), ";");
63
+ }, '');
64
+ };
65
+
66
+ /**
67
+ *
68
+ * @param text The string to estimate
69
+ * @param style The style applied
70
+ * @returns width and height of the text
71
+ */
72
+ export var getStringSize = function getStringSize(text) {
73
+ var style = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
74
+ if (text === undefined || text === null || isSsr()) {
75
+ return {
76
+ width: 0,
77
+ height: 0
78
+ };
79
+ }
80
+ var str = "".concat(text);
81
+ var styleString = getStyleString(style);
82
+ var cacheKey = "".concat(str, "-").concat(styleString);
83
+ if (stringCache.widthCache[cacheKey]) {
84
+ return stringCache.widthCache[cacheKey];
85
+ }
86
+ try {
87
+ var measurementSpan = document.getElementById(MEASUREMENT_SPAN_ID);
88
+ if (measurementSpan === null) {
89
+ measurementSpan = document.createElement('span');
90
+ measurementSpan.setAttribute('id', MEASUREMENT_SPAN_ID);
91
+ measurementSpan.setAttribute('aria-hidden', 'true');
92
+ document.body.appendChild(measurementSpan);
93
+ }
94
+ // Need to use CSS Object Model (CSSOM) to be able to comply with Content Security Policy (CSP)
95
+ // https://en.wikipedia.org/wiki/Content_Security_Policy
96
+ var measurementSpanStyle = _extends({}, SPAN_STYLE, style);
97
+ Object.keys(measurementSpanStyle).map(function (styleKey) {
98
+ measurementSpan.style[camelToMiddleLine(styleKey)] = autoCompleteStyle(styleKey, measurementSpanStyle[styleKey]);
99
+ return styleKey;
100
+ });
101
+ measurementSpan.textContent = str;
102
+ var rect = measurementSpan.getBoundingClientRect();
103
+ var result = {
104
+ width: rect.width,
105
+ height: rect.height
106
+ };
107
+ stringCache.widthCache[cacheKey] = result;
108
+ if (stringCache.cacheCount + 1 > MAX_CACHE_NUM) {
109
+ stringCache.cacheCount = 0;
110
+ stringCache.widthCache = {};
111
+ } else {
112
+ stringCache.cacheCount += 1;
113
+ }
114
+ return result;
115
+ } catch (e) {
116
+ return {
117
+ width: 0,
118
+ height: 0
119
+ };
120
+ }
121
+ };
@@ -0,0 +1,37 @@
1
+ var ANGLE_APPROX = 5; // Angle (in deg) for which we approximate the rectangle as perfectly horizontal/vertical
2
+
3
+ var warnedOnce = false;
4
+
5
+ /**
6
+ * Return the minimal translation along the x-axis to avoid overflow of a rectangle of a given width, height, and rotation.
7
+ * This assumes that all rectangles have the same height and angle between -90 and 90.
8
+ * Otherwise it would be problematic because you need the height/width of the next rectangle to do the correct computation.
9
+ * @param width the side along the x-axis.
10
+ * @param height the side along the y-axis.
11
+ * @param angle the rotation in degrees.
12
+ */
13
+ export function getMinXTranslation(width, height) {
14
+ var angle = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
15
+ if (process.env.NODE_ENV !== 'production') {
16
+ if (!warnedOnce && angle > 90 && angle < -90) {
17
+ warnedOnce = true;
18
+ console.warn(["MUI X: It seems you applied an angle larger than 90\xB0 or smaller than -90\xB0 to an axis text.", "This could cause some text overlapping.", "If you encounter a use case where it's needed, please open an issue."].join('\n'));
19
+ }
20
+ }
21
+ var standardAngle = Math.min(Math.abs(angle) % 180, Math.abs(Math.abs(angle) % 180 - 180) % 180); // Map from R to [0, 90]
22
+
23
+ if (standardAngle < ANGLE_APPROX) {
24
+ // It's nearly horizontal
25
+ return width;
26
+ }
27
+ if (standardAngle > 90 - ANGLE_APPROX) {
28
+ // It's nearly vertical
29
+ return height;
30
+ }
31
+ var radAngle = standardAngle * Math.PI / 180;
32
+ var angleSwich = Math.atan2(height, width);
33
+ if (radAngle < angleSwich) {
34
+ return width / Math.cos(radAngle);
35
+ }
36
+ return height / Math.sin(radAngle);
37
+ }
package/models/axis.d.ts CHANGED
@@ -2,25 +2,29 @@
2
2
  import type { ScaleBand, ScaleLogarithmic, ScalePower, ScaleTime, ScaleLinear, ScalePoint } from 'd3-scale';
3
3
  import { ChartsAxisClasses } from '../ChartsAxis/axisClasses';
4
4
  import type { TickParams } from '../hooks/useTicks';
5
- export type D3Scale = ScaleBand<any> | ScaleLogarithmic<any, any> | ScalePoint<any> | ScalePower<any, any> | ScaleTime<any, any> | ScaleLinear<any, any>;
6
- export type D3ContinuouseScale = ScaleLogarithmic<any, any> | ScalePower<any, any> | ScaleTime<any, any> | ScaleLinear<any, any>;
5
+ import { ChartsTextProps } from '../internals/components/ChartsText';
6
+ export type D3Scale<Domain extends {
7
+ toString(): string;
8
+ } = number | Date | string, Range = number, Output = number> = ScaleBand<Domain> | ScaleLogarithmic<Range, Output> | ScalePoint<Domain> | ScalePower<Range, Output> | ScaleTime<Range, Output> | ScaleLinear<Range, Output>;
9
+ export type D3ContinuouseScale<Range = number, Output = number> = ScaleLogarithmic<Range, Output> | ScalePower<Range, Output> | ScaleTime<Range, Output> | ScaleLinear<Range, Output>;
7
10
  export interface ChartsAxisSlotsComponent {
8
11
  axisLine?: React.JSXElementConstructor<React.SVGAttributes<SVGPathElement>>;
9
12
  axisTick?: React.JSXElementConstructor<React.SVGAttributes<SVGPathElement>>;
10
- axisTickLabel?: React.JSXElementConstructor<React.SVGAttributes<SVGTextElement>>;
11
- axisLabel?: React.JSXElementConstructor<React.SVGAttributes<SVGTextElement>>;
13
+ axisTickLabel?: React.JSXElementConstructor<ChartsTextProps>;
14
+ axisLabel?: React.JSXElementConstructor<ChartsTextProps>;
12
15
  }
13
16
  export interface ChartsAxisSlotComponentProps {
14
17
  axisLine?: Partial<React.SVGAttributes<SVGPathElement>>;
15
18
  axisTick?: Partial<React.SVGAttributes<SVGPathElement>>;
16
- axisTickLabel?: Partial<React.SVGAttributes<SVGTextElement>>;
17
- axisLabel?: Partial<React.SVGAttributes<SVGTextElement>>;
19
+ axisTickLabel?: Partial<ChartsTextProps>;
20
+ axisLabel?: Partial<ChartsTextProps>;
18
21
  }
19
22
  export interface ChartsAxisProps extends TickParams {
20
23
  /**
21
- * Id of the axis to render.
24
+ * The id of the axis to render.
25
+ * If undefined, it will be the first defined axis.
22
26
  */
23
- axisId: string;
27
+ axisId?: string;
24
28
  /**
25
29
  * If true, the axis line is disabled.
26
30
  * @default false
@@ -39,8 +43,24 @@ export interface ChartsAxisProps extends TickParams {
39
43
  /**
40
44
  * The font size of the axis ticks text.
41
45
  * @default 12
46
+ * @deprecated Consider using `tickLabelStyle.fontSize` instead.
42
47
  */
43
48
  tickFontSize?: number;
49
+ /**
50
+ * The style applied to ticks text.
51
+ */
52
+ tickLabelStyle?: ChartsTextProps['style'];
53
+ /**
54
+ * The style applied to the axis label.
55
+ */
56
+ labelStyle?: ChartsTextProps['style'];
57
+ /**
58
+ * Defines which ticks get its label displayed. Its value can be:
59
+ * - 'auto' In such case, labels are displayed if they do not overlap with the previous one.
60
+ * - a filtering function of the form (value, index) => boolean. Warning: the index is tick index, not data ones.
61
+ * @default 'auto'
62
+ */
63
+ tickLabelInterval?: 'auto' | ((value: any, index: number) => boolean);
44
64
  /**
45
65
  * The label of the axis.
46
66
  */
@@ -48,6 +68,7 @@ export interface ChartsAxisProps extends TickParams {
48
68
  /**
49
69
  * The font size of the axis label.
50
70
  * @default 14
71
+ * @deprecated Consider using `labelStyle.fontSize` instead.
51
72
  */
52
73
  labelFontSize?: number;
53
74
  /**
@@ -92,56 +113,70 @@ export type ContinuouseScaleName = 'linear' | 'log' | 'pow' | 'sqrt' | 'time' |
92
113
  interface AxisScaleConfig {
93
114
  band: {
94
115
  scaleType: 'band';
95
- scale: ScaleBand<any>;
116
+ scale: ScaleBand<number | Date | string>;
96
117
  /**
97
118
  * The ratio between the space allocated for padding between two categories and the category width.
98
119
  * 0 means no gap, and 1 no data.
99
- * @default 0.1
120
+ * @default 0.2
100
121
  */
101
122
  categoryGapRatio: number;
102
123
  /**
103
124
  * The ratio between the width of a bar, and the gap between two bars.
104
125
  * 0 means no gap, and 1 no bar.
105
- * @default 0
126
+ * @default 0.1
106
127
  */
107
128
  barGapRatio: number;
108
129
  };
109
130
  point: {
110
131
  scaleType: 'point';
111
- scale: ScalePoint<any>;
132
+ scale: ScalePoint<number | Date | string>;
112
133
  };
113
134
  log: {
114
135
  scaleType: 'log';
115
- scale: ScaleLogarithmic<any, any>;
136
+ scale: ScaleLogarithmic<number, number>;
116
137
  };
117
138
  pow: {
118
139
  scaleType: 'pow';
119
- scale: ScalePower<any, any>;
140
+ scale: ScalePower<number, number>;
120
141
  };
121
142
  sqrt: {
122
143
  scaleType: 'sqrt';
123
- scale: ScalePower<any, any>;
144
+ scale: ScalePower<number, number>;
124
145
  };
125
146
  time: {
126
147
  scaleType: 'time';
127
- scale: ScaleTime<any, any>;
148
+ scale: ScaleTime<number, number>;
128
149
  };
129
150
  utc: {
130
151
  scaleType: 'utc';
131
- scale: ScaleTime<any, any>;
152
+ scale: ScaleTime<number, number>;
132
153
  };
133
154
  linear: {
134
155
  scaleType: 'linear';
135
- scale: ScaleLinear<any, any>;
156
+ scale: ScaleLinear<number, number>;
136
157
  };
137
158
  }
138
159
  export type AxisConfig<S extends ScaleName = ScaleName, V = any> = {
160
+ /**
161
+ * Id used to identify the axis.
162
+ */
139
163
  id: string;
164
+ /**
165
+ * The minimal value of the domain.
166
+ * If not provided, it gets computed to display the entire chart data.
167
+ */
140
168
  min?: number | Date;
169
+ /**
170
+ * The maximal value of the domain.
171
+ * If not provided, it gets computed to display the entire chart data.
172
+ */
141
173
  max?: number | Date;
174
+ /**
175
+ * The data used by `'band'` and `'point'` scales.
176
+ */
142
177
  data?: V[];
143
178
  /**
144
- * The key used to retrieve data from the dataset prop.
179
+ * The key used to retrieve `data` from the `dataset` prop.
145
180
  */
146
181
  dataKey?: string;
147
182
  valueFormatter?: (value: V) => string;
@@ -151,7 +186,10 @@ export type AxisConfig<S extends ScaleName = ScaleName, V = any> = {
151
186
  hideTooltip?: boolean;
152
187
  } & Partial<ChartsXAxisProps | ChartsYAxisProps> & Partial<Omit<AxisScaleConfig[S], 'scale'>> & TickParams;
153
188
  export type AxisDefaultized<S extends ScaleName = ScaleName, V = any> = Omit<AxisConfig<S, V>, 'scaleType'> & AxisScaleConfig[S] & {
154
- ticksNumber: number;
189
+ /**
190
+ * An indication of the expected number of ticks.
191
+ */
192
+ tickNumber: number;
155
193
  };
156
194
  export declare function isBandScaleConfig(scaleConfig: AxisConfig<ScaleName>): scaleConfig is AxisConfig<'band'> & {
157
195
  scaleType: 'band';
@@ -1,10 +1,17 @@
1
+ export interface CardinalDirections<T> {
2
+ top?: T;
3
+ bottom?: T;
4
+ left?: T;
5
+ right?: T;
6
+ }
1
7
  export type LayoutConfig = {
2
8
  width: number;
3
9
  height: number;
4
- margin?: {
5
- top?: number;
6
- bottom?: number;
7
- left?: number;
8
- right?: number;
9
- };
10
+ /**
11
+ * The margin between the SVG and the drawing area.
12
+ * It's used for leaving some space for extra information such as the x- and y-axis or legend.
13
+ * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
14
+ * @default object Depends on the charts type.
15
+ */
16
+ margin?: Partial<CardinalDirections<number>>;
10
17
  };
@@ -13,12 +13,28 @@ export type CommonSeriesType<TValue> = {
13
13
  };
14
14
  export type CommonDefaultizedProps = 'id' | 'valueFormatter' | 'data';
15
15
  export type CartesianSeriesType = {
16
+ /**
17
+ * The id of the x-axis used to render the series.
18
+ */
16
19
  xAxisKey?: string;
20
+ /**
21
+ * The id of the y-axis used to render the series.
22
+ */
17
23
  yAxisKey?: string;
18
24
  };
19
25
  export type StackableSeriesType = {
26
+ /**
27
+ * The key that identifies the stacking group.
28
+ * Series with the same `stack` property will be stacked together.
29
+ */
20
30
  stack?: string;
31
+ /**
32
+ * Defines how stacked series handle negative values.
33
+ */
21
34
  stackOffset?: StackOffsetType;
35
+ /**
36
+ * The order in which series' of the same group are stacked together.
37
+ */
22
38
  stackOrder?: StackOrderType;
23
39
  };
24
40
  export type StackOrderType = keyof typeof StackOrder;