@easyv/charts 1.4.21 → 1.4.24

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 +8 -16
  6. package/lib/components/Axis.js +106 -138
  7. package/lib/components/Background.js +18 -26
  8. package/lib/components/Band.js +105 -91
  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 +292 -113
  13. package/lib/components/Chart.js +23 -36
  14. package/lib/components/ChartContainer.js +21 -29
  15. package/lib/components/ConicalGradient.js +56 -89
  16. package/lib/components/Control.js +65 -0
  17. package/lib/components/ExtentData.js +9 -17
  18. package/lib/components/FilterData.js +16 -27
  19. package/lib/components/Indicator.js +66 -12
  20. package/lib/components/Label.js +128 -118
  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 +312 -406
  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 -27
  33. package/lib/context/index.js +0 -2
  34. package/lib/css/index.module.css +42 -42
  35. package/lib/css/piechart.module.css +26 -26
  36. package/lib/element/ConicGradient.js +29 -35
  37. package/lib/element/Line.js +9 -13
  38. package/lib/element/index.js +0 -2
  39. package/lib/formatter/index.js +0 -2
  40. package/lib/formatter/legend.js +30 -41
  41. package/lib/hooks/index.js +0 -9
  42. package/lib/hooks/useAiData.js +12 -20
  43. package/lib/hooks/useAnimateData.js +8 -21
  44. package/lib/hooks/useAxes.js +69 -115
  45. package/lib/hooks/useCarouselAxisX.js +47 -68
  46. package/lib/hooks/useExtentData.js +14 -46
  47. package/lib/hooks/useFilterData.js +13 -34
  48. package/lib/hooks/useStackData.js +12 -35
  49. package/lib/hooks/useTooltip.js +37 -54
  50. package/lib/index.js +0 -15
  51. package/lib/utils/index.js +95 -247
  52. package/package.json +55 -55
  53. package/src/components/Axis.tsx +223 -183
  54. package/src/components/Background.tsx +61 -61
  55. package/src/components/Band.tsx +274 -239
  56. package/src/components/Brush.js +159 -159
  57. package/src/components/CartesianChart.js +320 -44
  58. package/src/components/Chart.js +99 -99
  59. package/src/components/ChartContainer.tsx +71 -64
  60. package/src/components/ConicalGradient.js +258 -258
  61. package/src/components/Control.jsx +51 -0
  62. package/src/components/ExtentData.js +17 -17
  63. package/src/components/Indicator.js +61 -13
  64. package/src/components/Label.js +275 -242
  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/PieChart.js +8 -4
  70. package/src/components/StereoBar.tsx +307 -307
  71. package/src/components/index.js +57 -55
  72. package/src/context/index.js +2 -2
  73. package/src/css/index.module.css +42 -42
  74. package/src/css/piechart.module.css +26 -26
  75. package/src/element/ConicGradient.jsx +55 -55
  76. package/src/element/Line.tsx +33 -33
  77. package/src/element/index.ts +3 -3
  78. package/src/formatter/index.js +1 -1
  79. package/src/formatter/legend.js +92 -92
  80. package/src/hooks/index.js +20 -20
  81. package/src/hooks/useAnimateData.ts +67 -67
  82. package/src/hooks/useAxes.js +9 -2
  83. package/src/hooks/useCarouselAxisX.js +35 -18
  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,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
15
  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
16
  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
17
  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
-
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
+ */
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,79 +61,80 @@ var getAttr = function getAttr(_ref) {
75
61
  height: length
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
70
  var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
87
71
  var triggerClick = _ref3.triggerClick,
88
- _ref3$config = _ref3.config,
89
- _ref3$config$pattern = _ref3$config.pattern,
90
- pattern = _ref3$config$pattern === void 0 ? {} : _ref3$config$pattern,
91
- _ref3$config$seriesIn = _ref3$config.seriesIntervalWidth,
92
- paddingInner = _ref3$config$seriesIn === void 0 ? 0 : _ref3$config$seriesIn,
93
- _ref3$config$paddingI = _ref3$config.paddingInner,
94
- paddingOuter = _ref3$config$paddingI === void 0 ? 0 : _ref3$config$paddingI,
95
- style = _ref3$config.style,
96
- fillType = _ref3$config.fillType,
97
- url = _ref3$config.url,
98
- size = _ref3$config.size,
99
- fill = _ref3$config.fill,
100
- border = _ref3$config.border,
101
- opacity = _ref3$config.opacity,
102
- _ref3$config$highligh = _ref3$config.highlight,
103
- showHighlight = _ref3$config$highligh.show,
104
- extent = _ref3$config$highligh.extent,
105
- highlightFill = _ref3$config$highligh.fill,
106
- headDecorate = _ref3$config.headDecorate,
107
- _ref3$bandLength = _ref3.bandLength,
108
- bandLength = _ref3$bandLength === void 0 ? 0 : _ref3$bandLength,
109
- data = _ref3.data,
110
- _ref3$xAxis = _ref3.xAxis,
111
- xScaler = _ref3$xAxis.scaler,
112
- step = _ref3$xAxis.step,
113
- direction = _ref3$xAxis.direction,
114
- _ref3$yAxis = _ref3.yAxis,
115
- yScaler = _ref3$yAxis.scaler,
116
- isClipAxis = _ref3$yAxis.isClipAxis,
117
- clipValue = _ref3$yAxis.clipValue;
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;
118
110
  if (!data.length) return null;
119
-
120
111
  var _getSeriesInfo = (0, _utils.getSeriesInfo)({
121
- step: step,
122
- bandLength: bandLength,
123
- paddingInner: paddingInner,
124
- paddingOuter: paddingOuter
125
- }),
126
- seriesWidth = _getSeriesInfo.seriesWidth,
127
- seriesStep = _getSeriesInfo.seriesStep,
128
- seriesStart = _getSeriesInfo.seriesStart;
129
-
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;
130
120
  var _data = showHighlight ? getHighlightData(data, extent) : data;
131
-
132
121
  var isVertical = direction === "vertical";
133
122
  var borderStr = "".concat(border.borderColor, " solid ").concat(border.borderWidth, "px");
134
123
  return /*#__PURE__*/_react["default"].createElement("g", {
135
124
  className: "__easyv-band"
136
125
  }, _data.map(function (_ref4, i) {
137
126
  var flag = _ref4.flag,
138
- index = _ref4.index,
139
- _ref4$bound = (0, _slicedToArray2["default"])(_ref4.bound, 2),
140
- start = _ref4$bound[0],
141
- end = _ref4$bound[1],
142
- data = _ref4.data,
143
- _ref4$data = _ref4.data,
144
- x = _ref4$data.x,
145
- y = _ref4$data.y,
146
- s = _ref4$data.s;
147
-
148
- //todo 柱状中空设置
149
- var y1, y2; //断轴图相关,断轴图的scaler是一个数组,内含上断轴下断轴的scaler
150
-
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
151
138
  if (isClipAxis) {
152
139
  if (end > +clipValue) {
153
140
  y1 = yScaler[1](start);
@@ -160,30 +147,25 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
160
147
  y1 = yScaler(isVertical ? end : start);
161
148
  y2 = yScaler(isVertical ? start : end);
162
149
  }
163
-
164
150
  var positionX = xScaler(x) - step / 2 + seriesStart + index * seriesStep;
165
151
  var showHead, headUrl, headWidth, headHeight, headTranslate;
166
-
167
152
  if (headDecorate) {
168
153
  showHead = headDecorate.show, headUrl = headDecorate.url, headWidth = headDecorate.size.width, headHeight = headDecorate.size.height, headTranslate = headDecorate.translate;
169
- } //断轴图相关,将柱形在断轴处切开
170
-
171
-
154
+ }
155
+ //断轴图相关,将柱形在断轴处切开
172
156
  var setClipPath = function setClipPath() {
173
157
  if (isClipAxis && end > +clipValue) {
174
158
  var clipValueY2 = yScaler[0](clipValue); //上方
175
-
176
159
  var clipValueY1 = yScaler[1](clipValue); //下方
177
-
178
160
  var top = Math.abs((y2 - clipValueY2) / (y1 - y2)) * 100;
179
- var bottom = Math.abs((y2 - clipValueY1) / (y1 - y2)) * 100; //clip path属性
161
+ var bottom = Math.abs((y2 - clipValueY1) / (y1 - y2)) * 100;
180
162
 
163
+ //clip path属性
181
164
  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%)");
182
165
  } else {
183
166
  return "none";
184
167
  }
185
168
  };
186
-
187
169
  if (isNaN(positionX)) return null;
188
170
  var positionY = y < 0 ? y1 : y2;
189
171
  var attr = getAttr({
@@ -201,7 +183,41 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
201
183
  cursor: "pointer"
202
184
  }
203
185
  }, attr, {
204
- onClick: triggerClick,
186
+ onClick: triggerClick
187
+ //enter和leave事件,用于控制图的提示框
188
+ ,
189
+ onMouseEnter: function onMouseEnter() {
190
+ if (isControlChart) {
191
+ setControlChartIndicatorList(function (v) {
192
+ return v.map(function (item) {
193
+ if (item.tick === data.x) {
194
+ return _objectSpread(_objectSpread({}, item), {}, {
195
+ isShow: true
196
+ });
197
+ } else {
198
+ return item;
199
+ }
200
+ });
201
+ });
202
+ setControlChartTooltipShow(true);
203
+ setControlChartTooltipX(xScaler(x) - indicatorWidth / 2);
204
+ setControlChartTooltipXName(data.x);
205
+ }
206
+ },
207
+ onMouseLeave: function onMouseLeave() {
208
+ if (isControlChart) {
209
+ setControlChartIndicatorList(function (v) {
210
+ return v.map(function (item) {
211
+ return _objectSpread(_objectSpread({}, item), {}, {
212
+ isShow: false
213
+ });
214
+ });
215
+ });
216
+ setControlChartTooltipShow(false);
217
+ setControlChartTooltipXName(undefined);
218
+ setControlChartTooltipX(undefined);
219
+ }
220
+ },
205
221
  "data-data": JSON.stringify(data)
206
222
  }), headUrl && showHead && /*#__PURE__*/_react["default"].createElement("div", {
207
223
  style: {
@@ -218,7 +234,6 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
218
234
  style: _objectSpread({
219
235
  width: "100%",
220
236
  height: "100%",
221
-
222
237
  /** Safari Bug **/
223
238
  position: "fixed",
224
239
  clipPath: setClipPath(),
@@ -241,5 +256,4 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
241
256
  }));
242
257
  }));
243
258
  });
244
-
245
259
  exports["default"] = _default;
@@ -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
12
  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
13
  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
14
  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
-
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
+ */
26
18
  var _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", {
@@ -108,5 +96,4 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
108
96
  return null;
109
97
  }
110
98
  });
111
-
112
99
  exports["default"] = _default;
@@ -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
11
  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
-
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
+ */
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
42
  var _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,15 @@ var _default = function _default(_ref) {
143
129
  name: "right"
144
130
  })));
145
131
  };
146
-
147
132
  exports["default"] = _default;
148
133
  var Move = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
149
134
  var style = _ref3.style,
150
- move = _ref3.move,
151
- name = _ref3.name;
152
-
135
+ move = _ref3.move,
136
+ name = _ref3.name;
153
137
  var _useState3 = (0, _react.useState)(initialPosition),
154
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
155
- position = _useState4[0],
156
- setPosition = _useState4[1];
157
-
138
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
139
+ position = _useState4[0],
140
+ setPosition = _useState4[1];
158
141
  var documentOnMouseMove = (0, _react.useCallback)(function (e) {
159
142
  // console.log('documentOnMouseMove');
160
143
  setPosition(function (position) {
@@ -187,8 +170,8 @@ var Move = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
187
170
  }, []);
188
171
  (0, _react.useEffect)(function () {
189
172
  var start = position.start,
190
- end = position.end,
191
- status = position.status;
173
+ end = position.end,
174
+ status = position.status;
192
175
  move({
193
176
  delta: end - start,
194
177
  status: status,