@easyv/charts 1.4.14 → 1.4.16

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 (53) hide show
  1. package/.husky/commit-msg +1 -1
  2. package/lib/components/AnimateData.js +8 -16
  3. package/lib/components/Axis.js +199 -191
  4. package/lib/components/Background.js +16 -24
  5. package/lib/components/Band.js +98 -91
  6. package/lib/components/BaseLine.js +39 -40
  7. package/lib/components/Brush.js +29 -46
  8. package/lib/components/Carousel.js +13 -40
  9. package/lib/components/CartesianChart.js +66 -86
  10. package/lib/components/Chart.js +23 -36
  11. package/lib/components/ChartContainer.js +18 -27
  12. package/lib/components/ConicalGradient.js +35 -68
  13. package/lib/components/ExtentData.js +9 -17
  14. package/lib/components/FilterData.js +16 -27
  15. package/lib/components/Indicator.js +6 -8
  16. package/lib/components/Label.js +120 -134
  17. package/lib/components/Legend.js +41 -66
  18. package/lib/components/Lighter.js +19 -48
  19. package/lib/components/Line.js +39 -59
  20. package/lib/components/LinearGradient.js +14 -20
  21. package/lib/components/Mapping.js +9 -34
  22. package/lib/components/Marquee.js +14 -30
  23. package/lib/components/PieChart.js +306 -400
  24. package/lib/components/StackData.js +8 -18
  25. package/lib/components/StereoBar.js +65 -105
  26. package/lib/components/TextOverflow.js +9 -22
  27. package/lib/components/Tooltip.js +41 -55
  28. package/lib/components/index.js +0 -27
  29. package/lib/context/index.js +0 -2
  30. package/lib/element/ConicGradient.js +29 -35
  31. package/lib/element/Line.js +9 -13
  32. package/lib/element/index.js +0 -2
  33. package/lib/formatter/index.js +0 -2
  34. package/lib/formatter/legend.js +30 -41
  35. package/lib/hooks/index.js +0 -8
  36. package/lib/hooks/useAnimateData.js +3 -16
  37. package/lib/hooks/useAxes.js +253 -114
  38. package/lib/hooks/useCarouselAxisX.js +26 -56
  39. package/lib/hooks/useExtentData.js +47 -44
  40. package/lib/hooks/useFilterData.js +8 -29
  41. package/lib/hooks/useStackData.js +7 -30
  42. package/lib/hooks/useTooltip.js +26 -43
  43. package/lib/index.js +0 -15
  44. package/lib/utils/index.js +95 -247
  45. package/package.json +55 -54
  46. package/src/components/Axis.tsx +246 -157
  47. package/src/components/Band.tsx +91 -56
  48. package/src/components/BaseLine.js +22 -5
  49. package/src/components/CartesianChart.js +1 -0
  50. package/src/components/Label.js +56 -46
  51. package/src/components/TextOverflow.tsx +1 -2
  52. package/src/hooks/useAxes.js +336 -117
  53. package/src/hooks/useExtentData.js +37 -10
@@ -1,67 +1,53 @@
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
- case 'min':
23
+ case "min":
35
24
  var minData = (0, _d3v.min)(data, function (d) {
36
25
  return d.data.y;
37
26
  });
38
27
  return data.map(function (item) {
39
28
  return _objectSpread(_objectSpread({}, item), {}, {
40
- flag: minData == item.data.y ? 'min' : ''
29
+ flag: minData == item.data.y ? "min" : ""
41
30
  });
42
31
  });
43
-
44
- case 'max':
32
+ case "max":
45
33
  var maxData = (0, _d3v.max)(data, function (d) {
46
34
  return d.data.y;
47
35
  });
48
36
  return data.map(function (item) {
49
37
  return _objectSpread(_objectSpread({}, item), {}, {
50
- flag: maxData == item.data.y ? 'max' : ''
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,82 +61,104 @@ 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;
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';
66
+ positive = _ref2.positive,
67
+ seriesWidth = _ref2.seriesWidth;
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
- yScaler = _ref3.yAxis.scaler;
72
+ _ref3$config = _ref3.config,
73
+ _ref3$config$pattern = _ref3$config.pattern,
74
+ pattern = _ref3$config$pattern === void 0 ? {} : _ref3$config$pattern,
75
+ _ref3$config$seriesIn = _ref3$config.seriesIntervalWidth,
76
+ paddingInner = _ref3$config$seriesIn === void 0 ? 0 : _ref3$config$seriesIn,
77
+ _ref3$config$paddingI = _ref3$config.paddingInner,
78
+ paddingOuter = _ref3$config$paddingI === void 0 ? 0 : _ref3$config$paddingI,
79
+ style = _ref3$config.style,
80
+ fillType = _ref3$config.fillType,
81
+ url = _ref3$config.url,
82
+ size = _ref3$config.size,
83
+ fill = _ref3$config.fill,
84
+ border = _ref3$config.border,
85
+ opacity = _ref3$config.opacity,
86
+ _ref3$config$highligh = _ref3$config.highlight,
87
+ showHighlight = _ref3$config$highligh.show,
88
+ extent = _ref3$config$highligh.extent,
89
+ highlightFill = _ref3$config$highligh.fill,
90
+ headDecorate = _ref3$config.headDecorate,
91
+ _ref3$bandLength = _ref3.bandLength,
92
+ bandLength = _ref3$bandLength === void 0 ? 0 : _ref3$bandLength,
93
+ data = _ref3.data,
94
+ _ref3$xAxis = _ref3.xAxis,
95
+ xScaler = _ref3$xAxis.scaler,
96
+ step = _ref3$xAxis.step,
97
+ direction = _ref3$xAxis.direction,
98
+ _ref3$yAxis = _ref3.yAxis,
99
+ yScaler = _ref3$yAxis.scaler,
100
+ isClipAxis = _ref3$yAxis.isClipAxis,
101
+ clipValue = _ref3$yAxis.clipValue;
115
102
  if (!data.length) return null;
116
-
117
103
  var _getSeriesInfo = (0, _utils.getSeriesInfo)({
118
- step: step,
119
- bandLength: bandLength,
120
- paddingInner: paddingInner,
121
- paddingOuter: paddingOuter
122
- }),
123
- seriesWidth = _getSeriesInfo.seriesWidth,
124
- seriesStep = _getSeriesInfo.seriesStep,
125
- seriesStart = _getSeriesInfo.seriesStart;
126
-
104
+ step: step,
105
+ bandLength: bandLength,
106
+ paddingInner: paddingInner,
107
+ paddingOuter: paddingOuter
108
+ }),
109
+ seriesWidth = _getSeriesInfo.seriesWidth,
110
+ seriesStep = _getSeriesInfo.seriesStep,
111
+ seriesStart = _getSeriesInfo.seriesStart;
127
112
  var _data = showHighlight ? getHighlightData(data, extent) : data;
128
-
129
- var isVertical = direction === 'vertical';
113
+ var isVertical = direction === "vertical";
130
114
  var borderStr = "".concat(border.borderColor, " solid ").concat(border.borderWidth, "px");
131
115
  return /*#__PURE__*/_react["default"].createElement("g", {
132
116
  className: "__easyv-band"
133
117
  }, _data.map(function (_ref4, i) {
134
118
  var flag = _ref4.flag,
135
- index = _ref4.index,
136
- _ref4$bound = (0, _slicedToArray2["default"])(_ref4.bound, 2),
137
- start = _ref4$bound[0],
138
- end = _ref4$bound[1],
139
- data = _ref4.data,
140
- _ref4$data = _ref4.data,
141
- x = _ref4$data.x,
142
- y = _ref4$data.y,
143
- s = _ref4$data.s;
144
-
145
- var y1 = yScaler(isVertical ? end : start);
146
- var y2 = yScaler(isVertical ? start : end);
119
+ index = _ref4.index,
120
+ _ref4$bound = (0, _slicedToArray2["default"])(_ref4.bound, 2),
121
+ start = _ref4$bound[0],
122
+ end = _ref4$bound[1],
123
+ data = _ref4.data,
124
+ _ref4$data = _ref4.data,
125
+ x = _ref4$data.x,
126
+ y = _ref4$data.y,
127
+ s = _ref4$data.s;
128
+ //todo 柱状中空设置
129
+ var y1, y2;
130
+ //断轴图相关,断轴图的scaler是一个数组,内含上断轴下断轴的scaler
131
+ if (isClipAxis) {
132
+ if (end > +clipValue) {
133
+ y1 = yScaler[1](start);
134
+ y2 = yScaler[0](end);
135
+ } else {
136
+ y1 = yScaler[1](start);
137
+ y2 = yScaler[1](end);
138
+ }
139
+ } else {
140
+ y1 = yScaler(isVertical ? end : start);
141
+ y2 = yScaler(isVertical ? start : end);
142
+ }
147
143
  var positionX = xScaler(x) - step / 2 + seriesStart + index * seriesStep;
148
144
  var showHead, headUrl, headWidth, headHeight, headTranslate;
149
-
150
145
  if (headDecorate) {
151
146
  showHead = headDecorate.show, headUrl = headDecorate.url, headWidth = headDecorate.size.width, headHeight = headDecorate.size.height, headTranslate = headDecorate.translate;
152
147
  }
153
-
148
+ //断轴图相关,将柱形在断轴处切开
149
+ var setClipPath = function setClipPath() {
150
+ if (isClipAxis && end > +clipValue) {
151
+ var clipValueY2 = yScaler[0](clipValue); //上方
152
+ var clipValueY1 = yScaler[1](clipValue); //下方
153
+ var top = Math.abs((y2 - clipValueY2) / (y1 - y2)) * 100;
154
+ var bottom = Math.abs((y2 - clipValueY1) / (y1 - y2)) * 100;
155
+
156
+ //clip path属性
157
+ 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%)");
158
+ } else {
159
+ return "none";
160
+ }
161
+ };
154
162
  if (isNaN(positionX)) return null;
155
163
  var positionY = y < 0 ? y1 : y2;
156
164
  var attr = getAttr({
@@ -183,14 +191,14 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
183
191
  }
184
192
  }), /*#__PURE__*/_react["default"].createElement("div", {
185
193
  style: _objectSpread({
186
- width: '100%',
187
- height: '100%',
188
-
194
+ width: "100%",
195
+ height: "100%",
189
196
  /** Safari Bug **/
190
- position: 'fixed',
191
- opacity: fillType == 'pattern' ? opacity : 1,
192
- background: fillType == 'pattern' ? "50% 50% / ".concat(size.width, "px ").concat(size.height, "px repeat ") + 'url(' + url + ')' : (0, _utils.getBandBackground)(pattern, extent === flag ? highlightFill : fill),
193
- borderRadius: style == 'square' ? '0 0 0 0' : getBorderRadius({
197
+ position: "fixed",
198
+ clipPath: setClipPath(),
199
+ opacity: fillType == "pattern" ? opacity : 1,
200
+ background: fillType == "pattern" ? "50% 50% / ".concat(size.width, "px ").concat(size.height, "px repeat ") + "url(" + url + ")" : (0, _utils.getBandBackground)(pattern, extent === flag ? highlightFill : fill),
201
+ borderRadius: style == "square" ? "0 0 0 0" : getBorderRadius({
194
202
  isVertical: isVertical,
195
203
  positive: y > 0,
196
204
  seriesWidth: seriesWidth
@@ -207,5 +215,4 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
207
215
  }));
208
216
  }));
209
217
  });
210
-
211
218
  exports["default"] = _default;
@@ -1,59 +1,59 @@
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
- yScaler = _ref.yAxis.scaler,
50
- data = _ref.data;
51
-
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
+ _ref$yAxis = _ref.yAxis,
42
+ yScaler = _ref$yAxis.scaler,
43
+ clipValue = _ref$yAxis.clipValue,
44
+ isClipAxis = _ref$yAxis.isClipAxis,
45
+ data = _ref.data;
52
46
  try {
53
- var x1 = orientation == 'left' ? yScaler(data.value) : marginLeft,
54
- x2 = orientation == 'left' ? yScaler(data.value) : width - marginRight,
55
- y1 = orientation == 'left' ? marginLeft : yScaler(data.value),
56
- y2 = orientation == 'left' ? height - marginRight : yScaler(data.value);
47
+ var x1, x2, y1, y2;
48
+ if (isClipAxis) {
49
+ if (data.value > +clipValue) {
50
+ 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);
51
+ } else {
52
+ x1 = orientation == 'left' ? yScaler[1](data.value) : marginLeft, x2 = orientation == 'left' ? yScaler[1](data.value) : width - marginRight, y1 = orientation == 'left' ? marginLeft : yScaler[1](data.value), y2 = orientation == 'left' ? height - marginRight : yScaler[1](data.value);
53
+ }
54
+ } else {
55
+ 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);
56
+ }
57
57
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("g", {
58
58
  className: "__easyv-baseLine"
59
59
  }, /*#__PURE__*/_react["default"].createElement("line", {
@@ -84,5 +84,4 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
84
84
  return null;
85
85
  }
86
86
  });
87
-
88
87
  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,