@gravity-ui/charts 1.39.0 → 1.39.1
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { line, select } from 'd3';
|
|
3
3
|
import { getAxisPlotsPosition, getLineDashArray } from '../../utils';
|
|
4
|
+
import { getXValue, getYValue } from '../useShapes/utils';
|
|
4
5
|
import { useCrosshairHover } from './useCrosshairHover';
|
|
5
6
|
export const useCrosshair = (props) => {
|
|
6
7
|
var _a, _b;
|
|
@@ -29,15 +30,18 @@ export const useCrosshair = (props) => {
|
|
|
29
30
|
crosshairSelection
|
|
30
31
|
.append('path')
|
|
31
32
|
.attr('d', (hoveredElement) => {
|
|
32
|
-
var _a, _b, _c;
|
|
33
33
|
let lineValue = 0;
|
|
34
|
-
if (xAxis.crosshair.snap
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
if (xAxis.crosshair.snap &&
|
|
35
|
+
typeof hoveredElement.data === 'object' &&
|
|
36
|
+
'x' in hoveredElement.data) {
|
|
37
|
+
const xVal = getXValue({
|
|
38
|
+
point: hoveredElement.data,
|
|
39
|
+
xAxis,
|
|
40
|
+
xScale: xAxisScale,
|
|
41
|
+
});
|
|
42
|
+
lineValue = xVal !== null && !Number.isNaN(xVal) ? xVal : lineValue;
|
|
39
43
|
}
|
|
40
|
-
else {
|
|
44
|
+
else if (!xAxis.crosshair.snap) {
|
|
41
45
|
lineValue = pointerXPos - boundsOffsetLeft;
|
|
42
46
|
}
|
|
43
47
|
const points = [
|
|
@@ -89,16 +93,18 @@ export const useCrosshair = (props) => {
|
|
|
89
93
|
crosshairSelection
|
|
90
94
|
.append('path')
|
|
91
95
|
.attr('d', (hoveredElement) => {
|
|
92
|
-
var _a, _b, _c;
|
|
93
96
|
let lineValue = 0;
|
|
94
|
-
if (yAxis.crosshair.snap
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
if (yAxis.crosshair.snap &&
|
|
98
|
+
typeof hoveredElement.data === 'object' &&
|
|
99
|
+
'y' in hoveredElement.data) {
|
|
100
|
+
const yVal = getYValue({
|
|
101
|
+
point: hoveredElement.data,
|
|
102
|
+
yAxis,
|
|
103
|
+
yScale: yAxisScale,
|
|
104
|
+
});
|
|
105
|
+
lineValue = yVal !== null && !Number.isNaN(yVal) ? yVal : lineValue;
|
|
100
106
|
}
|
|
101
|
-
else {
|
|
107
|
+
else if (!yAxis.crosshair.snap) {
|
|
102
108
|
lineValue = pointerYPos - boundsOffsetTop;
|
|
103
109
|
}
|
|
104
110
|
const points = [
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { line, select } from 'd3';
|
|
3
3
|
import { getAxisPlotsPosition, getLineDashArray } from '../../utils';
|
|
4
|
+
import { getXValue, getYValue } from '../useShapes/utils';
|
|
4
5
|
import { useCrosshairHover } from './useCrosshairHover';
|
|
5
6
|
export const useCrosshair = (props) => {
|
|
6
7
|
var _a, _b;
|
|
@@ -29,15 +30,18 @@ export const useCrosshair = (props) => {
|
|
|
29
30
|
crosshairSelection
|
|
30
31
|
.append('path')
|
|
31
32
|
.attr('d', (hoveredElement) => {
|
|
32
|
-
var _a, _b, _c;
|
|
33
33
|
let lineValue = 0;
|
|
34
|
-
if (xAxis.crosshair.snap
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
if (xAxis.crosshair.snap &&
|
|
35
|
+
typeof hoveredElement.data === 'object' &&
|
|
36
|
+
'x' in hoveredElement.data) {
|
|
37
|
+
const xVal = getXValue({
|
|
38
|
+
point: hoveredElement.data,
|
|
39
|
+
xAxis,
|
|
40
|
+
xScale: xAxisScale,
|
|
41
|
+
});
|
|
42
|
+
lineValue = xVal !== null && !Number.isNaN(xVal) ? xVal : lineValue;
|
|
39
43
|
}
|
|
40
|
-
else {
|
|
44
|
+
else if (!xAxis.crosshair.snap) {
|
|
41
45
|
lineValue = pointerXPos - boundsOffsetLeft;
|
|
42
46
|
}
|
|
43
47
|
const points = [
|
|
@@ -89,16 +93,18 @@ export const useCrosshair = (props) => {
|
|
|
89
93
|
crosshairSelection
|
|
90
94
|
.append('path')
|
|
91
95
|
.attr('d', (hoveredElement) => {
|
|
92
|
-
var _a, _b, _c;
|
|
93
96
|
let lineValue = 0;
|
|
94
|
-
if (yAxis.crosshair.snap
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
if (yAxis.crosshair.snap &&
|
|
98
|
+
typeof hoveredElement.data === 'object' &&
|
|
99
|
+
'y' in hoveredElement.data) {
|
|
100
|
+
const yVal = getYValue({
|
|
101
|
+
point: hoveredElement.data,
|
|
102
|
+
yAxis,
|
|
103
|
+
yScale: yAxisScale,
|
|
104
|
+
});
|
|
105
|
+
lineValue = yVal !== null && !Number.isNaN(yVal) ? yVal : lineValue;
|
|
100
106
|
}
|
|
101
|
-
else {
|
|
107
|
+
else if (!yAxis.crosshair.snap) {
|
|
102
108
|
lineValue = pointerYPos - boundsOffsetTop;
|
|
103
109
|
}
|
|
104
110
|
const points = [
|