@easyv/charts 1.10.4 → 1.10.5
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/hooks/useTooltip.js
CHANGED
|
@@ -29,6 +29,8 @@ var _default = exports["default"] = function _default(_ref) {
|
|
|
29
29
|
width = _ref.width,
|
|
30
30
|
height = _ref.height,
|
|
31
31
|
axisX = _ref.axisX,
|
|
32
|
+
_ref$offsetX = _ref.offsetX,
|
|
33
|
+
offsetX = _ref$offsetX === void 0 ? 0 : _ref$offsetX,
|
|
32
34
|
isHover = _ref.isHover,
|
|
33
35
|
_ref$config = _ref.config,
|
|
34
36
|
_ref$config2 = _ref$config === void 0 ? {} : _ref$config,
|
|
@@ -62,7 +64,7 @@ var _default = exports["default"] = function _default(_ref) {
|
|
|
62
64
|
var x = resetX - marginLeft;
|
|
63
65
|
var y = resetY - marginTop;
|
|
64
66
|
if (x > 0 && x < width && y > 0 && y < height && _ticks.length) {
|
|
65
|
-
var position = direction === "vertical" ? y : x;
|
|
67
|
+
var position = direction === "vertical" ? y : x + offsetX;
|
|
66
68
|
var _name = _ticks.reduce(function (prev, current) {
|
|
67
69
|
return Math.abs(scaler(prev) - position) > Math.abs(scaler(current) - position) ? current : prev;
|
|
68
70
|
});
|
|
@@ -76,7 +78,7 @@ var _default = exports["default"] = function _default(_ref) {
|
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
|
-
}, [svg, marginLeft, axisX, auto]);
|
|
81
|
+
}, [svg, marginLeft, axisX, auto, offsetX]);
|
|
80
82
|
(0, _react.useEffect)(function () {
|
|
81
83
|
var on = auto && tickLength && !isHover && active;
|
|
82
84
|
if (!auto) setIndex(-1); //不开启自动轮播,提示框等隐藏
|
package/package.json
CHANGED
|
@@ -144,7 +144,7 @@ const Chart = memo(
|
|
|
144
144
|
animation,
|
|
145
145
|
isHover,
|
|
146
146
|
controlInfo,
|
|
147
|
-
active
|
|
147
|
+
active,
|
|
148
148
|
);
|
|
149
149
|
|
|
150
150
|
//初始化控制图提示框状态的函数
|
|
@@ -206,6 +206,7 @@ const Chart = memo(
|
|
|
206
206
|
width: chartWidth,
|
|
207
207
|
height: yLineRange,
|
|
208
208
|
axisX,
|
|
209
|
+
offsetX: clipX,
|
|
209
210
|
isHover,
|
|
210
211
|
config: tooltipConfig,
|
|
211
212
|
active,
|
|
@@ -240,7 +241,7 @@ const Chart = memo(
|
|
|
240
241
|
const tooltipData = useMemo(
|
|
241
242
|
() =>
|
|
242
243
|
tickName !== undefined && originData.filter((d) => d.x === tickName),
|
|
243
|
-
[tickName, JSON.stringify(originData)]
|
|
244
|
+
[tickName, JSON.stringify(originData)],
|
|
244
245
|
);
|
|
245
246
|
|
|
246
247
|
const showTooltip = !!(
|
|
@@ -286,7 +287,7 @@ const Chart = memo(
|
|
|
286
287
|
onEmit(type, eventData);
|
|
287
288
|
}
|
|
288
289
|
},
|
|
289
|
-
[triggerOnRelative, onEmit, scale]
|
|
290
|
+
[triggerOnRelative, onEmit, scale],
|
|
290
291
|
);
|
|
291
292
|
|
|
292
293
|
/**
|
|
@@ -371,7 +372,7 @@ const Chart = memo(
|
|
|
371
372
|
if (timeStamp - loopTime < tranDuration) {
|
|
372
373
|
const percent = Math.min(
|
|
373
374
|
1,
|
|
374
|
-
(timeStamp - loopTime) / tranDuration
|
|
375
|
+
(timeStamp - loopTime) / tranDuration,
|
|
375
376
|
);
|
|
376
377
|
if (toRight) {
|
|
377
378
|
setControlTranslate(cBarWidth * percent + ctlBarX.current);
|
|
@@ -811,6 +812,6 @@ const Chart = memo(
|
|
|
811
812
|
{brush && <Brush config={brush} width={width} />}
|
|
812
813
|
</>
|
|
813
814
|
);
|
|
814
|
-
}
|
|
815
|
+
},
|
|
815
816
|
);
|
|
816
817
|
export default Mapping(FilterData(ExtentData(AnimateData(StackData(Chart)))));
|
|
@@ -161,7 +161,7 @@ export default memo(
|
|
|
161
161
|
>
|
|
162
162
|
{data.map(({ showY, s }, index) => {
|
|
163
163
|
const { type, icon, displayName } = series.find(
|
|
164
|
-
(series) => series.name == s
|
|
164
|
+
(series) => series.name == s,
|
|
165
165
|
);
|
|
166
166
|
const {
|
|
167
167
|
show: showSuffix,
|
|
@@ -232,5 +232,5 @@ export default memo(
|
|
|
232
232
|
) : (
|
|
233
233
|
""
|
|
234
234
|
);
|
|
235
|
-
}
|
|
235
|
+
},
|
|
236
236
|
);
|
package/src/hooks/useTooltip.ts
CHANGED
|
@@ -21,6 +21,7 @@ type Props = {
|
|
|
21
21
|
width: number;
|
|
22
22
|
height: number;
|
|
23
23
|
axisX: any;
|
|
24
|
+
offsetX?: number;
|
|
24
25
|
isHover: boolean;
|
|
25
26
|
config: { auto?: boolean; interval?: number; manual?: boolean };
|
|
26
27
|
active: boolean;
|
|
@@ -33,6 +34,7 @@ export default ({
|
|
|
33
34
|
width,
|
|
34
35
|
height,
|
|
35
36
|
axisX,
|
|
37
|
+
offsetX = 0,
|
|
36
38
|
isHover,
|
|
37
39
|
config: { auto, interval = 0, manual } = {},
|
|
38
40
|
active,
|
|
@@ -57,12 +59,12 @@ export default ({
|
|
|
57
59
|
const x = resetX - marginLeft;
|
|
58
60
|
const y = resetY - marginTop;
|
|
59
61
|
if (x > 0 && x < width && y > 0 && y < height && _ticks.length) {
|
|
60
|
-
const position = direction === "vertical" ? y : x;
|
|
62
|
+
const position = direction === "vertical" ? y : x + offsetX;
|
|
61
63
|
const name = _ticks.reduce((prev: string, current: string) =>
|
|
62
64
|
Math.abs(scaler(prev) - position) >
|
|
63
65
|
Math.abs(scaler(current) - position)
|
|
64
66
|
? current
|
|
65
|
-
: prev
|
|
67
|
+
: prev,
|
|
66
68
|
);
|
|
67
69
|
setCurrentIndex(allTicks.findIndex((tick: string) => tick == name));
|
|
68
70
|
} else {
|
|
@@ -73,7 +75,7 @@ export default ({
|
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
},
|
|
76
|
-
[svg, marginLeft, axisX, auto]
|
|
78
|
+
[svg, marginLeft, axisX, auto, offsetX],
|
|
77
79
|
);
|
|
78
80
|
useEffect(() => {
|
|
79
81
|
const on = auto && tickLength && !isHover && active;
|