@easyv/charts 1.8.15 → 1.8.16
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/Band.js +356 -356
- package/lib/components/Carousel.js +31 -21
- package/lib/components/Label.js +356 -356
- package/lib/components/Legend.js +312 -312
- package/lib/components/PieChart.js +8 -6
- package/lib/components/pieTooltip.js +202 -202
- package/lib/utils/index.js +822 -822
- package/package.json +1 -1
- package/src/components/PieChart.js +36 -9
|
@@ -20,16 +20,16 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
20
20
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21
21
|
var initialState = {
|
|
22
22
|
currentIndex: null,
|
|
23
|
-
trigger:
|
|
23
|
+
trigger: ""
|
|
24
24
|
};
|
|
25
25
|
var carouselState = {
|
|
26
26
|
currentIndex: 0,
|
|
27
|
-
trigger:
|
|
27
|
+
trigger: "carousel"
|
|
28
28
|
};
|
|
29
29
|
var defaultAnimation = {
|
|
30
30
|
on: false,
|
|
31
31
|
interval: 0,
|
|
32
|
-
interactive:
|
|
32
|
+
interactive: "",
|
|
33
33
|
canCancel: false,
|
|
34
34
|
current: {
|
|
35
35
|
heighten: 0,
|
|
@@ -62,11 +62,20 @@ var _default = exports["default"] = function _default(Component) {
|
|
|
62
62
|
var timer = (0, _react.useRef)(null);
|
|
63
63
|
var hoverState = (0, _react.useRef)(false);
|
|
64
64
|
var animationOn = on && interval && dataLength;
|
|
65
|
+
// 封装计时器停止逻辑
|
|
66
|
+
var stopTimer = (0, _react.useCallback)(function () {
|
|
67
|
+
if (timer.current) {
|
|
68
|
+
timer.current.stop();
|
|
69
|
+
timer.current = null;
|
|
70
|
+
}
|
|
71
|
+
}, []);
|
|
65
72
|
var carousel = (0, _react.useCallback)(function () {
|
|
73
|
+
// 先停止之前的计时器
|
|
74
|
+
stopTimer();
|
|
66
75
|
if (animationOn) {
|
|
67
76
|
setState({
|
|
68
77
|
currentIndex: 0,
|
|
69
|
-
trigger:
|
|
78
|
+
trigger: "carousel"
|
|
70
79
|
});
|
|
71
80
|
timer.current = (0, _d3v.interval)(function () {
|
|
72
81
|
setState(function (_ref2) {
|
|
@@ -74,7 +83,7 @@ var _default = exports["default"] = function _default(Component) {
|
|
|
74
83
|
var tmp = (currentIndex == null ? 0 : +currentIndex) + 1;
|
|
75
84
|
return {
|
|
76
85
|
currentIndex: tmp >= dataLength ? 0 : tmp,
|
|
77
|
-
trigger:
|
|
86
|
+
trigger: "carousel"
|
|
78
87
|
};
|
|
79
88
|
});
|
|
80
89
|
}, interval * 1000);
|
|
@@ -82,24 +91,24 @@ var _default = exports["default"] = function _default(Component) {
|
|
|
82
91
|
timer.current = null;
|
|
83
92
|
setState({
|
|
84
93
|
currentIndex: null,
|
|
85
|
-
trigger:
|
|
94
|
+
trigger: ""
|
|
86
95
|
});
|
|
87
96
|
}
|
|
88
97
|
}, [animationOn, interval, dataLength]);
|
|
89
98
|
(0, _react.useEffect)(function () {
|
|
90
99
|
active && carousel && carousel();
|
|
91
100
|
return function () {
|
|
92
|
-
|
|
101
|
+
stopTimer();
|
|
93
102
|
};
|
|
94
|
-
}, [carousel, active]);
|
|
103
|
+
}, [carousel, active, stopTimer]);
|
|
95
104
|
var onEvent = (0, _react.useCallback)(function (_ref3) {
|
|
96
105
|
var currentIndex = _ref3.currentIndex,
|
|
97
106
|
type = _ref3.type;
|
|
98
107
|
switch (interactive) {
|
|
99
108
|
case true:
|
|
100
|
-
case
|
|
101
|
-
if (type ==
|
|
102
|
-
|
|
109
|
+
case "click":
|
|
110
|
+
if (type == "onClick") {
|
|
111
|
+
stopTimer();
|
|
103
112
|
!hoverState.current && animationOn && carousel();
|
|
104
113
|
setState(function (pre) {
|
|
105
114
|
return {
|
|
@@ -109,14 +118,14 @@ var _default = exports["default"] = function _default(Component) {
|
|
|
109
118
|
});
|
|
110
119
|
}
|
|
111
120
|
break;
|
|
112
|
-
case
|
|
113
|
-
if (type ==
|
|
121
|
+
case "hover":
|
|
122
|
+
if (type == "onMouseEnter") {
|
|
114
123
|
setState({
|
|
115
124
|
trigger: type,
|
|
116
125
|
currentIndex: currentIndex
|
|
117
126
|
});
|
|
118
|
-
|
|
119
|
-
} else if (type ==
|
|
127
|
+
stopTimer();
|
|
128
|
+
} else if (type == "onMouseLeave") {
|
|
120
129
|
!hoverState.current && animationOn && carousel();
|
|
121
130
|
canCancel && setState(function (pre) {
|
|
122
131
|
return {
|
|
@@ -127,9 +136,9 @@ var _default = exports["default"] = function _default(Component) {
|
|
|
127
136
|
}
|
|
128
137
|
break;
|
|
129
138
|
case false:
|
|
130
|
-
case
|
|
139
|
+
case "":
|
|
131
140
|
break;
|
|
132
|
-
case
|
|
141
|
+
case "carousel":
|
|
133
142
|
default:
|
|
134
143
|
setState({
|
|
135
144
|
trigger: type,
|
|
@@ -137,29 +146,30 @@ var _default = exports["default"] = function _default(Component) {
|
|
|
137
146
|
});
|
|
138
147
|
break;
|
|
139
148
|
}
|
|
140
|
-
}, [interactive, canCancel, animationOn, carousel]);
|
|
149
|
+
}, [interactive, canCancel, animationOn, carousel, stopTimer]);
|
|
141
150
|
var hoverEvent = (0, _react.useCallback)(function (isHover) {
|
|
142
151
|
if (hoverStop) {
|
|
143
152
|
if (isHover) {
|
|
144
153
|
hoverState.current = true;
|
|
145
|
-
|
|
154
|
+
stopTimer();
|
|
146
155
|
} else {
|
|
147
156
|
hoverState.current = false;
|
|
148
157
|
if (animationOn) {
|
|
158
|
+
stopTimer();
|
|
149
159
|
timer.current = (0, _d3v.interval)(function () {
|
|
150
160
|
setState(function (_ref4) {
|
|
151
161
|
var currentIndex = _ref4.currentIndex;
|
|
152
162
|
var tmp = (currentIndex == null ? 0 : +currentIndex) + 1;
|
|
153
163
|
return {
|
|
154
164
|
currentIndex: tmp >= dataLength ? 0 : tmp,
|
|
155
|
-
trigger:
|
|
165
|
+
trigger: "carousel"
|
|
156
166
|
};
|
|
157
167
|
});
|
|
158
168
|
}, interval * 1000);
|
|
159
169
|
}
|
|
160
170
|
}
|
|
161
171
|
}
|
|
162
|
-
}, [hoverStop, animationOn,
|
|
172
|
+
}, [hoverStop, animationOn, interval, dataLength, stopTimer]);
|
|
163
173
|
return /*#__PURE__*/_react["default"].createElement(Component, (0, _extends2["default"])({}, rest, {
|
|
164
174
|
state: state,
|
|
165
175
|
onEvent: onEvent,
|