@mui/x-charts 7.3.1 → 7.3.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 (128) hide show
  1. package/BarChart/BarChart.d.ts +4 -3
  2. package/BarChart/BarChart.js +15 -5
  3. package/BarChart/BarPlot.js +6 -6
  4. package/CHANGELOG.md +76 -5
  5. package/ChartsAxis/axisClasses.d.ts +1 -1
  6. package/ChartsOverlay/ChartsLoadingOverlay.d.ts +3 -0
  7. package/ChartsOverlay/ChartsLoadingOverlay.js +43 -0
  8. package/ChartsOverlay/ChartsNoDataOverlay.d.ts +3 -0
  9. package/ChartsOverlay/ChartsNoDataOverlay.js +43 -0
  10. package/ChartsOverlay/ChartsOverlay.d.ts +35 -0
  11. package/ChartsOverlay/ChartsOverlay.js +41 -0
  12. package/ChartsOverlay/index.d.ts +3 -0
  13. package/ChartsOverlay/index.js +26 -0
  14. package/ChartsOverlay/package.json +6 -0
  15. package/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
  16. package/ChartsReferenceLine/common.d.ts +1 -1
  17. package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +1 -1
  18. package/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  19. package/ChartsTooltip/ChartsTooltip.d.ts +2 -2
  20. package/ChartsTooltip/ChartsTooltip.js +2 -2
  21. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
  22. package/ChartsXAxis/ChartsXAxis.d.ts +1 -1
  23. package/ChartsXAxis/ChartsXAxis.js +7 -0
  24. package/ChartsYAxis/ChartsYAxis.d.ts +1 -1
  25. package/ChartsYAxis/ChartsYAxis.js +7 -0
  26. package/Gauge/Gauge.js +1 -1
  27. package/Gauge/GaugeContainer.js +1 -1
  28. package/Gauge/GaugeProvider.d.ts +2 -2
  29. package/Gauge/GaugeProvider.js +1 -1
  30. package/Gauge/gaugeClasses.d.ts +2 -2
  31. package/Gauge/utils.d.ts +1 -1
  32. package/Gauge/utils.js +4 -4
  33. package/LineChart/AreaElement.d.ts +1 -1
  34. package/LineChart/LineChart.d.ts +4 -3
  35. package/LineChart/LineChart.js +12 -2
  36. package/LineChart/LineElement.d.ts +1 -1
  37. package/LineChart/MarkElement.d.ts +1 -1
  38. package/PieChart/PieArc.d.ts +1 -1
  39. package/PieChart/PieArcLabel.d.ts +1 -1
  40. package/PieChart/PieArcLabel.js +1 -1
  41. package/PieChart/PieArcLabelPlot.d.ts +1 -1
  42. package/PieChart/PieArcLabelPlot.js +3 -3
  43. package/PieChart/PieArcPlot.d.ts +1 -1
  44. package/PieChart/PieArcPlot.js +3 -3
  45. package/PieChart/PieChart.d.ts +4 -3
  46. package/PieChart/PieChart.js +15 -2
  47. package/ScatterChart/ScatterChart.d.ts +4 -3
  48. package/ScatterChart/ScatterChart.js +12 -2
  49. package/context/SeriesContextProvider.js +1 -1
  50. package/esm/BarChart/BarChart.js +15 -5
  51. package/esm/BarChart/BarPlot.js +6 -6
  52. package/esm/ChartsOverlay/ChartsLoadingOverlay.js +34 -0
  53. package/esm/ChartsOverlay/ChartsNoDataOverlay.js +34 -0
  54. package/esm/ChartsOverlay/ChartsOverlay.js +31 -0
  55. package/esm/ChartsOverlay/index.js +3 -0
  56. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
  57. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  58. package/esm/ChartsTooltip/ChartsTooltip.js +2 -2
  59. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
  60. package/esm/ChartsXAxis/ChartsXAxis.js +7 -0
  61. package/esm/ChartsYAxis/ChartsYAxis.js +7 -0
  62. package/esm/Gauge/Gauge.js +1 -1
  63. package/esm/Gauge/GaugeContainer.js +1 -1
  64. package/esm/Gauge/GaugeProvider.js +1 -1
  65. package/esm/Gauge/utils.js +4 -4
  66. package/esm/LineChart/LineChart.js +12 -2
  67. package/esm/PieChart/PieArcLabel.js +1 -1
  68. package/esm/PieChart/PieArcLabelPlot.js +3 -3
  69. package/esm/PieChart/PieArcPlot.js +3 -3
  70. package/esm/PieChart/PieChart.js +15 -2
  71. package/esm/ScatterChart/ScatterChart.js +12 -2
  72. package/esm/context/SeriesContextProvider.js +1 -1
  73. package/esm/hooks/useReducedMotion.js +1 -1
  74. package/esm/hooks/useScale.js +1 -1
  75. package/esm/hooks/useTicks.js +4 -0
  76. package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +5 -5
  77. package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -3
  78. package/esm/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -3
  79. package/esm/internals/utils.js +1 -1
  80. package/hooks/useReducedMotion.d.ts +1 -1
  81. package/hooks/useReducedMotion.js +1 -1
  82. package/hooks/useScale.d.ts +4 -4
  83. package/hooks/useScale.js +1 -1
  84. package/hooks/useTicks.js +4 -0
  85. package/index.js +1 -1
  86. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +5 -5
  87. package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +1 -1
  88. package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -3
  89. package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.d.ts +1 -1
  90. package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -3
  91. package/internals/utils.d.ts +1 -1
  92. package/internals/utils.js +1 -1
  93. package/models/axis.d.ts +1 -1
  94. package/models/seriesType/bar.d.ts +1 -1
  95. package/models/seriesType/line.d.ts +1 -1
  96. package/models/seriesType/pie.d.ts +4 -4
  97. package/modern/BarChart/BarChart.js +15 -5
  98. package/modern/BarChart/BarPlot.js +6 -6
  99. package/modern/ChartsOverlay/ChartsLoadingOverlay.js +34 -0
  100. package/modern/ChartsOverlay/ChartsNoDataOverlay.js +34 -0
  101. package/modern/ChartsOverlay/ChartsOverlay.js +31 -0
  102. package/modern/ChartsOverlay/index.js +3 -0
  103. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
  104. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  105. package/modern/ChartsTooltip/ChartsTooltip.js +2 -2
  106. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +1 -1
  107. package/modern/ChartsXAxis/ChartsXAxis.js +7 -0
  108. package/modern/ChartsYAxis/ChartsYAxis.js +7 -0
  109. package/modern/Gauge/Gauge.js +1 -1
  110. package/modern/Gauge/GaugeContainer.js +1 -1
  111. package/modern/Gauge/GaugeProvider.js +1 -1
  112. package/modern/Gauge/utils.js +4 -4
  113. package/modern/LineChart/LineChart.js +12 -2
  114. package/modern/PieChart/PieArcLabel.js +1 -1
  115. package/modern/PieChart/PieArcLabelPlot.js +3 -3
  116. package/modern/PieChart/PieArcPlot.js +3 -3
  117. package/modern/PieChart/PieChart.js +15 -2
  118. package/modern/ScatterChart/ScatterChart.js +12 -2
  119. package/modern/context/SeriesContextProvider.js +1 -1
  120. package/modern/hooks/useReducedMotion.js +1 -1
  121. package/modern/hooks/useScale.js +1 -1
  122. package/modern/hooks/useTicks.js +4 -0
  123. package/modern/index.js +1 -1
  124. package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +5 -5
  125. package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -3
  126. package/modern/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -3
  127. package/modern/internals/utils.js +1 -1
  128. package/package.json +1 -1
@@ -13,7 +13,7 @@ function getSymbol(shape) {
13
13
  return symbolNames.indexOf(shape) || 0;
14
14
  }
15
15
  /**
16
- * Transform mouse event position to corrdinates inside the SVG.
16
+ * Transform mouse event position to coordinates inside the SVG.
17
17
  * @param svg The SVG element
18
18
  * @param event The mouseEvent to transform
19
19
  */
package/models/axis.d.ts CHANGED
@@ -128,7 +128,7 @@ export interface ChartsXAxisProps extends ChartsAxisProps {
128
128
  }
129
129
  export type ScaleName = 'linear' | 'band' | 'point' | 'log' | 'pow' | 'sqrt' | 'time' | 'utc';
130
130
  export type ContinuousScaleName = 'linear' | 'log' | 'pow' | 'sqrt' | 'time' | 'utc';
131
- interface AxisScaleConfig {
131
+ export interface AxisScaleConfig {
132
132
  band: {
133
133
  scaleType: 'band';
134
134
  scale: ScaleBand<number | Date | string>;
@@ -8,7 +8,7 @@ export interface BarSeriesType extends CommonSeriesType<number | null>, Cartesia
8
8
  */
9
9
  data?: (number | null)[];
10
10
  /**
11
- * The key used to retrive data from the dataset.
11
+ * The key used to retrieve data from the dataset.
12
12
  */
13
13
  dataKey?: string;
14
14
  label?: string;
@@ -31,7 +31,7 @@ export interface LineSeriesType extends CommonSeriesType<number | null>, Cartesi
31
31
  */
32
32
  data?: (number | null)[];
33
33
  /**
34
- * The key used to retrive data from the dataset.
34
+ * The key used to retrieve data from the dataset.
35
35
  */
36
36
  dataKey?: string;
37
37
  stack?: string;
@@ -20,7 +20,7 @@ export interface PieSeriesType<Tdata = PieValueType> extends CommonSeriesType<Td
20
20
  type: 'pie';
21
21
  data: Tdata[];
22
22
  /**
23
- * The radius between circle center and the begining of the arc.
23
+ * The radius between circle center and the beginning of the arc.
24
24
  * Can be a number (in px) or a string with a percentage such as '50%'.
25
25
  * The '100%' is the maximal radius that fit into the drawing area.
26
26
  * @default 0
@@ -90,7 +90,7 @@ export interface PieSeriesType<Tdata = PieValueType> extends CommonSeriesType<Td
90
90
  */
91
91
  cy?: number | string;
92
92
  /**
93
- * Override the arc attibutes when it is highlighted.
93
+ * Override the arc attributes when it is highlighted.
94
94
  */
95
95
  highlighted?: {
96
96
  /**
@@ -106,7 +106,7 @@ export interface PieSeriesType<Tdata = PieValueType> extends CommonSeriesType<Td
106
106
  color?: string;
107
107
  };
108
108
  /**
109
- * Override the arc attibutes when it is faded.
109
+ * Override the arc attributes when it is faded.
110
110
  */
111
111
  faded?: {
112
112
  /**
@@ -139,7 +139,7 @@ export interface DefaultizedPieSeriesType extends DefaultizedProps<PieSeriesType
139
139
  */
140
140
  export interface ComputedPieRadius {
141
141
  /**
142
- * The radius between circle center and the begining of the arc.
142
+ * The radius between circle center and the beginning of the arc.
143
143
  * @default 0
144
144
  */
145
145
  innerRadius?: number;
@@ -12,6 +12,7 @@ import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
12
12
  import { ChartsClipPath } from '../ChartsClipPath';
13
13
  import { ChartsGrid } from '../ChartsGrid';
14
14
  import { ChartsOnAxisClickHandler } from '../ChartsOnAxisClickHandler';
15
+ import { ChartsOverlay } from '../ChartsOverlay/ChartsOverlay';
15
16
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
17
  /**
17
18
  * Demos:
@@ -49,7 +50,8 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
49
50
  onAxisClick,
50
51
  children,
51
52
  slots,
52
- slotProps
53
+ slotProps,
54
+ loading
53
55
  } = props;
54
56
  const id = useId();
55
57
  const clipPathId = `${id}-clip-path`;
@@ -90,14 +92,18 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
90
92
  }), grid && /*#__PURE__*/_jsx(ChartsGrid, {
91
93
  vertical: grid.vertical,
92
94
  horizontal: grid.horizontal
93
- }), /*#__PURE__*/_jsx("g", {
95
+ }), /*#__PURE__*/_jsxs("g", {
94
96
  clipPath: `url(#${clipPathId})`,
95
- children: /*#__PURE__*/_jsx(BarPlot, {
97
+ children: [/*#__PURE__*/_jsx(BarPlot, {
96
98
  slots: slots,
97
99
  slotProps: slotProps,
98
100
  skipAnimation: skipAnimation,
99
101
  onItemClick: onItemClick
100
- })
102
+ }), /*#__PURE__*/_jsx(ChartsOverlay, {
103
+ loading: loading,
104
+ slots: slots,
105
+ slotProps: slotProps
106
+ })]
101
107
  }), /*#__PURE__*/_jsx(ChartsAxis, {
102
108
  topAxis: topAxis,
103
109
  leftAxis: leftAxis,
@@ -108,7 +114,7 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
108
114
  }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
109
115
  slots: slots,
110
116
  slotProps: slotProps
111
- })), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, defaultizedAxisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
117
+ })), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, defaultizedAxisHighlight)), !loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
112
118
  slots: slots,
113
119
  slotProps: slotProps
114
120
  })), /*#__PURE__*/_jsx(ChartsClipPath, {
@@ -191,6 +197,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
191
197
  slotProps: PropTypes.object,
192
198
  slots: PropTypes.object
193
199
  }),
200
+ /**
201
+ * If `true`, a loading overlay is displayed.
202
+ */
203
+ loading: PropTypes.bool,
194
204
  /**
195
205
  * The margin between the SVG and the drawing area.
196
206
  * It's used for leaving some space for extra information such as the x- and y-axis or legend.
@@ -70,25 +70,25 @@ const useAggregatedData = () => {
70
70
  let baseScaleConfig;
71
71
  if (verticalLayout) {
72
72
  if (!isBandScaleConfig(xAxisConfig)) {
73
- throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} shoud be of type "band" to display the bar series of id "${seriesId}".`);
73
+ throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should be of type "band" to display the bar series of id "${seriesId}".`);
74
74
  }
75
75
  if (xAxis[xAxisKey].data === undefined) {
76
- throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} shoud have data property.`);
76
+ throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property.`);
77
77
  }
78
78
  baseScaleConfig = xAxisConfig;
79
79
  if (isBandScaleConfig(yAxisConfig) || isPointScaleConfig(yAxisConfig)) {
80
- throw new Error(`MUI X Charts: ${yAxisKey === DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} shoud be a continuous type to display the bar series of id "${seriesId}".`);
80
+ throw new Error(`MUI X Charts: ${yAxisKey === DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} should be a continuous type to display the bar series of id "${seriesId}".`);
81
81
  }
82
82
  } else {
83
83
  if (!isBandScaleConfig(yAxisConfig)) {
84
- throw new Error(`MUI X Charts: ${yAxisKey === DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} shoud be of type "band" to display the bar series of id "${seriesId}".`);
84
+ throw new Error(`MUI X Charts: ${yAxisKey === DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} should be of type "band" to display the bar series of id "${seriesId}".`);
85
85
  }
86
86
  if (yAxis[yAxisKey].data === undefined) {
87
- throw new Error(`MUI X Charts: ${yAxisKey === DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} shoud have data property.`);
87
+ throw new Error(`MUI X Charts: ${yAxisKey === DEFAULT_Y_AXIS_KEY ? 'The first `yAxis`' : `The y-axis with id "${yAxisKey}"`} should have data property.`);
88
88
  }
89
89
  baseScaleConfig = yAxisConfig;
90
90
  if (isBandScaleConfig(xAxisConfig) || isPointScaleConfig(xAxisConfig)) {
91
- throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} shoud be a continuous type to display the bar series of id "${seriesId}".`);
91
+ throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should be a continuous type to display the bar series of id "${seriesId}".`);
92
92
  }
93
93
  }
94
94
  const xScale = xAxisConfig.scale;
@@ -0,0 +1,34 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["message"];
4
+ import * as React from 'react';
5
+ import { styled } from '@mui/material/styles';
6
+ import { useDrawingArea } from '../hooks/useDrawingArea';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const StyledText = styled('text')(({
9
+ theme
10
+ }) => ({
11
+ stroke: 'none',
12
+ fill: theme.palette.text.primary,
13
+ shapeRendering: 'crispEdges',
14
+ textAnchor: 'middle',
15
+ dominantBaseline: 'middle'
16
+ }));
17
+ export function ChartsLoadingOverlay(props) {
18
+ const {
19
+ message
20
+ } = props,
21
+ other = _objectWithoutPropertiesLoose(props, _excluded);
22
+ const {
23
+ top,
24
+ left,
25
+ height,
26
+ width
27
+ } = useDrawingArea();
28
+ return /*#__PURE__*/_jsx(StyledText, _extends({
29
+ x: left + width / 2,
30
+ y: top + height / 2
31
+ }, other, {
32
+ children: message ?? 'Loading data ...'
33
+ }));
34
+ }
@@ -0,0 +1,34 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["message"];
4
+ import * as React from 'react';
5
+ import { styled } from '@mui/material/styles';
6
+ import { useDrawingArea } from '../hooks/useDrawingArea';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const StyledText = styled('text')(({
9
+ theme
10
+ }) => ({
11
+ stroke: 'none',
12
+ fill: theme.palette.text.primary,
13
+ shapeRendering: 'crispEdges',
14
+ textAnchor: 'middle',
15
+ dominantBaseline: 'middle'
16
+ }));
17
+ export function ChartsNoDataOverlay(props) {
18
+ const {
19
+ message
20
+ } = props,
21
+ other = _objectWithoutPropertiesLoose(props, _excluded);
22
+ const {
23
+ top,
24
+ left,
25
+ height,
26
+ width
27
+ } = useDrawingArea();
28
+ return /*#__PURE__*/_jsx(StyledText, _extends({
29
+ x: left + width / 2,
30
+ y: top + height / 2
31
+ }, other, {
32
+ children: message ?? 'No data to display'
33
+ }));
34
+ }
@@ -0,0 +1,31 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import { ChartsLoadingOverlay } from './ChartsLoadingOverlay';
4
+ import { useSeries } from '../hooks/useSeries';
5
+ import { ChartsNoDataOverlay } from './ChartsNoDataOverlay';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ export function useNoData() {
8
+ const seriesPerType = useSeries();
9
+ return Object.values(seriesPerType).every(seriesOfGivenType => {
10
+ if (!seriesOfGivenType) {
11
+ return true;
12
+ }
13
+ const {
14
+ series,
15
+ seriesOrder
16
+ } = seriesOfGivenType;
17
+ return seriesOrder.every(seriesId => series[seriesId].data.length === 0);
18
+ });
19
+ }
20
+ export function ChartsOverlay(props) {
21
+ const noData = useNoData();
22
+ if (props.loading) {
23
+ const LoadingOverlay = props.slots?.loadingOverlay ?? ChartsLoadingOverlay;
24
+ return /*#__PURE__*/_jsx(LoadingOverlay, _extends({}, props.slotProps?.loadingOverlay));
25
+ }
26
+ if (noData) {
27
+ const NoDataOverlay = props.slots?.noDataOverlay ?? ChartsNoDataOverlay;
28
+ return /*#__PURE__*/_jsx(NoDataOverlay, _extends({}, props.slotProps?.noDataOverlay));
29
+ }
30
+ return null;
31
+ }
@@ -0,0 +1,3 @@
1
+ export { ChartsOverlay } from './ChartsOverlay';
2
+ export { ChartsLoadingOverlay } from './ChartsLoadingOverlay';
3
+ export { ChartsNoDataOverlay } from './ChartsNoDataOverlay';
@@ -52,7 +52,7 @@ process.env.NODE_ENV !== "production" ? ChartsReferenceLine.propTypes = {
52
52
  */
53
53
  lineStyle: PropTypes.object,
54
54
  /**
55
- * Additional space arround the label in px.
55
+ * Additional space around the label in px.
56
56
  * Can be a number or an object `{ x, y }` to distinguish space with the reference line and space with axes.
57
57
  * @default 5
58
58
  */
@@ -106,7 +106,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxisTooltipContent.propTypes = {
106
106
  value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
107
107
  })
108
108
  }),
109
- axisValue: PropTypes.any,
109
+ axisValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]),
110
110
  classes: PropTypes.object,
111
111
  dataIndex: PropTypes.number,
112
112
  series: PropTypes.arrayOf(PropTypes.object),
@@ -113,7 +113,7 @@ process.env.NODE_ENV !== "production" ? ChartsTooltip.propTypes = {
113
113
  // | To update them edit the TypeScript types and run "yarn proptypes" |
114
114
  // ----------------------------------------------------------------------
115
115
  /**
116
- * Component to override the tooltip content when triger is set to 'axis'.
116
+ * Component to override the tooltip content when trigger is set to 'axis'.
117
117
  * @deprecated Use slots.axisContent instead
118
118
  */
119
119
  axisContent: PropTypes.elementType,
@@ -122,7 +122,7 @@ process.env.NODE_ENV !== "production" ? ChartsTooltip.propTypes = {
122
122
  */
123
123
  classes: PropTypes.object,
124
124
  /**
125
- * Component to override the tooltip content when triger is set to 'item'.
125
+ * Component to override the tooltip content when trigger is set to 'item'.
126
126
  * @deprecated Use slots.itemContent instead
127
127
  */
128
128
  itemContent: PropTypes.elementType,
@@ -100,7 +100,7 @@ process.env.NODE_ENV !== "production" ? DefaultChartsAxisTooltipContent.propType
100
100
  /**
101
101
  * The value associated to the current mouse position.
102
102
  */
103
- axisValue: PropTypes.any.isRequired,
103
+ axisValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]),
104
104
  /**
105
105
  * Override or extend the styles applied to the component.
106
106
  */
@@ -203,6 +203,13 @@ function ChartsXAxis(inProps) {
203
203
  },
204
204
  ownerState: {}
205
205
  });
206
+ const domain = xScale.domain();
207
+ if (domain.length === 0 || domain[0] === domain[1]) {
208
+ // Skip axis rendering if
209
+ // - the data is empty (for band and point axis)
210
+ // - No data is associated to the axis (other scale types)
211
+ return null;
212
+ }
206
213
  return /*#__PURE__*/_jsxs(AxisRoot, {
207
214
  transform: `translate(0, ${position === 'bottom' ? top + height : top})`,
208
215
  className: classes.root,
@@ -138,6 +138,13 @@ function ChartsYAxis(inProps) {
138
138
  },
139
139
  ownerState: {}
140
140
  });
141
+ const domain = yScale.domain();
142
+ if (domain.length === 0 || domain[0] === domain[1]) {
143
+ // Skip axis rendering if
144
+ // - the data is empty (for band and point axis)
145
+ // - No data is associated to the axis (other scale types)
146
+ return null;
147
+ }
141
148
  return /*#__PURE__*/_jsxs(AxisRoot, {
142
149
  transform: `translate(${position === 'right' ? left + width : left}, 0)`,
143
150
  className: classes.root,
@@ -84,7 +84,7 @@ process.env.NODE_ENV !== "production" ? Gauge.propTypes = {
84
84
  */
85
85
  height: PropTypes.number,
86
86
  /**
87
- * The radius between circle center and the begining of the arc.
87
+ * The radius between circle center and the beginning of the arc.
88
88
  * Can be a number (in px) or a string with a percentage such as '50%'.
89
89
  * The '100%' is the maximal radius that fit into the drawing area.
90
90
  * @default '80%'
@@ -145,7 +145,7 @@ process.env.NODE_ENV !== "production" ? GaugeContainer.propTypes = {
145
145
  */
146
146
  height: PropTypes.number,
147
147
  /**
148
- * The radius between circle center and the begining of the arc.
148
+ * The radius between circle center and the beginning of the arc.
149
149
  * Can be a number (in px) or a string with a percentage such as '50%'.
150
150
  * The '100%' is the maximal radius that fit into the drawing area.
151
151
  * @default '80%'
@@ -48,7 +48,7 @@ export function GaugeProvider(props) {
48
48
  let cy = top + innerCy;
49
49
  const maxRadius = getAvailableRadius(innerCx, innerCy, width, height, ratios);
50
50
 
51
- // If the center is not defined, after computation of the available radius, udpate the center to use the remaining space.
51
+ // If the center is not defined, after computation of the available radius, update the center to use the remaining space.
52
52
  if (cxParam === undefined) {
53
53
  const usedWidth = maxRadius * (ratios.maxX - ratios.minX);
54
54
  cx = left + (width - usedWidth) / 2 + ratios.cx * usedWidth;
@@ -7,7 +7,7 @@ function getPoint(angle) {
7
7
  }
8
8
 
9
9
  /**
10
- * Retruns the ratio of the arc bounding box and its center.
10
+ * Returns the ratio of the arc bounding box and its center.
11
11
  * @param startAngle The start angle (in deg)
12
12
  * @param endAngle The end angle (in deg)
13
13
  */
@@ -20,9 +20,9 @@ export function getArcRatios(startAngle, endAngle) {
20
20
  const maxAngle = Math.max(startAngle, endAngle);
21
21
  const initialAngle = Math.floor(minAngle / 90) * 90;
22
22
  for (let step = 1; step <= 4; step += 1) {
23
- const cartinalAngle = initialAngle + step * 90;
24
- if (cartinalAngle < maxAngle) {
25
- points.push(getPoint(cartinalAngle));
23
+ const cardinalAngle = initialAngle + step * 90;
24
+ if (cardinalAngle < maxAngle) {
25
+ points.push(getPoint(cardinalAngle));
26
26
  }
27
27
  }
28
28
  const minX = Math.min(...points.map(([x]) => x));
@@ -15,6 +15,7 @@ import { ChartsClipPath } from '../ChartsClipPath';
15
15
  import { LineHighlightPlot } from './LineHighlightPlot';
16
16
  import { ChartsGrid } from '../ChartsGrid';
17
17
  import { ChartsOnAxisClickHandler } from '../ChartsOnAxisClickHandler';
18
+ import { ChartsOverlay } from '../ChartsOverlay/ChartsOverlay';
18
19
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
20
  /**
20
21
  * Demos:
@@ -55,7 +56,8 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
55
56
  children,
56
57
  slots,
57
58
  slotProps,
58
- skipAnimation
59
+ skipAnimation,
60
+ loading
59
61
  } = props;
60
62
  const id = useId();
61
63
  const clipPathId = `${id}-clip-path`;
@@ -97,6 +99,10 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
97
99
  slotProps: slotProps,
98
100
  onItemClick: onLineClick,
99
101
  skipAnimation: skipAnimation
102
+ }), /*#__PURE__*/_jsx(ChartsOverlay, {
103
+ loading: loading,
104
+ slots: slots,
105
+ slotProps: slotProps
100
106
  })]
101
107
  }), /*#__PURE__*/_jsx(ChartsAxis, {
102
108
  topAxis: topAxis,
@@ -116,7 +122,7 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
116
122
  }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
117
123
  slots: slots,
118
124
  slotProps: slotProps
119
- })), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
125
+ })), !loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
120
126
  slots: slots,
121
127
  slotProps: slotProps
122
128
  })), /*#__PURE__*/_jsx(ChartsClipPath, {
@@ -197,6 +203,10 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
197
203
  slotProps: PropTypes.object,
198
204
  slots: PropTypes.object
199
205
  }),
206
+ /**
207
+ * If `true`, a loading overlay is displayed.
208
+ */
209
+ loading: PropTypes.bool,
200
210
  /**
201
211
  * The margin between the SVG and the drawing area.
202
212
  * It's used for leaving some space for extra information such as the x- and y-axis or legend.
@@ -39,7 +39,7 @@ const PieArcLabelRoot = styled(animated.text, {
39
39
  }));
40
40
  /**
41
41
  * Helper to compute label position.
42
- * It's not an inline function because we need it in inerpolation.
42
+ * It's not an inline function because we need it in interpolation.
43
43
  */
44
44
  const getLabelPosition = (formattedArcLabel, variable) => (startAngle, endAngle, padAngle, arcLabelRadius, cornerRadius) => {
45
45
  if (!formattedArcLabel) {
@@ -129,7 +129,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
129
129
  value: PropTypes.number.isRequired
130
130
  })).isRequired,
131
131
  /**
132
- * Override the arc attibutes when it is faded.
132
+ * Override the arc attributes when it is faded.
133
133
  * @default { additionalRadius: -5 }
134
134
  */
135
135
  faded: PropTypes.shape({
@@ -142,7 +142,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
142
142
  paddingAngle: PropTypes.number
143
143
  }),
144
144
  /**
145
- * Override the arc attibutes when it is highlighted.
145
+ * Override the arc attributes when it is highlighted.
146
146
  */
147
147
  highlighted: PropTypes.shape({
148
148
  additionalRadius: PropTypes.number,
@@ -159,7 +159,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
159
159
  }),
160
160
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
161
161
  /**
162
- * The radius between circle center and the begining of the arc.
162
+ * The radius between circle center and the beginning of the arc.
163
163
  * @default 0
164
164
  */
165
165
  innerRadius: PropTypes.number,
@@ -109,7 +109,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
109
109
  value: PropTypes.number.isRequired
110
110
  })).isRequired,
111
111
  /**
112
- * Override the arc attibutes when it is faded.
112
+ * Override the arc attributes when it is faded.
113
113
  * @default { additionalRadius: -5 }
114
114
  */
115
115
  faded: PropTypes.shape({
@@ -122,7 +122,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
122
122
  paddingAngle: PropTypes.number
123
123
  }),
124
124
  /**
125
- * Override the arc attibutes when it is highlighted.
125
+ * Override the arc attributes when it is highlighted.
126
126
  */
127
127
  highlighted: PropTypes.shape({
128
128
  additionalRadius: PropTypes.number,
@@ -139,7 +139,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
139
139
  }),
140
140
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
141
141
  /**
142
- * The radius between circle center and the begining of the arc.
142
+ * The radius between circle center and the beginning of the arc.
143
143
  * @default 0
144
144
  */
145
145
  innerRadius: PropTypes.number,
@@ -9,6 +9,7 @@ import { ChartsLegend } from '../ChartsLegend';
9
9
  import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
10
10
  import { PiePlot } from './PiePlot';
11
11
  import { useIsRTL } from '../internals/useIsRTL';
12
+ import { ChartsOverlay } from '../ChartsOverlay/ChartsOverlay';
12
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
14
  const defaultMargin = {
14
15
  top: 5,
@@ -59,7 +60,8 @@ function PieChart(props) {
59
60
  children,
60
61
  slots,
61
62
  slotProps,
62
- onItemClick
63
+ onItemClick,
64
+ loading
63
65
  } = props;
64
66
  const isRTL = useIsRTL();
65
67
  const margin = _extends({}, isRTL ? defaultRTLMargin : defaultMargin, marginProps);
@@ -98,10 +100,17 @@ function PieChart(props) {
98
100
  slotProps: slotProps,
99
101
  onItemClick: onItemClick,
100
102
  skipAnimation: skipAnimation
103
+ }), /*#__PURE__*/_jsx(ChartsOverlay, {
104
+ loading: loading,
105
+ slots: slots,
106
+ slotProps: slotProps
101
107
  }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
102
108
  slots: slots,
103
109
  slotProps: slotProps
104
- })), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip)), children]
110
+ })), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), !loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltip, {
111
+ slots: slots,
112
+ slotProps: slotProps
113
+ })), children]
105
114
  });
106
115
  }
107
116
  process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
@@ -168,6 +177,10 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
168
177
  slotProps: PropTypes.object,
169
178
  slots: PropTypes.object
170
179
  }),
180
+ /**
181
+ * If `true`, a loading overlay is displayed.
182
+ */
183
+ loading: PropTypes.bool,
171
184
  /**
172
185
  * The margin between the SVG and the drawing area.
173
186
  * It's used for leaving some space for extra information such as the x- and y-axis or legend.
@@ -6,6 +6,7 @@ import { ResponsiveChartContainer } from '../ResponsiveChartContainer';
6
6
  import { ChartsAxis } from '../ChartsAxis';
7
7
  import { ChartsTooltip } from '../ChartsTooltip';
8
8
  import { ChartsLegend } from '../ChartsLegend';
9
+ import { ChartsOverlay } from '../ChartsOverlay/ChartsOverlay';
9
10
  import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
10
11
  import { ChartsVoronoiHandler } from '../ChartsVoronoiHandler/ChartsVoronoiHandler';
11
12
  import { ChartsGrid } from '../ChartsGrid';
@@ -45,7 +46,8 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
45
46
  onItemClick,
46
47
  children,
47
48
  slots,
48
- slotProps
49
+ slotProps,
50
+ loading
49
51
  } = props;
50
52
  return /*#__PURE__*/_jsx(ResponsiveChartContainer, {
51
53
  ref: ref,
@@ -78,13 +80,17 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
78
80
  slots: slots,
79
81
  slotProps: slotProps,
80
82
  onItemClick: disableVoronoi ? onItemClick : undefined
83
+ }), /*#__PURE__*/_jsx(ChartsOverlay, {
84
+ loading: loading,
85
+ slots: slots,
86
+ slotProps: slotProps
81
87
  }), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legend, {
82
88
  slots: slots,
83
89
  slotProps: slotProps
84
90
  })), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({
85
91
  x: "none",
86
92
  y: "none"
87
- }, axisHighlight)), /*#__PURE__*/_jsx(ChartsTooltip, _extends({
93
+ }, axisHighlight)), !loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({
88
94
  trigger: "item"
89
95
  }, tooltip)), children]
90
96
  })
@@ -164,6 +170,10 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
164
170
  slotProps: PropTypes.object,
165
171
  slots: PropTypes.object
166
172
  }),
173
+ /**
174
+ * If `true`, a loading overlay is displayed.
175
+ */
176
+ loading: PropTypes.bool,
167
177
  /**
168
178
  * The margin between the SVG and the drawing area.
169
179
  * It's used for leaving some space for extra information such as the x- and y-axis or legend.
@@ -50,7 +50,7 @@ const formatSeries = (series, colors, dataset) => {
50
50
  seriesGroups[type].seriesOrder.push(id);
51
51
  });
52
52
  const formattedSeries = {};
53
- // Apply formater on a type group
53
+ // Apply formatter on a type group
54
54
  Object.keys(seriesTypeFormatter).forEach(type => {
55
55
  if (seriesGroups[type] !== undefined) {
56
56
  formattedSeries[type] = seriesTypeFormatter[type]?.(seriesGroups[type], dataset) ?? seriesGroups[type];
@@ -5,7 +5,7 @@ import { useIsomorphicLayoutEffect, Globals } from '@react-spring/web';
5
5
  * set skipAnimations to the value of the user's
6
6
  * `prefers-reduced-motion` query.
7
7
  *
8
- * The return value, post-effect, is the value of their prefered setting
8
+ * The return value, post-effect, is the value of their preferred setting
9
9
  */
10
10
  export const useReducedMotion = () => {
11
11
  // Taken from: https://github.com/pmndrs/react-spring/blob/02ec877bbfab0df46da0e4a47d5f68d3e731206a/packages/shared/src/hooks/useReducedMotion.ts#L13
@@ -3,7 +3,7 @@ import { CartesianContext } from '../context/CartesianContextProvider';
3
3
  import { isBandScale } from '../internals/isBandScale';
4
4
  /**
5
5
  * For a given scale return a function that map value to their position.
6
- * Usefull when dealing with specific scale such as band.
6
+ * Useful when dealing with specific scale such as band.
7
7
  * @param scale The scale to use
8
8
  * @returns (value: any) => number
9
9
  */