@easyv/charts 1.9.23 → 1.9.24
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.
|
@@ -29,7 +29,9 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
|
|
|
29
29
|
height = _props$props$control.height,
|
|
30
30
|
color = _props$props$control.color,
|
|
31
31
|
gap = _props$props$control.gap,
|
|
32
|
-
|
|
32
|
+
_props$props$control$ = _props$props$control.drag,
|
|
33
|
+
dragColor = _props$props$control$.color,
|
|
34
|
+
enableStretch = _props$props$control$.enableStretch,
|
|
33
35
|
left = _props$props$control.margin.left,
|
|
34
36
|
_props$props$controlI = _props$props.controlInfo,
|
|
35
37
|
cWidth = _props$props$controlI.cWidth,
|
|
@@ -60,13 +62,14 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
|
|
|
60
62
|
width: 12,
|
|
61
63
|
height: height,
|
|
62
64
|
padding: "0 5px",
|
|
63
|
-
cursor: "col-resize",
|
|
65
|
+
cursor: enableStretch ? "col-resize" : "auto",
|
|
64
66
|
background: "rgb(2, 176, 249)",
|
|
65
67
|
WebkitBackgroundClip: "content-box"
|
|
66
68
|
};
|
|
67
69
|
|
|
68
70
|
//左手柄的鼠标按下逻辑
|
|
69
71
|
var leftDown = function leftDown() {
|
|
72
|
+
if (!enableStretch) return;
|
|
70
73
|
var transform = ref.current.style.transform;
|
|
71
74
|
var initX = 0;
|
|
72
75
|
var rawTranslateX = parseFloat(transform ? transform.match(/\d+\.*\d*/)[0] : 0);
|
|
@@ -95,6 +98,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
|
|
|
95
98
|
};
|
|
96
99
|
//左手手柄的移动端适配
|
|
97
100
|
var leftTouchStart = function leftTouchStart(e) {
|
|
101
|
+
if (!enableStretch) return;
|
|
98
102
|
var transform = ref.current.style.transform;
|
|
99
103
|
var rawTranslateX = parseFloat(transform ? transform.match(/\d+\.*\d*/)[0] : 0);
|
|
100
104
|
var initX = 0;
|
|
@@ -174,6 +178,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
|
|
|
174
178
|
};
|
|
175
179
|
//右手柄的鼠标按下逻辑
|
|
176
180
|
var rightDown = function rightDown() {
|
|
181
|
+
if (!enableStretch) return;
|
|
177
182
|
var transform = ref.current.style.transform;
|
|
178
183
|
var rawTranslateX = parseFloat(transform ? transform.match(/\d+\.*\d*/)[0] : 0);
|
|
179
184
|
var move = function move(e) {
|
|
@@ -199,6 +204,7 @@ var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(
|
|
|
199
204
|
};
|
|
200
205
|
//右手手柄的移动端适配
|
|
201
206
|
var rightTouchStart = function rightTouchStart(e) {
|
|
207
|
+
if (!enableStretch) return;
|
|
202
208
|
var transform = ref.current.style.transform;
|
|
203
209
|
var startX = e.touches[0].clientX;
|
|
204
210
|
var currentX = 0;
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easyv/charts",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.24",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"make": "babel src -d lib --extensions .ts,.tsx,.js,.jsx && cp -r src/css lib",
|
|
8
|
+
"watch": "cp -r src/css lib && babel --watch src -d lib --extensions .ts,.tsx,.js,.jsx",
|
|
8
9
|
"prepare": "husky install"
|
|
9
10
|
},
|
|
10
11
|
"keywords": [],
|
|
@@ -54,4 +55,4 @@
|
|
|
54
55
|
"commit": true
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
|
-
}
|
|
58
|
+
}
|
|
@@ -348,9 +348,8 @@ const Chart = memo(
|
|
|
348
348
|
setClipX(-translateX);
|
|
349
349
|
const isVertical = axisX.direction === "vertical";
|
|
350
350
|
const coreOffset = isVertical ? marginRight : isIOS ? marginLeft : 0;
|
|
351
|
-
seriesEl.current.style.transform = `translate(${
|
|
352
|
-
|
|
353
|
-
}px,${marginTop}px)`;
|
|
351
|
+
seriesEl.current.style.transform = `translate(${translateX + coreOffset
|
|
352
|
+
}px,${marginTop}px)`;
|
|
354
353
|
axisElList.current[2].style.transform = `translate(${translateX}px,${0}px)`;
|
|
355
354
|
}
|
|
356
355
|
}, [controlInfo]);
|
|
@@ -459,8 +458,8 @@ const Chart = memo(
|
|
|
459
458
|
const controlChartTooltipData =
|
|
460
459
|
ctlXName && originData.filter((d) => d.x === ctlXName);
|
|
461
460
|
const bodyWidth = isVertical
|
|
462
|
-
|
|
463
|
-
|
|
461
|
+
? xLineRange + 100 + marginRight + marginLeft
|
|
462
|
+
: xLineRange,
|
|
464
463
|
bodyHeight = isVertical
|
|
465
464
|
? yLineRange
|
|
466
465
|
: yLineRange + marginTop + marginBottom;
|
|
@@ -725,7 +724,7 @@ const Chart = memo(
|
|
|
725
724
|
ctlX -
|
|
726
725
|
marginLeft -
|
|
727
726
|
(axisX.controlEnd + axisX.start / cPercent - chartWidth) *
|
|
728
|
-
|
|
727
|
+
curControlPercent.current
|
|
729
728
|
}
|
|
730
729
|
marginLeft={marginLeft}
|
|
731
730
|
marginTop={marginTop}
|
|
@@ -13,7 +13,7 @@ export default memo(
|
|
|
13
13
|
height,
|
|
14
14
|
color,
|
|
15
15
|
gap,
|
|
16
|
-
drag: { color: dragColor },
|
|
16
|
+
drag: { color: dragColor, enableStretch },
|
|
17
17
|
margin: { left },
|
|
18
18
|
},
|
|
19
19
|
controlInfo: { cWidth, cBarWidth },
|
|
@@ -46,17 +46,19 @@ export default memo(
|
|
|
46
46
|
width: 12,
|
|
47
47
|
height,
|
|
48
48
|
padding: "0 5px",
|
|
49
|
-
cursor: "col-resize",
|
|
49
|
+
cursor: enableStretch ? "col-resize" : "auto",
|
|
50
50
|
background: "rgb(2, 176, 249)",
|
|
51
|
-
WebkitBackgroundClip: "content-box"
|
|
51
|
+
WebkitBackgroundClip: "content-box"
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
//左手柄的鼠标按下逻辑
|
|
55
55
|
const leftDown = () => {
|
|
56
|
+
if (!enableStretch) return;
|
|
57
|
+
|
|
56
58
|
const transform = ref.current.style.transform;
|
|
57
59
|
let initX = 0;
|
|
58
60
|
let rawTranslateX = parseFloat(
|
|
59
|
-
transform ? transform.match(/\d+\.*\d*/)[0] : 0
|
|
61
|
+
transform ? transform.match(/\d+\.*\d*/)[0] : 0,
|
|
60
62
|
);
|
|
61
63
|
const rightX = rawTranslateX + cBarWidth;
|
|
62
64
|
const move = (e) => {
|
|
@@ -86,9 +88,11 @@ export default memo(
|
|
|
86
88
|
};
|
|
87
89
|
//左手手柄的移动端适配
|
|
88
90
|
const leftTouchStart = (e) => {
|
|
91
|
+
if (!enableStretch) return;
|
|
92
|
+
|
|
89
93
|
const transform = ref.current.style.transform;
|
|
90
94
|
let rawTranslateX = parseFloat(
|
|
91
|
-
transform ? transform.match(/\d+\.*\d*/)[0] : 0
|
|
95
|
+
transform ? transform.match(/\d+\.*\d*/)[0] : 0,
|
|
92
96
|
);
|
|
93
97
|
let initX = 0;
|
|
94
98
|
const rightX = rawTranslateX + cBarWidth;
|
|
@@ -127,7 +131,7 @@ export default memo(
|
|
|
127
131
|
const transform = ref.current.style.transform;
|
|
128
132
|
let movementX = 0;
|
|
129
133
|
let rawTranslateX = parseFloat(
|
|
130
|
-
transform ? transform.match(/\d+\.*\d*/)[0] : 0
|
|
134
|
+
transform ? transform.match(/\d+\.*\d*/)[0] : 0,
|
|
131
135
|
);
|
|
132
136
|
const mouseMoveHandle = (e) => {
|
|
133
137
|
//当前位移的距离
|
|
@@ -150,7 +154,7 @@ export default memo(
|
|
|
150
154
|
let currentX = 0;
|
|
151
155
|
let movementX = 0;
|
|
152
156
|
let rawTranslateX = parseFloat(
|
|
153
|
-
transform ? transform.match(/\d+\.*\d*/)[0] : 0
|
|
157
|
+
transform ? transform.match(/\d+\.*\d*/)[0] : 0,
|
|
154
158
|
);
|
|
155
159
|
const mouseMoveHandle = (e) => {
|
|
156
160
|
e.preventDefault();
|
|
@@ -172,9 +176,11 @@ export default memo(
|
|
|
172
176
|
};
|
|
173
177
|
//右手柄的鼠标按下逻辑
|
|
174
178
|
const rightDown = () => {
|
|
179
|
+
if (!enableStretch) return;
|
|
180
|
+
|
|
175
181
|
const transform = ref.current.style.transform;
|
|
176
182
|
let rawTranslateX = parseFloat(
|
|
177
|
-
transform ? transform.match(/\d+\.*\d*/)[0] : 0
|
|
183
|
+
transform ? transform.match(/\d+\.*\d*/)[0] : 0,
|
|
178
184
|
);
|
|
179
185
|
const move = (e) => {
|
|
180
186
|
const { movementX: ex } = e;
|
|
@@ -199,12 +205,14 @@ export default memo(
|
|
|
199
205
|
};
|
|
200
206
|
//右手手柄的移动端适配
|
|
201
207
|
const rightTouchStart = (e) => {
|
|
208
|
+
if (!enableStretch) return;
|
|
209
|
+
|
|
202
210
|
const transform = ref.current.style.transform;
|
|
203
211
|
let startX = e.touches[0].clientX;
|
|
204
212
|
let currentX = 0;
|
|
205
213
|
let movementX = 0;
|
|
206
214
|
let rawTranslateX = parseFloat(
|
|
207
|
-
transform ? transform.match(/\d+\.*\d*/)[0] : 0
|
|
215
|
+
transform ? transform.match(/\d+\.*\d*/)[0] : 0,
|
|
208
216
|
);
|
|
209
217
|
const move = (e) => {
|
|
210
218
|
e.preventDefault();
|
|
@@ -229,6 +237,7 @@ export default memo(
|
|
|
229
237
|
document.addEventListener("touchmove", move, { passive: false });
|
|
230
238
|
document.addEventListener("touchend", up);
|
|
231
239
|
};
|
|
240
|
+
|
|
232
241
|
return (
|
|
233
242
|
<div
|
|
234
243
|
style={{
|
|
@@ -265,6 +274,7 @@ export default memo(
|
|
|
265
274
|
);
|
|
266
275
|
})}
|
|
267
276
|
</svg>
|
|
277
|
+
|
|
268
278
|
{/* 控制条 */}
|
|
269
279
|
<div ref={ref} style={barStyle}>
|
|
270
280
|
<div
|
|
@@ -286,5 +296,5 @@ export default memo(
|
|
|
286
296
|
</div>
|
|
287
297
|
</div>
|
|
288
298
|
);
|
|
289
|
-
})
|
|
299
|
+
}),
|
|
290
300
|
);
|