@easyv/charts 1.1.4 → 1.1.7

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 (68) hide show
  1. package/.babelrc +8 -8
  2. package/.husky/commit-msg +3 -3
  3. package/CHANGELOG.md +18 -18
  4. package/commitlint.config.js +1 -1
  5. package/lib/components/AnimateData.js +2 -2
  6. package/lib/components/Axis.js +10 -10
  7. package/lib/components/Background.js +2 -2
  8. package/lib/components/Carousel.js +2 -2
  9. package/lib/components/Chart.js +2 -2
  10. package/lib/components/ConicalGradient.js +21 -21
  11. package/lib/components/Indicator.js +2 -2
  12. package/lib/components/Lighter.js +179 -179
  13. package/lib/components/LinearGradient.js +2 -2
  14. package/lib/components/StereoBar.js +2 -2
  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 +5 -5
  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/PieChart.js +1097 -1097
  45. package/src/components/StackData.js +20 -20
  46. package/src/components/StereoBar.tsx +311 -311
  47. package/src/components/Tooltip.js +168 -168
  48. package/src/components/index.js +51 -51
  49. package/src/context/index.js +2 -2
  50. package/src/css/index.module.css +41 -41
  51. package/src/css/piechart.module.css +26 -26
  52. package/src/element/ConicGradient.jsx +55 -55
  53. package/src/element/Line.tsx +33 -33
  54. package/src/element/index.ts +3 -3
  55. package/src/formatter/index.js +1 -1
  56. package/src/formatter/legend.js +90 -90
  57. package/src/hooks/index.js +17 -17
  58. package/src/hooks/useAnimateData.ts +62 -62
  59. package/src/hooks/useAxes.js +144 -144
  60. package/src/hooks/useCarouselAxisX.js +163 -163
  61. package/src/hooks/useExtentData.js +88 -88
  62. package/src/hooks/useFilterData.js +72 -72
  63. package/src/hooks/useStackData.js +100 -100
  64. package/src/hooks/useTooltip.ts +96 -96
  65. package/src/index.js +6 -6
  66. package/src/types/index.d.ts +62 -62
  67. package/src/utils/index.js +696 -696
  68. package/tsconfig.json +22 -22
package/.babelrc CHANGED
@@ -1,8 +1,8 @@
1
- {
2
- "presets": ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"],
3
- "plugins": [
4
- "@babel/plugin-proposal-export-default-from",
5
- "@babel/plugin-transform-runtime",
6
- "@babel/plugin-proposal-class-properties"
7
- ]
8
- }
1
+ {
2
+ "presets": ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"],
3
+ "plugins": [
4
+ "@babel/plugin-proposal-export-default-from",
5
+ "@babel/plugin-transform-runtime",
6
+ "@babel/plugin-proposal-class-properties"
7
+ ]
8
+ }
package/.husky/commit-msg CHANGED
@@ -1,4 +1,4 @@
1
- #!/bin/sh
2
- . "$(dirname "$0")/_/husky.sh"
3
-
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
4
  yarn commitlint --edit $1
package/CHANGELOG.md CHANGED
@@ -1,18 +1,18 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
-
5
- ### [1.1.1](https://gitlab.prod.dtstack.cn:10022/visdev/visApplication/easyv-charts/compare/v1.1.0...v1.1.1) (2022-04-13)
6
-
7
- ## 1.1.0 (2022-04-02)
8
-
9
-
10
- ### Features
11
-
12
- * 轴标签,label支持样式传入 ([749a595](https://gitlab.prod.dtstack.cn:10022/visdev/visApplication/easyv-charts/commit/749a595a96b95917dafdc1766f63efec73398d64))
13
- * axis轴标签支持点击触发回调 ([1f636e1](https://gitlab.prod.dtstack.cn:10022/visdev/visApplication/easyv-charts/commit/1f636e1840f4f3b48c2b9765ce6087759d82fb17))
14
-
15
-
16
- ### Bug Fixes
17
-
18
- * **band组件:** 修复foreignObject在Safari浏览器下的位置诡异偏离问题 ([1a65d54](https://gitlab.prod.dtstack.cn:10022/visdev/visApplication/easyv-charts/commit/1a65d54abbcf6c9e84cc85cc8b6a9d28b24fa4c4))
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ### [1.1.1](https://gitlab.prod.dtstack.cn:10022/visdev/visApplication/easyv-charts/compare/v1.1.0...v1.1.1) (2022-04-13)
6
+
7
+ ## 1.1.0 (2022-04-02)
8
+
9
+
10
+ ### Features
11
+
12
+ * 轴标签,label支持样式传入 ([749a595](https://gitlab.prod.dtstack.cn:10022/visdev/visApplication/easyv-charts/commit/749a595a96b95917dafdc1766f63efec73398d64))
13
+ * axis轴标签支持点击触发回调 ([1f636e1](https://gitlab.prod.dtstack.cn:10022/visdev/visApplication/easyv-charts/commit/1f636e1840f4f3b48c2b9765ce6087759d82fb17))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * **band组件:** 修复foreignObject在Safari浏览器下的位置诡异偏离问题 ([1a65d54](https://gitlab.prod.dtstack.cn:10022/visdev/visApplication/easyv-charts/commit/1a65d54abbcf6c9e84cc85cc8b6a9d28b24fa4c4))
@@ -1 +1 @@
1
- module.exports = {extends: ['@commitlint/config-conventional']}
1
+ module.exports = {extends: ['@commitlint/config-conventional']}
@@ -17,8 +17,8 @@ var _react = _interopRequireWildcard(require("react"));
17
17
 
18
18
  var _hooks = require("../hooks");
19
19
 
20
- /**
21
- * 用来做图表数据改变(增长)动画(HOC)
20
+ /**
21
+ * 用来做图表数据改变(增长)动画(HOC)
22
22
  */
23
23
  var _default = function _default(Component) {
24
24
  return /*#__PURE__*/(0, _react.memo)(function (_ref) {
@@ -55,16 +55,16 @@ var getAxesPath = function getAxesPath(orientation, _ref2) {
55
55
  return 'M0, -0.5V' + (height + 0.5);
56
56
  }
57
57
  };
58
- /**
59
- * 根据坐标轴位置来确定轴标签的垂直对齐方式,水平对齐方式,以及轴标签位于坐标轴的哪个方向
60
- * @param orientation 坐标轴位置
61
- * @param rotate 旋转角度
62
- * @returns {
63
- * dominantBaseline,
64
- * textAnchor,
65
- * directionX,
66
- * directionY
67
- * }
58
+ /**
59
+ * 根据坐标轴位置来确定轴标签的垂直对齐方式,水平对齐方式,以及轴标签位于坐标轴的哪个方向
60
+ * @param orientation 坐标轴位置
61
+ * @param rotate 旋转角度
62
+ * @returns {
63
+ * dominantBaseline,
64
+ * textAnchor,
65
+ * directionX,
66
+ * directionY
67
+ * }
68
68
  */
69
69
 
70
70
 
@@ -13,8 +13,8 @@ var _react = _interopRequireDefault(require("react"));
13
13
 
14
14
  var _utils = require("../utils");
15
15
 
16
- /**
17
- * 轴类图背景
16
+ /**
17
+ * 轴类图背景
18
18
  */
19
19
  var _default = function _default(_ref) {
20
20
  var _ref$axis = _ref.axis,
@@ -42,8 +42,8 @@ var defaultAnimation = {
42
42
  opacity: 100
43
43
  }
44
44
  };
45
- /**
46
- * 饼图类图表轮播逻辑,用来管理currentIndex,及回调逻辑(HOC)
45
+ /**
46
+ * 饼图类图表轮播逻辑,用来管理currentIndex,及回调逻辑(HOC)
47
47
  */
48
48
 
49
49
  var _default = function _default(Component) {
@@ -19,8 +19,8 @@ var _context = require("../context");
19
19
 
20
20
  var _ = require(".");
21
21
 
22
- /**
23
- * 总入口,通过外面传进来的type来确定渲染哪种图表,饼环图表为“pie”,否则为轴类图表
22
+ /**
23
+ * 总入口,通过外面传进来的type来确定渲染哪种图表,饼环图表为“pie”,否则为轴类图表
24
24
  */
25
25
  var getCallbackData = function getCallbackData(callbacks, data) {
26
26
  var callbackData;
@@ -19,8 +19,8 @@ var _utils = require("@easyv/utils/lib/common/utils");
19
19
 
20
20
  var _indexModule = _interopRequireDefault(require("../css/index.module.css"));
21
21
 
22
- /**
23
- * 饼图装饰内圈
22
+ /**
23
+ * 饼图装饰内圈
24
24
  */
25
25
  var _default = function _default(_ref) {
26
26
  var width = _ref.width,
@@ -123,8 +123,8 @@ var _default = function _default(_ref) {
123
123
  }
124
124
  });
125
125
  };
126
- /**
127
- * ConicalGradient
126
+ /**
127
+ * ConicalGradient
128
128
  */
129
129
 
130
130
 
@@ -136,11 +136,11 @@ function ConicalGradient() {
136
136
  }
137
137
 
138
138
  ConicalGradient.prototype = {
139
- /**
140
- * addColorStop
141
- *
142
- * @param {Number} offset
143
- * @param {Array} color RGBA值
139
+ /**
140
+ * addColorStop
141
+ *
142
+ * @param {Number} offset
143
+ * @param {Array} color RGBA值
144
144
  */
145
145
  addColorStop: function addColorStop(offset, color) {
146
146
  this._offsets.push(offset);
@@ -150,23 +150,23 @@ ConicalGradient.prototype = {
150
150
  return this;
151
151
  },
152
152
 
153
- /**
154
- * _offsetsReverse (array.forEach callback)
153
+ /**
154
+ * _offsetsReverse (array.forEach callback)
155
155
  */
156
156
  _offsetsReverse: function _offsetsReverse(offset, index, array) {
157
157
  array[index] = 1 - offset;
158
158
  },
159
159
 
160
- /**
161
- * fill
162
- *
163
- * @param {Number} context
164
- * @param {Number} x
165
- * @param {Number} y
166
- * @param {Number} radius
167
- * @param {Number} startAngle
168
- * @param {Number} endAngle
169
- * @param {Boolean} anticlockwise
160
+ /**
161
+ * fill
162
+ *
163
+ * @param {Number} context
164
+ * @param {Number} x
165
+ * @param {Number} y
166
+ * @param {Number} radius
167
+ * @param {Number} startAngle
168
+ * @param {Number} endAngle
169
+ * @param {Boolean} anticlockwise
170
170
  */
171
171
  fill: function fill(context, x, y, radius, startAngle, endAngle, anticlockwise) {
172
172
  var offsets = this._offsets;
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
 
8
- /**
9
- * 轴类图表移上去的指示框背景
8
+ /**
9
+ * 轴类图表移上去的指示框背景
10
10
  */
11
11
  var _default = function _default(_ref) {
12
12
  var color = _ref.color,
@@ -1,180 +1,180 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports["default"] = void 0;
11
-
12
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
-
14
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
-
16
- var _react = _interopRequireWildcard(require("react"));
17
-
18
- var _d3v = require("d3v7");
19
-
20
- var _utils = require("../utils");
21
-
22
- var _svgPathProperties = require("svg-path-properties");
23
-
24
- /**
25
- * 区域图发光跟踪路径
26
- */
27
- var _default = function _default(_ref) {
28
- var d = _ref.path,
29
- config = _ref.config,
30
- _ref$config = _ref.config,
31
- curveLength = _ref$config.length,
32
- width = _ref$config.width,
33
- fill = _ref$config.fill,
34
- unitStep = _ref$config.unitStep;
35
- var pointIndexRef = (0, _react.useRef)(0);
36
- var raf = (0, _react.useRef)(null);
37
-
38
- var _useState = (0, _react.useState)([]),
39
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
40
- points = _useState2[0],
41
- setPoints = _useState2[1];
42
-
43
- var _useState3 = (0, _react.useState)(null),
44
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
45
- lighter = _useState4[0],
46
- setLighter = _useState4[1];
47
-
48
- var pointLength = points.length;
49
- var totalLength = getLength(pointLength, curveLength);
50
- var easingFunc = easing.linear;
51
- var interpolateList = (0, _react.useMemo)(function () {
52
- return getColorsInterpolate((0, _utils.getColorList)(fill));
53
- }, [fill]);
54
- var drawLigher = (0, _react.useCallback)(function () {
55
- var STEP = 2;
56
- var LOOP = false;
57
-
58
- if (lighter && lighter.children) {
59
- var currentPointLength = pointIndexRef.current;
60
- var pointIndex = currentPointLength >= totalLength ? LOOP ? curveLength : 0 : currentPointLength + unitStep + Math.floor(easingFunc(pointIndexRef.current / totalLength) * STEP);
61
- var overstep = pointIndex - pointLength;
62
- var startIndex = getPointIndex(pointIndex, pointLength, curveLength);
63
- var endIndex = getPointIndex(pointIndex + curveLength, pointLength, curveLength);
64
- var overstepPoints = LOOP && overstep > 0 ? points.slice(0, overstep) : [];
65
- drawCircle(Array.from(lighter.children), [].concat((0, _toConsumableArray2["default"])(points.slice(startIndex, endIndex)), (0, _toConsumableArray2["default"])(overstepPoints)), interpolateList);
66
- pointIndexRef.current = pointIndex;
67
- }
68
-
69
- raf.current = requestAnimationFrame(drawLigher);
70
- }, [lighter, totalLength, curveLength, unitStep, points, interpolateList]);
71
- (0, _react.useEffect)(function () {
72
- var path = new _svgPathProperties.svgPathProperties(d);
73
- var totalLength = path.getTotalLength();
74
- var points = [];
75
-
76
- for (var i = 0; i < totalLength; i++) {
77
- var _path$getPointAtLengt = path.getPointAtLength(i),
78
- x = _path$getPointAtLengt.x,
79
- y = _path$getPointAtLengt.y;
80
-
81
- points.push({
82
- index: i,
83
- x: x,
84
- y: y
85
- });
86
- }
87
-
88
- setPoints(points);
89
- }, [d, config]);
90
- (0, _react.useEffect)(function () {
91
- raf.current = requestAnimationFrame(drawLigher);
92
- return function () {
93
- cancelAnimationFrame(raf.current);
94
- };
95
- }, [drawLigher]);
96
- return /*#__PURE__*/_react["default"].createElement("g", {
97
- ref: setLighter
98
- }, points.map(function (_ref2, index) {
99
- var x = _ref2.x,
100
- y = _ref2.y;
101
- return /*#__PURE__*/_react["default"].createElement("circle", {
102
- cx: x,
103
- cy: y,
104
- key: index,
105
- r: width,
106
- fill: "none"
107
- });
108
- }));
109
- };
110
-
111
- exports["default"] = _default;
112
-
113
- var drawCircle = function drawCircle(children, points, interpolateList) {
114
- var pointLength = points.length; // const [startPoint] = points;
115
- // const startIndex = startPoint ? startPoint.index : 0;
116
-
117
- children.forEach(function (child, index) {
118
- var pointIndex = points.findIndex(function (_ref3) {
119
- var i = _ref3.index;
120
- return i == index;
121
- });
122
- child.setAttribute('fill', pointIndex > -1 ? getColor(pointIndex / pointLength, //TODO: 颜色插值尚需完善
123
- interpolateList) : 'none');
124
- });
125
- };
126
-
127
- var getColor = function getColor(x, interpolateList) {
128
- return interpolateList(x);
129
- };
130
-
131
- var getLength = function getLength(pointLength, length) {
132
- if (length > pointLength) {
133
- return pointLength * 2;
134
- }
135
-
136
- return pointLength + length;
137
- };
138
-
139
- var getColorsInterpolate = function getColorsInterpolate(colors) {
140
- var length = colors.length;
141
- if (!!(length < 2)) return (0, _d3v.scaleLinear)().domain([0, 1]).range([colors[0].color || '#000', colors[0].color || '#000']);
142
- var linear = (0, _d3v.scaleLinear)().domain(colors.map(function (d) {
143
- return d.offset;
144
- })).range(colors.map(function (d) {
145
- return d.color;
146
- }));
147
- return linear;
148
- };
149
-
150
- var easing = {
151
- linear: function linear() {
152
- return 0;
153
- },
154
- easeIn: function easeIn(k) {
155
- return Math.pow(k, 3);
156
- },
157
- easeOut: function easeOut(k) {
158
- return 1 - easing.easeIn(1 - k);
159
- },
160
- easeInOut: function easeInOut(k) {
161
- return k < 0.5 ? easing.easeIn(k * 2) / 2 : 1 - easing.easeIn(2 - 2 * k) / 2;
162
- },
163
- easeOutIn: function easeOutIn(k) {
164
- return k < 0.5 ? 0.5 * (1 - easing.easeIn(1 - 2 * k)) : 0.5 * easing.easeIn(k * 2 - 1) + 0.5;
165
- }
166
- };
167
-
168
- var getPointIndex = function getPointIndex(pointIndex, pointLength, curveLength) {
169
- var index = pointIndex - curveLength;
170
-
171
- if (index < 0) {
172
- return 0;
173
- }
174
-
175
- if (index >= pointLength) {
176
- return pointLength - 1;
177
- }
178
-
179
- return index;
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
+
5
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports["default"] = void 0;
11
+
12
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
+
14
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
+
16
+ var _react = _interopRequireWildcard(require("react"));
17
+
18
+ var _d3v = require("d3v7");
19
+
20
+ var _utils = require("../utils");
21
+
22
+ var _svgPathProperties = require("svg-path-properties");
23
+
24
+ /**
25
+ * 区域图发光跟踪路径
26
+ */
27
+ var _default = function _default(_ref) {
28
+ var d = _ref.path,
29
+ config = _ref.config,
30
+ _ref$config = _ref.config,
31
+ curveLength = _ref$config.length,
32
+ width = _ref$config.width,
33
+ fill = _ref$config.fill,
34
+ unitStep = _ref$config.unitStep;
35
+ var pointIndexRef = (0, _react.useRef)(0);
36
+ var raf = (0, _react.useRef)(null);
37
+
38
+ var _useState = (0, _react.useState)([]),
39
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
40
+ points = _useState2[0],
41
+ setPoints = _useState2[1];
42
+
43
+ var _useState3 = (0, _react.useState)(null),
44
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
45
+ lighter = _useState4[0],
46
+ setLighter = _useState4[1];
47
+
48
+ var pointLength = points.length;
49
+ var totalLength = getLength(pointLength, curveLength);
50
+ var easingFunc = easing.linear;
51
+ var interpolateList = (0, _react.useMemo)(function () {
52
+ return getColorsInterpolate((0, _utils.getColorList)(fill));
53
+ }, [fill]);
54
+ var drawLigher = (0, _react.useCallback)(function () {
55
+ var STEP = 2;
56
+ var LOOP = false;
57
+
58
+ if (lighter && lighter.children) {
59
+ var currentPointLength = pointIndexRef.current;
60
+ var pointIndex = currentPointLength >= totalLength ? LOOP ? curveLength : 0 : currentPointLength + unitStep + Math.floor(easingFunc(pointIndexRef.current / totalLength) * STEP);
61
+ var overstep = pointIndex - pointLength;
62
+ var startIndex = getPointIndex(pointIndex, pointLength, curveLength);
63
+ var endIndex = getPointIndex(pointIndex + curveLength, pointLength, curveLength);
64
+ var overstepPoints = LOOP && overstep > 0 ? points.slice(0, overstep) : [];
65
+ drawCircle(Array.from(lighter.children), [].concat((0, _toConsumableArray2["default"])(points.slice(startIndex, endIndex)), (0, _toConsumableArray2["default"])(overstepPoints)), interpolateList);
66
+ pointIndexRef.current = pointIndex;
67
+ }
68
+
69
+ raf.current = requestAnimationFrame(drawLigher);
70
+ }, [lighter, totalLength, curveLength, unitStep, points, interpolateList]);
71
+ (0, _react.useEffect)(function () {
72
+ var path = new _svgPathProperties.svgPathProperties(d);
73
+ var totalLength = path.getTotalLength();
74
+ var points = [];
75
+
76
+ for (var i = 0; i < totalLength; i++) {
77
+ var _path$getPointAtLengt = path.getPointAtLength(i),
78
+ x = _path$getPointAtLengt.x,
79
+ y = _path$getPointAtLengt.y;
80
+
81
+ points.push({
82
+ index: i,
83
+ x: x,
84
+ y: y
85
+ });
86
+ }
87
+
88
+ setPoints(points);
89
+ }, [d, config]);
90
+ (0, _react.useEffect)(function () {
91
+ raf.current = requestAnimationFrame(drawLigher);
92
+ return function () {
93
+ cancelAnimationFrame(raf.current);
94
+ };
95
+ }, [drawLigher]);
96
+ return /*#__PURE__*/_react["default"].createElement("g", {
97
+ ref: setLighter
98
+ }, points.map(function (_ref2, index) {
99
+ var x = _ref2.x,
100
+ y = _ref2.y;
101
+ return /*#__PURE__*/_react["default"].createElement("circle", {
102
+ cx: x,
103
+ cy: y,
104
+ key: index,
105
+ r: width,
106
+ fill: "none"
107
+ });
108
+ }));
109
+ };
110
+
111
+ exports["default"] = _default;
112
+
113
+ var drawCircle = function drawCircle(children, points, interpolateList) {
114
+ var pointLength = points.length; // const [startPoint] = points;
115
+ // const startIndex = startPoint ? startPoint.index : 0;
116
+
117
+ children.forEach(function (child, index) {
118
+ var pointIndex = points.findIndex(function (_ref3) {
119
+ var i = _ref3.index;
120
+ return i == index;
121
+ });
122
+ child.setAttribute('fill', pointIndex > -1 ? getColor(pointIndex / pointLength, //TODO: 颜色插值尚需完善
123
+ interpolateList) : 'none');
124
+ });
125
+ };
126
+
127
+ var getColor = function getColor(x, interpolateList) {
128
+ return interpolateList(x);
129
+ };
130
+
131
+ var getLength = function getLength(pointLength, length) {
132
+ if (length > pointLength) {
133
+ return pointLength * 2;
134
+ }
135
+
136
+ return pointLength + length;
137
+ };
138
+
139
+ var getColorsInterpolate = function getColorsInterpolate(colors) {
140
+ var length = colors.length;
141
+ if (!!(length < 2)) return (0, _d3v.scaleLinear)().domain([0, 1]).range([colors[0].color || '#000', colors[0].color || '#000']);
142
+ var linear = (0, _d3v.scaleLinear)().domain(colors.map(function (d) {
143
+ return d.offset;
144
+ })).range(colors.map(function (d) {
145
+ return d.color;
146
+ }));
147
+ return linear;
148
+ };
149
+
150
+ var easing = {
151
+ linear: function linear() {
152
+ return 0;
153
+ },
154
+ easeIn: function easeIn(k) {
155
+ return Math.pow(k, 3);
156
+ },
157
+ easeOut: function easeOut(k) {
158
+ return 1 - easing.easeIn(1 - k);
159
+ },
160
+ easeInOut: function easeInOut(k) {
161
+ return k < 0.5 ? easing.easeIn(k * 2) / 2 : 1 - easing.easeIn(2 - 2 * k) / 2;
162
+ },
163
+ easeOutIn: function easeOutIn(k) {
164
+ return k < 0.5 ? 0.5 * (1 - easing.easeIn(1 - 2 * k)) : 0.5 * easing.easeIn(k * 2 - 1) + 0.5;
165
+ }
166
+ };
167
+
168
+ var getPointIndex = function getPointIndex(pointIndex, pointLength, curveLength) {
169
+ var index = pointIndex - curveLength;
170
+
171
+ if (index < 0) {
172
+ return 0;
173
+ }
174
+
175
+ if (index >= pointLength) {
176
+ return pointLength - 1;
177
+ }
178
+
179
+ return index;
180
180
  };
@@ -9,8 +9,8 @@ exports["default"] = void 0;
9
9
 
10
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
11
 
12
- /**
13
- * svg渐变滤镜
12
+ /**
13
+ * svg渐变滤镜
14
14
  */
15
15
  var _default = function _default(_ref) {
16
16
  var id = _ref.id,
@@ -330,8 +330,8 @@ function getTopColor(stops, angle) {
330
330
  }
331
331
 
332
332
  if (a >= 90 && a < 270) {
333
- return stops[0].color;
334
- } else {
335
333
  return stops[stops.length - 1].color;
334
+ } else {
335
+ return stops[0].color;
336
336
  }
337
337
  }