@easyv/charts 1.6.9 → 1.6.11

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