@mui/x-charts-pro 8.4.0 → 8.5.1

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 (184) hide show
  1. package/BarChartPro/BarChartPro.d.ts +13 -5
  2. package/BarChartPro/BarChartPro.js +19 -1
  3. package/CHANGELOG.md +215 -0
  4. package/ChartContainerPro/ChartContainerPro.d.ts +0 -1
  5. package/ChartContainerPro/ChartProApi.d.ts +28 -0
  6. package/ChartContainerPro/ChartProApi.js +5 -0
  7. package/ChartContainerPro/index.d.ts +2 -1
  8. package/ChartContainerPro/index.js +11 -0
  9. package/ChartDataProviderPro/ChartDataProviderPro.d.ts +11 -1
  10. package/ChartDataProviderPro/ChartDataProviderPro.js +19 -3
  11. package/ChartDataProviderPro/useChartDataProviderProProps.d.ts +2 -0
  12. package/ChartDataProviderPro/useChartDataProviderProProps.js +5 -1
  13. package/ChartZoomSlider/internals/ChartAxisZoomSlider.d.ts +1 -3
  14. package/ChartZoomSlider/internals/ChartAxisZoomSlider.js +25 -315
  15. package/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.d.ts +22 -0
  16. package/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +283 -0
  17. package/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.d.ts +18 -0
  18. package/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.js +138 -0
  19. package/ChartZoomSlider/internals/constants.d.ts +5 -0
  20. package/ChartZoomSlider/internals/constants.js +11 -0
  21. package/ChartZoomSlider/internals/zoom-utils.d.ts +4 -0
  22. package/ChartZoomSlider/internals/zoom-utils.js +48 -0
  23. package/ChartsToolbarPro/ChartsToolbarPro.d.ts +5 -1
  24. package/ChartsToolbarPro/ChartsToolbarPro.js +35 -7
  25. package/ChartsToolbarPro/ChartsToolbarZoomInTrigger.d.ts +17 -0
  26. package/ChartsToolbarPro/ChartsToolbarZoomInTrigger.js +57 -0
  27. package/ChartsToolbarPro/ChartsToolbarZoomOutTrigger.d.ts +17 -0
  28. package/ChartsToolbarPro/ChartsToolbarZoomOutTrigger.js +57 -0
  29. package/ChartsToolbarPro/index.d.ts +3 -1
  30. package/ChartsToolbarPro/index.js +22 -0
  31. package/FunnelChart/FunnelChart.d.ts +2 -1
  32. package/FunnelChart/FunnelChart.js +2 -20
  33. package/FunnelChart/FunnelChart.plugins.d.ts +4 -0
  34. package/FunnelChart/FunnelChart.plugins.js +9 -0
  35. package/FunnelChart/FunnelPlot.js +10 -22
  36. package/FunnelChart/FunnelSection.d.ts +1 -1
  37. package/FunnelChart/FunnelSectionLabel.d.ts +21 -0
  38. package/FunnelChart/FunnelSectionLabel.js +52 -0
  39. package/FunnelChart/curves/bump.d.ts +10 -4
  40. package/FunnelChart/curves/bump.js +73 -41
  41. package/FunnelChart/curves/curve.types.d.ts +6 -1
  42. package/FunnelChart/curves/getFunnelCurve.js +3 -0
  43. package/FunnelChart/curves/linear.d.ts +9 -1
  44. package/FunnelChart/curves/linear.js +82 -5
  45. package/FunnelChart/funnel.types.d.ts +1 -0
  46. package/FunnelChart/funnelPlotSlots.types.d.ts +11 -0
  47. package/FunnelChart/funnelSectionClasses.d.ts +2 -0
  48. package/FunnelChart/funnelSectionClasses.js +17 -4
  49. package/FunnelChart/funnelSlots.types.d.ts +4 -3
  50. package/FunnelChart/index.d.ts +3 -1
  51. package/FunnelChart/index.js +18 -2
  52. package/FunnelChart/useFunnelChartProps.d.ts +2 -1
  53. package/FunnelChart/useFunnelChartProps.js +3 -1
  54. package/Heatmap/Heatmap.d.ts +22 -4
  55. package/Heatmap/Heatmap.js +64 -22
  56. package/Heatmap/Heatmap.plugins.d.ts +2 -1
  57. package/Heatmap/Heatmap.plugins.js +2 -1
  58. package/Heatmap/HeatmapTooltip/HeatmapTooltipAxesValue.d.ts +1 -1
  59. package/LineChartPro/LineChartPro.d.ts +13 -5
  60. package/LineChartPro/LineChartPro.js +19 -1
  61. package/PieChartPro/PieChartPro.d.ts +21 -0
  62. package/PieChartPro/PieChartPro.js +204 -0
  63. package/PieChartPro/PieChartPro.plugins.d.ts +4 -0
  64. package/PieChartPro/PieChartPro.plugins.js +9 -0
  65. package/PieChartPro/index.d.ts +1 -0
  66. package/PieChartPro/index.js +16 -0
  67. package/RadarChartPro/RadarChartPro.d.ts +15 -0
  68. package/RadarChartPro/RadarChartPro.js +202 -0
  69. package/RadarChartPro/RadarChartPro.plugins.d.ts +4 -0
  70. package/RadarChartPro/RadarChartPro.plugins.js +9 -0
  71. package/RadarChartPro/index.d.ts +1 -0
  72. package/RadarChartPro/index.js +16 -0
  73. package/ScatterChartPro/ScatterChartPro.d.ts +13 -5
  74. package/ScatterChartPro/ScatterChartPro.js +19 -1
  75. package/context/index.d.ts +1 -0
  76. package/context/index.js +16 -0
  77. package/context/useChartApiContext.d.ts +9 -0
  78. package/context/useChartApiContext.js +17 -0
  79. package/esm/BarChartPro/BarChartPro.d.ts +13 -5
  80. package/esm/BarChartPro/BarChartPro.js +19 -1
  81. package/esm/ChartContainerPro/ChartContainerPro.d.ts +0 -1
  82. package/esm/ChartContainerPro/ChartProApi.d.ts +28 -0
  83. package/esm/ChartContainerPro/ChartProApi.js +1 -0
  84. package/esm/ChartContainerPro/index.d.ts +2 -1
  85. package/esm/ChartContainerPro/index.js +2 -1
  86. package/esm/ChartDataProviderPro/ChartDataProviderPro.d.ts +11 -1
  87. package/esm/ChartDataProviderPro/ChartDataProviderPro.js +20 -4
  88. package/esm/ChartDataProviderPro/useChartDataProviderProProps.d.ts +2 -0
  89. package/esm/ChartDataProviderPro/useChartDataProviderProProps.js +5 -1
  90. package/esm/ChartZoomSlider/internals/ChartAxisZoomSlider.d.ts +1 -3
  91. package/esm/ChartZoomSlider/internals/ChartAxisZoomSlider.js +19 -306
  92. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.d.ts +22 -0
  93. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +275 -0
  94. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.d.ts +18 -0
  95. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.js +130 -0
  96. package/esm/ChartZoomSlider/internals/constants.d.ts +5 -0
  97. package/esm/ChartZoomSlider/internals/constants.js +5 -0
  98. package/esm/ChartZoomSlider/internals/zoom-utils.d.ts +4 -0
  99. package/esm/ChartZoomSlider/internals/zoom-utils.js +40 -0
  100. package/esm/ChartsToolbarPro/ChartsToolbarPro.d.ts +5 -1
  101. package/esm/ChartsToolbarPro/ChartsToolbarPro.js +36 -9
  102. package/esm/ChartsToolbarPro/ChartsToolbarZoomInTrigger.d.ts +17 -0
  103. package/esm/ChartsToolbarPro/ChartsToolbarZoomInTrigger.js +51 -0
  104. package/esm/ChartsToolbarPro/ChartsToolbarZoomOutTrigger.d.ts +17 -0
  105. package/esm/ChartsToolbarPro/ChartsToolbarZoomOutTrigger.js +51 -0
  106. package/esm/ChartsToolbarPro/index.d.ts +3 -1
  107. package/esm/ChartsToolbarPro/index.js +3 -1
  108. package/esm/FunnelChart/FunnelChart.d.ts +2 -1
  109. package/esm/FunnelChart/FunnelChart.js +2 -20
  110. package/esm/FunnelChart/FunnelChart.plugins.d.ts +4 -0
  111. package/esm/FunnelChart/FunnelChart.plugins.js +3 -0
  112. package/esm/FunnelChart/FunnelPlot.js +10 -22
  113. package/esm/FunnelChart/FunnelSection.d.ts +1 -1
  114. package/esm/FunnelChart/FunnelSectionLabel.d.ts +21 -0
  115. package/esm/FunnelChart/FunnelSectionLabel.js +46 -0
  116. package/esm/FunnelChart/curves/bump.d.ts +10 -4
  117. package/esm/FunnelChart/curves/bump.js +73 -41
  118. package/esm/FunnelChart/curves/curve.types.d.ts +6 -1
  119. package/esm/FunnelChart/curves/getFunnelCurve.js +3 -0
  120. package/esm/FunnelChart/curves/linear.d.ts +9 -1
  121. package/esm/FunnelChart/curves/linear.js +82 -5
  122. package/esm/FunnelChart/funnel.types.d.ts +1 -0
  123. package/esm/FunnelChart/funnelPlotSlots.types.d.ts +11 -0
  124. package/esm/FunnelChart/funnelSectionClasses.d.ts +2 -0
  125. package/esm/FunnelChart/funnelSectionClasses.js +15 -3
  126. package/esm/FunnelChart/funnelSlots.types.d.ts +4 -3
  127. package/esm/FunnelChart/index.d.ts +3 -1
  128. package/esm/FunnelChart/index.js +3 -1
  129. package/esm/FunnelChart/useFunnelChartProps.d.ts +2 -1
  130. package/esm/FunnelChart/useFunnelChartProps.js +3 -1
  131. package/esm/Heatmap/Heatmap.d.ts +22 -4
  132. package/esm/Heatmap/Heatmap.js +64 -22
  133. package/esm/Heatmap/Heatmap.plugins.d.ts +2 -1
  134. package/esm/Heatmap/Heatmap.plugins.js +2 -1
  135. package/esm/Heatmap/HeatmapTooltip/HeatmapTooltipAxesValue.d.ts +1 -1
  136. package/esm/LineChartPro/LineChartPro.d.ts +13 -5
  137. package/esm/LineChartPro/LineChartPro.js +19 -1
  138. package/esm/PieChartPro/PieChartPro.d.ts +21 -0
  139. package/esm/PieChartPro/PieChartPro.js +197 -0
  140. package/esm/PieChartPro/PieChartPro.plugins.d.ts +4 -0
  141. package/esm/PieChartPro/PieChartPro.plugins.js +3 -0
  142. package/esm/PieChartPro/index.d.ts +1 -0
  143. package/esm/PieChartPro/index.js +1 -0
  144. package/esm/RadarChartPro/RadarChartPro.d.ts +15 -0
  145. package/esm/RadarChartPro/RadarChartPro.js +195 -0
  146. package/esm/RadarChartPro/RadarChartPro.plugins.d.ts +4 -0
  147. package/esm/RadarChartPro/RadarChartPro.plugins.js +3 -0
  148. package/esm/RadarChartPro/index.d.ts +1 -0
  149. package/esm/RadarChartPro/index.js +1 -0
  150. package/esm/ScatterChartPro/ScatterChartPro.d.ts +13 -5
  151. package/esm/ScatterChartPro/ScatterChartPro.js +19 -1
  152. package/esm/context/index.d.ts +1 -0
  153. package/esm/context/index.js +1 -0
  154. package/esm/context/useChartApiContext.d.ts +9 -0
  155. package/esm/context/useChartApiContext.js +11 -0
  156. package/esm/hooks/index.d.ts +2 -1
  157. package/esm/hooks/index.js +2 -1
  158. package/esm/index.d.ts +3 -1
  159. package/esm/index.js +3 -1
  160. package/esm/internals/material/index.d.ts +1 -0
  161. package/esm/internals/plugins/useChartProZoom/useChartProZoom.js +10 -0
  162. package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +358 -0
  163. package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +15 -1
  164. package/esm/internals/plugins/useChartProZoom/useChartProZoom.types.d.ts +7 -0
  165. package/esm/models/index.d.ts +1 -1
  166. package/hooks/index.d.ts +2 -1
  167. package/hooks/index.js +21 -10
  168. package/index.d.ts +3 -1
  169. package/index.js +23 -1
  170. package/internals/material/index.d.ts +1 -0
  171. package/internals/plugins/useChartProZoom/useChartProZoom.js +10 -0
  172. package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +358 -0
  173. package/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +16 -2
  174. package/internals/plugins/useChartProZoom/useChartProZoom.types.d.ts +7 -0
  175. package/models/index.d.ts +1 -1
  176. package/package.json +7 -7
  177. package/ChartsToolbarPro/internal/ChartsToolbarZoomInButton.d.ts +0 -13
  178. package/ChartsToolbarPro/internal/ChartsToolbarZoomInButton.js +0 -36
  179. package/ChartsToolbarPro/internal/ChartsToolbarZoomOutButton.d.ts +0 -13
  180. package/ChartsToolbarPro/internal/ChartsToolbarZoomOutButton.js +0 -36
  181. package/esm/ChartsToolbarPro/internal/ChartsToolbarZoomInButton.d.ts +0 -13
  182. package/esm/ChartsToolbarPro/internal/ChartsToolbarZoomInButton.js +0 -29
  183. package/esm/ChartsToolbarPro/internal/ChartsToolbarZoomOutButton.d.ts +0 -13
  184. package/esm/ChartsToolbarPro/internal/ChartsToolbarZoomOutButton.js +0 -29
@@ -11,64 +11,96 @@
11
11
  export class Bump {
12
12
  constructor(context, {
13
13
  isHorizontal,
14
- gap
14
+ gap,
15
+ min,
16
+ max,
17
+ isIncreasing
15
18
  }) {
16
19
  this.context = void 0;
17
- this.x = NaN;
18
- this.y = NaN;
19
- this.currentPoint = 0;
20
20
  this.isHorizontal = false;
21
21
  this.gap = 0;
22
+ this.min = {
23
+ x: 0,
24
+ y: 0
25
+ };
26
+ this.max = {
27
+ x: 0,
28
+ y: 0
29
+ };
30
+ this.points = [];
22
31
  this.context = context;
23
32
  this.isHorizontal = isHorizontal ?? false;
24
33
  this.gap = (gap ?? 0) / 2;
34
+ this.min = min ?? {
35
+ x: 0,
36
+ y: 0
37
+ };
38
+ this.max = max ?? {
39
+ x: 0,
40
+ y: 0
41
+ };
42
+ if (isIncreasing) {
43
+ const currentMin = this.min;
44
+ const currentMax = this.max;
45
+ this.min = currentMax;
46
+ this.max = currentMin;
47
+ }
25
48
  }
26
49
  areaStart() {}
27
50
  areaEnd() {}
28
51
  lineStart() {}
29
52
  lineEnd() {}
30
53
  point(x, y) {
31
- x = +x;
32
- y = +y;
33
-
34
- // 0 is the top-left corner.
35
- if (this.isHorizontal) {
36
- if (this.currentPoint === 0) {
37
- this.context.moveTo(x + this.gap, y);
38
- this.context.lineTo(x + this.gap, y);
39
- } else if (this.currentPoint === 1) {
40
- this.context.bezierCurveTo((this.x + x) / 2, this.y, (this.x + x) / 2, y, x - this.gap, y);
41
- } else if (this.currentPoint === 2) {
42
- this.context.lineTo(x - this.gap, y);
43
- } else {
44
- this.context.bezierCurveTo((this.x + x) / 2, this.y, (this.x + x) / 2, y, x + this.gap, y);
45
- }
46
- if (this.currentPoint === 3) {
47
- this.context.closePath();
48
- }
49
- this.currentPoint += 1;
50
- this.x = x;
51
- this.y = y;
54
+ this.points.push({
55
+ x,
56
+ y
57
+ });
58
+ if (this.points.length < 4) {
52
59
  return;
53
60
  }
54
61
 
55
- // 0 is the top-right corner.
56
- if (this.currentPoint === 0) {
57
- // X from Y
58
- this.context.moveTo(x, y + this.gap);
59
- this.context.lineTo(x, y + this.gap);
60
- } else if (this.currentPoint === 1) {
61
- this.context.bezierCurveTo(this.x, (this.y + y) / 2, x, (this.y + y) / 2, x, y - this.gap);
62
- } else if (this.currentPoint === 2) {
63
- this.context.lineTo(x, y - this.gap);
62
+ // Draw the path using bezier curves
63
+ this.drawPath();
64
+ }
65
+ drawPath() {
66
+ if (this.isHorizontal) {
67
+ this.drawHorizontalPath();
64
68
  } else {
65
- this.context.bezierCurveTo(this.x, (this.y + y) / 2, x, (this.y + y) / 2, x, y + this.gap);
66
- }
67
- if (this.currentPoint === 3) {
68
- this.context.closePath();
69
+ this.drawVerticalPath();
69
70
  }
70
- this.currentPoint += 1;
71
- this.x = x;
72
- this.y = y;
71
+ }
72
+ drawHorizontalPath() {
73
+ const [p0, p1, p2, p3] = this.points;
74
+
75
+ // 0 is the top-left corner
76
+ this.context.moveTo(p0.x + this.gap, p0.y);
77
+ this.context.lineTo(p0.x + this.gap, p0.y);
78
+
79
+ // Bezier curve to point 1
80
+ this.context.bezierCurveTo((p0.x + p1.x) / 2, p0.y, (p0.x + p1.x) / 2, p1.y, p1.x - this.gap, p1.y);
81
+
82
+ // Line to point 2
83
+ this.context.lineTo(p2.x - this.gap, p2.y);
84
+
85
+ // Bezier curve back to point 3
86
+ this.context.bezierCurveTo((p2.x + p3.x) / 2, p2.y, (p2.x + p3.x) / 2, p3.y, p3.x + this.gap, p3.y);
87
+ this.context.closePath();
88
+ }
89
+ drawVerticalPath() {
90
+ const [p0, p1, p2, p3] = this.points;
91
+
92
+ // 0 is the top-right corner
93
+ this.context.moveTo(p0.x, p0.y + this.gap);
94
+ this.context.lineTo(p0.x, p0.y + this.gap);
95
+
96
+ // Bezier curve to point 1
97
+ this.context.bezierCurveTo(p0.x, (p0.y + p1.y) / 2, p1.x, (p0.y + p1.y) / 2, p1.x, p1.y - this.gap);
98
+
99
+ // Line to point 2
100
+ this.context.lineTo(p2.x, p2.y - this.gap);
101
+
102
+ // Bezier curve back to point 3
103
+ this.context.bezierCurveTo(p2.x, (p2.y + p3.y) / 2, p3.x, (p2.y + p3.y) / 2, p3.x, p3.y + this.gap);
104
+ this.context.closePath();
73
105
  }
74
106
  }
@@ -34,8 +34,13 @@ export type CurveOptions = {
34
34
  * The maximum point for all the segments.
35
35
  */
36
36
  max?: Point;
37
+ /**
38
+ * The shape of the point of the funnel for the curves that support it.
39
+ */
40
+ pointShape?: FunnelPointShape;
37
41
  };
38
- export type FunnelCurveType = 'linear' | 'step' | 'bump' | 'pyramid' | 'step-pyramid';
42
+ export type FunnelCurveType = 'linear' | 'linear-sharp' | 'step' | 'bump' | 'pyramid' | 'step-pyramid';
43
+ export type FunnelPointShape = 'square' | 'sharp';
39
44
  export type Point = {
40
45
  x: number;
41
46
  y: number;
@@ -19,5 +19,8 @@ const curveConstructor = curve => {
19
19
  return Linear;
20
20
  };
21
21
  export const getFunnelCurve = (curve, options) => {
22
+ if (curve === 'linear-sharp') {
23
+ options.pointShape = 'sharp';
24
+ }
22
25
  return context => new (curveConstructor(curve))(context, options);
23
26
  };
@@ -13,15 +13,23 @@ export declare class Linear implements CurveGenerator {
13
13
  private position;
14
14
  private sections;
15
15
  private isHorizontal;
16
+ private isIncreasing;
16
17
  private gap;
17
18
  private borderRadius;
19
+ private min;
20
+ private max;
18
21
  private points;
22
+ private pointShape;
19
23
  constructor(context: CanvasRenderingContext2D, {
20
24
  isHorizontal,
21
25
  gap,
22
26
  position,
23
27
  sections,
24
- borderRadius
28
+ borderRadius,
29
+ min,
30
+ max,
31
+ isIncreasing,
32
+ pointShape
25
33
  }: CurveOptions);
26
34
  areaStart(): void;
27
35
  areaEnd(): void;
@@ -17,21 +17,51 @@ export class Linear {
17
17
  gap,
18
18
  position,
19
19
  sections,
20
- borderRadius
20
+ borderRadius,
21
+ min,
22
+ max,
23
+ isIncreasing,
24
+ pointShape
21
25
  }) {
22
26
  this.context = void 0;
23
27
  this.position = 0;
24
28
  this.sections = 0;
25
29
  this.isHorizontal = false;
30
+ this.isIncreasing = false;
26
31
  this.gap = 0;
27
32
  this.borderRadius = 0;
33
+ this.min = {
34
+ x: 0,
35
+ y: 0
36
+ };
37
+ this.max = {
38
+ x: 0,
39
+ y: 0
40
+ };
28
41
  this.points = [];
42
+ this.pointShape = 'square';
29
43
  this.context = context;
30
44
  this.isHorizontal = isHorizontal ?? false;
31
45
  this.gap = (gap ?? 0) / 2;
32
46
  this.position = position ?? 0;
33
47
  this.sections = sections ?? 1;
34
48
  this.borderRadius = borderRadius ?? 0;
49
+ this.isIncreasing = isIncreasing ?? false;
50
+ this.min = min ?? {
51
+ x: 0,
52
+ y: 0
53
+ };
54
+ this.max = max ?? {
55
+ x: 0,
56
+ y: 0
57
+ };
58
+ this.pointShape = pointShape ?? 'square';
59
+ if (isIncreasing) {
60
+ const currentMin = this.min;
61
+ const currentMax = this.max;
62
+ this.min = currentMax;
63
+ this.max = currentMin;
64
+ }
35
65
  }
36
66
  areaStart() {}
37
67
  areaEnd() {}
@@ -41,11 +71,34 @@ export class Linear {
41
71
  if (this.gap > 0) {
42
72
  return this.borderRadius;
43
73
  }
44
- if (this.position === 0) {
45
- return [0, 0, this.borderRadius, this.borderRadius];
74
+ if (this.isIncreasing) {
75
+ // Is largest section
76
+ if (this.position === this.sections - 1) {
77
+ return [this.borderRadius, this.borderRadius];
78
+ }
79
+ // Is smallest section and shaped like a triangle
80
+ if (this.position === 0 && this.pointShape === 'sharp') {
81
+ return [0, 0, this.borderRadius];
82
+ }
83
+ // Is smallest section
84
+ if (this.position === 0) {
85
+ return [0, 0, this.borderRadius, this.borderRadius];
86
+ }
46
87
  }
47
- if (this.position === this.sections - 1) {
48
- return [this.borderRadius, this.borderRadius];
88
+ if (!this.isIncreasing) {
89
+ // Is largest section
90
+ if (this.position === 0) {
91
+ return [0, 0, this.borderRadius, this.borderRadius];
92
+ }
93
+ // Is smallest section and shaped like a triangle
94
+ if (this.position === this.sections - 1 && this.pointShape === 'sharp') {
95
+ return [this.borderRadius];
96
+ }
97
+
98
+ // Is smallest section
99
+ if (this.position === this.sections - 1) {
100
+ return [this.borderRadius, this.borderRadius];
101
+ }
49
102
  }
50
103
  return 0;
51
104
  }
@@ -77,6 +130,30 @@ export class Linear {
77
130
  y: yGap
78
131
  };
79
132
  });
133
+ if (this.pointShape === 'sharp') {
134
+ // In the last section, to form a triangle we need 3 points instead of 4
135
+ // Else the algorithm will break.
136
+ const isLastSection = this.position === this.sections - 1;
137
+ const isFirstSection = this.position === 0;
138
+ if (isFirstSection && this.isIncreasing) {
139
+ this.points = [this.isHorizontal ? {
140
+ x: this.max.x + this.gap,
141
+ y: (this.max.y + this.min.y) / 2
142
+ } : {
143
+ x: (this.max.x + this.min.x) / 2,
144
+ y: this.max.y + this.gap
145
+ }, this.points[1], this.points[2]];
146
+ }
147
+ if (isLastSection && !this.isIncreasing) {
148
+ this.points = [this.points[0], this.isHorizontal ? {
149
+ x: this.max.x - this.gap,
150
+ y: (this.max.y + this.min.y) / 2
151
+ } : {
152
+ x: (this.max.x + this.min.x) / 2,
153
+ y: this.max.y - this.gap
154
+ }, this.points[3]];
155
+ }
156
+ }
80
157
  borderRadiusPolygon(this.context, this.points, this.getBorderRadius());
81
158
  }
82
159
  }
@@ -47,6 +47,7 @@ export interface FunnelSeriesType extends Omit<CommonSeriesType<FunnelValueType>
47
47
  *
48
48
  * - `bump`: A curve that creates a smooth transition between points, with a bump in the middle.
49
49
  * - `linear`: A straight line between points.
50
+ * - `linear-sharp`: A straight line between points, the smaller end of the funnel is a triangle.
50
51
  * - `step`: A step line that creates a staircase effect.
51
52
  * - `pyramid`: A pyramid shape that connects the points.
52
53
  * - `step-pyramid`: A step line that creates a staircase effect, with a pyramid shape.
@@ -1,10 +1,21 @@
1
1
  import * as React from 'react';
2
2
  import type { FunnelSectionProps } from "./FunnelSection.js";
3
+ import { FunnelSectionLabelProps } from "./FunnelSectionLabel.js";
3
4
  export interface FunnelPlotSlots {
5
+ /**
6
+ * Custom component for funnel section.
7
+ * @default FunnelSection
8
+ */
4
9
  funnelSection?: React.ElementType<FunnelSectionProps>;
10
+ /**
11
+ * Custom component for funnel section label.
12
+ * @default FunnelSectionLabel
13
+ */
14
+ funnelSectionLabel?: React.ElementType<FunnelSectionLabelProps>;
5
15
  }
6
16
  export interface FunnelPlotSlotProps {
7
17
  funnelSection?: FunnelSectionProps;
18
+ funnelSectionLabel?: FunnelSectionLabelProps;
8
19
  }
9
20
  export interface FunnelPlotSlotExtension {
10
21
  /**
@@ -1,4 +1,5 @@
1
1
  import type { FunnelSectionProps } from "./FunnelSection.js";
2
+ import type { FunnelSectionLabelProps } from "./FunnelSectionLabel.js";
2
3
  export interface FunnelSectionClasses {
3
4
  /** Styles applied to the root element. */
4
5
  root: string;
@@ -19,4 +20,5 @@ export interface FunnelSectionClasses {
19
20
  series: string;
20
21
  }
21
22
  export declare const useUtilityClasses: (props: FunnelSectionProps) => Record<"label" | "filled" | "outlined" | "highlighted" | "faded" | "root", string>;
23
+ export declare const useLabelUtilityClasses: (props: FunnelSectionLabelProps) => Record<"label", string>;
22
24
  export declare const funnelSectionClasses: FunnelSectionClasses;
@@ -8,10 +8,11 @@ export const useUtilityClasses = props => {
8
8
  const {
9
9
  classes,
10
10
  seriesId,
11
- variant
11
+ variant,
12
+ dataIndex
12
13
  } = props;
13
14
  const slots = {
14
- root: ['root', `series-${seriesId}`],
15
+ root: ['root', `series-${seriesId}`, `data-index-${dataIndex}`],
15
16
  highlighted: ['highlighted'],
16
17
  faded: ['faded'],
17
18
  outlined: variant === 'outlined' ? ['outlined'] : [],
@@ -20,4 +21,15 @@ export const useUtilityClasses = props => {
20
21
  };
21
22
  return composeClasses(slots, getFunnelSectionUtilityClass, classes);
22
23
  };
23
- export const funnelSectionClasses = generateUtilityClasses('MuiFunnelSection', ['root', 'highlighted', 'faded', 'filled', 'outlined', 'label', 'series']);
24
+ export const useLabelUtilityClasses = props => {
25
+ const {
26
+ classes,
27
+ seriesId,
28
+ dataIndex
29
+ } = props;
30
+ const slots = {
31
+ label: ['label', `series-${seriesId}`, `data-index-${dataIndex}`]
32
+ };
33
+ return composeClasses(slots, getFunnelSectionUtilityClass, classes);
34
+ };
35
+ export const funnelSectionClasses = generateUtilityClasses('MuiFunnelSection', ['root', 'highlighted', 'faded', 'filled', 'outlined', 'label', 'series', 'data-index']);
@@ -1,10 +1,11 @@
1
1
  import { ChartsOverlaySlotProps, ChartsOverlaySlots } from '@mui/x-charts/ChartsOverlay';
2
2
  import { ChartsTooltipSlotProps, ChartsTooltipSlots } from '@mui/x-charts/ChartsTooltip';
3
- import { ChartsAxisSlotProps, ChartsAxisSlots } from '@mui/x-charts/internals';
3
+ import { ChartsAxisSlotProps, ChartsAxisSlots, ChartsSlotProps, ChartsSlots } from '@mui/x-charts/internals';
4
4
  import { ChartsLegendSlotProps, ChartsLegendSlots } from '@mui/x-charts/ChartsLegend';
5
+ import { ChartsToolbarSlotProps, ChartsToolbarSlots } from '@mui/x-charts/Toolbar';
5
6
  import { FunnelPlotSlotProps, FunnelPlotSlots } from "./funnelPlotSlots.types.js";
6
- export interface FunnelChartSlots extends ChartsAxisSlots, FunnelPlotSlots, ChartsLegendSlots, ChartsTooltipSlots, ChartsOverlaySlots, ChartsAxisSlots {}
7
- export interface FunnelChartSlotProps extends ChartsAxisSlotProps, FunnelPlotSlotProps, ChartsLegendSlotProps, ChartsTooltipSlotProps, ChartsOverlaySlotProps, ChartsAxisSlotProps {}
7
+ export interface FunnelChartSlots extends ChartsAxisSlots, FunnelPlotSlots, ChartsLegendSlots, ChartsTooltipSlots, ChartsOverlaySlots, ChartsAxisSlots, ChartsToolbarSlots, Partial<ChartsSlots> {}
8
+ export interface FunnelChartSlotProps extends ChartsAxisSlotProps, FunnelPlotSlotProps, ChartsLegendSlotProps, ChartsTooltipSlotProps, ChartsOverlaySlotProps, ChartsAxisSlotProps, ChartsToolbarSlotProps, Partial<ChartsSlotProps> {}
8
9
  export interface FunnelChartSlotExtension {
9
10
  /**
10
11
  * Overridable component slots.
@@ -6,4 +6,6 @@ export * from "./categoryAxis.types.js";
6
6
  export * from "./funnelSlots.types.js";
7
7
  export type { FunnelCurveType } from "./curves/index.js";
8
8
  export { funnelSectionClasses } from "./funnelSectionClasses.js";
9
- export type { FunnelSectionClasses } from "./funnelSectionClasses.js";
9
+ export type { FunnelSectionClasses } from "./funnelSectionClasses.js";
10
+ export { FunnelSection } from "./FunnelSection.js";
11
+ export { FunnelSectionLabel } from "./FunnelSectionLabel.js";
@@ -3,4 +3,6 @@ export * from "./FunnelPlot.js";
3
3
  export * from "./funnel.types.js";
4
4
  export * from "./categoryAxis.types.js";
5
5
  export * from "./funnelSlots.types.js";
6
- export { funnelSectionClasses } from "./funnelSectionClasses.js";
6
+ export { funnelSectionClasses } from "./funnelSectionClasses.js";
7
+ export { FunnelSection } from "./FunnelSection.js";
8
+ export { FunnelSectionLabel } from "./FunnelSectionLabel.js";
@@ -3,6 +3,7 @@ import { ChartsAxisProps } from '@mui/x-charts/ChartsAxis';
3
3
  import { ChartsLegendSlotExtension } from '@mui/x-charts/ChartsLegend';
4
4
  import { ChartsWrapperProps } from '@mui/x-charts/internals';
5
5
  import { ChartsAxisHighlightProps } from '@mui/x-charts/ChartsAxisHighlight';
6
+ import { FunnelChartPluginsSignatures } from "./FunnelChart.plugins.js";
6
7
  import { FunnelPlotProps } from "./FunnelPlot.js";
7
8
  import type { FunnelChartProps } from "./FunnelChart.js";
8
9
  import { ChartContainerProProps } from "../ChartContainerPro/index.js";
@@ -14,7 +15,7 @@ import { ChartContainerProProps } from "../ChartContainerPro/index.js";
14
15
  * @returns An object with props for the children components of FunnelChart
15
16
  */
16
17
  export declare const useFunnelChartProps: (props: FunnelChartProps) => {
17
- chartContainerProps: ChartContainerProProps<"funnel">;
18
+ chartContainerProps: ChartContainerProProps<"funnel", FunnelChartPluginsSignatures>;
18
19
  funnelPlotProps: FunnelPlotProps;
19
20
  overlayProps: ChartsOverlayProps;
20
21
  chartsAxisProps: ChartsAxisProps;
@@ -7,6 +7,7 @@ import { DEFAULT_MARGINS, DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '@mui/x-
7
7
  import { defaultizeMargin } from '@mui/x-charts/internals';
8
8
  import { warnOnce } from '@mui/x-internals/warning';
9
9
  import { strawberrySkyPalette } from '@mui/x-charts/colorPalettes';
10
+ import { FUNNEL_CHART_PLUGINS } from "./FunnelChart.plugins.js";
10
11
  function getCategoryAxisConfig(categoryAxis, series, isHorizontal, direction) {
11
12
  const maxSeriesLength = Math.max(...series.map(s => (s.data ?? []).length), 0);
12
13
  const maxSeriesValue = Array.from({
@@ -113,7 +114,8 @@ export const useFunnelChartProps = props => {
113
114
  highlightedItem,
114
115
  onHighlightChange,
115
116
  className,
116
- apiRef
117
+ apiRef,
118
+ plugins: FUNNEL_CHART_PLUGINS
117
119
  });
118
120
  const funnelPlotProps = {
119
121
  gap,
@@ -4,22 +4,30 @@ import { ChartsAxisProps } from '@mui/x-charts/ChartsAxis';
4
4
  import { ChartsTooltipProps } from '@mui/x-charts/ChartsTooltip';
5
5
  import { ChartsAxisSlots, ChartsAxisSlotProps, XAxis, YAxis } from '@mui/x-charts/internals';
6
6
  import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from '@mui/x-charts/ChartsOverlay';
7
+ import { ChartsLegendSlotProps, ChartsLegendSlots } from '@mui/x-charts/ChartsLegend';
8
+ import { ChartsToolbarSlotProps, ChartsToolbarSlots } from '@mui/x-charts/Toolbar';
9
+ import { ChartsSlotPropsPro, ChartsSlotsPro } from "../internals/material/index.js";
7
10
  import { ChartContainerProProps } from "../ChartContainerPro/index.js";
8
11
  import { HeatmapSeriesType } from "../models/seriesType/heatmap.js";
9
12
  import { HeatmapTooltipProps } from "./HeatmapTooltip/index.js";
10
13
  import { HeatmapItemSlotProps, HeatmapItemSlots } from "./HeatmapItem.js";
11
14
  import { HeatmapPluginsSignatures } from "./Heatmap.plugins.js";
12
- export interface HeatmapSlots extends ChartsAxisSlots, ChartsOverlaySlots, HeatmapItemSlots {
15
+ export interface HeatmapSlots extends ChartsAxisSlots, ChartsOverlaySlots, HeatmapItemSlots, ChartsToolbarSlots, Partial<ChartsSlotsPro> {
13
16
  /**
14
- * Custom component for the tooltip popper.
17
+ * Custom component for the tooltip.
15
18
  * @default ChartsTooltipRoot
16
19
  */
17
20
  tooltip?: React.ElementType<HeatmapTooltipProps>;
21
+ /**
22
+ * Custom component for the legend.
23
+ * @default ContinuousColorLegendProps
24
+ */
25
+ legend?: ChartsLegendSlots['legend'];
18
26
  }
19
- export interface HeatmapSlotProps extends ChartsAxisSlotProps, ChartsOverlaySlotProps, HeatmapItemSlotProps {
27
+ export interface HeatmapSlotProps extends ChartsAxisSlotProps, ChartsOverlaySlotProps, HeatmapItemSlotProps, ChartsLegendSlotProps, ChartsToolbarSlotProps, Partial<ChartsSlotPropsPro> {
20
28
  tooltip?: Partial<HeatmapTooltipProps>;
21
29
  }
22
- export interface HeatmapProps extends Omit<ChartContainerProProps<'heatmap', HeatmapPluginsSignatures>, 'series' | 'plugins' | 'xAxis' | 'yAxis' | 'skipAnimation'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
30
+ export interface HeatmapProps extends Omit<ChartContainerProProps<'heatmap', HeatmapPluginsSignatures>, 'series' | 'plugins' | 'xAxis' | 'yAxis' | 'skipAnimation' | 'slots' | 'slotProps'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
23
31
  /**
24
32
  * The configuration of the x-axes.
25
33
  * If not provided, a default axis config is used.
@@ -42,6 +50,16 @@ export interface HeatmapProps extends Omit<ChartContainerProProps<'heatmap', Hea
42
50
  * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
43
51
  */
44
52
  tooltip?: ChartsTooltipProps;
53
+ /**
54
+ * If `true`, the legend is not rendered.
55
+ * @default true
56
+ */
57
+ hideLegend?: boolean;
58
+ /**
59
+ * If true, shows the default chart toolbar.
60
+ * @default false
61
+ */
62
+ showToolbar?: boolean;
45
63
  /**
46
64
  * Overridable component slots.
47
65
  * @default {}
@@ -8,14 +8,17 @@ import useId from '@mui/utils/useId';
8
8
  import { interpolateRgbBasis } from '@mui/x-charts-vendor/d3-interpolate';
9
9
  import { ChartsAxis } from '@mui/x-charts/ChartsAxis';
10
10
  import { ChartsSurface } from '@mui/x-charts/ChartsSurface';
11
+ import { ChartsWrapper } from '@mui/x-charts/internals';
11
12
  import { ChartsClipPath } from '@mui/x-charts/ChartsClipPath';
12
13
  import { ChartsOverlay } from '@mui/x-charts/ChartsOverlay';
13
14
  import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '@mui/x-charts/constants';
15
+ import { ChartsLegend, ContinuousColorLegend } from '@mui/x-charts/ChartsLegend';
14
16
  import { HeatmapPlot } from "./HeatmapPlot.js";
15
17
  import { seriesConfig as heatmapSeriesConfig } from "./seriesConfig/index.js";
16
18
  import { HeatmapTooltip } from "./HeatmapTooltip/index.js";
17
19
  import { HEATMAP_PLUGINS } from "./Heatmap.plugins.js";
18
20
  import { ChartDataProviderPro } from "../ChartDataProviderPro/index.js";
21
+ import { ChartsToolbarPro } from "../ChartsToolbarPro/index.js";
19
22
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
23
  // The GnBu: https://github.com/d3/d3-scale-chromatic/blob/main/src/sequential-multi/GnBu.js
21
24
  const defaultColorMap = interpolateRgbBasis(['#f7fcf0', '#e0f3db', '#ccebc5', '#a8ddb5', '#7bccc4', '#4eb3d3', '#2b8cbe', '#0868ac', '#084081']);
@@ -38,6 +41,7 @@ const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(inProps, ref) {
38
41
  name: 'MuiHeatmap'
39
42
  });
40
43
  const {
44
+ apiRef,
41
45
  xAxis,
42
46
  yAxis,
43
47
  zAxis,
@@ -54,7 +58,9 @@ const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(inProps, ref) {
54
58
  slotProps,
55
59
  loading,
56
60
  highlightedItem,
57
- onHighlightChange
61
+ onHighlightChange,
62
+ hideLegend = true,
63
+ showToolbar = false
58
64
  } = props;
59
65
  const id = useId();
60
66
  const clipPathId = `${id}-clip-path`;
@@ -82,8 +88,15 @@ const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(inProps, ref) {
82
88
  color: defaultColorMap
83
89
  }
84
90
  }], [zAxis]);
85
- const Tooltip = props.slots?.tooltip ?? HeatmapTooltip;
86
- return /*#__PURE__*/_jsxs(ChartDataProviderPro, {
91
+ const chartsWrapperProps = {
92
+ sx,
93
+ legendPosition: props.slotProps?.legend?.position,
94
+ legendDirection: props.slotProps?.legend?.direction
95
+ };
96
+ const Tooltip = slots?.tooltip ?? HeatmapTooltip;
97
+ const Toolbar = slots?.toolbar ?? ChartsToolbarPro;
98
+ return /*#__PURE__*/_jsx(ChartDataProviderPro, {
99
+ apiRef: apiRef,
87
100
  seriesConfig: seriesConfig,
88
101
  series: series.map(s => _extends({
89
102
  type: 'heatmap'
@@ -101,26 +114,42 @@ const Heatmap = /*#__PURE__*/React.forwardRef(function Heatmap(inProps, ref) {
101
114
  onHighlightChange: onHighlightChange,
102
115
  onAxisClick: onAxisClick,
103
116
  plugins: HEATMAP_PLUGINS,
104
- children: [/*#__PURE__*/_jsxs(ChartsSurface, {
105
- ref: ref,
106
- sx: sx,
107
- children: [/*#__PURE__*/_jsxs("g", {
108
- clipPath: `url(#${clipPathId})`,
109
- children: [/*#__PURE__*/_jsx(HeatmapPlot, {
110
- slots: slots,
111
- slotProps: slotProps
112
- }), /*#__PURE__*/_jsx(ChartsOverlay, {
113
- loading: loading,
117
+ children: /*#__PURE__*/_jsxs(ChartsWrapper, _extends({}, chartsWrapperProps, {
118
+ children: [showToolbar ? /*#__PURE__*/_jsx(Toolbar, _extends({}, props.slotProps?.toolbar)) : null, !hideLegend && /*#__PURE__*/_jsx(ChartsLegend, {
119
+ slots: _extends({}, slots, {
120
+ legend: slots?.legend ?? ContinuousColorLegend
121
+ }),
122
+ slotProps: {
123
+ legend: _extends({
124
+ labelPosition: 'extremes'
125
+ }, slotProps?.legend)
126
+ },
127
+ sx: slotProps?.legend?.direction === 'vertical' ? {
128
+ height: 150
129
+ } : {
130
+ width: '50%'
131
+ }
132
+ }), /*#__PURE__*/_jsxs(ChartsSurface, {
133
+ ref: ref,
134
+ sx: sx,
135
+ children: [/*#__PURE__*/_jsxs("g", {
136
+ clipPath: `url(#${clipPathId})`,
137
+ children: [/*#__PURE__*/_jsx(HeatmapPlot, {
138
+ slots: slots,
139
+ slotProps: slotProps
140
+ }), /*#__PURE__*/_jsx(ChartsOverlay, {
141
+ loading: loading,
142
+ slots: slots,
143
+ slotProps: slotProps
144
+ })]
145
+ }), /*#__PURE__*/_jsx(ChartsAxis, {
114
146
  slots: slots,
115
147
  slotProps: slotProps
116
- })]
117
- }), /*#__PURE__*/_jsx(ChartsAxis, {
118
- slots: slots,
119
- slotProps: slotProps
120
- }), /*#__PURE__*/_jsx(ChartsClipPath, {
121
- id: clipPathId
122
- }), children]
123
- }), !loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, slotProps?.tooltip))]
148
+ }), /*#__PURE__*/_jsx(ChartsClipPath, {
149
+ id: clipPathId
150
+ }), children]
151
+ }), !loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, slotProps?.tooltip))]
152
+ }))
124
153
  });
125
154
  });
126
155
  if (process.env.NODE_ENV !== "production") Heatmap.displayName = "Heatmap";
@@ -130,7 +159,10 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
130
159
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
131
160
  // ----------------------------------------------------------------------
132
161
  apiRef: PropTypes.shape({
133
- current: PropTypes.object
162
+ current: PropTypes.shape({
163
+ exportAsImage: PropTypes.func.isRequired,
164
+ exportAsPrint: PropTypes.func.isRequired
165
+ })
134
166
  }),
135
167
  className: PropTypes.string,
136
168
  /**
@@ -153,6 +185,11 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
153
185
  * The height of the chart in px. If not defined, it takes the height of the parent element.
154
186
  */
155
187
  height: PropTypes.number,
188
+ /**
189
+ * If `true`, the legend is not rendered.
190
+ * @default true
191
+ */
192
+ hideLegend: PropTypes.bool,
156
193
  /**
157
194
  * The highlighted item.
158
195
  * Used when the highlight is controlled.
@@ -210,6 +247,11 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
210
247
  * @ignore Unstable props for internal usage.
211
248
  */
212
249
  seriesConfig: PropTypes.object,
250
+ /**
251
+ * If true, shows the default chart toolbar.
252
+ * @default false
253
+ */
254
+ showToolbar: PropTypes.bool,
213
255
  /**
214
256
  * The props used for each component slot.
215
257
  * @default {}
@@ -1,3 +1,4 @@
1
1
  import { UseChartZAxisSignature, UseChartCartesianAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, ConvertSignaturesIntoPlugins } from '@mui/x-charts/internals';
2
- export type HeatmapPluginsSignatures = [UseChartZAxisSignature, UseChartCartesianAxisSignature<'heatmap'>, UseChartInteractionSignature, UseChartHighlightSignature];
2
+ import { UseChartProExportSignature } from "../internals/plugins/useChartProExport/index.js";
3
+ export type HeatmapPluginsSignatures = [UseChartZAxisSignature, UseChartCartesianAxisSignature<'heatmap'>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartProExportSignature];
3
4
  export declare const HEATMAP_PLUGINS: ConvertSignaturesIntoPlugins<HeatmapPluginsSignatures>;