@easyv/charts 1.1.8 → 1.2.2

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.
Files changed (69) hide show
  1. package/.babelrc +8 -8
  2. package/.husky/commit-msg +3 -3
  3. package/CHANGELOG.md +18 -18
  4. package/lib/components/AnimateData.js +2 -2
  5. package/lib/components/Axis.js +10 -10
  6. package/lib/components/Background.js +2 -2
  7. package/lib/components/Carousel.js +2 -2
  8. package/lib/components/Chart.js +2 -2
  9. package/lib/components/ConicalGradient.js +21 -21
  10. package/lib/components/Indicator.js +2 -2
  11. package/lib/components/Lighter.js +179 -179
  12. package/lib/components/LinearGradient.js +2 -2
  13. package/lib/components/Marquee.js +97 -0
  14. package/lib/components/PieChart.js +47 -39
  15. package/lib/css/index.module.css +41 -41
  16. package/lib/css/piechart.module.css +26 -26
  17. package/lib/element/ConicGradient.js +72 -72
  18. package/lib/hooks/useAnimateData.js +7 -7
  19. package/lib/hooks/useAxes.js +5 -5
  20. package/lib/hooks/useCarouselAxisX.js +5 -5
  21. package/lib/hooks/useExtentData.js +6 -6
  22. package/lib/hooks/useFilterData.js +5 -5
  23. package/lib/hooks/useStackData.js +5 -5
  24. package/lib/hooks/useTooltip.js +10 -10
  25. package/package.json +51 -52
  26. package/src/components/AnimateData.tsx +24 -24
  27. package/src/components/Axis.tsx +354 -354
  28. package/src/components/Background.tsx +45 -45
  29. package/src/components/Band.tsx +173 -173
  30. package/src/components/Brush.js +159 -159
  31. package/src/components/Carousel.tsx +144 -144
  32. package/src/components/Chart.js +99 -99
  33. package/src/components/ChartContainer.tsx +63 -63
  34. package/src/components/ConicalGradient.js +258 -258
  35. package/src/components/ExtentData.js +17 -17
  36. package/src/components/FilterData.js +23 -23
  37. package/src/components/Indicator.js +13 -13
  38. package/src/components/Label.js +206 -206
  39. package/src/components/Legend.js +158 -158
  40. package/src/components/Lighter.jsx +173 -173
  41. package/src/components/Line.js +144 -144
  42. package/src/components/LinearGradient.js +29 -29
  43. package/src/components/Mapping.js +71 -71
  44. package/src/components/Marquee.js +74 -0
  45. package/src/components/PieChart.js +1288 -1097
  46. package/src/components/StackData.js +20 -20
  47. package/src/components/StereoBar.tsx +310 -310
  48. package/src/components/Tooltip.js +169 -169
  49. package/src/components/index.js +51 -51
  50. package/src/context/index.js +2 -2
  51. package/src/css/index.module.css +41 -41
  52. package/src/css/piechart.module.css +26 -26
  53. package/src/element/ConicGradient.jsx +55 -55
  54. package/src/element/Line.tsx +33 -33
  55. package/src/element/index.ts +3 -3
  56. package/src/formatter/index.js +1 -1
  57. package/src/formatter/legend.js +90 -90
  58. package/src/hooks/index.js +17 -17
  59. package/src/hooks/useAnimateData.ts +67 -62
  60. package/src/hooks/useAxes.js +144 -144
  61. package/src/hooks/useCarouselAxisX.js +163 -163
  62. package/src/hooks/useExtentData.js +88 -88
  63. package/src/hooks/useFilterData.js +72 -72
  64. package/src/hooks/useStackData.js +100 -100
  65. package/src/hooks/useTooltip.ts +96 -96
  66. package/src/index.js +6 -6
  67. package/src/types/index.d.ts +67 -62
  68. package/src/utils/index.js +696 -696
  69. package/tsconfig.json +22 -22
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
14
+ var _react = require("react");
15
+
16
+ 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; }
17
+
18
+ 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; }
19
+
20
+ /**
21
+ * 文字跑马灯组件
22
+ * eg: <Marquee value={文本内容} speed={跑马灯速度} style={额外样式}></Marquee>
23
+ */
24
+ var _default = /*#__PURE__*/(0, _react.memo)(function (props) {
25
+ var value = props.value,
26
+ style = props.style,
27
+ _props$speed = props.speed,
28
+ speed = _props$speed === void 0 ? 5 : _props$speed;
29
+ var dom = (0, _react.useRef)(null);
30
+ var content = (0, _react.useRef)(null);
31
+ var duration = (0, _react.useRef)(1); //dom和content盒子对象,避免speed变化时重新获取盒子对象
32
+
33
+ var domRect = (0, _react.useRef)(null);
34
+ var contentRect = (0, _react.useRef)(null);
35
+
36
+ var _useState = (0, _react.useState)([value]),
37
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
38
+ textList = _useState2[0],
39
+ setTextList = _useState2[1]; //文本变化时,需要重新计算dom和content的宽高
40
+
41
+
42
+ (0, _react.useEffect)(function () {
43
+ var dom_ = dom.current;
44
+ domRect.current = dom_.getBoundingClientRect();
45
+ var content_ = content.current;
46
+ contentRect.current = content_.getBoundingClientRect();
47
+
48
+ if (domRect.current.width < contentRect.current.width) {
49
+ setTextList([value, value]);
50
+ }
51
+ }, [value]); //value和speed变化时,直接更新duration
52
+
53
+ (0, _react.useEffect)(function () {
54
+ if (domRect.current.width < contentRect.current.width) {
55
+ duration.current = contentRect.current.width / domRect.current.width / speed * 10;
56
+ }
57
+ }, [speed]); //在head标签中注入keyframes动画
58
+
59
+ (0, _react.useEffect)(function () {
60
+ var md_marquee = document.getElementById("md_marquee"); //先查找是否已经存在md_marquee
61
+
62
+ if (!md_marquee) {
63
+ //不存在时再注入style标签
64
+ var keyframes = "@keyframes md_marquee {0%{\n transform: translate(0,0);\n }\n 100%{\n transform: translate(-100%,0);\n }}";
65
+
66
+ var _style = document.createElement('style');
67
+
68
+ _style.id = 'md_marquee';
69
+ _style.innerHTML = keyframes; // 将style样式存放到head标签
70
+
71
+ document.getElementsByTagName('head')[0].appendChild(_style);
72
+ }
73
+ }, []);
74
+ return /*#__PURE__*/React.createElement("span", {
75
+ style: _objectSpread(_objectSpread({}, style), {}, {
76
+ width: "100%",
77
+ display: "flex",
78
+ whiteSpace: "nowrap",
79
+ overflow: "hidden"
80
+ }),
81
+ ref: dom
82
+ }, textList.map(function (item, itemIndex) {
83
+ return /*#__PURE__*/React.createElement("span", {
84
+ key: itemIndex,
85
+ style: textList.length == 2 ? {
86
+ //如果文本数量为2,则需要滚动
87
+ animationName: "md_marquee",
88
+ animationTimingFunction: "linear",
89
+ animationIterationCount: "infinite",
90
+ animationDuration: duration.current + "s"
91
+ } : {},
92
+ ref: itemIndex == 0 ? content : null
93
+ }, "\xA0", item);
94
+ }));
95
+ });
96
+
97
+ exports["default"] = _default;
@@ -59,14 +59,14 @@ var defaultAngle = {
59
59
 
60
60
  var nameDy = function nameDy(showValue, showPercent, mode, dir) {
61
61
  if (showValue || showPercent) {
62
- if (mode == "vertical") {
63
- return dir == 1 ? "1.1em" : "-2.6em";
62
+ if (mode == 'vertical') {
63
+ return dir == 1 ? '1.1em' : '-2.6em';
64
64
  } else {
65
65
  return 0;
66
66
  }
67
67
  } else {
68
- if (mode == "vertical") {
69
- return dir * 1.1 + "em";
68
+ if (mode == 'vertical') {
69
+ return dir * 1.1 + 'em';
70
70
  } else {
71
71
  return 0;
72
72
  }
@@ -75,14 +75,14 @@ var nameDy = function nameDy(showValue, showPercent, mode, dir) {
75
75
 
76
76
  var valueDy = function valueDy(value1, mode, dir) {
77
77
  if (value1) {
78
- if (mode == "vertical") {
79
- return "1.5em";
78
+ if (mode == 'vertical') {
79
+ return '1.5em';
80
80
  } else {
81
81
  return 0;
82
82
  }
83
83
  } else {
84
- if (mode == "vertical") {
85
- return dir == 1 ? "1.1em" : "-1.1em";
84
+ if (mode == 'vertical') {
85
+ return dir == 1 ? '1.1em' : '-1.1em';
86
86
  } else {
87
87
  return 0;
88
88
  }
@@ -495,8 +495,8 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
495
495
  marginTop: marginTop
496
496
  }, /*#__PURE__*/_react["default"].createElement("g", {
497
497
  style: {
498
- transition: "transform ease-in-out 0.3s",
499
- transform: 'translate(' + halfChartWidth + 'px, ' + halfChartHeight + 'px) rotate(' + rotate_ + "deg)"
498
+ transition: 'transform ease-in-out 0.3s',
499
+ transform: 'translate(' + halfChartWidth + 'px, ' + halfChartHeight + 'px) rotate(' + rotate_ + 'deg)'
500
500
  }
501
501
  }, //用于生成外环装饰的刻度
502
502
  outerDecorate.tick.show && getCircleScale(outerDecorate.tick, maxRadius), /*#__PURE__*/_react["default"].createElement("circle", {
@@ -532,7 +532,7 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
532
532
  onClick: onClick,
533
533
  onMouseEnter: onMouseEnter,
534
534
  onMouseLeave: onMouseLeave,
535
- d: path.split("L")[0],
535
+ d: path.split('L')[0],
536
536
  stroke: 'url(#' + id + ')',
537
537
  strokeWidth: arcWidth,
538
538
  fill: "none"
@@ -557,8 +557,8 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
557
557
  marginTop: marginTop
558
558
  }, /*#__PURE__*/_react["default"].createElement("g", {
559
559
  style: {
560
- transition: "transform ease-in-out 0.3s",
561
- transform: 'translate(' + halfChartWidth + 'px, ' + halfChartHeight + 'px) rotate(' + rotate_ + "deg)"
560
+ transition: 'transform ease-in-out 0.3s',
561
+ transform: 'translate(' + halfChartWidth + 'px, ' + halfChartHeight + 'px) rotate(' + rotate_ + 'deg)'
562
562
  }
563
563
  }, _arcs.map(function (_ref8, index) {
564
564
  var id = _ref8.id,
@@ -576,7 +576,7 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
576
576
  var path = arc.innerRadius(innerRadius + deltaHeighten).outerRadius(outerRadius + deltaHeighten)(value);
577
577
  var pie = (0, _utils.getColorList)(series.color);
578
578
  var currentPie = animateColor ? (0, _utils.getColorList)(animateColor) : (0, _utils.getColorList)(series.color);
579
- var textPath = "",
579
+ var textPath = '',
580
580
  categoryTextStyle = {};
581
581
 
582
582
  if (categoryText && categoryText.show) {
@@ -624,9 +624,9 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
624
624
  }), /*#__PURE__*/_react["default"].createElement("text", {
625
625
  textAnchor: "middle",
626
626
  style: _objectSpread(_objectSpread({}, categoryTextStyle), {}, {
627
- fontWeight: categoryTextStyle.bold ? "bold" : "normal",
628
- fontStyle: categoryTextStyle.italic ? "italic" : "normal",
629
- pointerEvents: "none"
627
+ fontWeight: categoryTextStyle.bold ? 'bold' : 'normal',
628
+ fontStyle: categoryTextStyle.italic ? 'italic' : 'normal',
629
+ pointerEvents: 'none'
630
630
  }),
631
631
  fill: categoryTextStyle.color
632
632
  }, /*#__PURE__*/_react["default"].createElement("textPath", {
@@ -644,7 +644,7 @@ var Component = /*#__PURE__*/(0, _react.memo)(function (_ref5) {
644
644
  }), current && /*#__PURE__*/_react["default"].createElement("g", {
645
645
  fillOpacity: y,
646
646
  style: {
647
- transform: "rotate(" + -rotate_ + "deg)"
647
+ transform: 'rotate(' + -rotate_ + 'deg)'
648
648
  }
649
649
  }, /*#__PURE__*/_react["default"].createElement(Current, {
650
650
  config: current,
@@ -672,10 +672,12 @@ var Current = function Current(_ref9) {
672
672
  gap = _ref9$config.gap,
673
673
  _ref9$config$name = _ref9$config.name,
674
674
  showName = _ref9$config$name.show,
675
+ nameColor = _ref9$config$name.sameColor,
675
676
  nameFont = _ref9$config$name.font,
676
677
  textBreak = _ref9$config$name.textBreak,
677
678
  _ref9$config$percent = _ref9$config.percent,
678
679
  showPercent = _ref9$config$percent.show,
680
+ percentColor = _ref9$config$percent.sameColor,
679
681
  percentFont = _ref9$config$percent.font,
680
682
  precision = _ref9$config$percent.precision,
681
683
  _ref9$config$percent$ = _ref9$config$percent.translate,
@@ -683,6 +685,7 @@ var Current = function Current(_ref9) {
683
685
  translatePercentY = _ref9$config$percent$.y,
684
686
  _ref9$config$value = _ref9$config.value,
685
687
  showValue = _ref9$config$value.show,
688
+ valueColor = _ref9$config$value.sameColor,
686
689
  valueFont = _ref9$config$value.font,
687
690
  _ref9$config$value$tr = _ref9$config$value.translate,
688
691
  translateValueX = _ref9$config$value$tr.x,
@@ -728,17 +731,19 @@ var Current = function Current(_ref9) {
728
731
  width: width,
729
732
  height: height,
730
733
  transform: "translate(-".concat(width / 2, "px,-").concat(height / 2, "px)"),
731
- pointerEvents: "none"
734
+ pointerEvents: 'none'
732
735
  },
733
736
  boxStyle = {
734
737
  //弹性盒子样式,用于当前值的上下居中对齐等
735
738
  width: width,
736
739
  height: height,
737
- display: "flex",
738
- flexDirection: "column",
739
- justifyContent: "center",
740
- alignItems: "center"
740
+ display: 'flex',
741
+ flexDirection: 'column',
742
+ justifyContent: 'center',
743
+ alignItems: 'center'
741
744
  };
745
+ var seriesColor = currentData.series.color;
746
+ seriesColor = seriesColor.type == 'pure' ? seriesColor.pure : seriesColor.linear.stops[0].color;
742
747
  return show && /*#__PURE__*/_react["default"].createElement("foreignObject", {
743
748
  style: foreignStyle
744
749
  }, /*#__PURE__*/_react["default"].createElement("div", {
@@ -746,10 +751,11 @@ var Current = function Current(_ref9) {
746
751
  }, //类目名称
747
752
  showName && /*#__PURE__*/_react["default"].createElement("div", {
748
753
  style: _objectSpread(_objectSpread({}, (0, _utils.getFontStyle)(nameFont)), {}, {
749
- margin: gap / 2 + "px 0",
750
- display: "flex",
751
- flexDirection: "column",
752
- alignItems: "center"
754
+ margin: gap / 2 + 'px 0',
755
+ display: 'flex',
756
+ flexDirection: 'column',
757
+ alignItems: 'center',
758
+ color: nameColor ? seriesColor : nameFont.color
753
759
  })
754
760
  }, nameList.map(function (d, i) {
755
761
  return /*#__PURE__*/_react["default"].createElement("span", {
@@ -758,20 +764,22 @@ var Current = function Current(_ref9) {
758
764
  })), //真实值
759
765
  showValue && /*#__PURE__*/_react["default"].createElement("span", {
760
766
  style: _objectSpread(_objectSpread({}, (0, _utils.getFontStyle)(valueFont)), {}, {
761
- transform: "translate(" + translateValueX + "px," + translateValueY + "px)",
762
- margin: gap / 2 + "px 0"
767
+ transform: 'translate(' + translateValueX + 'px,' + translateValueY + 'px)',
768
+ margin: gap / 2 + 'px 0',
769
+ color: valueColor ? seriesColor : valueFont.color
763
770
  })
764
771
  }, value, showSuffix && text && /*#__PURE__*/_react["default"].createElement("span", {
765
772
  style: {
766
- transform: "translate(" + translateSuffixX + "px," + translateSuffixY + "px)",
773
+ transform: 'translate(' + translateSuffixX + 'px,' + translateSuffixY + 'px)',
767
774
  fontSize: fontSize
768
775
  }
769
776
  }, text)), //百分比值
770
777
  showPercent && /*#__PURE__*/_react["default"].createElement("span", {
771
778
  style: _objectSpread(_objectSpread({
772
- transform: "translate(" + translatePercentX + "px," + translatePercentY + "px)"
779
+ transform: 'translate(' + translatePercentX + 'px,' + translatePercentY + 'px)'
773
780
  }, (0, _utils.getFontStyle)(percentFont)), {}, {
774
- margin: gap / 2 + "px 0"
781
+ margin: gap / 2 + 'px 0',
782
+ color: percentColor ? seriesColor : percentFont.color
775
783
  })
776
784
  }, percent + '%')));
777
785
  };
@@ -896,7 +904,7 @@ var Label = function Label(_ref10) {
896
904
  return show && (_showName || showPercent || showValue) && /*#__PURE__*/_react["default"].createElement("g", {
897
905
  key: index
898
906
  }, /*#__PURE__*/_react["default"].createElement("path", {
899
- className: animation ? _piechartModule["default"]['label-line'] : "",
907
+ className: animation ? _piechartModule["default"]['label-line'] : '',
900
908
  style: {
901
909
  animationDelay: "".concat(animation ? (actualIndex + 1) * 2000 - 800 : 0, "ms")
902
910
  },
@@ -904,7 +912,7 @@ var Label = function Label(_ref10) {
904
912
  stroke: lineColor ? lineColor : type == 'pure' ? pure : stops[0].color,
905
913
  fill: "none"
906
914
  }), /*#__PURE__*/_react["default"].createElement("text", {
907
- className: animation ? _piechartModule["default"]['label-text'] : "",
915
+ className: animation ? _piechartModule["default"]['label-text'] : '',
908
916
  style: {
909
917
  animationDelay: "".concat(animation ? (actualIndex + 1) * 2000 - 800 : 0, "ms")
910
918
  },
@@ -928,7 +936,7 @@ var Label = function Label(_ref10) {
928
936
  }, text)), showPercent && /*#__PURE__*/_react["default"].createElement("tspan", {
929
937
  x: percentX(_showName, _showValue, mode, _x),
930
938
  dx: percentDx(_showName, _showValue, mode),
931
- dy: percentDy(_showName, _showValue, mode) + (_showValue && showSuffix ? suffixTranslateY * -1 : ""),
939
+ dy: percentDy(_showName, _showValue, mode) + (_showValue && showSuffix ? suffixTranslateY * -1 : ''),
932
940
  style: (0, _utils.getFontStyle)(percentFont, 'svg')
933
941
  }, (_showValue ? '(' : '') + percent + '%' + (_showValue ? ')' : ''))));
934
942
  }));
@@ -1030,7 +1038,7 @@ var RingLabel = function RingLabel(_ref12) {
1030
1038
  style: {
1031
1039
  animationDelay: "".concat((actualIndex + 1) * 2000 - 800, "ms")
1032
1040
  },
1033
- x: mode == "horizontal" ? _x : x2,
1041
+ x: mode == 'horizontal' ? _x : x2,
1034
1042
  y: y2 + translateY,
1035
1043
  dominantBaseline: "middle",
1036
1044
  textAnchor: x3 >= 0 ? 'start' : 'end'
@@ -1038,7 +1046,7 @@ var RingLabel = function RingLabel(_ref12) {
1038
1046
  dy: nameDy(_showValue, showPercent, mode, directionY),
1039
1047
  style: (0, _utils.getFontStyle)(nameFont, 'svg')
1040
1048
  }, displayName + (showValue || showPercent ? ':' : '')), _showValue && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("tspan", {
1041
- x: _showName ? mode == "horizontal" ? '' : x2 : '',
1049
+ x: _showName ? mode == 'horizontal' ? '' : x2 : '',
1042
1050
  dx: valueDx(_showName, mode),
1043
1051
  dy: valueDy(_showName, mode, directionY),
1044
1052
  style: (0, _utils.getFontStyle)(valueFont, 'svg')
@@ -1049,9 +1057,9 @@ var RingLabel = function RingLabel(_ref12) {
1049
1057
  dx: suffixTranslateX,
1050
1058
  dy: suffixTranslateY
1051
1059
  }, text)), showPercent && /*#__PURE__*/_react["default"].createElement("tspan", {
1052
- x: _showName ? _showValue ? '' : mode == "vertical" ? x2 : '' : '',
1060
+ x: _showName ? _showValue ? '' : mode == 'vertical' ? x2 : '' : '',
1053
1061
  dx: percentDx(_showName, _showValue, mode),
1054
- dy: percentDy_(_showName, _showValue, mode, directionY) + (_showValue && showSuffix ? suffixTranslateY * -1 : ""),
1062
+ dy: percentDy_(_showName, _showValue, mode, directionY) + (_showValue && showSuffix ? suffixTranslateY * -1 : ''),
1055
1063
  style: (0, _utils.getFontStyle)(percentFont, 'svg')
1056
1064
  }, (_showValue ? '(' : '') + percent + '%' + (_showValue ? ')' : ''))));
1057
1065
  }));
@@ -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: 40% 30% 30%;
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;
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: 40% 30% 30%;
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
42
  }
@@ -1,27 +1,27 @@
1
- /*甜甜圈图专用css*/
2
- .label-line {
3
- stroke-dasharray: 100;
4
- stroke-dashoffset: 100;
5
- animation: dash 800ms ease forwards;
6
- }
7
-
8
- .label-text {
9
- opacity: 0;
10
- animation: show 800ms ease forwards;
11
- }
12
-
13
- .inner-arc {
14
- animation: dash 2s ease forwards;
15
- }
16
-
17
- @keyframes dash {
18
- 100% {
19
- stroke-dashoffset: 0%;
20
- }
21
- }
22
-
23
- @keyframes show {
24
- 100% {
25
- opacity: 1;
26
- }
1
+ /*甜甜圈图专用css*/
2
+ .label-line {
3
+ stroke-dasharray: 100;
4
+ stroke-dashoffset: 100;
5
+ animation: dash 800ms ease forwards;
6
+ }
7
+
8
+ .label-text {
9
+ opacity: 0;
10
+ animation: show 800ms ease forwards;
11
+ }
12
+
13
+ .inner-arc {
14
+ animation: dash 2s ease forwards;
15
+ }
16
+
17
+ @keyframes dash {
18
+ 100% {
19
+ stroke-dashoffset: 0%;
20
+ }
21
+ }
22
+
23
+ @keyframes show {
24
+ 100% {
25
+ opacity: 1;
26
+ }
27
27
  }
@@ -1,73 +1,73 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = ConicGradient;
9
-
10
- var d3 = _interopRequireWildcard(require("d3"));
11
-
12
- //只支持在svg中使用
13
- //在<clipPath>标签中绘制圆环路径,在<foreignObject>中使用conic-gradient来制作角向渐变
14
- //然后在foreignObject中调用clipPath来剪切dom元素,实现环形渐变效果
15
- function ConicGradient(props) {
16
- var gradientId = props.gradientId,
17
- _props$colorConfig = props.colorConfig,
18
- colorConfig = _props$colorConfig === void 0 ? {} : _props$colorConfig,
19
- _props$circleConfig = props.circleConfig,
20
- circleConfig = _props$circleConfig === void 0 ? {} : _props$circleConfig,
21
- _colorConfig$colorTyp = colorConfig.colorType,
22
- colorType = _colorConfig$colorTyp === void 0 ? "linear" : _colorConfig$colorTyp,
23
- _colorConfig$colors = colorConfig.colors,
24
- colors = _colorConfig$colors === void 0 ? [{
25
- offset: 0,
26
- color: "rgba(255,0,0,0.5)"
27
- }, {
28
- offset: 50,
29
- color: "rgba(0,255,0,0.5)"
30
- }, {
31
- offset: 100,
32
- color: "rgba(0,0,255,0.5)"
33
- }] : _colorConfig$colors,
34
- _circleConfig$innerRa = circleConfig.innerRadius,
35
- innerRadius = _circleConfig$innerRa === void 0 ? 80 : _circleConfig$innerRa,
36
- _circleConfig$outerRa = circleConfig.outerRadius,
37
- outerRadius = _circleConfig$outerRa === void 0 ? 100 : _circleConfig$outerRa,
38
- _circleConfig$startAn = circleConfig.startAngle,
39
- startAngle = _circleConfig$startAn === void 0 ? 0 : _circleConfig$startAn,
40
- _circleConfig$endAngl = circleConfig.endAngle,
41
- endAngle = _circleConfig$endAngl === void 0 ? 360 : _circleConfig$endAngl,
42
- _circleConfig$cornerR = circleConfig.cornerRadius,
43
- cornerRadius = _circleConfig$cornerR === void 0 ? 0 : _circleConfig$cornerR,
44
- _circleConfig$padAngl = circleConfig.padAngle,
45
- padAngle = _circleConfig$padAngl === void 0 ? 0 : _circleConfig$padAngl;
46
- var arc = d3.arc().innerRadius(innerRadius).outerRadius(outerRadius).startAngle(startAngle * Math.PI / 180).endAngle(endAngle * Math.PI / 180).cornerRadius(cornerRadius).padAngle(padAngle);
47
- return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("clipPath", {
48
- id: "" + gradientId,
49
- style: {
50
- transform: "translate(50%,50%)"
51
- }
52
- }, /*#__PURE__*/React.createElement("path", {
53
- d: arc()
54
- })), /*#__PURE__*/React.createElement("foreignObject", {
55
- style: {
56
- width: "100%",
57
- height: "100%",
58
- transform: "translate(-50%,-50%)",
59
- background: colorType === "pure" ? colors : "conic-gradient(".concat(colorsToString(colors), ")"),
60
- clipPath: "url(".concat('#' + gradientId, ")")
61
- }
62
- }));
63
- }
64
-
65
- function colorsToString(colors) {
66
- var s = "";
67
- colors.sort(function (a, b) {
68
- return a.offset - b.offset;
69
- }).map(function (d) {
70
- s = s + d.color + " " + d.offset + "%,";
71
- });
72
- return s.slice(0, -1);
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = ConicGradient;
9
+
10
+ var d3 = _interopRequireWildcard(require("d3"));
11
+
12
+ //只支持在svg中使用
13
+ //在<clipPath>标签中绘制圆环路径,在<foreignObject>中使用conic-gradient来制作角向渐变
14
+ //然后在foreignObject中调用clipPath来剪切dom元素,实现环形渐变效果
15
+ function ConicGradient(props) {
16
+ var gradientId = props.gradientId,
17
+ _props$colorConfig = props.colorConfig,
18
+ colorConfig = _props$colorConfig === void 0 ? {} : _props$colorConfig,
19
+ _props$circleConfig = props.circleConfig,
20
+ circleConfig = _props$circleConfig === void 0 ? {} : _props$circleConfig,
21
+ _colorConfig$colorTyp = colorConfig.colorType,
22
+ colorType = _colorConfig$colorTyp === void 0 ? "linear" : _colorConfig$colorTyp,
23
+ _colorConfig$colors = colorConfig.colors,
24
+ colors = _colorConfig$colors === void 0 ? [{
25
+ offset: 0,
26
+ color: "rgba(255,0,0,0.5)"
27
+ }, {
28
+ offset: 50,
29
+ color: "rgba(0,255,0,0.5)"
30
+ }, {
31
+ offset: 100,
32
+ color: "rgba(0,0,255,0.5)"
33
+ }] : _colorConfig$colors,
34
+ _circleConfig$innerRa = circleConfig.innerRadius,
35
+ innerRadius = _circleConfig$innerRa === void 0 ? 80 : _circleConfig$innerRa,
36
+ _circleConfig$outerRa = circleConfig.outerRadius,
37
+ outerRadius = _circleConfig$outerRa === void 0 ? 100 : _circleConfig$outerRa,
38
+ _circleConfig$startAn = circleConfig.startAngle,
39
+ startAngle = _circleConfig$startAn === void 0 ? 0 : _circleConfig$startAn,
40
+ _circleConfig$endAngl = circleConfig.endAngle,
41
+ endAngle = _circleConfig$endAngl === void 0 ? 360 : _circleConfig$endAngl,
42
+ _circleConfig$cornerR = circleConfig.cornerRadius,
43
+ cornerRadius = _circleConfig$cornerR === void 0 ? 0 : _circleConfig$cornerR,
44
+ _circleConfig$padAngl = circleConfig.padAngle,
45
+ padAngle = _circleConfig$padAngl === void 0 ? 0 : _circleConfig$padAngl;
46
+ var arc = d3.arc().innerRadius(innerRadius).outerRadius(outerRadius).startAngle(startAngle * Math.PI / 180).endAngle(endAngle * Math.PI / 180).cornerRadius(cornerRadius).padAngle(padAngle);
47
+ return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("clipPath", {
48
+ id: "" + gradientId,
49
+ style: {
50
+ transform: "translate(50%,50%)"
51
+ }
52
+ }, /*#__PURE__*/React.createElement("path", {
53
+ d: arc()
54
+ })), /*#__PURE__*/React.createElement("foreignObject", {
55
+ style: {
56
+ width: "100%",
57
+ height: "100%",
58
+ transform: "translate(-50%,-50%)",
59
+ background: colorType === "pure" ? colors : "conic-gradient(".concat(colorsToString(colors), ")"),
60
+ clipPath: "url(".concat('#' + gradientId, ")")
61
+ }
62
+ }));
63
+ }
64
+
65
+ function colorsToString(colors) {
66
+ var s = "";
67
+ colors.sort(function (a, b) {
68
+ return a.offset - b.offset;
69
+ }).map(function (d) {
70
+ s = s + d.color + " " + d.offset + "%,";
71
+ });
72
+ return s.slice(0, -1);
73
73
  }
@@ -19,11 +19,11 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
19
19
 
20
20
  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; }
21
21
 
22
- /**
23
- * 图表数据动画
24
- * @param {Array} data data列表
25
- * @param {boolean} dataAnimation 是否开启数据增长动画
26
- * @returns 改变后的数据
22
+ /**
23
+ * 图表数据动画
24
+ * @param {Array} data data列表
25
+ * @param {boolean} dataAnimation 是否开启数据增长动画
26
+ * @returns 改变后的数据
27
27
  */
28
28
  var _default = function _default(data, dataAnimation) {
29
29
  var _useState = (0, _react.useState)([]),
@@ -34,13 +34,13 @@ var _default = function _default(data, dataAnimation) {
34
34
  (0, _react.useEffect)(function () {
35
35
  var animateRef = null;
36
36
 
37
- if (dataAnimation && data.length) {
37
+ if (dataAnimation && dataAnimation.show && dataAnimation.duration && data.length) {
38
38
  animateRef = (0, _popmotion.animate)({
39
39
  autoplay: true,
40
40
  repeat: 0,
41
41
  from: 0,
42
42
  to: 1,
43
- duration: 500,
43
+ duration: dataAnimation.duration * 1000,
44
44
  ease: _popmotion.linear,
45
45
  onUpdate: function onUpdate(v) {
46
46
  setAnimateData(function (oldData) {