@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,5 +1,5 @@
1
- import { FunnelDataPoints, FunnelLabelOptions } from "./funnel.types.js";
2
- import { PositionGetter } from "./positionGetter.js";
1
+ import { FunnelLabelOptions } from "./funnel.types.js";
2
+ import { Point } from "./curves/index.js";
3
3
  /**
4
4
  * It tries to keep the label inside the bounds of the section based on the position.
5
5
  *
@@ -24,19 +24,11 @@ export declare const alignLabel: ({
24
24
  export declare const positionLabel: ({
25
25
  position,
26
26
  offset,
27
- xPosition,
28
- yPosition,
29
27
  isHorizontal,
30
- values,
31
- dataIndex,
32
- baseScaleData
28
+ values
33
29
  }: Omit<FunnelLabelOptions, "textAnchor" | "dominantBaseline"> & {
34
- xPosition: PositionGetter;
35
- yPosition: PositionGetter;
36
30
  isHorizontal: boolean;
37
- values: readonly FunnelDataPoints[];
38
- dataIndex: number;
39
- baseScaleData: readonly number[];
31
+ values: readonly Point[];
40
32
  }) => {
41
33
  x: number;
42
34
  y: number;
@@ -39,17 +39,21 @@ export const alignLabel = ({
39
39
  export const positionLabel = ({
40
40
  position,
41
41
  offset,
42
- xPosition,
43
- yPosition,
44
42
  isHorizontal,
45
- values,
46
- dataIndex,
47
- baseScaleData
43
+ values
48
44
  }) => {
49
45
  const vertical = position?.vertical ?? 'middle';
50
46
  const horizontal = position?.horizontal ?? 'center';
51
47
  let x = 0;
52
48
  let y = 0;
49
+
50
+ // The min/max values are due to the sections possibly being sloped.
51
+ // Importance of values differs from the horizontal and vertical sections.
52
+ // Example (vertical):
53
+ // MaxL MaxT MaxR
54
+ // \ /
55
+ // \ /
56
+ // MinL MaxB MinR
53
57
  let minTop = 0;
54
58
  let maxTop = 0;
55
59
  let minBottom = 0;
@@ -58,56 +62,51 @@ export const positionLabel = ({
58
62
  let maxLeft = 0;
59
63
  let minRight = 0;
60
64
  let maxRight = 0;
61
- let center = 0;
62
- let leftCenter = 0;
63
- let rightCenter = 0;
64
65
  let middle = 0;
65
- let topMiddle = 0;
66
- let bottomMiddle = 0;
66
+ let center = 0;
67
67
  const mv = typeof offset === 'number' ? offset : offset?.y ?? 0;
68
68
  const mh = typeof offset === 'number' ? offset : offset?.x ?? 0;
69
- const stackOffset = values[0].stackOffset;
69
+
70
+ // Min ... Max
71
+ const Ys = values.map(v => v.y).toSorted((a, b) => a - b);
72
+ const Xs = values.map(v => v.x).toSorted((a, b) => a - b);
73
+
74
+ // Visualization of the points in a hierarchical order:
75
+ // MaxT
76
+ // MinT
77
+ // MaxL MinL Cent/Mid MinR MaxR
78
+ // MinB
79
+ // MaxB
70
80
  if (isHorizontal) {
71
- maxTop = yPosition(values[0].y, baseScaleData[dataIndex], stackOffset) - mv;
72
- minTop = yPosition(values[1].y, baseScaleData[dataIndex], stackOffset) - mv;
73
- minBottom = yPosition(values[2].y, baseScaleData[dataIndex], stackOffset) + mv;
74
- maxBottom = yPosition(values[3].y, baseScaleData[dataIndex], stackOffset) + mv;
75
- minRight = 0;
76
- maxRight = xPosition(Math.min(...values.map(v => v.x)), dataIndex, baseScaleData[dataIndex], stackOffset, true) + mh;
77
- minLeft = 0;
78
- maxLeft = xPosition(Math.max(...values.map(v => v.x)), dataIndex, baseScaleData[dataIndex], stackOffset) + mh;
79
- center = maxRight - (maxRight - maxLeft) / 2;
80
- leftCenter = 0;
81
- rightCenter = 0;
82
- middle = yPosition(0, dataIndex, baseScaleData[dataIndex], stackOffset) - mv;
83
- topMiddle = yPosition(values[0].y - (values[0].y - values[1].y) / 2, dataIndex, baseScaleData[dataIndex], stackOffset) - mv;
84
- bottomMiddle = yPosition(values[3].y - (values[3].y - values[2].y) / 2, dataIndex, baseScaleData[dataIndex], stackOffset) + mv;
81
+ maxTop = Ys.at(0) - mv;
82
+ minTop = Ys.at(1) - mv;
83
+ minBottom = Ys.at(2) + mv;
84
+ maxBottom = (Ys.at(3) ?? Ys.at(2)) + mv;
85
+ maxRight = (Xs.at(3) ?? Xs.at(2)) + mh;
86
+ // We don't need (minRight/minLeft) for horizontal
87
+ maxLeft = Xs.at(0) + mh;
88
+ center = (maxRight + maxLeft) / 2;
89
+ middle = (maxBottom + maxTop) / 2;
85
90
  } else {
86
- minTop = 0;
87
- maxTop = yPosition(Math.max(...values.map(v => v.y)), dataIndex, baseScaleData[dataIndex], stackOffset) - mv;
88
- minBottom = 0;
89
- maxBottom = yPosition(Math.min(...values.map(v => v.y)), dataIndex, baseScaleData[dataIndex], stackOffset, true) - mv;
90
- maxRight = xPosition(values[0].x, dataIndex, baseScaleData[dataIndex], stackOffset) + mh;
91
- minRight = xPosition(values[1].x, dataIndex, baseScaleData[dataIndex], stackOffset) + mh;
92
- minLeft = xPosition(values[2].x, dataIndex, baseScaleData[dataIndex], stackOffset) - mh;
93
- maxLeft = xPosition(values[3].x, dataIndex, baseScaleData[dataIndex], stackOffset) - mh;
94
- center = xPosition(0, dataIndex, baseScaleData[dataIndex], stackOffset) - mh;
95
- rightCenter = xPosition(values[0].x - (values[0].x - values[1].x) / 2, dataIndex, baseScaleData[dataIndex], stackOffset) + mh;
96
- leftCenter = xPosition(values[3].x - (values[3].x - values[2].x) / 2, dataIndex, baseScaleData[dataIndex], stackOffset) - mh;
97
- middle = yPosition(values[0].y - (values[0].y - values[1].y) / 2, dataIndex, baseScaleData[dataIndex], stackOffset);
98
- middle = maxTop - (maxTop - maxBottom) / 2;
99
- topMiddle = 0;
100
- bottomMiddle = 0;
91
+ maxTop = Ys.at(0) - mv;
92
+ // We don't need (minTop/minBottom) for vertical
93
+ maxBottom = (Ys.at(3) ?? Ys.at(2)) - mv;
94
+ maxRight = (Xs.at(3) ?? Xs.at(2)) + mh;
95
+ minRight = Xs.at(2) + mh;
96
+ minLeft = Xs.at(1) - mh;
97
+ maxLeft = Xs.at(0) - mh;
98
+ center = (maxRight + maxLeft) / 2;
99
+ middle = (maxBottom + maxTop) / 2;
101
100
  }
102
101
  if (isHorizontal) {
103
102
  if (horizontal === 'center') {
104
103
  x = center;
105
104
  if (vertical === 'top') {
106
- y = topMiddle;
105
+ y = (maxTop + minTop) / 2;
107
106
  } else if (vertical === 'middle') {
108
107
  y = middle;
109
108
  } else if (vertical === 'bottom') {
110
- y = bottomMiddle;
109
+ y = (maxBottom + minBottom) / 2;
111
110
  }
112
111
  } else if (horizontal === 'start') {
113
112
  x = maxLeft;
@@ -133,11 +132,11 @@ export const positionLabel = ({
133
132
  if (vertical === 'middle') {
134
133
  y = middle;
135
134
  if (horizontal === 'start') {
136
- x = leftCenter;
135
+ x = (maxLeft + minLeft) / 2;
137
136
  } else if (horizontal === 'center') {
138
137
  x = center;
139
138
  } else if (horizontal === 'end') {
140
- x = rightCenter;
139
+ x = (maxRight + minRight) / 2;
141
140
  }
142
141
  } else if (vertical === 'top') {
143
142
  y = maxTop;
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts-pro v8.5.2
2
+ * @mui/x-charts-pro v8.5.3
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the