@gravity-ui/chartkit 5.11.1 → 5.11.2

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.
@@ -2,7 +2,7 @@ import { Delaunay, bisector, sort } from 'd3';
2
2
  import get from 'lodash/get';
3
3
  import groupBy from 'lodash/groupBy';
4
4
  function getClosestPointsByXValue(x, y, points) {
5
- var _a, _b;
5
+ var _a, _b, _c, _d;
6
6
  const sorted = sort(points, (p) => p.x);
7
7
  const closestXIndex = bisector((p) => p.x).center(sorted, x);
8
8
  if (closestXIndex === -1) {
@@ -19,6 +19,11 @@ function getClosestPointsByXValue(x, y, points) {
19
19
  }
20
20
  else {
21
21
  closestYIndex = closestPoints.findIndex((p) => y > p.y0 && y < p.y1);
22
+ if (closestYIndex === -1) {
23
+ const sortedY = sort(closestPoints.map((p, index) => ({ index, y: p.y1 + (p.y0 - p.y1) / 2 })), (p) => p.y);
24
+ const sortedYIndex = bisector((p) => p.y).center(sortedY, y);
25
+ closestYIndex = (_d = (_c = sortedY[sortedYIndex]) === null || _c === void 0 ? void 0 : _c.index) !== null && _d !== void 0 ? _d : -1;
26
+ }
22
27
  }
23
28
  return closestPoints.map((p, i) => ({
24
29
  data: p.data,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/chartkit",
3
- "version": "5.11.1",
3
+ "version": "5.11.2",
4
4
  "description": "React component used to render charts based on any sources you need",
5
5
  "license": "MIT",
6
6
  "repository": "git@github.com:gravity-ui/ChartKit.git",