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