@mui/x-charts-pro 8.5.2 → 8.6.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 (110) hide show
  1. package/CHANGELOG.md +203 -11
  2. package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  3. package/ChartZoomSlider/internals/ChartAxisZoomSlider.js +1 -1
  4. package/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +20 -31
  5. package/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.js +1 -8
  6. package/ChartZoomSlider/internals/zoom-utils.d.ts +3 -1
  7. package/ChartZoomSlider/internals/zoom-utils.js +19 -8
  8. package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.d.ts +27 -0
  9. package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.js +77 -0
  10. package/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.d.ts +33 -0
  11. package/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.js +75 -0
  12. package/ChartsToolbarPro/ChartsToolbarPro.d.ts +16 -3
  13. package/ChartsToolbarPro/ChartsToolbarPro.js +118 -8
  14. package/ChartsToolbarPro/index.d.ts +3 -1
  15. package/ChartsToolbarPro/index.js +22 -0
  16. package/ChartsToolbarPro/internals/ChartsMenu.d.ts +14 -0
  17. package/ChartsToolbarPro/internals/ChartsMenu.js +73 -0
  18. package/ChartsToolbarPro/internals/ChartsToolbarDivider.d.ts +5 -0
  19. package/ChartsToolbarPro/internals/ChartsToolbarDivider.js +47 -0
  20. package/FunnelChart/FunnelPlot.js +56 -40
  21. package/FunnelChart/FunnelSection.js +2 -0
  22. package/FunnelChart/curves/bump.d.ts +3 -3
  23. package/FunnelChart/curves/bump.js +3 -0
  24. package/FunnelChart/curves/curve.types.d.ts +14 -1
  25. package/FunnelChart/curves/getFunnelCurve.d.ts +7 -2
  26. package/FunnelChart/curves/linear.d.ts +3 -3
  27. package/FunnelChart/curves/linear.js +23 -18
  28. package/FunnelChart/curves/pyramid.d.ts +3 -3
  29. package/FunnelChart/curves/pyramid.js +17 -12
  30. package/FunnelChart/curves/step-pyramid.d.ts +5 -5
  31. package/FunnelChart/curves/step-pyramid.js +20 -18
  32. package/FunnelChart/curves/step.d.ts +3 -3
  33. package/FunnelChart/curves/step.js +14 -12
  34. package/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.d.ts +18 -1444
  35. package/FunnelChart/labelUtils.d.ts +4 -12
  36. package/FunnelChart/labelUtils.js +43 -44
  37. package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  38. package/esm/ChartZoomSlider/internals/ChartAxisZoomSlider.js +1 -1
  39. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +21 -32
  40. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.js +1 -8
  41. package/esm/ChartZoomSlider/internals/zoom-utils.d.ts +3 -1
  42. package/esm/ChartZoomSlider/internals/zoom-utils.js +19 -9
  43. package/esm/ChartsToolbarPro/ChartsToolbarImageExportTrigger.d.ts +27 -0
  44. package/esm/ChartsToolbarPro/ChartsToolbarImageExportTrigger.js +70 -0
  45. package/esm/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.d.ts +33 -0
  46. package/esm/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.js +68 -0
  47. package/esm/ChartsToolbarPro/ChartsToolbarPro.d.ts +16 -3
  48. package/esm/ChartsToolbarPro/ChartsToolbarPro.js +120 -8
  49. package/esm/ChartsToolbarPro/index.d.ts +3 -1
  50. package/esm/ChartsToolbarPro/index.js +3 -1
  51. package/esm/ChartsToolbarPro/internals/ChartsMenu.d.ts +14 -0
  52. package/esm/ChartsToolbarPro/internals/ChartsMenu.js +67 -0
  53. package/esm/ChartsToolbarPro/internals/ChartsToolbarDivider.d.ts +5 -0
  54. package/esm/ChartsToolbarPro/internals/ChartsToolbarDivider.js +40 -0
  55. package/esm/FunnelChart/FunnelPlot.js +56 -40
  56. package/esm/FunnelChart/FunnelSection.js +2 -0
  57. package/esm/FunnelChart/curves/bump.d.ts +3 -3
  58. package/esm/FunnelChart/curves/bump.js +3 -0
  59. package/esm/FunnelChart/curves/curve.types.d.ts +14 -1
  60. package/esm/FunnelChart/curves/getFunnelCurve.d.ts +7 -2
  61. package/esm/FunnelChart/curves/linear.d.ts +3 -3
  62. package/esm/FunnelChart/curves/linear.js +23 -18
  63. package/esm/FunnelChart/curves/pyramid.d.ts +3 -3
  64. package/esm/FunnelChart/curves/pyramid.js +17 -12
  65. package/esm/FunnelChart/curves/step-pyramid.d.ts +5 -5
  66. package/esm/FunnelChart/curves/step-pyramid.js +20 -18
  67. package/esm/FunnelChart/curves/step.d.ts +3 -3
  68. package/esm/FunnelChart/curves/step.js +14 -12
  69. package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.d.ts +18 -1444
  70. package/esm/FunnelChart/labelUtils.d.ts +4 -12
  71. package/esm/FunnelChart/labelUtils.js +43 -44
  72. package/esm/index.d.ts +2 -1
  73. package/esm/index.js +1 -1
  74. package/esm/internals/material/components/BaseMenuItem.d.ts +3 -0
  75. package/esm/internals/material/components/BaseMenuItem.js +27 -0
  76. package/esm/internals/material/components/BasePopper.d.ts +3 -0
  77. package/esm/internals/material/components/BasePopper.js +122 -0
  78. package/esm/internals/material/icons.d.ts +2 -1
  79. package/esm/internals/material/icons.js +4 -1
  80. package/esm/internals/material/index.d.ts +1 -0
  81. package/esm/internals/material/index.js +12 -3
  82. package/esm/internals/plugins/useChartProExport/print.js +1 -1
  83. package/esm/internals/plugins/useChartProExport/useChartProExport.types.d.ts +7 -6
  84. package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +16 -595
  85. package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +2 -2
  86. package/esm/internals/slots/chartBaseSlotProps.d.ts +50 -3
  87. package/esm/internals/slots/chartsBaseSlots.d.ts +5 -1
  88. package/esm/internals/slots/chartsIconSlots.d.ts +5 -0
  89. package/index.d.ts +2 -1
  90. package/index.js +1 -1
  91. package/internals/material/components/BaseMenuItem.d.ts +3 -0
  92. package/internals/material/components/BaseMenuItem.js +35 -0
  93. package/internals/material/components/BasePopper.d.ts +3 -0
  94. package/internals/material/components/BasePopper.js +130 -0
  95. package/internals/material/icons.d.ts +2 -1
  96. package/internals/material/icons.js +5 -2
  97. package/internals/material/index.d.ts +1 -0
  98. package/internals/material/index.js +11 -2
  99. package/internals/plugins/useChartProExport/print.js +1 -1
  100. package/internals/plugins/useChartProExport/useChartProExport.types.d.ts +7 -6
  101. package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +16 -595
  102. package/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +2 -2
  103. package/internals/slots/chartBaseSlotProps.d.ts +50 -3
  104. package/internals/slots/chartsBaseSlots.d.ts +5 -1
  105. package/internals/slots/chartsIconSlots.d.ts +5 -0
  106. package/package.json +5 -5
  107. package/FunnelChart/positionGetter.d.ts +0 -1
  108. package/FunnelChart/positionGetter.js +0 -5
  109. package/esm/FunnelChart/positionGetter.d.ts +0 -1
  110. package/esm/FunnelChart/positionGetter.js +0 -1
@@ -88,17 +88,9 @@ export class Pyramid {
88
88
  }
89
89
  return 0;
90
90
  }
91
- point(xIn, yIn) {
92
- this.points.push({
93
- x: xIn,
94
- y: yIn
95
- });
96
- if (this.points.length < 4) {
97
- return;
98
- }
99
-
91
+ processPoints(points) {
100
92
  // Replace funnel points by pyramids ones.
101
- this.points = this.points.map((point, index) => {
93
+ const processedPoints = points.map((point, index) => {
102
94
  if (this.isHorizontal) {
103
95
  const slopeEnd = {
104
96
  x: this.max.x,
@@ -134,10 +126,23 @@ export class Pyramid {
134
126
  const isLastSection = this.position === this.sections - 1;
135
127
  const isFirstSection = this.position === 0;
136
128
  if (isFirstSection && this.isIncreasing) {
137
- this.points = [this.points[0], this.points[1], this.points[2]];
129
+ return [processedPoints[0], processedPoints[1], processedPoints[2]];
138
130
  }
139
131
  if (isLastSection && !this.isIncreasing) {
140
- this.points = [this.points[0], this.points[1], this.points[3]];
132
+ return [processedPoints[0], processedPoints[1], processedPoints[3]];
133
+ }
134
+ return processedPoints;
135
+ }
136
+ point(xIn, yIn) {
137
+ this.points.push({
138
+ x: xIn,
139
+ y: yIn
140
+ });
141
+ const isLastSection = this.position === this.sections - 1;
142
+ const isFirstSection = this.position === 0;
143
+ const isSharpPoint = isLastSection && !this.isIncreasing || isFirstSection && this.isIncreasing;
144
+ if (this.points.length < (isSharpPoint ? 3 : 4)) {
145
+ return;
141
146
  }
142
147
  borderRadiusPolygon(this.context, this.points, this.getBorderRadius());
143
148
  }
@@ -1,11 +1,10 @@
1
- import { CurveGenerator } from '@mui/x-charts-vendor/d3-shape';
2
- import { CurveOptions, Point } from "./curve.types.js";
1
+ import { FunnelCurveGenerator, CurveOptions, Point } from "./curve.types.js";
3
2
  /**
4
3
  * This is a custom "step-pyramid" curve generator.
5
4
  * It creates a step pyramid, which is a step-like shape with static lengths.
6
5
  * It has the option to add a gap between sections while also properly handling the border radius.
7
6
  */
8
- export declare class StepPyramid implements CurveGenerator {
7
+ export declare class StepPyramid implements FunnelCurveGenerator {
9
8
  private context;
10
9
  private position;
11
10
  private sections;
@@ -33,7 +32,8 @@ export declare class StepPyramid implements CurveGenerator {
33
32
  protected getBorderRadius(): number | number[];
34
33
  slopeStart(index: number): Point;
35
34
  slopeEnd(index: number): Point;
36
- initialX(index: number): number;
37
- initialY(index: number): number;
35
+ initialX(index: number, points: Point[]): number;
36
+ initialY(index: number, points: Point[]): number;
37
+ processPoints(points: Point[]): Point[];
38
38
  point(xIn: number, yIn: number): void;
39
39
  }
@@ -130,46 +130,48 @@ export class StepPyramid {
130
130
  y: this.max.y
131
131
  };
132
132
  }
133
- initialX(index) {
133
+ initialX(index, points) {
134
134
  if (this.isIncreasing) {
135
- return index === 0 || index === 1 ? this.points.at(1).x : this.points.at(2).x;
135
+ return index === 0 || index === 1 ? points.at(1).x : points.at(2).x;
136
136
  }
137
- return index === 0 || index === 1 ? this.points.at(0).x : this.points.at(3).x;
137
+ return index === 0 || index === 1 ? points.at(0).x : points.at(3).x;
138
138
  }
139
- initialY(index) {
139
+ initialY(index, points) {
140
140
  if (this.isIncreasing) {
141
- return index === 0 || index === 1 ? this.points.at(1).y : this.points.at(2).y;
141
+ return index === 0 || index === 1 ? points.at(1).y : points.at(2).y;
142
142
  }
143
- return index === 0 || index === 1 ? this.points.at(0).y : this.points.at(3).y;
143
+ return index === 0 || index === 1 ? points.at(0).y : points.at(3).y;
144
144
  }
145
- point(xIn, yIn) {
146
- this.points.push({
147
- x: xIn,
148
- y: yIn
149
- });
150
- if (this.points.length < 4) {
151
- return;
152
- }
153
-
145
+ processPoints(points) {
154
146
  // Replace funnel points by pyramids ones.
155
- this.points = this.points.map((point, index) => {
147
+ const processedPoints = points.map((point, index) => {
156
148
  const slopeStart = this.slopeStart(index);
157
149
  const slopeEnd = this.slopeEnd(index);
158
150
  if (this.isHorizontal) {
159
151
  const yGetter = lerpY(slopeStart.x, slopeStart.y, slopeEnd.x, slopeEnd.y);
160
- const xInitial = this.initialX(index);
152
+ const xInitial = this.initialX(index, points);
161
153
  return {
162
154
  x: point.x,
163
155
  y: yGetter(xInitial)
164
156
  };
165
157
  }
166
158
  const xGetter = lerpX(slopeStart.x, slopeStart.y, slopeEnd.x, slopeEnd.y);
167
- const yInitial = this.initialY(index);
159
+ const yInitial = this.initialY(index, points);
168
160
  return {
169
161
  x: xGetter(yInitial),
170
162
  y: point.y
171
163
  };
172
164
  });
165
+ return processedPoints;
166
+ }
167
+ point(xIn, yIn) {
168
+ this.points.push({
169
+ x: xIn,
170
+ y: yIn
171
+ });
172
+ if (this.points.length < 4) {
173
+ return;
174
+ }
173
175
  borderRadiusPolygon(this.context, this.points, this.getBorderRadius());
174
176
  }
175
177
  }
@@ -1,5 +1,4 @@
1
- import { CurveGenerator } from '@mui/x-charts-vendor/d3-shape';
2
- import { CurveOptions } from "./curve.types.js";
1
+ import { FunnelCurveGenerator, CurveOptions, Point } from "./curve.types.js";
3
2
  /**
4
3
  * This is a custom "step" curve generator.
5
4
  * It is used to draw "rectangles" from 4 points without having to rework the rendering logic,
@@ -10,7 +9,7 @@ import { CurveOptions } from "./curve.types.js";
10
9
  * The implementation is based on the d3-shape step curve generator.
11
10
  * https://github.com/d3/d3-shape/blob/a82254af78f08799c71d7ab25df557c4872a3c51/src/curve/step.js
12
11
  */
13
- export declare class Step implements CurveGenerator {
12
+ export declare class Step implements FunnelCurveGenerator {
14
13
  private context;
15
14
  private isHorizontal;
16
15
  private isIncreasing;
@@ -32,5 +31,6 @@ export declare class Step implements CurveGenerator {
32
31
  lineStart(): void;
33
32
  lineEnd(): void;
34
33
  protected getBorderRadius(): number | number[];
34
+ processPoints(points: Point[]): Point[];
35
35
  point(xIn: number, yIn: number): void;
36
36
  }
@@ -57,19 +57,11 @@ export class Step {
57
57
  }
58
58
  return [this.borderRadius, this.borderRadius];
59
59
  }
60
- point(xIn, yIn) {
61
- this.points.push({
62
- x: xIn,
63
- y: yIn
64
- });
65
- if (this.points.length < 4) {
66
- return;
67
- }
68
-
60
+ processPoints(points) {
69
61
  // Ensure we have rectangles instead of trapezoids.
70
- this.points = this.points.map((_, index) => {
71
- const allX = this.points.map(p => p.x);
72
- const allY = this.points.map(p => p.y);
62
+ const processedPoints = points.map((_, index) => {
63
+ const allX = points.map(p => p.x);
64
+ const allY = points.map(p => p.y);
73
65
  if (this.isHorizontal) {
74
66
  return {
75
67
  x: index === 1 || index === 2 ? max(allX) : min(allX),
@@ -81,6 +73,16 @@ export class Step {
81
73
  y: index === 1 || index === 2 ? max(allY) : min(allY)
82
74
  };
83
75
  });
76
+ return processedPoints;
77
+ }
78
+ point(xIn, yIn) {
79
+ this.points.push({
80
+ x: xIn,
81
+ y: yIn
82
+ });
83
+ if (this.points.length < 4) {
84
+ return;
85
+ }
84
86
  borderRadiusPolygon(this.context, this.points, this.getBorderRadius());
85
87
  }
86
88
  }