@mui/x-charts 6.0.0-alpha.0 → 6.0.0-alpha.2

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 (126) hide show
  1. package/BarChart/BarChart.js +8 -5
  2. package/BarChart/legend.d.ts +3 -0
  3. package/BarChart/legend.js +20 -0
  4. package/CHANGELOG.md +136 -8
  5. package/ChartsAxis/ChartsAxis.d.ts +4 -4
  6. package/ChartsAxis/ChartsAxis.js +4 -4
  7. package/ChartsLegend/ChartsLegend.d.ts +5 -1
  8. package/ChartsLegend/ChartsLegend.js +5 -1
  9. package/ChartsLegend/utils.d.ts +1 -1
  10. package/ChartsLegend/utils.js +12 -1
  11. package/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  12. package/ChartsTooltip/ChartsItemTooltipContent.js +11 -2
  13. package/ChartsTooltip/ChartsTooltipTable.js +8 -8
  14. package/LineChart/LineChart.js +8 -5
  15. package/LineChart/legend.d.ts +3 -0
  16. package/LineChart/legend.js +20 -0
  17. package/PieChart/PieArc.d.ts +36 -0
  18. package/PieChart/PieArc.js +128 -0
  19. package/PieChart/PieArcLabel.d.ts +36 -0
  20. package/PieChart/PieArcLabel.js +113 -0
  21. package/PieChart/PieChart.d.ts +20 -0
  22. package/PieChart/PieChart.js +292 -0
  23. package/PieChart/PiePlot.d.ts +2 -0
  24. package/PieChart/PiePlot.js +98 -0
  25. package/PieChart/formatter.d.ts +3 -0
  26. package/PieChart/formatter.js +49 -0
  27. package/PieChart/index.d.ts +4 -0
  28. package/PieChart/index.js +47 -0
  29. package/PieChart/legend.d.ts +3 -0
  30. package/PieChart/legend.js +19 -0
  31. package/PieChart/package.json +6 -0
  32. package/README.md +30 -2
  33. package/ResponsiveChartContainer/index.js +91 -25
  34. package/ScatterChart/Scatter.js +1 -1
  35. package/ScatterChart/ScatterChart.js +5 -4
  36. package/ScatterChart/legend.d.ts +3 -0
  37. package/ScatterChart/legend.js +20 -0
  38. package/context/SeriesContextProvider.js +11 -1
  39. package/esm/BarChart/BarChart.js +8 -5
  40. package/esm/BarChart/legend.js +13 -0
  41. package/esm/ChartsAxis/ChartsAxis.js +4 -4
  42. package/esm/ChartsLegend/ChartsLegend.js +5 -1
  43. package/esm/ChartsLegend/utils.js +11 -1
  44. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  45. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +11 -3
  46. package/esm/ChartsTooltip/ChartsTooltipTable.js +8 -8
  47. package/esm/LineChart/LineChart.js +8 -5
  48. package/esm/LineChart/legend.js +13 -0
  49. package/esm/PieChart/PieArc.js +117 -0
  50. package/esm/PieChart/PieArcLabel.js +101 -0
  51. package/esm/PieChart/PieChart.js +285 -0
  52. package/esm/PieChart/PiePlot.js +92 -0
  53. package/esm/PieChart/formatter.js +48 -0
  54. package/esm/PieChart/index.js +4 -0
  55. package/esm/PieChart/legend.js +12 -0
  56. package/esm/ResponsiveChartContainer/index.js +94 -26
  57. package/esm/ScatterChart/Scatter.js +1 -1
  58. package/esm/ScatterChart/ScatterChart.js +5 -4
  59. package/esm/ScatterChart/legend.js +13 -0
  60. package/esm/context/SeriesContextProvider.js +11 -1
  61. package/esm/index.js +1 -0
  62. package/esm/internals/defaultizeColor.js +7 -0
  63. package/esm/models/seriesType/index.js +1 -8
  64. package/index.d.ts +1 -0
  65. package/index.js +12 -1
  66. package/internals/defaultizeColor.d.ts +35 -0
  67. package/internals/defaultizeColor.js +7 -0
  68. package/legacy/BarChart/BarChart.js +10 -7
  69. package/legacy/BarChart/legend.js +15 -0
  70. package/legacy/ChartsAxis/ChartsAxis.js +4 -4
  71. package/legacy/ChartsLegend/ChartsLegend.js +5 -1
  72. package/legacy/ChartsLegend/utils.js +12 -6
  73. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +3 -1
  74. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +10 -3
  75. package/legacy/ChartsTooltip/ChartsTooltipTable.js +7 -9
  76. package/legacy/LineChart/LineChart.js +10 -7
  77. package/legacy/LineChart/legend.js +15 -0
  78. package/legacy/PieChart/PieArc.js +118 -0
  79. package/legacy/PieChart/PieArcLabel.js +101 -0
  80. package/legacy/PieChart/PieChart.js +297 -0
  81. package/legacy/PieChart/PiePlot.js +89 -0
  82. package/legacy/PieChart/formatter.js +55 -0
  83. package/legacy/PieChart/index.js +4 -0
  84. package/legacy/PieChart/legend.js +16 -0
  85. package/legacy/ResponsiveChartContainer/index.js +89 -26
  86. package/legacy/ScatterChart/Scatter.js +1 -1
  87. package/legacy/ScatterChart/ScatterChart.js +5 -4
  88. package/legacy/ScatterChart/legend.js +15 -0
  89. package/legacy/context/SeriesContextProvider.js +11 -1
  90. package/legacy/index.js +2 -1
  91. package/legacy/internals/defaultizeColor.js +9 -0
  92. package/legacy/models/seriesType/index.js +1 -8
  93. package/models/seriesType/bar.d.ts +1 -1
  94. package/models/seriesType/common.d.ts +1 -1
  95. package/models/seriesType/config.d.ts +29 -2
  96. package/models/seriesType/index.d.ts +7 -3
  97. package/models/seriesType/index.js +11 -0
  98. package/models/seriesType/line.d.ts +1 -1
  99. package/models/seriesType/pie.d.ts +103 -3
  100. package/models/seriesType/scatter.d.ts +1 -1
  101. package/modern/BarChart/BarChart.js +8 -5
  102. package/modern/BarChart/legend.js +13 -0
  103. package/modern/ChartsAxis/ChartsAxis.js +4 -4
  104. package/modern/ChartsLegend/ChartsLegend.js +5 -1
  105. package/modern/ChartsLegend/utils.js +11 -1
  106. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  107. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +11 -2
  108. package/modern/ChartsTooltip/ChartsTooltipTable.js +8 -8
  109. package/modern/LineChart/LineChart.js +8 -5
  110. package/modern/LineChart/legend.js +13 -0
  111. package/modern/PieChart/PieArc.js +116 -0
  112. package/modern/PieChart/PieArcLabel.js +101 -0
  113. package/modern/PieChart/PieChart.js +285 -0
  114. package/modern/PieChart/PiePlot.js +91 -0
  115. package/modern/PieChart/formatter.js +41 -0
  116. package/modern/PieChart/index.js +4 -0
  117. package/modern/PieChart/legend.js +12 -0
  118. package/modern/ResponsiveChartContainer/index.js +91 -25
  119. package/modern/ScatterChart/Scatter.js +1 -1
  120. package/modern/ScatterChart/ScatterChart.js +5 -4
  121. package/modern/ScatterChart/legend.js +13 -0
  122. package/modern/context/SeriesContextProvider.js +11 -1
  123. package/modern/index.js +2 -1
  124. package/modern/internals/defaultizeColor.js +7 -0
  125. package/modern/models/seriesType/index.js +1 -8
  126. package/package.json +1 -3
@@ -51,7 +51,9 @@ function BarChart(props) {
51
51
  xAxis: xAxis ?? [{
52
52
  id: _constants.DEFAULT_X_AXIS_KEY,
53
53
  scaleType: 'band',
54
- data: [...new Array(Math.max(...series.map(s => s.data.length)))].map((_, index) => index)
54
+ data: Array.from({
55
+ length: Math.max(...series.map(s => s.data.length))
56
+ }, (_, index) => index)
55
57
  }],
56
58
  yAxis: yAxis,
57
59
  colors: colors,
@@ -82,7 +84,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
82
84
  y: _propTypes.default.oneOf(['line', 'none'])
83
85
  }),
84
86
  /**
85
- * Indicate which axis to display the the bottom of the charts.
87
+ * Indicate which axis to display the bottom of the charts.
86
88
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
87
89
  * @default xAxisIds[0] The id of the first provided axis
88
90
  */
@@ -109,7 +111,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
109
111
  disableAxisListener: _propTypes.default.bool,
110
112
  height: _propTypes.default.number,
111
113
  /**
112
- * Indicate which axis to display the the left of the charts.
114
+ * Indicate which axis to display the left of the charts.
113
115
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
114
116
  * @default yAxisIds[0] The id of the first provided axis
115
117
  */
@@ -129,6 +131,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
129
131
  legend: _propTypes.default.shape({
130
132
  classes: _propTypes.default.object,
131
133
  direction: _propTypes.default.oneOf(['column', 'row']),
134
+ hidden: _propTypes.default.bool,
132
135
  itemWidth: _propTypes.default.number,
133
136
  markSize: _propTypes.default.number,
134
137
  offset: _propTypes.default.shape({
@@ -148,7 +151,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
148
151
  top: _propTypes.default.number
149
152
  }),
150
153
  /**
151
- * Indicate which axis to display the the right of the charts.
154
+ * Indicate which axis to display the right of the charts.
152
155
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
153
156
  * @default null
154
157
  */
@@ -191,7 +194,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
191
194
  trigger: _propTypes.default.oneOf(['axis', 'item', 'none'])
192
195
  }),
193
196
  /**
194
- * Indicate which axis to display the the top of the charts.
197
+ * Indicate which axis to display the top of the charts.
195
198
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
196
199
  * @default null
197
200
  */
@@ -0,0 +1,3 @@
1
+ import { LegendGetter } from '../models/seriesType/config';
2
+ declare const legendGetter: LegendGetter<'bar'>;
3
+ export default legendGetter;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const legendGetter = params => {
8
+ const {
9
+ seriesOrder,
10
+ series
11
+ } = params;
12
+ const data = seriesOrder.map(seriesId => ({
13
+ color: series[seriesId].color,
14
+ label: series[seriesId].label,
15
+ id: seriesId
16
+ }));
17
+ return data.filter(item => item.label !== undefined);
18
+ };
19
+ var _default = legendGetter;
20
+ exports.default = _default;
package/CHANGELOG.md CHANGED
@@ -3,23 +3,151 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 6.9.2
7
+
8
+ _Jul 6, 2023_
9
+
10
+ We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🚀 Auto-scroll when making range selection (#8661) @m4theushw
13
+
14
+ - 📚 New page: Components lifecycle (#8372) @flaviendelangle
15
+
16
+ Clarify pickers events and value updates in a [single docs page](https://mui.com/x/react-date-pickers/lifecycle/).
17
+
18
+ - 🥧 Add pie chart component
19
+
20
+ They are fresh from the code editor. You can visit [pie charts docs](https://mui.com/x/react-charts/pie/) or their [demo page](https://mui.com/x/react-charts/pie-demo/).
21
+
22
+ <img width="380" alt="pie-charts" src="https://github.com/mui/mui-x/assets/13808724/fe908c45-803c-4316-b913-dbd2f9f0551e">
23
+
24
+ - 🐞 Bugfixes
25
+
26
+ - 📚 Documentation improvements
27
+
28
+ ### `@mui/x-data-grid@v6.9.2` / `@mui/x-data-grid-pro@v6.9.2` / `@mui/x-data-grid-premium@v6.9.2`
29
+
30
+ #### Changes
31
+
32
+ - [DataGrid] Fix `RangeError` when using flex columns (#9554) @cherniavskii
33
+ - [DataGrid] Fix React 17 editing bug (#9530) @romgrk
34
+ - [DataGrid] Use `getRowId` in filtering (#9564) @romgrk
35
+ - [DataGrid] Correctly reflect `TablePagination`'s `rowsPerPageOptions` shape to `pageSizeOptions` (#9438) @burakkgunduzz
36
+ - [DataGridPremium] Auto-scroll when making range selection (#8661) @m4theushw
37
+ - [l10n] Improve Spanish (es-ES) locale (#9500) @fufex
38
+
39
+ ### `@mui/x-date-pickers@v6.9.2` / `@mui/x-date-pickers-pro@v6.9.2`
40
+
41
+ #### Changes
42
+
43
+ - [pickers] Forward digital clock classes (#9555) @YoonjiJang
44
+ - [pickers] Rename `internal` folder to `internals` on `@mui/x-date-picker-pro` (#9571) @flaviendelangle
45
+
46
+ ### `@mui/x-charts@6.0.0-alpha.2`
47
+
48
+ #### Changes
49
+
50
+ - [charts] Add pie chart component (#9395) @alexfauquette
51
+
52
+ ### Docs
53
+
54
+ - [docs] Add pickers playground (#9164) @LukasTy
55
+ - [docs] Fix API links for pickers (#9573) @alexfauquette
56
+ - [docs] Fix demos with `ToggleButtonGroup` (#9548) @flaviendelangle
57
+ - [docs] Fix typos in pagination documentation page (#9332) @RatherBeLunar
58
+ - [docs] Hide ads on paid content @oliviertassinari
59
+ - [docs] Move the charts in the sidebar (#9437) @flaviendelangle
60
+ - [docs] New page: Components lifecycle (#8372) @flaviendelangle
61
+ - [docs] Remove outdated header tag @oliviertassinari
62
+
63
+ ### Core
64
+
65
+ - [core] Fix typo in priority support @oliviertassinari
66
+ - [core] Remove mention of Crowdin @oliviertassinari
67
+
68
+ ## 6.9.1
69
+
70
+ _Jun 30, 2023_
71
+
72
+ We'd like to offer a big thanks to the 13 contributors who made this release possible. Here are some highlights ✨:
73
+
74
+ - 🔎 Add experimental API for faster filtering performance
75
+ - 🌍 Add Chinese (Hong Kong) (zh-HK) locale on the pickers
76
+ - 🌍 Improve Romanian (ro-RO) and Hungarian (hu-HU) translations on the pickers and the data grid
77
+ - 🐞 Bugfixes
78
+ - 📚 Documentation improvements
79
+
80
+ ### `@mui/x-data-grid@v6.9.1` / `@mui/x-data-grid-pro@v6.9.1` / `@mui/x-data-grid-premium@v6.9.1`
81
+
82
+ #### Changes
83
+
84
+ - [DataGrid] Add Joy UI `tooltip` and `loadingOverlay` slots (#9028) @cherniavskii
85
+ - [DataGrid] Add section about enabling pagination on Pro and Premium (#8759) @joserodolfofreitas
86
+ - [DataGrid] Don't forward `editCellState` prop to DOM element (#9501) @m4theushw
87
+ - [DataGrid] Add experimental API for faster filtering performance (#9254) @romgrk
88
+ - [DataGrid] Fix `nextFieldToFocus` to always be a visible column field when <kbd>Tab</kbd> key is pressed (#8314) @yaredtsy
89
+ - [DataGrid] Fix `Maximum call stack size exceeded` error when using fractional width (#9516) @cherniavskii
90
+ - [DataGridPro] Don't throw error in column pinning (#9507) @romgrk
91
+ - [DataGridPro] Fix bug with `checkboxSelection` and treeData/grouping (#9418) @romgrk
92
+ - [l10n] Improve Romanian (ro-RO) and Hungarian (hu-HU) translations (#9436) @noraleonte
93
+
94
+ ### `@mui/x-date-pickers@v6.9.1` / `@mui/x-date-pickers-pro@v6.9.1`
95
+
96
+ #### Changes
97
+
98
+ - [DateTimePicker] Scroll to Digital Clock section only when selection changes (#9434) @LukasTy
99
+ - [pickers] Handle `keyDown` only when input is focused (#9481) @LukasTy
100
+ - [pickers] Add `referenceDate` prop on `TimeClock`, `DigitalClock` and `MultiSectionDigitalClock` (#9356) @flaviendelangle
101
+ - [l10n] Add Chinese (Hong Kong) (zh-HK) locale (#9468) @samchiu90
102
+ - [l10n] Improve Romanian (ro-RO) translations (#9436) @noraleonte
103
+
104
+ ### `@mui/x-charts@6.0.0-alpha.1`
105
+
106
+ #### Changes
107
+
108
+ - [charts] Take responsive container from data grid (#9497) @alexfauquette
109
+ - [charts] Update README.md (#9426) @alexfauquette
110
+ - [charts] Fix typo and small refactor (#9526) @flaviendelangle
111
+
112
+ ### Docs
113
+
114
+ - [docs] Add a recipe limiting to one expanded detail panel at a time (#9488) @cherniavskii
115
+ - [docs] Add missing upcoming flag without issue (#9449) @oliviertassinari
116
+ - [docs] Fix 301 when opening the charts @oliviertassinari
117
+ - [docs] Fix 404 link (#9435) @alexfauquette
118
+ - [docs] Fix `productId` logic (#9451) @oliviertassinari
119
+ - [docs] Update charts overview.md (#9429) @brentertz
120
+ - [docs] Avoid systematic usage of `"bg": "inline"` (#9499) @alexfauquette
121
+ - [docs] Display plan icon in ToC (#9490) @cherniavskii
122
+ - [docs] Remove "product" markdown header (#9517) @oliviertassinari
123
+
124
+ ### Core
125
+
126
+ - [core] Add `edit-mode` to priority support action (#9483) @DanailH
127
+ - [core] Fix priority support prompt action (#9472) @DanailH
128
+ - [core] Update `uses` for priority support action (#9480) @DanailH
129
+ - [core] Bumb update monorepo (#9476) @alexfauquette
130
+ - [CHANGELOG] Fix media quality (#9439) @oliviertassinari
131
+ - [CHANGELOG] Remove height img attribute @oliviertassinari
132
+ - [test] Skip flaky row pinning tests in JSDOM (#9511) @cherniavskii
133
+
6
134
  ## 6.9.0
7
135
 
8
136
  _Jun 22, 2023_
9
137
 
10
138
  We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
11
139
 
12
- - 🎁 We release a new package `@mui/x-charts`.
13
- This package aims at simplifying the integration of charts into your dashboards. 📊
140
+ - 🎁 We released a new open-source package: `@mui/x-charts`. This package aims at simplifying the integration of charts into your dashboards. 📊
141
+
142
+ <img width="512" alt="charts" src="https://github.com/mui/mui-x/assets/3165635/41201d3c-16a4-442d-a230-68356e6b433d">
143
+
144
+ It already contains [line](https://mui.com/x/react-charts/lines/), [bar](https://mui.com/x/react-charts/bars/), and [scatter](https://mui.com/x/react-charts/scatter/) charts, with basic customization features. Check out the [documentation](https://mui.com/x/react-charts/) to see what it can do, and open issues to get the feature you need implemented.
14
145
 
15
- ![image](https://github.com/mui/mui-x/assets/45398769/613bae2f-537d-4ec3-8046-591d1a504a72)
146
+ - 🚀 Introducing UTC and timezone support for pickers.
16
147
 
17
- It already contains [lines](https://mui.com/x/react-charts/lines/), [bars](https://mui.com/x/react-charts/bars/), and [scatter](https://mui.com/x/react-charts/scatter/) charts with basic customization features.
18
- Please, visit the new [documentation](https://mui.com/x/react-charts/) to know what it does, and open issues to get the feature you need to be implemented.
148
+ <img width="774" src="https://github.com/mui/mui-x/assets/3165635/ad95a404-ee67-4aff-b996-ad6cbb322348">
19
149
 
20
- - 🚀 Introduce the UTC and timezone support for pickers.
21
- ![image](https://github.com/mui/mui-x/assets/3309670/f8b552b0-9ec2-417b-b769-95740308291d)
22
- Please visit the [documentation](https://mui.com/x/react-date-pickers/timezone/) to learn how to use it.
150
+ Visit the [documentation](https://mui.com/x/react-date-pickers/timezone/) to learn how to use it.
23
151
 
24
152
  - 🌍 Improve Brazilian Portuguese (pt-BR) on the data grid
25
153
  - 🌍 Improve Czech (cs-CZ) locale on the pickers
@@ -2,25 +2,25 @@ import * as React from 'react';
2
2
  import { ChartsXAxisProps, ChartsYAxisProps } from '../models/axis';
3
3
  export interface ChartsAxisProps {
4
4
  /**
5
- * Indicate which axis to display the the top of the charts.
5
+ * Indicate which axis to display the top of the charts.
6
6
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
7
7
  * @default null
8
8
  */
9
9
  topAxis?: null | string | ChartsXAxisProps;
10
10
  /**
11
- * Indicate which axis to display the the bottom of the charts.
11
+ * Indicate which axis to display the bottom of the charts.
12
12
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
13
13
  * @default xAxisIds[0] The id of the first provided axis
14
14
  */
15
15
  bottomAxis?: null | string | ChartsXAxisProps;
16
16
  /**
17
- * Indicate which axis to display the the left of the charts.
17
+ * Indicate which axis to display the left of the charts.
18
18
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
19
19
  * @default yAxisIds[0] The id of the first provided axis
20
20
  */
21
21
  leftAxis?: null | string | ChartsYAxisProps;
22
22
  /**
23
- * Indicate which axis to display the the right of the charts.
23
+ * Indicate which axis to display the right of the charts.
24
24
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
25
25
  * @default null
26
26
  */
@@ -78,7 +78,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
78
78
  // | To update them edit the TypeScript types and run "yarn proptypes" |
79
79
  // ----------------------------------------------------------------------
80
80
  /**
81
- * Indicate which axis to display the the bottom of the charts.
81
+ * Indicate which axis to display the bottom of the charts.
82
82
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
83
83
  * @default xAxisIds[0] The id of the first provided axis
84
84
  */
@@ -96,7 +96,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
96
96
  tickSize: _propTypes.default.number
97
97
  }), _propTypes.default.string]),
98
98
  /**
99
- * Indicate which axis to display the the left of the charts.
99
+ * Indicate which axis to display the left of the charts.
100
100
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
101
101
  * @default yAxisIds[0] The id of the first provided axis
102
102
  */
@@ -114,7 +114,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
114
114
  tickSize: _propTypes.default.number
115
115
  }), _propTypes.default.string]),
116
116
  /**
117
- * Indicate which axis to display the the right of the charts.
117
+ * Indicate which axis to display the right of the charts.
118
118
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
119
119
  * @default null
120
120
  */
@@ -132,7 +132,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
132
132
  tickSize: _propTypes.default.number
133
133
  }), _propTypes.default.string]),
134
134
  /**
135
- * Indicate which axis to display the the top of the charts.
135
+ * Indicate which axis to display the top of the charts.
136
136
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
137
137
  * @default null
138
138
  */
@@ -15,6 +15,10 @@ export type ChartsLegendProps = {
15
15
  * Override or extend the styles applied to the component.
16
16
  */
17
17
  classes?: Partial<ChartsLegendClasses>;
18
+ /**
19
+ * Set to true to hide the legend.
20
+ */
21
+ hidden?: boolean;
18
22
  } & SizingParams;
19
23
  type DefaultizedChartsLegendProps = DefaultizedProps<ChartsLegendProps, 'direction' | 'position'>;
20
24
  type SeriesLegendOwnerState = ChartSeriesDefaultized<any> & Pick<DefaultizedChartsLegendProps, 'direction'> & {
@@ -40,5 +44,5 @@ export declare const ChartsLegendMark: import("@emotion/styled").StyledComponent
40
44
  };
41
45
  }, Pick<React.SVGProps<SVGRectElement>, keyof React.SVGProps<SVGRectElement>>, {}>;
42
46
  export declare const ChartsLegendLabel: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<Theme>, Pick<React.SVGTextElementAttributes<SVGTextElement>, keyof React.SVGTextElementAttributes<SVGTextElement>>, {}>;
43
- export declare function ChartsLegend(inProps: ChartsLegendProps): React.JSX.Element;
47
+ export declare function ChartsLegend(inProps: ChartsLegendProps): React.JSX.Element | null;
44
48
  export {};
@@ -159,7 +159,8 @@ function ChartsLegend(inProps) {
159
159
  const {
160
160
  position,
161
161
  direction,
162
- offset
162
+ offset,
163
+ hidden
163
164
  } = props;
164
165
  const theme = (0, _styles.useTheme)();
165
166
  const classes = useUtilityClasses((0, _extends2.default)({}, props, {
@@ -167,6 +168,9 @@ function ChartsLegend(inProps) {
167
168
  }));
168
169
  const drawingArea = React.useContext(_DrawingProvider.DrawingContext);
169
170
  const series = React.useContext(_SeriesContextProvider.SeriesContext);
171
+ if (hidden) {
172
+ return null;
173
+ }
170
174
  const seriesToDisplay = (0, _utils2.getSeriesToDisplay)(series);
171
175
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(ChartsLegendRoot, {
172
176
  ownerState: {
@@ -11,4 +11,4 @@ export type SizingParams = {
11
11
  itemWidth?: number;
12
12
  spacing?: number;
13
13
  };
14
- export declare function getSeriesToDisplay(series: FormattedSeries): (import("../models/seriesType/config").ChartSeriesDefaultized<"bar"> | import("../models/seriesType/config").ChartSeriesDefaultized<"scatter"> | import("../models/seriesType/config").ChartSeriesDefaultized<"line">)[];
14
+ export declare function getSeriesToDisplay(series: FormattedSeries): import("../models/seriesType/config").LegendParams[];
@@ -1,9 +1,20 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.getSeriesToDisplay = getSeriesToDisplay;
8
+ var _legend = _interopRequireDefault(require("../BarChart/legend"));
9
+ var _legend2 = _interopRequireDefault(require("../ScatterChart/legend"));
10
+ var _legend3 = _interopRequireDefault(require("../LineChart/legend"));
11
+ var _legend4 = _interopRequireDefault(require("../PieChart/legend"));
12
+ const legendGetter = {
13
+ bar: _legend.default,
14
+ scatter: _legend2.default,
15
+ line: _legend3.default,
16
+ pie: _legend4.default
17
+ };
7
18
  function getSeriesToDisplay(series) {
8
- return Object.values(series).flatMap(s => s.seriesOrder.map(seriesId => s.series[seriesId])).filter(s => s.label !== undefined);
19
+ return Object.keys(series).flatMap(seriesType => legendGetter[seriesType](series[seriesType]));
9
20
  }
@@ -90,7 +90,7 @@ function ChartsAxisTooltipContent(props) {
90
90
  const USED_X_AXIS_ID = xAxisIds[0];
91
91
  const relevantSeries = React.useMemo(() => {
92
92
  const rep = [];
93
- Object.keys(series).forEach(seriesType => {
93
+ Object.keys(series).filter(seriesType => ['bar', 'line', 'scatter'].includes(seriesType)).forEach(seriesType => {
94
94
  series[seriesType].seriesOrder.forEach(seriesId => {
95
95
  const axisKey = series[seriesType].series[seriesId].xAxisKey;
96
96
  if (axisKey === undefined || axisKey === USED_X_AXIS_ID) {
@@ -21,8 +21,17 @@ function DefaultChartsItemContent(props) {
21
21
  if (itemData.dataIndex === undefined) {
22
22
  return null;
23
23
  }
24
- const displayedLabel = series.label ?? null;
25
- const color = series.color;
24
+ const {
25
+ displayedLabel,
26
+ color
27
+ } = series.type === 'pie' ? {
28
+ color: series.data[itemData.dataIndex].color,
29
+ displayedLabel: series.data[itemData.dataIndex].label
30
+ } : {
31
+ color: series.color,
32
+ displayedLabel: series.label
33
+ };
34
+
26
35
  // TODO: Manage to let TS understand series.data and series.valueFormatter are coherent
27
36
  // @ts-ignore
28
37
  const formattedValue = series.valueFormatter(series.data[itemData.dataIndex]);
@@ -32,10 +32,10 @@ const ChartsTooltipRow = (0, _styles.styled)('tr', {
32
32
  })(({
33
33
  theme
34
34
  }) => ({
35
- '&:first-child td': {
35
+ 'tr:first-of-type& td': {
36
36
  paddingTop: theme.spacing(1)
37
37
  },
38
- '&:last-child td': {
38
+ 'tr:last-of-type& td': {
39
39
  paddingBottom: theme.spacing(1)
40
40
  }
41
41
  }));
@@ -48,18 +48,18 @@ const ChartsTooltipCell = (0, _styles.styled)('td', {
48
48
  }) => ({
49
49
  verticalAlign: 'middle',
50
50
  color: theme.palette.text.secondary,
51
- '&:first-child': {
52
- paddingLeft: theme.spacing(2)
53
- },
54
- '&:last-child': {
55
- paddingRight: theme.spacing(2)
56
- },
57
51
  [`&.${_tooltipClasses.tooltipClasses.labelCell}`]: {
58
52
  paddingLeft: theme.spacing(1)
59
53
  },
60
54
  [`&.${_tooltipClasses.tooltipClasses.valueCell}`]: {
61
55
  paddingLeft: theme.spacing(4),
62
56
  color: theme.palette.text.primary
57
+ },
58
+ 'td:first-of-type&': {
59
+ paddingLeft: theme.spacing(2)
60
+ },
61
+ 'td:last-of-type&': {
62
+ paddingRight: theme.spacing(2)
63
63
  }
64
64
  }));
65
65
  exports.ChartsTooltipCell = ChartsTooltipCell;
@@ -55,7 +55,9 @@ function LineChart(props) {
55
55
  xAxis: xAxis ?? [{
56
56
  id: _constants.DEFAULT_X_AXIS_KEY,
57
57
  scaleType: 'point',
58
- data: [...new Array(Math.max(...series.map(s => s.data.length)))].map((_, index) => index)
58
+ data: Array.from({
59
+ length: Math.max(...series.map(s => s.data.length))
60
+ }, (_, index) => index)
59
61
  }],
60
62
  yAxis: yAxis,
61
63
  colors: colors,
@@ -84,7 +86,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
84
86
  y: _propTypes.default.oneOf(['line', 'none'])
85
87
  }),
86
88
  /**
87
- * Indicate which axis to display the the bottom of the charts.
89
+ * Indicate which axis to display the bottom of the charts.
88
90
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
89
91
  * @default xAxisIds[0] The id of the first provided axis
90
92
  */
@@ -111,7 +113,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
111
113
  disableAxisListener: _propTypes.default.bool,
112
114
  height: _propTypes.default.number,
113
115
  /**
114
- * Indicate which axis to display the the left of the charts.
116
+ * Indicate which axis to display the left of the charts.
115
117
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
116
118
  * @default yAxisIds[0] The id of the first provided axis
117
119
  */
@@ -131,6 +133,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
131
133
  legend: _propTypes.default.shape({
132
134
  classes: _propTypes.default.object,
133
135
  direction: _propTypes.default.oneOf(['column', 'row']),
136
+ hidden: _propTypes.default.bool,
134
137
  itemWidth: _propTypes.default.number,
135
138
  markSize: _propTypes.default.number,
136
139
  offset: _propTypes.default.shape({
@@ -150,7 +153,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
150
153
  top: _propTypes.default.number
151
154
  }),
152
155
  /**
153
- * Indicate which axis to display the the right of the charts.
156
+ * Indicate which axis to display the right of the charts.
154
157
  * Can be a string (the id of the axis) or an object `ChartsYAxisProps`
155
158
  * @default null
156
159
  */
@@ -195,7 +198,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
195
198
  trigger: _propTypes.default.oneOf(['axis', 'item', 'none'])
196
199
  }),
197
200
  /**
198
- * Indicate which axis to display the the top of the charts.
201
+ * Indicate which axis to display the top of the charts.
199
202
  * Can be a string (the id of the axis) or an object `ChartsXAxisProps`
200
203
  * @default null
201
204
  */
@@ -0,0 +1,3 @@
1
+ import { LegendGetter } from '../models/seriesType/config';
2
+ declare const legendGetter: LegendGetter<'line'>;
3
+ export default legendGetter;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const legendGetter = params => {
8
+ const {
9
+ seriesOrder,
10
+ series
11
+ } = params;
12
+ const data = seriesOrder.map(seriesId => ({
13
+ color: series[seriesId].color,
14
+ label: series[seriesId].label,
15
+ id: seriesId
16
+ }));
17
+ return data.filter(item => item.label !== undefined);
18
+ };
19
+ var _default = legendGetter;
20
+ exports.default = _default;
@@ -0,0 +1,36 @@
1
+ import * as React from 'react';
2
+ import { PieArcDatum as D3PieArcDatum } from 'd3-shape';
3
+ import { HighlightScope } from '../context/HighlightProvider';
4
+ import { PieSeriesType } from '../models/seriesType/pie';
5
+ export interface PieArcClasses {
6
+ /** Styles applied to the root element. */
7
+ root: string;
8
+ /** Styles applied to the root element when higlighted. */
9
+ highlighted: string;
10
+ /** Styles applied to the root element when faded. */
11
+ faded: string;
12
+ }
13
+ export type PieArcClassKey = keyof PieArcClasses;
14
+ export interface PieArcOwnerState {
15
+ id: string;
16
+ dataIndex: number;
17
+ color: string;
18
+ isFaded: boolean;
19
+ isHighlighted: boolean;
20
+ classes?: Partial<PieArcClasses>;
21
+ }
22
+ export declare function getPieArcUtilityClass(slot: string): string;
23
+ export declare const pieArcClasses: PieArcClasses;
24
+ export type PieArcProps = Omit<PieArcOwnerState, 'isFaded' | 'isHighlighted'> & React.ComponentPropsWithoutRef<'path'> & D3PieArcDatum<any> & {
25
+ highlightScope?: Partial<HighlightScope>;
26
+ innerRadius: PieSeriesType['innerRadius'];
27
+ outerRadius: number;
28
+ cornerRadius: PieSeriesType['cornerRadius'];
29
+ highlighted: PieSeriesType['highlighted'];
30
+ faded: PieSeriesType['faded'];
31
+ };
32
+ declare function PieArc(props: PieArcProps): React.JSX.Element;
33
+ declare namespace PieArc {
34
+ var propTypes: any;
35
+ }
36
+ export default PieArc;