@easyv/charts 1.2.11 → 1.2.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.
|
@@ -49,7 +49,6 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
49
49
|
yScaler = _ref.yAxis.scaler,
|
|
50
50
|
data = _ref.data;
|
|
51
51
|
if (!data.value) return null;
|
|
52
|
-
console.log(orientation, 'orientation');
|
|
53
52
|
var x1 = orientation == 'left' ? yScaler(data.value) : marginLeft,
|
|
54
53
|
x2 = orientation == 'left' ? yScaler(data.value) : width - marginRight,
|
|
55
54
|
y1 = orientation == 'left' ? marginLeft : yScaler(data.value),
|
|
@@ -46,11 +46,12 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
46
46
|
series = _ref$config.series,
|
|
47
47
|
tooltip = _ref$config.tooltip,
|
|
48
48
|
_ref$config$baseLine = _ref$config.baseLine,
|
|
49
|
-
|
|
50
|
-
_ref$config$baseLine$
|
|
51
|
-
|
|
52
|
-
_ref$config$baseLine$2
|
|
53
|
-
|
|
49
|
+
_ref$config$baseLine$ = _ref$config$baseLine.orientation,
|
|
50
|
+
baseLineOri = _ref$config$baseLine$ === void 0 ? '' : _ref$config$baseLine$,
|
|
51
|
+
_ref$config$baseLine$2 = _ref$config$baseLine.config,
|
|
52
|
+
baseLineConfig = _ref$config$baseLine$2 === void 0 ? {} : _ref$config$baseLine$2,
|
|
53
|
+
_ref$config$baseLine$3 = _ref$config$baseLine.data,
|
|
54
|
+
baseLineData = _ref$config$baseLine$3 === void 0 ? [] : _ref$config$baseLine$3,
|
|
54
55
|
_ref$config$tooltip = _ref$config.tooltip;
|
|
55
56
|
_ref$config$tooltip = _ref$config$tooltip === void 0 ? {} : _ref$config$tooltip;
|
|
56
57
|
var _ref$config$tooltip$c = _ref$config$tooltip.config,
|
|
@@ -9,8 +9,6 @@ exports["default"] = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
-
|
|
14
12
|
var _react = require("react");
|
|
15
13
|
|
|
16
14
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -27,33 +25,32 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
27
25
|
_props$speed = props.speed,
|
|
28
26
|
speed = _props$speed === void 0 ? 5 : _props$speed;
|
|
29
27
|
var dom = (0, _react.useRef)(null);
|
|
30
|
-
var content = (0, _react.useRef)(null);
|
|
31
|
-
var duration = (0, _react.useRef)(1); //dom和content盒子对象,避免speed变化时重新获取盒子对象
|
|
28
|
+
var content = (0, _react.useRef)(null); //dom和content盒子对象,避免speed变化时重新获取盒子对象
|
|
32
29
|
|
|
33
30
|
var domRect = (0, _react.useRef)(null);
|
|
34
|
-
var contentRect = (0, _react.useRef)(null);
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
contentRect.current = content_.getBoundingClientRect();
|
|
47
|
-
|
|
48
|
-
if (domRect.current.width < contentRect.current.width) {
|
|
49
|
-
setTextList([value, value]);
|
|
31
|
+
var contentRect = (0, _react.useRef)(null); //文本变化时,需要重新计算dom和content的宽高
|
|
32
|
+
|
|
33
|
+
var textList = (0, _react.useMemo)(function () {
|
|
34
|
+
if (dom.current && content.current) {
|
|
35
|
+
var dom_ = dom.current;
|
|
36
|
+
domRect.current = dom_.getBoundingClientRect();
|
|
37
|
+
var content_ = content.current;
|
|
38
|
+
contentRect.current = content_.getBoundingClientRect();
|
|
39
|
+
|
|
40
|
+
if (domRect.current.width < contentRect.current.width) {
|
|
41
|
+
return [value, value];
|
|
42
|
+
}
|
|
50
43
|
}
|
|
44
|
+
|
|
45
|
+
return [value];
|
|
51
46
|
}, [value]); //value和speed变化时,直接更新duration
|
|
52
47
|
|
|
53
|
-
(0, _react.
|
|
54
|
-
if (domRect.current.width < contentRect.current.width) {
|
|
55
|
-
|
|
48
|
+
var duration = (0, _react.useMemo)(function () {
|
|
49
|
+
if (domRect.current && contentRect.current && domRect.current.width < contentRect.current.width) {
|
|
50
|
+
return contentRect.current.width / domRect.current.width / speed * 10;
|
|
56
51
|
}
|
|
52
|
+
|
|
53
|
+
return 5;
|
|
57
54
|
}, [speed]); //在head标签中注入keyframes动画
|
|
58
55
|
|
|
59
56
|
(0, _react.useEffect)(function () {
|
|
@@ -88,7 +85,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
88
85
|
animationName: 'md_marquee',
|
|
89
86
|
animationTimingFunction: 'linear',
|
|
90
87
|
animationIterationCount: 'infinite',
|
|
91
|
-
animationDuration: duration
|
|
88
|
+
animationDuration: duration + 's'
|
|
92
89
|
} : {},
|
|
93
90
|
ref: itemIndex == 0 ? content : null
|
|
94
91
|
}, "\xA0", item);
|
package/package.json
CHANGED
|
@@ -38,7 +38,6 @@ export default memo(
|
|
|
38
38
|
data
|
|
39
39
|
}) => {
|
|
40
40
|
if (!data.value) return null;
|
|
41
|
-
console.log(orientation, 'orientation')
|
|
42
41
|
const x1 = orientation == 'left' ? yScaler(data.value) : marginLeft,
|
|
43
42
|
x2 = orientation == 'left' ? yScaler(data.value) : width - marginRight,
|
|
44
43
|
y1 = orientation == 'left' ? marginLeft : yScaler(data.value),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, memo, useRef, useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 文字跑马灯组件
|
|
@@ -14,29 +14,30 @@ export default memo((props) => {
|
|
|
14
14
|
|
|
15
15
|
const dom = useRef(null);
|
|
16
16
|
const content = useRef(null);
|
|
17
|
-
const duration = useRef(1);
|
|
18
17
|
//dom和content盒子对象,避免speed变化时重新获取盒子对象
|
|
19
18
|
const domRect = useRef(null);
|
|
20
19
|
const contentRect = useRef(null);
|
|
21
20
|
|
|
22
|
-
const [textList, setTextList] = useState([value]);
|
|
23
|
-
|
|
24
21
|
//文本变化时,需要重新计算dom和content的宽高
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
const textList = useMemo(()=>{
|
|
23
|
+
if(dom.current && content.current){
|
|
24
|
+
const dom_ = dom.current;
|
|
25
|
+
domRect.current = dom_.getBoundingClientRect();
|
|
26
|
+
let content_ = content.current;
|
|
27
|
+
contentRect.current = content_.getBoundingClientRect();
|
|
28
|
+
if (domRect.current.width < contentRect.current.width) {
|
|
29
|
+
return [value, value];
|
|
30
|
+
}
|
|
32
31
|
}
|
|
33
|
-
|
|
32
|
+
return [value];
|
|
33
|
+
},[value])
|
|
34
|
+
|
|
34
35
|
//value和speed变化时,直接更新duration
|
|
35
|
-
|
|
36
|
-
if (domRect.current.width < contentRect.current.width) {
|
|
37
|
-
|
|
38
|
-
(contentRect.current.width / domRect.current.width / speed) * 10;
|
|
36
|
+
const duration = useMemo(() => {
|
|
37
|
+
if (domRect.current && contentRect.current && domRect.current.width < contentRect.current.width) {
|
|
38
|
+
return (contentRect.current.width / domRect.current.width / speed) * 10;
|
|
39
39
|
}
|
|
40
|
+
return 5
|
|
40
41
|
}, [speed]);
|
|
41
42
|
//在head标签中注入keyframes动画
|
|
42
43
|
useEffect(() => {
|
|
@@ -78,7 +79,7 @@ export default memo((props) => {
|
|
|
78
79
|
animationName: 'md_marquee',
|
|
79
80
|
animationTimingFunction: 'linear',
|
|
80
81
|
animationIterationCount: 'infinite',
|
|
81
|
-
animationDuration: duration
|
|
82
|
+
animationDuration: duration + 's',
|
|
82
83
|
}
|
|
83
84
|
: {}
|
|
84
85
|
}
|