@easyv/charts 1.4.34 → 1.4.36
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/Axis.js +7 -7
- package/lib/components/Band.js +28 -26
- package/lib/components/CartesianChart.js +208 -175
- package/lib/components/Control.js +78 -30
- package/lib/components/Indicator.js +30 -34
- package/lib/components/Label.js +1 -41
- package/lib/hooks/useAxes.js +43 -12
- package/lib/hooks/useCarouselAxisX.js +15 -16
- package/lib/hooks/useFilterData.js +21 -1
- package/package.json +1 -1
- package/src/components/Axis.tsx +6 -7
- package/src/components/Band.tsx +27 -34
- package/src/components/CartesianChart.js +186 -196
- package/src/components/Control.jsx +87 -43
- package/src/components/Indicator.js +17 -20
- package/src/components/Label.js +1 -34
- package/src/components/Tooltip.js +0 -1
- package/src/hooks/useAxes.js +34 -16
- package/src/hooks/useCarouselAxisX.js +14 -18
- package/src/hooks/useFilterData.js +7 -1
|
@@ -25,8 +25,6 @@ var _context = require("../context");
|
|
|
25
25
|
|
|
26
26
|
var _ = require(".");
|
|
27
27
|
|
|
28
|
-
var _utils = require("../utils");
|
|
29
|
-
|
|
30
28
|
var _excluded = ["Component", "yOrZ"],
|
|
31
29
|
_excluded2 = ["Component", "yOrZ"];
|
|
32
30
|
|
|
@@ -70,8 +68,6 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
70
68
|
_ref$config$tooltip$c3 = _ref$config$tooltip$c2.indicator,
|
|
71
69
|
indicator = _ref$config$tooltip$c3 === void 0 ? {} : _ref$config$tooltip$c3,
|
|
72
70
|
brush = _ref$config.brush,
|
|
73
|
-
_ref$config$isControl = _ref$config.isControlChart,
|
|
74
|
-
isControlChart = _ref$config$isControl === void 0 ? false : _ref$config$isControl,
|
|
75
71
|
_ref$config$control = _ref$config.control,
|
|
76
72
|
control = _ref$config$control === void 0 ? null : _ref$config$control,
|
|
77
73
|
style = _ref.style,
|
|
@@ -86,23 +82,65 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
86
82
|
isHover = _useState2[0],
|
|
87
83
|
setIsHover = _useState2[1];
|
|
88
84
|
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
85
|
+
var chartWidth = context.width,
|
|
86
|
+
chartHeight = context.height,
|
|
87
|
+
triggerOnRelative = context.triggerOnRelative,
|
|
88
|
+
onEmit = context.onEmit;
|
|
89
|
+
var xLineRange = chartWidth;
|
|
90
|
+
var yLineRange = chartHeight; //获取控制条相关的参数
|
|
91
|
+
|
|
92
|
+
var isControl = false;
|
|
93
|
+
var controlWidth = 0;
|
|
94
|
+
var controlBarWidth = 0;
|
|
95
|
+
var dragPercent = 1;
|
|
96
|
+
var controlHeight = 0;
|
|
97
|
+
|
|
98
|
+
if (control) {
|
|
99
|
+
var _height = control.height,
|
|
100
|
+
_control$margin = control.margin,
|
|
101
|
+
left = _control$margin.left,
|
|
102
|
+
right = _control$margin.right,
|
|
103
|
+
dragWidth = control.drag.width;
|
|
104
|
+
isControl = true;
|
|
105
|
+
controlHeight = _height;
|
|
106
|
+
controlWidth = width - left - right;
|
|
107
|
+
dragPercent = dragWidth / 100;
|
|
108
|
+
controlBarWidth = controlWidth * dragPercent;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
var _useState3 = (0, _react.useState)({
|
|
112
|
+
isC: isControl,
|
|
113
|
+
cWidth: controlWidth,
|
|
114
|
+
cHeight: controlHeight,
|
|
115
|
+
cBarWidth: controlBarWidth,
|
|
116
|
+
cPercent: dragPercent
|
|
117
|
+
}),
|
|
118
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
119
|
+
controlInfo = _useState4[0],
|
|
120
|
+
setControlInfo = _useState4[1];
|
|
121
|
+
|
|
122
|
+
var cWidth = controlInfo.cWidth,
|
|
123
|
+
cHeight = controlInfo.cHeight,
|
|
124
|
+
cBarWidth = controlInfo.cBarWidth,
|
|
125
|
+
cPercent = controlInfo.cPercent;
|
|
126
|
+
yLineRange -= cHeight;
|
|
127
|
+
(0, _react.useEffect)(function () {
|
|
128
|
+
setControlInfo({
|
|
129
|
+
isC: isControl,
|
|
130
|
+
cWidth: controlWidth,
|
|
131
|
+
cHeight: controlHeight,
|
|
132
|
+
cBarWidth: controlBarWidth,
|
|
133
|
+
cPercent: dragPercent
|
|
134
|
+
});
|
|
135
|
+
}, [JSON.stringify(control)]);
|
|
95
136
|
var svg = (0, _react.useRef)();
|
|
96
137
|
var axes = (0, _hooks.useAxes)({
|
|
97
138
|
axes: axesConfig,
|
|
98
139
|
context: context,
|
|
99
|
-
|
|
100
|
-
control: control
|
|
140
|
+
controlInfo: controlInfo
|
|
101
141
|
});
|
|
102
142
|
var aiData = aiFormatter ? aiFormatter(originData, axes, series) : (0, _hooks.useAiData)(originData, axes, series);
|
|
103
|
-
var axisX = (0, _hooks.useCarouselAxisX)(axes.get("x"), animation, isHover,
|
|
104
|
-
var xLineRange = width - marginLeft - marginRight;
|
|
105
|
-
var yLineRange = height - marginTop - marginBottom;
|
|
143
|
+
var axisX = (0, _hooks.useCarouselAxisX)(axes.get("x"), animation, isHover, controlInfo);
|
|
106
144
|
(0, _react.useEffect)(function () {
|
|
107
145
|
if (aiData.length) {
|
|
108
146
|
if (!window.aiData) {
|
|
@@ -126,7 +164,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
126
164
|
marginLeft: marginLeft,
|
|
127
165
|
marginTop: marginTop,
|
|
128
166
|
width: chartWidth,
|
|
129
|
-
height:
|
|
167
|
+
height: yLineRange,
|
|
130
168
|
axisX: axisX,
|
|
131
169
|
isHover: isHover,
|
|
132
170
|
config: tooltipConfig
|
|
@@ -142,14 +180,14 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
142
180
|
}, [tickName, originData]);
|
|
143
181
|
var showTooltip = !!(tooltipData && tooltipData.length && (auto || manual));
|
|
144
182
|
var isVertical = axisX.direction === "vertical";
|
|
145
|
-
var indicatorWidth = indicator.width * axisX.step / 100;
|
|
183
|
+
var indicatorWidth = indicator.width * (control ? axisX.controlStep : axisX.step) / 100;
|
|
146
184
|
var position = axisX.scaler(tickName) - indicatorWidth / 2;
|
|
147
185
|
var indicatorAttr = isVertical ? {
|
|
148
186
|
width: chartWidth,
|
|
149
187
|
height: indicatorWidth,
|
|
150
188
|
y: position
|
|
151
189
|
} : {
|
|
152
|
-
height:
|
|
190
|
+
height: yLineRange,
|
|
153
191
|
width: indicatorWidth,
|
|
154
192
|
x: position
|
|
155
193
|
};
|
|
@@ -170,168 +208,167 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
170
208
|
var seriesEl = (0, _react.useRef)(null);
|
|
171
209
|
var axisElList = (0, _react.useRef)([]);
|
|
172
210
|
var curControlPercent = (0, _react.useRef)(0);
|
|
173
|
-
(0, _react.
|
|
174
|
-
if (controlEl.current && isControlChart) {
|
|
175
|
-
var isDragging = false;
|
|
176
|
-
var movementX = 0;
|
|
177
|
-
var rawTranslateX = 0;
|
|
178
|
-
var percent = 0;
|
|
179
|
-
var controlWidth = xLineRange * control.drag.width / 100;
|
|
180
|
-
|
|
181
|
-
var range = function range(num) {
|
|
182
|
-
var _num = num;
|
|
183
|
-
var min = 0;
|
|
184
|
-
var max = xLineRange - controlWidth;
|
|
185
|
-
_num = Math.max(_num, min);
|
|
186
|
-
_num = Math.min(_num, max);
|
|
187
|
-
return _num;
|
|
188
|
-
};
|
|
211
|
+
var controlTimer = (0, _react.useRef)(); //控制条的动画计时器
|
|
189
212
|
|
|
190
|
-
|
|
191
|
-
var moveLen = range(x);
|
|
192
|
-
controlEl.current.style.transform = "translateX(".concat(moveLen, "px)"); //计算出当前位移的百分比
|
|
213
|
+
var ctlBarX = (0, _react.useRef)(0); //控制条的滑块偏移值
|
|
193
214
|
|
|
194
|
-
|
|
195
|
-
curControlPercent.current = percent;
|
|
196
|
-
seriesEl.current.style.transform = "translate(".concat(-(axisX.controlEnd - axisX.end) * percent, "px,").concat(marginTop, "px)");
|
|
197
|
-
axisElList.current[2].style.transform = "translate(".concat(-(axisX.controlEnd - axisX.end) * percent, "px,", 0, "px)");
|
|
198
|
-
};
|
|
215
|
+
var isWorking = (0, _react.useRef)(false); //控制条是否正在进行各种操作
|
|
199
216
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
217
|
+
var range = function range(num) {
|
|
218
|
+
var _num = num;
|
|
219
|
+
var min = 0;
|
|
220
|
+
var max = cWidth - cBarWidth;
|
|
221
|
+
_num = Math.max(_num, min);
|
|
222
|
+
_num = Math.min(_num, max);
|
|
223
|
+
return _num;
|
|
224
|
+
}; //设置滑块和图表主体的偏移值
|
|
208
225
|
|
|
209
|
-
var mouseUpHandle = function mouseUpHandle(e) {
|
|
210
|
-
rawTranslateX = range(movementX + rawTranslateX);
|
|
211
|
-
movementX = 0;
|
|
212
|
-
isDragging = false;
|
|
213
|
-
document.removeEventListener("mousemove", mouseMoveHandle);
|
|
214
|
-
document.removeEventListener("mouseup", mouseUpHandle);
|
|
215
|
-
};
|
|
216
226
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
227
|
+
var setControlTranslate = function setControlTranslate(x, needSave) {
|
|
228
|
+
var controlEnd = axisX.controlEnd,
|
|
229
|
+
start = axisX.start;
|
|
230
|
+
var moveLen = range(x);
|
|
231
|
+
if (needSave) ctlBarX.current = moveLen;
|
|
232
|
+
controlEl.current.style.transform = "translate(".concat(moveLen, "px,0)"); //计算出当前位移的百分比
|
|
221
233
|
|
|
222
|
-
|
|
234
|
+
var percent = moveLen / (cWidth - cBarWidth);
|
|
235
|
+
var translateX = -(controlEnd + start / cPercent - chartWidth) * percent;
|
|
236
|
+
curControlPercent.current = percent;
|
|
237
|
+
seriesEl.current.style.transform = "translate(".concat(translateX, "px,").concat(marginTop, "px)");
|
|
238
|
+
axisElList.current[2].style.transform = "translate(".concat(translateX, "px,", 0, "px)");
|
|
239
|
+
}; //设置控制条是否正在进行拖拽/缩放操作
|
|
223
240
|
|
|
224
|
-
var setAnimationHoverStopTrue = function setAnimationHoverStopTrue() {
|
|
225
|
-
animationHoverStop = true;
|
|
226
|
-
};
|
|
227
241
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
242
|
+
var setWorking = function setWorking(bool) {
|
|
243
|
+
isWorking.current = bool;
|
|
244
|
+
};
|
|
231
245
|
|
|
232
|
-
|
|
233
|
-
|
|
246
|
+
(0, _react.useEffect)(function () {
|
|
247
|
+
if (controlEl.current && control) {
|
|
248
|
+
var isEnter = false; //控制条轮播动画是否处于暂停状态
|
|
234
249
|
|
|
235
250
|
var show = animation.show,
|
|
236
251
|
duration = animation.duration,
|
|
237
252
|
interval = animation.interval,
|
|
238
253
|
hover = animation.hover;
|
|
239
|
-
var times = Math.floor(xLineRange / controlWidth);
|
|
240
|
-
var animatePos = [];
|
|
241
|
-
|
|
242
|
-
for (var i = 0; i <= times; i++) {
|
|
243
|
-
if (i * controlWidth <= xLineRange) {
|
|
244
|
-
animatePos.push(i * controlWidth);
|
|
245
|
-
} else {
|
|
246
|
-
animatePos.push(xLineRange - controlWidth);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
254
|
|
|
250
|
-
var
|
|
251
|
-
|
|
255
|
+
var startAnimate = function startAnimate() {
|
|
256
|
+
var loopInterval = interval * 1000,
|
|
257
|
+
tranDuration = duration * 1000;
|
|
258
|
+
var loopTime,
|
|
259
|
+
timeGap,
|
|
260
|
+
toRight = true;
|
|
252
261
|
|
|
253
|
-
|
|
254
|
-
|
|
262
|
+
var transition = function transition(timeStamp) {
|
|
263
|
+
if (!loopTime) loopTime = timeStamp;
|
|
255
264
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (animationHoverStop && hover) {
|
|
262
|
-
initTime = timestamp - timeGap;
|
|
263
|
-
}
|
|
265
|
+
if (!isEnter && !isWorking.current) {
|
|
266
|
+
if (timeStamp - loopTime < tranDuration) {
|
|
267
|
+
var percent = Math.min(1, (timeStamp - loopTime) / tranDuration);
|
|
264
268
|
|
|
265
|
-
|
|
269
|
+
if (toRight) {
|
|
270
|
+
setControlTranslate(cBarWidth * percent + ctlBarX.current);
|
|
271
|
+
} else {
|
|
272
|
+
setControlTranslate(ctlBarX.current * (1 - percent));
|
|
273
|
+
}
|
|
266
274
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
var nextIndex = index + 1;
|
|
271
|
-
var v;
|
|
275
|
+
controlTimer.current = requestAnimationFrame(transition);
|
|
276
|
+
} else {
|
|
277
|
+
loopTime = timeStamp;
|
|
272
278
|
|
|
273
|
-
if (
|
|
274
|
-
|
|
279
|
+
if (toRight) {
|
|
280
|
+
setControlTranslate(cBarWidth + ctlBarX.current, true);
|
|
275
281
|
} else {
|
|
276
|
-
|
|
277
|
-
v = (1 - p) * animatePos[index];
|
|
282
|
+
setControlTranslate(0, true);
|
|
278
283
|
}
|
|
279
284
|
|
|
280
|
-
|
|
285
|
+
controlTimer.current = requestAnimationFrame(loop);
|
|
281
286
|
}
|
|
287
|
+
} else {
|
|
288
|
+
loopTime = timeStamp - timeGap;
|
|
289
|
+
controlTimer.current = requestAnimationFrame(transition);
|
|
290
|
+
}
|
|
282
291
|
|
|
283
|
-
|
|
292
|
+
timeGap = timeStamp - loopTime;
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
var loop = function loop(timeStamp) {
|
|
296
|
+
if (!loopTime) loopTime = timeStamp;
|
|
297
|
+
|
|
298
|
+
if (!isEnter && !isWorking.current) {
|
|
299
|
+
if (timeStamp - loopTime < loopInterval) {
|
|
300
|
+
controlTimer.current = requestAnimationFrame(loop);
|
|
301
|
+
} else {
|
|
302
|
+
loopTime = timeStamp;
|
|
303
|
+
if (ctlBarX.current == cWidth - cBarWidth) toRight = false;else toRight = true;
|
|
304
|
+
controlTimer.current = requestAnimationFrame(transition);
|
|
305
|
+
}
|
|
284
306
|
} else {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
animationId = window.requestAnimationFrame(_animation);
|
|
307
|
+
loopTime = timeStamp - timeGap;
|
|
308
|
+
controlTimer.current = requestAnimationFrame(loop);
|
|
288
309
|
}
|
|
310
|
+
|
|
311
|
+
timeGap = timeStamp - loopTime;
|
|
289
312
|
};
|
|
290
313
|
|
|
291
|
-
|
|
292
|
-
}
|
|
314
|
+
controlTimer.current = requestAnimationFrame(loop);
|
|
315
|
+
};
|
|
293
316
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
controlEl.current.removeEventListener("mousedown", mouseDownHandle);
|
|
297
|
-
svg.current.removeEventListener("mouseenter", setAnimationHoverStopTrue);
|
|
298
|
-
svg.current.removeEventListener("mouseleave", setAnimationHoverStopFalse);
|
|
299
|
-
window.cancelAnimationFrame(animationId);
|
|
317
|
+
var mouseenter = function mouseenter() {
|
|
318
|
+
isEnter = true;
|
|
300
319
|
};
|
|
301
|
-
}
|
|
302
|
-
}, [JSON.stringify(animation), control]);
|
|
303
320
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
setControlChartTooltipShow = _useState4[1];
|
|
321
|
+
var mouseleave = function mouseleave() {
|
|
322
|
+
isEnter = false;
|
|
323
|
+
};
|
|
308
324
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
325
|
+
if (hover) {
|
|
326
|
+
svg.current.addEventListener("mouseenter", mouseenter);
|
|
327
|
+
svg.current.addEventListener("mouseleave", mouseleave);
|
|
328
|
+
controlEl.current.addEventListener("mouseenter", mouseenter);
|
|
329
|
+
controlEl.current.addEventListener("mouseleave", mouseleave);
|
|
330
|
+
}
|
|
313
331
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
setControlChartTooltipX = _useState8[1];
|
|
332
|
+
if (show) {
|
|
333
|
+
startAnimate();
|
|
334
|
+
}
|
|
318
335
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
336
|
+
return function () {
|
|
337
|
+
svg.current.removeEventListener("mouseenter", mouseenter);
|
|
338
|
+
svg.current.removeEventListener("mouseleave", mouseleave);
|
|
339
|
+
controlEl.current.removeEventListener("mouseenter", mouseenter);
|
|
340
|
+
controlEl.current.removeEventListener("mouseleave", mouseleave);
|
|
341
|
+
cancelAnimationFrame(controlTimer.current);
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
}, [JSON.stringify(animation), control]); //初始化控制图提示框状态的函数
|
|
324
345
|
|
|
325
|
-
var
|
|
346
|
+
var initCtlTip = function initCtlTip() {
|
|
326
347
|
return {
|
|
327
|
-
|
|
328
|
-
|
|
348
|
+
show: false,
|
|
349
|
+
xName: "",
|
|
350
|
+
x: undefined,
|
|
351
|
+
indicatorList: axisX.ticks.map(function (tick) {
|
|
352
|
+
return {
|
|
353
|
+
tick: tick,
|
|
354
|
+
isShow: false
|
|
355
|
+
};
|
|
356
|
+
})
|
|
329
357
|
};
|
|
330
|
-
}
|
|
331
|
-
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
|
332
|
-
controlChartIndicatorList = _useState10[0],
|
|
333
|
-
setControlChartIndicatorList = _useState10[1];
|
|
358
|
+
};
|
|
334
359
|
|
|
360
|
+
var _useState5 = (0, _react.useState)(initCtlTip),
|
|
361
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
362
|
+
ctlTip = _useState6[0],
|
|
363
|
+
setCtlTip = _useState6[1];
|
|
364
|
+
|
|
365
|
+
var showCtl = ctlTip.show,
|
|
366
|
+
ctlXName = ctlTip.xName,
|
|
367
|
+
ctlX = ctlTip.x,
|
|
368
|
+
ctlIndicatorList = ctlTip.indicatorList;
|
|
369
|
+
var controlChartTooltipData = ctlXName && originData.filter(function (d) {
|
|
370
|
+
return d.x === ctlXName;
|
|
371
|
+
});
|
|
335
372
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_.ChartContainer, {
|
|
336
373
|
style: style,
|
|
337
374
|
width: width,
|
|
@@ -356,7 +393,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
356
393
|
width: "100%",
|
|
357
394
|
height: "100%"
|
|
358
395
|
}, /*#__PURE__*/_react["default"].createElement(_.Background, {
|
|
359
|
-
length: isVertical ? chartWidth :
|
|
396
|
+
length: isVertical ? chartWidth : yLineRange,
|
|
360
397
|
axis: axisX,
|
|
361
398
|
config: background,
|
|
362
399
|
bandLength: bandLength
|
|
@@ -369,24 +406,11 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
369
406
|
triggerClick: onInteraction,
|
|
370
407
|
xLineRange: xLineRange,
|
|
371
408
|
yLineRange: yLineRange,
|
|
372
|
-
|
|
373
|
-
controlConfig: control
|
|
409
|
+
controlInfo: controlInfo
|
|
374
410
|
}, config, {
|
|
375
411
|
key: index
|
|
376
412
|
}));
|
|
377
|
-
}),
|
|
378
|
-
ref: controlEl,
|
|
379
|
-
props: {
|
|
380
|
-
control: control,
|
|
381
|
-
axes: axes,
|
|
382
|
-
series: series,
|
|
383
|
-
xLineRange: xLineRange,
|
|
384
|
-
yLineRange: yLineRange,
|
|
385
|
-
marginTop: marginTop,
|
|
386
|
-
axisX: axisX,
|
|
387
|
-
bandLength: bandLength
|
|
388
|
-
}
|
|
389
|
-
}), showTooltip && !isControlChart && /*#__PURE__*/_react["default"].createElement(_.Indicator, (0, _extends2["default"])({}, indicator, indicatorAttr)), /*#__PURE__*/_react["default"].createElement("foreignObject", {
|
|
413
|
+
}), showTooltip && !control && /*#__PURE__*/_react["default"].createElement(_.Indicator, (0, _extends2["default"])({}, indicator, indicatorAttr)), /*#__PURE__*/_react["default"].createElement("foreignObject", {
|
|
390
414
|
style: isVertical ? {
|
|
391
415
|
width: xLineRange + marginRight + marginLeft,
|
|
392
416
|
height: yLineRange,
|
|
@@ -404,21 +428,18 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
404
428
|
overflow: "visible",
|
|
405
429
|
transform: isVertical ? "translateX(".concat(marginRight, "px)") : "translateY(".concat(marginTop, "px)")
|
|
406
430
|
}
|
|
407
|
-
}, /*#__PURE__*/_react["default"].createElement("g", null,
|
|
431
|
+
}, /*#__PURE__*/_react["default"].createElement("g", null, control && ctlIndicatorList.map(function (item, index) {
|
|
408
432
|
var x = axisX.scaler(item.tick);
|
|
409
433
|
return /*#__PURE__*/_react["default"].createElement(_.Indicator, (0, _extends2["default"])({
|
|
410
434
|
key: index
|
|
411
435
|
}, indicator, {
|
|
412
|
-
height:
|
|
436
|
+
height: yLineRange,
|
|
413
437
|
width: indicatorWidth,
|
|
414
438
|
x: x - indicatorWidth / 2,
|
|
415
|
-
isControlChart:
|
|
439
|
+
isControlChart: !!control,
|
|
416
440
|
xName: item.tick,
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
setControlChartTooltipShow: setControlChartTooltipShow,
|
|
420
|
-
controlChartIndicatorList: controlChartIndicatorList,
|
|
421
|
-
setControlChartIndicatorList: setControlChartIndicatorList
|
|
441
|
+
setCtlTip: setCtlTip,
|
|
442
|
+
ctlIndicatorList: ctlIndicatorList
|
|
422
443
|
}));
|
|
423
444
|
})), series.map(function (_ref2, index) {
|
|
424
445
|
var Component = _ref2.Component,
|
|
@@ -432,13 +453,10 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
432
453
|
xAxis: axisX,
|
|
433
454
|
yAxis: yAxis // 控制图部分,主要是为了,当鼠标悬浮在指示器上时,显示对应的tooltip
|
|
434
455
|
,
|
|
435
|
-
isControlChart:
|
|
436
|
-
setControlChartTooltipXName: setControlChartTooltipXName,
|
|
437
|
-
setControlChartTooltipX: setControlChartTooltipX,
|
|
438
|
-
setControlChartTooltipShow: setControlChartTooltipShow,
|
|
456
|
+
isControlChart: !!control,
|
|
439
457
|
indicatorWidth: indicatorWidth,
|
|
440
458
|
triggerClick: onInteraction,
|
|
441
|
-
|
|
459
|
+
setCtlTip: setCtlTip
|
|
442
460
|
}));
|
|
443
461
|
}), series.map(function (_ref3, index) {
|
|
444
462
|
var Component = _ref3.Component,
|
|
@@ -467,10 +485,25 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
467
485
|
axisX: axisX,
|
|
468
486
|
data: item
|
|
469
487
|
});
|
|
470
|
-
})), /*#__PURE__*/_react["default"].createElement(_.
|
|
488
|
+
})), control && /*#__PURE__*/_react["default"].createElement(_.Control, {
|
|
489
|
+
ref: controlEl,
|
|
490
|
+
actions: {
|
|
491
|
+
setX: setControlTranslate,
|
|
492
|
+
setWorking: setWorking,
|
|
493
|
+
setControlInfo: setControlInfo
|
|
494
|
+
},
|
|
495
|
+
props: {
|
|
496
|
+
control: control,
|
|
497
|
+
axes: axes,
|
|
498
|
+
series: series,
|
|
499
|
+
width: width,
|
|
500
|
+
top: chartHeight + marginTop,
|
|
501
|
+
bandLength: bandLength
|
|
502
|
+
}
|
|
503
|
+
}), /*#__PURE__*/_react["default"].createElement(_.Legend, (0, _extends2["default"])({}, legend, {
|
|
471
504
|
filterData: filterData,
|
|
472
505
|
series: series
|
|
473
|
-
})), showTooltip && !
|
|
506
|
+
})), showTooltip && !control && /*#__PURE__*/_react["default"].createElement(_.Tooltip, (0, _extends2["default"])({
|
|
474
507
|
isVertical: isVertical
|
|
475
508
|
}, tooltip, {
|
|
476
509
|
data: tooltipData,
|
|
@@ -481,14 +514,14 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
481
514
|
series: series,
|
|
482
515
|
width: width,
|
|
483
516
|
height: height
|
|
484
|
-
})),
|
|
517
|
+
})), showCtl && !!control && /*#__PURE__*/_react["default"].createElement(_.Tooltip, (0, _extends2["default"])({
|
|
485
518
|
isVertical: isVertical
|
|
486
519
|
}, tooltip, {
|
|
487
520
|
data: controlChartTooltipData,
|
|
488
|
-
x:
|
|
521
|
+
x: ctlX - (axisX.controlEnd + axisX.start / cPercent - chartWidth) * curControlPercent.current,
|
|
489
522
|
marginLeft: marginLeft,
|
|
490
523
|
marginTop: marginTop,
|
|
491
|
-
tickName:
|
|
524
|
+
tickName: ctlXName,
|
|
492
525
|
series: series,
|
|
493
526
|
width: width,
|
|
494
527
|
height: height
|