@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.
- package/CHANGELOG.md +96 -11
- package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
- package/ChartZoomSlider/internals/ChartAxisZoomSlider.js +1 -1
- package/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +20 -31
- package/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.js +1 -8
- package/ChartZoomSlider/internals/zoom-utils.d.ts +3 -1
- package/ChartZoomSlider/internals/zoom-utils.js +19 -8
- package/FunnelChart/FunnelPlot.js +56 -40
- package/FunnelChart/FunnelSection.js +2 -0
- package/FunnelChart/curves/bump.d.ts +3 -3
- package/FunnelChart/curves/bump.js +3 -0
- package/FunnelChart/curves/curve.types.d.ts +14 -1
- package/FunnelChart/curves/getFunnelCurve.d.ts +7 -2
- package/FunnelChart/curves/linear.d.ts +3 -3
- package/FunnelChart/curves/linear.js +23 -18
- package/FunnelChart/curves/pyramid.d.ts +3 -3
- package/FunnelChart/curves/pyramid.js +17 -12
- package/FunnelChart/curves/step-pyramid.d.ts +5 -5
- package/FunnelChart/curves/step-pyramid.js +20 -18
- package/FunnelChart/curves/step.d.ts +3 -3
- package/FunnelChart/curves/step.js +14 -12
- package/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.d.ts +18 -1444
- package/FunnelChart/labelUtils.d.ts +4 -12
- package/FunnelChart/labelUtils.js +43 -44
- package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSlider.js +1 -1
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +21 -32
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.js +1 -8
- package/esm/ChartZoomSlider/internals/zoom-utils.d.ts +3 -1
- package/esm/ChartZoomSlider/internals/zoom-utils.js +19 -9
- package/esm/FunnelChart/FunnelPlot.js +56 -40
- package/esm/FunnelChart/FunnelSection.js +2 -0
- package/esm/FunnelChart/curves/bump.d.ts +3 -3
- package/esm/FunnelChart/curves/bump.js +3 -0
- package/esm/FunnelChart/curves/curve.types.d.ts +14 -1
- package/esm/FunnelChart/curves/getFunnelCurve.d.ts +7 -2
- package/esm/FunnelChart/curves/linear.d.ts +3 -3
- package/esm/FunnelChart/curves/linear.js +23 -18
- package/esm/FunnelChart/curves/pyramid.d.ts +3 -3
- package/esm/FunnelChart/curves/pyramid.js +17 -12
- package/esm/FunnelChart/curves/step-pyramid.d.ts +5 -5
- package/esm/FunnelChart/curves/step-pyramid.js +20 -18
- package/esm/FunnelChart/curves/step.d.ts +3 -3
- package/esm/FunnelChart/curves/step.js +14 -12
- package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.d.ts +18 -1444
- package/esm/FunnelChart/labelUtils.d.ts +4 -12
- package/esm/FunnelChart/labelUtils.js +43 -44
- package/esm/index.js +1 -1
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +16 -595
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +2 -2
- package/index.js +1 -1
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +16 -595
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +2 -2
- package/package.json +5 -5
- package/FunnelChart/positionGetter.d.ts +0 -1
- package/FunnelChart/positionGetter.js +0 -5
- package/esm/FunnelChart/positionGetter.d.ts +0 -1
- package/esm/FunnelChart/positionGetter.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
|
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
|
|
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
|
-
|
|
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 =
|
|
72
|
-
minTop =
|
|
73
|
-
minBottom =
|
|
74
|
-
maxBottom =
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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 =
|
|
105
|
+
y = (maxTop + minTop) / 2;
|
|
107
106
|
} else if (vertical === 'middle') {
|
|
108
107
|
y = middle;
|
|
109
108
|
} else if (vertical === 'bottom') {
|
|
110
|
-
y =
|
|
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 =
|
|
135
|
+
x = (maxLeft + minLeft) / 2;
|
|
137
136
|
} else if (horizontal === 'center') {
|
|
138
137
|
x = center;
|
|
139
138
|
} else if (horizontal === 'end') {
|
|
140
|
-
x =
|
|
139
|
+
x = (maxRight + minRight) / 2;
|
|
141
140
|
}
|
|
142
141
|
} else if (vertical === 'top') {
|
|
143
142
|
y = maxTop;
|
package/esm/index.js
CHANGED