@easyv/charts 1.1.7 → 1.1.8
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/lib/components/Tooltip.js +1 -1
- package/package.json +3 -2
- package/src/components/Tooltip.js +11 -10
- package/src/hooks/useTooltip.ts +11 -11
|
@@ -63,7 +63,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
63
63
|
if (translate3d.y + tipHeight > height) {
|
|
64
64
|
var _newPositon = position + marginTop - tipHeight - translateTip.y;
|
|
65
65
|
|
|
66
|
-
translate3d.y = _newPositon
|
|
66
|
+
translate3d.y = _newPositon <= 0 ? _newPositon : height - tipHeight;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
return (0, _utils.getTranslate3d)(translate3d);
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easyv/charts",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
+
"release": "standard-version",
|
|
7
8
|
"make": "babel src -d lib --extensions .ts,.tsx,.js && cp -r src/css lib",
|
|
8
9
|
"prepare": "husky install"
|
|
9
10
|
},
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
"standard-version": "^9.3.2"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@easyv/utils": "^0.0.
|
|
35
|
+
"@easyv/utils": "^0.0.44",
|
|
35
36
|
"d3v7": "npm:d3@^7.0.0",
|
|
36
37
|
"popmotion": "^9.3.6",
|
|
37
38
|
"react": "^17.0.2",
|
|
@@ -34,20 +34,21 @@ export default memo(
|
|
|
34
34
|
const tipPosition = useMemo(() => {
|
|
35
35
|
const translate3d = isVertical
|
|
36
36
|
? {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
...translateTip,
|
|
38
|
+
y: translateTip.y + position + marginTop,
|
|
39
|
+
}
|
|
40
40
|
: {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
...translateTip,
|
|
42
|
+
x: translateTip.x + position + marginLeft,
|
|
43
|
+
};
|
|
44
|
+
|
|
44
45
|
if (translate3d.x + tipWidth > width) {
|
|
45
46
|
const newPositon = position + marginLeft - tipWidth - translateTip.x;
|
|
46
47
|
translate3d.x = newPositon >= 0 ? newPositon : 0;
|
|
47
48
|
}
|
|
48
49
|
if (translate3d.y + tipHeight > height) {
|
|
49
50
|
const newPositon = position + marginTop - tipHeight - translateTip.y;
|
|
50
|
-
translate3d.y = newPositon
|
|
51
|
+
translate3d.y = newPositon <= 0 ? newPositon : height - tipHeight;
|
|
51
52
|
}
|
|
52
53
|
return getTranslate3d(translate3d);
|
|
53
54
|
}, [
|
|
@@ -72,9 +73,9 @@ export default memo(
|
|
|
72
73
|
padding: getMargin(margin),
|
|
73
74
|
background: image
|
|
74
75
|
? '50% 50% / 100% 100% no-repeat url(' +
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
window.appConfig.ASSETS_URL +
|
|
77
|
+
image +
|
|
78
|
+
')'
|
|
78
79
|
: 'rgba(48, 55, 66, 0.85)',
|
|
79
80
|
...getFontStyle(font),
|
|
80
81
|
}}
|
package/src/hooks/useTooltip.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useState, useEffect } from 'react';
|
|
2
2
|
import { getMousePos } from '../utils';
|
|
3
|
-
const callback = () => {};
|
|
3
|
+
const callback = () => { };
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 主要用于轴类图表,返回当前选中的是哪一个x
|
|
@@ -56,7 +56,7 @@ export default ({
|
|
|
56
56
|
const position = direction === 'vertical' ? y : x;
|
|
57
57
|
const name = _ticks.reduce((prev: string, current: string) =>
|
|
58
58
|
Math.abs(scaler(prev) - position) >
|
|
59
|
-
|
|
59
|
+
Math.abs(scaler(current) - position)
|
|
60
60
|
? current
|
|
61
61
|
: prev
|
|
62
62
|
);
|
|
@@ -73,15 +73,15 @@ export default ({
|
|
|
73
73
|
if (!!on) setCurrentIndex(0);
|
|
74
74
|
const intervalHandler = on
|
|
75
75
|
? setInterval(() => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
76
|
+
setCurrentIndex((index) => {
|
|
77
|
+
const tmp = index == null ? 0 : index;
|
|
78
|
+
const currentIndex = tmp + 1;
|
|
79
|
+
if (currentIndex >= tickLength) {
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
return currentIndex;
|
|
83
|
+
});
|
|
84
|
+
}, interval * 1000)
|
|
85
85
|
: null;
|
|
86
86
|
return () => {
|
|
87
87
|
intervalHandler && clearInterval(intervalHandler);
|