@easyv/charts 1.0.44 → 1.0.48
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/lib/components/AnimateData.js +2 -2
- package/lib/components/Axis.js +12 -12
- package/lib/components/Background.js +2 -2
- package/lib/components/Carousel.js +4 -2
- package/lib/components/Chart.js +2 -2
- package/lib/components/ConicalGradient.js +21 -21
- package/lib/components/Indicator.js +2 -2
- package/lib/components/Label.js +1 -1
- package/lib/components/LinearGradient.js +2 -2
- package/lib/components/PieChart.js +326 -139
- package/lib/css/index.module.css +42 -42
- package/lib/css/piechart.module.css +27 -0
- package/lib/formatter/legend.js +3 -2
- package/lib/hooks/useAnimateData.js +5 -5
- package/lib/hooks/useAxes.js +5 -5
- package/lib/hooks/useCarouselAxisX.js +5 -5
- package/lib/hooks/useExtentData.js +6 -6
- package/lib/hooks/useFilterData.js +5 -5
- package/lib/hooks/useStackData.js +5 -5
- package/lib/hooks/useTooltip.js +10 -10
- package/lib/utils/index.js +1 -1
- package/package.json +34 -34
- package/src/components/AnimateData.tsx +24 -24
- package/src/components/Axis.tsx +333 -333
- package/src/components/Background.tsx +45 -45
- package/src/components/Band.tsx +160 -160
- package/src/components/Brush.js +159 -159
- package/src/components/Carousel.tsx +144 -142
- package/src/components/Chart.js +99 -101
- package/src/components/ChartContainer.tsx +63 -63
- package/src/components/ConicalGradient.js +258 -258
- package/src/components/ExtentData.js +17 -17
- package/src/components/FilterData.js +23 -23
- package/src/components/Indicator.js +13 -13
- package/src/components/Label.js +194 -194
- package/src/components/Legend.js +158 -158
- package/src/components/Lighter.jsx +162 -162
- package/src/components/Line.js +126 -126
- package/src/components/LinearGradient.js +29 -29
- package/src/components/Mapping.js +71 -72
- package/src/components/PieChart.js +876 -709
- package/src/components/StackData.js +20 -20
- package/src/components/StereoBar.tsx +298 -298
- package/src/components/Tooltip.js +116 -116
- package/src/components/index.js +49 -49
- package/src/context/index.js +2 -2
- package/src/css/index.module.css +42 -42
- package/src/css/piechart.module.css +27 -0
- 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 +87 -87
- package/src/hooks/index.js +17 -17
- package/src/hooks/useAnimateData.ts +62 -62
- package/src/hooks/useAxes.js +143 -143
- package/src/hooks/useCarouselAxisX.js +163 -163
- package/src/hooks/useExtentData.js +88 -88
- package/src/hooks/useFilterData.js +65 -65
- package/src/hooks/useStackData.js +100 -100
- package/src/hooks/useTooltip.ts +96 -96
- package/src/index.js +6 -6
- package/src/types/index.d.ts +59 -59
- package/src/utils/index.js +640 -641
- package/tsconfig.json +22 -22
|
@@ -35,6 +35,8 @@ var _LinearGradient = _interopRequireDefault(require("./LinearGradient"));
|
|
|
35
35
|
|
|
36
36
|
var _formatter = require("../formatter");
|
|
37
37
|
|
|
38
|
+
var _piechartModule = _interopRequireDefault(require("../css/piechart.module.css"));
|
|
39
|
+
|
|
38
40
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
39
41
|
|
|
40
42
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -167,50 +169,100 @@ var getArc = function getArc(radius, _ref3, series) {
|
|
|
167
169
|
});
|
|
168
170
|
};
|
|
169
171
|
|
|
170
|
-
var
|
|
171
|
-
var _ref4
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
width = _ref4
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
var
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
172
|
+
var getCircleScale = function getCircleScale() {
|
|
173
|
+
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : tick,
|
|
174
|
+
count = _ref4.count,
|
|
175
|
+
color = _ref4.color,
|
|
176
|
+
width = _ref4.width,
|
|
177
|
+
length = _ref4.length;
|
|
178
|
+
|
|
179
|
+
var radius = arguments.length > 1 ? arguments[1] : undefined;
|
|
180
|
+
var data = [],
|
|
181
|
+
arcs = [],
|
|
182
|
+
centroids = [];
|
|
183
|
+
|
|
184
|
+
for (var i = 0; i < count; i++) {
|
|
185
|
+
data.push(1);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
var scaleData = (0, _d3v.pie)()(data);
|
|
189
|
+
scaleData.map(function (data) {
|
|
190
|
+
var _arc = (0, _d3v.arc)().innerRadius(radius + length / 2).outerRadius(radius + length / 2).startAngle(data.startAngle).endAngle(data.endAngle);
|
|
191
|
+
|
|
192
|
+
arcs.push(_arc());
|
|
193
|
+
centroids.push(_arc.centroid());
|
|
194
|
+
});
|
|
195
|
+
return /*#__PURE__*/_react["default"].createElement("g", null, centroids.map(function (center, index) {
|
|
196
|
+
var x = center[0],
|
|
197
|
+
y = center[1];
|
|
198
|
+
var rate = length / Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
|
|
199
|
+
return /*#__PURE__*/_react["default"].createElement("path", {
|
|
200
|
+
key: index,
|
|
201
|
+
d: "M".concat(x, ",").concat(y, "l").concat(x * rate, ",").concat(y * rate),
|
|
202
|
+
strokeWidth: width,
|
|
203
|
+
stroke: color
|
|
204
|
+
});
|
|
205
|
+
}));
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
|
|
209
|
+
var _ref5$config = _ref5.config,
|
|
210
|
+
_ref5$config$chart = _ref5$config.chart,
|
|
211
|
+
_ref5$config$chart$di = _ref5$config$chart.dimension.chartDimension,
|
|
212
|
+
width = _ref5$config$chart$di.width,
|
|
213
|
+
height = _ref5$config$chart$di.height,
|
|
214
|
+
label = _ref5$config$chart.label,
|
|
215
|
+
_ref5$config$chart$le = _ref5$config$chart.legend,
|
|
216
|
+
_ref5$config$chart$le2 = _ref5$config$chart$le.formatter,
|
|
217
|
+
formatter = _ref5$config$chart$le2 === void 0 ? _formatter.pieLegendFormatter : _ref5$config$chart$le2,
|
|
218
|
+
legend = (0, _objectWithoutProperties2["default"])(_ref5$config$chart$le, ["formatter"]),
|
|
219
|
+
_ref5$config$chart$ma = _ref5$config$chart.margin,
|
|
220
|
+
marginLeft = _ref5$config$chart$ma.marginLeft,
|
|
221
|
+
marginTop = _ref5$config$chart$ma.marginTop,
|
|
222
|
+
_ref5$config$fan = _ref5$config.fan;
|
|
223
|
+
_ref5$config$fan = _ref5$config$fan === void 0 ? {} : _ref5$config$fan;
|
|
224
|
+
var _ref5$config$fan$char = _ref5$config$fan.chart,
|
|
225
|
+
chart = _ref5$config$fan$char === void 0 ? defaultChart : _ref5$config$fan$char,
|
|
226
|
+
_ref5$config$fan$char2 = _ref5$config$fan.chart,
|
|
227
|
+
_ref5$config$fan$char3 = _ref5$config$fan$char2.outerRadius,
|
|
228
|
+
outerRadius = _ref5$config$fan$char3 === void 0 ? defaultChart.outerRadius : _ref5$config$fan$char3,
|
|
229
|
+
padAngle = _ref5$config$fan$char2.padAngle,
|
|
230
|
+
_ref5$config$fan$angl = _ref5$config$fan.angle,
|
|
231
|
+
angle = _ref5$config$fan$angl === void 0 ? defaultAngle : _ref5$config$fan$angl,
|
|
232
|
+
_ref5$config$fan$stro = _ref5$config$fan.stroke;
|
|
233
|
+
_ref5$config$fan$stro = _ref5$config$fan$stro === void 0 ? {
|
|
194
234
|
show: false
|
|
195
|
-
} :
|
|
196
|
-
var show =
|
|
197
|
-
strokeWidth =
|
|
198
|
-
color =
|
|
199
|
-
decorate =
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
235
|
+
} : _ref5$config$fan$stro;
|
|
236
|
+
var show = _ref5$config$fan$stro.show,
|
|
237
|
+
strokeWidth = _ref5$config$fan$stro.strokeWidth,
|
|
238
|
+
color = _ref5$config$fan$stro.color,
|
|
239
|
+
decorate = _ref5$config$fan.decorate,
|
|
240
|
+
decorate2 = _ref5$config$fan.decorate2,
|
|
241
|
+
categoryText = _ref5$config$fan.categoryText,
|
|
242
|
+
outerDecorate = _ref5$config$fan.outerDecorate,
|
|
243
|
+
current = _ref5$config$fan.current,
|
|
244
|
+
order = _ref5$config.order,
|
|
245
|
+
series = _ref5$config.series,
|
|
246
|
+
_ref5$config$animatio = _ref5$config.animation,
|
|
247
|
+
on = _ref5$config$animatio.on,
|
|
248
|
+
_ref5$config$animatio2 = _ref5$config$animatio.current,
|
|
249
|
+
_ref5$config$animatio3 = _ref5$config$animatio2.heighten,
|
|
250
|
+
heighten = _ref5$config$animatio3 === void 0 ? 0 : _ref5$config$animatio3,
|
|
251
|
+
_ref5$config$animatio4 = _ref5$config$animatio2.opacity,
|
|
252
|
+
opacity = _ref5$config$animatio4 === void 0 ? 0 : _ref5$config$animatio4,
|
|
253
|
+
_ref5$config$animatio5 = _ref5$config$animatio2.width,
|
|
254
|
+
radiusWidthAdd = _ref5$config$animatio5 === void 0 ? 0 : _ref5$config$animatio5,
|
|
255
|
+
animateColor = _ref5$config$animatio2.color,
|
|
256
|
+
_ref5$config$animatio6 = _ref5$config$animatio2.gap,
|
|
257
|
+
gap = _ref5$config$animatio6 === void 0 ? 0 : _ref5$config$animatio6,
|
|
258
|
+
_ref5$config$animatio7 = _ref5$config$animatio.rotate,
|
|
259
|
+
rotate = _ref5$config$animatio7 === void 0 ? 0 : _ref5$config$animatio7,
|
|
260
|
+
_ref5$state = _ref5.state,
|
|
261
|
+
currentIndex = _ref5$state.currentIndex,
|
|
262
|
+
trigger = _ref5$state.trigger,
|
|
263
|
+
onEvent = _ref5.onEvent,
|
|
264
|
+
_ref5$data = _ref5.data,
|
|
265
|
+
data = _ref5$data === void 0 ? [] : _ref5$data;
|
|
214
266
|
var prevIndex = (0, _react.useRef)(null);
|
|
215
267
|
var legendPrecision = legend.config.percent.precision;
|
|
216
268
|
|
|
@@ -283,10 +335,10 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref4) {
|
|
|
283
335
|
|
|
284
336
|
var _angle = PI * 2 / _legendDataWithPercent.length;
|
|
285
337
|
|
|
286
|
-
return _legendDataWithPercent.map(function (
|
|
287
|
-
var startAngle =
|
|
288
|
-
endAngle =
|
|
289
|
-
arc = (0, _objectWithoutProperties2["default"])(
|
|
338
|
+
return _legendDataWithPercent.map(function (_ref6, index) {
|
|
339
|
+
var startAngle = _ref6.startAngle,
|
|
340
|
+
endAngle = _ref6.endAngle,
|
|
341
|
+
arc = (0, _objectWithoutProperties2["default"])(_ref6, ["startAngle", "endAngle"]);
|
|
290
342
|
return _objectSpread(_objectSpread({}, arc), {}, {
|
|
291
343
|
id: id + '_linear_' + index,
|
|
292
344
|
startAngle: roseType == 'area' ? _angle * index : startAngle,
|
|
@@ -374,28 +426,117 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref4) {
|
|
|
374
426
|
}, [JSON.stringify(arcs), on, currentIndex, trigger, onEmit, triggerOnRelative]);
|
|
375
427
|
var halfChartWidth = chartWidth / 2;
|
|
376
428
|
var halfChartHeight = chartHeight / 2;
|
|
377
|
-
|
|
429
|
+
var rotate_ = decorate2 ? -(arcs[+currentIndex].startAngle + arcs[+currentIndex].endAngle) * 90 / Math.PI + rotate : 0;
|
|
430
|
+
var maxRadius = 0;
|
|
431
|
+
|
|
432
|
+
_arcs.map(function (d) {
|
|
433
|
+
maxRadius = Math.max(maxRadius, d.outerRadius);
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
var centerRadius = 0.5 * maxRadius + 0.5 * _arcs[0].innerRadius;
|
|
437
|
+
return outerDecorate ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_.ChartContainer //用于生成甜甜圈图,判断依据是外环装饰这个配置项(outerDecorate)
|
|
438
|
+
, {
|
|
378
439
|
width: width,
|
|
379
440
|
height: height,
|
|
380
441
|
marginLeft: marginLeft,
|
|
381
442
|
marginTop: marginTop
|
|
382
443
|
}, /*#__PURE__*/_react["default"].createElement("g", {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
444
|
+
style: {
|
|
445
|
+
transition: "transform ease-in-out 0.3s",
|
|
446
|
+
transform: 'translate(' + halfChartWidth + 'px, ' + halfChartHeight + 'px) rotate(' + rotate_ + "deg)"
|
|
447
|
+
}
|
|
448
|
+
}, //用于生成外环装饰的刻度
|
|
449
|
+
outerDecorate.tick.show && getCircleScale(outerDecorate.tick, maxRadius), /*#__PURE__*/_react["default"].createElement("circle", {
|
|
450
|
+
//外环装饰
|
|
451
|
+
cx: "0",
|
|
452
|
+
cy: "0",
|
|
453
|
+
r: maxRadius + 2,
|
|
454
|
+
fill: "none",
|
|
455
|
+
stroke: outerDecorate.color,
|
|
456
|
+
strokeWidth: outerDecorate.width
|
|
457
|
+
}), _arcs.map(function (_ref7, index) {
|
|
458
|
+
var id = _ref7.id,
|
|
459
|
+
value = _ref7.value,
|
|
460
|
+
series = _ref7.series,
|
|
461
|
+
arc = _ref7.arc,
|
|
462
|
+
innerRadius = _ref7.innerRadius,
|
|
463
|
+
outerRadius = _ref7.outerRadius,
|
|
464
|
+
dataIndex = _ref7.index;
|
|
465
|
+
var arcWidth = outerRadius - innerRadius;
|
|
466
|
+
var path = arc.innerRadius(centerRadius).outerRadius(centerRadius)(value);
|
|
467
|
+
var dashLength = Math.ceil(Math.PI * centerRadius * 2 / _arcs.length);
|
|
468
|
+
var pie = (0, _utils.getColorList)(series.color);
|
|
469
|
+
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, {
|
|
470
|
+
key: index
|
|
471
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
472
|
+
className: _piechartModule["default"]['inner-arc'],
|
|
473
|
+
style: {
|
|
474
|
+
strokeDasharray: "".concat(dashLength, ",").concat(2 * dashLength),
|
|
475
|
+
strokeDashoffset: dashLength,
|
|
476
|
+
animationDelay: "".concat(index * 2000, "ms")
|
|
477
|
+
},
|
|
478
|
+
"data-index": dataIndex,
|
|
479
|
+
onClick: onClick,
|
|
480
|
+
onMouseEnter: onMouseEnter,
|
|
481
|
+
onMouseLeave: onMouseLeave,
|
|
482
|
+
d: path.split("L")[0],
|
|
483
|
+
stroke: 'url(#' + id + ')',
|
|
484
|
+
strokeWidth: arcWidth,
|
|
485
|
+
fill: "none"
|
|
486
|
+
}), /*#__PURE__*/_react["default"].createElement("defs", null, /*#__PURE__*/_react["default"].createElement(_LinearGradient["default"], {
|
|
487
|
+
id: id,
|
|
488
|
+
colors: pie,
|
|
489
|
+
rotate: series.color.linear.angle + 180 // gradientUnits='objectBoundingBox'
|
|
394
490
|
|
|
491
|
+
})));
|
|
492
|
+
}), label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
493
|
+
config: _objectSpread(_objectSpread({}, label), {}, {
|
|
494
|
+
maxRadius: maxRadius + 2
|
|
495
|
+
}),
|
|
496
|
+
arcs: _arcs,
|
|
497
|
+
animation: true
|
|
498
|
+
}))), /*#__PURE__*/_react["default"].createElement(_.Legend, (0, _extends2["default"])({}, legend, {
|
|
499
|
+
series: _arcs,
|
|
500
|
+
formatter: formatter
|
|
501
|
+
}))) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_.ChartContainer, {
|
|
502
|
+
width: width,
|
|
503
|
+
height: height,
|
|
504
|
+
marginLeft: marginLeft,
|
|
505
|
+
marginTop: marginTop
|
|
506
|
+
}, /*#__PURE__*/_react["default"].createElement("g", {
|
|
507
|
+
style: {
|
|
508
|
+
transition: "transform ease-in-out 0.3s",
|
|
509
|
+
transform: 'translate(' + halfChartWidth + 'px, ' + halfChartHeight + 'px) rotate(' + rotate_ + "deg)"
|
|
510
|
+
}
|
|
511
|
+
}, _arcs.map(function (_ref8, index) {
|
|
512
|
+
var id = _ref8.id,
|
|
513
|
+
value = _ref8.value,
|
|
514
|
+
series = _ref8.series,
|
|
515
|
+
arc = _ref8.arc,
|
|
516
|
+
innerRadius = _ref8.innerRadius,
|
|
517
|
+
outerRadius = _ref8.outerRadius,
|
|
518
|
+
dataIndex = _ref8.index;
|
|
519
|
+
var current = index == currentIndex;
|
|
520
|
+
var prev = index == prevIndex.current;
|
|
395
521
|
var offset = current ? y : prev ? 1 - y : 0;
|
|
396
|
-
var fillOpacity = current ? opacity / 100 : 1;
|
|
397
|
-
var
|
|
522
|
+
var fillOpacity = animateColor ? 1 : current ? opacity / 100 : 1;
|
|
523
|
+
var deltaHeighten = offset * heighten;
|
|
524
|
+
var path = arc.innerRadius(innerRadius + deltaHeighten).outerRadius(outerRadius + deltaHeighten)(value);
|
|
398
525
|
var pie = (0, _utils.getColorList)(series.color);
|
|
526
|
+
var currentPie = animateColor ? (0, _utils.getColorList)(animateColor) : (0, _utils.getColorList)(series.color);
|
|
527
|
+
var textPath = "",
|
|
528
|
+
categoryTextStyle = {};
|
|
529
|
+
|
|
530
|
+
if (categoryText && categoryText.show) {
|
|
531
|
+
//如果有类目文本,则需要计算文字路径
|
|
532
|
+
//let offsetWidth=decorate2.radiusWidth/2 + radiusWidthAdd/2; //当前文字需生成在装饰物内,故而半径需要减小
|
|
533
|
+
var textArc = arc.innerRadius(outerRadius + (current ? gap : categoryText.gap)).outerRadius(outerRadius + (current ? gap : categoryText.gap))(value);
|
|
534
|
+
var lastA = textArc.lastIndexOf('A');
|
|
535
|
+
textPath = textArc.slice(0, lastA > 0 ? lastA : textArc.length); //文字路径
|
|
536
|
+
|
|
537
|
+
categoryTextStyle = categoryText.textStyle; //这里把textstyle拿出来
|
|
538
|
+
}
|
|
539
|
+
|
|
399
540
|
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, {
|
|
400
541
|
key: index
|
|
401
542
|
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
@@ -408,17 +549,50 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref4) {
|
|
|
408
549
|
strokeWidth: show ? strokeWidth : '0',
|
|
409
550
|
fill: 'url(#' + id + ')',
|
|
410
551
|
fillOpacity: fillOpacity
|
|
411
|
-
}),
|
|
552
|
+
}), //装饰物2,产生于每个弧的外部
|
|
553
|
+
decorate2 && decorate2.show && /*#__PURE__*/_react["default"].createElement("path", {
|
|
554
|
+
"data-index": dataIndex,
|
|
555
|
+
onClick: onClick,
|
|
556
|
+
onMouseEnter: onMouseEnter,
|
|
557
|
+
onMouseLeave: onMouseLeave,
|
|
558
|
+
d: arc.innerRadius(outerRadius).outerRadius(outerRadius + decorate2.radiusWidth + radiusWidthAdd)(value),
|
|
559
|
+
stroke: show ? color : 'none',
|
|
560
|
+
strokeWidth: show ? strokeWidth : '0',
|
|
561
|
+
fill: 'url(#' + id + ')',
|
|
562
|
+
fillOpacity: decorate2.opacity / 100
|
|
563
|
+
}), //类目文本
|
|
564
|
+
categoryText && categoryText.show && /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("path", {
|
|
565
|
+
onClick: onClick,
|
|
566
|
+
onMouseEnter: onMouseEnter,
|
|
567
|
+
onMouseLeave: onMouseLeave,
|
|
568
|
+
id: id + '_text_' + index,
|
|
569
|
+
d: textPath,
|
|
570
|
+
fill: "none",
|
|
571
|
+
stroke: "none"
|
|
572
|
+
}), /*#__PURE__*/_react["default"].createElement("text", {
|
|
573
|
+
textAnchor: "middle",
|
|
574
|
+
style: _objectSpread(_objectSpread({}, categoryTextStyle), {}, {
|
|
575
|
+
fontWeight: categoryTextStyle.bold ? "bold" : "normal",
|
|
576
|
+
fontStyle: categoryTextStyle.italic ? "italic" : "normal"
|
|
577
|
+
}),
|
|
578
|
+
fill: categoryText.textStyle.color
|
|
579
|
+
}, /*#__PURE__*/_react["default"].createElement("textPath", {
|
|
580
|
+
startOffset: "50%",
|
|
581
|
+
href: '#' + id + '_text_' + index
|
|
582
|
+
}, _arcs[index].displayName || _arcs[index].fieldName))), /*#__PURE__*/_react["default"].createElement("defs", null, /*#__PURE__*/_react["default"].createElement(_LinearGradient["default"], {
|
|
412
583
|
id: id,
|
|
413
|
-
colors: pie,
|
|
414
|
-
rotate: series.color.linear.angle + 180 // gradientUnits='objectBoundingBox'
|
|
584
|
+
colors: current ? currentPie : pie,
|
|
585
|
+
rotate: current ? animateColor ? animateColor.linear.angle + 180 : series.color.linear.angle + 180 : series.color.linear.angle + 180 // gradientUnits='objectBoundingBox'
|
|
415
586
|
|
|
416
587
|
})));
|
|
417
588
|
}), label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
418
589
|
config: label,
|
|
419
590
|
arcs: _arcs
|
|
420
591
|
}), current && /*#__PURE__*/_react["default"].createElement("g", {
|
|
421
|
-
fillOpacity: y
|
|
592
|
+
fillOpacity: y,
|
|
593
|
+
style: {
|
|
594
|
+
transform: "rotate(" + -rotate_ + "deg)"
|
|
595
|
+
}
|
|
422
596
|
}, /*#__PURE__*/_react["default"].createElement(Current, {
|
|
423
597
|
config: current,
|
|
424
598
|
data: _arcs,
|
|
@@ -437,35 +611,35 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref4) {
|
|
|
437
611
|
})));
|
|
438
612
|
});
|
|
439
613
|
|
|
440
|
-
var Current = function Current(
|
|
441
|
-
var
|
|
442
|
-
show =
|
|
443
|
-
gap =
|
|
444
|
-
|
|
445
|
-
showName =
|
|
446
|
-
nameFont =
|
|
447
|
-
|
|
448
|
-
showPercent =
|
|
449
|
-
percentFont =
|
|
450
|
-
precision =
|
|
451
|
-
|
|
452
|
-
translatePercentX =
|
|
453
|
-
translatePercentY =
|
|
454
|
-
|
|
455
|
-
showValue =
|
|
456
|
-
valueFont =
|
|
457
|
-
|
|
458
|
-
translateValueX =
|
|
459
|
-
translateValueY =
|
|
460
|
-
|
|
461
|
-
showSuffix =
|
|
462
|
-
fontSize =
|
|
463
|
-
text =
|
|
464
|
-
|
|
465
|
-
translateSuffixX =
|
|
466
|
-
translateSuffixY =
|
|
467
|
-
data =
|
|
468
|
-
currentIndex =
|
|
614
|
+
var Current = function Current(_ref9) {
|
|
615
|
+
var _ref9$config = _ref9.config,
|
|
616
|
+
show = _ref9$config.show,
|
|
617
|
+
gap = _ref9$config.gap,
|
|
618
|
+
_ref9$config$name = _ref9$config.name,
|
|
619
|
+
showName = _ref9$config$name.show,
|
|
620
|
+
nameFont = _ref9$config$name.font,
|
|
621
|
+
_ref9$config$percent = _ref9$config.percent,
|
|
622
|
+
showPercent = _ref9$config$percent.show,
|
|
623
|
+
percentFont = _ref9$config$percent.font,
|
|
624
|
+
precision = _ref9$config$percent.precision,
|
|
625
|
+
_ref9$config$percent$ = _ref9$config$percent.translate,
|
|
626
|
+
translatePercentX = _ref9$config$percent$.x,
|
|
627
|
+
translatePercentY = _ref9$config$percent$.y,
|
|
628
|
+
_ref9$config$value = _ref9$config.value,
|
|
629
|
+
showValue = _ref9$config$value.show,
|
|
630
|
+
valueFont = _ref9$config$value.font,
|
|
631
|
+
_ref9$config$value$tr = _ref9$config$value.translate,
|
|
632
|
+
translateValueX = _ref9$config$value$tr.x,
|
|
633
|
+
translateValueY = _ref9$config$value$tr.y,
|
|
634
|
+
_ref9$config$value$su = _ref9$config$value.suffix,
|
|
635
|
+
showSuffix = _ref9$config$value$su.show,
|
|
636
|
+
fontSize = _ref9$config$value$su.fontSize,
|
|
637
|
+
text = _ref9$config$value$su.text,
|
|
638
|
+
_ref9$config$value$su2 = _ref9$config$value$su.translate,
|
|
639
|
+
translateSuffixX = _ref9$config$value$su2.x,
|
|
640
|
+
translateSuffixY = _ref9$config$value$su2.y,
|
|
641
|
+
data = _ref9.data,
|
|
642
|
+
currentIndex = _ref9.currentIndex;
|
|
469
643
|
|
|
470
644
|
var _data = (0, _react.useMemo)(function () {
|
|
471
645
|
var legendDataWithPercent = (0, _utils.getDataWithPercent)(data, precision);
|
|
@@ -496,37 +670,41 @@ var Current = function Current(_ref7) {
|
|
|
496
670
|
}, (0, _utils.getFontStyle)(percentFont, 'svg')), percent + '%'));
|
|
497
671
|
};
|
|
498
672
|
|
|
499
|
-
var Label = function Label(
|
|
500
|
-
var
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
673
|
+
var Label = function Label(_ref10) {
|
|
674
|
+
var _ref10$config = _ref10.config,
|
|
675
|
+
_ref10$config$maxRadi = _ref10$config.maxRadius,
|
|
676
|
+
maxRadius = _ref10$config$maxRadi === void 0 ? 0 : _ref10$config$maxRadi,
|
|
677
|
+
lineLength = _ref10$config.lineLength,
|
|
678
|
+
lineColor = _ref10$config.lineColor,
|
|
679
|
+
distance = _ref10$config.distance,
|
|
680
|
+
mode = _ref10$config.mode,
|
|
681
|
+
show = _ref10$config.show,
|
|
682
|
+
_ref10$config$transla = _ref10$config.translate,
|
|
683
|
+
translateX = _ref10$config$transla.x,
|
|
684
|
+
translateY = _ref10$config$transla.y,
|
|
685
|
+
_ref10$config$name = _ref10$config.name,
|
|
686
|
+
showName = _ref10$config$name.show,
|
|
687
|
+
nameFont = _ref10$config$name.font,
|
|
688
|
+
_ref10$config$value = _ref10$config.value,
|
|
689
|
+
showValue = _ref10$config$value.show,
|
|
690
|
+
valueFont = _ref10$config$value.font,
|
|
691
|
+
_ref10$config$value$s = _ref10$config$value.suffix,
|
|
692
|
+
showSuffix = _ref10$config$value$s.show,
|
|
693
|
+
text = _ref10$config$value$s.text,
|
|
694
|
+
suffixFontSize = _ref10$config$value$s.fontSize,
|
|
695
|
+
_ref10$config$value$s2 = _ref10$config$value$s.translate,
|
|
696
|
+
suffixTranslateX = _ref10$config$value$s2.x,
|
|
697
|
+
suffixTranslateY = _ref10$config$value$s2.y,
|
|
698
|
+
_ref10$config$value$s3 = _ref10$config$value.sameColor,
|
|
699
|
+
valueSameColor = _ref10$config$value$s3 === void 0 ? false : _ref10$config$value$s3,
|
|
700
|
+
_ref10$config$percent = _ref10$config.percent,
|
|
701
|
+
showPercent = _ref10$config$percent.show,
|
|
702
|
+
percentFont = _ref10$config$percent.font,
|
|
703
|
+
precision = _ref10$config$percent.precision,
|
|
704
|
+
_ref10$config$percent2 = _ref10$config$percent.sameColor,
|
|
705
|
+
percentSameColor = _ref10$config$percent2 === void 0 ? false : _ref10$config$percent2,
|
|
706
|
+
arcs = _ref10.arcs,
|
|
707
|
+
animation = _ref10.animation;
|
|
530
708
|
|
|
531
709
|
// const [labels, setLabels] = useState(null);
|
|
532
710
|
// const [opacity, setOpacity] = useState(0);
|
|
@@ -569,16 +747,17 @@ var Label = function Label(_ref8) {
|
|
|
569
747
|
// }, [labels]);
|
|
570
748
|
|
|
571
749
|
|
|
572
|
-
return /*#__PURE__*/_react["default"].createElement("g", null, _arcs.map(function (
|
|
573
|
-
var
|
|
574
|
-
type =
|
|
575
|
-
pure =
|
|
576
|
-
stops =
|
|
577
|
-
displayName =
|
|
578
|
-
value =
|
|
579
|
-
percent =
|
|
580
|
-
arc =
|
|
581
|
-
outerRadius =
|
|
750
|
+
return /*#__PURE__*/_react["default"].createElement("g", null, _arcs.map(function (_ref11, index) {
|
|
751
|
+
var _ref11$series$color = _ref11.series.color,
|
|
752
|
+
type = _ref11$series$color.type,
|
|
753
|
+
pure = _ref11$series$color.pure,
|
|
754
|
+
stops = _ref11$series$color.linear.stops,
|
|
755
|
+
displayName = _ref11.displayName,
|
|
756
|
+
value = _ref11.value,
|
|
757
|
+
percent = _ref11.percent,
|
|
758
|
+
arc = _ref11.arc,
|
|
759
|
+
outerRadius = _ref11.outerRadius,
|
|
760
|
+
actualIndex = _ref11.index;
|
|
582
761
|
|
|
583
762
|
var _arc$centroid = arc.centroid(),
|
|
584
763
|
_arc$centroid2 = (0, _slicedToArray2["default"])(_arc$centroid, 2),
|
|
@@ -587,12 +766,12 @@ var Label = function Label(_ref8) {
|
|
|
587
766
|
|
|
588
767
|
var midAngle = Math.atan2(y, x);
|
|
589
768
|
|
|
590
|
-
var _getCoord = getCoord(midAngle, outerRadius),
|
|
769
|
+
var _getCoord = getCoord(midAngle, maxRadius ? maxRadius : outerRadius),
|
|
591
770
|
_getCoord2 = (0, _slicedToArray2["default"])(_getCoord, 2),
|
|
592
771
|
x1 = _getCoord2[0],
|
|
593
772
|
y1 = _getCoord2[1];
|
|
594
773
|
|
|
595
|
-
var radius = outerRadius + distance;
|
|
774
|
+
var radius = (maxRadius ? maxRadius : outerRadius) + distance;
|
|
596
775
|
|
|
597
776
|
var _getCoord3 = getCoord(midAngle, radius),
|
|
598
777
|
_getCoord4 = (0, _slicedToArray2["default"])(_getCoord3, 2),
|
|
@@ -611,10 +790,18 @@ var Label = function Label(_ref8) {
|
|
|
611
790
|
return show && (_showName || showPercent || _showValue) && /*#__PURE__*/_react["default"].createElement("g", {
|
|
612
791
|
key: index
|
|
613
792
|
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
793
|
+
className: animation ? _piechartModule["default"]['label-line'] : "",
|
|
794
|
+
style: {
|
|
795
|
+
animationDelay: "".concat(animation ? (actualIndex + 1) * 2000 - 800 : 0, "ms")
|
|
796
|
+
},
|
|
614
797
|
d: 'M' + x1 + ', ' + y1 + 'L' + x2 + ', ' + y2 + 'L' + x3 + ', ' + y2,
|
|
615
|
-
stroke: type == 'pure' ? pure : stops[0].color,
|
|
798
|
+
stroke: lineColor ? lineColor : type == 'pure' ? pure : stops[0].color,
|
|
616
799
|
fill: "none"
|
|
617
800
|
}), /*#__PURE__*/_react["default"].createElement("text", {
|
|
801
|
+
className: animation ? _piechartModule["default"]['label-text'] : "",
|
|
802
|
+
style: {
|
|
803
|
+
animationDelay: "".concat(animation ? (actualIndex + 1) * 2000 - 800 : 0, "ms")
|
|
804
|
+
},
|
|
618
805
|
x: _x,
|
|
619
806
|
y: y2 + translateY,
|
|
620
807
|
dominantBaseline: "middle",
|
|
@@ -635,7 +822,7 @@ var Label = function Label(_ref8) {
|
|
|
635
822
|
}, text)), showPercent && /*#__PURE__*/_react["default"].createElement("tspan", {
|
|
636
823
|
x: percentX(_showName, _showValue, mode, _x),
|
|
637
824
|
dx: percentDx(_showName, _showValue, mode),
|
|
638
|
-
dy: percentDy(_showName, _showValue, mode) + (_showValue && showSuffix ? suffixTranslateY * -1 :
|
|
825
|
+
dy: percentDy(_showName, _showValue, mode) + (_showValue && showSuffix ? suffixTranslateY * -1 : ""),
|
|
639
826
|
style: (0, _utils.getFontStyle)(percentFont, 'svg')
|
|
640
827
|
}, (_showValue ? '(' : '') + percent + '%' + (_showValue ? ')' : ''))));
|
|
641
828
|
}));
|
package/lib/css/index.module.css
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
.rotateClockwise {
|
|
2
|
-
animation-name: rotateClockwise;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
@keyframes rotateClockwise {
|
|
6
|
-
0% {
|
|
7
|
-
transform: rotate(0deg);
|
|
8
|
-
}
|
|
9
|
-
100% {
|
|
10
|
-
transform: rotate(360deg);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.rotateCounterClockwise {
|
|
15
|
-
animation-name: rotateCounterClockwise;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@keyframes rotateCounterClockwise {
|
|
19
|
-
0% {
|
|
20
|
-
transform: rotate(360deg);
|
|
21
|
-
}
|
|
22
|
-
100% {
|
|
23
|
-
transform: rotate(0deg);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.showAllStyle {
|
|
28
|
-
display: grid;
|
|
29
|
-
width: 100%;
|
|
30
|
-
grid-template-columns: 50% 25% 25%;
|
|
31
|
-
align-items: center;
|
|
32
|
-
flex-direction: row;
|
|
33
|
-
justify-content: space-between;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.notShowAllStyle {
|
|
37
|
-
display: flex;
|
|
38
|
-
width: 100%;
|
|
39
|
-
align-items: center;
|
|
40
|
-
flex-direction: row;
|
|
41
|
-
justify-content: space-between;
|
|
42
|
-
}
|
|
1
|
+
.rotateClockwise {
|
|
2
|
+
animation-name: rotateClockwise;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
@keyframes rotateClockwise {
|
|
6
|
+
0% {
|
|
7
|
+
transform: rotate(0deg);
|
|
8
|
+
}
|
|
9
|
+
100% {
|
|
10
|
+
transform: rotate(360deg);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.rotateCounterClockwise {
|
|
15
|
+
animation-name: rotateCounterClockwise;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@keyframes rotateCounterClockwise {
|
|
19
|
+
0% {
|
|
20
|
+
transform: rotate(360deg);
|
|
21
|
+
}
|
|
22
|
+
100% {
|
|
23
|
+
transform: rotate(0deg);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.showAllStyle {
|
|
28
|
+
display: grid;
|
|
29
|
+
width: 100%;
|
|
30
|
+
grid-template-columns: 50% 25% 25%;
|
|
31
|
+
align-items: center;
|
|
32
|
+
flex-direction: row;
|
|
33
|
+
justify-content: space-between;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.notShowAllStyle {
|
|
37
|
+
display: flex;
|
|
38
|
+
width: 100%;
|
|
39
|
+
align-items: center;
|
|
40
|
+
flex-direction: row;
|
|
41
|
+
justify-content: space-between;
|
|
42
|
+
}
|