@easyv/charts 1.5.17 → 1.5.19
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/PieChart.js +17 -4
- 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/PieChart.js +13 -3
- 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
|
};
|
|
@@ -350,6 +350,7 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
350
350
|
|
|
351
351
|
var _useContext = (0, _react.useContext)(_context.chartContext),
|
|
352
352
|
id = _useContext.id,
|
|
353
|
+
isIOS = _useContext.isIOS,
|
|
353
354
|
chartWidth = _useContext.width,
|
|
354
355
|
chartHeight = _useContext.height,
|
|
355
356
|
triggerOnRelative = _useContext.triggerOnRelative,
|
|
@@ -796,8 +797,13 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
796
797
|
}
|
|
797
798
|
}, /*#__PURE__*/_react["default"].createElement(Current, {
|
|
798
799
|
config: current,
|
|
799
|
-
width:
|
|
800
|
-
height:
|
|
800
|
+
width: chartWidth,
|
|
801
|
+
height: chartHeight,
|
|
802
|
+
iosStyle: {
|
|
803
|
+
marginLeft: marginLeft,
|
|
804
|
+
marginTop: marginTop,
|
|
805
|
+
isIOS: isIOS
|
|
806
|
+
},
|
|
801
807
|
data: _arcs,
|
|
802
808
|
judge: judgeData,
|
|
803
809
|
currentIndex: +currentIndex
|
|
@@ -867,6 +873,10 @@ var Current = function Current(_ref9) {
|
|
|
867
873
|
_ref9$config$value$su2 = _ref9$config$value$su.translate,
|
|
868
874
|
translateSuffixX = _ref9$config$value$su2.x,
|
|
869
875
|
translateSuffixY = _ref9$config$value$su2.y,
|
|
876
|
+
_ref9$iosStyle = _ref9.iosStyle,
|
|
877
|
+
isIOS = _ref9$iosStyle.isIOS,
|
|
878
|
+
marginLeft = _ref9$iosStyle.marginLeft,
|
|
879
|
+
marginTop = _ref9$iosStyle.marginTop,
|
|
870
880
|
width = _ref9.width,
|
|
871
881
|
height = _ref9.height,
|
|
872
882
|
data = _ref9.data,
|
|
@@ -897,17 +907,20 @@ var Current = function Current(_ref9) {
|
|
|
897
907
|
//foreignObject标签样式,
|
|
898
908
|
width: width,
|
|
899
909
|
height: height,
|
|
900
|
-
|
|
910
|
+
position: "relative",
|
|
911
|
+
overflow: "visible",
|
|
901
912
|
pointerEvents: "none"
|
|
902
913
|
},
|
|
903
914
|
boxStyle = {
|
|
904
915
|
//弹性盒子样式,用于当前值的上下居中对齐等
|
|
905
916
|
width: width,
|
|
906
917
|
height: height,
|
|
918
|
+
position: "absolute",
|
|
907
919
|
display: "flex",
|
|
908
920
|
flexDirection: "column",
|
|
909
921
|
justifyContent: "center",
|
|
910
|
-
alignItems: "center"
|
|
922
|
+
alignItems: "center",
|
|
923
|
+
transform: isIOS ? "translate(".concat(marginLeft, "px,").concat(marginTop, "px)") : "translate(-".concat(width / 2, "px,-").concat(height / 2, "px)")
|
|
911
924
|
};
|
|
912
925
|
var seriesColor = currentData.series.color;
|
|
913
926
|
seriesColor = seriesColor.type == "pure" ? seriesColor.pure : seriesColor.linear.stops[0].color;
|
|
@@ -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
|
);
|
|
@@ -295,6 +295,7 @@ const Component = memo(
|
|
|
295
295
|
const { precision: legendPrecision } = legend.config.percent;
|
|
296
296
|
const {
|
|
297
297
|
id,
|
|
298
|
+
isIOS,
|
|
298
299
|
width: chartWidth,
|
|
299
300
|
height: chartHeight,
|
|
300
301
|
triggerOnRelative,
|
|
@@ -826,8 +827,11 @@ const Component = memo(
|
|
|
826
827
|
>
|
|
827
828
|
<Current
|
|
828
829
|
config={current}
|
|
829
|
-
width={
|
|
830
|
-
height={
|
|
830
|
+
width={chartWidth}
|
|
831
|
+
height={chartHeight}
|
|
832
|
+
iosStyle={{
|
|
833
|
+
marginLeft, marginTop, isIOS
|
|
834
|
+
}}
|
|
831
835
|
data={_arcs}
|
|
832
836
|
judge={judgeData}
|
|
833
837
|
currentIndex={+currentIndex}
|
|
@@ -910,6 +914,9 @@ const Current = ({
|
|
|
910
914
|
},
|
|
911
915
|
},
|
|
912
916
|
},
|
|
917
|
+
iosStyle:{
|
|
918
|
+
isIOS, marginLeft, marginTop
|
|
919
|
+
},
|
|
913
920
|
width,
|
|
914
921
|
height,
|
|
915
922
|
data,
|
|
@@ -939,17 +946,20 @@ const Current = ({
|
|
|
939
946
|
//foreignObject标签样式,
|
|
940
947
|
width,
|
|
941
948
|
height,
|
|
942
|
-
|
|
949
|
+
position:"relative",
|
|
950
|
+
overflow:"visible",
|
|
943
951
|
pointerEvents: "none",
|
|
944
952
|
},
|
|
945
953
|
boxStyle = {
|
|
946
954
|
//弹性盒子样式,用于当前值的上下居中对齐等
|
|
947
955
|
width,
|
|
948
956
|
height,
|
|
957
|
+
position:"absolute",
|
|
949
958
|
display: "flex",
|
|
950
959
|
flexDirection: "column",
|
|
951
960
|
justifyContent: "center",
|
|
952
961
|
alignItems: "center",
|
|
962
|
+
transform: isIOS?`translate(${marginLeft}px,${marginTop}px)`:`translate(-${width / 2}px,-${height / 2}px)`,
|
|
953
963
|
};
|
|
954
964
|
let seriesColor = currentData.series.color;
|
|
955
965
|
seriesColor =
|
|
@@ -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
|
}
|