@mui/x-charts 6.18.2 → 6.18.3

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 (89) hide show
  1. package/BarChart/BarElement.d.ts +5 -1
  2. package/BarChart/BarElement.js +24 -1
  3. package/BarChart/index.d.ts +3 -2
  4. package/BarChart/index.js +31 -12
  5. package/CHANGELOG.md +59 -0
  6. package/ChartsLegend/index.d.ts +1 -0
  7. package/ChartsLegend/index.js +11 -0
  8. package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +5 -2
  9. package/ChartsTooltip/ChartsAxisTooltipContent.js +93 -73
  10. package/ChartsTooltip/ChartsItemTooltipContent.d.ts +5 -2
  11. package/ChartsTooltip/ChartsItemTooltipContent.js +38 -57
  12. package/ChartsTooltip/DefaultChartsAxisTooltipContent.d.ts +7 -0
  13. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +174 -0
  14. package/ChartsTooltip/DefaultChartsItemTooltipContent.d.ts +8 -0
  15. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +99 -0
  16. package/ChartsTooltip/index.d.ts +4 -0
  17. package/ChartsTooltip/index.js +44 -0
  18. package/ChartsYAxis/ChartsYAxis.js +6 -4
  19. package/LineChart/extremums.js +25 -8
  20. package/LineChart/index.d.ts +5 -5
  21. package/LineChart/index.js +50 -41
  22. package/PieChart/PieArcLabelPlot.d.ts +5 -1
  23. package/PieChart/PieArcLabelPlot.js +89 -1
  24. package/PieChart/PieArcPlot.d.ts +5 -1
  25. package/PieChart/PieArcPlot.js +88 -1
  26. package/PieChart/index.d.ts +6 -6
  27. package/PieChart/index.js +60 -46
  28. package/ScatterChart/Scatter.js +1 -1
  29. package/ScatterChart/index.d.ts +3 -3
  30. package/ScatterChart/index.js +31 -19
  31. package/esm/BarChart/BarElement.js +26 -2
  32. package/esm/BarChart/index.js +3 -2
  33. package/esm/ChartsLegend/index.js +2 -1
  34. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +95 -75
  35. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +40 -58
  36. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +168 -0
  37. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +92 -0
  38. package/esm/ChartsTooltip/index.js +5 -1
  39. package/esm/ChartsYAxis/ChartsYAxis.js +6 -4
  40. package/esm/LineChart/extremums.js +25 -8
  41. package/esm/LineChart/index.js +5 -5
  42. package/esm/PieChart/PieArcLabelPlot.js +91 -2
  43. package/esm/PieChart/PieArcPlot.js +90 -2
  44. package/esm/PieChart/index.js +6 -4
  45. package/esm/ScatterChart/Scatter.js +1 -1
  46. package/esm/ScatterChart/index.js +3 -3
  47. package/esm/internals/defaultizeValueFormatter.js +4 -3
  48. package/index.js +1 -1
  49. package/internals/defaultizeValueFormatter.d.ts +3 -1
  50. package/internals/defaultizeValueFormatter.js +3 -3
  51. package/legacy/BarChart/BarElement.js +26 -2
  52. package/legacy/BarChart/index.js +3 -2
  53. package/legacy/ChartsLegend/index.js +2 -1
  54. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +95 -74
  55. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +40 -55
  56. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +167 -0
  57. package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +89 -0
  58. package/legacy/ChartsTooltip/index.js +5 -1
  59. package/legacy/ChartsYAxis/ChartsYAxis.js +6 -4
  60. package/legacy/LineChart/extremums.js +29 -14
  61. package/legacy/LineChart/index.js +5 -5
  62. package/legacy/PieChart/PieArcLabelPlot.js +91 -2
  63. package/legacy/PieChart/PieArcPlot.js +90 -2
  64. package/legacy/PieChart/index.js +6 -4
  65. package/legacy/ScatterChart/Scatter.js +1 -1
  66. package/legacy/ScatterChart/index.js +3 -3
  67. package/legacy/index.js +1 -1
  68. package/legacy/internals/defaultizeValueFormatter.js +4 -3
  69. package/models/seriesType/config.d.ts +5 -1
  70. package/models/seriesType/scatter.d.ts +1 -1
  71. package/modern/BarChart/BarElement.js +26 -2
  72. package/modern/BarChart/index.js +3 -2
  73. package/modern/ChartsLegend/index.js +2 -1
  74. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +95 -74
  75. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +40 -58
  76. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +167 -0
  77. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +92 -0
  78. package/modern/ChartsTooltip/index.js +5 -1
  79. package/modern/ChartsYAxis/ChartsYAxis.js +6 -4
  80. package/modern/LineChart/extremums.js +25 -8
  81. package/modern/LineChart/index.js +5 -5
  82. package/modern/PieChart/PieArcLabelPlot.js +91 -2
  83. package/modern/PieChart/PieArcPlot.js +90 -2
  84. package/modern/PieChart/index.js +6 -4
  85. package/modern/ScatterChart/Scatter.js +1 -1
  86. package/modern/ScatterChart/index.js +3 -3
  87. package/modern/index.js +1 -1
  88. package/modern/internals/defaultizeValueFormatter.js +3 -3
  89. package/package.json +1 -1
@@ -6,6 +6,18 @@ export const getExtremumX = params => {
6
6
  const maxX = Math.max(...(axis.data ?? []));
7
7
  return [minX, maxX];
8
8
  };
9
+ function getSeriesExtremums(getValues, stackedData) {
10
+ if (stackedData.length === 0) {
11
+ return [null, null];
12
+ }
13
+ return stackedData.reduce((seriesAcc, stackedValue) => {
14
+ const [base, value] = getValues(stackedValue);
15
+ if (seriesAcc[0] === null) {
16
+ return [Math.min(base, value), Math.max(base, value)];
17
+ }
18
+ return [Math.min(base, value, seriesAcc[0]), Math.max(base, value, seriesAcc[1])];
19
+ }, getValues(stackedData[0]));
20
+ }
9
21
  export const getExtremumY = params => {
10
22
  const {
11
23
  series,
@@ -13,16 +25,21 @@ export const getExtremumY = params => {
13
25
  isDefaultAxis
14
26
  } = params;
15
27
  return Object.keys(series).filter(seriesId => series[seriesId].yAxisKey === axis.id || isDefaultAxis && series[seriesId].yAxisKey === undefined).reduce((acc, seriesId) => {
16
- const isArea = series[seriesId].area !== undefined;
17
- const getValues = isArea ? d => d : d => [d[1], d[1]]; // Id area should go from bottom to top, without area should only consider the top
28
+ const {
29
+ area,
30
+ stackedData
31
+ } = series[seriesId];
32
+ const isArea = area !== undefined;
33
+ const getValues = isArea ? d => d : d => [d[1], d[1]]; // Since this series is not used to display an area, we do not consider the base (the d[0]).
18
34
 
19
- const [seriesMin, seriesMax] = series[seriesId].stackedData.reduce((seriesAcc, stackedValue) => {
20
- const [base, value] = getValues(stackedValue);
21
- return [Math.min(base, value, seriesAcc[0]), Math.max(base, value, seriesAcc[1])];
22
- }, getValues(series[seriesId].stackedData[0]));
23
- if (acc[0] === null || acc[1] === null) {
24
- return [seriesMin, seriesMax];
35
+ const seriesExtremums = getSeriesExtremums(getValues, stackedData);
36
+ if (acc[0] === null) {
37
+ return seriesExtremums;
38
+ }
39
+ if (seriesExtremums[0] === null) {
40
+ return acc;
25
41
  }
42
+ const [seriesMin, seriesMax] = seriesExtremums;
26
43
  return [Math.min(seriesMin, acc[0]), Math.max(seriesMax, acc[1])];
27
44
  }, [null, null]);
28
45
  };
@@ -1,8 +1,8 @@
1
- export { LinePlot } from './LinePlot';
2
- export { AreaPlot } from './AreaPlot';
3
- export { MarkPlot } from './MarkPlot';
4
- export { LineHighlightPlot } from './LineHighlightPlot';
5
- export { LineChart } from './LineChart';
1
+ export * from './LineChart';
2
+ export * from './LinePlot';
3
+ export * from './AreaPlot';
4
+ export * from './MarkPlot';
5
+ export * from './LineHighlightPlot';
6
6
  export * from './AreaElement';
7
7
  export * from './LineElement';
8
8
  export * from './MarkElement';
@@ -3,6 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "arcLabel", "arcLabelMinAngle", "skipAnimation"],
4
4
  _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
5
5
  import * as React from 'react';
6
+ import PropTypes from 'prop-types';
6
7
  import { useTransition } from '@react-spring/web';
7
8
  import { defaultLabelTransitionConfig } from './dataTransform/transition';
8
9
  import { useTransformData } from './dataTransform/useTransformData';
@@ -22,7 +23,7 @@ function getItemLabel(arcLabel, arcLabelMinAngle, item) {
22
23
  }
23
24
  return arcLabel(item);
24
25
  }
25
- export function PieArcLabelPlot(props) {
26
+ function PieArcLabelPlot(props) {
26
27
  const {
27
28
  slots,
28
29
  slotProps,
@@ -87,4 +88,92 @@ export function PieArcLabelPlot(props) {
87
88
  }, slotProps?.pieArcLabel));
88
89
  })
89
90
  }));
90
- }
91
+ }
92
+ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
93
+ // ----------------------------- Warning --------------------------------
94
+ // | These PropTypes are generated from the TypeScript type definitions |
95
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
96
+ // ----------------------------------------------------------------------
97
+ /**
98
+ * The label displayed into the arc.
99
+ */
100
+ arcLabel: PropTypes.oneOfType([PropTypes.oneOf(['formattedValue', 'label', 'value']), PropTypes.func]),
101
+ /**
102
+ * The minimal angle required to display the arc label.
103
+ */
104
+ arcLabelMinAngle: PropTypes.number,
105
+ /**
106
+ * The radius applied to arc corners (similar to border radius).
107
+ * @default 0
108
+ */
109
+ cornerRadius: PropTypes.number,
110
+ data: PropTypes.arrayOf(PropTypes.shape({
111
+ color: PropTypes.string.isRequired,
112
+ endAngle: PropTypes.number.isRequired,
113
+ formattedValue: PropTypes.string.isRequired,
114
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
115
+ index: PropTypes.number.isRequired,
116
+ label: PropTypes.string,
117
+ padAngle: PropTypes.number.isRequired,
118
+ startAngle: PropTypes.number.isRequired,
119
+ value: PropTypes.number.isRequired
120
+ })).isRequired,
121
+ /**
122
+ * Override the arc attibutes when it is faded.
123
+ */
124
+ faded: PropTypes.shape({
125
+ additionalRadius: PropTypes.number,
126
+ color: PropTypes.string,
127
+ cornerRadius: PropTypes.number,
128
+ innerRadius: PropTypes.number,
129
+ outerRadius: PropTypes.number,
130
+ paddingAngle: PropTypes.number
131
+ }),
132
+ /**
133
+ * Override the arc attibutes when it is highlighted.
134
+ */
135
+ highlighted: PropTypes.shape({
136
+ additionalRadius: PropTypes.number,
137
+ color: PropTypes.string,
138
+ cornerRadius: PropTypes.number,
139
+ innerRadius: PropTypes.number,
140
+ outerRadius: PropTypes.number,
141
+ paddingAngle: PropTypes.number
142
+ }),
143
+ highlightScope: PropTypes.shape({
144
+ faded: PropTypes.oneOf(['global', 'none', 'series']),
145
+ highlighted: PropTypes.oneOf(['item', 'none', 'series'])
146
+ }),
147
+ id: PropTypes.string.isRequired,
148
+ /**
149
+ * The radius between circle center and the begining of the arc.
150
+ * @default 0
151
+ */
152
+ innerRadius: PropTypes.number,
153
+ /**
154
+ * The radius between circle center and the end of the arc.
155
+ * @default R_max The maximal radius that fit into the drawing area.
156
+ */
157
+ outerRadius: PropTypes.number.isRequired,
158
+ /**
159
+ * The padding angle (deg) between two arcs.
160
+ * @default 0
161
+ */
162
+ paddingAngle: PropTypes.number,
163
+ /**
164
+ * If `true`, animations are skiped.
165
+ * @default false
166
+ */
167
+ skipAnimation: PropTypes.bool,
168
+ /**
169
+ * The props used for each component slot.
170
+ * @default {}
171
+ */
172
+ slotProps: PropTypes.object,
173
+ /**
174
+ * Overridable component slots.
175
+ * @default {}
176
+ */
177
+ slots: PropTypes.object
178
+ } : void 0;
179
+ export { PieArcLabelPlot };
@@ -3,12 +3,13 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "onClick", "skipAnimation"],
4
4
  _excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
5
5
  import * as React from 'react';
6
+ import PropTypes from 'prop-types';
6
7
  import { useTransition } from '@react-spring/web';
7
8
  import { PieArc } from './PieArc';
8
9
  import { defaultTransitionConfig } from './dataTransform/transition';
9
10
  import { useTransformData } from './dataTransform/useTransformData';
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
11
- export function PieArcPlot(props) {
12
+ function PieArcPlot(props) {
12
13
  const {
13
14
  slots,
14
15
  slotProps,
@@ -80,4 +81,91 @@ export function PieArcPlot(props) {
80
81
  }, slotProps?.pieArc));
81
82
  })
82
83
  }));
83
- }
84
+ }
85
+ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
86
+ // ----------------------------- Warning --------------------------------
87
+ // | These PropTypes are generated from the TypeScript type definitions |
88
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
89
+ // ----------------------------------------------------------------------
90
+ /**
91
+ * The radius applied to arc corners (similar to border radius).
92
+ * @default 0
93
+ */
94
+ cornerRadius: PropTypes.number,
95
+ data: PropTypes.arrayOf(PropTypes.shape({
96
+ color: PropTypes.string.isRequired,
97
+ endAngle: PropTypes.number.isRequired,
98
+ formattedValue: PropTypes.string.isRequired,
99
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
100
+ index: PropTypes.number.isRequired,
101
+ label: PropTypes.string,
102
+ padAngle: PropTypes.number.isRequired,
103
+ startAngle: PropTypes.number.isRequired,
104
+ value: PropTypes.number.isRequired
105
+ })).isRequired,
106
+ /**
107
+ * Override the arc attibutes when it is faded.
108
+ */
109
+ faded: PropTypes.shape({
110
+ additionalRadius: PropTypes.number,
111
+ color: PropTypes.string,
112
+ cornerRadius: PropTypes.number,
113
+ innerRadius: PropTypes.number,
114
+ outerRadius: PropTypes.number,
115
+ paddingAngle: PropTypes.number
116
+ }),
117
+ /**
118
+ * Override the arc attibutes when it is highlighted.
119
+ */
120
+ highlighted: PropTypes.shape({
121
+ additionalRadius: PropTypes.number,
122
+ color: PropTypes.string,
123
+ cornerRadius: PropTypes.number,
124
+ innerRadius: PropTypes.number,
125
+ outerRadius: PropTypes.number,
126
+ paddingAngle: PropTypes.number
127
+ }),
128
+ highlightScope: PropTypes.shape({
129
+ faded: PropTypes.oneOf(['global', 'none', 'series']),
130
+ highlighted: PropTypes.oneOf(['item', 'none', 'series'])
131
+ }),
132
+ id: PropTypes.string.isRequired,
133
+ /**
134
+ * The radius between circle center and the begining of the arc.
135
+ * @default 0
136
+ */
137
+ innerRadius: PropTypes.number,
138
+ /**
139
+ * Callback fired when a pie item is clicked.
140
+ * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
141
+ * @param {PieItemIdentifier} pieItemIdentifier The pie item identifier.
142
+ * @param {DefaultizedPieValueType} item The pie item.
143
+ */
144
+ onClick: PropTypes.func,
145
+ /**
146
+ * The radius between circle center and the end of the arc.
147
+ * @default R_max The maximal radius that fit into the drawing area.
148
+ */
149
+ outerRadius: PropTypes.number.isRequired,
150
+ /**
151
+ * The padding angle (deg) between two arcs.
152
+ * @default 0
153
+ */
154
+ paddingAngle: PropTypes.number,
155
+ /**
156
+ * If `true`, animations are skiped.
157
+ * @default false
158
+ */
159
+ skipAnimation: PropTypes.bool,
160
+ /**
161
+ * The props used for each component slot.
162
+ * @default {}
163
+ */
164
+ slotProps: PropTypes.object,
165
+ /**
166
+ * Overridable component slots.
167
+ * @default {}
168
+ */
169
+ slots: PropTypes.object
170
+ } : void 0;
171
+ export { PieArcPlot };
@@ -1,4 +1,6 @@
1
- export { PiePlot } from './PiePlot';
2
- export { PieChart } from './PieChart';
3
- export { PieArcLabel, getPieArcLabelUtilityClass, pieArcLabelClasses } from './PieArcLabel';
4
- export { PieArc, getPieArcUtilityClass, pieArcClasses } from './PieArc';
1
+ export * from './PieChart';
2
+ export * from './PiePlot';
3
+ export * from './PieArcPlot';
4
+ export * from './PieArcLabelPlot';
5
+ export * from './PieArc';
6
+ export * from './PieArcLabel';
@@ -78,7 +78,7 @@ process.env.NODE_ENV !== "production" ? Scatter.propTypes = {
78
78
  color: PropTypes.string.isRequired,
79
79
  markerSize: PropTypes.number.isRequired,
80
80
  series: PropTypes.shape({
81
- color: PropTypes.string,
81
+ color: PropTypes.string.isRequired,
82
82
  data: PropTypes.arrayOf(PropTypes.shape({
83
83
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
84
84
  x: PropTypes.number.isRequired,
@@ -1,3 +1,3 @@
1
- export { ScatterPlot } from './ScatterPlot';
2
- export { ScatterChart } from './ScatterChart';
3
- export { Scatter } from './Scatter';
1
+ export * from './ScatterChart';
2
+ export * from './ScatterPlot';
3
+ export * from './Scatter';
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v6.18.2
2
+ * @mui/x-charts v6.18.3
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -2,9 +2,9 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  function defaultizeValueFormatter(series, defaultValueFormatter) {
3
3
  const defaultizedSeries = {};
4
4
  Object.keys(series).forEach(seriesId => {
5
- defaultizedSeries[seriesId] = _extends({
6
- valueFormatter: defaultValueFormatter
7
- }, series[seriesId]);
5
+ defaultizedSeries[seriesId] = _extends({}, series[seriesId], {
6
+ valueFormatter: series[seriesId].valueFormatter ?? defaultValueFormatter
7
+ });
8
8
  });
9
9
  return defaultizedSeries;
10
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-charts",
3
- "version": "6.18.2",
3
+ "version": "6.18.3",
4
4
  "description": "The community edition of the charts components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./index.js",