@easyv/charts 1.4.25 → 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/.babelrc +8 -8
- package/.husky/commit-msg +3 -3
- package/CHANGELOG.md +18 -18
- package/commitlint.config.js +1 -1
- package/lib/components/AnimateData.js +8 -16
- package/lib/components/Axis.js +86 -133
- package/lib/components/Background.js +18 -26
- package/lib/components/Band.js +72 -98
- package/lib/components/BaseLine.js +33 -46
- package/lib/components/Brush.js +29 -46
- package/lib/components/Carousel.js +13 -40
- package/lib/components/CartesianChart.js +98 -146
- package/lib/components/Chart.js +23 -36
- package/lib/components/ChartContainer.js +18 -27
- package/lib/components/ConicalGradient.js +56 -89
- package/lib/components/Control.js +12 -28
- package/lib/components/ExtentData.js +9 -17
- package/lib/components/FilterData.js +16 -27
- package/lib/components/Indicator.js +23 -30
- package/lib/components/Label.js +96 -126
- package/lib/components/Legend.js +41 -66
- package/lib/components/Lighter.js +21 -50
- package/lib/components/Line.js +39 -59
- package/lib/components/LinearGradient.js +16 -22
- package/lib/components/Mapping.js +9 -34
- package/lib/components/Marquee.js +14 -30
- package/lib/components/PieChart.js +457 -487
- package/lib/components/StackData.js +8 -18
- package/lib/components/StereoBar.js +65 -105
- package/lib/components/TextOverflow.js +8 -21
- package/lib/components/Tooltip.js +41 -55
- package/lib/components/index.js +7 -28
- package/lib/components/pieTooltip.js +132 -0
- package/lib/context/index.js +0 -2
- package/lib/css/index.module.css +42 -42
- package/lib/css/piechart.module.css +26 -26
- package/lib/element/ConicGradient.js +29 -35
- package/lib/element/Line.js +9 -13
- package/lib/element/index.js +0 -2
- package/lib/formatter/index.js +0 -2
- package/lib/formatter/legend.js +30 -41
- package/lib/hooks/index.js +0 -9
- package/lib/hooks/useAiData.js +12 -20
- package/lib/hooks/useAnimateData.js +8 -21
- package/lib/hooks/useAxes.js +67 -117
- package/lib/hooks/useCarouselAxisX.js +27 -60
- package/lib/hooks/useExtentData.js +14 -46
- package/lib/hooks/useFilterData.js +13 -34
- package/lib/hooks/useStackData.js +12 -35
- package/lib/hooks/useTooltip.js +36 -53
- package/lib/index.js +0 -15
- package/lib/utils/index.js +95 -247
- package/package.json +55 -55
- package/src/components/Background.tsx +61 -61
- package/src/components/Band.tsx +274 -274
- package/src/components/Brush.js +159 -159
- package/src/components/CartesianChart.js +1 -1
- package/src/components/Chart.js +99 -99
- package/src/components/ChartContainer.tsx +71 -71
- package/src/components/ConicalGradient.js +258 -258
- package/src/components/Control.jsx +51 -51
- package/src/components/ExtentData.js +17 -17
- package/src/components/Indicator.js +61 -61
- package/src/components/Label.js +275 -275
- package/src/components/Legend.js +165 -165
- package/src/components/Lighter.jsx +173 -173
- package/src/components/Line.js +150 -150
- package/src/components/LinearGradient.js +29 -29
- package/src/components/Marquee.tsx +1 -1
- package/src/components/PieChart.js +403 -260
- package/src/components/PieTooltip.jsx +134 -0
- package/src/components/StereoBar.tsx +307 -307
- package/src/components/index.js +59 -57
- package/src/context/index.js +2 -2
- package/src/css/index.module.css +42 -42
- package/src/css/piechart.module.css +26 -26
- package/src/element/ConicGradient.jsx +55 -55
- package/src/element/Line.tsx +33 -33
- package/src/element/index.ts +3 -3
- package/src/formatter/index.js +1 -1
- package/src/formatter/legend.js +92 -92
- package/src/hooks/index.js +20 -20
- package/src/hooks/useAnimateData.ts +67 -67
- package/src/hooks/useCarouselAxisX.js +1 -1
- package/src/hooks/useFilterData.js +72 -72
- package/src/hooks/useStackData.js +101 -101
- package/src/hooks/useTooltip.ts +100 -100
- package/src/index.js +6 -6
- package/src/types/index.d.ts +67 -67
- package/src/utils/index.js +757 -757
- package/tsconfig.json +23 -23
|
@@ -1,64 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = void 0;
|
|
11
|
-
|
|
12
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
15
|
-
|
|
16
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
-
|
|
18
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
-
|
|
20
13
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
21
|
-
|
|
22
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
23
|
-
|
|
24
15
|
var _ = require(".");
|
|
25
|
-
|
|
26
16
|
var _context = require("../context");
|
|
27
|
-
|
|
28
17
|
var _utils = require("../utils");
|
|
29
|
-
|
|
30
18
|
var _d3v = require("d3v7");
|
|
31
|
-
|
|
32
19
|
var _popmotion = require("popmotion");
|
|
33
|
-
|
|
34
20
|
var _LinearGradient = _interopRequireDefault(require("./LinearGradient"));
|
|
35
|
-
|
|
36
21
|
var _formatter = require("../formatter");
|
|
37
|
-
|
|
38
22
|
var _piechartModule = _interopRequireDefault(require("../css/piechart.module.css"));
|
|
39
|
-
|
|
40
23
|
var _hooks = require("../hooks");
|
|
41
|
-
|
|
24
|
+
var _PieTooltip = require("./PieTooltip");
|
|
42
25
|
var _excluded = ["startAngle", "endAngle", "antiClockwise"],
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
26
|
+
_excluded2 = ["padAngle", "innerRadius", "outerRadius", "cornerRadius", "startAngle", "endAngle"],
|
|
27
|
+
_excluded3 = ["formatter"],
|
|
28
|
+
_excluded4 = ["startAngle", "endAngle"];
|
|
29
|
+
/**
|
|
30
|
+
* 饼环图
|
|
31
|
+
*/
|
|
47
32
|
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); }
|
|
48
|
-
|
|
49
33
|
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; }
|
|
50
|
-
|
|
51
34
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
52
|
-
|
|
53
35
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
54
|
-
|
|
55
36
|
var PI = Math.PI;
|
|
56
37
|
var defaultChart = {
|
|
57
38
|
outerRadius: 1,
|
|
58
39
|
innerRadius: 0,
|
|
59
40
|
cornerRadius: 0,
|
|
60
41
|
rose: false,
|
|
61
|
-
roseType:
|
|
42
|
+
roseType: "radius",
|
|
62
43
|
baseRadius: 0,
|
|
63
44
|
padAngle: 0
|
|
64
45
|
};
|
|
@@ -67,99 +48,89 @@ var defaultAngle = {
|
|
|
67
48
|
endAngle: 360,
|
|
68
49
|
antiClockwise: false
|
|
69
50
|
};
|
|
70
|
-
|
|
71
51
|
var nameDy = function nameDy(showValue, showPercent, mode, dir) {
|
|
72
52
|
if (showValue || showPercent) {
|
|
73
|
-
if (mode ==
|
|
74
|
-
return dir == 1 ?
|
|
53
|
+
if (mode == "vertical") {
|
|
54
|
+
return dir == 1 ? "1.1em" : "-2.6em";
|
|
75
55
|
} else {
|
|
76
56
|
return 0;
|
|
77
57
|
}
|
|
78
58
|
} else {
|
|
79
|
-
if (mode ==
|
|
80
|
-
return dir * 1.1 +
|
|
59
|
+
if (mode == "vertical") {
|
|
60
|
+
return dir * 1.1 + "em";
|
|
81
61
|
} else {
|
|
82
62
|
return 0;
|
|
83
63
|
}
|
|
84
64
|
}
|
|
85
65
|
};
|
|
86
|
-
|
|
87
66
|
var valueDy = function valueDy(value1, mode, dir) {
|
|
88
67
|
if (value1) {
|
|
89
|
-
if (mode ==
|
|
90
|
-
return
|
|
68
|
+
if (mode == "vertical") {
|
|
69
|
+
return "1.5em";
|
|
91
70
|
} else {
|
|
92
71
|
return 0;
|
|
93
72
|
}
|
|
94
73
|
} else {
|
|
95
|
-
if (mode ==
|
|
96
|
-
return dir == 1 ?
|
|
74
|
+
if (mode == "vertical") {
|
|
75
|
+
return dir == 1 ? "1.1em" : "-1.1em";
|
|
97
76
|
} else {
|
|
98
77
|
return 0;
|
|
99
78
|
}
|
|
100
79
|
}
|
|
101
80
|
};
|
|
102
|
-
|
|
103
81
|
var percentDy_ = function percentDy_(showName, showValue, mode, dir) {
|
|
104
82
|
if (showValue) {
|
|
105
83
|
return 0;
|
|
106
84
|
}
|
|
107
|
-
|
|
108
85
|
if (showName) {
|
|
109
|
-
if (mode ==
|
|
110
|
-
return
|
|
86
|
+
if (mode == "vertical") {
|
|
87
|
+
return "1.5em";
|
|
111
88
|
} else {
|
|
112
89
|
return 0;
|
|
113
90
|
}
|
|
114
91
|
} else {
|
|
115
|
-
if (mode ==
|
|
116
|
-
return dir * 1.1 +
|
|
92
|
+
if (mode == "vertical") {
|
|
93
|
+
return dir * 1.1 + "em";
|
|
117
94
|
} else {
|
|
118
95
|
return 0;
|
|
119
96
|
}
|
|
120
97
|
}
|
|
121
98
|
};
|
|
122
|
-
|
|
123
99
|
var percentX = function percentX(showName, showValue, mode, x) {
|
|
124
100
|
if (showValue) {
|
|
125
|
-
return
|
|
101
|
+
return "";
|
|
126
102
|
}
|
|
127
|
-
|
|
128
103
|
if (showName) {
|
|
129
|
-
if (mode ==
|
|
104
|
+
if (mode == "vertical") {
|
|
130
105
|
return x;
|
|
131
106
|
} else {
|
|
132
|
-
return
|
|
107
|
+
return "";
|
|
133
108
|
}
|
|
134
109
|
} else {
|
|
135
110
|
return x;
|
|
136
111
|
}
|
|
137
112
|
};
|
|
138
|
-
|
|
139
113
|
var percentDx = function percentDx(showName, showValue, mode) {
|
|
140
114
|
if (showValue) {
|
|
141
|
-
return
|
|
115
|
+
return "0.5em";
|
|
142
116
|
}
|
|
143
|
-
|
|
144
117
|
if (showName) {
|
|
145
|
-
if (mode ==
|
|
118
|
+
if (mode == "vertical") {
|
|
146
119
|
return 0;
|
|
147
120
|
} else {
|
|
148
|
-
return
|
|
121
|
+
return "0.5em";
|
|
149
122
|
}
|
|
150
123
|
} else {
|
|
151
124
|
return 0;
|
|
152
125
|
}
|
|
153
126
|
};
|
|
154
|
-
|
|
155
127
|
var percentDy = function percentDy(showName, showValue, mode) {
|
|
156
128
|
if (showValue) {
|
|
157
129
|
return 0;
|
|
158
130
|
}
|
|
159
|
-
|
|
160
131
|
if (showName) {
|
|
161
|
-
if (mode ==
|
|
162
|
-
return
|
|
132
|
+
if (mode == "vertical") {
|
|
133
|
+
return "1.5em";
|
|
163
134
|
} else {
|
|
164
135
|
return 0;
|
|
165
136
|
}
|
|
@@ -167,36 +138,31 @@ var percentDy = function percentDy(showName, showValue, mode) {
|
|
|
167
138
|
return 0;
|
|
168
139
|
}
|
|
169
140
|
};
|
|
170
|
-
|
|
171
141
|
var valueDx = function valueDx(showName, mode) {
|
|
172
142
|
if (!showName) {
|
|
173
|
-
return
|
|
143
|
+
return "";
|
|
174
144
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return '';
|
|
145
|
+
if (mode == "vertical") {
|
|
146
|
+
return "";
|
|
178
147
|
} else {
|
|
179
|
-
return
|
|
148
|
+
return "0.5em";
|
|
180
149
|
}
|
|
181
150
|
};
|
|
182
|
-
|
|
183
151
|
var getCoord = function getCoord(deg, radius) {
|
|
184
152
|
var x = Math.cos(deg) * radius,
|
|
185
|
-
|
|
153
|
+
y = Math.sin(deg) * radius;
|
|
186
154
|
return [x, y];
|
|
187
155
|
};
|
|
188
|
-
|
|
189
156
|
var getRoseRadius = function getRoseRadius(_ref) {
|
|
190
157
|
var innerRadius = _ref.innerRadius,
|
|
191
|
-
|
|
158
|
+
baseRadius = _ref.baseRadius;
|
|
192
159
|
return innerRadius + (1 - innerRadius) * baseRadius;
|
|
193
160
|
};
|
|
194
|
-
|
|
195
161
|
var getAngle = function getAngle(_ref2) {
|
|
196
162
|
var startAngle = _ref2.startAngle,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
163
|
+
endAngle = _ref2.endAngle,
|
|
164
|
+
antiClockwise = _ref2.antiClockwise,
|
|
165
|
+
rest = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
|
|
200
166
|
if (antiClockwise) return _objectSpread(_objectSpread({}, rest), {}, {
|
|
201
167
|
startAngle: endAngle - 180,
|
|
202
168
|
endAngle: startAngle - 180
|
|
@@ -206,26 +172,25 @@ var getAngle = function getAngle(_ref2) {
|
|
|
206
172
|
endAngle: endAngle
|
|
207
173
|
});
|
|
208
174
|
};
|
|
209
|
-
|
|
210
175
|
var getArc = function getArc(radius, _ref3, series_, index) {
|
|
211
176
|
var _ref3$padAngle = _ref3.padAngle,
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
177
|
+
padAngle = _ref3$padAngle === void 0 ? 0 : _ref3$padAngle,
|
|
178
|
+
_ref3$innerRadius = _ref3.innerRadius,
|
|
179
|
+
innerRadius = _ref3$innerRadius === void 0 ? 0 : _ref3$innerRadius,
|
|
180
|
+
_ref3$outerRadius = _ref3.outerRadius,
|
|
181
|
+
outerRadius = _ref3$outerRadius === void 0 ? 1 : _ref3$outerRadius,
|
|
182
|
+
_ref3$cornerRadius = _ref3.cornerRadius,
|
|
183
|
+
cornerRadius = _ref3$cornerRadius === void 0 ? 0 : _ref3$cornerRadius,
|
|
184
|
+
_ref3$startAngle = _ref3.startAngle,
|
|
185
|
+
startAngle = _ref3$startAngle === void 0 ? 0 : _ref3$startAngle,
|
|
186
|
+
_ref3$endAngle = _ref3.endAngle,
|
|
187
|
+
endAngle = _ref3$endAngle === void 0 ? 360 : _ref3$endAngle,
|
|
188
|
+
rest = (0, _objectWithoutProperties2["default"])(_ref3, _excluded2);
|
|
224
189
|
var series = series_.find(function (s) {
|
|
225
190
|
return s.fieldName == rest.data.s;
|
|
226
191
|
}) || series_[index % series_.length];
|
|
227
192
|
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
228
|
-
type:
|
|
193
|
+
type: "pie",
|
|
229
194
|
fieldName: series.fieldName,
|
|
230
195
|
displayName: series.displayName || rest.data.s,
|
|
231
196
|
series: series,
|
|
@@ -234,33 +199,28 @@ var getArc = function getArc(radius, _ref3, series_, index) {
|
|
|
234
199
|
arc: (0, _d3v.arc)().innerRadius(innerRadius * radius).outerRadius(outerRadius * radius).cornerRadius(cornerRadius).startAngle(startAngle).endAngle(endAngle).padAngle(padAngle)
|
|
235
200
|
});
|
|
236
201
|
};
|
|
237
|
-
|
|
238
202
|
var getCircleScale = function getCircleScale() {
|
|
239
203
|
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : tick,
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
204
|
+
count = _ref4.count,
|
|
205
|
+
color = _ref4.color,
|
|
206
|
+
width = _ref4.width,
|
|
207
|
+
length = _ref4.length;
|
|
245
208
|
var radius = arguments.length > 1 ? arguments[1] : undefined;
|
|
246
209
|
var data = [],
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
210
|
+
arcs = [],
|
|
211
|
+
centroids = [];
|
|
250
212
|
for (var i = 0; i < count; i++) {
|
|
251
213
|
data.push(1);
|
|
252
214
|
}
|
|
253
|
-
|
|
254
215
|
var scaleData = (0, _d3v.pie)()(data);
|
|
255
216
|
scaleData.map(function (data) {
|
|
256
217
|
var _arc = (0, _d3v.arc)().innerRadius(radius + length / 2).outerRadius(radius + length / 2).startAngle(data.startAngle).endAngle(data.endAngle);
|
|
257
|
-
|
|
258
218
|
arcs.push(_arc());
|
|
259
219
|
centroids.push(_arc.centroid());
|
|
260
220
|
});
|
|
261
221
|
return /*#__PURE__*/_react["default"].createElement("g", null, centroids.map(function (center, index) {
|
|
262
222
|
var x = center[0],
|
|
263
|
-
|
|
223
|
+
y = center[1];
|
|
264
224
|
var rate = length / Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
|
|
265
225
|
return /*#__PURE__*/_react["default"].createElement("path", {
|
|
266
226
|
key: index,
|
|
@@ -270,67 +230,69 @@ var getCircleScale = function getCircleScale() {
|
|
|
270
230
|
});
|
|
271
231
|
}));
|
|
272
232
|
};
|
|
273
|
-
|
|
274
233
|
var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
275
234
|
var _ref5$config = _ref5.config,
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
235
|
+
_ref5$config$chart = _ref5$config.chart,
|
|
236
|
+
_ref5$config$chart$di = _ref5$config$chart.dimension.chartDimension,
|
|
237
|
+
width = _ref5$config$chart$di.width,
|
|
238
|
+
height = _ref5$config$chart$di.height,
|
|
239
|
+
label = _ref5$config$chart.label,
|
|
240
|
+
_ref5$config$chart$le = _ref5$config$chart.legend,
|
|
241
|
+
_ref5$config$chart$le2 = _ref5$config$chart$le.formatter,
|
|
242
|
+
formatter = _ref5$config$chart$le2 === void 0 ? _formatter.pieLegendFormatter : _ref5$config$chart$le2,
|
|
243
|
+
legend = (0, _objectWithoutProperties2["default"])(_ref5$config$chart$le, _excluded3),
|
|
244
|
+
_ref5$config$chart$ma = _ref5$config$chart.margin,
|
|
245
|
+
marginLeft = _ref5$config$chart$ma.marginLeft,
|
|
246
|
+
marginTop = _ref5$config$chart$ma.marginTop,
|
|
247
|
+
_ref5$config$fan = _ref5$config.fan,
|
|
248
|
+
_ref5$config$fan2 = _ref5$config$fan === void 0 ? {} : _ref5$config$fan,
|
|
249
|
+
_ref5$config$fan2$cha = _ref5$config$fan2.chart,
|
|
250
|
+
chart = _ref5$config$fan2$cha === void 0 ? defaultChart : _ref5$config$fan2$cha,
|
|
251
|
+
_ref5$config$fan2$cha2 = _ref5$config$fan2.chart,
|
|
252
|
+
_ref5$config$fan2$cha3 = _ref5$config$fan2$cha2.outerRadius,
|
|
253
|
+
outerRadius = _ref5$config$fan2$cha3 === void 0 ? defaultChart.outerRadius : _ref5$config$fan2$cha3,
|
|
254
|
+
padAngle = _ref5$config$fan2$cha2.padAngle,
|
|
255
|
+
_ref5$config$fan2$ang = _ref5$config$fan2.angle,
|
|
256
|
+
angle = _ref5$config$fan2$ang === void 0 ? defaultAngle : _ref5$config$fan2$ang,
|
|
257
|
+
_ref5$config$fan2$str = _ref5$config$fan2.stroke,
|
|
258
|
+
_ref5$config$fan2$str2 = _ref5$config$fan2$str === void 0 ? {
|
|
259
|
+
show: false
|
|
260
|
+
} : _ref5$config$fan2$str,
|
|
261
|
+
show = _ref5$config$fan2$str2.show,
|
|
262
|
+
strokeWidth = _ref5$config$fan2$str2.strokeWidth,
|
|
263
|
+
color = _ref5$config$fan2$str2.color,
|
|
264
|
+
decorate = _ref5$config$fan2.decorate,
|
|
265
|
+
decorate2 = _ref5$config$fan2.decorate2,
|
|
266
|
+
categoryText = _ref5$config$fan2.categoryText,
|
|
267
|
+
outerDecorate = _ref5$config$fan2.outerDecorate,
|
|
268
|
+
current = _ref5$config$fan2.current,
|
|
269
|
+
order = _ref5$config.order,
|
|
270
|
+
series = _ref5$config.series,
|
|
271
|
+
_ref5$config$animatio = _ref5$config.animation,
|
|
272
|
+
on = _ref5$config$animatio.on,
|
|
273
|
+
_ref5$config$animatio2 = _ref5$config$animatio.current,
|
|
274
|
+
_ref5$config$animatio3 = _ref5$config$animatio2.heighten,
|
|
275
|
+
heighten = _ref5$config$animatio3 === void 0 ? 0 : _ref5$config$animatio3,
|
|
276
|
+
_ref5$config$animatio4 = _ref5$config$animatio2.opacity,
|
|
277
|
+
opacity = _ref5$config$animatio4 === void 0 ? 0 : _ref5$config$animatio4,
|
|
278
|
+
_ref5$config$animatio5 = _ref5$config$animatio2.width,
|
|
279
|
+
radiusWidthAdd = _ref5$config$animatio5 === void 0 ? 0 : _ref5$config$animatio5,
|
|
280
|
+
animateColor = _ref5$config$animatio2.color,
|
|
281
|
+
animateCTS = _ref5$config$animatio2.textStyle,
|
|
282
|
+
_ref5$config$animatio6 = _ref5$config$animatio2.gap,
|
|
283
|
+
gap = _ref5$config$animatio6 === void 0 ? 0 : _ref5$config$animatio6,
|
|
284
|
+
_ref5$config$animatio7 = _ref5$config$animatio.rotate,
|
|
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,
|
|
289
|
+
_ref5$state = _ref5.state,
|
|
290
|
+
currentIndex = _ref5$state.currentIndex,
|
|
291
|
+
trigger = _ref5$state.trigger,
|
|
292
|
+
onEvent = _ref5.onEvent,
|
|
293
|
+
hoverEvent = _ref5.hoverEvent,
|
|
294
|
+
_ref5$data = _ref5.data,
|
|
295
|
+
originData = _ref5$data === void 0 ? [] : _ref5$data;
|
|
334
296
|
var data = originData.map(function (d) {
|
|
335
297
|
return _objectSpread(_objectSpread({}, d), {}, {
|
|
336
298
|
y: d.y < 0 ? 0 : d.y
|
|
@@ -338,111 +300,96 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
338
300
|
});
|
|
339
301
|
var prevIndex = (0, _react.useRef)(null);
|
|
340
302
|
var legendPrecision = legend.config.percent.precision;
|
|
341
|
-
|
|
342
303
|
var _useContext = (0, _react.useContext)(_context.chartContext),
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
304
|
+
id = _useContext.id,
|
|
305
|
+
chartWidth = _useContext.width,
|
|
306
|
+
chartHeight = _useContext.height,
|
|
307
|
+
triggerOnRelative = _useContext.triggerOnRelative,
|
|
308
|
+
onEmit = _useContext.onEmit;
|
|
349
309
|
var _useState = (0, _react.useState)(1),
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
310
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
311
|
+
y = _useState2[0],
|
|
312
|
+
setY = _useState2[1];
|
|
354
313
|
var radius = Math.min(chartWidth, chartHeight) / 2 * outerRadius;
|
|
355
314
|
var arcsFunc = (0, _react.useMemo)(function () {
|
|
356
315
|
var _getAngle = getAngle(angle),
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
316
|
+
_getAngle$startAngle = _getAngle.startAngle,
|
|
317
|
+
startAngle = _getAngle$startAngle === void 0 ? 0 : _getAngle$startAngle,
|
|
318
|
+
_getAngle$endAngle = _getAngle.endAngle,
|
|
319
|
+
endAngle = _getAngle$endAngle === void 0 ? 360 : _getAngle$endAngle;
|
|
362
320
|
var arcsFunc = (0, _d3v.pie)().startAngle(startAngle * PI / 180).endAngle(endAngle * PI / 180).value(function (d) {
|
|
363
321
|
return d.y;
|
|
364
322
|
});
|
|
365
323
|
return arcsFunc;
|
|
366
|
-
}, [angle]);
|
|
367
|
-
|
|
324
|
+
}, [angle]);
|
|
325
|
+
//此处创建arcsFuncTwo的原因是为了兼容数据全为零
|
|
368
326
|
var arcsFuncTwo = (0, _react.useMemo)(function () {
|
|
369
327
|
var _getAngle2 = getAngle(angle),
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
328
|
+
_getAngle2$startAngle = _getAngle2.startAngle,
|
|
329
|
+
startAngle = _getAngle2$startAngle === void 0 ? 0 : _getAngle2$startAngle,
|
|
330
|
+
_getAngle2$endAngle = _getAngle2.endAngle,
|
|
331
|
+
endAngle = _getAngle2$endAngle === void 0 ? 360 : _getAngle2$endAngle;
|
|
375
332
|
var arcsFunc = (0, _d3v.pie)().startAngle(startAngle * PI / 180).endAngle(endAngle * PI / 180).value(function (d) {
|
|
376
333
|
return d.y == 0 ? 1 : d.y;
|
|
377
334
|
});
|
|
378
335
|
return arcsFunc;
|
|
379
336
|
}, [angle]);
|
|
380
337
|
var judgeData = 0; //此处声明全局变量是为了父子组件传递值来判断数据是否都为零
|
|
381
|
-
|
|
382
338
|
var arcs = (0, _react.useMemo)(function () {
|
|
383
339
|
var _chart = Object.assign(defaultChart, chart);
|
|
384
|
-
|
|
385
340
|
var innerRadius = _chart.innerRadius,
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
341
|
+
outerRadius = _chart.outerRadius,
|
|
342
|
+
rose = _chart.rose,
|
|
343
|
+
cornerRadius = _chart.cornerRadius,
|
|
344
|
+
padAngle = _chart.padAngle,
|
|
345
|
+
roseType = _chart.roseType;
|
|
392
346
|
var _padAngle = padAngle * Math.PI / 180;
|
|
393
|
-
|
|
394
347
|
switch (order) {
|
|
395
|
-
case
|
|
348
|
+
case "":
|
|
396
349
|
arcsFunc.sort(null);
|
|
397
350
|
break;
|
|
398
|
-
|
|
399
|
-
case 'desc':
|
|
351
|
+
case "desc":
|
|
400
352
|
arcsFunc.sort(function (a, b) {
|
|
401
353
|
return b.y - a.y;
|
|
402
354
|
});
|
|
403
355
|
break;
|
|
404
|
-
|
|
405
|
-
case 'asc':
|
|
356
|
+
case "asc":
|
|
406
357
|
arcsFunc.sort(function (a, b) {
|
|
407
358
|
return a.y - b.y;
|
|
408
359
|
});
|
|
409
360
|
break;
|
|
410
|
-
}
|
|
361
|
+
}
|
|
411
362
|
|
|
363
|
+
//此处判断data中的y是否都为零,方便饼图都为零时展示
|
|
412
364
|
|
|
413
365
|
var arcs = 0;
|
|
414
366
|
data.forEach(function (item) {
|
|
415
367
|
judgeData += item.y;
|
|
416
368
|
});
|
|
417
|
-
|
|
418
369
|
if (judgeData == 0) {
|
|
419
370
|
arcs = arcsFuncTwo(data);
|
|
420
371
|
} else {
|
|
421
372
|
arcs = arcsFunc(data);
|
|
422
|
-
}
|
|
423
|
-
|
|
373
|
+
}
|
|
424
374
|
|
|
375
|
+
//const arcs = arcsFunc(data); 此处是原本的传输饼图data流程
|
|
425
376
|
var legendDataWithPercent = (0, _utils.getDataWithPercent)(arcs, legendPrecision);
|
|
426
|
-
|
|
427
377
|
var _legendDataWithPercent = (0, _utils.sortPie)(legendDataWithPercent, order);
|
|
428
|
-
|
|
429
378
|
if (rose) {
|
|
430
379
|
var domain = (0, _d3v.extent)(_legendDataWithPercent, function (d) {
|
|
431
380
|
return d.value;
|
|
432
381
|
});
|
|
433
382
|
var roseRadius = getRoseRadius(_chart);
|
|
434
383
|
var scaler = (0, _d3v.scaleLinear)().domain(domain).range([roseRadius, 1]);
|
|
435
|
-
|
|
436
384
|
var _angle = PI * 2 / _legendDataWithPercent.length;
|
|
437
|
-
|
|
438
385
|
return _legendDataWithPercent.map(function (_ref6, index) {
|
|
439
386
|
var startAngle = _ref6.startAngle,
|
|
440
|
-
|
|
441
|
-
|
|
387
|
+
endAngle = _ref6.endAngle,
|
|
388
|
+
arc = (0, _objectWithoutProperties2["default"])(_ref6, _excluded4);
|
|
442
389
|
return _objectSpread(_objectSpread({}, arc), {}, {
|
|
443
|
-
id: id +
|
|
444
|
-
startAngle: roseType ==
|
|
445
|
-
endAngle: roseType ==
|
|
390
|
+
id: id + "_linear_" + index,
|
|
391
|
+
startAngle: roseType == "area" ? _angle * index : startAngle,
|
|
392
|
+
endAngle: roseType == "area" ? _angle * (index + 1) : endAngle,
|
|
446
393
|
cornerRadius: cornerRadius,
|
|
447
394
|
padAngle: _padAngle,
|
|
448
395
|
innerRadius: innerRadius,
|
|
@@ -450,10 +397,9 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
450
397
|
});
|
|
451
398
|
});
|
|
452
399
|
}
|
|
453
|
-
|
|
454
400
|
return _legendDataWithPercent.map(function (arc, index) {
|
|
455
401
|
return _objectSpread(_objectSpread({}, arc), {}, {
|
|
456
|
-
id: id +
|
|
402
|
+
id: id + "_linear_" + index,
|
|
457
403
|
cornerRadius: cornerRadius,
|
|
458
404
|
padAngle: _padAngle,
|
|
459
405
|
innerRadius: innerRadius,
|
|
@@ -461,40 +407,42 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
461
407
|
});
|
|
462
408
|
});
|
|
463
409
|
}, [data, arcsFunc, arcsFuncTwo, chart, legendPrecision, order]);
|
|
464
|
-
|
|
465
410
|
var _arcs = (0, _react.useMemo)(function () {
|
|
466
411
|
var seriesLength = series.size;
|
|
467
412
|
if (!seriesLength) return [];
|
|
468
|
-
|
|
469
413
|
var _series = (0, _toConsumableArray2["default"])(series.values());
|
|
470
|
-
|
|
471
414
|
if (_series.length < arcs.length) console.warn("请检查数据中是否存在相同的s");
|
|
472
415
|
return arcs.map(function (arc, index) {
|
|
473
416
|
return getArc(radius, arc, _series, index);
|
|
474
417
|
});
|
|
475
418
|
}, [series, arcs, radius]);
|
|
476
|
-
|
|
477
419
|
var onClick = (0, _react.useCallback)(function (e) {
|
|
478
420
|
return onEvent({
|
|
479
421
|
currentIndex: +e.currentTarget.dataset.index,
|
|
480
|
-
type:
|
|
422
|
+
type: "onClick"
|
|
481
423
|
});
|
|
482
424
|
}, [onEvent]);
|
|
483
425
|
var onMouseEnter = (0, _react.useCallback)(function (e) {
|
|
484
|
-
|
|
426
|
+
var _data = arcs[+currentIndex].data;
|
|
427
|
+
triggerOnRelative(_data);
|
|
428
|
+
onEmit("onMouseEnter", _data);
|
|
429
|
+
onEvent({
|
|
485
430
|
currentIndex: +e.currentTarget.dataset.index,
|
|
486
|
-
type:
|
|
431
|
+
type: "onMouseEnter"
|
|
487
432
|
});
|
|
488
|
-
}, [onEvent]);
|
|
433
|
+
}, [onEvent, triggerOnRelative, onEmit]);
|
|
489
434
|
var onMouseLeave = (0, _react.useCallback)(function (e) {
|
|
490
|
-
|
|
435
|
+
setMousePos({
|
|
436
|
+
x: 0,
|
|
437
|
+
y: 0
|
|
438
|
+
});
|
|
439
|
+
onEvent({
|
|
491
440
|
currentIndex: +e.currentTarget.dataset.index,
|
|
492
|
-
type:
|
|
441
|
+
type: "onMouseLeave"
|
|
493
442
|
});
|
|
494
443
|
}, [onEvent]);
|
|
495
444
|
(0, _react.useLayoutEffect)(function () {
|
|
496
445
|
var animation;
|
|
497
|
-
|
|
498
446
|
if (!!on) {
|
|
499
447
|
animation = (0, _popmotion.animate)({
|
|
500
448
|
from: 0,
|
|
@@ -508,17 +456,16 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
508
456
|
onComplete: function onComplete() {
|
|
509
457
|
var _data = arcs[+currentIndex].data;
|
|
510
458
|
triggerOnRelative(_data);
|
|
511
|
-
onEmit(
|
|
459
|
+
onEmit("carousel", _data);
|
|
512
460
|
}
|
|
513
461
|
});
|
|
514
462
|
} else {
|
|
515
|
-
if (currentIndex !== null && trigger ===
|
|
463
|
+
if (currentIndex !== null && trigger === "onClick") {
|
|
516
464
|
var _data = arcs[+currentIndex].data;
|
|
517
465
|
triggerOnRelative(_data);
|
|
518
466
|
onEmit(trigger, _data);
|
|
519
467
|
}
|
|
520
468
|
}
|
|
521
|
-
|
|
522
469
|
return function () {
|
|
523
470
|
prevIndex.current = currentIndex;
|
|
524
471
|
animation && animation.stop();
|
|
@@ -531,14 +478,12 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
531
478
|
if (!window.aiData) {
|
|
532
479
|
window.aiData = {};
|
|
533
480
|
}
|
|
534
|
-
|
|
535
481
|
window.aiData[id] = {
|
|
536
482
|
getAI: function getAI() {
|
|
537
483
|
return aiData;
|
|
538
484
|
}
|
|
539
485
|
};
|
|
540
486
|
}
|
|
541
|
-
|
|
542
487
|
return function () {
|
|
543
488
|
window.aiData && window.aiData[id] && delete window.aiData[id];
|
|
544
489
|
};
|
|
@@ -547,24 +492,36 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
547
492
|
var halfChartHeight = chartHeight / 2;
|
|
548
493
|
var rotate_ = decorate2 ? -(arcs[+currentIndex].startAngle + arcs[+currentIndex].endAngle) * 90 / Math.PI + rotate : 0;
|
|
549
494
|
var maxRadius = 0;
|
|
550
|
-
|
|
551
495
|
_arcs.map(function (d) {
|
|
552
496
|
maxRadius = Math.max(maxRadius, d.outerRadius);
|
|
553
497
|
});
|
|
554
|
-
|
|
555
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);
|
|
556
511
|
return outerDecorate ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_.ChartContainer //用于生成甜甜圈图,判断依据是外环装饰这个配置项(outerDecorate)
|
|
557
512
|
, {
|
|
558
513
|
width: width,
|
|
559
514
|
height: height,
|
|
560
515
|
marginLeft: marginLeft,
|
|
561
|
-
marginTop: marginTop
|
|
516
|
+
marginTop: marginTop,
|
|
517
|
+
ref: pieWarpEl
|
|
562
518
|
}, /*#__PURE__*/_react["default"].createElement("g", {
|
|
563
519
|
style: {
|
|
564
|
-
transition:
|
|
565
|
-
transform:
|
|
520
|
+
transition: "transform ease-in-out 0.3s",
|
|
521
|
+
transform: "translate(" + halfChartWidth + "px, " + halfChartHeight + "px) rotate(" + rotate_ + "deg)"
|
|
566
522
|
}
|
|
567
|
-
},
|
|
523
|
+
},
|
|
524
|
+
//用于生成外环装饰的刻度
|
|
568
525
|
outerDecorate.tick.show && getCircleScale(outerDecorate.tick, maxRadius), /*#__PURE__*/_react["default"].createElement("circle", {
|
|
569
526
|
//外环装饰
|
|
570
527
|
cx: "0",
|
|
@@ -575,11 +532,11 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
575
532
|
strokeWidth: outerDecorate.width
|
|
576
533
|
}), _arcs.map(function (_ref7, index) {
|
|
577
534
|
var id = _ref7.id,
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
535
|
+
value = _ref7.value,
|
|
536
|
+
series = _ref7.series,
|
|
537
|
+
arc = _ref7.arc,
|
|
538
|
+
innerRadius = _ref7.innerRadius,
|
|
539
|
+
outerRadius = _ref7.outerRadius;
|
|
583
540
|
var arcWidth = outerRadius - innerRadius;
|
|
584
541
|
var path = arc.innerRadius(centerRadius).outerRadius(centerRadius)(value);
|
|
585
542
|
var dashLength = Math.ceil(Math.PI * centerRadius * 2 / _arcs.length);
|
|
@@ -587,7 +544,7 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
587
544
|
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, {
|
|
588
545
|
key: index
|
|
589
546
|
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
590
|
-
className: _piechartModule["default"][
|
|
547
|
+
className: _piechartModule["default"]["inner-arc"],
|
|
591
548
|
style: {
|
|
592
549
|
strokeDasharray: "".concat(dashLength, ",").concat(2 * dashLength),
|
|
593
550
|
strokeDashoffset: dashLength,
|
|
@@ -597,15 +554,27 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
597
554
|
onClick: onClick,
|
|
598
555
|
onMouseEnter: onMouseEnter,
|
|
599
556
|
onMouseLeave: onMouseLeave,
|
|
600
|
-
|
|
601
|
-
|
|
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 + ")",
|
|
602
571
|
strokeWidth: arcWidth,
|
|
603
572
|
fill: "none"
|
|
604
573
|
}), /*#__PURE__*/_react["default"].createElement("defs", null, /*#__PURE__*/_react["default"].createElement(_LinearGradient["default"], {
|
|
605
574
|
id: id,
|
|
606
575
|
colors: pie,
|
|
607
|
-
rotate: series.color.linear.angle + 180
|
|
608
|
-
|
|
576
|
+
rotate: series.color.linear.angle + 180
|
|
577
|
+
// gradientUnits='objectBoundingBox'
|
|
609
578
|
})));
|
|
610
579
|
}), label && /*#__PURE__*/_react["default"].createElement(RingLabel, {
|
|
611
580
|
config: _objectSpread(_objectSpread({}, label), {}, {
|
|
@@ -613,7 +582,16 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
613
582
|
}),
|
|
614
583
|
arcs: _arcs,
|
|
615
584
|
judge: judgeData
|
|
616
|
-
}))), /*#__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, {
|
|
617
595
|
series: _arcs,
|
|
618
596
|
formatter: formatter,
|
|
619
597
|
judge: judgeData
|
|
@@ -627,20 +605,21 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
627
605
|
},
|
|
628
606
|
onMouseLeave: function onMouseLeave() {
|
|
629
607
|
hoverEvent(false);
|
|
630
|
-
}
|
|
608
|
+
},
|
|
609
|
+
ref: pieWarpEl
|
|
631
610
|
}, /*#__PURE__*/_react["default"].createElement("g", {
|
|
632
611
|
style: {
|
|
633
|
-
transition:
|
|
634
|
-
transform:
|
|
612
|
+
transition: "transform ease-in-out 0.3s",
|
|
613
|
+
transform: "translate(" + halfChartWidth + "px, " + halfChartHeight + "px) rotate(" + rotate_ + "deg)"
|
|
635
614
|
}
|
|
636
615
|
}, _arcs.map(function (_ref8, index) {
|
|
637
616
|
var id = _ref8.id,
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
617
|
+
value = _ref8.value,
|
|
618
|
+
series = _ref8.series,
|
|
619
|
+
arc = _ref8.arc,
|
|
620
|
+
innerRadius = _ref8.innerRadius,
|
|
621
|
+
outerRadius = _ref8.outerRadius,
|
|
622
|
+
dataIndex = _ref8.index;
|
|
644
623
|
var current = index == currentIndex;
|
|
645
624
|
var prev = index == prevIndex.current;
|
|
646
625
|
var offset = current ? y : prev ? 1 - y : 0;
|
|
@@ -649,16 +628,14 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
649
628
|
var path = arc.innerRadius(innerRadius + deltaHeighten).outerRadius(outerRadius + deltaHeighten)(value);
|
|
650
629
|
var pie = (0, _utils.getColorList)(series.color);
|
|
651
630
|
var currentPie = animateColor ? (0, _utils.getColorList)(animateColor) : (0, _utils.getColorList)(series.color);
|
|
652
|
-
var textPath =
|
|
653
|
-
|
|
654
|
-
|
|
631
|
+
var textPath = "",
|
|
632
|
+
categoryTextStyle = {};
|
|
655
633
|
if (categoryText && categoryText.show) {
|
|
656
634
|
//如果有类目文本,则需要计算文字路径
|
|
657
635
|
//let offsetWidth=decorate2.radiusWidth/2 + radiusWidthAdd/2; //当前文字需生成在装饰物内,故而半径需要减小
|
|
658
636
|
var textArc = arc.innerRadius(outerRadius + (current ? gap : categoryText.gap)).outerRadius(outerRadius + (current ? gap : categoryText.gap))(value);
|
|
659
|
-
var lastA = textArc.lastIndexOf(
|
|
637
|
+
var lastA = textArc.lastIndexOf("A");
|
|
660
638
|
textPath = textArc.slice(0, lastA > 0 ? lastA : textArc.length); //文字路径
|
|
661
|
-
|
|
662
639
|
categoryTextStyle = current ? animateCTS : categoryText.textStyle; //这里把textstyle拿出来
|
|
663
640
|
}
|
|
664
641
|
|
|
@@ -669,47 +646,61 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
669
646
|
onClick: onClick,
|
|
670
647
|
onMouseEnter: onMouseEnter,
|
|
671
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
|
+
},
|
|
672
661
|
d: path,
|
|
673
|
-
stroke: show ? color :
|
|
674
|
-
strokeWidth: show ? strokeWidth :
|
|
675
|
-
fill:
|
|
662
|
+
stroke: show ? color : "none",
|
|
663
|
+
strokeWidth: show ? strokeWidth : "0",
|
|
664
|
+
fill: "url(#" + id + ")",
|
|
676
665
|
fillOpacity: fillOpacity
|
|
677
|
-
}),
|
|
666
|
+
}),
|
|
667
|
+
//装饰物2,产生于每个弧的外部
|
|
678
668
|
decorate2 && decorate2.show && /*#__PURE__*/_react["default"].createElement("path", {
|
|
679
669
|
"data-index": index,
|
|
680
670
|
onClick: onClick,
|
|
681
671
|
onMouseEnter: onMouseEnter,
|
|
682
672
|
onMouseLeave: onMouseLeave,
|
|
683
673
|
d: arc.innerRadius(outerRadius).outerRadius(outerRadius + decorate2.radiusWidth + (current ? radiusWidthAdd : 0))(value),
|
|
684
|
-
stroke: show ? color :
|
|
685
|
-
strokeWidth: show ? strokeWidth :
|
|
686
|
-
fill:
|
|
674
|
+
stroke: show ? color : "none",
|
|
675
|
+
strokeWidth: show ? strokeWidth : "0",
|
|
676
|
+
fill: "url(#" + id + ")",
|
|
687
677
|
fillOpacity: decorate2.opacity / 100
|
|
688
|
-
}),
|
|
678
|
+
}),
|
|
679
|
+
//类目文本
|
|
689
680
|
value && categoryText && categoryText.show && /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("path", {
|
|
690
681
|
onClick: onClick,
|
|
691
682
|
onMouseEnter: onMouseEnter,
|
|
692
683
|
onMouseLeave: onMouseLeave,
|
|
693
|
-
id: id +
|
|
684
|
+
id: id + "_text_" + index,
|
|
694
685
|
d: textPath,
|
|
695
686
|
fill: "none",
|
|
696
687
|
stroke: "none"
|
|
697
688
|
}), /*#__PURE__*/_react["default"].createElement("text", {
|
|
698
689
|
textAnchor: "middle",
|
|
699
690
|
style: _objectSpread(_objectSpread({}, categoryTextStyle), {}, {
|
|
700
|
-
fontWeight: categoryTextStyle.bold ?
|
|
701
|
-
fontStyle: categoryTextStyle.italic ?
|
|
702
|
-
pointerEvents:
|
|
691
|
+
fontWeight: categoryTextStyle.bold ? "bold" : "normal",
|
|
692
|
+
fontStyle: categoryTextStyle.italic ? "italic" : "normal",
|
|
693
|
+
pointerEvents: "none"
|
|
703
694
|
}),
|
|
704
695
|
fill: categoryTextStyle.color
|
|
705
696
|
}, /*#__PURE__*/_react["default"].createElement("textPath", {
|
|
706
697
|
startOffset: "50%",
|
|
707
|
-
href:
|
|
698
|
+
href: "#" + id + "_text_" + index
|
|
708
699
|
}, _arcs[index].displayName || _arcs[index].fieldName))), /*#__PURE__*/_react["default"].createElement("defs", null, /*#__PURE__*/_react["default"].createElement(_LinearGradient["default"], {
|
|
709
700
|
id: id,
|
|
710
701
|
colors: current ? currentPie : pie,
|
|
711
|
-
rotate: current ? animateColor ? animateColor.linear.angle + 180 : series.color.linear.angle + 180 : series.color.linear.angle + 180
|
|
712
|
-
|
|
702
|
+
rotate: current ? animateColor ? animateColor.linear.angle + 180 : series.color.linear.angle + 180 : series.color.linear.angle + 180
|
|
703
|
+
// gradientUnits='objectBoundingBox'
|
|
713
704
|
})));
|
|
714
705
|
}), label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
715
706
|
config: label,
|
|
@@ -718,7 +709,7 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
718
709
|
}), current && /*#__PURE__*/_react["default"].createElement("g", {
|
|
719
710
|
fillOpacity: y,
|
|
720
711
|
style: {
|
|
721
|
-
transform:
|
|
712
|
+
transform: "rotate(" + -rotate_ + "deg)"
|
|
722
713
|
}
|
|
723
714
|
}, /*#__PURE__*/_react["default"].createElement(Current, {
|
|
724
715
|
config: current,
|
|
@@ -735,90 +726,96 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
|
735
726
|
config: decorate,
|
|
736
727
|
arcs: _arcs,
|
|
737
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
|
|
738
738
|
}), /*#__PURE__*/_react["default"].createElement(_.Legend, (0, _extends2["default"])({}, legend, {
|
|
739
739
|
series: _arcs,
|
|
740
740
|
formatter: formatter,
|
|
741
741
|
judge: judgeData
|
|
742
742
|
})));
|
|
743
743
|
});
|
|
744
|
-
|
|
745
744
|
var Current = function Current(_ref9) {
|
|
746
745
|
var _ref9$config = _ref9.config,
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
746
|
+
show = _ref9$config.show,
|
|
747
|
+
gap = _ref9$config.gap,
|
|
748
|
+
_ref9$config$name = _ref9$config.name,
|
|
749
|
+
showName = _ref9$config$name.show,
|
|
750
|
+
nameColor = _ref9$config$name.sameColor,
|
|
751
|
+
nameFont = _ref9$config$name.font,
|
|
752
|
+
maxWidth = _ref9$config$name.maxWidth,
|
|
753
|
+
textOverflow = _ref9$config$name.textOverflow,
|
|
754
|
+
speed = _ref9$config$name.speed,
|
|
755
|
+
_ref9$config$percent = _ref9$config.percent,
|
|
756
|
+
showPercent = _ref9$config$percent.show,
|
|
757
|
+
percentColor = _ref9$config$percent.sameColor,
|
|
758
|
+
percentFont = _ref9$config$percent.font,
|
|
759
|
+
precision = _ref9$config$percent.precision,
|
|
760
|
+
_ref9$config$percent$ = _ref9$config$percent.translate,
|
|
761
|
+
translatePercentX = _ref9$config$percent$.x,
|
|
762
|
+
translatePercentY = _ref9$config$percent$.y,
|
|
763
|
+
_ref9$config$value = _ref9$config.value,
|
|
764
|
+
showValue = _ref9$config$value.show,
|
|
765
|
+
valueColor = _ref9$config$value.sameColor,
|
|
766
|
+
valueFont = _ref9$config$value.font,
|
|
767
|
+
_ref9$config$value$tr = _ref9$config$value.translate,
|
|
768
|
+
translateValueX = _ref9$config$value$tr.x,
|
|
769
|
+
translateValueY = _ref9$config$value$tr.y,
|
|
770
|
+
_ref9$config$value$su = _ref9$config$value.suffix,
|
|
771
|
+
showSuffix = _ref9$config$value$su.show,
|
|
772
|
+
fontSize = _ref9$config$value$su.fontSize,
|
|
773
|
+
text = _ref9$config$value$su.text,
|
|
774
|
+
_ref9$config$value$su2 = _ref9$config$value$su.translate,
|
|
775
|
+
translateSuffixX = _ref9$config$value$su2.x,
|
|
776
|
+
translateSuffixY = _ref9$config$value$su2.y,
|
|
777
|
+
width = _ref9.width,
|
|
778
|
+
height = _ref9.height,
|
|
779
|
+
data = _ref9.data,
|
|
780
|
+
judge = _ref9.judge,
|
|
781
|
+
currentIndex = _ref9.currentIndex;
|
|
784
782
|
var _data = (0, _react.useMemo)(function () {
|
|
785
783
|
var legendDataWithPercent = (0, _utils.getDataWithPercent)(data, precision);
|
|
786
|
-
return (0, _utils.sortPie)(legendDataWithPercent,
|
|
787
|
-
}, [data, precision]);
|
|
788
|
-
|
|
784
|
+
return (0, _utils.sortPie)(legendDataWithPercent, "");
|
|
785
|
+
}, [data, precision]);
|
|
789
786
|
|
|
787
|
+
//数据容错,当data都为零那么需要进行以下容错
|
|
790
788
|
if (judge == 0) {
|
|
791
789
|
_data.forEach(function (d) {
|
|
792
790
|
d.percent = 0, d.value = 0;
|
|
793
791
|
});
|
|
794
792
|
}
|
|
795
|
-
|
|
796
793
|
var currentData = _data[currentIndex];
|
|
797
794
|
if (!currentData) return null;
|
|
798
795
|
var displayName = currentData.displayName,
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
796
|
+
fieldName = currentData.fieldName,
|
|
797
|
+
value = currentData.value,
|
|
798
|
+
percent = currentData.percent;
|
|
802
799
|
var nameTemp = displayName ? displayName : fieldName; //类目名
|
|
803
800
|
|
|
804
801
|
var foreignStyle = {
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
802
|
+
//foreignObject标签样式,
|
|
803
|
+
width: width,
|
|
804
|
+
height: height,
|
|
805
|
+
transform: "translate(-".concat(width / 2, "px,-").concat(height / 2, "px)"),
|
|
806
|
+
pointerEvents: "none"
|
|
807
|
+
},
|
|
808
|
+
boxStyle = {
|
|
809
|
+
//弹性盒子样式,用于当前值的上下居中对齐等
|
|
810
|
+
width: width,
|
|
811
|
+
height: height,
|
|
812
|
+
display: "flex",
|
|
813
|
+
flexDirection: "column",
|
|
814
|
+
justifyContent: "center",
|
|
815
|
+
alignItems: "center"
|
|
816
|
+
};
|
|
820
817
|
var seriesColor = currentData.series.color;
|
|
821
|
-
seriesColor = seriesColor.type ==
|
|
818
|
+
seriesColor = seriesColor.type == "pure" ? seriesColor.pure : seriesColor.linear.stops[0].color;
|
|
822
819
|
return show && /*#__PURE__*/_react["default"].createElement("foreignObject", {
|
|
823
820
|
style: foreignStyle
|
|
824
821
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -832,131 +829,119 @@ var Current = function Current(_ref9) {
|
|
|
832
829
|
display: textOverflow == "marquee" ? "flex" : "bolck",
|
|
833
830
|
justifyContent: "center"
|
|
834
831
|
}, (0, _utils.getFontStyle)(nameFont)), {}, {
|
|
835
|
-
margin: gap / 2 +
|
|
832
|
+
margin: gap / 2 + "px 0",
|
|
836
833
|
color: nameColor ? seriesColor : nameFont.color
|
|
837
834
|
})
|
|
838
|
-
}),
|
|
835
|
+
}),
|
|
836
|
+
//真实值
|
|
839
837
|
showValue && /*#__PURE__*/_react["default"].createElement("span", {
|
|
840
838
|
style: _objectSpread(_objectSpread({}, (0, _utils.getFontStyle)(valueFont)), {}, {
|
|
841
|
-
transform:
|
|
842
|
-
margin: gap / 2 +
|
|
839
|
+
transform: "translate(" + translateValueX + "px," + translateValueY + "px)",
|
|
840
|
+
margin: gap / 2 + "px 0",
|
|
843
841
|
color: valueColor ? seriesColor : valueFont.color
|
|
844
842
|
})
|
|
845
843
|
}, value, showSuffix && text && /*#__PURE__*/_react["default"].createElement("span", {
|
|
846
844
|
style: {
|
|
847
845
|
display: "inline-block",
|
|
848
|
-
transform:
|
|
846
|
+
transform: "translate(" + translateSuffixX + "px," + translateSuffixY + "px)",
|
|
849
847
|
fontSize: fontSize
|
|
850
848
|
}
|
|
851
|
-
}, text)),
|
|
849
|
+
}, text)),
|
|
850
|
+
//百分比值
|
|
852
851
|
showPercent && /*#__PURE__*/_react["default"].createElement("span", {
|
|
853
852
|
style: _objectSpread(_objectSpread({
|
|
854
|
-
transform:
|
|
853
|
+
transform: "translate(" + translatePercentX + "px," + translatePercentY + "px)"
|
|
855
854
|
}, (0, _utils.getFontStyle)(percentFont)), {}, {
|
|
856
|
-
margin: gap / 2 +
|
|
855
|
+
margin: gap / 2 + "px 0",
|
|
857
856
|
color: percentColor ? seriesColor : percentFont.color
|
|
858
857
|
})
|
|
859
|
-
}, percent +
|
|
858
|
+
}, percent + "%")));
|
|
860
859
|
};
|
|
861
|
-
|
|
862
860
|
var Label = function Label(_ref10) {
|
|
863
861
|
var _ref10$config = _ref10.config,
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
862
|
+
_ref10$config$maxRadi = _ref10$config.maxRadius,
|
|
863
|
+
maxRadius = _ref10$config$maxRadi === void 0 ? 0 : _ref10$config$maxRadi,
|
|
864
|
+
lineLength = _ref10$config.lineLength,
|
|
865
|
+
lineColor = _ref10$config.lineColor,
|
|
866
|
+
distance = _ref10$config.distance,
|
|
867
|
+
mode = _ref10$config.mode,
|
|
868
|
+
show = _ref10$config.show,
|
|
869
|
+
_ref10$config$transla = _ref10$config.translate,
|
|
870
|
+
translateX = _ref10$config$transla.x,
|
|
871
|
+
translateY = _ref10$config$transla.y,
|
|
872
|
+
_ref10$config$name = _ref10$config.name,
|
|
873
|
+
showName = _ref10$config$name.show,
|
|
874
|
+
nameFont = _ref10$config$name.font,
|
|
875
|
+
maxWidth = _ref10$config$name.maxWidth,
|
|
876
|
+
textOverflow = _ref10$config$name.textOverflow,
|
|
877
|
+
speed = _ref10$config$name.speed,
|
|
878
|
+
_ref10$config$value = _ref10$config.value,
|
|
879
|
+
showValue = _ref10$config$value.show,
|
|
880
|
+
valueFont = _ref10$config$value.font,
|
|
881
|
+
_ref10$config$value$s = _ref10$config$value.suffix,
|
|
882
|
+
showSuffix = _ref10$config$value$s.show,
|
|
883
|
+
text = _ref10$config$value$s.text,
|
|
884
|
+
suffixFontSize = _ref10$config$value$s.fontSize,
|
|
885
|
+
_ref10$config$value$s2 = _ref10$config$value$s.translate,
|
|
886
|
+
suffixTranslateX = _ref10$config$value$s2.x,
|
|
887
|
+
suffixTranslateY = _ref10$config$value$s2.y,
|
|
888
|
+
_ref10$config$percent = _ref10$config.percent,
|
|
889
|
+
showPercent = _ref10$config$percent.show,
|
|
890
|
+
percentFont = _ref10$config$percent.font,
|
|
891
|
+
precision = _ref10$config$percent.precision,
|
|
892
|
+
arcs = _ref10.arcs,
|
|
893
|
+
judge = _ref10.judge,
|
|
894
|
+
animation = _ref10.animation;
|
|
898
895
|
var _arcs = (0, _react.useMemo)(function () {
|
|
899
896
|
return (0, _utils.getDataWithPercent)(arcs, precision);
|
|
900
|
-
}, [arcs, precision]);
|
|
901
|
-
|
|
902
|
-
|
|
897
|
+
}, [arcs, precision]);
|
|
898
|
+
//数据做出容错
|
|
903
899
|
if (judge == 0) {
|
|
904
900
|
_arcs.forEach(function (d) {
|
|
905
901
|
d.percent = 0;
|
|
906
902
|
});
|
|
907
903
|
}
|
|
908
|
-
|
|
909
904
|
return /*#__PURE__*/_react["default"].createElement("g", null, _arcs.map(function (_ref11, index) {
|
|
910
905
|
var _ref11$series$color = _ref11.series.color,
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
906
|
+
type = _ref11$series$color.type,
|
|
907
|
+
pure = _ref11$series$color.pure,
|
|
908
|
+
stops = _ref11$series$color.linear.stops,
|
|
909
|
+
data = _ref11.data,
|
|
910
|
+
displayName = _ref11.displayName,
|
|
911
|
+
value = _ref11.value,
|
|
912
|
+
percent = _ref11.percent,
|
|
913
|
+
arc = _ref11.arc,
|
|
914
|
+
outerRadius = _ref11.outerRadius,
|
|
915
|
+
actualIndex = _ref11.index;
|
|
922
916
|
var _arc$centroid = arc.centroid(),
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
917
|
+
_arc$centroid2 = (0, _slicedToArray2["default"])(_arc$centroid, 2),
|
|
918
|
+
x = _arc$centroid2[0],
|
|
919
|
+
y = _arc$centroid2[1];
|
|
927
920
|
var midAngle = Math.atan2(y, x);
|
|
928
|
-
|
|
929
921
|
var _getCoord = getCoord(midAngle, maxRadius ? maxRadius : outerRadius),
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
922
|
+
_getCoord2 = (0, _slicedToArray2["default"])(_getCoord, 2),
|
|
923
|
+
x1 = _getCoord2[0],
|
|
924
|
+
y1 = _getCoord2[1];
|
|
934
925
|
var radius = (maxRadius ? maxRadius : outerRadius) + distance;
|
|
935
|
-
|
|
936
926
|
var _getCoord3 = getCoord(midAngle, radius),
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
927
|
+
_getCoord4 = (0, _slicedToArray2["default"])(_getCoord3, 2),
|
|
928
|
+
x2 = _getCoord4[0],
|
|
929
|
+
y2 = _getCoord4[1];
|
|
941
930
|
var direction = x2 < 0 ? -1 : 1;
|
|
942
931
|
var x3 = x2 + lineLength * direction;
|
|
943
|
-
|
|
944
932
|
var _x = x3 + (translateX + 6) * direction;
|
|
945
|
-
|
|
946
933
|
var _showName = showName && displayName;
|
|
947
|
-
|
|
948
934
|
var _showValue = showValue && (value || showSuffix);
|
|
949
|
-
|
|
950
935
|
var nameStyle = (0, _utils.getFontStyle)(nameFont);
|
|
951
936
|
return show && (_showName || showPercent || showValue) && /*#__PURE__*/_react["default"].createElement("g", {
|
|
952
937
|
key: index
|
|
953
938
|
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
954
|
-
className: animation ? _piechartModule["default"][
|
|
939
|
+
className: animation ? _piechartModule["default"]["label-line"] : "",
|
|
955
940
|
style: {
|
|
956
941
|
animationDelay: "".concat(animation ? (actualIndex + 1) * 2000 - 800 : 0, "ms")
|
|
957
942
|
},
|
|
958
|
-
d:
|
|
959
|
-
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,
|
|
960
945
|
fill: "none"
|
|
961
946
|
}), /*#__PURE__*/_react["default"].createElement("foreignObject", {
|
|
962
947
|
width: "1",
|
|
@@ -967,7 +952,7 @@ var Label = function Label(_ref10) {
|
|
|
967
952
|
overflow: "visible"
|
|
968
953
|
}
|
|
969
954
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
970
|
-
className: animation ? _piechartModule["default"][
|
|
955
|
+
className: animation ? _piechartModule["default"]["label-text"] : "",
|
|
971
956
|
style: {
|
|
972
957
|
transform: "translate(0,-50%)",
|
|
973
958
|
whiteSpace: "nowrap",
|
|
@@ -994,107 +979,94 @@ var Label = function Label(_ref10) {
|
|
|
994
979
|
}
|
|
995
980
|
}, text)), showPercent && /*#__PURE__*/_react["default"].createElement("span", {
|
|
996
981
|
style: (0, _utils.getFontStyle)(percentFont)
|
|
997
|
-
}, (_showValue ?
|
|
982
|
+
}, (_showValue ? "(" : "") + percent + "%" + (_showValue ? ")" : "")))));
|
|
998
983
|
}));
|
|
999
984
|
};
|
|
1000
|
-
|
|
1001
985
|
var RingLabel = function RingLabel(_ref12) {
|
|
1002
986
|
var _ref12$config = _ref12.config,
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
987
|
+
_ref12$config$maxRadi = _ref12$config.maxRadius,
|
|
988
|
+
maxRadius = _ref12$config$maxRadi === void 0 ? 0 : _ref12$config$maxRadi,
|
|
989
|
+
lineLength = _ref12$config.lineLength,
|
|
990
|
+
lineColor = _ref12$config.lineColor,
|
|
991
|
+
distance = _ref12$config.distance,
|
|
992
|
+
mode = _ref12$config.mode,
|
|
993
|
+
show = _ref12$config.show,
|
|
994
|
+
_ref12$config$transla = _ref12$config.translate,
|
|
995
|
+
translateX = _ref12$config$transla.x,
|
|
996
|
+
translateY = _ref12$config$transla.y,
|
|
997
|
+
_ref12$config$name = _ref12$config.name,
|
|
998
|
+
showName = _ref12$config$name.show,
|
|
999
|
+
nameFont = _ref12$config$name.font,
|
|
1000
|
+
maxWidth = _ref12$config$name.maxWidth,
|
|
1001
|
+
textOverflow = _ref12$config$name.textOverflow,
|
|
1002
|
+
speed = _ref12$config$name.speed,
|
|
1003
|
+
_ref12$config$value = _ref12$config.value,
|
|
1004
|
+
showValue = _ref12$config$value.show,
|
|
1005
|
+
valueFont = _ref12$config$value.font,
|
|
1006
|
+
_ref12$config$value$s = _ref12$config$value.suffix,
|
|
1007
|
+
showSuffix = _ref12$config$value$s.show,
|
|
1008
|
+
text = _ref12$config$value$s.text,
|
|
1009
|
+
suffixFontSize = _ref12$config$value$s.fontSize,
|
|
1010
|
+
_ref12$config$value$s2 = _ref12$config$value$s.translate,
|
|
1011
|
+
suffixTranslateX = _ref12$config$value$s2.x,
|
|
1012
|
+
suffixTranslateY = _ref12$config$value$s2.y,
|
|
1013
|
+
_ref12$config$percent = _ref12$config.percent,
|
|
1014
|
+
showPercent = _ref12$config$percent.show,
|
|
1015
|
+
percentFont = _ref12$config$percent.font,
|
|
1016
|
+
precision = _ref12$config$percent.precision,
|
|
1017
|
+
judge = _ref12.judge,
|
|
1018
|
+
arcs = _ref12.arcs;
|
|
1036
1019
|
var _arcs = (0, _react.useMemo)(function () {
|
|
1037
1020
|
return (0, _utils.getDataWithPercent)(arcs, precision);
|
|
1038
|
-
}, [arcs, precision]);
|
|
1039
|
-
|
|
1021
|
+
}, [arcs, precision]);
|
|
1040
1022
|
|
|
1023
|
+
//数据做出容错
|
|
1041
1024
|
if (judge == 0) {
|
|
1042
1025
|
_arcs.forEach(function (d) {
|
|
1043
1026
|
d.percent = 0;
|
|
1044
1027
|
});
|
|
1045
1028
|
}
|
|
1046
|
-
|
|
1047
1029
|
return /*#__PURE__*/_react["default"].createElement("g", null, _arcs.map(function (_ref13, index) {
|
|
1048
1030
|
var _ref13$series$color = _ref13.series.color,
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1031
|
+
type = _ref13$series$color.type,
|
|
1032
|
+
pure = _ref13$series$color.pure,
|
|
1033
|
+
stops = _ref13$series$color.linear.stops,
|
|
1034
|
+
realData = _ref13.data,
|
|
1035
|
+
displayName = _ref13.displayName,
|
|
1036
|
+
value = _ref13.value,
|
|
1037
|
+
percent = _ref13.percent,
|
|
1038
|
+
arc = _ref13.arc,
|
|
1039
|
+
outerRadius = _ref13.outerRadius,
|
|
1040
|
+
actualIndex = _ref13.index;
|
|
1060
1041
|
var _arc$centroid3 = arc.centroid(),
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1042
|
+
_arc$centroid4 = (0, _slicedToArray2["default"])(_arc$centroid3, 2),
|
|
1043
|
+
x = _arc$centroid4[0],
|
|
1044
|
+
y = _arc$centroid4[1];
|
|
1065
1045
|
var midAngle = Math.atan2(y, x);
|
|
1066
|
-
|
|
1067
1046
|
var _getCoord5 = getCoord(midAngle, maxRadius ? maxRadius : outerRadius),
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1047
|
+
_getCoord6 = (0, _slicedToArray2["default"])(_getCoord5, 2),
|
|
1048
|
+
x1 = _getCoord6[0],
|
|
1049
|
+
y1 = _getCoord6[1];
|
|
1072
1050
|
var radius = (maxRadius ? maxRadius : outerRadius) + distance;
|
|
1073
|
-
|
|
1074
1051
|
var _getCoord7 = getCoord(midAngle, radius),
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1052
|
+
_getCoord8 = (0, _slicedToArray2["default"])(_getCoord7, 2),
|
|
1053
|
+
x2 = _getCoord8[0],
|
|
1054
|
+
y2 = _getCoord8[1];
|
|
1079
1055
|
var directionX = x2 < 0 ? -1 : 1;
|
|
1080
1056
|
var directionY = y2 < 0 ? -1 : 1;
|
|
1081
1057
|
var x3 = x2 + lineLength * directionX;
|
|
1082
|
-
|
|
1083
1058
|
var _x = x3 + (translateX + 6) * directionX;
|
|
1084
|
-
|
|
1085
1059
|
var _showName = showName && displayName;
|
|
1086
|
-
|
|
1087
1060
|
var _showValue = showValue && (value || showSuffix);
|
|
1088
|
-
|
|
1089
1061
|
return show && (_showName || showPercent || _showValue) && /*#__PURE__*/_react["default"].createElement("g", {
|
|
1090
1062
|
key: index
|
|
1091
1063
|
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
1092
|
-
className: _piechartModule["default"][
|
|
1064
|
+
className: _piechartModule["default"]["label-line"],
|
|
1093
1065
|
style: {
|
|
1094
1066
|
animationDelay: "".concat((actualIndex + 1) * 2000 - 800, "ms")
|
|
1095
1067
|
},
|
|
1096
|
-
d:
|
|
1097
|
-
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,
|
|
1098
1070
|
fill: "none"
|
|
1099
1071
|
}), /*#__PURE__*/_react["default"].createElement("foreignObject", {
|
|
1100
1072
|
width: "1",
|
|
@@ -1105,7 +1077,7 @@ var RingLabel = function RingLabel(_ref12) {
|
|
|
1105
1077
|
overflow: "visible"
|
|
1106
1078
|
}
|
|
1107
1079
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
1108
|
-
className: _piechartModule["default"][
|
|
1080
|
+
className: _piechartModule["default"]["label-text"],
|
|
1109
1081
|
style: {
|
|
1110
1082
|
transform: "translate(0,-50%)",
|
|
1111
1083
|
whiteSpace: "nowrap",
|
|
@@ -1133,10 +1105,8 @@ var RingLabel = function RingLabel(_ref12) {
|
|
|
1133
1105
|
}
|
|
1134
1106
|
}, text)), showPercent && /*#__PURE__*/_react["default"].createElement("span", {
|
|
1135
1107
|
style: (0, _utils.getFontStyle)(percentFont)
|
|
1136
|
-
}, (_showValue ?
|
|
1108
|
+
}, (_showValue ? "(" : "") + percent + "%" + (_showValue ? ")" : "")))));
|
|
1137
1109
|
}));
|
|
1138
1110
|
};
|
|
1139
|
-
|
|
1140
1111
|
var _default = (0, _.Mapping)((0, _.Carousel)(Component));
|
|
1141
|
-
|
|
1142
1112
|
exports["default"] = _default;
|