@gravity-ui/charts 1.34.7 → 1.34.9
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/dist/cjs/components/AxisX/AxisX.js +0 -1
- package/dist/cjs/components/AxisX/prepare-axis-data.js +4 -23
- package/dist/cjs/components/AxisX/types.d.ts +1 -9
- package/dist/cjs/components/AxisY/prepare-axis-title.js +3 -34
- package/dist/cjs/components/AxisY/types.d.ts +1 -9
- package/dist/cjs/components/ChartInner/index.js +6 -6
- package/dist/cjs/components/ChartInner/useChartInnerProps.d.ts +0 -1
- package/dist/cjs/components/ChartInner/useChartInnerProps.js +16 -6
- package/dist/cjs/components/ChartInner/useChartInnerState.d.ts +2 -3
- package/dist/cjs/components/ChartInner/useChartInnerState.js +14 -22
- package/dist/cjs/components/RangeSlider/index.d.ts +0 -1
- package/dist/cjs/components/RangeSlider/index.js +1 -8
- package/dist/cjs/components/types/index.d.ts +9 -0
- package/dist/cjs/components/types/index.js +1 -0
- package/dist/cjs/components/utils/axis-title.d.ts +6 -0
- package/dist/cjs/components/utils/axis-title.js +39 -0
- package/dist/cjs/components/{utils.d.ts → utils/index.d.ts} +3 -3
- package/dist/cjs/components/{utils.js → utils/index.js} +1 -1
- package/dist/cjs/hooks/useAxisScales/index.js +3 -1
- package/dist/cjs/hooks/useAxisScales/x-scale.d.ts +0 -6
- package/dist/cjs/hooks/useAxisScales/x-scale.js +12 -35
- package/dist/cjs/hooks/useAxisScales/y-scale.js +2 -7
- package/dist/cjs/hooks/useRangeSlider/types.d.ts +1 -1
- package/dist/cjs/hooks/useSeries/prepare-legend.js +2 -1
- package/dist/cjs/hooks/useShapes/area/index.js +13 -4
- package/dist/cjs/hooks/useShapes/area/prepare-data.js +3 -2
- package/dist/cjs/hooks/useShapes/bar-x/index.js +13 -4
- package/dist/cjs/hooks/useShapes/bar-x/prepare-data.js +15 -6
- package/dist/cjs/hooks/useShapes/line/index.js +13 -4
- package/dist/cjs/hooks/useShapes/line/prepare-data.js +4 -2
- package/dist/cjs/hooks/useShapes/waterfall/index.js +13 -4
- package/dist/cjs/utils/chart/get-closest-data.js +39 -35
- package/dist/cjs/utils/chart/zoom.d.ts +2 -1
- package/dist/cjs/utils/chart/zoom.js +9 -0
- package/dist/esm/components/AxisX/AxisX.js +0 -1
- package/dist/esm/components/AxisX/prepare-axis-data.js +4 -23
- package/dist/esm/components/AxisX/types.d.ts +1 -9
- package/dist/esm/components/AxisY/prepare-axis-title.js +3 -34
- package/dist/esm/components/AxisY/types.d.ts +1 -9
- package/dist/esm/components/ChartInner/index.js +6 -6
- package/dist/esm/components/ChartInner/useChartInnerProps.d.ts +0 -1
- package/dist/esm/components/ChartInner/useChartInnerProps.js +16 -6
- package/dist/esm/components/ChartInner/useChartInnerState.d.ts +2 -3
- package/dist/esm/components/ChartInner/useChartInnerState.js +14 -22
- package/dist/esm/components/RangeSlider/index.d.ts +0 -1
- package/dist/esm/components/RangeSlider/index.js +1 -8
- package/dist/esm/components/types/index.d.ts +9 -0
- package/dist/esm/components/types/index.js +1 -0
- package/dist/esm/components/utils/axis-title.d.ts +6 -0
- package/dist/esm/components/utils/axis-title.js +39 -0
- package/dist/esm/components/{utils.d.ts → utils/index.d.ts} +3 -3
- package/dist/esm/components/{utils.js → utils/index.js} +1 -1
- package/dist/esm/hooks/useAxisScales/index.js +3 -1
- package/dist/esm/hooks/useAxisScales/x-scale.d.ts +0 -6
- package/dist/esm/hooks/useAxisScales/x-scale.js +12 -35
- package/dist/esm/hooks/useAxisScales/y-scale.js +2 -7
- package/dist/esm/hooks/useRangeSlider/types.d.ts +1 -1
- package/dist/esm/hooks/useSeries/prepare-legend.js +2 -1
- package/dist/esm/hooks/useShapes/area/index.js +13 -4
- package/dist/esm/hooks/useShapes/area/prepare-data.js +3 -2
- package/dist/esm/hooks/useShapes/bar-x/index.js +13 -4
- package/dist/esm/hooks/useShapes/bar-x/prepare-data.js +15 -6
- package/dist/esm/hooks/useShapes/line/index.js +13 -4
- package/dist/esm/hooks/useShapes/line/prepare-data.js +4 -2
- package/dist/esm/hooks/useShapes/waterfall/index.js +13 -4
- package/dist/esm/utils/chart/get-closest-data.js +39 -35
- package/dist/esm/utils/chart/zoom.d.ts +2 -1
- package/dist/esm/utils/chart/zoom.js +9 -0
- package/package.json +1 -1
|
@@ -47,19 +47,53 @@ export function getClosestPoints(args) {
|
|
|
47
47
|
const [pointerX, pointerY] = position;
|
|
48
48
|
const result = [];
|
|
49
49
|
const groups = groupBy(shapesData, getSeriesType);
|
|
50
|
+
const closestPointsByXValue = [];
|
|
50
51
|
// eslint-disable-next-line complexity
|
|
51
52
|
Object.entries(groups).forEach(([seriesType, list]) => {
|
|
52
53
|
var _a, _b, _c, _d, _e;
|
|
53
54
|
switch (seriesType) {
|
|
55
|
+
case 'line': {
|
|
56
|
+
const linePoints = list.reduce((acc, d) => {
|
|
57
|
+
acc.push(...d.points.reduce((accPoints, p) => {
|
|
58
|
+
if (p.y !== null && p.x !== null) {
|
|
59
|
+
accPoints.push({
|
|
60
|
+
data: p.data,
|
|
61
|
+
series: p.series,
|
|
62
|
+
x: p.x,
|
|
63
|
+
y0: p.y,
|
|
64
|
+
y1: p.y,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return accPoints;
|
|
68
|
+
}, []));
|
|
69
|
+
return acc;
|
|
70
|
+
}, []);
|
|
71
|
+
closestPointsByXValue.push(...linePoints);
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case 'area': {
|
|
75
|
+
const areaPoints = list.reduce((acc, d) => {
|
|
76
|
+
Array.prototype.push.apply(acc, d.points.map((p) => ({
|
|
77
|
+
data: p.data,
|
|
78
|
+
series: p.series,
|
|
79
|
+
x: p.x,
|
|
80
|
+
y0: p.y0,
|
|
81
|
+
y1: p.y,
|
|
82
|
+
})));
|
|
83
|
+
return acc;
|
|
84
|
+
}, []);
|
|
85
|
+
closestPointsByXValue.push(...areaPoints);
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
54
88
|
case 'bar-x': {
|
|
55
|
-
const
|
|
89
|
+
const barXPoints = list.map((d) => ({
|
|
56
90
|
data: d.data,
|
|
57
91
|
series: d.series,
|
|
58
92
|
x: d.x + d.width / 2,
|
|
59
93
|
y0: d.y,
|
|
60
94
|
y1: d.y + d.height,
|
|
61
95
|
}));
|
|
62
|
-
|
|
96
|
+
closestPointsByXValue.push(...barXPoints);
|
|
63
97
|
break;
|
|
64
98
|
}
|
|
65
99
|
case 'waterfall': {
|
|
@@ -74,39 +108,6 @@ export function getClosestPoints(args) {
|
|
|
74
108
|
result.push(...getClosestPointsByXValue(pointerX, pointerY, points));
|
|
75
109
|
break;
|
|
76
110
|
}
|
|
77
|
-
case 'area': {
|
|
78
|
-
const points = list.reduce((acc, d) => {
|
|
79
|
-
Array.prototype.push.apply(acc, d.points.map((p) => ({
|
|
80
|
-
data: p.data,
|
|
81
|
-
series: p.series,
|
|
82
|
-
x: p.x,
|
|
83
|
-
y0: p.y0,
|
|
84
|
-
y1: p.y,
|
|
85
|
-
})));
|
|
86
|
-
return acc;
|
|
87
|
-
}, []);
|
|
88
|
-
result.push(...getClosestPointsByXValue(pointerX, pointerY, points));
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
case 'line': {
|
|
92
|
-
const points = list.reduce((acc, d) => {
|
|
93
|
-
acc.push(...d.points.reduce((accPoints, p) => {
|
|
94
|
-
if (p.y !== null && p.x !== null) {
|
|
95
|
-
accPoints.push({
|
|
96
|
-
data: p.data,
|
|
97
|
-
series: p.series,
|
|
98
|
-
x: p.x,
|
|
99
|
-
y0: p.y,
|
|
100
|
-
y1: p.y,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
return accPoints;
|
|
104
|
-
}, []));
|
|
105
|
-
return acc;
|
|
106
|
-
}, []);
|
|
107
|
-
result.push(...getClosestPointsByXValue(pointerX, pointerY, points));
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
111
|
case 'bar-y': {
|
|
111
112
|
const points = list;
|
|
112
113
|
const sorted = sort(points, (p) => p.y);
|
|
@@ -267,6 +268,9 @@ export function getClosestPoints(args) {
|
|
|
267
268
|
}
|
|
268
269
|
}
|
|
269
270
|
});
|
|
271
|
+
if (closestPointsByXValue.length) {
|
|
272
|
+
result.push(...getClosestPointsByXValue(pointerX, pointerY, closestPointsByXValue));
|
|
273
|
+
}
|
|
270
274
|
return result;
|
|
271
275
|
}
|
|
272
276
|
function isInsidePath(args) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PreparedSeries, PreparedXAxis, PreparedYAxis } from '../../hooks';
|
|
1
|
+
import type { PreparedSeries, PreparedXAxis, PreparedYAxis, RangeSliderState } from '../../hooks';
|
|
2
2
|
import type { ZoomState } from '../../hooks/useZoom/types';
|
|
3
3
|
import type { ChartXAxis, ChartYAxis } from '../../types';
|
|
4
4
|
export declare function getZoomedSeriesData(args: {
|
|
@@ -10,3 +10,4 @@ export declare function getZoomedSeriesData(args: {
|
|
|
10
10
|
preparedSeries: PreparedSeries[];
|
|
11
11
|
preparedShapesSeries: PreparedSeries[];
|
|
12
12
|
};
|
|
13
|
+
export declare function getEffectiveXRange(zoomStateX: [number, number] | undefined, rangeSliderState: RangeSliderState | undefined): [number, number] | undefined;
|
|
@@ -123,3 +123,12 @@ export function getZoomedSeriesData(args) {
|
|
|
123
123
|
preparedShapesSeries: zoomedShapesSeriesData,
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
|
+
export function getEffectiveXRange(zoomStateX, rangeSliderState) {
|
|
127
|
+
if (zoomStateX && rangeSliderState) {
|
|
128
|
+
return [
|
|
129
|
+
Math.max(zoomStateX[0], rangeSliderState.min),
|
|
130
|
+
Math.min(zoomStateX[1], rangeSliderState.max),
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
return (zoomStateX !== null && zoomStateX !== void 0 ? zoomStateX : (rangeSliderState ? [rangeSliderState.min, rangeSliderState.max] : undefined));
|
|
134
|
+
}
|