@easyv/charts 1.4.24 → 1.4.26
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/Marquee.js +1 -1
- package/lib/components/PieChart.js +152 -88
- package/lib/components/index.js +7 -0
- package/lib/components/pieTooltip.js +132 -0
- package/package.json +1 -1
- package/src/components/Marquee.tsx +2 -2
- package/src/components/PieChart.js +400 -261
- package/src/components/PieTooltip.jsx +134 -0
- package/src/components/index.js +2 -0
|
@@ -45,7 +45,7 @@ var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
|
|
|
45
45
|
//初始化观察器,利用观察器来监视组件可视区域变化
|
|
46
46
|
observe.current = new IntersectionObserver(function (entries) {
|
|
47
47
|
var entrie = entries[0];
|
|
48
|
-
if (entrie.boundingClientRect.width
|
|
48
|
+
if (entrie.boundingClientRect.width <= entrie.rootBounds.width) {
|
|
49
49
|
//表示文字全部可视
|
|
50
50
|
cancelAnimationFrame(timer.current || 0);
|
|
51
51
|
target.current.style.transform = "translate(0px,0px)"; //重置偏移
|
|
@@ -21,6 +21,7 @@ var _LinearGradient = _interopRequireDefault(require("./LinearGradient"));
|
|
|
21
21
|
var _formatter = require("../formatter");
|
|
22
22
|
var _piechartModule = _interopRequireDefault(require("../css/piechart.module.css"));
|
|
23
23
|
var _hooks = require("../hooks");
|
|
24
|
+
var _PieTooltip = require("./PieTooltip");
|
|
24
25
|
var _excluded = ["startAngle", "endAngle", "antiClockwise"],
|
|
25
26
|
_excluded2 = ["padAngle", "innerRadius", "outerRadius", "cornerRadius", "startAngle", "endAngle"],
|
|
26
27
|
_excluded3 = ["formatter"],
|
|
@@ -38,7 +39,7 @@ var defaultChart = {
|
|
|
38
39
|
innerRadius: 0,
|
|
39
40
|
cornerRadius: 0,
|
|
40
41
|
rose: false,
|
|
41
|
-
roseType:
|
|
42
|
+
roseType: "radius",
|
|
42
43
|
baseRadius: 0,
|
|
43
44
|
padAngle: 0
|
|
44
45
|
};
|
|
@@ -49,14 +50,14 @@ var defaultAngle = {
|
|
|
49
50
|
};
|
|
50
51
|
var nameDy = function nameDy(showValue, showPercent, mode, dir) {
|
|
51
52
|
if (showValue || showPercent) {
|
|
52
|
-
if (mode ==
|
|
53
|
-
return dir == 1 ?
|
|
53
|
+
if (mode == "vertical") {
|
|
54
|
+
return dir == 1 ? "1.1em" : "-2.6em";
|
|
54
55
|
} else {
|
|
55
56
|
return 0;
|
|
56
57
|
}
|
|
57
58
|
} else {
|
|
58
|
-
if (mode ==
|
|
59
|
-
return dir * 1.1 +
|
|
59
|
+
if (mode == "vertical") {
|
|
60
|
+
return dir * 1.1 + "em";
|
|
60
61
|
} else {
|
|
61
62
|
return 0;
|
|
62
63
|
}
|
|
@@ -64,14 +65,14 @@ var nameDy = function nameDy(showValue, showPercent, mode, dir) {
|
|
|
64
65
|
};
|
|
65
66
|
var valueDy = function valueDy(value1, mode, dir) {
|
|
66
67
|
if (value1) {
|
|
67
|
-
if (mode ==
|
|
68
|
-
return
|
|
68
|
+
if (mode == "vertical") {
|
|
69
|
+
return "1.5em";
|
|
69
70
|
} else {
|
|
70
71
|
return 0;
|
|
71
72
|
}
|
|
72
73
|
} else {
|
|
73
|
-
if (mode ==
|
|
74
|
-
return dir == 1 ?
|
|
74
|
+
if (mode == "vertical") {
|
|
75
|
+
return dir == 1 ? "1.1em" : "-1.1em";
|
|
75
76
|
} else {
|
|
76
77
|
return 0;
|
|
77
78
|
}
|
|
@@ -82,14 +83,14 @@ var percentDy_ = function percentDy_(showName, showValue, mode, dir) {
|
|
|
82
83
|
return 0;
|
|
83
84
|
}
|
|
84
85
|
if (showName) {
|
|
85
|
-
if (mode ==
|
|
86
|
-
return
|
|
86
|
+
if (mode == "vertical") {
|
|
87
|
+
return "1.5em";
|
|
87
88
|
} else {
|
|
88
89
|
return 0;
|
|
89
90
|
}
|
|
90
91
|
} else {
|
|
91
|
-
if (mode ==
|
|
92
|
-
return dir * 1.1 +
|
|
92
|
+
if (mode == "vertical") {
|
|
93
|
+
return dir * 1.1 + "em";
|
|
93
94
|
} else {
|
|
94
95
|
return 0;
|
|
95
96
|
}
|
|
@@ -97,13 +98,13 @@ var percentDy_ = function percentDy_(showName, showValue, mode, dir) {
|
|
|
97
98
|
};
|
|
98
99
|
var percentX = function percentX(showName, showValue, mode, x) {
|
|
99
100
|
if (showValue) {
|
|
100
|
-
return
|
|
101
|
+
return "";
|
|
101
102
|
}
|
|
102
103
|
if (showName) {
|
|
103
|
-
if (mode ==
|
|
104
|
+
if (mode == "vertical") {
|
|
104
105
|
return x;
|
|
105
106
|
} else {
|
|
106
|
-
return
|
|
107
|
+
return "";
|
|
107
108
|
}
|
|
108
109
|
} else {
|
|
109
110
|
return x;
|
|
@@ -111,13 +112,13 @@ var percentX = function percentX(showName, showValue, mode, x) {
|
|
|
111
112
|
};
|
|
112
113
|
var percentDx = function percentDx(showName, showValue, mode) {
|
|
113
114
|
if (showValue) {
|
|
114
|
-
return
|
|
115
|
+
return "0.5em";
|
|
115
116
|
}
|
|
116
117
|
if (showName) {
|
|
117
|
-
if (mode ==
|
|
118
|
+
if (mode == "vertical") {
|
|
118
119
|
return 0;
|
|
119
120
|
} else {
|
|
120
|
-
return
|
|
121
|
+
return "0.5em";
|
|
121
122
|
}
|
|
122
123
|
} else {
|
|
123
124
|
return 0;
|
|
@@ -128,8 +129,8 @@ var percentDy = function percentDy(showName, showValue, mode) {
|
|
|
128
129
|
return 0;
|
|
129
130
|
}
|
|
130
131
|
if (showName) {
|
|
131
|
-
if (mode ==
|
|
132
|
-
return
|
|
132
|
+
if (mode == "vertical") {
|
|
133
|
+
return "1.5em";
|
|
133
134
|
} else {
|
|
134
135
|
return 0;
|
|
135
136
|
}
|
|
@@ -139,12 +140,12 @@ var percentDy = function percentDy(showName, showValue, mode) {
|
|
|
139
140
|
};
|
|
140
141
|
var valueDx = function valueDx(showName, mode) {
|
|
141
142
|
if (!showName) {
|
|
142
|
-
return
|
|
143
|
+
return "";
|
|
143
144
|
}
|
|
144
|
-
if (mode ==
|
|
145
|
-
return
|
|
145
|
+
if (mode == "vertical") {
|
|
146
|
+
return "";
|
|
146
147
|
} else {
|
|
147
|
-
return
|
|
148
|
+
return "0.5em";
|
|
148
149
|
}
|
|
149
150
|
};
|
|
150
151
|
var getCoord = function getCoord(deg, radius) {
|
|
@@ -189,7 +190,7 @@ var getArc = function getArc(radius, _ref3, series_, index) {
|
|
|
189
190
|
return s.fieldName == rest.data.s;
|
|
190
191
|
}) || series_[index % series_.length];
|
|
191
192
|
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
192
|
-
type:
|
|
193
|
+
type: "pie",
|
|
193
194
|
fieldName: series.fieldName,
|
|
194
195
|
displayName: series.displayName || rest.data.s,
|
|
195
196
|
series: series,
|
|
@@ -282,6 +283,9 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
282
283
|
gap = _ref5$config$animatio6 === void 0 ? 0 : _ref5$config$animatio6,
|
|
283
284
|
_ref5$config$animatio7 = _ref5$config$animatio.rotate,
|
|
284
285
|
rotate = _ref5$config$animatio7 === void 0 ? 0 : _ref5$config$animatio7,
|
|
286
|
+
_ref5$config$tooltip = _ref5$config.tooltip,
|
|
287
|
+
tooltip = _ref5$config$tooltip === void 0 ? {} : _ref5$config$tooltip,
|
|
288
|
+
config = _ref5.config,
|
|
285
289
|
_ref5$state = _ref5.state,
|
|
286
290
|
currentIndex = _ref5$state.currentIndex,
|
|
287
291
|
trigger = _ref5$state.trigger,
|
|
@@ -341,15 +345,15 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
341
345
|
roseType = _chart.roseType;
|
|
342
346
|
var _padAngle = padAngle * Math.PI / 180;
|
|
343
347
|
switch (order) {
|
|
344
|
-
case
|
|
348
|
+
case "":
|
|
345
349
|
arcsFunc.sort(null);
|
|
346
350
|
break;
|
|
347
|
-
case
|
|
351
|
+
case "desc":
|
|
348
352
|
arcsFunc.sort(function (a, b) {
|
|
349
353
|
return b.y - a.y;
|
|
350
354
|
});
|
|
351
355
|
break;
|
|
352
|
-
case
|
|
356
|
+
case "asc":
|
|
353
357
|
arcsFunc.sort(function (a, b) {
|
|
354
358
|
return a.y - b.y;
|
|
355
359
|
});
|
|
@@ -383,9 +387,9 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
383
387
|
endAngle = _ref6.endAngle,
|
|
384
388
|
arc = (0, _objectWithoutProperties2["default"])(_ref6, _excluded4);
|
|
385
389
|
return _objectSpread(_objectSpread({}, arc), {}, {
|
|
386
|
-
id: id +
|
|
387
|
-
startAngle: roseType ==
|
|
388
|
-
endAngle: roseType ==
|
|
390
|
+
id: id + "_linear_" + index,
|
|
391
|
+
startAngle: roseType == "area" ? _angle * index : startAngle,
|
|
392
|
+
endAngle: roseType == "area" ? _angle * (index + 1) : endAngle,
|
|
389
393
|
cornerRadius: cornerRadius,
|
|
390
394
|
padAngle: _padAngle,
|
|
391
395
|
innerRadius: innerRadius,
|
|
@@ -395,7 +399,7 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
395
399
|
}
|
|
396
400
|
return _legendDataWithPercent.map(function (arc, index) {
|
|
397
401
|
return _objectSpread(_objectSpread({}, arc), {}, {
|
|
398
|
-
id: id +
|
|
402
|
+
id: id + "_linear_" + index,
|
|
399
403
|
cornerRadius: cornerRadius,
|
|
400
404
|
padAngle: _padAngle,
|
|
401
405
|
innerRadius: innerRadius,
|
|
@@ -415,22 +419,26 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
415
419
|
var onClick = (0, _react.useCallback)(function (e) {
|
|
416
420
|
return onEvent({
|
|
417
421
|
currentIndex: +e.currentTarget.dataset.index,
|
|
418
|
-
type:
|
|
422
|
+
type: "onClick"
|
|
419
423
|
});
|
|
420
424
|
}, [onEvent]);
|
|
421
425
|
var onMouseEnter = (0, _react.useCallback)(function (e) {
|
|
422
426
|
var _data = arcs[+currentIndex].data;
|
|
423
427
|
triggerOnRelative(_data);
|
|
424
|
-
onEmit(
|
|
428
|
+
onEmit("onMouseEnter", _data);
|
|
425
429
|
onEvent({
|
|
426
430
|
currentIndex: +e.currentTarget.dataset.index,
|
|
427
|
-
type:
|
|
431
|
+
type: "onMouseEnter"
|
|
428
432
|
});
|
|
429
433
|
}, [onEvent, triggerOnRelative, onEmit]);
|
|
430
434
|
var onMouseLeave = (0, _react.useCallback)(function (e) {
|
|
431
|
-
|
|
435
|
+
setMousePos({
|
|
436
|
+
x: 0,
|
|
437
|
+
y: 0
|
|
438
|
+
});
|
|
439
|
+
onEvent({
|
|
432
440
|
currentIndex: +e.currentTarget.dataset.index,
|
|
433
|
-
type:
|
|
441
|
+
type: "onMouseLeave"
|
|
434
442
|
});
|
|
435
443
|
}, [onEvent]);
|
|
436
444
|
(0, _react.useLayoutEffect)(function () {
|
|
@@ -448,11 +456,11 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
448
456
|
onComplete: function onComplete() {
|
|
449
457
|
var _data = arcs[+currentIndex].data;
|
|
450
458
|
triggerOnRelative(_data);
|
|
451
|
-
onEmit(
|
|
459
|
+
onEmit("carousel", _data);
|
|
452
460
|
}
|
|
453
461
|
});
|
|
454
462
|
} else {
|
|
455
|
-
if (currentIndex !== null && trigger ===
|
|
463
|
+
if (currentIndex !== null && trigger === "onClick") {
|
|
456
464
|
var _data = arcs[+currentIndex].data;
|
|
457
465
|
triggerOnRelative(_data);
|
|
458
466
|
onEmit(trigger, _data);
|
|
@@ -488,16 +496,29 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
488
496
|
maxRadius = Math.max(maxRadius, d.outerRadius);
|
|
489
497
|
});
|
|
490
498
|
var centerRadius = 0.5 * maxRadius + 0.5 * _arcs[0].innerRadius;
|
|
499
|
+
var _useState3 = (0, _react.useState)({
|
|
500
|
+
x: 0,
|
|
501
|
+
y: 0
|
|
502
|
+
}),
|
|
503
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
504
|
+
mousePos = _useState4[0],
|
|
505
|
+
setMousePos = _useState4[1];
|
|
506
|
+
var _useState5 = (0, _react.useState)(null),
|
|
507
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
508
|
+
hoverData = _useState6[0],
|
|
509
|
+
setHoverData = _useState6[1];
|
|
510
|
+
var pieWarpEl = (0, _react.useRef)(null);
|
|
491
511
|
return outerDecorate ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_.ChartContainer //用于生成甜甜圈图,判断依据是外环装饰这个配置项(outerDecorate)
|
|
492
512
|
, {
|
|
493
513
|
width: width,
|
|
494
514
|
height: height,
|
|
495
515
|
marginLeft: marginLeft,
|
|
496
|
-
marginTop: marginTop
|
|
516
|
+
marginTop: marginTop,
|
|
517
|
+
ref: pieWarpEl
|
|
497
518
|
}, /*#__PURE__*/_react["default"].createElement("g", {
|
|
498
519
|
style: {
|
|
499
|
-
transition:
|
|
500
|
-
transform:
|
|
520
|
+
transition: "transform ease-in-out 0.3s",
|
|
521
|
+
transform: "translate(" + halfChartWidth + "px, " + halfChartHeight + "px) rotate(" + rotate_ + "deg)"
|
|
501
522
|
}
|
|
502
523
|
},
|
|
503
524
|
//用于生成外环装饰的刻度
|
|
@@ -523,7 +544,7 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
523
544
|
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, {
|
|
524
545
|
key: index
|
|
525
546
|
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
526
|
-
className: _piechartModule["default"][
|
|
547
|
+
className: _piechartModule["default"]["inner-arc"],
|
|
527
548
|
style: {
|
|
528
549
|
strokeDasharray: "".concat(dashLength, ",").concat(2 * dashLength),
|
|
529
550
|
strokeDashoffset: dashLength,
|
|
@@ -533,8 +554,20 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
533
554
|
onClick: onClick,
|
|
534
555
|
onMouseEnter: onMouseEnter,
|
|
535
556
|
onMouseLeave: onMouseLeave,
|
|
536
|
-
|
|
537
|
-
|
|
557
|
+
onMouseMove: function onMouseMove(e) {
|
|
558
|
+
var _data = arcs[+e.currentTarget.dataset.index];
|
|
559
|
+
var warpBoxPos = {
|
|
560
|
+
x: pieWarpEl.current.getBoundingClientRect().x,
|
|
561
|
+
y: pieWarpEl.current.getBoundingClientRect().y
|
|
562
|
+
};
|
|
563
|
+
setMousePos({
|
|
564
|
+
x: e.clientX - warpBoxPos.x,
|
|
565
|
+
y: e.clientY - warpBoxPos.y
|
|
566
|
+
});
|
|
567
|
+
setHoverData(_data);
|
|
568
|
+
},
|
|
569
|
+
d: path.split("L")[0],
|
|
570
|
+
stroke: "url(#" + id + ")",
|
|
538
571
|
strokeWidth: arcWidth,
|
|
539
572
|
fill: "none"
|
|
540
573
|
}), /*#__PURE__*/_react["default"].createElement("defs", null, /*#__PURE__*/_react["default"].createElement(_LinearGradient["default"], {
|
|
@@ -549,7 +582,16 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
549
582
|
}),
|
|
550
583
|
arcs: _arcs,
|
|
551
584
|
judge: judgeData
|
|
552
|
-
}))), /*#__PURE__*/_react["default"].createElement(
|
|
585
|
+
}))), tooltip && mousePos && mousePos.x != 0 && mousePos.y != 0 && tooltip.manual && /*#__PURE__*/_react["default"].createElement(_PieTooltip.PieTooltip, {
|
|
586
|
+
series: series,
|
|
587
|
+
data: hoverData,
|
|
588
|
+
config: tooltip,
|
|
589
|
+
pieCenter: {
|
|
590
|
+
x: halfChartWidth,
|
|
591
|
+
y: maxRadius + marginTop
|
|
592
|
+
},
|
|
593
|
+
mousePos: mousePos
|
|
594
|
+
}), /*#__PURE__*/_react["default"].createElement(_.Legend, (0, _extends2["default"])({}, legend, {
|
|
553
595
|
series: _arcs,
|
|
554
596
|
formatter: formatter,
|
|
555
597
|
judge: judgeData
|
|
@@ -563,11 +605,12 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
563
605
|
},
|
|
564
606
|
onMouseLeave: function onMouseLeave() {
|
|
565
607
|
hoverEvent(false);
|
|
566
|
-
}
|
|
608
|
+
},
|
|
609
|
+
ref: pieWarpEl
|
|
567
610
|
}, /*#__PURE__*/_react["default"].createElement("g", {
|
|
568
611
|
style: {
|
|
569
|
-
transition:
|
|
570
|
-
transform:
|
|
612
|
+
transition: "transform ease-in-out 0.3s",
|
|
613
|
+
transform: "translate(" + halfChartWidth + "px, " + halfChartHeight + "px) rotate(" + rotate_ + "deg)"
|
|
571
614
|
}
|
|
572
615
|
}, _arcs.map(function (_ref8, index) {
|
|
573
616
|
var id = _ref8.id,
|
|
@@ -585,13 +628,13 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
585
628
|
var path = arc.innerRadius(innerRadius + deltaHeighten).outerRadius(outerRadius + deltaHeighten)(value);
|
|
586
629
|
var pie = (0, _utils.getColorList)(series.color);
|
|
587
630
|
var currentPie = animateColor ? (0, _utils.getColorList)(animateColor) : (0, _utils.getColorList)(series.color);
|
|
588
|
-
var textPath =
|
|
631
|
+
var textPath = "",
|
|
589
632
|
categoryTextStyle = {};
|
|
590
633
|
if (categoryText && categoryText.show) {
|
|
591
634
|
//如果有类目文本,则需要计算文字路径
|
|
592
635
|
//let offsetWidth=decorate2.radiusWidth/2 + radiusWidthAdd/2; //当前文字需生成在装饰物内,故而半径需要减小
|
|
593
636
|
var textArc = arc.innerRadius(outerRadius + (current ? gap : categoryText.gap)).outerRadius(outerRadius + (current ? gap : categoryText.gap))(value);
|
|
594
|
-
var lastA = textArc.lastIndexOf(
|
|
637
|
+
var lastA = textArc.lastIndexOf("A");
|
|
595
638
|
textPath = textArc.slice(0, lastA > 0 ? lastA : textArc.length); //文字路径
|
|
596
639
|
categoryTextStyle = current ? animateCTS : categoryText.textStyle; //这里把textstyle拿出来
|
|
597
640
|
}
|
|
@@ -603,10 +646,22 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
603
646
|
onClick: onClick,
|
|
604
647
|
onMouseEnter: onMouseEnter,
|
|
605
648
|
onMouseLeave: onMouseLeave,
|
|
649
|
+
onMouseMove: function onMouseMove(e) {
|
|
650
|
+
var _data = arcs[+e.currentTarget.dataset.index];
|
|
651
|
+
var warpBoxPos = {
|
|
652
|
+
x: pieWarpEl.current.getBoundingClientRect().x,
|
|
653
|
+
y: pieWarpEl.current.getBoundingClientRect().y
|
|
654
|
+
};
|
|
655
|
+
setMousePos({
|
|
656
|
+
x: e.clientX - warpBoxPos.x,
|
|
657
|
+
y: e.clientY - warpBoxPos.y
|
|
658
|
+
});
|
|
659
|
+
setHoverData(_data);
|
|
660
|
+
},
|
|
606
661
|
d: path,
|
|
607
|
-
stroke: show ? color :
|
|
608
|
-
strokeWidth: show ? strokeWidth :
|
|
609
|
-
fill:
|
|
662
|
+
stroke: show ? color : "none",
|
|
663
|
+
strokeWidth: show ? strokeWidth : "0",
|
|
664
|
+
fill: "url(#" + id + ")",
|
|
610
665
|
fillOpacity: fillOpacity
|
|
611
666
|
}),
|
|
612
667
|
//装饰物2,产生于每个弧的外部
|
|
@@ -616,9 +671,9 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
616
671
|
onMouseEnter: onMouseEnter,
|
|
617
672
|
onMouseLeave: onMouseLeave,
|
|
618
673
|
d: arc.innerRadius(outerRadius).outerRadius(outerRadius + decorate2.radiusWidth + (current ? radiusWidthAdd : 0))(value),
|
|
619
|
-
stroke: show ? color :
|
|
620
|
-
strokeWidth: show ? strokeWidth :
|
|
621
|
-
fill:
|
|
674
|
+
stroke: show ? color : "none",
|
|
675
|
+
strokeWidth: show ? strokeWidth : "0",
|
|
676
|
+
fill: "url(#" + id + ")",
|
|
622
677
|
fillOpacity: decorate2.opacity / 100
|
|
623
678
|
}),
|
|
624
679
|
//类目文本
|
|
@@ -626,21 +681,21 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
626
681
|
onClick: onClick,
|
|
627
682
|
onMouseEnter: onMouseEnter,
|
|
628
683
|
onMouseLeave: onMouseLeave,
|
|
629
|
-
id: id +
|
|
684
|
+
id: id + "_text_" + index,
|
|
630
685
|
d: textPath,
|
|
631
686
|
fill: "none",
|
|
632
687
|
stroke: "none"
|
|
633
688
|
}), /*#__PURE__*/_react["default"].createElement("text", {
|
|
634
689
|
textAnchor: "middle",
|
|
635
690
|
style: _objectSpread(_objectSpread({}, categoryTextStyle), {}, {
|
|
636
|
-
fontWeight: categoryTextStyle.bold ?
|
|
637
|
-
fontStyle: categoryTextStyle.italic ?
|
|
638
|
-
pointerEvents:
|
|
691
|
+
fontWeight: categoryTextStyle.bold ? "bold" : "normal",
|
|
692
|
+
fontStyle: categoryTextStyle.italic ? "italic" : "normal",
|
|
693
|
+
pointerEvents: "none"
|
|
639
694
|
}),
|
|
640
695
|
fill: categoryTextStyle.color
|
|
641
696
|
}, /*#__PURE__*/_react["default"].createElement("textPath", {
|
|
642
697
|
startOffset: "50%",
|
|
643
|
-
href:
|
|
698
|
+
href: "#" + id + "_text_" + index
|
|
644
699
|
}, _arcs[index].displayName || _arcs[index].fieldName))), /*#__PURE__*/_react["default"].createElement("defs", null, /*#__PURE__*/_react["default"].createElement(_LinearGradient["default"], {
|
|
645
700
|
id: id,
|
|
646
701
|
colors: current ? currentPie : pie,
|
|
@@ -654,7 +709,7 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
654
709
|
}), current && /*#__PURE__*/_react["default"].createElement("g", {
|
|
655
710
|
fillOpacity: y,
|
|
656
711
|
style: {
|
|
657
|
-
transform:
|
|
712
|
+
transform: "rotate(" + -rotate_ + "deg)"
|
|
658
713
|
}
|
|
659
714
|
}, /*#__PURE__*/_react["default"].createElement(Current, {
|
|
660
715
|
config: current,
|
|
@@ -671,6 +726,15 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
671
726
|
config: decorate,
|
|
672
727
|
arcs: _arcs,
|
|
673
728
|
radius: radius
|
|
729
|
+
}), tooltip && mousePos && mousePos.x != 0 && mousePos.y != 0 && tooltip.manual && /*#__PURE__*/_react["default"].createElement(_PieTooltip.PieTooltip, {
|
|
730
|
+
series: series,
|
|
731
|
+
data: hoverData,
|
|
732
|
+
config: tooltip,
|
|
733
|
+
pieCenter: {
|
|
734
|
+
x: halfChartWidth,
|
|
735
|
+
y: maxRadius + marginTop
|
|
736
|
+
},
|
|
737
|
+
mousePos: mousePos
|
|
674
738
|
}), /*#__PURE__*/_react["default"].createElement(_.Legend, (0, _extends2["default"])({}, legend, {
|
|
675
739
|
series: _arcs,
|
|
676
740
|
formatter: formatter,
|
|
@@ -717,7 +781,7 @@ var Current = function Current(_ref9) {
|
|
|
717
781
|
currentIndex = _ref9.currentIndex;
|
|
718
782
|
var _data = (0, _react.useMemo)(function () {
|
|
719
783
|
var legendDataWithPercent = (0, _utils.getDataWithPercent)(data, precision);
|
|
720
|
-
return (0, _utils.sortPie)(legendDataWithPercent,
|
|
784
|
+
return (0, _utils.sortPie)(legendDataWithPercent, "");
|
|
721
785
|
}, [data, precision]);
|
|
722
786
|
|
|
723
787
|
//数据容错,当data都为零那么需要进行以下容错
|
|
@@ -739,19 +803,19 @@ var Current = function Current(_ref9) {
|
|
|
739
803
|
width: width,
|
|
740
804
|
height: height,
|
|
741
805
|
transform: "translate(-".concat(width / 2, "px,-").concat(height / 2, "px)"),
|
|
742
|
-
pointerEvents:
|
|
806
|
+
pointerEvents: "none"
|
|
743
807
|
},
|
|
744
808
|
boxStyle = {
|
|
745
809
|
//弹性盒子样式,用于当前值的上下居中对齐等
|
|
746
810
|
width: width,
|
|
747
811
|
height: height,
|
|
748
|
-
display:
|
|
749
|
-
flexDirection:
|
|
750
|
-
justifyContent:
|
|
751
|
-
alignItems:
|
|
812
|
+
display: "flex",
|
|
813
|
+
flexDirection: "column",
|
|
814
|
+
justifyContent: "center",
|
|
815
|
+
alignItems: "center"
|
|
752
816
|
};
|
|
753
817
|
var seriesColor = currentData.series.color;
|
|
754
|
-
seriesColor = seriesColor.type ==
|
|
818
|
+
seriesColor = seriesColor.type == "pure" ? seriesColor.pure : seriesColor.linear.stops[0].color;
|
|
755
819
|
return show && /*#__PURE__*/_react["default"].createElement("foreignObject", {
|
|
756
820
|
style: foreignStyle
|
|
757
821
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -765,33 +829,33 @@ var Current = function Current(_ref9) {
|
|
|
765
829
|
display: textOverflow == "marquee" ? "flex" : "bolck",
|
|
766
830
|
justifyContent: "center"
|
|
767
831
|
}, (0, _utils.getFontStyle)(nameFont)), {}, {
|
|
768
|
-
margin: gap / 2 +
|
|
832
|
+
margin: gap / 2 + "px 0",
|
|
769
833
|
color: nameColor ? seriesColor : nameFont.color
|
|
770
834
|
})
|
|
771
835
|
}),
|
|
772
836
|
//真实值
|
|
773
837
|
showValue && /*#__PURE__*/_react["default"].createElement("span", {
|
|
774
838
|
style: _objectSpread(_objectSpread({}, (0, _utils.getFontStyle)(valueFont)), {}, {
|
|
775
|
-
transform:
|
|
776
|
-
margin: gap / 2 +
|
|
839
|
+
transform: "translate(" + translateValueX + "px," + translateValueY + "px)",
|
|
840
|
+
margin: gap / 2 + "px 0",
|
|
777
841
|
color: valueColor ? seriesColor : valueFont.color
|
|
778
842
|
})
|
|
779
843
|
}, value, showSuffix && text && /*#__PURE__*/_react["default"].createElement("span", {
|
|
780
844
|
style: {
|
|
781
845
|
display: "inline-block",
|
|
782
|
-
transform:
|
|
846
|
+
transform: "translate(" + translateSuffixX + "px," + translateSuffixY + "px)",
|
|
783
847
|
fontSize: fontSize
|
|
784
848
|
}
|
|
785
849
|
}, text)),
|
|
786
850
|
//百分比值
|
|
787
851
|
showPercent && /*#__PURE__*/_react["default"].createElement("span", {
|
|
788
852
|
style: _objectSpread(_objectSpread({
|
|
789
|
-
transform:
|
|
853
|
+
transform: "translate(" + translatePercentX + "px," + translatePercentY + "px)"
|
|
790
854
|
}, (0, _utils.getFontStyle)(percentFont)), {}, {
|
|
791
|
-
margin: gap / 2 +
|
|
855
|
+
margin: gap / 2 + "px 0",
|
|
792
856
|
color: percentColor ? seriesColor : percentFont.color
|
|
793
857
|
})
|
|
794
|
-
}, percent +
|
|
858
|
+
}, percent + "%")));
|
|
795
859
|
};
|
|
796
860
|
var Label = function Label(_ref10) {
|
|
797
861
|
var _ref10$config = _ref10.config,
|
|
@@ -872,12 +936,12 @@ var Label = function Label(_ref10) {
|
|
|
872
936
|
return show && (_showName || showPercent || showValue) && /*#__PURE__*/_react["default"].createElement("g", {
|
|
873
937
|
key: index
|
|
874
938
|
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
875
|
-
className: animation ? _piechartModule["default"][
|
|
939
|
+
className: animation ? _piechartModule["default"]["label-line"] : "",
|
|
876
940
|
style: {
|
|
877
941
|
animationDelay: "".concat(animation ? (actualIndex + 1) * 2000 - 800 : 0, "ms")
|
|
878
942
|
},
|
|
879
|
-
d:
|
|
880
|
-
stroke: lineColor ? lineColor : type ==
|
|
943
|
+
d: "M" + x1 + ", " + y1 + "L" + x2 + ", " + y2 + "L" + x3 + ", " + y2,
|
|
944
|
+
stroke: lineColor ? lineColor : type == "pure" ? pure : stops[0].color,
|
|
881
945
|
fill: "none"
|
|
882
946
|
}), /*#__PURE__*/_react["default"].createElement("foreignObject", {
|
|
883
947
|
width: "1",
|
|
@@ -888,7 +952,7 @@ var Label = function Label(_ref10) {
|
|
|
888
952
|
overflow: "visible"
|
|
889
953
|
}
|
|
890
954
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
891
|
-
className: animation ? _piechartModule["default"][
|
|
955
|
+
className: animation ? _piechartModule["default"]["label-text"] : "",
|
|
892
956
|
style: {
|
|
893
957
|
transform: "translate(0,-50%)",
|
|
894
958
|
whiteSpace: "nowrap",
|
|
@@ -915,7 +979,7 @@ var Label = function Label(_ref10) {
|
|
|
915
979
|
}
|
|
916
980
|
}, text)), showPercent && /*#__PURE__*/_react["default"].createElement("span", {
|
|
917
981
|
style: (0, _utils.getFontStyle)(percentFont)
|
|
918
|
-
}, (_showValue ?
|
|
982
|
+
}, (_showValue ? "(" : "") + percent + "%" + (_showValue ? ")" : "")))));
|
|
919
983
|
}));
|
|
920
984
|
};
|
|
921
985
|
var RingLabel = function RingLabel(_ref12) {
|
|
@@ -997,12 +1061,12 @@ var RingLabel = function RingLabel(_ref12) {
|
|
|
997
1061
|
return show && (_showName || showPercent || _showValue) && /*#__PURE__*/_react["default"].createElement("g", {
|
|
998
1062
|
key: index
|
|
999
1063
|
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
1000
|
-
className: _piechartModule["default"][
|
|
1064
|
+
className: _piechartModule["default"]["label-line"],
|
|
1001
1065
|
style: {
|
|
1002
1066
|
animationDelay: "".concat((actualIndex + 1) * 2000 - 800, "ms")
|
|
1003
1067
|
},
|
|
1004
|
-
d:
|
|
1005
|
-
stroke: lineColor ? lineColor : type ==
|
|
1068
|
+
d: "M" + x1 + ", " + y1 + "L" + x2 + ", " + y2 + "L" + x3 + ", " + y2,
|
|
1069
|
+
stroke: lineColor ? lineColor : type == "pure" ? pure : stops[0].color,
|
|
1006
1070
|
fill: "none"
|
|
1007
1071
|
}), /*#__PURE__*/_react["default"].createElement("foreignObject", {
|
|
1008
1072
|
width: "1",
|
|
@@ -1013,7 +1077,7 @@ var RingLabel = function RingLabel(_ref12) {
|
|
|
1013
1077
|
overflow: "visible"
|
|
1014
1078
|
}
|
|
1015
1079
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
1016
|
-
className: _piechartModule["default"][
|
|
1080
|
+
className: _piechartModule["default"]["label-text"],
|
|
1017
1081
|
style: {
|
|
1018
1082
|
transform: "translate(0,-50%)",
|
|
1019
1083
|
whiteSpace: "nowrap",
|
|
@@ -1041,7 +1105,7 @@ var RingLabel = function RingLabel(_ref12) {
|
|
|
1041
1105
|
}
|
|
1042
1106
|
}, text)), showPercent && /*#__PURE__*/_react["default"].createElement("span", {
|
|
1043
1107
|
style: (0, _utils.getFontStyle)(percentFont)
|
|
1044
|
-
}, (_showValue ?
|
|
1108
|
+
}, (_showValue ? "(" : "") + percent + "%" + (_showValue ? ")" : "")))));
|
|
1045
1109
|
}));
|
|
1046
1110
|
};
|
|
1047
1111
|
var _default = (0, _.Mapping)((0, _.Carousel)(Component));
|
package/lib/components/index.js
CHANGED
|
@@ -137,6 +137,12 @@ Object.defineProperty(exports, "PieChart", {
|
|
|
137
137
|
return _PieChart["default"];
|
|
138
138
|
}
|
|
139
139
|
});
|
|
140
|
+
Object.defineProperty(exports, "PieTooltip", {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
get: function get() {
|
|
143
|
+
return _PieTooltip.PieTooltip;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
140
146
|
Object.defineProperty(exports, "StackData", {
|
|
141
147
|
enumerable: true,
|
|
142
148
|
get: function get() {
|
|
@@ -187,5 +193,6 @@ var _PieChart = _interopRequireDefault(require("./PieChart"));
|
|
|
187
193
|
var _TextOverflow = _interopRequireDefault(require("./TextOverflow"));
|
|
188
194
|
var _BaseLine = _interopRequireDefault(require("./BaseLine"));
|
|
189
195
|
var _Control = _interopRequireDefault(require("./Control"));
|
|
196
|
+
var _PieTooltip = require("./PieTooltip");
|
|
190
197
|
var Area = _Line["default"];
|
|
191
198
|
exports.Area = Area;
|