@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
@@ -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
  }
@@ -93,17 +93,9 @@ class Pyramid {
93
93
  }
94
94
  return 0;
95
95
  }
96
- point(xIn, yIn) {
97
- this.points.push({
98
- x: xIn,
99
- y: yIn
100
- });
101
- if (this.points.length < 4) {
102
- return;
103
- }
104
-
96
+ processPoints(points) {
105
97
  // Replace funnel points by pyramids ones.
106
- this.points = this.points.map((point, index) => {
98
+ const processedPoints = points.map((point, index) => {
107
99
  if (this.isHorizontal) {
108
100
  const slopeEnd = {
109
101
  x: this.max.x,
@@ -139,10 +131,23 @@ class Pyramid {
139
131
  const isLastSection = this.position === this.sections - 1;
140
132
  const isFirstSection = this.position === 0;
141
133
  if (isFirstSection && this.isIncreasing) {
142
- this.points = [this.points[0], this.points[1], this.points[2]];
134
+ return [processedPoints[0], processedPoints[1], processedPoints[2]];
143
135
  }
144
136
  if (isLastSection && !this.isIncreasing) {
145
- this.points = [this.points[0], this.points[1], this.points[3]];
137
+ return [processedPoints[0], processedPoints[1], processedPoints[3]];
138
+ }
139
+ return processedPoints;
140
+ }
141
+ point(xIn, yIn) {
142
+ this.points.push({
143
+ x: xIn,
144
+ y: yIn
145
+ });
146
+ const isLastSection = this.position === this.sections - 1;
147
+ const isFirstSection = this.position === 0;
148
+ const isSharpPoint = isLastSection && !this.isIncreasing || isFirstSection && this.isIncreasing;
149
+ if (this.points.length < (isSharpPoint ? 3 : 4)) {
150
+ return;
146
151
  }
147
152
  (0, _borderRadiusPolygon.borderRadiusPolygon)(this.context, this.points, this.getBorderRadius());
148
153
  }
@@ -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
  }
@@ -135,46 +135,48 @@ class StepPyramid {
135
135
  y: this.max.y
136
136
  };
137
137
  }
138
- initialX(index) {
138
+ initialX(index, points) {
139
139
  if (this.isIncreasing) {
140
- return index === 0 || index === 1 ? this.points.at(1).x : this.points.at(2).x;
140
+ return index === 0 || index === 1 ? points.at(1).x : points.at(2).x;
141
141
  }
142
- return index === 0 || index === 1 ? this.points.at(0).x : this.points.at(3).x;
142
+ return index === 0 || index === 1 ? points.at(0).x : points.at(3).x;
143
143
  }
144
- initialY(index) {
144
+ initialY(index, points) {
145
145
  if (this.isIncreasing) {
146
- return index === 0 || index === 1 ? this.points.at(1).y : this.points.at(2).y;
146
+ return index === 0 || index === 1 ? points.at(1).y : points.at(2).y;
147
147
  }
148
- return index === 0 || index === 1 ? this.points.at(0).y : this.points.at(3).y;
148
+ return index === 0 || index === 1 ? points.at(0).y : points.at(3).y;
149
149
  }
150
- point(xIn, yIn) {
151
- this.points.push({
152
- x: xIn,
153
- y: yIn
154
- });
155
- if (this.points.length < 4) {
156
- return;
157
- }
158
-
150
+ processPoints(points) {
159
151
  // Replace funnel points by pyramids ones.
160
- this.points = this.points.map((point, index) => {
152
+ const processedPoints = points.map((point, index) => {
161
153
  const slopeStart = this.slopeStart(index);
162
154
  const slopeEnd = this.slopeEnd(index);
163
155
  if (this.isHorizontal) {
164
156
  const yGetter = (0, _utils.lerpY)(slopeStart.x, slopeStart.y, slopeEnd.x, slopeEnd.y);
165
- const xInitial = this.initialX(index);
157
+ const xInitial = this.initialX(index, points);
166
158
  return {
167
159
  x: point.x,
168
160
  y: yGetter(xInitial)
169
161
  };
170
162
  }
171
163
  const xGetter = (0, _utils.lerpX)(slopeStart.x, slopeStart.y, slopeEnd.x, slopeEnd.y);
172
- const yInitial = this.initialY(index);
164
+ const yInitial = this.initialY(index, points);
173
165
  return {
174
166
  x: xGetter(yInitial),
175
167
  y: point.y
176
168
  };
177
169
  });
170
+ return processedPoints;
171
+ }
172
+ point(xIn, yIn) {
173
+ this.points.push({
174
+ x: xIn,
175
+ y: yIn
176
+ });
177
+ if (this.points.length < 4) {
178
+ return;
179
+ }
178
180
  (0, _borderRadiusPolygon.borderRadiusPolygon)(this.context, this.points, this.getBorderRadius());
179
181
  }
180
182
  }
@@ -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
  }
@@ -62,19 +62,11 @@ class Step {
62
62
  }
63
63
  return [this.borderRadius, this.borderRadius];
64
64
  }
65
- point(xIn, yIn) {
66
- this.points.push({
67
- x: xIn,
68
- y: yIn
69
- });
70
- if (this.points.length < 4) {
71
- return;
72
- }
73
-
65
+ processPoints(points) {
74
66
  // Ensure we have rectangles instead of trapezoids.
75
- this.points = this.points.map((_, index) => {
76
- const allX = this.points.map(p => p.x);
77
- const allY = this.points.map(p => p.y);
67
+ const processedPoints = points.map((_, index) => {
68
+ const allX = points.map(p => p.x);
69
+ const allY = points.map(p => p.y);
78
70
  if (this.isHorizontal) {
79
71
  return {
80
72
  x: index === 1 || index === 2 ? (0, _utils.max)(allX) : (0, _utils.min)(allX),
@@ -86,6 +78,16 @@ class Step {
86
78
  y: index === 1 || index === 2 ? (0, _utils.max)(allY) : (0, _utils.min)(allY)
87
79
  };
88
80
  });
81
+ return processedPoints;
82
+ }
83
+ point(xIn, yIn) {
84
+ this.points.push({
85
+ x: xIn,
86
+ y: yIn
87
+ });
88
+ if (this.points.length < 4) {
89
+ return;
90
+ }
89
91
  (0, _borderRadiusPolygon.borderRadiusPolygon)(this.context, this.points, this.getBorderRadius());
90
92
  }
91
93
  }