@easyv/charts 1.10.4 → 1.10.6
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.
|
@@ -213,6 +213,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
213
213
|
width: chartWidth,
|
|
214
214
|
height: yLineRange,
|
|
215
215
|
axisX: axisX,
|
|
216
|
+
offsetX: clipX,
|
|
216
217
|
isHover: isHover,
|
|
217
218
|
config: tooltipConfig,
|
|
218
219
|
active: active
|
|
@@ -690,8 +691,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
690
691
|
marginTop: marginTop,
|
|
691
692
|
tickName: ctlXName,
|
|
692
693
|
series: series,
|
|
693
|
-
width:
|
|
694
|
-
height:
|
|
694
|
+
width: bodyWidth,
|
|
695
|
+
height: bodyHeight,
|
|
695
696
|
auto: auto,
|
|
696
697
|
manual: manual
|
|
697
698
|
}))), baseLineData && baseLineData.length > 0 && baseLineData.map(function (item, index) {
|
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);
|
|
@@ -731,8 +732,8 @@ const Chart = memo(
|
|
|
731
732
|
marginTop={marginTop}
|
|
732
733
|
tickName={ctlXName}
|
|
733
734
|
series={series}
|
|
734
|
-
width={
|
|
735
|
-
height={
|
|
735
|
+
width={bodyWidth}
|
|
736
|
+
height={bodyHeight}
|
|
736
737
|
auto={auto}
|
|
737
738
|
manual={manual}
|
|
738
739
|
/>
|
|
@@ -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)))));
|
package/src/components/Chart.js
CHANGED
|
@@ -48,7 +48,7 @@ const Chart = memo(
|
|
|
48
48
|
const isIOS = useRef(
|
|
49
49
|
/iPad|iPhone|iPod|iOS/i.test(navigator.userAgent) ||
|
|
50
50
|
(/Mac OS X/i.test(navigator.userAgent) &&
|
|
51
|
-
!/Chrome/i.test(navigator.userAgent))
|
|
51
|
+
!/Chrome/i.test(navigator.userAgent)),
|
|
52
52
|
);
|
|
53
53
|
const svg = createRef();
|
|
54
54
|
const chartWidth = width - marginLeft - marginRight;
|
|
@@ -81,12 +81,12 @@ const Chart = memo(
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
|
-
[JSON.stringify(interaction)]
|
|
84
|
+
[JSON.stringify(interaction)],
|
|
85
85
|
);
|
|
86
86
|
|
|
87
87
|
const onEmit = useCallback(
|
|
88
88
|
(type = "click", data) => emit && emit(type, data),
|
|
89
|
-
[emit]
|
|
89
|
+
[emit],
|
|
90
90
|
);
|
|
91
91
|
|
|
92
92
|
const context = useMemo(
|
|
@@ -101,7 +101,7 @@ const Chart = memo(
|
|
|
101
101
|
svg,
|
|
102
102
|
onEmit,
|
|
103
103
|
}),
|
|
104
|
-
[id, chartWidth, chartHeight, triggerOnRelative, svg, onEmit]
|
|
104
|
+
[id, chartWidth, chartHeight, triggerOnRelative, svg, onEmit],
|
|
105
105
|
);
|
|
106
106
|
|
|
107
107
|
useEffect(() => {
|
|
@@ -185,7 +185,7 @@ const Chart = memo(
|
|
|
185
185
|
} catch (e) {}
|
|
186
186
|
return [];
|
|
187
187
|
}
|
|
188
|
-
}
|
|
188
|
+
},
|
|
189
189
|
);
|
|
190
190
|
|
|
191
191
|
export default 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;
|