@easyv/charts 1.4.10 → 1.4.12
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/Band.js +2 -1
- package/lib/components/CartesianChart.js +6 -5
- package/lib/components/Label.js +3 -0
- package/lib/components/Tooltip.js +1 -0
- package/lib/hooks/useTooltip.js +9 -5
- package/package.json +1 -1
- package/src/components/Band.tsx +2 -1
- package/src/components/CartesianChart.js +6 -5
- package/src/components/Label.js +1 -0
- package/src/components/Tooltip.js +1 -1
- package/src/hooks/useTooltip.ts +10 -6
package/lib/components/Band.js
CHANGED
|
@@ -84,7 +84,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
84
84
|
triggerOnRelative = _useContext.triggerOnRelative,
|
|
85
85
|
onEmit = _useContext.onEmit;
|
|
86
86
|
|
|
87
|
-
var svg =
|
|
87
|
+
var svg = (0, _react.useRef)();
|
|
88
88
|
var axes = (0, _hooks.useAxes)({
|
|
89
89
|
axes: axesConfig,
|
|
90
90
|
context: context
|
|
@@ -100,6 +100,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
100
100
|
width: chartWidth,
|
|
101
101
|
height: chartHeight,
|
|
102
102
|
axisX: axisX,
|
|
103
|
+
isHover: isHover,
|
|
103
104
|
config: tooltipConfig
|
|
104
105
|
}),
|
|
105
106
|
tooltipX = _useTooltip.x,
|
|
@@ -172,14 +173,14 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
172
173
|
}));
|
|
173
174
|
}), showTooltip && /*#__PURE__*/_react["default"].createElement(_.Indicator, (0, _extends2["default"])({}, indicator, indicatorAttr)), /*#__PURE__*/_react["default"].createElement("foreignObject", {
|
|
174
175
|
style: isVertical ? {
|
|
175
|
-
width: xLineRange + marginRight,
|
|
176
|
+
width: xLineRange + marginRight + marginLeft,
|
|
176
177
|
height: yLineRange,
|
|
177
178
|
transform: "translateX(".concat(-marginRight, "px)")
|
|
178
179
|
} : {
|
|
179
180
|
width: xLineRange,
|
|
180
|
-
height: yLineRange + marginTop,
|
|
181
|
-
transform: "translateY(".concat(-marginTop, "px)")
|
|
182
|
-
|
|
181
|
+
height: yLineRange + marginTop + marginBottom,
|
|
182
|
+
transform: "translateY(".concat(-marginTop, "px)") // overflow:'visible'
|
|
183
|
+
// paddingTop:marginTop
|
|
183
184
|
|
|
184
185
|
}
|
|
185
186
|
}, /*#__PURE__*/_react["default"].createElement("svg", {
|
package/lib/components/Label.js
CHANGED
|
@@ -107,6 +107,9 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
107
107
|
return /*#__PURE__*/React.createElement("g", {
|
|
108
108
|
key: i,
|
|
109
109
|
onClick: triggerClick,
|
|
110
|
+
style: {
|
|
111
|
+
cursor: "pointer"
|
|
112
|
+
},
|
|
110
113
|
"data-data": JSON.stringify(data)
|
|
111
114
|
}, showIcon && !isNaN(attr.y) && /*#__PURE__*/React.createElement(Icon, {
|
|
112
115
|
cx: attr.x,
|
|
@@ -147,6 +147,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
147
147
|
style: (0, _utils.getFontStyle)(value)
|
|
148
148
|
}, showY, showSuffix && /*#__PURE__*/React.createElement("span", {
|
|
149
149
|
style: _objectSpread(_objectSpread({}, (0, _utils.getFontStyle)(suffiixFont)), {}, {
|
|
150
|
+
display: "inline-block",
|
|
150
151
|
transform: (0, _utils.getTranslate3d)(suffixTranslate)
|
|
151
152
|
})
|
|
152
153
|
}, tmp.get(s))));
|
package/lib/hooks/useTooltip.js
CHANGED
|
@@ -34,6 +34,7 @@ var _default = function _default(_ref) {
|
|
|
34
34
|
width = _ref.width,
|
|
35
35
|
height = _ref.height,
|
|
36
36
|
axisX = _ref.axisX,
|
|
37
|
+
isHover = _ref.isHover,
|
|
37
38
|
_ref$config = _ref.config;
|
|
38
39
|
_ref$config = _ref$config === void 0 ? {} : _ref$config;
|
|
39
40
|
var auto = _ref$config.auto,
|
|
@@ -81,13 +82,16 @@ var _default = function _default(_ref) {
|
|
|
81
82
|
return tick == _name;
|
|
82
83
|
}));
|
|
83
84
|
} else {
|
|
84
|
-
|
|
85
|
+
// 鼠标划出后,如果开启了自动轮播,就不需要让提示框消失了
|
|
86
|
+
if (!auto) {
|
|
87
|
+
setCurrentIndex(null);
|
|
88
|
+
}
|
|
85
89
|
}
|
|
86
90
|
}
|
|
87
|
-
}, [svg, marginLeft, axisX]);
|
|
91
|
+
}, [svg, marginLeft, axisX, auto]);
|
|
88
92
|
(0, _react.useEffect)(function () {
|
|
89
|
-
var on = auto && tickLength;
|
|
90
|
-
|
|
93
|
+
var on = auto && tickLength && !isHover; // if (!!on) setCurrentIndex(0);
|
|
94
|
+
|
|
91
95
|
var intervalHandler = on ? setInterval(function () {
|
|
92
96
|
setCurrentIndex(function (index) {
|
|
93
97
|
var tmp = index == null ? 0 : index;
|
|
@@ -103,7 +107,7 @@ var _default = function _default(_ref) {
|
|
|
103
107
|
return function () {
|
|
104
108
|
intervalHandler && clearInterval(intervalHandler);
|
|
105
109
|
};
|
|
106
|
-
}, [auto, tickLength, interval]);
|
|
110
|
+
}, [auto, tickLength, interval, isHover]);
|
|
107
111
|
var name = currentIndex === null ? null : axisX.allTicks[currentIndex];
|
|
108
112
|
return {
|
|
109
113
|
name: name,
|
package/package.json
CHANGED
package/src/components/Band.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import React, {
|
|
|
5
5
|
memo,
|
|
6
6
|
useMemo,
|
|
7
7
|
useState,
|
|
8
|
-
|
|
8
|
+
useRef,
|
|
9
9
|
useContext,
|
|
10
10
|
useCallback,
|
|
11
11
|
} from 'react';
|
|
@@ -68,7 +68,7 @@ const Chart = memo(
|
|
|
68
68
|
triggerOnRelative,
|
|
69
69
|
onEmit,
|
|
70
70
|
} = useContext(chartContext);
|
|
71
|
-
const svg =
|
|
71
|
+
const svg = useRef();
|
|
72
72
|
const axes = useAxes({ axes: axesConfig, context });
|
|
73
73
|
const axisX = useCarouselAxisX(axes.get('x'), animation, isHover);
|
|
74
74
|
const xLineRange = width-marginLeft-marginRight;
|
|
@@ -85,6 +85,7 @@ const Chart = memo(
|
|
|
85
85
|
width: chartWidth,
|
|
86
86
|
height: chartHeight,
|
|
87
87
|
axisX,
|
|
88
|
+
isHover,
|
|
88
89
|
config: tooltipConfig,
|
|
89
90
|
});
|
|
90
91
|
const tooltipData = useMemo(
|
|
@@ -157,14 +158,14 @@ const Chart = memo(
|
|
|
157
158
|
})}
|
|
158
159
|
{showTooltip && <Indicator {...indicator} {...indicatorAttr} />}
|
|
159
160
|
<foreignObject style={isVertical?{
|
|
160
|
-
width:xLineRange+marginRight,
|
|
161
|
+
width:xLineRange+marginRight+marginLeft,
|
|
161
162
|
height:yLineRange,
|
|
162
163
|
transform:`translateX(${-marginRight}px)`,
|
|
163
164
|
}:{
|
|
164
165
|
width:xLineRange,
|
|
165
|
-
height:yLineRange+marginTop,
|
|
166
|
+
height:yLineRange+marginTop+marginBottom,
|
|
166
167
|
transform:`translateY(${-marginTop}px)`,
|
|
167
|
-
overflow:'visible'
|
|
168
|
+
// overflow:'visible'
|
|
168
169
|
// paddingTop:marginTop
|
|
169
170
|
}}>
|
|
170
171
|
<svg width="100%" height="100%" style={{overflow:"visible",transform:isVertical?`translateX(${marginRight}px)`:`translateY(${marginTop}px)`}}>
|
package/src/components/Label.js
CHANGED
|
@@ -61,7 +61,6 @@ export default memo(
|
|
|
61
61
|
tipHeight,
|
|
62
62
|
translateTip,
|
|
63
63
|
]);
|
|
64
|
-
|
|
65
64
|
return (
|
|
66
65
|
<div
|
|
67
66
|
className='__easyv-tooltip'
|
|
@@ -151,6 +150,7 @@ export default memo(
|
|
|
151
150
|
<span
|
|
152
151
|
style={{
|
|
153
152
|
...getFontStyle(suffiixFont),
|
|
153
|
+
display:"inline-block",
|
|
154
154
|
transform: getTranslate3d(suffixTranslate),
|
|
155
155
|
}}
|
|
156
156
|
>
|
package/src/hooks/useTooltip.ts
CHANGED
|
@@ -20,6 +20,7 @@ type Props = {
|
|
|
20
20
|
width: number;
|
|
21
21
|
height: number;
|
|
22
22
|
axisX: AxisX;
|
|
23
|
+
isHover:boolean,
|
|
23
24
|
config: { auto?: boolean; interval?: number; manual?: boolean };
|
|
24
25
|
};
|
|
25
26
|
|
|
@@ -30,10 +31,10 @@ export default ({
|
|
|
30
31
|
width,
|
|
31
32
|
height,
|
|
32
33
|
axisX,
|
|
34
|
+
isHover,
|
|
33
35
|
config: { auto, interval = 0, manual } = {},
|
|
34
36
|
}: Props) => {
|
|
35
37
|
const [currentIndex, setCurrentIndex] = useState<number | null>(null);
|
|
36
|
-
|
|
37
38
|
const tickLength = axisX.allTicks.length;
|
|
38
39
|
const setIndex = useCallback(
|
|
39
40
|
(e) => {
|
|
@@ -62,15 +63,18 @@ export default ({
|
|
|
62
63
|
);
|
|
63
64
|
setCurrentIndex(allTicks.findIndex((tick: string) => tick == name));
|
|
64
65
|
} else {
|
|
65
|
-
|
|
66
|
+
// 鼠标划出后,如果开启了自动轮播,就不需要让提示框消失了
|
|
67
|
+
if(!auto){
|
|
68
|
+
setCurrentIndex(null);
|
|
69
|
+
}
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
},
|
|
69
|
-
[svg, marginLeft, axisX]
|
|
73
|
+
[svg, marginLeft, axisX, auto]
|
|
70
74
|
);
|
|
71
75
|
useEffect(() => {
|
|
72
|
-
const on = auto && tickLength;
|
|
73
|
-
if (!!on) setCurrentIndex(0);
|
|
76
|
+
const on = auto && tickLength && !isHover;
|
|
77
|
+
// if (!!on) setCurrentIndex(0);
|
|
74
78
|
const intervalHandler = on
|
|
75
79
|
? setInterval(() => {
|
|
76
80
|
setCurrentIndex((index) => {
|
|
@@ -86,7 +90,7 @@ export default ({
|
|
|
86
90
|
return () => {
|
|
87
91
|
intervalHandler && clearInterval(intervalHandler);
|
|
88
92
|
};
|
|
89
|
-
}, [auto, tickLength, interval]);
|
|
93
|
+
}, [auto, tickLength, interval, isHover]);
|
|
90
94
|
const name = currentIndex === null ? null : axisX.allTicks[currentIndex];
|
|
91
95
|
return {
|
|
92
96
|
name,
|