@easyv/charts 1.5.16 → 1.5.18
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/AnimateData.js +4 -2
- package/lib/components/Chart.js +5 -1
- package/lib/hooks/useAnimateData.js +4 -3
- package/lib/utils/index.js +4 -5
- package/package.json +1 -1
- package/src/components/AnimateData.tsx +3 -1
- package/src/components/Chart.js +3 -1
- package/src/hooks/useAnimateData.ts +5 -4
- package/src/utils/index.js +2 -4
|
@@ -18,7 +18,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
18
18
|
var _hooks = require("../hooks");
|
|
19
19
|
|
|
20
20
|
var _excluded = ["dataAnimation"],
|
|
21
|
-
_excluded2 = ["data", "config"];
|
|
21
|
+
_excluded2 = ["data", "config", "active"];
|
|
22
22
|
|
|
23
23
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
24
24
|
|
|
@@ -30,11 +30,13 @@ var _default = function _default(Component) {
|
|
|
30
30
|
_ref$config = _ref.config,
|
|
31
31
|
dataAnimation = _ref$config.dataAnimation,
|
|
32
32
|
config = (0, _objectWithoutProperties2["default"])(_ref$config, _excluded),
|
|
33
|
+
active = _ref.active,
|
|
33
34
|
rest = (0, _objectWithoutProperties2["default"])(_ref, _excluded2);
|
|
34
35
|
return /*#__PURE__*/_react["default"].createElement(Component, (0, _extends2["default"])({}, rest, {
|
|
35
36
|
config: config,
|
|
36
37
|
originData: data,
|
|
37
|
-
|
|
38
|
+
active: active,
|
|
39
|
+
data: (0, _hooks.useAnimateData)(data, dataAnimation, active)
|
|
38
40
|
}));
|
|
39
41
|
});
|
|
40
42
|
};
|
package/lib/components/Chart.js
CHANGED
|
@@ -116,11 +116,15 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
|
|
|
116
116
|
};
|
|
117
117
|
}, [id, chartWidth, chartHeight, triggerOnRelative, svg, onEmit]);
|
|
118
118
|
(0, _react.useEffect)(function () {
|
|
119
|
+
var isAnimation = window.screenConfig ? window.screenConfig.isAnimation : true; //大屏的全局设置是否允许开启动画,false为不允许
|
|
120
|
+
|
|
121
|
+
if (!isAnimation) setActive(false);
|
|
122
|
+
|
|
119
123
|
var activeHandler = function activeHandler(e) {
|
|
120
124
|
var _e$dynamicData = e.dynamicData,
|
|
121
125
|
dynamicData = _e$dynamicData === void 0 ? true : _e$dynamicData; // console.log("当前组件(id="+id+")状态:",dynamicData?"唤醒":"休眠");
|
|
122
126
|
|
|
123
|
-
setActive(dynamicData);
|
|
127
|
+
isAnimation && setActive(dynamicData);
|
|
124
128
|
};
|
|
125
129
|
|
|
126
130
|
document.addEventListener("switchActive_".concat(id), activeHandler);
|
|
@@ -23,9 +23,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
23
23
|
* 图表数据动画
|
|
24
24
|
* @param {Array} data data列表
|
|
25
25
|
* @param {boolean} dataAnimation 是否开启数据增长动画
|
|
26
|
+
* @param {boolean} active 是否处于活跃状态,false为休眠
|
|
26
27
|
* @returns 改变后的数据
|
|
27
28
|
*/
|
|
28
|
-
var _default = function _default(data, dataAnimation) {
|
|
29
|
+
var _default = function _default(data, dataAnimation, active) {
|
|
29
30
|
var _useState = (0, _react.useState)([]),
|
|
30
31
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
31
32
|
animateData = _useState2[0],
|
|
@@ -34,7 +35,7 @@ var _default = function _default(data, dataAnimation) {
|
|
|
34
35
|
(0, _react.useEffect)(function () {
|
|
35
36
|
var animateRef = null;
|
|
36
37
|
|
|
37
|
-
if (dataAnimation && dataAnimation.show && dataAnimation.duration && data.length) {
|
|
38
|
+
if (dataAnimation && dataAnimation.show && dataAnimation.duration && data.length && active) {
|
|
38
39
|
animateRef = (0, _popmotion.animate)({
|
|
39
40
|
autoplay: true,
|
|
40
41
|
repeat: 0,
|
|
@@ -82,7 +83,7 @@ var _default = function _default(data, dataAnimation) {
|
|
|
82
83
|
return function () {
|
|
83
84
|
animateRef && animateRef.stop();
|
|
84
85
|
};
|
|
85
|
-
}, [data, dataAnimation]);
|
|
86
|
+
}, [data, dataAnimation, active]);
|
|
86
87
|
return animateData;
|
|
87
88
|
};
|
|
88
89
|
|
package/lib/utils/index.js
CHANGED
|
@@ -32,15 +32,11 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
32
32
|
|
|
33
33
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
34
34
|
|
|
35
|
-
var defaultSize = 10;
|
|
36
35
|
var defaultBackground = '#000000';
|
|
37
36
|
var defaultIcon = {
|
|
38
|
-
minWidth: defaultSize,
|
|
39
|
-
height: defaultSize,
|
|
40
37
|
background: defaultBackground
|
|
41
38
|
};
|
|
42
39
|
var defaultLineIcon = {
|
|
43
|
-
minWidth: defaultSize,
|
|
44
40
|
height: 2,
|
|
45
41
|
background: defaultBackground
|
|
46
42
|
};
|
|
@@ -131,11 +127,14 @@ var getIcon = function getIcon(type, icon) {
|
|
|
131
127
|
case 'line':
|
|
132
128
|
var color = icon.background;
|
|
133
129
|
return icon ? _objectSpread(_objectSpread(_objectSpread({}, defaultLineIcon), icon), {}, {
|
|
130
|
+
minWidth: icon.width,
|
|
134
131
|
background: lineType == "solid" ? color : "linear-gradient(90deg, ".concat(color, ", ").concat(color, " 66%, transparent 66%) 0 0/33% 100% repeat")
|
|
135
132
|
}) : defaultLineIcon;
|
|
136
133
|
|
|
137
134
|
default:
|
|
138
|
-
return icon ? _objectSpread(_objectSpread({}, defaultIcon), icon)
|
|
135
|
+
return icon ? _objectSpread(_objectSpread(_objectSpread({}, defaultIcon), icon), {}, {
|
|
136
|
+
minWidth: icon.width
|
|
137
|
+
}) : defaultIcon;
|
|
139
138
|
}
|
|
140
139
|
};
|
|
141
140
|
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ export default (Component: ComponentType<any>) =>
|
|
|
9
9
|
({
|
|
10
10
|
data,
|
|
11
11
|
config: { dataAnimation, ...config },
|
|
12
|
+
active,
|
|
12
13
|
...rest
|
|
13
14
|
}: {
|
|
14
15
|
data: DataType[];
|
|
@@ -19,7 +20,8 @@ export default (Component: ComponentType<any>) =>
|
|
|
19
20
|
{...rest}
|
|
20
21
|
config={config}
|
|
21
22
|
originData={data}
|
|
22
|
-
|
|
23
|
+
active={active}
|
|
24
|
+
data={useAnimateData(data, dataAnimation, active)}
|
|
23
25
|
/>
|
|
24
26
|
}
|
|
25
27
|
);
|
package/src/components/Chart.js
CHANGED
|
@@ -92,10 +92,12 @@ const Chart = memo(
|
|
|
92
92
|
);
|
|
93
93
|
|
|
94
94
|
useEffect(()=>{
|
|
95
|
+
let isAnimation = window.screenConfig?window.screenConfig.isAnimation:true; //大屏的全局设置是否允许开启动画,false为不允许
|
|
96
|
+
if(!isAnimation) setActive(false);
|
|
95
97
|
const activeHandler=(e)=>{
|
|
96
98
|
const { dynamicData = true } = e;
|
|
97
99
|
// console.log("当前组件(id="+id+")状态:",dynamicData?"唤醒":"休眠");
|
|
98
|
-
setActive(dynamicData);
|
|
100
|
+
isAnimation && setActive(dynamicData);
|
|
99
101
|
}
|
|
100
102
|
document.addEventListener(`switchActive_${id}`,activeHandler);
|
|
101
103
|
return ()=>{
|
|
@@ -5,19 +5,20 @@ import { animate, easeIn, easeOut, linear } from 'popmotion';
|
|
|
5
5
|
* 图表数据动画
|
|
6
6
|
* @param {Array} data data列表
|
|
7
7
|
* @param {boolean} dataAnimation 是否开启数据增长动画
|
|
8
|
+
* @param {boolean} active 是否处于活跃状态,false为休眠
|
|
8
9
|
* @returns 改变后的数据
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
|
-
export default (data: DataType[], dataAnimation: DataAnimation) => {
|
|
12
|
+
export default (data: DataType[], dataAnimation: DataAnimation, active:boolean) => {
|
|
12
13
|
const [animateData, setAnimateData] = useState<DataType[]>([]);
|
|
13
|
-
|
|
14
14
|
useEffect(() => {
|
|
15
15
|
let animateRef: any = null;
|
|
16
16
|
if (
|
|
17
17
|
dataAnimation &&
|
|
18
18
|
dataAnimation.show &&
|
|
19
19
|
dataAnimation.duration &&
|
|
20
|
-
data.length
|
|
20
|
+
data.length &&
|
|
21
|
+
active
|
|
21
22
|
) {
|
|
22
23
|
animateRef = animate({
|
|
23
24
|
autoplay: true,
|
|
@@ -61,7 +62,7 @@ export default (data: DataType[], dataAnimation: DataAnimation) => {
|
|
|
61
62
|
return () => {
|
|
62
63
|
animateRef && animateRef.stop();
|
|
63
64
|
};
|
|
64
|
-
}, [data, dataAnimation]);
|
|
65
|
+
}, [data, dataAnimation, active]);
|
|
65
66
|
|
|
66
67
|
return animateData;
|
|
67
68
|
};
|
package/src/utils/index.js
CHANGED
|
@@ -10,15 +10,11 @@ import {
|
|
|
10
10
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
11
11
|
import { toPath } from 'svg-points';
|
|
12
12
|
|
|
13
|
-
const defaultSize = 10;
|
|
14
13
|
const defaultBackground = '#000000';
|
|
15
14
|
const defaultIcon = {
|
|
16
|
-
minWidth: defaultSize,
|
|
17
|
-
height: defaultSize,
|
|
18
15
|
background: defaultBackground,
|
|
19
16
|
};
|
|
20
17
|
const defaultLineIcon = {
|
|
21
|
-
minWidth: defaultSize,
|
|
22
18
|
height: 2,
|
|
23
19
|
background: defaultBackground,
|
|
24
20
|
};
|
|
@@ -89,6 +85,7 @@ const getIcon = (type, icon, lineType="solid") => {
|
|
|
89
85
|
? {
|
|
90
86
|
...defaultLineIcon,
|
|
91
87
|
...icon,
|
|
88
|
+
minWidth: icon.width,
|
|
92
89
|
background:lineType=="solid"?color:`linear-gradient(90deg, ${color}, ${color} 66%, transparent 66%) 0 0/33% 100% repeat`
|
|
93
90
|
}
|
|
94
91
|
: defaultLineIcon;
|
|
@@ -97,6 +94,7 @@ const getIcon = (type, icon, lineType="solid") => {
|
|
|
97
94
|
? {
|
|
98
95
|
...defaultIcon,
|
|
99
96
|
...icon,
|
|
97
|
+
minWidth: icon.width,
|
|
100
98
|
}
|
|
101
99
|
: defaultIcon;
|
|
102
100
|
}
|