@mui/x-charts 7.10.0 → 7.11.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 (299) hide show
  1. package/BarChart/BarChart.js +2 -2
  2. package/BarChart/BarElement.d.ts +2 -1
  3. package/BarChart/BarLabel/BarLabelItem.d.ts +2 -1
  4. package/BarChart/BarPlot.js +8 -8
  5. package/BarChart/checkScaleErrors.d.ts +4 -4
  6. package/BarChart/checkScaleErrors.js +11 -11
  7. package/BarChart/extremums.js +4 -1
  8. package/BarChart/formatter.js +2 -2
  9. package/BarChart/useBarChartProps.js +38 -33
  10. package/CHANGELOG.md +169 -0
  11. package/ChartContainer/ChartContainer.d.ts +28 -2
  12. package/ChartContainer/ChartContainer.js +25 -66
  13. package/ChartContainer/useChartContainerHooks.d.ts +1 -1
  14. package/ChartContainer/useChartContainerHooks.js +2 -2
  15. package/ChartContainer/useChartContainerProps.d.ts +86 -0
  16. package/ChartContainer/useChartContainerProps.js +95 -0
  17. package/ChartContainer/useDefaultizeAxis.d.ts +36 -0
  18. package/ChartContainer/useDefaultizeAxis.js +29 -0
  19. package/ChartsAxis/ChartsAxis.js +4 -4
  20. package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  21. package/ChartsLegend/ChartsLegend.d.ts +3 -12
  22. package/ChartsLegend/ContinuousColorLegend.d.ts +65 -0
  23. package/ChartsLegend/ContinuousColorLegend.js +398 -0
  24. package/ChartsLegend/DefaultChartsLegend.d.ts +7 -50
  25. package/ChartsLegend/DefaultChartsLegend.js +13 -198
  26. package/ChartsLegend/LegendPerItem.d.ts +61 -0
  27. package/ChartsLegend/LegendPerItem.js +151 -0
  28. package/ChartsLegend/PiecewiseColorLegend.d.ts +26 -0
  29. package/ChartsLegend/PiecewiseColorLegend.js +169 -0
  30. package/ChartsLegend/chartsLegend.types.d.ts +31 -0
  31. package/ChartsLegend/chartsLegend.types.js +5 -0
  32. package/ChartsLegend/index.d.ts +2 -0
  33. package/ChartsLegend/index.js +22 -0
  34. package/ChartsLegend/legend.types.d.ts +62 -0
  35. package/ChartsLegend/legend.types.js +5 -0
  36. package/ChartsLegend/legendItemsPlacement.d.ts +3 -0
  37. package/ChartsLegend/legendItemsPlacement.js +79 -0
  38. package/ChartsLegend/useAxis.d.ts +7 -0
  39. package/ChartsLegend/useAxis.js +47 -0
  40. package/ChartsLegend/utils.d.ts +1 -8
  41. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  42. package/ChartsOverlay/ChartsOverlay.d.ts +3 -2
  43. package/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
  44. package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  45. package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
  46. package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
  47. package/ChartsSurface.js +3 -1
  48. package/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
  49. package/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
  50. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
  51. package/ChartsXAxis/ChartsXAxis.js +1 -1
  52. package/ChartsYAxis/ChartsYAxis.js +15 -3
  53. package/Gauge/Gauge.d.ts +1 -4
  54. package/Gauge/Gauge.js +9 -6
  55. package/Gauge/GaugeContainer.js +8 -4
  56. package/Gauge/GaugeProvider.js +9 -9
  57. package/LineChart/AnimatedArea.js +2 -2
  58. package/LineChart/AnimatedLine.js +2 -2
  59. package/LineChart/AreaElement.d.ts +2 -1
  60. package/LineChart/AreaPlot.js +10 -6
  61. package/LineChart/LineChart.js +5 -2
  62. package/LineChart/LineElement.d.ts +2 -1
  63. package/LineChart/LineHighlightPlot.d.ts +2 -1
  64. package/LineChart/LineHighlightPlot.js +17 -5
  65. package/LineChart/LinePlot.js +10 -6
  66. package/LineChart/MarkElement.js +2 -2
  67. package/LineChart/MarkPlot.js +13 -25
  68. package/LineChart/extremums.js +4 -1
  69. package/LineChart/formatter.js +2 -2
  70. package/LineChart/useLineChartProps.js +38 -33
  71. package/PieChart/PieArc.js +1 -0
  72. package/PieChart/PieChart.d.ts +1 -4
  73. package/PieChart/PieChart.js +40 -34
  74. package/PieChart/PiePlot.js +6 -6
  75. package/PieChart/getPieCoordinates.js +3 -3
  76. package/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
  77. package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +5 -1
  78. package/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
  79. package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +20 -0
  80. package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +73 -0
  81. package/ScatterChart/Scatter.js +6 -9
  82. package/ScatterChart/ScatterChart.js +4 -1
  83. package/ScatterChart/ScatterPlot.js +6 -3
  84. package/ScatterChart/extremums.js +8 -2
  85. package/ScatterChart/useScatterChartProps.js +35 -30
  86. package/SparkLineChart/SparkLineChart.js +27 -22
  87. package/context/CartesianProvider/CartesianContext.d.ts +1 -1
  88. package/context/CartesianProvider/CartesianProvider.d.ts +2 -3
  89. package/context/CartesianProvider/CartesianProvider.js +18 -7
  90. package/context/CartesianProvider/computeValue.d.ts +32 -9
  91. package/context/CartesianProvider/computeValue.js +20 -16
  92. package/context/CartesianProvider/defaultizeAxis.d.ts +36 -0
  93. package/context/CartesianProvider/defaultizeAxis.js +21 -0
  94. package/context/CartesianProvider/index.d.ts +0 -1
  95. package/context/CartesianProvider/index.js +1 -3
  96. package/context/CartesianProvider/normalizeAxis.d.ts +1 -1
  97. package/context/CartesianProvider/normalizeAxis.js +2 -2
  98. package/context/DrawingProvider.d.ts +12 -0
  99. package/context/DrawingProvider.js +15 -2
  100. package/context/HighlightedProvider/HighlightedProvider.js +2 -2
  101. package/context/SeriesContextProvider.js +1 -1
  102. package/context/ZAxisContextProvider.d.ts +1 -1
  103. package/context/ZAxisContextProvider.js +1 -1
  104. package/esm/BarChart/BarChart.js +2 -2
  105. package/esm/BarChart/BarPlot.js +8 -8
  106. package/esm/BarChart/checkScaleErrors.js +11 -11
  107. package/esm/BarChart/extremums.js +4 -1
  108. package/esm/BarChart/formatter.js +2 -2
  109. package/esm/BarChart/useBarChartProps.js +38 -33
  110. package/esm/ChartContainer/ChartContainer.js +25 -66
  111. package/esm/ChartContainer/useChartContainerHooks.js +2 -2
  112. package/esm/ChartContainer/useChartContainerProps.js +87 -0
  113. package/esm/ChartContainer/useDefaultizeAxis.js +19 -0
  114. package/esm/ChartsAxis/ChartsAxis.js +4 -4
  115. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  116. package/esm/ChartsLegend/ContinuousColorLegend.js +390 -0
  117. package/esm/ChartsLegend/DefaultChartsLegend.js +14 -198
  118. package/esm/ChartsLegend/LegendPerItem.js +141 -0
  119. package/esm/ChartsLegend/PiecewiseColorLegend.js +161 -0
  120. package/esm/ChartsLegend/chartsLegend.types.js +1 -0
  121. package/esm/ChartsLegend/index.js +2 -0
  122. package/esm/ChartsLegend/legend.types.js +1 -0
  123. package/esm/ChartsLegend/legendItemsPlacement.js +72 -0
  124. package/esm/ChartsLegend/useAxis.js +39 -0
  125. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  126. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  127. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
  128. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
  129. package/esm/ChartsSurface.js +3 -1
  130. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
  131. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
  132. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
  133. package/esm/ChartsXAxis/ChartsXAxis.js +1 -1
  134. package/esm/ChartsYAxis/ChartsYAxis.js +15 -3
  135. package/esm/Gauge/Gauge.js +8 -5
  136. package/esm/Gauge/GaugeContainer.js +8 -4
  137. package/esm/Gauge/GaugeProvider.js +1 -1
  138. package/esm/LineChart/AnimatedArea.js +1 -1
  139. package/esm/LineChart/AnimatedLine.js +1 -1
  140. package/esm/LineChart/AreaPlot.js +10 -6
  141. package/esm/LineChart/LineChart.js +5 -2
  142. package/esm/LineChart/LineHighlightPlot.js +17 -5
  143. package/esm/LineChart/LinePlot.js +10 -6
  144. package/esm/LineChart/MarkElement.js +1 -1
  145. package/esm/LineChart/MarkPlot.js +12 -24
  146. package/esm/LineChart/extremums.js +4 -1
  147. package/esm/LineChart/formatter.js +2 -2
  148. package/esm/LineChart/useLineChartProps.js +38 -33
  149. package/esm/PieChart/PieArc.js +1 -0
  150. package/esm/PieChart/PieChart.js +39 -33
  151. package/esm/PieChart/PiePlot.js +1 -1
  152. package/esm/PieChart/getPieCoordinates.js +1 -1
  153. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
  154. package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
  155. package/esm/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
  156. package/esm/ScatterChart/Scatter.js +6 -9
  157. package/esm/ScatterChart/ScatterChart.js +4 -1
  158. package/esm/ScatterChart/ScatterPlot.js +6 -3
  159. package/esm/ScatterChart/extremums.js +8 -2
  160. package/esm/ScatterChart/useScatterChartProps.js +35 -30
  161. package/esm/SparkLineChart/SparkLineChart.js +27 -22
  162. package/esm/context/CartesianProvider/CartesianProvider.js +18 -7
  163. package/esm/context/CartesianProvider/computeValue.js +20 -16
  164. package/esm/context/CartesianProvider/defaultizeAxis.js +13 -0
  165. package/esm/context/CartesianProvider/index.js +1 -3
  166. package/esm/context/CartesianProvider/normalizeAxis.js +2 -2
  167. package/esm/context/DrawingProvider.js +15 -2
  168. package/esm/context/HighlightedProvider/HighlightedProvider.js +2 -2
  169. package/esm/context/SeriesContextProvider.js +1 -1
  170. package/esm/context/ZAxisContextProvider.js +1 -1
  171. package/esm/hooks/useAxisEvents.js +14 -17
  172. package/esm/hooks/useDrawingArea.js +5 -3
  173. package/esm/hooks/useReducedMotion.js +4 -2
  174. package/esm/internals/SlotComponentPropsFromProps.js +1 -0
  175. package/esm/internals/cleanId.js +6 -0
  176. package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
  177. package/esm/internals/geometry.js +1 -1
  178. package/esm/internals/{utils.js → getPercentageValue.js} +1 -13
  179. package/esm/internals/getSymbol.js +5 -0
  180. package/esm/internals/index.js +3 -1
  181. package/esm/internals/isDefined.js +3 -0
  182. package/esm/internals/notNull.js +3 -0
  183. package/esm/internals/ts-generic.js +1 -0
  184. package/esm/internals/warning.js +19 -11
  185. package/hooks/useAxisEvents.js +14 -17
  186. package/hooks/useDrawingArea.js +5 -3
  187. package/hooks/useReducedMotion.js +4 -2
  188. package/index.js +1 -1
  189. package/internals/SlotComponentPropsFromProps.d.ts +1 -0
  190. package/internals/SlotComponentPropsFromProps.js +5 -0
  191. package/internals/cleanId.d.ts +4 -0
  192. package/internals/cleanId.js +12 -0
  193. package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +6 -0
  194. package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
  195. package/internals/defaultizeColor.d.ts +7 -0
  196. package/internals/geometry.js +1 -1
  197. package/internals/getPercentageValue.d.ts +7 -0
  198. package/internals/{utils.js → getPercentageValue.js} +1 -15
  199. package/internals/getSymbol.d.ts +2 -0
  200. package/internals/getSymbol.js +11 -0
  201. package/internals/index.d.ts +3 -1
  202. package/internals/index.js +25 -5
  203. package/internals/isDefined.d.ts +1 -0
  204. package/internals/isDefined.js +9 -0
  205. package/internals/notNull.d.ts +1 -0
  206. package/internals/notNull.js +9 -0
  207. package/internals/ts-generic.d.ts +5 -0
  208. package/internals/ts-generic.js +5 -0
  209. package/internals/warning.d.ts +2 -1
  210. package/internals/warning.js +21 -12
  211. package/models/axis.d.ts +5 -2
  212. package/models/helpers.d.ts +1 -0
  213. package/models/seriesType/common.d.ts +10 -0
  214. package/models/seriesType/config.d.ts +2 -16
  215. package/models/seriesType/scatter.d.ts +5 -0
  216. package/modern/BarChart/BarChart.js +2 -2
  217. package/modern/BarChart/BarPlot.js +8 -8
  218. package/modern/BarChart/checkScaleErrors.js +11 -11
  219. package/modern/BarChart/extremums.js +4 -1
  220. package/modern/BarChart/formatter.js +2 -2
  221. package/modern/BarChart/useBarChartProps.js +38 -33
  222. package/modern/ChartContainer/ChartContainer.js +25 -66
  223. package/modern/ChartContainer/useChartContainerHooks.js +2 -2
  224. package/modern/ChartContainer/useChartContainerProps.js +87 -0
  225. package/modern/ChartContainer/useDefaultizeAxis.js +19 -0
  226. package/modern/ChartsAxis/ChartsAxis.js +4 -4
  227. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  228. package/modern/ChartsLegend/ContinuousColorLegend.js +390 -0
  229. package/modern/ChartsLegend/DefaultChartsLegend.js +14 -198
  230. package/modern/ChartsLegend/LegendPerItem.js +141 -0
  231. package/modern/ChartsLegend/PiecewiseColorLegend.js +161 -0
  232. package/modern/ChartsLegend/chartsLegend.types.js +1 -0
  233. package/modern/ChartsLegend/index.js +2 -0
  234. package/modern/ChartsLegend/legend.types.js +1 -0
  235. package/modern/ChartsLegend/legendItemsPlacement.js +72 -0
  236. package/modern/ChartsLegend/useAxis.js +39 -0
  237. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  238. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  239. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
  240. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
  241. package/modern/ChartsSurface.js +3 -1
  242. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
  243. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
  244. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
  245. package/modern/ChartsXAxis/ChartsXAxis.js +1 -1
  246. package/modern/ChartsYAxis/ChartsYAxis.js +15 -3
  247. package/modern/Gauge/Gauge.js +8 -5
  248. package/modern/Gauge/GaugeContainer.js +8 -4
  249. package/modern/Gauge/GaugeProvider.js +1 -1
  250. package/modern/LineChart/AnimatedArea.js +1 -1
  251. package/modern/LineChart/AnimatedLine.js +1 -1
  252. package/modern/LineChart/AreaPlot.js +10 -6
  253. package/modern/LineChart/LineChart.js +5 -2
  254. package/modern/LineChart/LineHighlightPlot.js +17 -5
  255. package/modern/LineChart/LinePlot.js +10 -6
  256. package/modern/LineChart/MarkElement.js +1 -1
  257. package/modern/LineChart/MarkPlot.js +12 -24
  258. package/modern/LineChart/extremums.js +4 -1
  259. package/modern/LineChart/formatter.js +2 -2
  260. package/modern/LineChart/useLineChartProps.js +38 -33
  261. package/modern/PieChart/PieArc.js +1 -0
  262. package/modern/PieChart/PieChart.js +39 -33
  263. package/modern/PieChart/PiePlot.js +1 -1
  264. package/modern/PieChart/getPieCoordinates.js +1 -1
  265. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
  266. package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
  267. package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
  268. package/modern/ScatterChart/Scatter.js +6 -9
  269. package/modern/ScatterChart/ScatterChart.js +4 -1
  270. package/modern/ScatterChart/ScatterPlot.js +6 -3
  271. package/modern/ScatterChart/extremums.js +8 -2
  272. package/modern/ScatterChart/useScatterChartProps.js +35 -30
  273. package/modern/SparkLineChart/SparkLineChart.js +27 -22
  274. package/modern/context/CartesianProvider/CartesianProvider.js +18 -7
  275. package/modern/context/CartesianProvider/computeValue.js +20 -16
  276. package/modern/context/CartesianProvider/defaultizeAxis.js +13 -0
  277. package/modern/context/CartesianProvider/index.js +1 -3
  278. package/modern/context/CartesianProvider/normalizeAxis.js +2 -2
  279. package/modern/context/DrawingProvider.js +15 -2
  280. package/modern/context/HighlightedProvider/HighlightedProvider.js +2 -2
  281. package/modern/context/SeriesContextProvider.js +1 -1
  282. package/modern/context/ZAxisContextProvider.js +1 -1
  283. package/modern/hooks/useAxisEvents.js +14 -17
  284. package/modern/hooks/useDrawingArea.js +5 -3
  285. package/modern/hooks/useReducedMotion.js +4 -2
  286. package/modern/index.js +1 -1
  287. package/modern/internals/SlotComponentPropsFromProps.js +1 -0
  288. package/modern/internals/cleanId.js +6 -0
  289. package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
  290. package/modern/internals/geometry.js +1 -1
  291. package/modern/internals/{utils.js → getPercentageValue.js} +1 -13
  292. package/modern/internals/getSymbol.js +5 -0
  293. package/modern/internals/index.js +3 -1
  294. package/modern/internals/isDefined.js +3 -0
  295. package/modern/internals/notNull.js +3 -0
  296. package/modern/internals/ts-generic.js +1 -0
  297. package/modern/internals/warning.js +19 -11
  298. package/package.json +4 -4
  299. package/internals/utils.d.ts +0 -18
@@ -4,212 +4,24 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.ChartsLegendRoot = void 0;
8
7
  exports.DefaultChartsLegend = DefaultChartsLegend;
9
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
10
  var React = _interopRequireWildcard(require("react"));
12
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
- var _NoSsr = require("@mui/base/NoSsr");
14
- var _styles = require("@mui/material/styles");
15
- var _ChartsText = require("../ChartsText");
16
- var _getWordsByLines = require("../internals/getWordsByLines");
12
+ var _LegendPerItem = require("./LegendPerItem");
17
13
  var _jsxRuntime = require("react/jsx-runtime");
18
- const _excluded = ["rotate", "dominantBaseline"],
19
- _excluded2 = ["label"];
14
+ const _excluded = ["drawingArea", "seriesToDisplay"];
20
15
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
21
16
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
22
- const ChartsLegendRoot = exports.ChartsLegendRoot = (0, _styles.styled)('g', {
23
- name: 'MuiChartsLegend',
24
- slot: 'Root',
25
- overridesResolver: (props, styles) => styles.root
26
- })({});
27
- /**
28
- * Transforms number or partial padding object to a defaultized padding object.
29
- */
30
- const getStandardizedPadding = padding => {
31
- if (typeof padding === 'number') {
32
- return {
33
- left: padding,
34
- right: padding,
35
- top: padding,
36
- bottom: padding
37
- };
38
- }
39
- return (0, _extends2.default)({
40
- left: 0,
41
- right: 0,
42
- top: 0,
43
- bottom: 0
44
- }, padding);
45
- };
46
17
  function DefaultChartsLegend(props) {
47
18
  const {
48
- hidden,
49
- position,
50
- direction,
51
- seriesToDisplay,
52
- drawingArea,
53
- classes,
54
- itemMarkWidth = 20,
55
- itemMarkHeight = 20,
56
- markGap = 5,
57
- itemGap = 10,
58
- padding: paddingProps = 10,
59
- labelStyle: inLabelStyle
60
- } = props;
61
- const theme = (0, _styles.useTheme)();
62
- const isRTL = theme.direction === 'rtl';
63
- const labelStyle = React.useMemo(() => (0, _extends2.default)({}, theme.typography.subtitle1, {
64
- color: 'inherit',
65
- dominantBaseline: 'central',
66
- textAnchor: 'start',
67
- fill: (theme.vars || theme).palette.text.primary,
68
- lineHeight: 1
69
- }, inLabelStyle),
70
- // To say to TS that the dominantBaseline and textAnchor are correct
71
- [inLabelStyle, theme]);
72
- const padding = React.useMemo(() => getStandardizedPadding(paddingProps), [paddingProps]);
73
- const getItemSpace = React.useCallback((label, inStyle = {}) => {
74
- const style = (0, _objectWithoutPropertiesLoose2.default)(inStyle, _excluded);
75
- const linesSize = (0, _getWordsByLines.getWordsByLines)({
76
- style,
77
- needsComputation: true,
78
- text: label
79
- });
80
- const innerSize = {
81
- innerWidth: itemMarkWidth + markGap + Math.max(...linesSize.map(size => size.width)),
82
- innerHeight: Math.max(itemMarkHeight, linesSize.length * linesSize[0].height)
83
- };
84
- return (0, _extends2.default)({}, innerSize, {
85
- outerWidth: innerSize.innerWidth + itemGap,
86
- outerHeight: innerSize.innerHeight + itemGap
87
- });
88
- }, [itemGap, itemMarkHeight, itemMarkWidth, markGap]);
89
- const totalWidth = drawingArea.left + drawingArea.width + drawingArea.right;
90
- const totalHeight = drawingArea.top + drawingArea.height + drawingArea.bottom;
91
- const availableWidth = totalWidth - padding.left - padding.right;
92
- const availableHeight = totalHeight - padding.top - padding.bottom;
93
- const [seriesWithPosition, legendWidth, legendHeight] = React.useMemo(() => {
94
- // Start at 0, 0. Will be modified later by padding and position.
95
- let x = 0;
96
- let y = 0;
97
-
98
- // total values used to align legend later.
99
- let totalWidthUsed = 0;
100
- let totalHeightUsed = 0;
101
- let rowIndex = 0;
102
- const rowMaxHeight = [0];
103
- const seriesWithRawPosition = seriesToDisplay.map(_ref => {
104
- let {
105
- label
106
- } = _ref,
107
- other = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded2);
108
- const itemSpace = getItemSpace(label, labelStyle);
109
- const rep = (0, _extends2.default)({}, other, {
110
- label,
111
- positionX: x,
112
- positionY: y,
113
- innerHeight: itemSpace.innerHeight,
114
- innerWidth: itemSpace.innerWidth,
115
- outerHeight: itemSpace.outerHeight,
116
- outerWidth: itemSpace.outerWidth,
117
- rowIndex
118
- });
119
- if (direction === 'row') {
120
- if (x + itemSpace.innerWidth > availableWidth) {
121
- // This legend item would create overflow along the x-axis, so we start a new row.
122
- x = 0;
123
- y += rowMaxHeight[rowIndex];
124
- rowIndex += 1;
125
- if (rowMaxHeight.length <= rowIndex) {
126
- rowMaxHeight.push(0);
127
- }
128
- rep.positionX = x;
129
- rep.positionY = y;
130
- rep.rowIndex = rowIndex;
131
- }
132
- totalWidthUsed = Math.max(totalWidthUsed, x + itemSpace.outerWidth);
133
- totalHeightUsed = Math.max(totalHeightUsed, y + itemSpace.outerHeight);
134
- rowMaxHeight[rowIndex] = Math.max(rowMaxHeight[rowIndex], itemSpace.outerHeight);
135
- x += itemSpace.outerWidth;
136
- }
137
- if (direction === 'column') {
138
- if (y + itemSpace.innerHeight > availableHeight) {
139
- // This legend item would create overflow along the y-axis, so we start a new column.
140
- x = totalWidthUsed + itemGap;
141
- y = 0;
142
- rowIndex = 0;
143
- rep.positionX = x;
144
- rep.positionY = y;
145
- rep.rowIndex = rowIndex;
146
- }
147
- if (rowMaxHeight.length <= rowIndex) {
148
- rowMaxHeight.push(0);
149
- }
150
- totalWidthUsed = Math.max(totalWidthUsed, x + itemSpace.outerWidth);
151
- totalHeightUsed = Math.max(totalHeightUsed, y + itemSpace.outerHeight);
152
- rowIndex += 1;
153
- y += itemSpace.outerHeight;
154
- }
155
- return rep;
156
- });
157
- return [seriesWithRawPosition.map(item => (0, _extends2.default)({}, item, {
158
- positionY: item.positionY + (direction === 'row' ? rowMaxHeight[item.rowIndex] / 2 // Get the center of the entire row
159
- : item.outerHeight / 2) // Get the center of the item
160
- })), totalWidthUsed, totalHeightUsed];
161
- }, [seriesToDisplay, getItemSpace, labelStyle, direction, availableWidth, availableHeight, itemGap]);
162
- const gapX = React.useMemo(() => {
163
- switch (position.horizontal) {
164
- case 'left':
165
- return padding.left;
166
- case 'right':
167
- return totalWidth - padding.right - legendWidth;
168
- default:
169
- return (totalWidth - legendWidth) / 2;
170
- }
171
- }, [position.horizontal, padding.left, padding.right, totalWidth, legendWidth]);
172
- const gapY = React.useMemo(() => {
173
- switch (position.vertical) {
174
- case 'top':
175
- return padding.top;
176
- case 'bottom':
177
- return totalHeight - padding.bottom - legendHeight;
178
- default:
179
- return (totalHeight - legendHeight) / 2;
180
- }
181
- }, [position.vertical, padding.top, padding.bottom, totalHeight, legendHeight]);
182
- if (hidden) {
183
- return null;
184
- }
185
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_NoSsr.NoSsr, {
186
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ChartsLegendRoot, {
187
- className: classes.root,
188
- children: seriesWithPosition.map(({
189
- id,
190
- label,
191
- color,
192
- positionX,
193
- positionY
194
- }) => /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
195
- className: classes.series,
196
- transform: `translate(${gapX + (isRTL ? legendWidth - positionX : positionX)} ${gapY + positionY})`,
197
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("rect", {
198
- className: classes.mark,
199
- x: isRTL ? -itemMarkWidth : 0,
200
- y: -itemMarkHeight / 2,
201
- width: itemMarkWidth,
202
- height: itemMarkHeight,
203
- fill: color
204
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsText.ChartsText, {
205
- style: labelStyle,
206
- text: label,
207
- x: (isRTL ? -1 : 1) * (itemMarkWidth + markGap),
208
- y: 0
209
- })]
210
- }, id))
211
- })
212
- });
19
+ seriesToDisplay
20
+ } = props,
21
+ other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
22
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_LegendPerItem.LegendPerItem, (0, _extends2.default)({}, other, {
23
+ itemsToDisplay: seriesToDisplay
24
+ }));
213
25
  }
214
26
  process.env.NODE_ENV !== "production" ? DefaultChartsLegend.propTypes = {
215
27
  // ----------------------------- Warning --------------------------------
@@ -219,12 +31,15 @@ process.env.NODE_ENV !== "production" ? DefaultChartsLegend.propTypes = {
219
31
  /**
220
32
  * Override or extend the styles applied to the component.
221
33
  */
222
- classes: _propTypes.default.object.isRequired,
34
+ classes: _propTypes.default.object,
223
35
  /**
224
36
  * The direction of the legend layout.
225
37
  * The default depends on the chart.
226
38
  */
227
39
  direction: _propTypes.default.oneOf(['column', 'row']).isRequired,
40
+ /**
41
+ * @deprecated Use the `useDrawingArea` hook instead.
42
+ */
228
43
  drawingArea: _propTypes.default.shape({
229
44
  bottom: _propTypes.default.number.isRequired,
230
45
  height: _propTypes.default.number.isRequired,
@@ -0,0 +1,61 @@
1
+ import * as React from 'react';
2
+ import { DrawingArea } from '../context/DrawingProvider';
3
+ import { DefaultizedProps } from '../models/helpers';
4
+ import { ChartsTextStyle } from '../ChartsText';
5
+ import { CardinalDirections } from '../models/layout';
6
+ import type { ChartsLegendProps } from './ChartsLegend';
7
+ import { LegendItemParams } from './chartsLegend.types';
8
+ import { AnchorPosition, Direction } from './legend.types';
9
+ export type ChartsLegendRootOwnerState = {
10
+ position: AnchorPosition;
11
+ direction: Direction;
12
+ drawingArea: DrawingArea;
13
+ offsetX?: number;
14
+ offsetY?: number;
15
+ seriesNumber: number;
16
+ };
17
+ export declare const ChartsLegendRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<React.SVGProps<SVGGElement>, keyof React.SVGProps<SVGGElement>>, {}>;
18
+ export interface LegendPerItemProps extends DefaultizedProps<Omit<ChartsLegendProps, 'slots' | 'slotProps'>, 'direction' | 'position'> {
19
+ /**
20
+ * The ordered array of item to display in the legend.
21
+ */
22
+ itemsToDisplay: LegendItemParams[];
23
+ classes?: Record<'mark' | 'series' | 'root', string>;
24
+ /**
25
+ * Style applied to legend labels.
26
+ * @default theme.typography.subtitle1
27
+ */
28
+ labelStyle?: ChartsTextStyle;
29
+ /**
30
+ * Width of the item mark (in px).
31
+ * @default 20
32
+ */
33
+ itemMarkWidth?: number;
34
+ /**
35
+ * Height of the item mark (in px).
36
+ * @default 20
37
+ */
38
+ itemMarkHeight?: number;
39
+ /**
40
+ * Space between the mark and the label (in px).
41
+ * @default 5
42
+ */
43
+ markGap?: number;
44
+ /**
45
+ * Space between two legend items (in px).
46
+ * @default 10
47
+ */
48
+ itemGap?: number;
49
+ /**
50
+ * Legend padding (in px).
51
+ * Can either be a single number, or an object with top, left, bottom, right properties.
52
+ * @default 10
53
+ */
54
+ padding?: number | Partial<CardinalDirections<number>>;
55
+ }
56
+ /**
57
+ * Internal component to display an array of items as a legend.
58
+ * Used for series legend, and threshold color legend.
59
+ * @ignore - Do not document
60
+ */
61
+ export declare function LegendPerItem(props: LegendPerItemProps): React.JSX.Element | null;
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ChartsLegendRoot = void 0;
8
+ exports.LegendPerItem = LegendPerItem;
9
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var React = _interopRequireWildcard(require("react"));
12
+ var _NoSsr = require("@mui/base/NoSsr");
13
+ var _styles = require("@mui/material/styles");
14
+ var _ChartsText = require("../ChartsText");
15
+ var _getWordsByLines = require("../internals/getWordsByLines");
16
+ var _legendItemsPlacement = require("./legendItemsPlacement");
17
+ var _useDrawingArea = require("../hooks/useDrawingArea");
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+ const _excluded = ["rotate", "dominantBaseline"];
20
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
21
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
22
+ const ChartsLegendRoot = exports.ChartsLegendRoot = (0, _styles.styled)('g', {
23
+ name: 'MuiChartsLegend',
24
+ slot: 'Root',
25
+ overridesResolver: (props, styles) => styles.root
26
+ })({});
27
+ /**
28
+ * Transforms number or partial padding object to a defaultized padding object.
29
+ */
30
+ const getStandardizedPadding = padding => {
31
+ if (typeof padding === 'number') {
32
+ return {
33
+ left: padding,
34
+ right: padding,
35
+ top: padding,
36
+ bottom: padding
37
+ };
38
+ }
39
+ return (0, _extends2.default)({
40
+ left: 0,
41
+ right: 0,
42
+ top: 0,
43
+ bottom: 0
44
+ }, padding);
45
+ };
46
+
47
+ /**
48
+ * Internal component to display an array of items as a legend.
49
+ * Used for series legend, and threshold color legend.
50
+ * @ignore - Do not document
51
+ */
52
+ function LegendPerItem(props) {
53
+ const {
54
+ hidden,
55
+ position,
56
+ direction,
57
+ itemsToDisplay,
58
+ classes,
59
+ itemMarkWidth = 20,
60
+ itemMarkHeight = 20,
61
+ markGap = 5,
62
+ itemGap = 10,
63
+ padding: paddingProps = 10,
64
+ labelStyle: inLabelStyle
65
+ } = props;
66
+ const theme = (0, _styles.useTheme)();
67
+ const isRTL = theme.direction === 'rtl';
68
+ const drawingArea = (0, _useDrawingArea.useDrawingArea)();
69
+ const labelStyle = React.useMemo(() => (0, _extends2.default)({}, theme.typography.subtitle1, {
70
+ color: 'inherit',
71
+ dominantBaseline: 'central',
72
+ textAnchor: 'start',
73
+ fill: (theme.vars || theme).palette.text.primary,
74
+ lineHeight: 1
75
+ }, inLabelStyle),
76
+ // To say to TS that the dominantBaseline and textAnchor are correct
77
+ [inLabelStyle, theme]);
78
+ const padding = React.useMemo(() => getStandardizedPadding(paddingProps), [paddingProps]);
79
+ const getItemSpace = React.useCallback((label, inStyle = {}) => {
80
+ const style = (0, _objectWithoutPropertiesLoose2.default)(inStyle, _excluded);
81
+ const linesSize = (0, _getWordsByLines.getWordsByLines)({
82
+ style,
83
+ needsComputation: true,
84
+ text: label
85
+ });
86
+ const innerSize = {
87
+ innerWidth: itemMarkWidth + markGap + Math.max(...linesSize.map(size => size.width)),
88
+ innerHeight: Math.max(itemMarkHeight, linesSize.length * linesSize[0].height)
89
+ };
90
+ return (0, _extends2.default)({}, innerSize, {
91
+ outerWidth: innerSize.innerWidth + itemGap,
92
+ outerHeight: innerSize.innerHeight + itemGap
93
+ });
94
+ }, [itemGap, itemMarkHeight, itemMarkWidth, markGap]);
95
+ const totalWidth = drawingArea.left + drawingArea.width + drawingArea.right;
96
+ const totalHeight = drawingArea.top + drawingArea.height + drawingArea.bottom;
97
+ const availableWidth = totalWidth - padding.left - padding.right;
98
+ const availableHeight = totalHeight - padding.top - padding.bottom;
99
+ const [itemsWithPosition, legendWidth, legendHeight] = React.useMemo(() => (0, _legendItemsPlacement.legendItemPlacements)(itemsToDisplay, getItemSpace, labelStyle, direction, availableWidth, availableHeight, itemGap), [itemsToDisplay, getItemSpace, labelStyle, direction, availableWidth, availableHeight, itemGap]);
100
+ const gapX = React.useMemo(() => {
101
+ switch (position.horizontal) {
102
+ case 'left':
103
+ return padding.left;
104
+ case 'right':
105
+ return totalWidth - padding.right - legendWidth;
106
+ default:
107
+ return (totalWidth - legendWidth) / 2;
108
+ }
109
+ }, [position.horizontal, padding.left, padding.right, totalWidth, legendWidth]);
110
+ const gapY = React.useMemo(() => {
111
+ switch (position.vertical) {
112
+ case 'top':
113
+ return padding.top;
114
+ case 'bottom':
115
+ return totalHeight - padding.bottom - legendHeight;
116
+ default:
117
+ return (totalHeight - legendHeight) / 2;
118
+ }
119
+ }, [position.vertical, padding.top, padding.bottom, totalHeight, legendHeight]);
120
+ if (hidden) {
121
+ return null;
122
+ }
123
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_NoSsr.NoSsr, {
124
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ChartsLegendRoot, {
125
+ className: classes?.root,
126
+ children: itemsWithPosition.map(({
127
+ id,
128
+ label,
129
+ color,
130
+ positionX,
131
+ positionY
132
+ }) => /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
133
+ className: classes?.series,
134
+ transform: `translate(${gapX + (isRTL ? legendWidth - positionX : positionX)} ${gapY + positionY})`,
135
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("rect", {
136
+ className: classes?.mark,
137
+ x: isRTL ? -itemMarkWidth : 0,
138
+ y: -itemMarkHeight / 2,
139
+ width: itemMarkWidth,
140
+ height: itemMarkHeight,
141
+ fill: color
142
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsText.ChartsText, {
143
+ style: labelStyle,
144
+ text: label,
145
+ x: (isRTL ? -1 : 1) * (itemMarkWidth + markGap),
146
+ y: 0
147
+ })]
148
+ }, id))
149
+ })
150
+ });
151
+ }
@@ -0,0 +1,26 @@
1
+ import * as React from 'react';
2
+ import { ColorLegendSelector, PiecewiseLabelFormatterParams } from './legend.types';
3
+ import { LegendPerItemProps } from './LegendPerItem';
4
+ export interface PiecewiseColorLegendProps extends ColorLegendSelector, Omit<LegendPerItemProps, 'itemsToDisplay'> {
5
+ /**
6
+ * Hide the first item of the legend, corresponding to the [-infinity, min] piece.
7
+ * @default false
8
+ */
9
+ hideFirst?: boolean;
10
+ /**
11
+ * Hide the last item of the legend, corresponding to the [max, +infinity] piece.
12
+ * @default false
13
+ */
14
+ hideLast?: boolean;
15
+ /**
16
+ * Format the legend labels.
17
+ * @param {PiecewiseLabelFormatterParams} params The bound of the piece to format.
18
+ * @returns {string|null} The displayed label, or `null` to skip the item.
19
+ */
20
+ labelFormatter?: (params: PiecewiseLabelFormatterParams) => string | null;
21
+ }
22
+ declare function PiecewiseColorLegend(props: PiecewiseColorLegendProps): React.JSX.Element | null;
23
+ declare namespace PiecewiseColorLegend {
24
+ var propTypes: any;
25
+ }
26
+ export { PiecewiseColorLegend };
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.PiecewiseColorLegend = PiecewiseColorLegend;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
+ var React = _interopRequireWildcard(require("react"));
11
+ var _propTypes = _interopRequireDefault(require("prop-types"));
12
+ var _useAxis = require("./useAxis");
13
+ var _LegendPerItem = require("./LegendPerItem");
14
+ var _notNull = require("../internals/notNull");
15
+ var _jsxRuntime = require("react/jsx-runtime");
16
+ const _excluded = ["axisDirection", "axisId", "hideFirst", "hideLast", "labelFormatter"];
17
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
18
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
+ function defaultLabelFormatter(params) {
20
+ if (params.min === null) {
21
+ return `<${params.formattedMax}`;
22
+ }
23
+ if (params.max === null) {
24
+ return `>${params.formattedMin}`;
25
+ }
26
+ return `${params.formattedMin}-${params.formattedMax}`;
27
+ }
28
+ function PiecewiseColorLegend(props) {
29
+ const {
30
+ axisDirection,
31
+ axisId,
32
+ hideFirst,
33
+ hideLast,
34
+ labelFormatter = defaultLabelFormatter
35
+ } = props,
36
+ other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
37
+ const axisItem = (0, _useAxis.useAxis)({
38
+ axisDirection,
39
+ axisId
40
+ });
41
+ const colorMap = axisItem?.colorMap;
42
+ if (!colorMap || !colorMap.type || colorMap.type !== 'piecewise') {
43
+ return null;
44
+ }
45
+ const valueFormatter = v => axisItem.valueFormatter?.(v, {
46
+ location: 'legend'
47
+ }) ?? v.toLocaleString();
48
+ const formattedLabels = colorMap.thresholds.map(valueFormatter);
49
+ const itemsToDisplay = colorMap.colors.map((color, index) => {
50
+ const isFirst = index === 0;
51
+ const isLast = index === colorMap.colors.length - 1;
52
+ if (hideFirst && isFirst || hideLast && isLast) {
53
+ return null;
54
+ }
55
+ const label = labelFormatter((0, _extends2.default)({}, index === 0 ? {
56
+ min: null,
57
+ formattedMin: null
58
+ } : {
59
+ min: colorMap.thresholds[index - 1],
60
+ formattedMin: formattedLabels[index - 1]
61
+ }, index === colorMap.colors.length - 1 ? {
62
+ max: null,
63
+ formattedMax: null
64
+ } : {
65
+ max: colorMap.thresholds[index],
66
+ formattedMax: formattedLabels[index]
67
+ }));
68
+ if (label === null) {
69
+ return null;
70
+ }
71
+ return {
72
+ id: label,
73
+ color,
74
+ label
75
+ };
76
+ }).filter(_notNull.notNull);
77
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_LegendPerItem.LegendPerItem, (0, _extends2.default)({}, other, {
78
+ itemsToDisplay: itemsToDisplay
79
+ }));
80
+ }
81
+ process.env.NODE_ENV !== "production" ? PiecewiseColorLegend.propTypes = {
82
+ // ----------------------------- Warning --------------------------------
83
+ // | These PropTypes are generated from the TypeScript type definitions |
84
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
85
+ // ----------------------------------------------------------------------
86
+ /**
87
+ * The axis direction containing the color configuration to represent.
88
+ * @default 'z'
89
+ */
90
+ axisDirection: _propTypes.default.oneOf(['x', 'y', 'z']),
91
+ /**
92
+ * The id of the axis item with the color configuration to represent.
93
+ * @default The first axis item.
94
+ */
95
+ axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
96
+ /**
97
+ * Override or extend the styles applied to the component.
98
+ */
99
+ classes: _propTypes.default.object,
100
+ /**
101
+ * The direction of the legend layout.
102
+ * The default depends on the chart.
103
+ */
104
+ direction: _propTypes.default.oneOf(['column', 'row']).isRequired,
105
+ /**
106
+ * Set to true to hide the legend.
107
+ * @default false
108
+ */
109
+ hidden: _propTypes.default.bool,
110
+ /**
111
+ * Hide the first item of the legend, corresponding to the [-infinity, min] piece.
112
+ * @default false
113
+ */
114
+ hideFirst: _propTypes.default.bool,
115
+ /**
116
+ * Hide the last item of the legend, corresponding to the [max, +infinity] piece.
117
+ * @default false
118
+ */
119
+ hideLast: _propTypes.default.bool,
120
+ /**
121
+ * Space between two legend items (in px).
122
+ * @default 10
123
+ */
124
+ itemGap: _propTypes.default.number,
125
+ /**
126
+ * Height of the item mark (in px).
127
+ * @default 20
128
+ */
129
+ itemMarkHeight: _propTypes.default.number,
130
+ /**
131
+ * Width of the item mark (in px).
132
+ * @default 20
133
+ */
134
+ itemMarkWidth: _propTypes.default.number,
135
+ /**
136
+ * Format the legend labels.
137
+ * @param {PiecewiseLabelFormatterParams} params The bound of the piece to format.
138
+ * @returns {string|null} The displayed label, or `null` to skip the item.
139
+ */
140
+ labelFormatter: _propTypes.default.func,
141
+ /**
142
+ * Style applied to legend labels.
143
+ * @default theme.typography.subtitle1
144
+ */
145
+ labelStyle: _propTypes.default.object,
146
+ /**
147
+ * Space between the mark and the label (in px).
148
+ * @default 5
149
+ */
150
+ markGap: _propTypes.default.number,
151
+ /**
152
+ * Legend padding (in px).
153
+ * Can either be a single number, or an object with top, left, bottom, right properties.
154
+ * @default 10
155
+ */
156
+ padding: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.shape({
157
+ bottom: _propTypes.default.number,
158
+ left: _propTypes.default.number,
159
+ right: _propTypes.default.number,
160
+ top: _propTypes.default.number
161
+ })]),
162
+ /**
163
+ * The position of the legend.
164
+ */
165
+ position: _propTypes.default.shape({
166
+ horizontal: _propTypes.default.oneOf(['left', 'middle', 'right']).isRequired,
167
+ vertical: _propTypes.default.oneOf(['bottom', 'middle', 'top']).isRequired
168
+ }).isRequired
169
+ } : void 0;
@@ -0,0 +1,31 @@
1
+ import { ChartsTextStyle } from '../ChartsText';
2
+ export interface LegendItemParams {
3
+ /**
4
+ * The color used in the legend
5
+ */
6
+ color: string;
7
+ /**
8
+ * The label displayed in the legend
9
+ */
10
+ label: string;
11
+ /**
12
+ * The identifier of the legend element.
13
+ * Used for internal purpose such as `key` props
14
+ */
15
+ id: number | string;
16
+ }
17
+ export interface LegendItemWithPosition extends LegendItemParams {
18
+ positionX: number;
19
+ positionY: number;
20
+ innerHeight: number;
21
+ innerWidth: number;
22
+ outerHeight: number;
23
+ outerWidth: number;
24
+ rowIndex: number;
25
+ }
26
+ export type GetItemSpaceType = (label: string, inStyle?: ChartsTextStyle) => {
27
+ innerWidth: number;
28
+ innerHeight: number;
29
+ outerWidth: number;
30
+ outerHeight: number;
31
+ };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });