@easyv/charts 1.4.29 → 1.4.31

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 +39 -26
  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 +100 -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,12 +1,16 @@
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.useAiDataOfPie = exports.useAiData = void 0;
9
+
8
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+
9
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
10
14
  //生成AI图表分析所需的数据
11
15
  var useAiData = function useAiData(data, axes, series) {
12
16
  try {
@@ -16,18 +20,19 @@ var useAiData = function useAiData(data, axes, series) {
16
20
  var type = d.yOrZ;
17
21
  var yAxis = axes.get(type);
18
22
  var _yAxis$config$unit = yAxis.config.unit,
19
- show = _yAxis$config$unit.show,
20
- text = _yAxis$config$unit.text;
23
+ show = _yAxis$config$unit.show,
24
+ text = _yAxis$config$unit.text;
21
25
  var unit = show ? text : "";
22
26
  return [d.name, d.displayName + (unit === "" ? "" : "(".concat(unit, ")"))];
23
27
  }));
24
28
  var res = new Map();
25
29
  data.forEach(function (d) {
26
30
  var x = d.x,
27
- y = d.y,
28
- s = d.s;
31
+ y = d.y,
32
+ s = d.s;
29
33
  var arr = res.get(x);
30
34
  var sObj = seriesMap.get(s);
35
+
31
36
  if (arr) {
32
37
  arr.push((0, _defineProperty2["default"])({}, sObj, y));
33
38
  } else {
@@ -42,26 +47,29 @@ var useAiData = function useAiData(data, axes, series) {
42
47
  });
43
48
  return obj;
44
49
  });
45
- } catch (e) {
46
- // console.error("生成AI数据失败:",e);
50
+ } catch (e) {// console.error("生成AI数据失败:",e);
47
51
  }
52
+
48
53
  return [];
49
- };
54
+ }; //生成饼图的AI图表分析所需的数据
55
+
50
56
 
51
- //生成饼图的AI图表分析所需的数据
52
57
  exports.useAiData = useAiData;
58
+
53
59
  var useAiDataOfPie = function useAiDataOfPie(series, legend) {
54
60
  try {
55
61
  var _legend$config$value$ = legend.config.value.suffix,
56
- show = _legend$config$value$.show,
57
- text = _legend$config$value$.text;
62
+ show = _legend$config$value$.show,
63
+ text = _legend$config$value$.text;
58
64
  return series.map(function (d) {
59
65
  var _ref2;
66
+
60
67
  return _ref2 = {}, (0, _defineProperty2["default"])(_ref2, d.displayName, d.value + (show ? text : "")), (0, _defineProperty2["default"])(_ref2, "占比值", d.percent + "%"), _ref2;
61
68
  });
62
- } catch (e) {
63
- // console.error("生成ai数据失败:",e);
69
+ } catch (e) {// console.error("生成ai数据失败:",e);
64
70
  }
71
+
65
72
  return [];
66
73
  };
74
+
67
75
  exports.useAiDataOfPie = useAiDataOfPie;
@@ -1,29 +1,39 @@
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
  var _popmotion = require("popmotion");
17
+
12
18
  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; }
19
+
13
20
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
14
- /**
15
- * 图表数据动画
16
- * @param {Array} data data列表
17
- * @param {boolean} dataAnimation 是否开启数据增长动画
18
- * @returns 改变后的数据
21
+
22
+ /**
23
+ * 图表数据动画
24
+ * @param {Array} data data列表
25
+ * @param {boolean} dataAnimation 是否开启数据增长动画
26
+ * @returns 改变后的数据
19
27
  */
20
28
  var _default = function _default(data, dataAnimation) {
21
29
  var _useState = (0, _react.useState)([]),
22
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
23
- animateData = _useState2[0],
24
- setAnimateData = _useState2[1];
30
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
31
+ animateData = _useState2[0],
32
+ setAnimateData = _useState2[1];
33
+
25
34
  (0, _react.useEffect)(function () {
26
35
  var animateRef = null;
36
+
27
37
  if (dataAnimation && dataAnimation.show && dataAnimation.duration && data.length) {
28
38
  animateRef = (0, _popmotion.animate)({
29
39
  autoplay: true,
@@ -36,6 +46,7 @@ var _default = function _default(data, dataAnimation) {
36
46
  setAnimateData(function (oldData) {
37
47
  var oldLength = oldData.length;
38
48
  var newLength = data.length;
49
+
39
50
  if (oldLength >= newLength) {
40
51
  return oldData.map(function (_ref, i) {
41
52
  var y = _ref.y;
@@ -67,10 +78,12 @@ var _default = function _default(data, dataAnimation) {
67
78
  } else {
68
79
  setAnimateData(data);
69
80
  }
81
+
70
82
  return function () {
71
83
  animateRef && animateRef.stop();
72
84
  };
73
85
  }, [data, dataAnimation]);
74
86
  return animateData;
75
87
  };
88
+
76
89
  exports["default"] = _default;
@@ -1,54 +1,75 @@
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 _react = require("react");
13
+
10
14
  var _d3Scale = require("d3-scale");
15
+
11
16
  var _utils = require("../utils");
17
+
12
18
  var _utils2 = require("@easyv/utils/lib/common/utils");
19
+
13
20
  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; }
21
+
14
22
  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; }
23
+
15
24
  var getCount = function getCount(num) {
16
25
  var i = 0,
17
- num_ = Math.abs(num);
26
+ num_ = Math.abs(num);
18
27
  if (num_ < 1) return i;
28
+
19
29
  while (num_ > 10) {
20
30
  i++;
21
31
  num_ = Math.floor(num_ / 10);
22
32
  }
33
+
23
34
  return i;
24
35
  };
36
+
25
37
  var getNewDomain = function getNewDomain(domain, mode, step) {
26
38
  var newDomain = [];
27
39
  var min = domain[0],
28
- max = domain[1];
40
+ max = domain[1];
29
41
  var minCount = Math.pow(10, getCount(min)),
30
- maxCount = Math.pow(10, getCount(max));
42
+ maxCount = Math.pow(10, getCount(max));
43
+
31
44
  switch (mode) {
32
45
  case "count":
33
46
  newDomain[0] = Math.floor(domain[0] / minCount) * minCount;
34
47
  newDomain[1] = Math.ceil(domain[1] / maxCount) * maxCount;
35
48
  break;
49
+
36
50
  case "step":
37
51
  newDomain = [domain[0], domain[0]];
52
+
38
53
  while (newDomain[1] < domain[1]) {
39
54
  newDomain[1] += step;
40
55
  }
56
+
41
57
  }
58
+
42
59
  return newDomain;
43
60
  };
61
+
44
62
  var getTickCount = function getTickCount(domain, count, decimal) {
45
63
  var multiple = Math.pow(10, decimal);
46
64
  var gap = domain[1] * multiple - domain[0] * multiple;
65
+
47
66
  if (gap < count) {
48
67
  return Math.max(2, 1 + gap);
49
68
  }
69
+
50
70
  return count;
51
71
  };
72
+
52
73
  var scales = {
53
74
  linear: _d3Scale.scaleLinear,
54
75
  log: _d3Scale.scaleLog,
@@ -56,54 +77,54 @@ var scales = {
56
77
  utc: _d3Scale.scaleUtc,
57
78
  ordinal: _utils.band
58
79
  };
59
-
60
80
  /**
61
81
  * x/y/z轴
62
82
  * @param {Array} axes 轴列表数组
63
83
  * @param {Object} context 其中需要包括
64
84
  * @returns {Map} 返回所有轴
65
85
  */
86
+
66
87
  var _default = function _default(_ref) {
67
88
  var axes = _ref.axes,
68
- _ref$context = _ref.context,
69
- width = _ref$context.width,
70
- height = _ref$context.height,
71
- isControlChart = _ref.isControlChart,
72
- controlConfig = _ref.control;
89
+ _ref$context = _ref.context,
90
+ width = _ref$context.width,
91
+ height = _ref$context.height,
92
+ isControlChart = _ref.isControlChart,
93
+ controlConfig = _ref.control;
94
+
73
95
  var _axes = (0, _react.useMemo)(function () {
74
96
  var tmp = new Map();
75
97
  var xAxisPositions = [];
76
98
  axes.forEach(function (item) {
77
99
  var _item$config$label = item.config.label,
78
- _item$config$label$sh = _item$config$label.showLast,
79
- showLast = _item$config$label$sh === void 0 ? false : _item$config$label$sh,
80
- _item$config$label$de = _item$config$label.decimal,
81
- decimal = _item$config$label$de === void 0 ? 0 : _item$config$label$de,
82
- type = item.type,
83
- orientation = item.orientation,
84
- ticks = item.ticks,
85
- _item$tickCount = item.tickCount,
86
- count = _item$tickCount === void 0 ? 1 : _item$tickCount,
87
- _item$step = item.step,
88
- step = _item$step === void 0 ? 1 : _item$step,
89
- domain = item.domain,
90
- axisType = item.axisType,
91
- _item$paddingOuter = item.paddingOuter,
92
- paddingOuter = _item$paddingOuter === void 0 ? 0 : _item$paddingOuter,
93
- auto = item.auto,
94
- mode = item.mode,
95
- carousel = item.carousel,
96
- config = item.config,
97
- isClipAxis = item.isClipAxis,
98
- bottomClipAxisCount = item.bottomClipAxisCount,
99
- topClipAxisCount = item.topClipAxisCount,
100
- bottomClipAxisStep = item.bottomClipAxisStep,
101
- topClipAxisStep = item.topClipAxisStep,
102
- clipValue = item.clipValue,
103
- clipPosition = item.clipPosition,
104
- clipDifferenceValue = item.clipDifferenceValue,
105
- clipAxisMode = item.clipAxisMode;
106
- //如果是断轴类型,输出一套完全不同的values
100
+ _item$config$label$sh = _item$config$label.showLast,
101
+ showLast = _item$config$label$sh === void 0 ? false : _item$config$label$sh,
102
+ _item$config$label$de = _item$config$label.decimal,
103
+ decimal = _item$config$label$de === void 0 ? 0 : _item$config$label$de,
104
+ type = item.type,
105
+ orientation = item.orientation,
106
+ ticks = item.ticks,
107
+ _item$tickCount = item.tickCount,
108
+ count = _item$tickCount === void 0 ? 1 : _item$tickCount,
109
+ _item$step = item.step,
110
+ step = _item$step === void 0 ? 1 : _item$step,
111
+ domain = item.domain,
112
+ axisType = item.axisType,
113
+ _item$paddingOuter = item.paddingOuter,
114
+ paddingOuter = _item$paddingOuter === void 0 ? 0 : _item$paddingOuter,
115
+ auto = item.auto,
116
+ mode = item.mode,
117
+ carousel = item.carousel,
118
+ config = item.config,
119
+ isClipAxis = item.isClipAxis,
120
+ bottomClipAxisCount = item.bottomClipAxisCount,
121
+ topClipAxisCount = item.topClipAxisCount,
122
+ bottomClipAxisStep = item.bottomClipAxisStep,
123
+ topClipAxisStep = item.topClipAxisStep,
124
+ clipValue = item.clipValue,
125
+ clipPosition = item.clipPosition,
126
+ clipDifferenceValue = item.clipDifferenceValue,
127
+ clipAxisMode = item.clipAxisMode; //如果是断轴类型,输出一套完全不同的values
107
128
 
108
129
  /**
109
130
  * 获取轴的:朝向direction,起点位置start,终点位置end
@@ -113,10 +134,13 @@ var _default = function _default(_ref) {
113
134
  * @param {*} paddingOuter
114
135
  * @returns {start,end,direction}
115
136
  */
137
+
116
138
  function getChartsConfig(orientation, width, height, paddingOuter) {
117
139
  var direction = orientation === "top" || orientation === "bottom" ? "horizontal" : orientation === "left" || orientation === "right" ? "vertical" : "";
118
140
  var length = direction === "horizontal" ? width : direction === "vertical" ? height : 0;
141
+
119
142
  var _paddingOuter = paddingOuter * length;
143
+
120
144
  var start = _paddingOuter / 2;
121
145
  var end = length - start;
122
146
  return {
@@ -127,7 +151,6 @@ var _default = function _default(_ref) {
127
151
  _paddingOuter: _paddingOuter
128
152
  };
129
153
  }
130
-
131
154
  /**
132
155
  * 设置scaler
133
156
  * @param {*} scales
@@ -136,14 +159,16 @@ var _default = function _default(_ref) {
136
159
  * @param {*} range 屏幕坐标的范围
137
160
  * @returns
138
161
  */
162
+
163
+
139
164
  function setScaler(scales, type, domain, range) {
140
165
  //比例将抽象数据的维度映射到可视表示形式。虽然最常用于将数据编码为位置,例如将时间和温度映射到散点图中的水平和垂直位置
141
166
  var scaler = scales[type]().domain(domain).range(range);
142
167
  scaler.type = type;
143
168
  if (type !== "ordinal") scaler.clamp(true); //scaler.nice().clamp(true)
169
+
144
170
  return scaler;
145
171
  }
146
-
147
172
  /**
148
173
  * 获取所有标签数据
149
174
  * @param {*} scaler
@@ -151,10 +176,11 @@ var _default = function _default(_ref) {
151
176
  * @param {*} tickCount
152
177
  * @returns
153
178
  */
179
+
180
+
154
181
  function getAllTicks(scaler, ticks, tickCount) {
155
182
  return ticks ? ticks : scaler.ticks ? scaler.ticks(tickCount) : scaler.domain();
156
183
  }
157
-
158
184
  /**
159
185
  * 计算非自动模式下的标签集合
160
186
  * @param {*} allTicks
@@ -168,8 +194,11 @@ var _default = function _default(_ref) {
168
194
  * @param {*} step
169
195
  * @returns
170
196
  */
197
+
198
+
171
199
  function getTicks(allTicks, type, carousel, showLast, auto, mode, newDomain, tickCount, step) {
172
200
  var _ticks = allTicks;
201
+
173
202
  if (type === "ordinal") {
174
203
  if (carousel === false) {
175
204
  _ticks = (0, _utils.getTicksOfAxis)(_ticks, +tickCount, showLast);
@@ -180,23 +209,26 @@ var _default = function _default(_ref) {
180
209
  case "count":
181
210
  _ticks = (0, _utils2.getYTicks)(newDomain[1], newDomain[0], +tickCount);
182
211
  break;
212
+
183
213
  case "step":
184
214
  _ticks = (0, _utils2.getYTicksByStep)(newDomain[1], newDomain[0], +step);
185
215
  break;
186
216
  }
187
217
  }
188
218
  }
219
+
189
220
  return _ticks;
190
- }
191
- //断轴相关
221
+ } //断轴相关
222
+
223
+
192
224
  var _isClipAxis = isClipAxis,
193
- clipAxisDomain = [],
194
- clipAxisCount = [],
195
- clipAxisTickCount = [],
196
- clipAxisStep = [];
225
+ clipAxisDomain = [],
226
+ clipAxisCount = [],
227
+ clipAxisTickCount = [],
228
+ clipAxisStep = [];
197
229
  var _count = count,
198
- _step = step;
199
- //计算topDomain,bottomDomain,当断轴值为设置不合理的时候,不开启断轴
230
+ _step = step; //计算topDomain,bottomDomain,当断轴值为设置不合理的时候,不开启断轴
231
+
200
232
  if (isClipAxis && (clipValue > domain[1] || clipValue < domain[0])) {
201
233
  _isClipAxis = false;
202
234
  _count = topClipAxisCount;
@@ -206,25 +238,30 @@ var _default = function _default(_ref) {
206
238
  clipAxisCount = [topClipAxisCount, bottomClipAxisCount];
207
239
  clipAxisStep = [topClipAxisStep, bottomClipAxisStep];
208
240
  }
241
+
209
242
  if (_isClipAxis) {
210
243
  var getClipAxisRange = function getClipAxisRange(start, end, clipPosition, clipMargin) {
211
244
  var topRange = [(end - start) * (clipPosition / 100) - clipMargin / 2, start];
212
245
  var bottomRange = [end, (end - start) * (clipPosition / 100) + clipMargin / 2];
213
246
  return [topRange, bottomRange];
214
247
  }; //计算range填入scaler参数
248
+
249
+
215
250
  clipAxisDomain.forEach(function (domain, index) {
216
251
  clipAxisTickCount.push(getTickCount(domain, clipAxisCount[index], decimal));
217
252
  });
253
+
218
254
  var _getChartsConfig = getChartsConfig(orientation, width, height, paddingOuter),
219
- start = _getChartsConfig.start,
220
- end = _getChartsConfig.end,
221
- direction = _getChartsConfig.direction,
222
- _paddingOuter = _getChartsConfig._paddingOuter,
223
- length = _getChartsConfig.length;
255
+ start = _getChartsConfig.start,
256
+ end = _getChartsConfig.end,
257
+ direction = _getChartsConfig.direction,
258
+ _paddingOuter = _getChartsConfig._paddingOuter,
259
+ length = _getChartsConfig.length;
260
+
224
261
  var clipMargin = 10;
225
262
  var clipAxisRange = getClipAxisRange(start, end, clipPosition, clipMargin);
226
- var newClipAxisDomain = [];
227
- //如果非自适应模式,计算新的domain,传入scaler,适配强制步长或者数量强制
263
+ var newClipAxisDomain = []; //如果非自适应模式,计算新的domain,传入scaler,适配强制步长或者数量强制
264
+
228
265
  if (!isNaN(domain[1]) && !auto) {
229
266
  clipAxisDomain.forEach(function (domain, index) {
230
267
  newClipAxisDomain.push(getNewDomain(domain, mode, clipAxisStep[index]));
@@ -232,13 +269,14 @@ var _default = function _default(_ref) {
232
269
  } else {
233
270
  //如果为刻度自适应,使用原先domain直接传入scaler,使用scaler.ticks来计算出标签集合
234
271
  newClipAxisDomain = clipAxisDomain;
235
- }
236
- //设置scaler,scaler会将数值映射真实的坐标(svg坐标)
272
+ } //设置scaler,scaler会将数值映射真实的坐标(svg坐标)
273
+
274
+
237
275
  var clipAxisScaler = [];
238
276
  newClipAxisDomain.forEach(function (domain, index) {
239
277
  clipAxisScaler.push(setScaler(scales, type, domain, clipAxisRange[index]));
240
- });
241
- //clipAxisAllTicks作用是使用scaler.ticks方法,来计算标签集合
278
+ }); //clipAxisAllTicks作用是使用scaler.ticks方法,来计算标签集合
279
+
242
280
  var clipAxisAllTicks = [];
243
281
  clipAxisScaler.forEach(function (scaler, index) {
244
282
  clipAxisAllTicks.push(getAllTicks(scaler, ticks, clipAxisTickCount[index]));
@@ -265,23 +303,28 @@ var _default = function _default(_ref) {
265
303
  } else {
266
304
  //计算真正需要的tickCount,如果domain区间太小,不能完全按照count来,需要减少count数
267
305
  var tickCount = type == "ordinal" ? _count : getTickCount(domain, _count, decimal);
306
+
268
307
  var _getChartsConfig2 = getChartsConfig(orientation, width, height, paddingOuter),
269
- _start = _getChartsConfig2.start,
270
- _end = _getChartsConfig2.end,
271
- _direction = _getChartsConfig2.direction,
272
- _paddingOuter2 = _getChartsConfig2._paddingOuter,
273
- _length = _getChartsConfig2.length;
308
+ _start = _getChartsConfig2.start,
309
+ _end = _getChartsConfig2.end,
310
+ _direction = _getChartsConfig2.direction,
311
+ _paddingOuter2 = _getChartsConfig2._paddingOuter,
312
+ _length = _getChartsConfig2.length;
313
+
274
314
  var range = _direction === "horizontal" ? [_start, _end] : _direction === "vertical" ? [_end, _start] : [0, 0];
275
315
  var newDomain = domain;
316
+
276
317
  if (type !== "ordinal" && !isNaN(domain[1]) && !auto) {
277
318
  newDomain = getNewDomain(domain, mode, _step);
278
319
  }
320
+
279
321
  var scaler = scales[type]().domain(newDomain).range(range);
280
322
  scaler.type = type;
281
323
  if (type !== "ordinal") scaler.clamp(true); //scaler.nice().clamp(true)
324
+
282
325
  var allTicks = ticks ? ticks : scaler.ticks ? scaler.ticks(tickCount) : scaler.domain();
283
- var _ticks = allTicks;
284
- //
326
+ var _ticks = allTicks; //
327
+
285
328
  if (type === "ordinal") {
286
329
  if (carousel === false) {
287
330
  _ticks = (0, _utils.getTicksOfAxis)(_ticks, +tickCount, showLast);
@@ -292,15 +335,19 @@ var _default = function _default(_ref) {
292
335
  case "count":
293
336
  _ticks = (0, _utils2.getYTicks)(newDomain[1], newDomain[0], +tickCount);
294
337
  break;
338
+
295
339
  case "step":
296
340
  _ticks = (0, _utils2.getYTicksByStep)(newDomain[1], newDomain[0], +_step);
297
341
  break;
298
342
  }
299
343
  }
300
344
  }
345
+
301
346
  var _lengthWithoutPaddingOuter = _length - _paddingOuter2;
347
+
302
348
  if (type == "linear" && config.on) {
303
349
  var zeroPosition = scaler(0);
350
+
304
351
  if (zeroPosition !== range[0] && !isNaN(zeroPosition)) {
305
352
  if (_direction === "horizontal") {
306
353
  xAxisPositions.push({
@@ -315,6 +362,7 @@ var _default = function _default(_ref) {
315
362
  }
316
363
  }
317
364
  }
365
+
318
366
  tmp.set(axisType, _objectSpread(_objectSpread({}, item), {}, {
319
367
  count: _count,
320
368
  isClipAxis: _isClipAxis,
@@ -335,6 +383,8 @@ var _default = function _default(_ref) {
335
383
  tmp.get("x") && (tmp.get("x").positions = xAxisPositions);
336
384
  return tmp;
337
385
  }, [axes]);
386
+
338
387
  return _axes;
339
388
  };
389
+
340
390
  exports["default"] = _default;