@easyv/charts 1.4.25 → 1.4.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) 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 +8 -16
  6. package/lib/components/Axis.js +86 -133
  7. package/lib/components/Background.js +18 -26
  8. package/lib/components/Band.js +72 -98
  9. package/lib/components/BaseLine.js +33 -46
  10. package/lib/components/Brush.js +29 -46
  11. package/lib/components/Carousel.js +13 -40
  12. package/lib/components/CartesianChart.js +98 -146
  13. package/lib/components/Chart.js +23 -36
  14. package/lib/components/ChartContainer.js +18 -27
  15. package/lib/components/ConicalGradient.js +56 -89
  16. package/lib/components/Control.js +12 -28
  17. package/lib/components/ExtentData.js +9 -17
  18. package/lib/components/FilterData.js +16 -27
  19. package/lib/components/Indicator.js +23 -30
  20. package/lib/components/Label.js +96 -126
  21. package/lib/components/Legend.js +41 -66
  22. package/lib/components/Lighter.js +21 -50
  23. package/lib/components/Line.js +39 -59
  24. package/lib/components/LinearGradient.js +16 -22
  25. package/lib/components/Mapping.js +9 -34
  26. package/lib/components/Marquee.js +14 -30
  27. package/lib/components/PieChart.js +457 -487
  28. package/lib/components/StackData.js +8 -18
  29. package/lib/components/StereoBar.js +65 -105
  30. package/lib/components/TextOverflow.js +8 -21
  31. package/lib/components/Tooltip.js +41 -55
  32. package/lib/components/index.js +7 -28
  33. package/lib/components/pieTooltip.js +132 -0
  34. package/lib/context/index.js +0 -2
  35. package/lib/css/index.module.css +42 -42
  36. package/lib/css/piechart.module.css +26 -26
  37. package/lib/element/ConicGradient.js +29 -35
  38. package/lib/element/Line.js +9 -13
  39. package/lib/element/index.js +0 -2
  40. package/lib/formatter/index.js +0 -2
  41. package/lib/formatter/legend.js +30 -41
  42. package/lib/hooks/index.js +0 -9
  43. package/lib/hooks/useAiData.js +12 -20
  44. package/lib/hooks/useAnimateData.js +8 -21
  45. package/lib/hooks/useAxes.js +67 -117
  46. package/lib/hooks/useCarouselAxisX.js +27 -60
  47. package/lib/hooks/useExtentData.js +14 -46
  48. package/lib/hooks/useFilterData.js +13 -34
  49. package/lib/hooks/useStackData.js +12 -35
  50. package/lib/hooks/useTooltip.js +36 -53
  51. package/lib/index.js +0 -15
  52. package/lib/utils/index.js +95 -247
  53. package/package.json +55 -55
  54. package/src/components/Background.tsx +61 -61
  55. package/src/components/Band.tsx +274 -274
  56. package/src/components/Brush.js +159 -159
  57. package/src/components/CartesianChart.js +1 -1
  58. package/src/components/Chart.js +99 -99
  59. package/src/components/ChartContainer.tsx +71 -71
  60. package/src/components/ConicalGradient.js +258 -258
  61. package/src/components/Control.jsx +51 -51
  62. package/src/components/ExtentData.js +17 -17
  63. package/src/components/Indicator.js +61 -61
  64. package/src/components/Label.js +275 -275
  65. package/src/components/Legend.js +165 -165
  66. package/src/components/Lighter.jsx +173 -173
  67. package/src/components/Line.js +150 -150
  68. package/src/components/LinearGradient.js +29 -29
  69. package/src/components/Marquee.tsx +1 -1
  70. package/src/components/PieChart.js +403 -260
  71. package/src/components/PieTooltip.jsx +134 -0
  72. package/src/components/StereoBar.tsx +307 -307
  73. package/src/components/index.js +59 -57
  74. package/src/context/index.js +2 -2
  75. package/src/css/index.module.css +42 -42
  76. package/src/css/piechart.module.css +26 -26
  77. package/src/element/ConicGradient.jsx +55 -55
  78. package/src/element/Line.tsx +33 -33
  79. package/src/element/index.ts +3 -3
  80. package/src/formatter/index.js +1 -1
  81. package/src/formatter/legend.js +92 -92
  82. package/src/hooks/index.js +20 -20
  83. package/src/hooks/useAnimateData.ts +67 -67
  84. package/src/hooks/useCarouselAxisX.js +1 -1
  85. package/src/hooks/useFilterData.js +72 -72
  86. package/src/hooks/useStackData.js +101 -101
  87. package/src/hooks/useTooltip.ts +100 -100
  88. package/src/index.js +6 -6
  89. package/src/types/index.d.ts +67 -67
  90. package/src/utils/index.js +757 -757
  91. package/tsconfig.json +23 -23
@@ -1,37 +1,23 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports["default"] = void 0;
11
-
12
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
-
14
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
-
16
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
-
18
12
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
19
-
20
13
  var _react = _interopRequireWildcard(require("react"));
21
-
22
14
  var _d3v = require("d3v7");
23
-
24
15
  var _excluded = ["animation"],
25
- _excluded2 = ["config", "data"];
26
-
16
+ _excluded2 = ["config", "data"];
27
17
  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); }
28
-
29
18
  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; }
30
-
31
19
  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; }
32
-
33
20
  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; }
34
-
35
21
  var initialState = {
36
22
  currentIndex: null,
37
23
  trigger: ''
@@ -52,29 +38,24 @@ var defaultAnimation = {
52
38
  /**
53
39
  * 饼图类图表轮播逻辑,用来管理currentIndex,及回调逻辑(HOC)
54
40
  */
55
-
56
41
  var _default = function _default(Component) {
57
42
  return /*#__PURE__*/(0, _react.memo)(function (_ref) {
58
43
  var _ref$config = _ref.config,
59
- animation = _ref$config.animation,
60
- config = (0, _objectWithoutProperties2["default"])(_ref$config, _excluded),
61
- _ref$data = _ref.data,
62
- data = _ref$data === void 0 ? [] : _ref$data,
63
- rest = (0, _objectWithoutProperties2["default"])(_ref, _excluded2);
44
+ animation = _ref$config.animation,
45
+ config = (0, _objectWithoutProperties2["default"])(_ref$config, _excluded),
46
+ _ref$data = _ref.data,
47
+ data = _ref$data === void 0 ? [] : _ref$data,
48
+ rest = (0, _objectWithoutProperties2["default"])(_ref, _excluded2);
64
49
  var dataLength = data.length;
65
-
66
50
  var _animation = Object.assign({}, defaultAnimation, animation);
67
-
68
51
  var on = _animation.on,
69
- interval = _animation.interval,
70
- interactive = _animation.interactive,
71
- hoverStop = _animation.hoverStop;
72
-
52
+ interval = _animation.interval,
53
+ interactive = _animation.interactive,
54
+ hoverStop = _animation.hoverStop;
73
55
  var _useState = (0, _react.useState)(on ? carouselState : initialState),
74
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
75
- state = _useState2[0],
76
- setState = _useState2[1];
77
-
56
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
57
+ state = _useState2[0],
58
+ setState = _useState2[1];
78
59
  var timer = (0, _react.useRef)(null);
79
60
  var hoverState = (0, _react.useRef)(false);
80
61
  var animationOn = on && interval && dataLength;
@@ -110,8 +91,7 @@ var _default = function _default(Component) {
110
91
  }, [carousel]);
111
92
  var onEvent = (0, _react.useCallback)(function (_ref3) {
112
93
  var currentIndex = _ref3.currentIndex,
113
- type = _ref3.type;
114
-
94
+ type = _ref3.type;
115
95
  switch (interactive) {
116
96
  case true:
117
97
  case 'click':
@@ -123,9 +103,7 @@ var _default = function _default(Component) {
123
103
  currentIndex: currentIndex
124
104
  });
125
105
  }
126
-
127
106
  break;
128
-
129
107
  case 'hover':
130
108
  if (type == 'onMouseEnter') {
131
109
  setState({
@@ -136,13 +114,10 @@ var _default = function _default(Component) {
136
114
  } else if (type == 'onMouseLeave') {
137
115
  !hoverState.current && animationOn && carousel();
138
116
  }
139
-
140
117
  break;
141
-
142
118
  case false:
143
119
  case '':
144
120
  break;
145
-
146
121
  case 'carousel':
147
122
  default:
148
123
  setState({
@@ -159,7 +134,6 @@ var _default = function _default(Component) {
159
134
  timer.current && timer.current.stop();
160
135
  } else {
161
136
  hoverState.current = false;
162
-
163
137
  if (animationOn) {
164
138
  timer.current = (0, _d3v.interval)(function () {
165
139
  setState(function (_ref4) {
@@ -186,5 +160,4 @@ var _default = function _default(Component) {
186
160
  }));
187
161
  });
188
162
  };
189
-
190
163
  exports["default"] = _default;
@@ -1,97 +1,82 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports["default"] = void 0;
11
-
12
9
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
-
14
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
15
-
16
11
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
17
-
18
12
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
19
-
20
13
  var _react = _interopRequireWildcard(require("react"));
21
-
22
14
  var _hooks = require("../hooks");
23
-
24
15
  var _context = require("../context");
25
-
26
16
  var _ = require(".");
27
-
28
17
  var _utils = require("../utils");
29
-
30
18
  var _excluded = ["Component", "yOrZ"],
31
- _excluded2 = ["Component", "yOrZ"];
32
-
19
+ _excluded2 = ["Component", "yOrZ"];
20
+ /**
21
+ * 轴类图表
22
+ */
33
23
  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); }
34
-
35
24
  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; }
36
-
37
25
  var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
38
26
  var _ref$config = _ref.config,
39
- axesConfig = _ref$config.axes,
40
- background = _ref$config.background,
41
- _ref$config$chart = _ref$config.chart,
42
- _ref$config$chart$dim = _ref$config$chart.dimension.chartDimension,
43
- height = _ref$config$chart$dim.height,
44
- width = _ref$config$chart$dim.width,
45
- _ref$config$chart$mar = _ref$config$chart.margin,
46
- marginLeft = _ref$config$chart$mar.marginLeft,
47
- marginTop = _ref$config$chart$mar.marginTop,
48
- marginRight = _ref$config$chart$mar.marginRight,
49
- marginBottom = _ref$config$chart$mar.marginBottom,
50
- animation = _ref$config$chart.animation,
51
- legend = _ref$config$chart.legend,
52
- series = _ref$config.series,
53
- bandLength = _ref$config.bandLength,
54
- tooltip = _ref$config.tooltip,
55
- _ref$config$baseLine = _ref$config.baseLine,
56
- _ref$config$baseLine$ = _ref$config$baseLine.orientation,
57
- baseLineOri = _ref$config$baseLine$ === void 0 ? "" : _ref$config$baseLine$,
58
- _ref$config$baseLine$2 = _ref$config$baseLine.config,
59
- baseLineConfig = _ref$config$baseLine$2 === void 0 ? {} : _ref$config$baseLine$2,
60
- _ref$config$baseLine$3 = _ref$config$baseLine.data,
61
- baseLineData = _ref$config$baseLine$3 === void 0 ? [] : _ref$config$baseLine$3,
62
- _ref$config$tooltip = _ref$config.tooltip;
63
- _ref$config$tooltip = _ref$config$tooltip === void 0 ? {} : _ref$config$tooltip;
64
- var _ref$config$tooltip$c = _ref$config$tooltip.config,
65
- tooltipConfig = _ref$config$tooltip$c === void 0 ? {} : _ref$config$tooltip$c,
66
- _ref$config$tooltip$c2 = _ref$config$tooltip.config;
67
- _ref$config$tooltip$c2 = _ref$config$tooltip$c2 === void 0 ? {} : _ref$config$tooltip$c2;
68
- var auto = _ref$config$tooltip$c2.auto,
69
- manual = _ref$config$tooltip$c2.manual,
70
- _ref$config$tooltip$c3 = _ref$config$tooltip$c2.indicator,
71
- indicator = _ref$config$tooltip$c3 === void 0 ? {} : _ref$config$tooltip$c3,
72
- brush = _ref$config.brush,
73
- _ref$config$isControl = _ref$config.isControlChart,
74
- isControlChart = _ref$config$isControl === void 0 ? false : _ref$config$isControl,
75
- _ref$config$control = _ref$config.control,
76
- control = _ref$config$control === void 0 ? null : _ref$config$control,
77
- style = _ref.style,
78
- originData = _ref.originData,
79
- filterData = _ref.filterData,
80
- aiFormatter = _ref.aiFormatter,
81
- id = _ref.id;
27
+ axesConfig = _ref$config.axes,
28
+ background = _ref$config.background,
29
+ _ref$config$chart = _ref$config.chart,
30
+ _ref$config$chart$dim = _ref$config$chart.dimension.chartDimension,
31
+ height = _ref$config$chart$dim.height,
32
+ width = _ref$config$chart$dim.width,
33
+ _ref$config$chart$mar = _ref$config$chart.margin,
34
+ marginLeft = _ref$config$chart$mar.marginLeft,
35
+ marginTop = _ref$config$chart$mar.marginTop,
36
+ marginRight = _ref$config$chart$mar.marginRight,
37
+ marginBottom = _ref$config$chart$mar.marginBottom,
38
+ animation = _ref$config$chart.animation,
39
+ legend = _ref$config$chart.legend,
40
+ series = _ref$config.series,
41
+ bandLength = _ref$config.bandLength,
42
+ tooltip = _ref$config.tooltip,
43
+ _ref$config$baseLine = _ref$config.baseLine,
44
+ _ref$config$baseLine$ = _ref$config$baseLine.orientation,
45
+ baseLineOri = _ref$config$baseLine$ === void 0 ? "" : _ref$config$baseLine$,
46
+ _ref$config$baseLine$2 = _ref$config$baseLine.config,
47
+ baseLineConfig = _ref$config$baseLine$2 === void 0 ? {} : _ref$config$baseLine$2,
48
+ _ref$config$baseLine$3 = _ref$config$baseLine.data,
49
+ baseLineData = _ref$config$baseLine$3 === void 0 ? [] : _ref$config$baseLine$3,
50
+ _ref$config$tooltip = _ref$config.tooltip,
51
+ _ref$config$tooltip2 = _ref$config$tooltip === void 0 ? {} : _ref$config$tooltip,
52
+ _ref$config$tooltip2$ = _ref$config$tooltip2.config,
53
+ tooltipConfig = _ref$config$tooltip2$ === void 0 ? {} : _ref$config$tooltip2$,
54
+ _ref$config$tooltip2$2 = _ref$config$tooltip2.config,
55
+ _ref$config$tooltip2$3 = _ref$config$tooltip2$2 === void 0 ? {} : _ref$config$tooltip2$2,
56
+ auto = _ref$config$tooltip2$3.auto,
57
+ manual = _ref$config$tooltip2$3.manual,
58
+ _ref$config$tooltip2$4 = _ref$config$tooltip2$3.indicator,
59
+ indicator = _ref$config$tooltip2$4 === void 0 ? {} : _ref$config$tooltip2$4,
60
+ brush = _ref$config.brush,
61
+ _ref$config$isControl = _ref$config.isControlChart,
62
+ isControlChart = _ref$config$isControl === void 0 ? false : _ref$config$isControl,
63
+ _ref$config$control = _ref$config.control,
64
+ control = _ref$config$control === void 0 ? null : _ref$config$control,
65
+ style = _ref.style,
66
+ originData = _ref.originData,
67
+ filterData = _ref.filterData,
68
+ aiFormatter = _ref.aiFormatter,
69
+ id = _ref.id;
82
70
  var context = (0, _react.useContext)(_context.chartContext);
83
-
84
71
  var _useState = (0, _react.useState)(false),
85
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
86
- isHover = _useState2[0],
87
- setIsHover = _useState2[1];
88
-
72
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
73
+ isHover = _useState2[0],
74
+ setIsHover = _useState2[1];
89
75
  var _useContext = (0, _react.useContext)(_context.chartContext),
90
- chartWidth = _useContext.width,
91
- chartHeight = _useContext.height,
92
- triggerOnRelative = _useContext.triggerOnRelative,
93
- onEmit = _useContext.onEmit;
94
-
76
+ chartWidth = _useContext.width,
77
+ chartHeight = _useContext.height,
78
+ triggerOnRelative = _useContext.triggerOnRelative,
79
+ onEmit = _useContext.onEmit;
95
80
  var svg = (0, _react.useRef)();
96
81
  var axes = (0, _hooks.useAxes)({
97
82
  axes: axesConfig,
@@ -99,7 +84,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
99
84
  isControlChart: isControlChart,
100
85
  control: control
101
86
  });
102
- var aiData = aiFormatter ? aiFormatter(originData, axes, series) : useAiData(originData, axes, series);
87
+ var aiData = aiFormatter ? aiFormatter(originData, axes, series) : (0, _hooks.useAiData)(originData, axes, series);
103
88
  var axisX = (0, _hooks.useCarouselAxisX)(axes.get("x"), animation, isHover, isControlChart, control);
104
89
  var xLineRange = width - marginLeft - marginRight;
105
90
  var yLineRange = height - marginTop - marginBottom;
@@ -108,33 +93,29 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
108
93
  if (!window.aiData) {
109
94
  window.aiData = {};
110
95
  }
111
-
112
96
  window.aiData[id] = {
113
97
  getAI: function getAI() {
114
98
  return aiData;
115
99
  }
116
100
  };
117
101
  }
118
-
119
102
  return function () {
120
103
  window.aiData && window.aiData[id] && delete window.aiData[id];
121
104
  };
122
105
  }, [JSON.stringify(aiData), id]);
123
-
124
106
  var _useTooltip = (0, _hooks.useTooltip)({
125
- svg: svg,
126
- marginLeft: marginLeft,
127
- marginTop: marginTop,
128
- width: chartWidth,
129
- height: chartHeight,
130
- axisX: axisX,
131
- isHover: isHover,
132
- config: tooltipConfig
133
- }),
134
- tooltipX = _useTooltip.x,
135
- tickName = _useTooltip.name,
136
- setIndex = _useTooltip.setIndex;
137
-
107
+ svg: svg,
108
+ marginLeft: marginLeft,
109
+ marginTop: marginTop,
110
+ width: chartWidth,
111
+ height: chartHeight,
112
+ axisX: axisX,
113
+ isHover: isHover,
114
+ config: tooltipConfig
115
+ }),
116
+ tooltipX = _useTooltip.x,
117
+ tickName = _useTooltip.name,
118
+ setIndex = _useTooltip.setIndex;
138
119
  var tooltipData = (0, _react.useMemo)(function () {
139
120
  return tickName !== undefined && originData.filter(function (d) {
140
121
  return d.x === tickName;
@@ -156,16 +137,14 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
156
137
  var onInteraction = (0, _react.useCallback)(function (e) {
157
138
  e.stopPropagation();
158
139
  var data = e.currentTarget.dataset.data;
159
-
160
140
  var _data = JSON.parse(data);
161
-
162
141
  triggerOnRelative(_data);
163
142
  onEmit("click", _data);
164
143
  }, [triggerOnRelative, onEmit]);
144
+
165
145
  /**
166
146
  * 控制图相关
167
147
  */
168
-
169
148
  var controlEl = (0, _react.useRef)();
170
149
  var seriesEl = (0, _react.useRef)(null);
171
150
  var axisElList = (0, _react.useRef)([]);
@@ -177,7 +156,6 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
177
156
  var rawTranslateX = 0;
178
157
  var percent = 0;
179
158
  var controlWidth = xLineRange * control.drag.width / 100;
180
-
181
159
  var range = function range(num) {
182
160
  var _num = num;
183
161
  var min = 0;
@@ -186,17 +164,15 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
186
164
  _num = Math.min(_num, max);
187
165
  return _num;
188
166
  };
189
-
190
167
  var setControlTranslate = function setControlTranslate(x) {
191
168
  var moveLen = range(x);
192
- controlEl.current.style.transform = "translateX(".concat(moveLen, "px)"); //计算出当前位移的百分比
193
-
169
+ controlEl.current.style.transform = "translateX(".concat(moveLen, "px)");
170
+ //计算出当前位移的百分比
194
171
  percent = moveLen / (xLineRange - controlWidth);
195
172
  curControlPercent.current = percent;
196
173
  seriesEl.current.style.transform = "translate(".concat(-(axisX.controlEnd - axisX.end) * percent, "px,").concat(marginTop, "px)");
197
174
  axisElList.current[2].style.transform = "translate(".concat(-(axisX.controlEnd - axisX.end) * percent, "px,", 0, "px)");
198
175
  };
199
-
200
176
  var mouseDownHandle = function mouseDownHandle(e) {
201
177
  var mouseMoveHandle = function mouseMoveHandle(e) {
202
178
  //当前位移的距离
@@ -205,7 +181,6 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
205
181
  setControlTranslate(movementX + rawTranslateX);
206
182
  }
207
183
  };
208
-
209
184
  var mouseUpHandle = function mouseUpHandle(e) {
210
185
  rawTranslateX = range(movementX + rawTranslateX);
211
186
  movementX = 0;
@@ -213,32 +188,27 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
213
188
  document.removeEventListener("mousemove", mouseMoveHandle);
214
189
  document.removeEventListener("mouseup", mouseUpHandle);
215
190
  };
216
-
217
191
  document.addEventListener("mousemove", mouseMoveHandle);
218
192
  document.addEventListener("mouseup", mouseUpHandle);
219
193
  isDragging = true;
220
194
  };
221
-
222
195
  var animationHoverStop;
223
-
224
196
  var setAnimationHoverStopTrue = function setAnimationHoverStopTrue() {
225
197
  animationHoverStop = true;
226
198
  };
227
-
228
199
  var setAnimationHoverStopFalse = function setAnimationHoverStopFalse() {
229
200
  animationHoverStop = false;
230
201
  };
231
-
232
202
  svg.current.addEventListener("mouseenter", setAnimationHoverStopTrue);
233
- svg.current.addEventListener("mouseleave", setAnimationHoverStopFalse); //控制图轮播动画逻辑
203
+ svg.current.addEventListener("mouseleave", setAnimationHoverStopFalse);
234
204
 
205
+ //控制图轮播动画逻辑
235
206
  var show = animation.show,
236
- duration = animation.duration,
237
- interval = animation.interval,
238
- hover = animation.hover;
207
+ duration = animation.duration,
208
+ interval = animation.interval,
209
+ hover = animation.hover;
239
210
  var times = Math.floor(xLineRange / controlWidth);
240
211
  var animatePos = [];
241
-
242
212
  for (var i = 0; i <= times; i++) {
243
213
  if (i * controlWidth <= xLineRange) {
244
214
  animatePos.push(i * controlWidth);
@@ -246,40 +216,31 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
246
216
  animatePos.push(xLineRange - controlWidth);
247
217
  }
248
218
  }
249
-
250
219
  var index = 0;
251
220
  var animationId;
252
-
253
221
  if (animation.show) {
254
222
  var initTime, timeGap;
255
-
256
223
  var _animation = function _animation(timestamp) {
257
224
  if (!initTime) {
258
225
  initTime = timestamp;
259
226
  }
260
-
261
227
  if (animationHoverStop && hover) {
262
228
  initTime = timestamp - timeGap;
263
229
  }
264
-
265
230
  timeGap = timestamp - initTime;
266
-
267
231
  if (timeGap < (interval + duration) * 1000) {
268
232
  if (timeGap < duration * 1000) {
269
233
  var p = timeGap / (duration * 1000);
270
234
  var nextIndex = index + 1;
271
235
  var v;
272
-
273
236
  if (nextIndex < animatePos.length) {
274
237
  v = p * (animatePos[nextIndex] - animatePos[index]) + animatePos[index];
275
238
  } else {
276
239
  nextIndex = 0;
277
240
  v = (1 - p) * animatePos[index];
278
241
  }
279
-
280
242
  setControlTranslate(v);
281
243
  }
282
-
283
244
  animationId = window.requestAnimationFrame(_animation);
284
245
  } else {
285
246
  index = index < times ? index + 1 : 0;
@@ -287,10 +248,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
287
248
  animationId = window.requestAnimationFrame(_animation);
288
249
  }
289
250
  };
290
-
291
251
  animationId = window.requestAnimationFrame(_animation);
292
252
  }
293
-
294
253
  controlEl.current.addEventListener("mousedown", mouseDownHandle);
295
254
  return function () {
296
255
  controlEl.current.removeEventListener("mousedown", mouseDownHandle);
@@ -300,38 +259,32 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
300
259
  };
301
260
  }
302
261
  }, [JSON.stringify(animation), control]);
303
-
304
262
  var _useState3 = (0, _react.useState)(false),
305
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
306
- controlChartTooltipShow = _useState4[0],
307
- setControlChartTooltipShow = _useState4[1];
308
-
263
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
264
+ controlChartTooltipShow = _useState4[0],
265
+ setControlChartTooltipShow = _useState4[1];
309
266
  var _useState5 = (0, _react.useState)(undefined),
310
- _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
311
- controlChartTooltipXName = _useState6[0],
312
- setControlChartTooltipXName = _useState6[1];
313
-
267
+ _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
268
+ controlChartTooltipXName = _useState6[0],
269
+ setControlChartTooltipXName = _useState6[1];
314
270
  var _useState7 = (0, _react.useState)(undefined),
315
- _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
316
- controlChartTooltipX = _useState8[0],
317
- setControlChartTooltipX = _useState8[1];
318
-
271
+ _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
272
+ controlChartTooltipX = _useState8[0],
273
+ setControlChartTooltipX = _useState8[1];
319
274
  var controlChartTooltipData = (0, _react.useMemo)(function () {
320
275
  return controlChartTooltipXName !== undefined && originData.filter(function (d) {
321
276
  return d.x === controlChartTooltipXName;
322
277
  });
323
278
  }, [controlChartTooltipXName, originData]);
324
-
325
279
  var _useState9 = (0, _react.useState)(axisX.ticks.map(function (tick) {
326
- return {
327
- tick: tick,
328
- isShow: false
329
- };
330
- })),
331
- _useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
332
- controlChartIndicatorList = _useState10[0],
333
- setControlChartIndicatorList = _useState10[1];
334
-
280
+ return {
281
+ tick: tick,
282
+ isShow: false
283
+ };
284
+ })),
285
+ _useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
286
+ controlChartIndicatorList = _useState10[0],
287
+ setControlChartIndicatorList = _useState10[1];
335
288
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_.ChartContainer, {
336
289
  style: style,
337
290
  width: width,
@@ -421,15 +374,16 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
421
374
  }));
422
375
  })), series.map(function (_ref2, index) {
423
376
  var Component = _ref2.Component,
424
- yOrZ = _ref2.yOrZ,
425
- config = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
377
+ yOrZ = _ref2.yOrZ,
378
+ config = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
426
379
  var yAxis = axes.get(yOrZ);
427
380
  return yAxis && Component && /*#__PURE__*/_react["default"].createElement(Component, (0, _extends2["default"])({
428
381
  key: index
429
382
  }, config, {
430
383
  bandLength: bandLength,
431
384
  xAxis: axisX,
432
- yAxis: yAxis // 控制图部分,主要是为了,当鼠标悬浮在指示器上时,显示对应的tooltip
385
+ yAxis: yAxis
386
+ // 控制图部分,主要是为了,当鼠标悬浮在指示器上时,显示对应的tooltip
433
387
  ,
434
388
  isControlChart: isControlChart,
435
389
  setControlChartTooltipXName: setControlChartTooltipXName,
@@ -441,8 +395,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
441
395
  }));
442
396
  }), series.map(function (_ref3, index) {
443
397
  var Component = _ref3.Component,
444
- yOrZ = _ref3.yOrZ,
445
- config = (0, _objectWithoutProperties2["default"])(_ref3, _excluded2);
398
+ yOrZ = _ref3.yOrZ,
399
+ config = (0, _objectWithoutProperties2["default"])(_ref3, _excluded2);
446
400
  var yAxis = axes.get(yOrZ);
447
401
  return yAxis && /*#__PURE__*/_react["default"].createElement(_.Label, (0, _extends2["default"])({
448
402
  key: index
@@ -496,7 +450,5 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
496
450
  width: width
497
451
  }));
498
452
  });
499
-
500
453
  var _default = (0, _.Mapping)((0, _.FilterData)((0, _.ExtentData)((0, _.AnimateData)((0, _.StackData)(Chart)))));
501
-
502
454
  exports["default"] = _default;