@mui/x-charts-pro 8.6.0 → 8.8.0

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 (144) hide show
  1. package/BarChartPro/BarChartPro.d.ts +1 -1
  2. package/BarChartPro/BarChartPro.js +32 -0
  3. package/CHANGELOG.md +202 -1
  4. package/ChartContainerPro/index.d.ts +7 -1
  5. package/ChartContainerPro/index.js +0 -11
  6. package/ChartDataProviderPro/ChartDataProviderPro.js +7 -1
  7. package/ChartZoomSlider/index.d.ts +2 -1
  8. package/ChartZoomSlider/index.js +10 -2
  9. package/ChartZoomSlider/internals/ChartAxisZoomSlider.js +35 -16
  10. package/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.d.ts +4 -0
  11. package/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +34 -13
  12. package/ChartZoomSlider/internals/ChartAxisZoomSliderPreview.d.ts +18 -0
  13. package/ChartZoomSlider/internals/ChartAxisZoomSliderPreview.js +102 -0
  14. package/ChartZoomSlider/internals/ChartAxisZoomSliderPreviewContent.d.ts +11 -0
  15. package/ChartZoomSlider/internals/ChartAxisZoomSliderPreviewContent.js +62 -0
  16. package/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.js +9 -1
  17. package/ChartZoomSlider/internals/chartAxisZoomSliderTrackClasses.d.ts +15 -0
  18. package/ChartZoomSlider/internals/chartAxisZoomSliderTrackClasses.js +31 -0
  19. package/ChartZoomSlider/internals/previews/AreaPreviewPlot.d.ts +14 -0
  20. package/ChartZoomSlider/internals/previews/AreaPreviewPlot.js +61 -0
  21. package/ChartZoomSlider/internals/previews/BarPreviewPlot.d.ts +10 -0
  22. package/ChartZoomSlider/internals/previews/BarPreviewPlot.js +62 -0
  23. package/ChartZoomSlider/internals/previews/LinePreviewPlot.d.ts +14 -0
  24. package/ChartZoomSlider/internals/previews/LinePreviewPlot.js +59 -0
  25. package/ChartZoomSlider/internals/previews/PreviewPlot.types.d.ts +4 -0
  26. package/ChartZoomSlider/internals/previews/ScatterPreviewPlot.d.ts +16 -0
  27. package/ChartZoomSlider/internals/previews/ScatterPreviewPlot.js +93 -0
  28. package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.js +3 -1
  29. package/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.js +4 -2
  30. package/ChartsToolbarPro/ChartsToolbarPro.js +2 -0
  31. package/FunnelChart/FunnelChart.d.ts +1 -1
  32. package/FunnelChart/FunnelPlot.js +1 -1
  33. package/FunnelChart/funnel.types.d.ts +14 -9
  34. package/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.js +43 -33
  35. package/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.types.d.ts +1 -1
  36. package/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.d.ts +3 -3
  37. package/FunnelChart/seriesConfig/seriesProcessor.js +24 -48
  38. package/Heatmap/Heatmap.d.ts +1 -1
  39. package/LineChartPro/LineChartPro.js +38 -0
  40. package/PieChartPro/PieChartPro.d.ts +1 -1
  41. package/RadarChartPro/RadarChartPro.d.ts +1 -1
  42. package/ScatterChartPro/ScatterChartPro.d.ts +1 -1
  43. package/ScatterChartPro/ScatterChartPro.js +16 -0
  44. package/{ChartContainerPro → context}/ChartProApi.d.ts +2 -3
  45. package/context/ChartProApi.js +5 -0
  46. package/context/index.d.ts +2 -1
  47. package/context/index.js +4 -4
  48. package/context/useChartProApiContext.d.ts +9 -0
  49. package/context/{useChartApiContext.js → useChartProApiContext.js} +4 -4
  50. package/esm/BarChartPro/BarChartPro.d.ts +1 -1
  51. package/esm/BarChartPro/BarChartPro.js +32 -0
  52. package/esm/ChartContainerPro/index.d.ts +7 -1
  53. package/esm/ChartContainerPro/index.js +4 -1
  54. package/esm/ChartDataProviderPro/ChartDataProviderPro.js +7 -1
  55. package/esm/ChartZoomSlider/index.d.ts +2 -1
  56. package/esm/ChartZoomSlider/index.js +2 -1
  57. package/esm/ChartZoomSlider/internals/ChartAxisZoomSlider.js +37 -18
  58. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.d.ts +4 -0
  59. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +36 -14
  60. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderPreview.d.ts +18 -0
  61. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderPreview.js +94 -0
  62. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderPreviewContent.d.ts +11 -0
  63. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderPreviewContent.js +54 -0
  64. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.js +10 -1
  65. package/esm/ChartZoomSlider/internals/chartAxisZoomSliderTrackClasses.d.ts +15 -0
  66. package/esm/ChartZoomSlider/internals/chartAxisZoomSliderTrackClasses.js +21 -0
  67. package/esm/ChartZoomSlider/internals/previews/AreaPreviewPlot.d.ts +14 -0
  68. package/esm/ChartZoomSlider/internals/previews/AreaPreviewPlot.js +53 -0
  69. package/esm/ChartZoomSlider/internals/previews/BarPreviewPlot.d.ts +10 -0
  70. package/esm/ChartZoomSlider/internals/previews/BarPreviewPlot.js +55 -0
  71. package/esm/ChartZoomSlider/internals/previews/LinePreviewPlot.d.ts +14 -0
  72. package/esm/ChartZoomSlider/internals/previews/LinePreviewPlot.js +51 -0
  73. package/esm/ChartZoomSlider/internals/previews/PreviewPlot.types.d.ts +4 -0
  74. package/esm/ChartZoomSlider/internals/previews/ScatterPreviewPlot.d.ts +16 -0
  75. package/esm/ChartZoomSlider/internals/previews/ScatterPreviewPlot.js +86 -0
  76. package/esm/ChartsToolbarPro/ChartsToolbarImageExportTrigger.js +4 -2
  77. package/esm/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.js +5 -3
  78. package/esm/ChartsToolbarPro/ChartsToolbarPro.js +2 -0
  79. package/esm/FunnelChart/FunnelChart.d.ts +1 -1
  80. package/esm/FunnelChart/FunnelPlot.js +1 -1
  81. package/esm/FunnelChart/funnel.types.d.ts +14 -9
  82. package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.js +43 -33
  83. package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.types.d.ts +1 -1
  84. package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.d.ts +3 -3
  85. package/esm/FunnelChart/seriesConfig/seriesProcessor.js +24 -48
  86. package/esm/Heatmap/Heatmap.d.ts +1 -1
  87. package/esm/LineChartPro/LineChartPro.js +38 -0
  88. package/esm/PieChartPro/PieChartPro.d.ts +1 -1
  89. package/esm/RadarChartPro/RadarChartPro.d.ts +1 -1
  90. package/esm/ScatterChartPro/ScatterChartPro.d.ts +1 -1
  91. package/esm/ScatterChartPro/ScatterChartPro.js +16 -0
  92. package/esm/{ChartContainerPro → context}/ChartProApi.d.ts +2 -3
  93. package/esm/context/ChartProApi.js +1 -0
  94. package/esm/context/index.d.ts +2 -1
  95. package/esm/context/index.js +2 -1
  96. package/esm/context/useChartProApiContext.d.ts +9 -0
  97. package/esm/context/{useChartApiContext.js → useChartProApiContext.js} +3 -3
  98. package/esm/hooks/index.d.ts +2 -1
  99. package/esm/hooks/index.js +2 -1
  100. package/esm/hooks/useChartProApiRef.d.ts +23 -0
  101. package/esm/hooks/useChartProApiRef.js +20 -0
  102. package/esm/index.d.ts +4 -2
  103. package/esm/index.js +3 -3
  104. package/esm/internals/plugins/allPlugins.d.ts +2 -2
  105. package/esm/internals/plugins/useChartProExport/exportImage.js +9 -3
  106. package/esm/internals/plugins/useChartProExport/print.d.ts +3 -1
  107. package/esm/internals/plugins/useChartProExport/print.js +7 -2
  108. package/esm/internals/plugins/useChartProExport/useChartProExport.types.d.ts +22 -12
  109. package/esm/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.d.ts +8 -0
  110. package/esm/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.js +58 -0
  111. package/esm/internals/plugins/useChartProZoom/{useChartProZoom.utils.d.ts → gestureHooks/useZoom.utils.d.ts} +14 -10
  112. package/esm/internals/plugins/useChartProZoom/{useChartProZoom.utils.js → gestureHooks/useZoom.utils.js} +41 -31
  113. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.d.ts +8 -0
  114. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.js +59 -0
  115. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.d.ts +8 -0
  116. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.js +79 -0
  117. package/esm/internals/plugins/useChartProZoom/useChartProZoom.js +15 -227
  118. package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +4 -4
  119. package/hooks/index.d.ts +2 -1
  120. package/hooks/index.js +11 -0
  121. package/hooks/useChartProApiRef.d.ts +23 -0
  122. package/hooks/useChartProApiRef.js +28 -0
  123. package/index.d.ts +4 -2
  124. package/index.js +58 -22
  125. package/internals/plugins/allPlugins.d.ts +2 -2
  126. package/internals/plugins/useChartProExport/exportImage.js +9 -3
  127. package/internals/plugins/useChartProExport/print.d.ts +3 -1
  128. package/internals/plugins/useChartProExport/print.js +7 -2
  129. package/internals/plugins/useChartProExport/useChartProExport.types.d.ts +22 -12
  130. package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.d.ts +8 -0
  131. package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.js +65 -0
  132. package/internals/plugins/useChartProZoom/{useChartProZoom.utils.d.ts → gestureHooks/useZoom.utils.d.ts} +14 -10
  133. package/internals/plugins/useChartProZoom/{useChartProZoom.utils.js → gestureHooks/useZoom.utils.js} +43 -34
  134. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.d.ts +8 -0
  135. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.js +66 -0
  136. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.d.ts +8 -0
  137. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.js +86 -0
  138. package/internals/plugins/useChartProZoom/useChartProZoom.js +14 -226
  139. package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +4 -4
  140. package/package.json +6 -5
  141. package/context/useChartApiContext.d.ts +0 -9
  142. package/esm/context/useChartApiContext.d.ts +0 -9
  143. /package/{ChartContainerPro/ChartProApi.js → ChartZoomSlider/internals/previews/PreviewPlot.types.js} +0 -0
  144. /package/esm/{ChartContainerPro/ChartProApi.js → ChartZoomSlider/internals/previews/PreviewPlot.types.js} +0 -0
@@ -313,6 +313,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
313
313
  panning: PropTypes.bool,
314
314
  slider: PropTypes.shape({
315
315
  enabled: PropTypes.bool,
316
+ preview: PropTypes.bool,
316
317
  showTooltip: PropTypes.oneOf(['always', 'hover', 'never']),
317
318
  size: PropTypes.number
318
319
  }),
@@ -378,6 +379,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
378
379
  panning: PropTypes.bool,
379
380
  slider: PropTypes.shape({
380
381
  enabled: PropTypes.bool,
382
+ preview: PropTypes.bool,
381
383
  showTooltip: PropTypes.oneOf(['always', 'hover', 'never']),
382
384
  size: PropTypes.number
383
385
  }),
@@ -438,6 +440,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
438
440
  panning: PropTypes.bool,
439
441
  slider: PropTypes.shape({
440
442
  enabled: PropTypes.bool,
443
+ preview: PropTypes.bool,
441
444
  showTooltip: PropTypes.oneOf(['always', 'hover', 'never']),
442
445
  size: PropTypes.number
443
446
  }),
@@ -498,6 +501,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
498
501
  panning: PropTypes.bool,
499
502
  slider: PropTypes.shape({
500
503
  enabled: PropTypes.bool,
504
+ preview: PropTypes.bool,
501
505
  showTooltip: PropTypes.oneOf(['always', 'hover', 'never']),
502
506
  size: PropTypes.number
503
507
  }),
@@ -558,6 +562,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
558
562
  panning: PropTypes.bool,
559
563
  slider: PropTypes.shape({
560
564
  enabled: PropTypes.bool,
565
+ preview: PropTypes.bool,
561
566
  showTooltip: PropTypes.oneOf(['always', 'hover', 'never']),
562
567
  size: PropTypes.number
563
568
  }),
@@ -618,6 +623,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
618
623
  panning: PropTypes.bool,
619
624
  slider: PropTypes.shape({
620
625
  enabled: PropTypes.bool,
626
+ preview: PropTypes.bool,
621
627
  showTooltip: PropTypes.oneOf(['always', 'hover', 'never']),
622
628
  size: PropTypes.number
623
629
  }),
@@ -678,6 +684,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
678
684
  panning: PropTypes.bool,
679
685
  slider: PropTypes.shape({
680
686
  enabled: PropTypes.bool,
687
+ preview: PropTypes.bool,
681
688
  showTooltip: PropTypes.oneOf(['always', 'hover', 'never']),
682
689
  size: PropTypes.number
683
690
  }),
@@ -738,6 +745,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
738
745
  panning: PropTypes.bool,
739
746
  slider: PropTypes.shape({
740
747
  enabled: PropTypes.bool,
748
+ preview: PropTypes.bool,
741
749
  showTooltip: PropTypes.oneOf(['always', 'hover', 'never']),
742
750
  size: PropTypes.number
743
751
  }),
@@ -810,6 +818,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
810
818
  panning: PropTypes.bool,
811
819
  slider: PropTypes.shape({
812
820
  enabled: PropTypes.bool,
821
+ preview: PropTypes.bool,
813
822
  showTooltip: PropTypes.oneOf(['always', 'hover', 'never']),
814
823
  size: PropTypes.number
815
824
  }),
@@ -874,6 +883,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
874
883
  panning: PropTypes.bool,
875
884
  slider: PropTypes.shape({
876
885
  enabled: PropTypes.bool,
886
+ preview: PropTypes.bool,
877
887
  showTooltip: PropTypes.oneOf(['always', 'hover', 'never']),
878
888
  size: PropTypes.number
879
889
  }),
@@ -933,6 +943,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
933
943
  panning: PropTypes.bool,
934
944
  slider: PropTypes.shape({
935
945
  enabled: PropTypes.bool,
946
+ preview: PropTypes.bool,
936
947
  showTooltip: PropTypes.oneOf(['always', 'hover', 'never']),
937
948
  size: PropTypes.number
938
949
  }),
@@ -992,6 +1003,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
992
1003
  panning: PropTypes.bool,
993
1004
  slider: PropTypes.shape({
994
1005
  enabled: PropTypes.bool,
1006
+ preview: PropTypes.bool,
995
1007
  showTooltip: PropTypes.oneOf(['always', 'hover', 'never']),
996
1008
  size: PropTypes.number
997
1009
  }),
@@ -1051,6 +1063,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
1051
1063
  panning: PropTypes.bool,
1052
1064
  slider: PropTypes.shape({
1053
1065
  enabled: PropTypes.bool,
1066
+ preview: PropTypes.bool,
1054
1067
  showTooltip: PropTypes.oneOf(['always', 'hover', 'never']),
1055
1068
  size: PropTypes.number
1056
1069
  }),
@@ -1110,6 +1123,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
1110
1123
  panning: PropTypes.bool,
1111
1124
  slider: PropTypes.shape({
1112
1125
  enabled: PropTypes.bool,
1126
+ preview: PropTypes.bool,
1113
1127
  showTooltip: PropTypes.oneOf(['always', 'hover', 'never']),
1114
1128
  size: PropTypes.number
1115
1129
  }),
@@ -1169,6 +1183,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
1169
1183
  panning: PropTypes.bool,
1170
1184
  slider: PropTypes.shape({
1171
1185
  enabled: PropTypes.bool,
1186
+ preview: PropTypes.bool,
1172
1187
  showTooltip: PropTypes.oneOf(['always', 'hover', 'never']),
1173
1188
  size: PropTypes.number
1174
1189
  }),
@@ -1228,6 +1243,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
1228
1243
  panning: PropTypes.bool,
1229
1244
  slider: PropTypes.shape({
1230
1245
  enabled: PropTypes.bool,
1246
+ preview: PropTypes.bool,
1231
1247
  showTooltip: PropTypes.oneOf(['always', 'hover', 'never']),
1232
1248
  size: PropTypes.number
1233
1249
  }),
@@ -7,7 +7,7 @@ import { AllPluginSignatures, DefaultPluginSignatures } from "../internals/plugi
7
7
  import { FunnelChartPluginsSignatures } from "../FunnelChart/FunnelChart.plugins.js";
8
8
  import { RadarChartProPluginsSignatures } from "../RadarChartPro/RadarChartPro.plugins.js";
9
9
  import { PieChartProPluginSignatures } from "../PieChartPro/PieChartPro.plugins.js";
10
- type PluginsPerSeriesType = {
10
+ export type ProPluginsPerSeriesType = {
11
11
  heatmap: HeatmapPluginsSignatures;
12
12
  line: LineChartProPluginsSignatures;
13
13
  scatter: ScatterChartProPluginsSignatures;
@@ -24,5 +24,4 @@ type PluginsPerSeriesType = {
24
24
  * If the chart is being created using composition, the `composition` value can be used.
25
25
  * @example ChartProApi<'composition'>
26
26
  */
27
- export type ChartProApi<TSeries extends keyof PluginsPerSeriesType | undefined = undefined, TSignatures extends readonly ChartAnyPluginSignature[] = (TSeries extends keyof PluginsPerSeriesType ? PluginsPerSeriesType[TSeries] : AllPluginSignatures)> = ChartPublicAPI<TSignatures>;
28
- export {};
27
+ export type ChartProApi<ChartType extends keyof ProPluginsPerSeriesType | undefined = undefined, Signatures extends readonly ChartAnyPluginSignature[] = (ChartType extends keyof ProPluginsPerSeriesType ? ProPluginsPerSeriesType[ChartType] : AllPluginSignatures)> = ChartPublicAPI<Signatures>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1,2 @@
1
- export * from "./useChartApiContext.js";
1
+ export * from "./useChartProApiContext.js";
2
+ export type { ChartProApi } from "./ChartProApi.js";
@@ -1 +1,2 @@
1
- export * from "./useChartApiContext.js";
1
+ export * from "./useChartProApiContext.js";
2
+ export {};
@@ -0,0 +1,9 @@
1
+ import { ChartProApi } from "./ChartProApi.js";
2
+ /**
3
+ * The `useChartProApiContext` hook provides access to the chart API.
4
+ * This is only available when the chart is rendered within a chart or a `ChartDataProvider` component.
5
+ * If you want to access the chart API outside those components, you should use the `apiRef` prop instead.
6
+ * @example
7
+ * const apiRef = useChartProApiContext<ChartProApi<'bar'>>();
8
+ */
9
+ export declare function useChartProApiContext<Api extends ChartProApi>(): import("react").RefObject<Api>;
@@ -1,11 +1,11 @@
1
1
  import { useChartApiContext as useChartApiContextCommunity } from '@mui/x-charts/context';
2
2
  /**
3
- * The `useChartApiContext` hook provides access to the chart API.
3
+ * The `useChartProApiContext` hook provides access to the chart API.
4
4
  * This is only available when the chart is rendered within a chart or a `ChartDataProvider` component.
5
5
  * If you want to access the chart API outside those components, you should use the `apiRef` prop instead.
6
6
  * @example
7
- * const apiRef = useChartApiContext<ChartProApi<'bar'>>();
7
+ * const apiRef = useChartProApiContext<ChartProApi<'bar'>>();
8
8
  */
9
- export function useChartApiContext() {
9
+ export function useChartProApiContext() {
10
10
  return useChartApiContextCommunity();
11
11
  }
@@ -1,3 +1,4 @@
1
1
  export * from "./useHeatmapSeries.js";
2
2
  export * from "./useFunnelSeries.js";
3
- export * from "./zoom/index.js";
3
+ export * from "./zoom/index.js";
4
+ export * from "./useChartProApiRef.js";
@@ -1,3 +1,4 @@
1
1
  export * from "./useHeatmapSeries.js";
2
2
  export * from "./useFunnelSeries.js";
3
- export * from "./zoom/index.js";
3
+ export * from "./zoom/index.js";
4
+ export * from "./useChartProApiRef.js";
@@ -0,0 +1,23 @@
1
+ import * as React from 'react';
2
+ import { ChartAnyPluginSignature } from '@mui/x-charts/internals';
3
+ import { AllPluginSignatures } from "../internals/plugins/allPlugins.js";
4
+ import { ProPluginsPerSeriesType, type ChartProApi } from "../context/ChartProApi.js";
5
+ /**
6
+ * Hook that instantiates a [[ChartProApiRef]].
7
+ * The chart type needs to be given as the generic parameter to narrow down the API to the specific chart type.
8
+ * @example
9
+ * ```tsx
10
+ * const barApiRef = useChartProApiRef<'bar'>();
11
+ * ```
12
+ * @example
13
+ * ```tsx
14
+ * // The API can be passed to the chart component and used to interact with the chart.
15
+ * <BarChart apiRef={barApiRef} />
16
+ * ```
17
+ * @example
18
+ * ```tsx
19
+ * // The API can be used to access chart methods and properties.
20
+ * barApiRef.current?.getSeries();
21
+ * ```
22
+ */
23
+ export declare const useChartProApiRef: <ChartType extends keyof ProPluginsPerSeriesType = never, Signatures extends readonly ChartAnyPluginSignature[] = (ChartType extends keyof ProPluginsPerSeriesType ? ProPluginsPerSeriesType[ChartType] : AllPluginSignatures)>() => React.RefObject<ChartProApi<ChartType, Signatures> | undefined>;
@@ -0,0 +1,20 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Hook that instantiates a [[ChartProApiRef]].
4
+ * The chart type needs to be given as the generic parameter to narrow down the API to the specific chart type.
5
+ * @example
6
+ * ```tsx
7
+ * const barApiRef = useChartProApiRef<'bar'>();
8
+ * ```
9
+ * @example
10
+ * ```tsx
11
+ * // The API can be passed to the chart component and used to interact with the chart.
12
+ * <BarChart apiRef={barApiRef} />
13
+ * ```
14
+ * @example
15
+ * ```tsx
16
+ * // The API can be used to access chart methods and properties.
17
+ * barApiRef.current?.getSeries();
18
+ * ```
19
+ */
20
+ export const useChartProApiRef = () => React.useRef(undefined);
package/esm/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./typeOverloads/modules.js";
2
2
  export * from '@mui/x-charts/constants';
3
- export * from '@mui/x-charts/context';
3
+ export type { FadeOptions, HighlightItemData, HighlightOptions, HighlightScope } from '@mui/x-charts/context';
4
4
  export * from '@mui/x-charts/hooks';
5
5
  export * from '@mui/x-charts/colorPalettes';
6
6
  export * from '@mui/x-charts/models';
@@ -26,9 +26,11 @@ export * from '@mui/x-charts/ChartsSurface';
26
26
  export * from '@mui/x-charts/ChartDataProvider';
27
27
  export * from '@mui/x-charts/ChartsLabel';
28
28
  export type { ZoomData, ZoomFilterMode, ZoomSliderShowTooltip, ZoomOptions, ZoomSliderOptions } from '@mui/x-charts/internals';
29
+ export * from "./context/index.js";
29
30
  export * from "./hooks/index.js";
30
31
  export * from "./Heatmap/index.js";
31
- export * from "./ChartContainerPro/index.js";
32
+ export { ChartContainerPro } from "./ChartContainerPro/index.js";
33
+ export type { ChartContainerProProps } from "./ChartContainerPro/index.js";
32
34
  export * from "./ChartDataProviderPro/index.js";
33
35
  export * from "./ScatterChartPro/index.js";
34
36
  export * from "./BarChartPro/index.js";
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts-pro v8.6.0
2
+ * @mui/x-charts-pro v8.8.0
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -9,7 +9,6 @@ import "./typeOverloads/modules.js";
9
9
 
10
10
  // exports from MIT package
11
11
  export * from '@mui/x-charts/constants';
12
- export * from '@mui/x-charts/context';
13
12
  export * from '@mui/x-charts/hooks';
14
13
  export * from '@mui/x-charts/colorPalettes';
15
14
  export * from '@mui/x-charts/models';
@@ -35,9 +34,10 @@ export * from '@mui/x-charts/ChartsSurface';
35
34
  export * from '@mui/x-charts/ChartDataProvider';
36
35
  export * from '@mui/x-charts/ChartsLabel';
37
36
  // Pro components
37
+ export * from "./context/index.js";
38
38
  export * from "./hooks/index.js";
39
39
  export * from "./Heatmap/index.js";
40
- export * from "./ChartContainerPro/index.js";
40
+ export { ChartContainerPro } from "./ChartContainerPro/index.js";
41
41
  export * from "./ChartDataProviderPro/index.js";
42
42
  export * from "./ScatterChartPro/index.js";
43
43
  export * from "./BarChartPro/index.js";
@@ -3,7 +3,7 @@ import { UseChartProExportSignature } from "./useChartProExport/index.js";
3
3
  import { UseChartProZoomSignature } from "./useChartProZoom/index.js";
4
4
  export type AllPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartCartesianAxisSignature<TSeries>, UseChartPolarAxisSignature<TSeries>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartProZoomSignature, UseChartProExportSignature];
5
5
  export type AllPluginsType<TSeries extends ChartSeriesType = ChartSeriesType> = ConvertSignaturesIntoPlugins<AllPluginSignatures<TSeries>>;
6
- export declare const ALL_PLUGINS: (import("@mui/x-charts/internals").ChartPlugin<UseChartProZoomSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartProExportSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartZAxisSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartInteractionSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartHighlightSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartCartesianAxisSignature<any>> | import("@mui/x-charts/internals").ChartPlugin<UseChartPolarAxisSignature<any>>)[];
6
+ export declare const ALL_PLUGINS: (import("@mui/x-charts/internals").ChartPlugin<UseChartProExportSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartZAxisSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartInteractionSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartHighlightSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartCartesianAxisSignature<any>> | import("@mui/x-charts/internals").ChartPlugin<UseChartProZoomSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartPolarAxisSignature<any>>)[];
7
7
  export type DefaultPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartCartesianAxisSignature<TSeries>, UseChartPolarAxisSignature<TSeries>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartProZoomSignature, UseChartProExportSignature];
8
8
  export type DefaultPluginsType<TSeries extends ChartSeriesType = ChartSeriesType> = ConvertSignaturesIntoPlugins<DefaultPluginSignatures<TSeries>>;
9
- export declare const DEFAULT_PLUGINS: (import("@mui/x-charts/internals").ChartPlugin<UseChartProZoomSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartProExportSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartZAxisSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartInteractionSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartHighlightSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartCartesianAxisSignature<any>>)[];
9
+ export declare const DEFAULT_PLUGINS: (import("@mui/x-charts/internals").ChartPlugin<UseChartProExportSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartZAxisSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartInteractionSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartHighlightSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartCartesianAxisSignature<any>> | import("@mui/x-charts/internals").ChartPlugin<UseChartProZoomSignature>)[];
@@ -15,7 +15,9 @@ export async function exportImage(element, params) {
15
15
  const {
16
16
  fileName,
17
17
  type = 'image/png',
18
- quality = 0.9
18
+ quality = 0.9,
19
+ onBeforeExport,
20
+ copyStyles = true
19
21
  } = params ?? {};
20
22
  const drawDocumentPromise = getDrawDocument();
21
23
  const {
@@ -43,11 +45,15 @@ export async function exportImage(element, params) {
43
45
  exportDoc.body.style.margin = '0px';
44
46
  const rootCandidate = element.getRootNode();
45
47
  const root = rootCandidate.constructor.name === 'ShadowRoot' ? rootCandidate : doc;
46
- await Promise.all(loadStyleSheets(exportDoc, root));
48
+ if (copyStyles) {
49
+ await Promise.all(loadStyleSheets(exportDoc, root));
50
+ }
47
51
  resolve();
48
52
  };
49
53
  doc.body.appendChild(iframe);
50
- const [drawDocument] = await Promise.all([drawDocumentPromise, iframeLoadPromise]);
54
+ await iframeLoadPromise;
55
+ await onBeforeExport?.(iframe);
56
+ const drawDocument = await drawDocumentPromise;
51
57
  try {
52
58
  await drawDocument(iframe.contentDocument, canvas, {
53
59
  // Handle retina displays: https://github.com/cburgmer/rasterizeHTML.js/blob/262b3404d1c469ce4a7750a2976dec09b8ae2d6c/examples/retina.html#L71
@@ -1,4 +1,6 @@
1
1
  import { ChartPrintExportOptions } from "./useChartProExport.types.js";
2
2
  export declare function printChart(element: HTMLElement | SVGElement, {
3
- fileName
3
+ fileName,
4
+ onBeforeExport,
5
+ copyStyles
4
6
  }?: ChartPrintExportOptions): void;
@@ -2,7 +2,9 @@ import ownerDocument from '@mui/utils/ownerDocument';
2
2
  import { loadStyleSheets } from '@mui/x-internals/export';
3
3
  import { createExportIframe } from "./common.js";
4
4
  export function printChart(element, {
5
- fileName
5
+ fileName,
6
+ onBeforeExport,
7
+ copyStyles = true
6
8
  } = {}) {
7
9
  const printWindow = createExportIframe(fileName);
8
10
  const doc = ownerDocument(element);
@@ -14,7 +16,9 @@ export function printChart(element, {
14
16
  printDoc.body.innerHTML = container.innerHTML;
15
17
  const rootCandidate = element.getRootNode();
16
18
  const root = rootCandidate.constructor.name === 'ShadowRoot' ? rootCandidate : doc;
17
- await Promise.all(loadStyleSheets(printDoc, root));
19
+ if (copyStyles) {
20
+ await Promise.all(loadStyleSheets(printDoc, root));
21
+ }
18
22
  const mediaQueryList = printWindow.contentWindow.matchMedia('print');
19
23
  mediaQueryList.addEventListener('change', mql => {
20
24
  const isAfterPrint = mql.matches === false;
@@ -22,6 +26,7 @@ export function printChart(element, {
22
26
  doc.body.removeChild(printWindow);
23
27
  }
24
28
  });
29
+ await onBeforeExport?.(printWindow);
25
30
  printWindow.contentWindow.print();
26
31
  };
27
32
  doc.body.appendChild(printWindow);
@@ -4,29 +4,39 @@ export type UseChartProExportDefaultizedParameters = UseChartProExportParameters
4
4
  export interface UseChartProExportState {
5
5
  export: {};
6
6
  }
7
- /**
8
- * The options to apply on the Print export.
9
- * @demos
10
- * - [Print export](https://mui.com/x/react-charts/export/#print-export-as-pdf)
11
- */
12
- export interface ChartPrintExportOptions {
7
+ export interface ChartExportOptions {
13
8
  /**
14
9
  * The name of the file without the extension.
15
10
  * @default The title of the document the chart belongs to
16
11
  */
17
12
  fileName?: string;
13
+ /**
14
+ * Callback function that is called before the export is triggered.
15
+ * It can be used to modify the iframe or perform any other actions before the export, such as updating styles,
16
+ * removing elements, etc.
17
+ * @param {HTMLIFrameElement} iframe containing the chart to be exported.
18
+ * @returns {Promise<void> | void} A promise or void. If a promise is returned, the export will wait for it to resolve before proceeding.
19
+ */
20
+ onBeforeExport?: (iframe: HTMLIFrameElement) => Promise<void> | void;
21
+ /**
22
+ * If `true`, the styles of the page the chart belongs to will be copied to the export iframe.
23
+ * Copying styles is useful to ensure that the exported chart looks the same as it does on the page.
24
+ * @default true
25
+ */
26
+ copyStyles?: boolean;
18
27
  }
28
+ /**
29
+ * The options to apply on the Print export.
30
+ * @demos
31
+ * - [Print export](https://mui.com/x/react-charts/export/#print-export-as-pdf)
32
+ */
33
+ export interface ChartPrintExportOptions extends ChartExportOptions {}
19
34
  /**
20
35
  * The options to apply on the image export.
21
36
  * @demos
22
37
  * - [Image export](https://mui.com/x/react-charts/export/#export-as-image)
23
38
  */
24
- export interface ChartImageExportOptions {
25
- /**
26
- * The name of the file without the extension.
27
- * @default The title of the document the chart belongs to
28
- */
29
- fileName?: string;
39
+ export interface ChartImageExportOptions extends ChartExportOptions {
30
40
  /**
31
41
  * The format of the image to be exported.
32
42
  * Browsers are required to support 'image/png'. Some browsers also support 'image/jpeg' and 'image/webp'.
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import { ChartPlugin, ZoomData } from '@mui/x-charts/internals';
3
+ import { UseChartProZoomSignature } from "../useChartProZoom.types.js";
4
+ export declare const usePanOnDrag: ({
5
+ store,
6
+ instance,
7
+ svgRef
8
+ }: Pick<Parameters<ChartPlugin<UseChartProZoomSignature>>[0], "store" | "instance" | "svgRef">, setZoomDataCallback: React.Dispatch<ZoomData[] | ((prev: ZoomData[]) => ZoomData[])>) => void;
@@ -0,0 +1,58 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { useSelector, selectorChartDrawingArea, selectorChartZoomOptionsLookup } from '@mui/x-charts/internals';
5
+ import { rafThrottle } from '@mui/x-internals/rafThrottle';
6
+ import { translateZoom } from "./useZoom.utils.js";
7
+ export const usePanOnDrag = ({
8
+ store,
9
+ instance,
10
+ svgRef
11
+ }, setZoomDataCallback) => {
12
+ const drawingArea = useSelector(store, selectorChartDrawingArea);
13
+ const optionsLookup = useSelector(store, selectorChartZoomOptionsLookup);
14
+ const startRef = React.useRef(null);
15
+
16
+ // Add event for chart panning
17
+ const isPanEnabled = React.useMemo(() => Object.values(optionsLookup).some(v => v.panning) || false, [optionsLookup]);
18
+ React.useEffect(() => {
19
+ const element = svgRef.current;
20
+ if (element === null || !isPanEnabled) {
21
+ return () => {};
22
+ }
23
+ const handlePanStart = event => {
24
+ if (!event.detail.target?.closest('[data-charts-zoom-slider]')) {
25
+ startRef.current = store.value.zoom.zoomData;
26
+ }
27
+ };
28
+ const handlePanEnd = () => {
29
+ startRef.current = null;
30
+ };
31
+ const throttledCallback = rafThrottle((event, zoomData) => {
32
+ const newZoomData = translateZoom(zoomData, {
33
+ x: event.detail.activeDeltaX,
34
+ y: -event.detail.activeDeltaY
35
+ }, {
36
+ width: drawingArea.width,
37
+ height: drawingArea.height
38
+ }, optionsLookup);
39
+ setZoomDataCallback(newZoomData);
40
+ });
41
+ const handlePan = event => {
42
+ const zoomData = startRef.current;
43
+ if (!zoomData) {
44
+ return;
45
+ }
46
+ throttledCallback(event, zoomData);
47
+ };
48
+ const panHandler = instance.addInteractionListener('pan', handlePan);
49
+ const panStartHandler = instance.addInteractionListener('panStart', handlePanStart);
50
+ const panEndHandler = instance.addInteractionListener('panEnd', handlePanEnd);
51
+ return () => {
52
+ panStartHandler.cleanup();
53
+ panHandler.cleanup();
54
+ panEndHandler.cleanup();
55
+ throttledCallback.clear();
56
+ };
57
+ }, [instance, svgRef, isPanEnabled, optionsLookup, drawingArea.width, drawingArea.height, setZoomDataCallback, store, startRef]);
58
+ };
@@ -17,14 +17,6 @@ export declare function getWheelScaleRatio(event: WheelEvent, step: number): {
17
17
  scaleRatio: number;
18
18
  isZoomIn: boolean;
19
19
  };
20
- /**
21
- * Get the scale ratio and if it's a zoom in or out from a pinch gesture.
22
- */
23
- export declare function getPinchScaleRatio(curDiff: number, prevDiff: number, step: number): {
24
- scaleRatio: number;
25
- isZoomIn: boolean;
26
- };
27
- export declare function getDiff(eventCache: PointerEvent[]): number;
28
20
  /**
29
21
  * Get the ratio of the point in the horizontal center of the area.
30
22
  */
@@ -35,11 +27,23 @@ export declare function getHorizontalCenterRatio(point: {
35
27
  left: number;
36
28
  width: number;
37
29
  }): number;
38
- export declare function preventDefault(event: TouchEvent): void;
30
+ /**
31
+ * Get the ratio of the point in the vertical center of the area.
32
+ */
39
33
  export declare function getVerticalCenterRatio(point: {
40
34
  x: number;
41
35
  y: number;
42
36
  }, area: {
43
37
  top: number;
44
38
  height: number;
45
- }): number;
39
+ }): number;
40
+ /**
41
+ * Translate the zoom data by a given movement.
42
+ */
43
+ export declare function translateZoom(initialZoomData: readonly ZoomData[], movement: {
44
+ x: number;
45
+ y: number;
46
+ }, drawingArea: {
47
+ width: number;
48
+ height: number;
49
+ }, optionsLookup: Record<string | number, DefaultizedZoomOptions>): ZoomData[];
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  /**
2
3
  * Helper to get the range (in percents of a reference range) corresponding to a given scale.
3
4
  * @param centerRatio {number} The ratio of the point that should not move between the previous and next range.
@@ -76,34 +77,6 @@ export function getWheelScaleRatio(event, step) {
76
77
  };
77
78
  }
78
79
 
79
- /**
80
- * Get the scale ratio and if it's a zoom in or out from a pinch gesture.
81
- */
82
- export function getPinchScaleRatio(curDiff, prevDiff, step) {
83
- const scaledStep = step / 1000;
84
- let scaleRatio = 0;
85
- let isZoomIn = false;
86
- const hasMoved = prevDiff > 0;
87
- if (hasMoved && curDiff > prevDiff) {
88
- // The distance between the two pointers has increased
89
- scaleRatio = 1 + scaledStep;
90
- isZoomIn = true;
91
- }
92
- if (hasMoved && curDiff < prevDiff) {
93
- // The distance between the two pointers has decreased
94
- scaleRatio = 1 - scaledStep;
95
- isZoomIn = false;
96
- }
97
- return {
98
- scaleRatio,
99
- isZoomIn
100
- };
101
- }
102
- export function getDiff(eventCache) {
103
- const [firstEvent, secondEvent] = eventCache;
104
- return Math.hypot(firstEvent.pageX - secondEvent.pageX, firstEvent.pageY - secondEvent.pageY);
105
- }
106
-
107
80
  /**
108
81
  * Get the ratio of the point in the horizontal center of the area.
109
82
  */
@@ -114,13 +87,50 @@ export function getHorizontalCenterRatio(point, area) {
114
87
  } = area;
115
88
  return (point.x - left) / width;
116
89
  }
117
- export function preventDefault(event) {
118
- event.preventDefault();
119
- }
90
+
91
+ /**
92
+ * Get the ratio of the point in the vertical center of the area.
93
+ */
120
94
  export function getVerticalCenterRatio(point, area) {
121
95
  const {
122
96
  top,
123
97
  height
124
98
  } = area;
125
99
  return (point.y - top) / height * -1 + 1;
100
+ }
101
+
102
+ /**
103
+ * Translate the zoom data by a given movement.
104
+ */
105
+ export function translateZoom(initialZoomData, movement, drawingArea, optionsLookup) {
106
+ return initialZoomData.map(zoom => {
107
+ const options = optionsLookup[zoom.axisId];
108
+ if (!options || !options.panning) {
109
+ return zoom;
110
+ }
111
+ const min = zoom.start;
112
+ const max = zoom.end;
113
+ const span = max - min;
114
+ const MIN_PERCENT = options.minStart;
115
+ const MAX_PERCENT = options.maxEnd;
116
+ const displacement = options.axisDirection === 'x' ? movement.x : movement.y;
117
+ const dimension = options.axisDirection === 'x' ? drawingArea.width : drawingArea.height;
118
+ let newMinPercent = min - displacement / dimension * span;
119
+ let newMaxPercent = max - displacement / dimension * span;
120
+ if (newMinPercent < MIN_PERCENT) {
121
+ newMinPercent = MIN_PERCENT;
122
+ newMaxPercent = newMinPercent + span;
123
+ }
124
+ if (newMaxPercent > MAX_PERCENT) {
125
+ newMaxPercent = MAX_PERCENT;
126
+ newMinPercent = newMaxPercent - span;
127
+ }
128
+ if (newMinPercent < MIN_PERCENT || newMaxPercent > MAX_PERCENT || span < options.minSpan || span > options.maxSpan) {
129
+ return zoom;
130
+ }
131
+ return _extends({}, zoom, {
132
+ start: newMinPercent,
133
+ end: newMaxPercent
134
+ });
135
+ });
126
136
  }
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import { ChartPlugin, ZoomData } from '@mui/x-charts/internals';
3
+ import { UseChartProZoomSignature } from "../useChartProZoom.types.js";
4
+ export declare const useZoomOnPinch: ({
5
+ store,
6
+ instance,
7
+ svgRef
8
+ }: Pick<Parameters<ChartPlugin<UseChartProZoomSignature>>[0], "store" | "instance" | "svgRef">, setZoomDataCallback: React.Dispatch<ZoomData[] | ((prev: ZoomData[]) => ZoomData[])>) => void;