@mui/x-charts-pro 8.0.0-alpha.12 → 8.0.0-alpha.13

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 (51) hide show
  1. package/BarChartPro/BarChartPro.js +25 -30
  2. package/CHANGELOG.md +299 -0
  3. package/ChartContainerPro/ChartContainerPro.d.ts +1 -1
  4. package/ChartContainerPro/ChartContainerPro.js +1 -1
  5. package/ChartContainerPro/useChartContainerProProps.js +3 -1
  6. package/ChartDataProviderPro/ChartDataProviderPro.d.ts +1 -1
  7. package/ChartDataProviderPro/ChartDataProviderPro.js +3 -2
  8. package/Heatmap/Heatmap.d.ts +5 -4
  9. package/Heatmap/Heatmap.js +37 -52
  10. package/LineChartPro/LineChartPro.js +25 -30
  11. package/ScatterChartPro/ScatterChartPro.js +25 -30
  12. package/esm/BarChartPro/BarChartPro.js +25 -30
  13. package/esm/ChartContainerPro/ChartContainerPro.d.ts +1 -1
  14. package/esm/ChartContainerPro/ChartContainerPro.js +1 -1
  15. package/esm/ChartContainerPro/useChartContainerProProps.js +3 -1
  16. package/esm/ChartDataProviderPro/ChartDataProviderPro.d.ts +1 -1
  17. package/esm/ChartDataProviderPro/ChartDataProviderPro.js +3 -2
  18. package/esm/Heatmap/Heatmap.d.ts +5 -4
  19. package/esm/Heatmap/Heatmap.js +37 -52
  20. package/esm/LineChartPro/LineChartPro.js +25 -30
  21. package/esm/ScatterChartPro/ScatterChartPro.js +25 -30
  22. package/esm/index.js +1 -1
  23. package/esm/internals/plugins/useChartProZoom/useChartProZoom.js +63 -12
  24. package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +26 -24
  25. package/esm/internals/plugins/useChartProZoom/useChartProZoom.types.d.ts +12 -3
  26. package/esm/internals/utils/releaseInfo.js +1 -1
  27. package/esm/models/seriesType/heatmap.d.ts +2 -2
  28. package/index.js +1 -1
  29. package/internals/plugins/useChartProZoom/useChartProZoom.js +63 -12
  30. package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +26 -24
  31. package/internals/plugins/useChartProZoom/useChartProZoom.types.d.ts +12 -3
  32. package/internals/utils/releaseInfo.js +1 -1
  33. package/models/seriesType/heatmap.d.ts +2 -2
  34. package/modern/BarChartPro/BarChartPro.js +25 -30
  35. package/modern/ChartContainerPro/ChartContainerPro.d.ts +1 -1
  36. package/modern/ChartContainerPro/ChartContainerPro.js +1 -1
  37. package/modern/ChartContainerPro/useChartContainerProProps.js +3 -1
  38. package/modern/ChartDataProviderPro/ChartDataProviderPro.d.ts +1 -1
  39. package/modern/ChartDataProviderPro/ChartDataProviderPro.js +3 -2
  40. package/modern/Heatmap/Heatmap.d.ts +5 -4
  41. package/modern/Heatmap/Heatmap.js +37 -52
  42. package/modern/LineChartPro/LineChartPro.js +25 -30
  43. package/modern/ScatterChartPro/ScatterChartPro.js +25 -30
  44. package/modern/index.js +1 -1
  45. package/modern/internals/plugins/useChartProZoom/useChartProZoom.js +63 -12
  46. package/modern/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +26 -24
  47. package/modern/internals/plugins/useChartProZoom/useChartProZoom.types.d.ts +12 -3
  48. package/modern/internals/utils/releaseInfo.js +1 -1
  49. package/modern/models/seriesType/heatmap.d.ts +2 -2
  50. package/package.json +5 -5
  51. package/tsconfig.build.tsbuildinfo +1 -1
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
4
  import _extends from "@babel/runtime/helpers/esm/extends";
5
- const _excluded = ["initialZoom", "onZoomChange", "apiRef"];
5
+ const _excluded = ["initialZoom", "zoomData", "onZoomChange", "apiRef"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import { useThemeProps } from '@mui/material/styles';
@@ -84,6 +84,7 @@ const BarChartPro = /*#__PURE__*/React.forwardRef(function BarChartPro(inProps,
84
84
  });
85
85
  const {
86
86
  initialZoom,
87
+ zoomData,
87
88
  onZoomChange,
88
89
  apiRef
89
90
  } = props,
@@ -106,6 +107,7 @@ const BarChartPro = /*#__PURE__*/React.forwardRef(function BarChartPro(inProps,
106
107
  chartsSurfaceProps
107
108
  } = useChartContainerProProps(_extends({}, chartContainerProps, {
108
109
  initialZoom,
110
+ zoomData,
109
111
  onZoomChange,
110
112
  apiRef,
111
113
  plugins: BAR_CHART_PRO_PLUGINS
@@ -153,12 +155,6 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
153
155
  * Defines the border radius of the bar element.
154
156
  */
155
157
  borderRadius: PropTypes.number,
156
- /**
157
- * Indicate which axis to display the bottom of the charts.
158
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
159
- * @default xAxisIds[0] The id of the first provided axis
160
- */
161
- bottomAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
162
158
  children: PropTypes.node,
163
159
  className: PropTypes.string,
164
160
  /**
@@ -207,6 +203,7 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
207
203
  id: PropTypes.string,
208
204
  /**
209
205
  * The list of zoom data related to each axis.
206
+ * Used to initialize the zoom in a specific configuration without controlling it.
210
207
  */
211
208
  initialZoom: PropTypes.arrayOf(PropTypes.shape({
212
209
  axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
@@ -218,12 +215,6 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
218
215
  * @default 'vertical'
219
216
  */
220
217
  layout: PropTypes.oneOf(['horizontal', 'vertical']),
221
- /**
222
- * Indicate which axis to display the left of the charts.
223
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
224
- * @default yAxisIds[0] The id of the first provided axis
225
- */
226
- leftAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
227
218
  /**
228
219
  * If `true`, a loading overlay is displayed.
229
220
  * @default false
@@ -232,14 +223,15 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
232
223
  /**
233
224
  * The margin between the SVG and the drawing area.
234
225
  * It's used for leaving some space for extra information such as the x- and y-axis or legend.
235
- * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
226
+ *
227
+ * Accepts a `number` to be used on all sides or an object with the optional properties: `top`, `bottom`, `left`, and `right`.
236
228
  */
237
- margin: PropTypes.shape({
229
+ margin: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
238
230
  bottom: PropTypes.number,
239
231
  left: PropTypes.number,
240
232
  right: PropTypes.number,
241
233
  top: PropTypes.number
242
- }),
234
+ })]),
243
235
  /**
244
236
  * The function called for onClick events.
245
237
  * The second argument contains information about all line/bar elements at the current mouse position.
@@ -265,12 +257,6 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
265
257
  * @param {ZoomData[]} zoomData Updated zoom data.
266
258
  */
267
259
  onZoomChange: PropTypes.func,
268
- /**
269
- * Indicate which axis to display the right of the charts.
270
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
271
- * @default null
272
- */
273
- rightAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
274
260
  /**
275
261
  * The series to display in the bar chart.
276
262
  * An array of [[BarSeriesType]] objects.
@@ -294,12 +280,6 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
294
280
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
295
281
  theme: PropTypes.oneOf(['dark', 'light']),
296
282
  title: PropTypes.string,
297
- /**
298
- * Indicate which axis to display the top of the charts.
299
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
300
- * @default null
301
- */
302
- topAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
303
283
  /**
304
284
  * The width of the chart in px. If not defined, it takes the width of the parent element.
305
285
  */
@@ -310,6 +290,7 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
310
290
  * An array of [[AxisConfig]] objects.
311
291
  */
312
292
  xAxis: PropTypes.arrayOf(PropTypes.shape({
293
+ axis: PropTypes.oneOf(['x']),
313
294
  classes: PropTypes.object,
314
295
  colorMap: PropTypes.oneOfType([PropTypes.shape({
315
296
  colors: PropTypes.arrayOf(PropTypes.string).isRequired,
@@ -332,13 +313,15 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
332
313
  disableTicks: PropTypes.bool,
333
314
  domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
334
315
  fill: PropTypes.string,
316
+ height: PropTypes.number,
335
317
  hideTooltip: PropTypes.bool,
336
318
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
337
319
  label: PropTypes.string,
338
320
  labelStyle: PropTypes.object,
339
321
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
340
322
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
341
- position: PropTypes.oneOf(['bottom', 'top']),
323
+ offset: PropTypes.number,
324
+ position: PropTypes.oneOf(['bottom', 'none', 'top']),
342
325
  reverse: PropTypes.bool,
343
326
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
344
327
  slotProps: PropTypes.object,
@@ -347,6 +330,7 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
347
330
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
348
331
  tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
349
332
  tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
333
+ tickLabelMinGap: PropTypes.number,
350
334
  tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
351
335
  tickLabelStyle: PropTypes.object,
352
336
  tickMaxStep: PropTypes.number,
@@ -371,6 +355,7 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
371
355
  * An array of [[AxisConfig]] objects.
372
356
  */
373
357
  yAxis: PropTypes.arrayOf(PropTypes.shape({
358
+ axis: PropTypes.oneOf(['y']),
374
359
  classes: PropTypes.object,
375
360
  colorMap: PropTypes.oneOfType([PropTypes.shape({
376
361
  colors: PropTypes.arrayOf(PropTypes.string).isRequired,
@@ -399,7 +384,8 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
399
384
  labelStyle: PropTypes.object,
400
385
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
401
386
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
402
- position: PropTypes.oneOf(['left', 'right']),
387
+ offset: PropTypes.number,
388
+ position: PropTypes.oneOf(['left', 'none', 'right']),
403
389
  reverse: PropTypes.bool,
404
390
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
405
391
  slotProps: PropTypes.object,
@@ -416,6 +402,7 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
416
402
  tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
417
403
  tickSize: PropTypes.number,
418
404
  valueFormatter: PropTypes.func,
405
+ width: PropTypes.number,
419
406
  zoom: PropTypes.oneOfType([PropTypes.shape({
420
407
  filterMode: PropTypes.oneOf(['discard', 'keep']),
421
408
  maxEnd: PropTypes.number,
@@ -450,6 +437,14 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
450
437
  id: PropTypes.string,
451
438
  max: PropTypes.number,
452
439
  min: PropTypes.number
440
+ })),
441
+ /**
442
+ * The list of zoom data related to each axis.
443
+ */
444
+ zoomData: PropTypes.arrayOf(PropTypes.shape({
445
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
446
+ end: PropTypes.number.isRequired,
447
+ start: PropTypes.number.isRequired
453
448
  }))
454
449
  } : void 0;
455
450
  export { BarChartPro };
@@ -27,7 +27,7 @@ type ChartContainerProComponent = <TSeries extends ChartSeriesType = ChartSeries
27
27
  * xAxis={[{ data: ["A", "B"], scaleType: "band", id: "x-axis" }]}
28
28
  * >
29
29
  * <BarPlot />
30
- * <ChartsXAxis position="bottom" axisId="x-axis" />
30
+ * <ChartsXAxis axisId="x-axis" />
31
31
  * </ChartContainerPro>
32
32
  * ```
33
33
  */
@@ -27,7 +27,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
27
27
  * xAxis={[{ data: ["A", "B"], scaleType: "band", id: "x-axis" }]}
28
28
  * >
29
29
  * <BarPlot />
30
- * <ChartsXAxis position="bottom" axisId="x-axis" />
30
+ * <ChartsXAxis axisId="x-axis" />
31
31
  * </ChartContainerPro>
32
32
  * ```
33
33
  */
@@ -2,13 +2,14 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- const _excluded = ["initialZoom", "onZoomChange", "plugins", "apiRef"];
5
+ const _excluded = ["initialZoom", "zoomData", "onZoomChange", "plugins", "apiRef"];
6
6
  import { useChartContainerProps } from '@mui/x-charts/internals';
7
7
  import { ALL_PLUGINS } from "../internals/plugins/allPlugins.js";
8
8
  export const useChartContainerProProps = (props, ref) => {
9
9
  const _ref = props,
10
10
  {
11
11
  initialZoom,
12
+ zoomData,
12
13
  onZoomChange,
13
14
  plugins,
14
15
  apiRef
@@ -21,6 +22,7 @@ export const useChartContainerProProps = (props, ref) => {
21
22
  } = useChartContainerProps(baseProps, ref);
22
23
  const chartDataProviderProProps = _extends({}, chartDataProviderProps, {
23
24
  initialZoom,
25
+ zoomData,
24
26
  onZoomChange,
25
27
  apiRef,
26
28
  plugins: plugins ?? ALL_PLUGINS
@@ -24,7 +24,7 @@ export type ChartDataProviderProProps<TSeries extends ChartSeriesType = ChartSer
24
24
  * >
25
25
  * <ChartsSurface>
26
26
  * <BarPlot />
27
- * <ChartsXAxis position="bottom" axisId="x-axis" />
27
+ * <ChartsXAxis axisId="x-axis" />
28
28
  * </ChartsSurface>
29
29
  * {'Custom Legend Component'}
30
30
  * </ChartDataProviderPro>
@@ -32,7 +32,7 @@ const packageIdentifier = 'x-charts-pro';
32
32
  * >
33
33
  * <ChartsSurface>
34
34
  * <BarPlot />
35
- * <ChartsXAxis position="bottom" axisId="x-axis" />
35
+ * <ChartsXAxis axisId="x-axis" />
36
36
  * </ChartsSurface>
37
37
  * {'Custom Legend Component'}
38
38
  * </ChartDataProviderPro>
@@ -82,7 +82,8 @@ process.env.NODE_ENV !== "production" ? ChartDataProviderPro.propTypes = {
82
82
  /**
83
83
  * The margin between the SVG and the drawing area.
84
84
  * It's used for leaving some space for extra information such as the x- and y-axis or legend.
85
- * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
85
+ *
86
+ * Accepts a `number` to be used on all sides or an object with the optional properties: `top`, `bottom`, `left`, and `right`.
86
87
  */
87
88
  margin: PropTypes.any,
88
89
  /**
@@ -8,6 +8,7 @@ import { ChartContainerProProps } from "../ChartContainerPro/index.js";
8
8
  import { HeatmapSeriesType } from "../models/seriesType/heatmap.js";
9
9
  import { HeatmapTooltipProps } from "./HeatmapTooltip.js";
10
10
  import { HeatmapItemSlotProps, HeatmapItemSlots } from "./HeatmapItem.js";
11
+ import { HeatmapPluginsSignatures } from "./Heatmap.plugins.js";
11
12
  export interface HeatmapSlots extends ChartsAxisSlots, ChartsOverlaySlots, HeatmapItemSlots {
12
13
  /**
13
14
  * Custom component for the tooltip popper.
@@ -18,24 +19,24 @@ export interface HeatmapSlots extends ChartsAxisSlots, ChartsOverlaySlots, Heatm
18
19
  export interface HeatmapSlotProps extends ChartsAxisSlotProps, ChartsOverlaySlotProps, HeatmapItemSlotProps {
19
20
  tooltip?: Partial<HeatmapTooltipProps>;
20
21
  }
21
- export interface HeatmapProps extends Omit<ChartContainerProProps, 'series' | 'plugins' | 'xAxis' | 'yAxis' | 'zoom' | 'onZoomChange' | 'skipAnimation'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
22
+ export interface HeatmapProps extends Omit<ChartContainerProProps<'heatmap', HeatmapPluginsSignatures>, 'series' | 'plugins' | 'xAxis' | 'yAxis' | 'skipAnimation'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
22
23
  /**
23
24
  * The configuration of the x-axes.
24
25
  * If not provided, a default axis config is used.
25
26
  * An array of [[AxisConfig]] objects.
26
27
  */
27
- xAxis: MakeOptional<AxisConfig<'band', any, ChartsXAxisProps>, 'id' | 'scaleType'>[];
28
+ xAxis: Readonly<MakeOptional<AxisConfig<'band', any, ChartsXAxisProps>, 'id' | 'scaleType'>[]>;
28
29
  /**
29
30
  * The configuration of the y-axes.
30
31
  * If not provided, a default axis config is used.
31
32
  * An array of [[AxisConfig]] objects.
32
33
  */
33
- yAxis: MakeOptional<AxisConfig<'band', any, ChartsYAxisProps>, 'id' | 'scaleType'>[];
34
+ yAxis: Readonly<MakeOptional<AxisConfig<'band', any, ChartsYAxisProps>, 'id' | 'scaleType'>[]>;
34
35
  /**
35
36
  * The series to display in the bar chart.
36
37
  * An array of [[HeatmapSeriesType]] objects.
37
38
  */
38
- series: MakeOptional<HeatmapSeriesType, 'type'>[];
39
+ series: Readonly<MakeOptional<HeatmapSeriesType, 'type'>[]>;
39
40
  /**
40
41
  * The configuration of the tooltip.
41
42
  * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
@@ -9,6 +9,7 @@ import { interpolateRgbBasis } from '@mui/x-charts-vendor/d3-interpolate';
9
9
  import { ChartsAxis } from '@mui/x-charts/ChartsAxis';
10
10
  import { ChartsClipPath } from '@mui/x-charts/ChartsClipPath';
11
11
  import { ChartsOverlay } from '@mui/x-charts/ChartsOverlay';
12
+ import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '@mui/x-charts/constants';
12
13
  import { ChartContainerPro } from "../ChartContainerPro/index.js";
13
14
  import { HeatmapPlot } from "./HeatmapPlot.js";
14
15
  import { seriesConfig as heatmapSeriesConfig } from "./seriesConfig/index.js";
@@ -20,6 +21,16 @@ const defaultColorMap = interpolateRgbBasis(['#f7fcf0', '#e0f3db', '#ccebc5', '#
20
21
  const seriesConfig = {
21
22
  heatmap: heatmapSeriesConfig
22
23
  };
24
+ function getDefaultDataForAxis(series, dimension) {
25
+ if (series?.[0]?.data === undefined || series[0].data.length === 0) {
26
+ return [];
27
+ }
28
+ return Array.from({
29
+ length: Math.max(...series[0].data.map(dataPoint => dataPoint[dimension])) + 1
30
+ }, (_, index) => index);
31
+ }
32
+ const getDefaultDataForXAxis = series => getDefaultDataForAxis(series, 0);
33
+ const getDefaultDataForYAxis = series => getDefaultDataForAxis(series, 1);
23
34
  const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(inProps, ref) {
24
35
  const props = useThemeProps({
25
36
  props: inProps,
@@ -36,10 +47,6 @@ const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(inProps, ref) {
36
47
  colors,
37
48
  dataset,
38
49
  sx,
39
- topAxis,
40
- leftAxis,
41
- rightAxis,
42
- bottomAxis,
43
50
  onAxisClick,
44
51
  children,
45
52
  slots,
@@ -50,14 +57,22 @@ const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(inProps, ref) {
50
57
  } = props;
51
58
  const id = useId();
52
59
  const clipPathId = `${id}-clip-path`;
53
- const defaultizedXAxis = React.useMemo(() => xAxis.map(axis => _extends({
60
+ const defaultizedXAxis = React.useMemo(() => (xAxis && xAxis.length > 0 ? xAxis : [{
61
+ id: DEFAULT_X_AXIS_KEY
62
+ }]).map(axis => _extends({
54
63
  scaleType: 'band',
55
64
  categoryGapRatio: 0
56
- }, axis)), [xAxis]);
57
- const defaultizedYAxis = React.useMemo(() => yAxis.map(axis => _extends({
65
+ }, axis, {
66
+ data: axis.data ?? getDefaultDataForXAxis(series)
67
+ })), [series, xAxis]);
68
+ const defaultizedYAxis = React.useMemo(() => (yAxis && yAxis.length > 0 ? yAxis : [{
69
+ id: DEFAULT_Y_AXIS_KEY
70
+ }]).map(axis => _extends({
58
71
  scaleType: 'band',
59
72
  categoryGapRatio: 0
60
- }, axis)), [yAxis]);
73
+ }, axis, {
74
+ data: axis.data ?? getDefaultDataForYAxis(series)
75
+ })), [series, yAxis]);
61
76
  const defaultizedZAxis = React.useMemo(() => zAxis ?? [{
62
77
  colorMap: {
63
78
  type: 'continuous',
@@ -98,10 +113,6 @@ const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(inProps, ref) {
98
113
  slotProps: slotProps
99
114
  })]
100
115
  }), /*#__PURE__*/_jsx(ChartsAxis, {
101
- topAxis: topAxis,
102
- leftAxis: leftAxis,
103
- rightAxis: rightAxis,
104
- bottomAxis: bottomAxis,
105
116
  slots: slots,
106
117
  slotProps: slotProps
107
118
  }), !loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, slotProps?.tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, {
@@ -115,16 +126,8 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
115
126
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
116
127
  // ----------------------------------------------------------------------
117
128
  apiRef: PropTypes.shape({
118
- current: PropTypes.shape({
119
- setZoomData: PropTypes.func.isRequired
120
- })
129
+ current: PropTypes.object
121
130
  }),
122
- /**
123
- * Indicate which axis to display the bottom of the charts.
124
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
125
- * @default xAxisIds[0] The id of the first provided axis
126
- */
127
- bottomAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
128
131
  children: PropTypes.node,
129
132
  className: PropTypes.string,
130
133
  /**
@@ -160,20 +163,6 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
160
163
  * If you don't provide this prop. It falls back to a randomly generated id.
161
164
  */
162
165
  id: PropTypes.string,
163
- /**
164
- * The list of zoom data related to each axis.
165
- */
166
- initialZoom: PropTypes.arrayOf(PropTypes.shape({
167
- axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
168
- end: PropTypes.number.isRequired,
169
- start: PropTypes.number.isRequired
170
- })),
171
- /**
172
- * Indicate which axis to display the left of the charts.
173
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
174
- * @default yAxisIds[0] The id of the first provided axis
175
- */
176
- leftAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
177
166
  /**
178
167
  * If `true`, a loading overlay is displayed.
179
168
  * @default false
@@ -182,14 +171,15 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
182
171
  /**
183
172
  * The margin between the SVG and the drawing area.
184
173
  * It's used for leaving some space for extra information such as the x- and y-axis or legend.
185
- * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
174
+ *
175
+ * Accepts a `number` to be used on all sides or an object with the optional properties: `top`, `bottom`, `left`, and `right`.
186
176
  */
187
- margin: PropTypes.shape({
177
+ margin: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
188
178
  bottom: PropTypes.number,
189
179
  left: PropTypes.number,
190
180
  right: PropTypes.number,
191
181
  top: PropTypes.number
192
- }),
182
+ })]),
193
183
  /**
194
184
  * The function called for onClick events.
195
185
  * The second argument contains information about all line/bar elements at the current mouse position.
@@ -203,12 +193,6 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
203
193
  * @param {HighlightItemData | null} highlightedItem The newly highlighted item.
204
194
  */
205
195
  onHighlightChange: PropTypes.func,
206
- /**
207
- * Indicate which axis to display the right of the charts.
208
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
209
- * @default null
210
- */
211
- rightAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
212
196
  /**
213
197
  * The series to display in the bar chart.
214
198
  * An array of [[HeatmapSeriesType]] objects.
@@ -237,12 +221,6 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
237
221
  * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
238
222
  */
239
223
  tooltip: PropTypes.object,
240
- /**
241
- * Indicate which axis to display the top of the charts.
242
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
243
- * @default null
244
- */
245
- topAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
246
224
  /**
247
225
  * The width of the chart in px. If not defined, it takes the width of the parent element.
248
226
  */
@@ -253,6 +231,7 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
253
231
  * An array of [[AxisConfig]] objects.
254
232
  */
255
233
  xAxis: PropTypes.arrayOf(PropTypes.shape({
234
+ axis: PropTypes.oneOf(['x']),
256
235
  barGapRatio: PropTypes.number,
257
236
  categoryGapRatio: PropTypes.number,
258
237
  classes: PropTypes.object,
@@ -277,13 +256,15 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
277
256
  disableTicks: PropTypes.bool,
278
257
  domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
279
258
  fill: PropTypes.string,
259
+ height: PropTypes.number,
280
260
  hideTooltip: PropTypes.bool,
281
261
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
282
262
  label: PropTypes.string,
283
263
  labelStyle: PropTypes.object,
284
264
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
285
265
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
286
- position: PropTypes.oneOf(['bottom', 'top']),
266
+ offset: PropTypes.number,
267
+ position: PropTypes.oneOf(['bottom', 'none', 'top']),
287
268
  reverse: PropTypes.bool,
288
269
  scaleType: PropTypes.oneOf(['band']),
289
270
  slotProps: PropTypes.object,
@@ -292,6 +273,7 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
292
273
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
293
274
  tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
294
275
  tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
276
+ tickLabelMinGap: PropTypes.number,
295
277
  tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
296
278
  tickLabelStyle: PropTypes.object,
297
279
  tickMaxStep: PropTypes.number,
@@ -316,6 +298,7 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
316
298
  * An array of [[AxisConfig]] objects.
317
299
  */
318
300
  yAxis: PropTypes.arrayOf(PropTypes.shape({
301
+ axis: PropTypes.oneOf(['y']),
319
302
  barGapRatio: PropTypes.number,
320
303
  categoryGapRatio: PropTypes.number,
321
304
  classes: PropTypes.object,
@@ -346,7 +329,8 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
346
329
  labelStyle: PropTypes.object,
347
330
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
348
331
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
349
- position: PropTypes.oneOf(['left', 'right']),
332
+ offset: PropTypes.number,
333
+ position: PropTypes.oneOf(['left', 'none', 'right']),
350
334
  reverse: PropTypes.bool,
351
335
  scaleType: PropTypes.oneOf(['band']),
352
336
  slotProps: PropTypes.object,
@@ -363,6 +347,7 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
363
347
  tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
364
348
  tickSize: PropTypes.number,
365
349
  valueFormatter: PropTypes.func,
350
+ width: PropTypes.number,
366
351
  zoom: PropTypes.oneOfType([PropTypes.shape({
367
352
  filterMode: PropTypes.oneOf(['discard', 'keep']),
368
353
  maxEnd: PropTypes.number,
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
4
  import _extends from "@babel/runtime/helpers/esm/extends";
5
- const _excluded = ["initialZoom", "onZoomChange", "apiRef"];
5
+ const _excluded = ["initialZoom", "zoomData", "onZoomChange", "apiRef"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import { useThemeProps } from '@mui/material/styles';
@@ -137,6 +137,7 @@ const LineChartPro = /*#__PURE__*/React.forwardRef(function LineChartPro(inProps
137
137
  });
138
138
  const {
139
139
  initialZoom,
140
+ zoomData,
140
141
  onZoomChange,
141
142
  apiRef
142
143
  } = props,
@@ -162,6 +163,7 @@ const LineChartPro = /*#__PURE__*/React.forwardRef(function LineChartPro(inProps
162
163
  chartsSurfaceProps
163
164
  } = useChartContainerProProps(_extends({}, chartContainerProps, {
164
165
  initialZoom,
166
+ zoomData,
165
167
  onZoomChange,
166
168
  apiRef,
167
169
  plugins: LINE_CHART_PRO_PLUGINS
@@ -199,12 +201,6 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
199
201
  x: PropTypes.oneOf(['band', 'line', 'none']),
200
202
  y: PropTypes.oneOf(['band', 'line', 'none'])
201
203
  }),
202
- /**
203
- * Indicate which axis to display the bottom of the charts.
204
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
205
- * @default xAxisIds[0] The id of the first provided axis
206
- */
207
- bottomAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
208
204
  children: PropTypes.node,
209
205
  className: PropTypes.string,
210
206
  /**
@@ -257,18 +253,13 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
257
253
  id: PropTypes.string,
258
254
  /**
259
255
  * The list of zoom data related to each axis.
256
+ * Used to initialize the zoom in a specific configuration without controlling it.
260
257
  */
261
258
  initialZoom: PropTypes.arrayOf(PropTypes.shape({
262
259
  axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
263
260
  end: PropTypes.number.isRequired,
264
261
  start: PropTypes.number.isRequired
265
262
  })),
266
- /**
267
- * Indicate which axis to display the left of the charts.
268
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
269
- * @default yAxisIds[0] The id of the first provided axis
270
- */
271
- leftAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
272
263
  /**
273
264
  * If `true`, a loading overlay is displayed.
274
265
  * @default false
@@ -277,14 +268,15 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
277
268
  /**
278
269
  * The margin between the SVG and the drawing area.
279
270
  * It's used for leaving some space for extra information such as the x- and y-axis or legend.
280
- * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
271
+ *
272
+ * Accepts a `number` to be used on all sides or an object with the optional properties: `top`, `bottom`, `left`, and `right`.
281
273
  */
282
- margin: PropTypes.shape({
274
+ margin: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
283
275
  bottom: PropTypes.number,
284
276
  left: PropTypes.number,
285
277
  right: PropTypes.number,
286
278
  top: PropTypes.number
287
- }),
279
+ })]),
288
280
  /**
289
281
  * Callback fired when an area element is clicked.
290
282
  */
@@ -316,12 +308,6 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
316
308
  * @param {ZoomData[]} zoomData Updated zoom data.
317
309
  */
318
310
  onZoomChange: PropTypes.func,
319
- /**
320
- * Indicate which axis to display the right of the charts.
321
- * Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
322
- * @default null
323
- */
324
- rightAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
325
311
  /**
326
312
  * The series to display in the line chart.
327
313
  * An array of [[LineSeriesType]] objects.
@@ -345,12 +331,6 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
345
331
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
346
332
  theme: PropTypes.oneOf(['dark', 'light']),
347
333
  title: PropTypes.string,
348
- /**
349
- * Indicate which axis to display the top of the charts.
350
- * Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
351
- * @default null
352
- */
353
- topAxis: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
354
334
  /**
355
335
  * The width of the chart in px. If not defined, it takes the width of the parent element.
356
336
  */
@@ -361,6 +341,7 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
361
341
  * An array of [[AxisConfig]] objects.
362
342
  */
363
343
  xAxis: PropTypes.arrayOf(PropTypes.shape({
344
+ axis: PropTypes.oneOf(['x']),
364
345
  classes: PropTypes.object,
365
346
  colorMap: PropTypes.oneOfType([PropTypes.shape({
366
347
  colors: PropTypes.arrayOf(PropTypes.string).isRequired,
@@ -383,13 +364,15 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
383
364
  disableTicks: PropTypes.bool,
384
365
  domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
385
366
  fill: PropTypes.string,
367
+ height: PropTypes.number,
386
368
  hideTooltip: PropTypes.bool,
387
369
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
388
370
  label: PropTypes.string,
389
371
  labelStyle: PropTypes.object,
390
372
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
391
373
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
392
- position: PropTypes.oneOf(['bottom', 'top']),
374
+ offset: PropTypes.number,
375
+ position: PropTypes.oneOf(['bottom', 'none', 'top']),
393
376
  reverse: PropTypes.bool,
394
377
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
395
378
  slotProps: PropTypes.object,
@@ -398,6 +381,7 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
398
381
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
399
382
  tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
400
383
  tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
384
+ tickLabelMinGap: PropTypes.number,
401
385
  tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
402
386
  tickLabelStyle: PropTypes.object,
403
387
  tickMaxStep: PropTypes.number,
@@ -422,6 +406,7 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
422
406
  * An array of [[AxisConfig]] objects.
423
407
  */
424
408
  yAxis: PropTypes.arrayOf(PropTypes.shape({
409
+ axis: PropTypes.oneOf(['y']),
425
410
  classes: PropTypes.object,
426
411
  colorMap: PropTypes.oneOfType([PropTypes.shape({
427
412
  colors: PropTypes.arrayOf(PropTypes.string).isRequired,
@@ -450,7 +435,8 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
450
435
  labelStyle: PropTypes.object,
451
436
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
452
437
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
453
- position: PropTypes.oneOf(['left', 'right']),
438
+ offset: PropTypes.number,
439
+ position: PropTypes.oneOf(['left', 'none', 'right']),
454
440
  reverse: PropTypes.bool,
455
441
  scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
456
442
  slotProps: PropTypes.object,
@@ -467,6 +453,7 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
467
453
  tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
468
454
  tickSize: PropTypes.number,
469
455
  valueFormatter: PropTypes.func,
456
+ width: PropTypes.number,
470
457
  zoom: PropTypes.oneOfType([PropTypes.shape({
471
458
  filterMode: PropTypes.oneOf(['discard', 'keep']),
472
459
  maxEnd: PropTypes.number,
@@ -501,6 +488,14 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
501
488
  id: PropTypes.string,
502
489
  max: PropTypes.number,
503
490
  min: PropTypes.number
491
+ })),
492
+ /**
493
+ * The list of zoom data related to each axis.
494
+ */
495
+ zoomData: PropTypes.arrayOf(PropTypes.shape({
496
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
497
+ end: PropTypes.number.isRequired,
498
+ start: PropTypes.number.isRequired
504
499
  }))
505
500
  } : void 0;
506
501
  export { LineChartPro };