@easyv/charts 1.4.29 → 1.4.30

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 (90) 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 +16 -8
  6. package/lib/components/Axis.js +134 -87
  7. package/lib/components/Background.js +26 -18
  8. package/lib/components/Band.js +98 -72
  9. package/lib/components/BaseLine.js +46 -33
  10. package/lib/components/Brush.js +46 -29
  11. package/lib/components/Carousel.js +40 -13
  12. package/lib/components/CartesianChart.js +146 -97
  13. package/lib/components/Chart.js +38 -24
  14. package/lib/components/ChartContainer.js +27 -18
  15. package/lib/components/ConicalGradient.js +89 -56
  16. package/lib/components/Control.js +28 -12
  17. package/lib/components/ExtentData.js +17 -9
  18. package/lib/components/FilterData.js +27 -16
  19. package/lib/components/Indicator.js +30 -23
  20. package/lib/components/Label.js +126 -96
  21. package/lib/components/Legend.js +66 -41
  22. package/lib/components/Lighter.js +50 -21
  23. package/lib/components/Line.js +59 -39
  24. package/lib/components/LinearGradient.js +22 -16
  25. package/lib/components/Mapping.js +34 -9
  26. package/lib/components/Marquee.js +30 -14
  27. package/lib/components/PieChart.js +420 -318
  28. package/lib/components/StackData.js +18 -8
  29. package/lib/components/StereoBar.js +105 -65
  30. package/lib/components/TextOverflow.js +21 -8
  31. package/lib/components/Tooltip.js +55 -41
  32. package/lib/components/index.js +29 -0
  33. package/lib/components/pieTooltip.js +67 -40
  34. package/lib/context/index.js +2 -0
  35. package/lib/css/index.module.css +42 -42
  36. package/lib/css/piechart.module.css +26 -26
  37. package/lib/element/ConicGradient.js +35 -29
  38. package/lib/element/Line.js +13 -9
  39. package/lib/element/index.js +2 -0
  40. package/lib/formatter/index.js +2 -0
  41. package/lib/formatter/legend.js +41 -30
  42. package/lib/hooks/index.js +9 -0
  43. package/lib/hooks/useAiData.js +20 -12
  44. package/lib/hooks/useAnimateData.js +21 -8
  45. package/lib/hooks/useAxes.js +117 -67
  46. package/lib/hooks/useCarouselAxisX.js +59 -26
  47. package/lib/hooks/useExtentData.js +47 -15
  48. package/lib/hooks/useFilterData.js +34 -13
  49. package/lib/hooks/useStackData.js +35 -12
  50. package/lib/hooks/useTooltip.js +53 -36
  51. package/lib/index.js +15 -0
  52. package/lib/utils/index.js +247 -95
  53. package/package.json +55 -55
  54. package/src/components/Axis.tsx +1 -1
  55. package/src/components/Background.tsx +61 -61
  56. package/src/components/Band.tsx +274 -274
  57. package/src/components/Brush.js +159 -159
  58. package/src/components/CartesianChart.js +1 -0
  59. package/src/components/Chart.js +101 -101
  60. package/src/components/ChartContainer.tsx +71 -71
  61. package/src/components/ConicalGradient.js +258 -258
  62. package/src/components/Control.jsx +51 -51
  63. package/src/components/ExtentData.js +17 -17
  64. package/src/components/Indicator.js +61 -61
  65. package/src/components/Label.js +275 -275
  66. package/src/components/Legend.js +165 -165
  67. package/src/components/Lighter.jsx +173 -173
  68. package/src/components/Line.js +150 -150
  69. package/src/components/LinearGradient.js +29 -29
  70. package/src/components/PieTooltip.jsx +160 -160
  71. package/src/components/StereoBar.tsx +307 -307
  72. package/src/components/index.js +59 -59
  73. package/src/context/index.js +2 -2
  74. package/src/css/index.module.css +42 -42
  75. package/src/css/piechart.module.css +26 -26
  76. package/src/element/ConicGradient.jsx +55 -55
  77. package/src/element/Line.tsx +33 -33
  78. package/src/element/index.ts +3 -3
  79. package/src/formatter/index.js +1 -1
  80. package/src/formatter/legend.js +92 -92
  81. package/src/hooks/index.js +20 -20
  82. package/src/hooks/useAnimateData.ts +67 -67
  83. package/src/hooks/useExtentData.js +1 -1
  84. package/src/hooks/useFilterData.js +72 -72
  85. package/src/hooks/useStackData.js +101 -101
  86. package/src/hooks/useTooltip.ts +100 -100
  87. package/src/index.js +6 -6
  88. package/src/types/index.d.ts +67 -67
  89. package/src/utils/index.js +757 -757
  90. package/tsconfig.json +23 -23
@@ -1,23 +1,34 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  var _typeof = require("@babel/runtime/helpers/typeof");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
8
10
  exports["default"] = void 0;
11
+
9
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
10
14
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
+
11
16
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
+
12
18
  var _react = _interopRequireWildcard(require("react"));
19
+
13
20
  var _d3v = require("d3v7");
21
+
14
22
  var _utils = require("../utils");
23
+
15
24
  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); }
25
+
16
26
  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; }
27
+
17
28
  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; }
18
- 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; } /**
19
- * (柱状/条形)图柱子
20
- */
29
+
30
+ 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; }
31
+
21
32
  var getHighlightData = function getHighlightData(data, extent) {
22
33
  switch (extent) {
23
34
  case "min":
@@ -29,6 +40,7 @@ var getHighlightData = function getHighlightData(data, extent) {
29
40
  flag: minData == item.data.y ? "min" : ""
30
41
  });
31
42
  });
43
+
32
44
  case "max":
33
45
  var maxData = (0, _d3v.max)(data, function (d) {
34
46
  return d.data.y;
@@ -38,16 +50,18 @@ var getHighlightData = function getHighlightData(data, extent) {
38
50
  flag: maxData == item.data.y ? "max" : ""
39
51
  });
40
52
  });
53
+
41
54
  default:
42
55
  return data;
43
56
  }
44
57
  };
58
+
45
59
  var getAttr = function getAttr(_ref) {
46
60
  var isVertical = _ref.isVertical,
47
- seriesWidth = _ref.seriesWidth,
48
- length = _ref.length,
49
- x = _ref.x,
50
- y = _ref.y;
61
+ seriesWidth = _ref.seriesWidth,
62
+ length = _ref.length,
63
+ x = _ref.x,
64
+ y = _ref.y;
51
65
  if (isVertical) return {
52
66
  width: length,
53
67
  height: seriesWidth,
@@ -61,80 +75,86 @@ var getAttr = function getAttr(_ref) {
61
75
  height: length
62
76
  };
63
77
  };
78
+
64
79
  var getBorderRadius = function getBorderRadius(_ref2) {
65
80
  var isVertical = _ref2.isVertical,
66
- positive = _ref2.positive,
67
- seriesWidth = _ref2.seriesWidth;
81
+ positive = _ref2.positive,
82
+ seriesWidth = _ref2.seriesWidth;
68
83
  return isVertical ? positive ? "0px " + seriesWidth + "px " + seriesWidth + "px 0" : seriesWidth + "px 0 0 " + seriesWidth + "px" : positive ? seriesWidth / 2 + "px " + seriesWidth / 2 + "px 0 0" : "0 0 " + seriesWidth / 2 + "px " + seriesWidth / 2 + "px";
69
84
  };
85
+
70
86
  var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
71
87
  var triggerClick = _ref3.triggerClick,
72
- indicatorWidth = _ref3.indicatorWidth,
73
- setControlChartTooltipShow = _ref3.setControlChartTooltipShow,
74
- setControlChartTooltipX = _ref3.setControlChartTooltipX,
75
- setControlChartTooltipXName = _ref3.setControlChartTooltipXName,
76
- _ref3$isControlChart = _ref3.isControlChart,
77
- isControlChart = _ref3$isControlChart === void 0 ? false : _ref3$isControlChart,
78
- setControlChartIndicatorList = _ref3.setControlChartIndicatorList,
79
- _ref3$config = _ref3.config,
80
- _ref3$config$pattern = _ref3$config.pattern,
81
- pattern = _ref3$config$pattern === void 0 ? {} : _ref3$config$pattern,
82
- _ref3$config$seriesIn = _ref3$config.seriesIntervalWidth,
83
- paddingInner = _ref3$config$seriesIn === void 0 ? 0 : _ref3$config$seriesIn,
84
- _ref3$config$paddingI = _ref3$config.paddingInner,
85
- paddingOuter = _ref3$config$paddingI === void 0 ? 0 : _ref3$config$paddingI,
86
- style = _ref3$config.style,
87
- fillType = _ref3$config.fillType,
88
- url = _ref3$config.url,
89
- size = _ref3$config.size,
90
- fill = _ref3$config.fill,
91
- border = _ref3$config.border,
92
- opacity = _ref3$config.opacity,
93
- _ref3$config$highligh = _ref3$config.highlight,
94
- showHighlight = _ref3$config$highligh.show,
95
- extent = _ref3$config$highligh.extent,
96
- highlightFill = _ref3$config$highligh.fill,
97
- headDecorate = _ref3$config.headDecorate,
98
- _ref3$bandLength = _ref3.bandLength,
99
- bandLength = _ref3$bandLength === void 0 ? 0 : _ref3$bandLength,
100
- data = _ref3.data,
101
- _ref3$xAxis = _ref3.xAxis,
102
- xScaler = _ref3$xAxis.scaler,
103
- step = _ref3$xAxis.step,
104
- direction = _ref3$xAxis.direction,
105
- xAxis = _ref3.xAxis,
106
- _ref3$yAxis = _ref3.yAxis,
107
- yScaler = _ref3$yAxis.scaler,
108
- isClipAxis = _ref3$yAxis.isClipAxis,
109
- clipValue = _ref3$yAxis.clipValue;
88
+ indicatorWidth = _ref3.indicatorWidth,
89
+ setControlChartTooltipShow = _ref3.setControlChartTooltipShow,
90
+ setControlChartTooltipX = _ref3.setControlChartTooltipX,
91
+ setControlChartTooltipXName = _ref3.setControlChartTooltipXName,
92
+ _ref3$isControlChart = _ref3.isControlChart,
93
+ isControlChart = _ref3$isControlChart === void 0 ? false : _ref3$isControlChart,
94
+ setControlChartIndicatorList = _ref3.setControlChartIndicatorList,
95
+ _ref3$config = _ref3.config,
96
+ _ref3$config$pattern = _ref3$config.pattern,
97
+ pattern = _ref3$config$pattern === void 0 ? {} : _ref3$config$pattern,
98
+ _ref3$config$seriesIn = _ref3$config.seriesIntervalWidth,
99
+ paddingInner = _ref3$config$seriesIn === void 0 ? 0 : _ref3$config$seriesIn,
100
+ _ref3$config$paddingI = _ref3$config.paddingInner,
101
+ paddingOuter = _ref3$config$paddingI === void 0 ? 0 : _ref3$config$paddingI,
102
+ style = _ref3$config.style,
103
+ fillType = _ref3$config.fillType,
104
+ url = _ref3$config.url,
105
+ size = _ref3$config.size,
106
+ fill = _ref3$config.fill,
107
+ border = _ref3$config.border,
108
+ opacity = _ref3$config.opacity,
109
+ _ref3$config$highligh = _ref3$config.highlight,
110
+ showHighlight = _ref3$config$highligh.show,
111
+ extent = _ref3$config$highligh.extent,
112
+ highlightFill = _ref3$config$highligh.fill,
113
+ headDecorate = _ref3$config.headDecorate,
114
+ _ref3$bandLength = _ref3.bandLength,
115
+ bandLength = _ref3$bandLength === void 0 ? 0 : _ref3$bandLength,
116
+ data = _ref3.data,
117
+ _ref3$xAxis = _ref3.xAxis,
118
+ xScaler = _ref3$xAxis.scaler,
119
+ step = _ref3$xAxis.step,
120
+ direction = _ref3$xAxis.direction,
121
+ xAxis = _ref3.xAxis,
122
+ _ref3$yAxis = _ref3.yAxis,
123
+ yScaler = _ref3$yAxis.scaler,
124
+ isClipAxis = _ref3$yAxis.isClipAxis,
125
+ clipValue = _ref3$yAxis.clipValue;
110
126
  if (!data.length) return null;
127
+
111
128
  var _getSeriesInfo = (0, _utils.getSeriesInfo)({
112
- step: step,
113
- bandLength: bandLength,
114
- paddingInner: paddingInner,
115
- paddingOuter: paddingOuter
116
- }),
117
- seriesWidth = _getSeriesInfo.seriesWidth,
118
- seriesStep = _getSeriesInfo.seriesStep,
119
- seriesStart = _getSeriesInfo.seriesStart;
129
+ step: step,
130
+ bandLength: bandLength,
131
+ paddingInner: paddingInner,
132
+ paddingOuter: paddingOuter
133
+ }),
134
+ seriesWidth = _getSeriesInfo.seriesWidth,
135
+ seriesStep = _getSeriesInfo.seriesStep,
136
+ seriesStart = _getSeriesInfo.seriesStart;
137
+
120
138
  var _data = showHighlight ? getHighlightData(data, extent) : data;
139
+
121
140
  var isVertical = direction === "vertical";
122
141
  var borderStr = "".concat(border.borderColor, " solid ").concat(border.borderWidth, "px");
123
142
  return /*#__PURE__*/_react["default"].createElement("g", {
124
143
  className: "__easyv-band"
125
144
  }, _data.map(function (_ref4, i) {
126
145
  var flag = _ref4.flag,
127
- index = _ref4.index,
128
- _ref4$bound = (0, _slicedToArray2["default"])(_ref4.bound, 2),
129
- start = _ref4$bound[0],
130
- end = _ref4$bound[1],
131
- data = _ref4.data,
132
- _ref4$data = _ref4.data,
133
- x = _ref4$data.x,
134
- y = _ref4$data.y,
135
- s = _ref4$data.s;
136
- var y1, y2;
137
- //断轴图相关,断轴图的scaler是一个数组,内含上断轴下断轴的scaler
146
+ index = _ref4.index,
147
+ _ref4$bound = (0, _slicedToArray2["default"])(_ref4.bound, 2),
148
+ start = _ref4$bound[0],
149
+ end = _ref4$bound[1],
150
+ data = _ref4.data,
151
+ _ref4$data = _ref4.data,
152
+ x = _ref4$data.x,
153
+ y = _ref4$data.y,
154
+ s = _ref4$data.s;
155
+
156
+ var y1, y2; //断轴图相关,断轴图的scaler是一个数组,内含上断轴下断轴的scaler
157
+
138
158
  if (isClipAxis) {
139
159
  if (end > +clipValue) {
140
160
  y1 = yScaler[1](start);
@@ -147,25 +167,30 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
147
167
  y1 = yScaler(isVertical ? end : start);
148
168
  y2 = yScaler(isVertical ? start : end);
149
169
  }
170
+
150
171
  var positionX = xScaler(x) - step / 2 + seriesStart + index * seriesStep;
151
172
  var showHead, headUrl, headWidth, headHeight, headTranslate;
173
+
152
174
  if (headDecorate) {
153
175
  showHead = headDecorate.show, headUrl = headDecorate.url, headWidth = headDecorate.size.width, headHeight = headDecorate.size.height, headTranslate = headDecorate.translate;
154
- }
155
- //断轴图相关,将柱形在断轴处切开
176
+ } //断轴图相关,将柱形在断轴处切开
177
+
178
+
156
179
  var setClipPath = function setClipPath() {
157
180
  if (isClipAxis && end > +clipValue) {
158
181
  var clipValueY2 = yScaler[0](clipValue); //上方
182
+
159
183
  var clipValueY1 = yScaler[1](clipValue); //下方
184
+
160
185
  var top = Math.abs((y2 - clipValueY2) / (y1 - y2)) * 100;
161
- var bottom = Math.abs((y2 - clipValueY1) / (y1 - y2)) * 100;
186
+ var bottom = Math.abs((y2 - clipValueY1) / (y1 - y2)) * 100; //clip path属性
162
187
 
163
- //clip path属性
164
188
  return "polygon(0% 0%, 0% 100%, 0 100%, 0 ".concat(top, "%, 100% ").concat(top, "%, 100% ").concat(bottom, "%, 0 ").concat(bottom, "%, 0 100%, 100% 100%, 100% 0%)");
165
189
  } else {
166
190
  return "none";
167
191
  }
168
192
  };
193
+
169
194
  if (isNaN(positionX)) return null;
170
195
  var positionY = y < 0 ? y1 : y2;
171
196
  var attr = getAttr({
@@ -183,8 +208,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
183
208
  cursor: "pointer"
184
209
  }
185
210
  }, attr, {
186
- onClick: triggerClick
187
- //enter和leave事件,用于控制图的提示框
211
+ onClick: triggerClick //enter和leave事件,用于控制图的提示框
188
212
  ,
189
213
  onMouseEnter: function onMouseEnter() {
190
214
  if (isControlChart) {
@@ -234,6 +258,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
234
258
  style: _objectSpread({
235
259
  width: "100%",
236
260
  height: "100%",
261
+
237
262
  /** Safari Bug **/
238
263
  position: "fixed",
239
264
  clipPath: setClipPath(),
@@ -256,4 +281,5 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
256
281
  }));
257
282
  }));
258
283
  });
284
+
259
285
  exports["default"] = _default;
@@ -1,52 +1,62 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  var _typeof = require("@babel/runtime/helpers/typeof");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
8
10
  exports["default"] = void 0;
11
+
9
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
10
14
  var _react = _interopRequireWildcard(require("react"));
15
+
11
16
  var _utils = require("../utils");
17
+
12
18
  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); }
19
+
13
20
  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; }
21
+
14
22
  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; }
15
- 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; } /**
16
- * 参考线
17
- */
23
+
24
+ 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; }
25
+
18
26
  var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
19
27
  var width = _ref.width,
20
- height = _ref.height,
21
- orientation = _ref.baseLineOri,
22
- _ref$config = _ref.config,
23
- _ref$config$dataStyle = _ref$config.dataStyle,
24
- _ref$config$dataStyle2 = _ref$config$dataStyle.data,
25
- dataShow = _ref$config$dataStyle2.show,
26
- dataStyle = _ref$config$dataStyle2.dataStyle,
27
- dataTranslate = _ref$config$dataStyle2.translate,
28
- _ref$config$dataStyle3 = _ref$config$dataStyle.label,
29
- label = _ref$config$dataStyle3.label,
30
- labelShow = _ref$config$dataStyle3.show,
31
- textStyle = _ref$config$dataStyle3.textStyle,
32
- labelTranslate = _ref$config$dataStyle3.translate,
33
- _ref$config$line = _ref$config.line,
34
- color = _ref$config$line.color,
35
- lineType = _ref$config$line.lineType,
36
- lineWidth = _ref$config$line.lineWidth,
37
- _ref$config$line$marg = _ref$config$line.margin,
38
- marginLeft = _ref$config$line$marg.marginLeft,
39
- marginRight = _ref$config$line$marg.marginRight,
40
- strokeDasharray = _ref$config$line.strokeDasharray,
41
- yOrZ = _ref.yOrZ,
42
- _ref$yAxis = _ref.yAxis,
43
- yScaler = _ref$yAxis.scaler,
44
- clipValue = _ref$yAxis.clipValue,
45
- isClipAxis = _ref$yAxis.isClipAxis,
46
- scaler = _ref.axisX.scaler,
47
- data = _ref.data;
28
+ height = _ref.height,
29
+ orientation = _ref.baseLineOri,
30
+ _ref$config = _ref.config,
31
+ _ref$config$dataStyle = _ref$config.dataStyle,
32
+ _ref$config$dataStyle2 = _ref$config$dataStyle.data,
33
+ dataShow = _ref$config$dataStyle2.show,
34
+ dataStyle = _ref$config$dataStyle2.dataStyle,
35
+ dataTranslate = _ref$config$dataStyle2.translate,
36
+ _ref$config$dataStyle3 = _ref$config$dataStyle.label,
37
+ label = _ref$config$dataStyle3.label,
38
+ labelShow = _ref$config$dataStyle3.show,
39
+ textStyle = _ref$config$dataStyle3.textStyle,
40
+ labelTranslate = _ref$config$dataStyle3.translate,
41
+ _ref$config$line = _ref$config.line,
42
+ color = _ref$config$line.color,
43
+ lineType = _ref$config$line.lineType,
44
+ lineWidth = _ref$config$line.lineWidth,
45
+ _ref$config$line$marg = _ref$config$line.margin,
46
+ marginLeft = _ref$config$line$marg.marginLeft,
47
+ marginRight = _ref$config$line$marg.marginRight,
48
+ strokeDasharray = _ref$config$line.strokeDasharray,
49
+ yOrZ = _ref.yOrZ,
50
+ _ref$yAxis = _ref.yAxis,
51
+ yScaler = _ref$yAxis.scaler,
52
+ clipValue = _ref$yAxis.clipValue,
53
+ isClipAxis = _ref$yAxis.isClipAxis,
54
+ scaler = _ref.axisX.scaler,
55
+ data = _ref.data;
56
+
48
57
  try {
49
58
  var x1, x2, y1, y2;
59
+
50
60
  if (isClipAxis) {
51
61
  if (data.value > +clipValue) {
52
62
  x1 = orientation == 'left' ? yScaler[0](data.value) : marginLeft, x2 = orientation == 'left' ? yScaler[0](data.value) : width - marginRight, y1 = orientation == 'left' ? marginLeft : yScaler[0](data.value), y2 = orientation == 'left' ? height - marginRight : yScaler[0](data.value);
@@ -59,13 +69,15 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
59
69
  } else {
60
70
  x1 = orientation == 'left' ? yScaler(data.value) : marginLeft, x2 = orientation == 'left' ? yScaler(data.value) : width - marginRight, y1 = orientation == 'left' ? marginLeft : yScaler(data.value), y2 = orientation == 'left' ? height - marginRight : yScaler(data.value);
61
71
  }
62
- }
63
- //当坐标值存在undefined时,返回null
72
+ } //当坐标值存在undefined时,返回null
73
+
74
+
64
75
  if ([x1, x2, y1, y2].some(function (d) {
65
76
  return d == undefined;
66
77
  })) {
67
78
  return null;
68
79
  }
80
+
69
81
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("g", {
70
82
  className: "__easyv-baseLine"
71
83
  }, /*#__PURE__*/_react["default"].createElement("line", {
@@ -96,4 +108,5 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
96
108
  return null;
97
109
  }
98
110
  });
111
+
99
112
  exports["default"] = _default;
@@ -1,17 +1,22 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports["default"] = void 0;
9
+
8
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
9
12
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
10
14
  var _react = require("react");
15
+
11
16
  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; }
12
- 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; } /**
13
- * 实现中
14
- */
17
+
18
+ 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; }
19
+
15
20
  var left = {
16
21
  position: 'relative',
17
22
  width: 5,
@@ -36,57 +41,66 @@ var initialPosition = {
36
41
  end: 0,
37
42
  status: ''
38
43
  };
44
+
39
45
  var getValue = function getValue(x, min, max) {
40
46
  return Math.max(min, Math.min(x, max));
41
47
  };
48
+
42
49
  var _default = function _default(_ref) {
43
50
  var width = _ref.width,
44
- _ref$config = _ref.config,
45
- height = _ref$config.height,
46
- background = _ref$config.background,
47
- _ref$config$margin = _ref$config.margin,
48
- marginLeft = _ref$config$margin.marginLeft,
49
- marginRight = _ref$config$margin.marginRight,
50
- _ref$config$detail = _ref$config.detail,
51
- blockWidth = _ref$config$detail.width,
52
- color = _ref$config$detail.color;
51
+ _ref$config = _ref.config,
52
+ height = _ref$config.height,
53
+ background = _ref$config.background,
54
+ _ref$config$margin = _ref$config.margin,
55
+ marginLeft = _ref$config$margin.marginLeft,
56
+ marginRight = _ref$config$margin.marginRight,
57
+ _ref$config$detail = _ref$config.detail,
58
+ blockWidth = _ref$config$detail.width,
59
+ color = _ref$config$detail.color;
60
+
53
61
  var _useState = (0, _react.useState)({
54
- translateX: 0,
55
- width: blockWidth
56
- }),
57
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
58
- state = _useState2[0],
59
- setState = _useState2[1];
62
+ translateX: 0,
63
+ width: blockWidth
64
+ }),
65
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
66
+ state = _useState2[0],
67
+ setState = _useState2[1];
68
+
60
69
  var availableWidth = width - marginLeft - marginRight;
61
70
  var cache = (0, _react.useRef)(state);
62
71
  var move = (0, _react.useCallback)(function (_ref2) {
63
72
  var delta = _ref2.delta,
64
- status = _ref2.status,
65
- name = _ref2.name;
73
+ status = _ref2.status,
74
+ name = _ref2.name;
66
75
  var _cache$current = cache.current,
67
- width = _cache$current.width,
68
- translateX = _cache$current.translateX;
76
+ width = _cache$current.width,
77
+ translateX = _cache$current.translateX;
69
78
  var minWidth = 40;
70
79
  var minX = 0;
80
+
71
81
  switch (name) {
72
82
  case 'center':
73
83
  translateX = getValue(translateX + delta, minX, availableWidth - width);
74
84
  break;
85
+
75
86
  case 'left':
76
87
  var tempWidth = width;
77
88
  width = getValue(width + delta * -1, minWidth, translateX + width);
78
89
  translateX = getValue(translateX + delta, minX, translateX + tempWidth - width);
79
90
  break;
91
+
80
92
  case 'right':
81
93
  width = getValue(width + delta, minWidth, availableWidth - translateX);
82
94
  break;
83
95
  }
96
+
84
97
  if (status === 'up') {
85
98
  cache.current = {
86
99
  width: width,
87
100
  translateX: translateX
88
101
  };
89
102
  }
103
+
90
104
  setState({
91
105
  width: width,
92
106
  translateX: translateX
@@ -129,15 +143,18 @@ var _default = function _default(_ref) {
129
143
  name: "right"
130
144
  })));
131
145
  };
146
+
132
147
  exports["default"] = _default;
133
148
  var Move = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
134
149
  var style = _ref3.style,
135
- move = _ref3.move,
136
- name = _ref3.name;
150
+ move = _ref3.move,
151
+ name = _ref3.name;
152
+
137
153
  var _useState3 = (0, _react.useState)(initialPosition),
138
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
139
- position = _useState4[0],
140
- setPosition = _useState4[1];
154
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
155
+ position = _useState4[0],
156
+ setPosition = _useState4[1];
157
+
141
158
  var documentOnMouseMove = (0, _react.useCallback)(function (e) {
142
159
  // console.log('documentOnMouseMove');
143
160
  setPosition(function (position) {
@@ -170,8 +187,8 @@ var Move = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
170
187
  }, []);
171
188
  (0, _react.useEffect)(function () {
172
189
  var start = position.start,
173
- end = position.end,
174
- status = position.status;
190
+ end = position.end,
191
+ status = position.status;
175
192
  move({
176
193
  delta: end - start,
177
194
  status: status,