@easyv/charts 1.9.9 → 1.9.10
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 +10 -2
- package/package.json +4 -2
- package/src/components/Band.tsx +23 -12
package/lib/components/Band.js
CHANGED
|
@@ -13,6 +13,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
13
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
14
|
var _d3v = require("d3v7");
|
|
15
15
|
var _utils = require("../utils");
|
|
16
|
+
var _lodash = require("lodash");
|
|
16
17
|
var _excluded = ["show", "extent"],
|
|
17
18
|
_excluded2 = ["pattern", "seriesIntervalWidth", "paddingInner", "highlight"],
|
|
18
19
|
_excluded3 = ["bgAttr"];
|
|
@@ -154,6 +155,13 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
154
155
|
seriesStart = _getSeriesInfo.seriesStart;
|
|
155
156
|
var _data = showHighlight ? getHighlightData(data, extent) : data;
|
|
156
157
|
var isVertical = direction === "vertical";
|
|
158
|
+
var handleMouseMove = (0, _react.useCallback)((0, _lodash.throttle)(function (e) {
|
|
159
|
+
if (triggerEvents) {
|
|
160
|
+
triggerEvents(e, "setCurrent");
|
|
161
|
+
}
|
|
162
|
+
}, 100),
|
|
163
|
+
// 每 100ms 最多执行一次
|
|
164
|
+
[triggerEvents]);
|
|
157
165
|
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
158
166
|
className: "__easyv-band"
|
|
159
167
|
}, _data.map(function (_ref4, i) {
|
|
@@ -243,10 +251,10 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(function (_ref
|
|
|
243
251
|
}
|
|
244
252
|
}, bgAttr, {
|
|
245
253
|
onClick: function onClick(e) {
|
|
246
|
-
|
|
254
|
+
triggerEvents ? triggerEvents(e, "setCurrent") : "";
|
|
247
255
|
},
|
|
248
256
|
onMouseMove: function onMouseMove(e) {
|
|
249
|
-
|
|
257
|
+
triggerEvents ? handleMouseMove : "";
|
|
250
258
|
},
|
|
251
259
|
onMouseEnter: function onMouseEnter() {
|
|
252
260
|
if (isControlChart) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easyv/charts",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"@commitlint/cli": "^17.6.7",
|
|
23
23
|
"@commitlint/config-conventional": "^16.2.4",
|
|
24
24
|
"@types/d3": "^7.0.0",
|
|
25
|
+
"@types/lodash": "^4.17.21",
|
|
25
26
|
"@types/react": "^18.0.12",
|
|
26
27
|
"@types/react-dom": "^18.0.5",
|
|
27
28
|
"babel-plugin-transform-import-styles": "^0.0.11",
|
|
@@ -35,6 +36,7 @@
|
|
|
35
36
|
"@easyv/utils": "^0.0.50",
|
|
36
37
|
"d3v7": "npm:d3@^7.0.0",
|
|
37
38
|
"gitignore": "^0.7.0",
|
|
39
|
+
"lodash": "^4.17.21",
|
|
38
40
|
"mrm": "^4.0.0",
|
|
39
41
|
"popmotion": "^9.3.6",
|
|
40
42
|
"react": "^17.0.2",
|
|
@@ -52,4 +54,4 @@
|
|
|
52
54
|
"commit": true
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
|
-
}
|
|
57
|
+
}
|
package/src/components/Band.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* (柱状/条形)图柱子
|
|
3
3
|
*/
|
|
4
|
-
import React, { memo, Fragment } from "react";
|
|
4
|
+
import React, { memo, Fragment, useCallback } from "react";
|
|
5
5
|
import { min, max } from "d3v7";
|
|
6
6
|
import { getBandBackground, getMultiColorStr, getSeriesInfo } from "../utils";
|
|
7
|
-
|
|
7
|
+
import { throttle } from "lodash";
|
|
8
8
|
const getHighlightData = (data: Array<DataWithBoundType>, extent: string) => {
|
|
9
9
|
switch (extent) {
|
|
10
10
|
case "min":
|
|
@@ -40,15 +40,15 @@ const getAttr = ({
|
|
|
40
40
|
const len = length ? length : 0.1; //柱子长度
|
|
41
41
|
if (isVertical) {
|
|
42
42
|
return {
|
|
43
|
-
width: Math.max(0,len),
|
|
44
|
-
height: Math.max(0,seriesWidth),
|
|
43
|
+
width: Math.max(0, len),
|
|
44
|
+
height: Math.max(0, seriesWidth),
|
|
45
45
|
x: y,
|
|
46
46
|
y: x,
|
|
47
47
|
bgAttr: {
|
|
48
48
|
x: 0,
|
|
49
49
|
y: x,
|
|
50
|
-
width: Math.max(0,len + x),
|
|
51
|
-
height: Math.max(0,seriesWidth),
|
|
50
|
+
width: Math.max(0, len + x),
|
|
51
|
+
height: Math.max(0, seriesWidth),
|
|
52
52
|
},
|
|
53
53
|
};
|
|
54
54
|
} else {
|
|
@@ -60,8 +60,8 @@ const getAttr = ({
|
|
|
60
60
|
bgAttr: {
|
|
61
61
|
x,
|
|
62
62
|
y: 0,
|
|
63
|
-
width: Math.max(0,seriesWidth),
|
|
64
|
-
height: Math.max(0,y + len),
|
|
63
|
+
width: Math.max(0, seriesWidth),
|
|
64
|
+
height: Math.max(0, y + len),
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
67
|
}
|
|
@@ -136,7 +136,14 @@ export default memo(
|
|
|
136
136
|
});
|
|
137
137
|
const _data = showHighlight ? getHighlightData(data, extent) : data;
|
|
138
138
|
const isVertical = direction === "vertical";
|
|
139
|
-
|
|
139
|
+
const handleMouseMove = useCallback(
|
|
140
|
+
throttle((e) => {
|
|
141
|
+
if (triggerEvents) {
|
|
142
|
+
triggerEvents(e, "setCurrent");
|
|
143
|
+
}
|
|
144
|
+
}, 100), // 每 100ms 最多执行一次
|
|
145
|
+
[triggerEvents]
|
|
146
|
+
);
|
|
140
147
|
return (
|
|
141
148
|
<g className="__easyv-band">
|
|
142
149
|
{_data.map(
|
|
@@ -232,8 +239,12 @@ export default memo(
|
|
|
232
239
|
cursor: "pointer",
|
|
233
240
|
}}
|
|
234
241
|
{...bgAttr}
|
|
235
|
-
onClick={(e) =>
|
|
236
|
-
|
|
242
|
+
onClick={(e) => {
|
|
243
|
+
triggerEvents ? triggerEvents(e, "setCurrent") : "";
|
|
244
|
+
}}
|
|
245
|
+
onMouseMove={(e) => {
|
|
246
|
+
triggerEvents ? handleMouseMove : "";
|
|
247
|
+
}}
|
|
237
248
|
onMouseEnter={() => {
|
|
238
249
|
if (isControlChart) {
|
|
239
250
|
setCtlTip((pre: any) => ({
|
|
@@ -251,7 +262,7 @@ export default memo(
|
|
|
251
262
|
}
|
|
252
263
|
}}
|
|
253
264
|
onMouseLeave={(e) => {
|
|
254
|
-
triggerEvents?triggerEvents(e, "mouseleave"):"";
|
|
265
|
+
triggerEvents ? triggerEvents(e, "mouseleave") : "";
|
|
255
266
|
if (isControlChart && !auto) {
|
|
256
267
|
setCtlTip((pre: any) => ({
|
|
257
268
|
show: false,
|