@mui/x-charts-pro 8.5.2 → 8.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +96 -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/FunnelChart/FunnelPlot.js +56 -40
  9. package/FunnelChart/FunnelSection.js +2 -0
  10. package/FunnelChart/curves/bump.d.ts +3 -3
  11. package/FunnelChart/curves/bump.js +3 -0
  12. package/FunnelChart/curves/curve.types.d.ts +14 -1
  13. package/FunnelChart/curves/getFunnelCurve.d.ts +7 -2
  14. package/FunnelChart/curves/linear.d.ts +3 -3
  15. package/FunnelChart/curves/linear.js +23 -18
  16. package/FunnelChart/curves/pyramid.d.ts +3 -3
  17. package/FunnelChart/curves/pyramid.js +17 -12
  18. package/FunnelChart/curves/step-pyramid.d.ts +5 -5
  19. package/FunnelChart/curves/step-pyramid.js +20 -18
  20. package/FunnelChart/curves/step.d.ts +3 -3
  21. package/FunnelChart/curves/step.js +14 -12
  22. package/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.d.ts +18 -1444
  23. package/FunnelChart/labelUtils.d.ts +4 -12
  24. package/FunnelChart/labelUtils.js +43 -44
  25. package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  26. package/esm/ChartZoomSlider/internals/ChartAxisZoomSlider.js +1 -1
  27. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +21 -32
  28. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.js +1 -8
  29. package/esm/ChartZoomSlider/internals/zoom-utils.d.ts +3 -1
  30. package/esm/ChartZoomSlider/internals/zoom-utils.js +19 -9
  31. package/esm/FunnelChart/FunnelPlot.js +56 -40
  32. package/esm/FunnelChart/FunnelSection.js +2 -0
  33. package/esm/FunnelChart/curves/bump.d.ts +3 -3
  34. package/esm/FunnelChart/curves/bump.js +3 -0
  35. package/esm/FunnelChart/curves/curve.types.d.ts +14 -1
  36. package/esm/FunnelChart/curves/getFunnelCurve.d.ts +7 -2
  37. package/esm/FunnelChart/curves/linear.d.ts +3 -3
  38. package/esm/FunnelChart/curves/linear.js +23 -18
  39. package/esm/FunnelChart/curves/pyramid.d.ts +3 -3
  40. package/esm/FunnelChart/curves/pyramid.js +17 -12
  41. package/esm/FunnelChart/curves/step-pyramid.d.ts +5 -5
  42. package/esm/FunnelChart/curves/step-pyramid.js +20 -18
  43. package/esm/FunnelChart/curves/step.d.ts +3 -3
  44. package/esm/FunnelChart/curves/step.js +14 -12
  45. package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.d.ts +18 -1444
  46. package/esm/FunnelChart/labelUtils.d.ts +4 -12
  47. package/esm/FunnelChart/labelUtils.js +43 -44
  48. package/esm/index.js +1 -1
  49. package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +16 -595
  50. package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +2 -2
  51. package/index.js +1 -1
  52. package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +16 -595
  53. package/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +2 -2
  54. package/package.json +5 -5
  55. package/FunnelChart/positionGetter.d.ts +0 -1
  56. package/FunnelChart/positionGetter.js +0 -5
  57. package/esm/FunnelChart/positionGetter.d.ts +0 -1
  58. package/esm/FunnelChart/positionGetter.js +0 -1
@@ -92,7 +92,7 @@ export class Linear {
92
92
  }
93
93
  // Is smallest section and shaped like a triangle
94
94
  if (this.position === this.sections - 1 && this.pointShape === 'sharp') {
95
- return [this.borderRadius];
95
+ return [0, 0, this.borderRadius];
96
96
  }
97
97
 
98
98
  // Is smallest section
@@ -102,19 +102,11 @@ export class Linear {
102
102
  }
103
103
  return 0;
104
104
  }
105
- point(xIn, yIn) {
106
- this.points.push({
107
- x: xIn,
108
- y: yIn
109
- });
110
- if (this.points.length < 4) {
111
- return;
112
- }
113
-
105
+ processPoints(points) {
114
106
  // Add gaps where they are needed.
115
- this.points = this.points.map((point, index) => {
116
- const slopeStart = this.points.at(index <= 1 ? 0 : 3);
117
- const slopeEnd = this.points.at(index <= 1 ? 1 : 2);
107
+ const processedPoints = points.map((point, index) => {
108
+ const slopeStart = points.at(index <= 1 ? 0 : 3);
109
+ const slopeEnd = points.at(index <= 1 ? 1 : 2);
118
110
  if (this.isHorizontal) {
119
111
  const yGetter = lerpY(slopeStart.x - this.gap, slopeStart.y, slopeEnd.x, slopeEnd.y);
120
112
  return {
@@ -136,15 +128,15 @@ export class Linear {
136
128
  let firstPoint = null;
137
129
  let secondPoint = null;
138
130
  if (isFirstSection && this.isIncreasing) {
139
- firstPoint = this.points[1];
140
- secondPoint = this.points[2];
131
+ firstPoint = processedPoints[1];
132
+ secondPoint = processedPoints[2];
141
133
  }
142
134
  if (isLastSection && !this.isIncreasing) {
143
- firstPoint = this.points[3];
144
- secondPoint = this.points[0];
135
+ firstPoint = processedPoints[3];
136
+ secondPoint = processedPoints[0];
145
137
  }
146
138
  if (firstPoint && secondPoint) {
147
- this.points = [
139
+ return [
148
140
  // Sharp point at the start
149
141
  this.isHorizontal ? {
150
142
  x: this.max.x,
@@ -157,6 +149,19 @@ export class Linear {
157
149
  firstPoint, secondPoint];
158
150
  }
159
151
  }
152
+ return processedPoints;
153
+ }
154
+ point(xIn, yIn) {
155
+ this.points.push({
156
+ x: xIn,
157
+ y: yIn
158
+ });
159
+ const isLastSection = this.position === this.sections - 1;
160
+ const isFirstSection = this.position === 0;
161
+ const isSharpPoint = this.pointShape === 'sharp' && (isLastSection && !this.isIncreasing || isFirstSection && this.isIncreasing);
162
+ if (this.points.length < (isSharpPoint ? 3 : 4)) {
163
+ return;
164
+ }
160
165
  borderRadiusPolygon(this.context, this.points, this.getBorderRadius());
161
166
  }
162
167
  }
@@ -1,12 +1,11 @@
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 "pyramid" curve generator.
5
4
  * It draws straight lines for the 4 provided points. The slopes are calculated
6
5
  * based on the min and max values of the x and y axes.
7
6
  * with the option to add a gap between sections while also properly handling the border radius.
8
7
  */
9
- export declare class Pyramid implements CurveGenerator {
8
+ export declare class Pyramid implements FunnelCurveGenerator {
10
9
  private context;
11
10
  private position;
12
11
  private sections;
@@ -32,5 +31,6 @@ export declare class Pyramid 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
  }
@@ -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
  }