@gravity-ui/chartkit 5.11.1 → 5.12.0

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,
@@ -357,17 +357,6 @@ export declare class HighchartsComponent extends React.PureComponent<Props, Stat
357
357
  stickyTracking: boolean;
358
358
  };
359
359
  series: {
360
- events: {
361
- legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void;
362
- mouseOver: () => void;
363
- mouseOut: () => void;
364
- click: (event: any) => void;
365
- };
366
- point: {
367
- events: {
368
- click: () => false;
369
- };
370
- };
371
360
  marker: {
372
361
  states: {
373
362
  hover: {
@@ -380,6 +369,17 @@ export declare class HighchartsComponent extends React.PureComponent<Props, Stat
380
369
  } | {
381
370
  states?: undefined;
382
371
  };
372
+ point?: {
373
+ events: {
374
+ click: () => false;
375
+ };
376
+ } | undefined;
377
+ events: {
378
+ legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void;
379
+ mouseOver: () => void;
380
+ mouseOut: () => void;
381
+ click: (event: any) => void;
382
+ };
383
383
  };
384
384
  pie: {
385
385
  point: {
@@ -520,17 +520,6 @@ export function prepareConfig(data: any, options: any, isMobile: any, holidays:
520
520
  stickyTracking: boolean;
521
521
  };
522
522
  series: {
523
- events: {
524
- legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void;
525
- mouseOver: () => void;
526
- mouseOut: () => void;
527
- click: (event: any) => void;
528
- };
529
- point: {
530
- events: {
531
- click: () => false;
532
- };
533
- };
534
523
  marker: {
535
524
  states: {
536
525
  hover: {
@@ -543,6 +532,17 @@ export function prepareConfig(data: any, options: any, isMobile: any, holidays:
543
532
  } | {
544
533
  states?: undefined;
545
534
  };
535
+ point?: {
536
+ events: {
537
+ click: () => false;
538
+ };
539
+ } | undefined;
540
+ events: {
541
+ legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void;
542
+ mouseOver: () => void;
543
+ mouseOut: () => void;
544
+ click: (event: any) => void;
545
+ };
546
546
  };
547
547
  pie: {
548
548
  point: {
@@ -1262,8 +1262,7 @@ export function prepareConfig(data, options, isMobile, holidays) {
1262
1262
  xrange: {
1263
1263
  stickyTracking: false,
1264
1264
  },
1265
- series: {
1266
- events: {
1265
+ series: Object.assign(Object.assign({ events: {
1267
1266
  legendItemClick: handleLegendItemClick,
1268
1267
  mouseOver: function () {
1269
1268
  this.chart.userOptions._activeSeries = this.index;
@@ -1279,16 +1278,18 @@ export function prepareConfig(data, options, isMobile, holidays) {
1279
1278
  fixTooltipOnClick.bind(this)(event, { options });
1280
1279
  }
1281
1280
  },
1282
- },
1283
- point: {
1284
- events: {
1285
- click: function () {
1286
- // Prevent slicing of pie segment after clicking it
1287
- return false;
1281
+ } }, (options.preventDefaultForPointClick !== false
1282
+ ? {
1283
+ point: {
1284
+ events: {
1285
+ click: function () {
1286
+ // Prevent slicing of pie segment after clicking it
1287
+ return false;
1288
+ },
1288
1289
  },
1289
1290
  },
1290
- },
1291
- marker: options.splitTooltip
1291
+ }
1292
+ : {})), { marker: options.splitTooltip
1292
1293
  ? {
1293
1294
  states: {
1294
1295
  hover: {
@@ -1299,8 +1300,7 @@ export function prepareConfig(data, options, isMobile, holidays) {
1299
1300
  },
1300
1301
  },
1301
1302
  }
1302
- : {},
1303
- },
1303
+ : {} }),
1304
1304
  pie: {
1305
1305
  point: {
1306
1306
  events: {
@@ -351,17 +351,6 @@ declare function getGraph({ options, data, comments, isMobile, holidays }: GetGr
351
351
  stickyTracking: boolean;
352
352
  };
353
353
  series: {
354
- events: {
355
- legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void;
356
- mouseOver: () => void;
357
- mouseOut: () => void;
358
- click: (event: any) => void;
359
- };
360
- point: {
361
- events: {
362
- click: () => false;
363
- };
364
- };
365
354
  marker: {
366
355
  states: {
367
356
  hover: {
@@ -374,6 +363,17 @@ declare function getGraph({ options, data, comments, isMobile, holidays }: GetGr
374
363
  } | {
375
364
  states?: undefined;
376
365
  };
366
+ point?: {
367
+ events: {
368
+ click: () => false;
369
+ };
370
+ } | undefined;
371
+ events: {
372
+ legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void;
373
+ mouseOver: () => void;
374
+ mouseOut: () => void;
375
+ click: (event: any) => void;
376
+ };
377
377
  };
378
378
  pie: {
379
379
  point: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/chartkit",
3
- "version": "5.11.1",
3
+ "version": "5.12.0",
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",