@easyv/charts 1.3.30 → 1.3.32
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/Carousel.js +29 -15
- package/lib/components/Lighter.js +6 -2
- package/lib/components/PieChart.js +8 -1
- package/lib/element/ConicGradient.js +5 -1
- package/lib/hooks/useExtentData.js +1 -1
- package/package.json +2 -2
- package/src/components/Carousel.tsx +33 -19
- package/src/components/ChartContainer.tsx +19 -18
- package/src/components/PieChart.js +3 -1
- package/src/hooks/useExtentData.js +1 -1
|
@@ -67,7 +67,8 @@ var _default = function _default(Component) {
|
|
|
67
67
|
|
|
68
68
|
var on = _animation.on,
|
|
69
69
|
interval = _animation.interval,
|
|
70
|
-
interactive = _animation.interactive
|
|
70
|
+
interactive = _animation.interactive,
|
|
71
|
+
hoverStop = _animation.hoverStop;
|
|
71
72
|
|
|
72
73
|
var _useState = (0, _react.useState)(on ? carouselState : initialState),
|
|
73
74
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
@@ -75,6 +76,7 @@ var _default = function _default(Component) {
|
|
|
75
76
|
setState = _useState2[1];
|
|
76
77
|
|
|
77
78
|
var timer = (0, _react.useRef)(null);
|
|
79
|
+
var hoverState = (0, _react.useRef)(false);
|
|
78
80
|
var animationOn = on && interval && dataLength;
|
|
79
81
|
var carousel = (0, _react.useCallback)(function () {
|
|
80
82
|
if (animationOn) {
|
|
@@ -115,7 +117,7 @@ var _default = function _default(Component) {
|
|
|
115
117
|
case 'click':
|
|
116
118
|
if (type == 'onClick') {
|
|
117
119
|
timer.current && timer.current.stop();
|
|
118
|
-
animationOn && carousel();
|
|
120
|
+
!hoverState.current && animationOn && carousel();
|
|
119
121
|
setState({
|
|
120
122
|
trigger: type,
|
|
121
123
|
currentIndex: currentIndex
|
|
@@ -132,7 +134,7 @@ var _default = function _default(Component) {
|
|
|
132
134
|
});
|
|
133
135
|
timer.current && timer.current.stop();
|
|
134
136
|
} else if (type == 'onMouseLeave') {
|
|
135
|
-
animationOn && carousel();
|
|
137
|
+
!hoverState.current && animationOn && carousel();
|
|
136
138
|
}
|
|
137
139
|
|
|
138
140
|
break;
|
|
@@ -150,21 +152,33 @@ var _default = function _default(Component) {
|
|
|
150
152
|
break;
|
|
151
153
|
}
|
|
152
154
|
}, [interactive, animationOn, carousel]);
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
155
|
+
var hoverEvent = (0, _react.useCallback)(function (isHover) {
|
|
156
|
+
if (hoverStop) {
|
|
157
|
+
if (isHover) {
|
|
158
|
+
hoverState.current = true;
|
|
159
|
+
timer.current && timer.current.stop();
|
|
160
|
+
} else {
|
|
161
|
+
hoverState.current = false;
|
|
162
|
+
|
|
163
|
+
if (animationOn) {
|
|
164
|
+
timer.current = (0, _d3v.interval)(function () {
|
|
165
|
+
setState(function (_ref4) {
|
|
166
|
+
var currentIndex = _ref4.currentIndex;
|
|
167
|
+
var tmp = (currentIndex == null ? 0 : +currentIndex) + 1;
|
|
168
|
+
return {
|
|
169
|
+
currentIndex: tmp >= dataLength ? 0 : tmp,
|
|
170
|
+
trigger: 'carousel'
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
}, interval * 1000);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}, [hoverStop, animationOn, carousel]);
|
|
165
178
|
return /*#__PURE__*/_react["default"].createElement(Component, (0, _extends2["default"])({}, rest, {
|
|
166
179
|
state: state,
|
|
167
180
|
onEvent: onEvent,
|
|
181
|
+
hoverEvent: hoverEvent,
|
|
168
182
|
config: _objectSpread(_objectSpread({}, config), {}, {
|
|
169
183
|
animation: _animation
|
|
170
184
|
}),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
-
|
|
5
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
@@ -21,6 +21,10 @@ var _utils = require("../utils");
|
|
|
21
21
|
|
|
22
22
|
var _svgPathProperties = require("svg-path-properties");
|
|
23
23
|
|
|
24
|
+
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); }
|
|
25
|
+
|
|
26
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
|
+
|
|
24
28
|
/**
|
|
25
29
|
* 区域图发光跟踪路径
|
|
26
30
|
*/
|
|
@@ -323,6 +323,7 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
323
323
|
currentIndex = _ref5$state.currentIndex,
|
|
324
324
|
trigger = _ref5$state.trigger,
|
|
325
325
|
onEvent = _ref5.onEvent,
|
|
326
|
+
hoverEvent = _ref5.hoverEvent,
|
|
326
327
|
_ref5$data = _ref5.data,
|
|
327
328
|
originData = _ref5$data === void 0 ? [] : _ref5$data;
|
|
328
329
|
var data = originData.map(function (d) {
|
|
@@ -597,7 +598,13 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
597
598
|
width: width,
|
|
598
599
|
height: height,
|
|
599
600
|
marginLeft: marginLeft,
|
|
600
|
-
marginTop: marginTop
|
|
601
|
+
marginTop: marginTop,
|
|
602
|
+
onMouseEnter: function onMouseEnter() {
|
|
603
|
+
hoverEvent(true);
|
|
604
|
+
},
|
|
605
|
+
onMouseLeave: function onMouseLeave() {
|
|
606
|
+
hoverEvent(false);
|
|
607
|
+
}
|
|
601
608
|
}, /*#__PURE__*/_react["default"].createElement("g", {
|
|
602
609
|
style: {
|
|
603
610
|
transition: 'transform ease-in-out 0.3s',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -9,6 +9,10 @@ exports["default"] = ConicGradient;
|
|
|
9
9
|
|
|
10
10
|
var d3 = _interopRequireWildcard(require("d3"));
|
|
11
11
|
|
|
12
|
+
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); }
|
|
13
|
+
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
|
|
12
16
|
//只支持在svg中使用
|
|
13
17
|
//在<clipPath>标签中绘制圆环路径,在<foreignObject>中使用conic-gradient来制作角向渐变
|
|
14
18
|
//然后在foreignObject中调用clipPath来剪切dom元素,实现环形渐变效果
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easyv/charts",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.32",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"make": "babel src -d lib --extensions .ts,.tsx,.js && cp -r src/css lib",
|
|
7
|
+
"make": "babel src -d lib --extensions .ts,.tsx,.js,.jsx && cp -r src/css lib",
|
|
8
8
|
"prepare": "husky install"
|
|
9
9
|
},
|
|
10
10
|
"keywords": [],
|
|
@@ -44,13 +44,12 @@ export default (Component: ComponentType<any>) =>
|
|
|
44
44
|
}) => {
|
|
45
45
|
const dataLength = data.length;
|
|
46
46
|
const _animation = Object.assign({}, defaultAnimation, animation);
|
|
47
|
-
const { on, interval, interactive } = _animation;
|
|
48
|
-
|
|
47
|
+
const { on, interval, interactive, hoverStop } = _animation;
|
|
49
48
|
const [state, setState] = useState<State>(
|
|
50
49
|
on ? carouselState : initialState
|
|
51
50
|
);
|
|
52
51
|
const timer: { current: Timer | null } = useRef(null);
|
|
53
|
-
|
|
52
|
+
const hoverState = useRef(false);
|
|
54
53
|
const animationOn = on && interval && dataLength;
|
|
55
54
|
|
|
56
55
|
const carousel = useCallback(() => {
|
|
@@ -83,15 +82,18 @@ export default (Component: ComponentType<any>) =>
|
|
|
83
82
|
timer.current && timer.current.stop();
|
|
84
83
|
};
|
|
85
84
|
}, [carousel]);
|
|
86
|
-
|
|
85
|
+
interface Event{
|
|
86
|
+
currentIndex:number,
|
|
87
|
+
type:string
|
|
88
|
+
}
|
|
87
89
|
const onEvent = useCallback(
|
|
88
|
-
({ currentIndex, type }) => {
|
|
90
|
+
({ currentIndex, type }:Event) => {
|
|
89
91
|
switch (interactive) {
|
|
90
92
|
case true:
|
|
91
93
|
case 'click':
|
|
92
94
|
if (type == 'onClick') {
|
|
93
95
|
timer.current && timer.current.stop();
|
|
94
|
-
animationOn && carousel();
|
|
96
|
+
!hoverState.current && animationOn && carousel();
|
|
95
97
|
setState({
|
|
96
98
|
trigger: type,
|
|
97
99
|
currentIndex,
|
|
@@ -101,12 +103,12 @@ export default (Component: ComponentType<any>) =>
|
|
|
101
103
|
case 'hover':
|
|
102
104
|
if (type == 'onMouseEnter') {
|
|
103
105
|
setState({
|
|
104
|
-
trigger:
|
|
106
|
+
trigger:type,
|
|
105
107
|
currentIndex,
|
|
106
108
|
});
|
|
107
109
|
timer.current && timer.current.stop();
|
|
108
110
|
} else if (type == 'onMouseLeave') {
|
|
109
|
-
animationOn && carousel();
|
|
111
|
+
!hoverState.current && animationOn && carousel();
|
|
110
112
|
}
|
|
111
113
|
break;
|
|
112
114
|
case false:
|
|
@@ -123,23 +125,35 @@ export default (Component: ComponentType<any>) =>
|
|
|
123
125
|
},
|
|
124
126
|
[interactive, animationOn, carousel]
|
|
125
127
|
);
|
|
128
|
+
|
|
129
|
+
const hoverEvent = useCallback((isHover:boolean)=>{
|
|
130
|
+
if(hoverStop){
|
|
131
|
+
if(isHover){
|
|
132
|
+
hoverState.current = true;
|
|
133
|
+
timer.current && timer.current.stop();
|
|
134
|
+
}else{
|
|
135
|
+
hoverState.current = false;
|
|
136
|
+
if(animationOn){
|
|
137
|
+
timer.current = d3Interval(() => {
|
|
138
|
+
setState(({ currentIndex }) => {
|
|
139
|
+
const tmp = (currentIndex == null ? 0 : +currentIndex) + 1;
|
|
140
|
+
return {
|
|
141
|
+
currentIndex: tmp >= dataLength ? 0 : tmp,
|
|
142
|
+
trigger: 'carousel',
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
}, interval * 1000);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},[hoverStop, animationOn, carousel]);
|
|
126
150
|
|
|
127
|
-
if (!animationOn) {
|
|
128
|
-
return (
|
|
129
|
-
<Component
|
|
130
|
-
{...rest}
|
|
131
|
-
state={state}
|
|
132
|
-
onEvent={onEvent}
|
|
133
|
-
config={{ ...config, animation: _animation }}
|
|
134
|
-
data={data}
|
|
135
|
-
/>
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
151
|
return (
|
|
139
152
|
<Component
|
|
140
153
|
{...rest}
|
|
141
154
|
state={state}
|
|
142
155
|
onEvent={onEvent}
|
|
156
|
+
hoverEvent={hoverEvent}
|
|
143
157
|
config={{ ...config, animation: _animation }}
|
|
144
158
|
data={data}
|
|
145
159
|
/>
|
|
@@ -41,23 +41,24 @@ export default memo(
|
|
|
41
41
|
onMouseOut = event,
|
|
42
42
|
}: Props,
|
|
43
43
|
ref: LegacyRef<SVGSVGElement>
|
|
44
|
-
) =>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
44
|
+
) =>
|
|
45
|
+
{
|
|
46
|
+
return <svg
|
|
47
|
+
className='__easyv-svg'
|
|
48
|
+
width={width}
|
|
49
|
+
height={height}
|
|
50
|
+
onMouseEnter={onMouseEnter}
|
|
51
|
+
onMouseLeave={onMouseLeave}
|
|
52
|
+
onMouseOut={onMouseOut}
|
|
53
|
+
onClick={onClick}
|
|
54
|
+
onMouseMove={onMouseMove}
|
|
55
|
+
ref={ref}
|
|
56
|
+
style={{ position: 'absolute', width, height, ...style }}
|
|
57
|
+
>
|
|
58
|
+
<g transform={'translate(' + marginLeft + ', ' + marginTop + ')'}>
|
|
59
|
+
{children}
|
|
60
|
+
</g>
|
|
61
|
+
</svg>
|
|
62
|
+
}
|
|
62
63
|
)
|
|
63
64
|
);
|
|
@@ -269,9 +269,9 @@ const Component = memo(
|
|
|
269
269
|
},
|
|
270
270
|
state: { currentIndex, trigger },
|
|
271
271
|
onEvent,
|
|
272
|
+
hoverEvent,
|
|
272
273
|
data:originData = [],
|
|
273
274
|
}) => {
|
|
274
|
-
|
|
275
275
|
const data =originData.map(d=>({...d,y:d.y<0?0:d.y}));
|
|
276
276
|
const prevIndex = useRef(null);
|
|
277
277
|
const { precision: legendPrecision } = legend.config.percent;
|
|
@@ -553,6 +553,8 @@ const Component = memo(
|
|
|
553
553
|
height={height}
|
|
554
554
|
marginLeft={marginLeft}
|
|
555
555
|
marginTop={marginTop}
|
|
556
|
+
onMouseEnter={()=>{hoverEvent(true)}}
|
|
557
|
+
onMouseLeave={()=>{hoverEvent(false)}}
|
|
556
558
|
>
|
|
557
559
|
<g
|
|
558
560
|
style={{
|