@easyv/charts 1.6.8 → 1.6.10

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 (52) 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 +79 -105
  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 +138 -325
  48. package/package.json +1 -1
  49. package/src/components/Band.tsx +1 -1
  50. package/src/components/CartesianChart.js +2 -2
  51. package/src/css/index.module.css +1 -1
  52. package/src/formatter/legend.js +13 -1
@@ -1,18 +1,14 @@
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.useAiDataOfPie = exports.useAiData = void 0;
9
-
10
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
-
14
10
  //生成AI图表分析所需的数据
15
- var useAiData = function useAiData(data, axes, series) {
11
+ var useAiData = exports.useAiData = function useAiData(data, axes, series) {
16
12
  try {
17
13
  var xAxis = axes.get("x");
18
14
  var xType = xAxis.config.label.format.type == "date" ? "时间" : "类别";
@@ -20,19 +16,18 @@ var useAiData = function useAiData(data, axes, series) {
20
16
  var type = d.yOrZ;
21
17
  var yAxis = axes.get(type);
22
18
  var _yAxis$config$unit = yAxis.config.unit,
23
- show = _yAxis$config$unit.show,
24
- text = _yAxis$config$unit.text;
19
+ show = _yAxis$config$unit.show,
20
+ text = _yAxis$config$unit.text;
25
21
  var unit = show ? text : "";
26
22
  return [d.name, d.displayName + (unit === "" ? "" : "(".concat(unit, ")"))];
27
23
  }));
28
24
  var res = new Map();
29
25
  data.forEach(function (d) {
30
26
  var x = d.x,
31
- y = d.y,
32
- s = d.s;
27
+ y = d.y,
28
+ s = d.s;
33
29
  var arr = res.get(x);
34
30
  var sObj = seriesMap.get(s);
35
-
36
31
  if (arr) {
37
32
  arr.push((0, _defineProperty2["default"])({}, sObj, y));
38
33
  } else {
@@ -47,29 +42,23 @@ var useAiData = function useAiData(data, axes, series) {
47
42
  });
48
43
  return obj;
49
44
  });
50
- } catch (e) {// console.error("生成AI数据失败:",e);
45
+ } catch (e) {
46
+ // console.error("生成AI数据失败:",e);
51
47
  }
52
-
53
48
  return [];
54
- }; //生成饼图的AI图表分析所需的数据
55
-
56
-
57
- exports.useAiData = useAiData;
49
+ };
58
50
 
59
- var useAiDataOfPie = function useAiDataOfPie(series, legend) {
51
+ //生成饼图的AI图表分析所需的数据
52
+ var useAiDataOfPie = exports.useAiDataOfPie = function useAiDataOfPie(series, legend) {
60
53
  try {
61
54
  var _legend$config$value$ = legend.config.value.suffix,
62
- show = _legend$config$value$.show,
63
- text = _legend$config$value$.text;
55
+ show = _legend$config$value$.show,
56
+ text = _legend$config$value$.text;
64
57
  return series.map(function (d) {
65
- var _ref2;
66
-
67
- return _ref2 = {}, (0, _defineProperty2["default"])(_ref2, d.displayName, d.value + (show ? text : "")), (0, _defineProperty2["default"])(_ref2, "占比值", d.percent + "%"), _ref2;
58
+ return (0, _defineProperty2["default"])((0, _defineProperty2["default"])({}, d.displayName, d.value + (show ? text : "")), "占比值", d.percent + "%");
68
59
  });
69
- } catch (e) {// console.error("生成ai数据失败:",e);
60
+ } catch (e) {
61
+ // console.error("生成ai数据失败:",e);
70
62
  }
71
-
72
63
  return [];
73
- };
74
-
75
- exports.useAiDataOfPie = useAiDataOfPie;
64
+ };
@@ -1,24 +1,16 @@
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
  var _popmotion = require("popmotion");
17
-
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
-
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; }
21
-
12
+ 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; }
13
+ 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; }
22
14
  /**
23
15
  * 图表数据动画
24
16
  * @param {Array} data data列表
@@ -26,15 +18,13 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
26
18
  * @param {boolean} active 是否处于活跃状态,false为休眠
27
19
  * @returns 改变后的数据
28
20
  */
29
- var _default = function _default(data, dataAnimation, active) {
21
+ var _default = exports["default"] = function _default(data, dataAnimation, active) {
30
22
  var _useState = (0, _react.useState)([]),
31
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
32
- animateData = _useState2[0],
33
- setAnimateData = _useState2[1];
34
-
23
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
24
+ animateData = _useState2[0],
25
+ setAnimateData = _useState2[1];
35
26
  (0, _react.useEffect)(function () {
36
27
  var animateRef = null;
37
-
38
28
  if (dataAnimation && dataAnimation.show && dataAnimation.duration && data.length && active) {
39
29
  animateRef = (0, _popmotion.animate)({
40
30
  autoplay: true,
@@ -47,7 +37,6 @@ var _default = function _default(data, dataAnimation, active) {
47
37
  setAnimateData(function (oldData) {
48
38
  var oldLength = oldData.length;
49
39
  var newLength = data.length;
50
-
51
40
  if (oldLength >= newLength) {
52
41
  return oldData.map(function (_ref, i) {
53
42
  var y = _ref.y;
@@ -79,12 +68,9 @@ var _default = function _default(data, dataAnimation, active) {
79
68
  } else {
80
69
  setAnimateData(data);
81
70
  }
82
-
83
71
  return function () {
84
72
  animateRef && animateRef.stop();
85
73
  };
86
74
  }, [data, dataAnimation, active]);
87
75
  return animateData;
88
- };
89
-
90
- exports["default"] = _default;
76
+ };
@@ -1,41 +1,28 @@
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 _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
-
14
10
  var _react = require("react");
15
-
16
11
  var _d3Scale = require("d3-scale");
17
-
18
12
  var _utils = require("../utils");
19
-
20
13
  var _utils2 = require("@easyv/utils/lib/common/utils");
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
-
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; }
26
16
  var getCount = function getCount(num) {
27
17
  var i = 0,
28
- num_ = Math.abs(num);
18
+ num_ = Math.abs(num);
29
19
  if (num_ < 1) return i;
30
-
31
20
  while (num_ > 10) {
32
21
  i++;
33
22
  num_ = Math.floor(num_ / 10);
34
23
  }
35
-
36
24
  return i;
37
25
  };
38
-
39
26
  var getNewDomain = function getNewDomain(domain, mode, step) {
40
27
  var extent = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
41
28
  var numericalRangeModel = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "value";
@@ -44,69 +31,58 @@ var getNewDomain = function getNewDomain(domain, mode, step) {
44
31
  min: 100
45
32
  };
46
33
  var _extent$min = extent.min,
47
- defaultBottom = _extent$min === void 0 ? "" : _extent$min,
48
- _extent$max = extent.max,
49
- defaultTop = _extent$max === void 0 ? "" : _extent$max;
34
+ defaultBottom = _extent$min === void 0 ? "" : _extent$min,
35
+ _extent$max = extent.max,
36
+ defaultTop = _extent$max === void 0 ? "" : _extent$max;
50
37
  var _percentageExtent$min = percentageExtent.min,
51
- defaultPercentageMin = _percentageExtent$min === void 0 ? 100 : _percentageExtent$min,
52
- _percentageExtent$max = percentageExtent.max,
53
- defaultPercentageMax = _percentageExtent$max === void 0 ? 100 : _percentageExtent$max;
38
+ defaultPercentageMin = _percentageExtent$min === void 0 ? 100 : _percentageExtent$min,
39
+ _percentageExtent$max = percentageExtent.max,
40
+ defaultPercentageMax = _percentageExtent$max === void 0 ? 100 : _percentageExtent$max;
54
41
  var bottom = defaultBottom,
55
- top = defaultTop;
56
- var newDomain = []; //能进入这个函数,说明extent中min和max至少有一个是缺失的,如果max存在,意味着纵轴上限被固定
57
-
42
+ top = defaultTop;
43
+ var newDomain = [];
44
+ //能进入这个函数,说明extent中min和max至少有一个是缺失的,如果max存在,意味着纵轴上限被固定
58
45
  var min = domain[0],
59
- max = domain[1];
46
+ max = domain[1];
60
47
  var minCount = Math.pow(10, getCount(min)),
61
- maxCount = Math.pow(10, getCount(max)); //轴标签,范围模式,百分比模式
48
+ maxCount = Math.pow(10, getCount(max));
62
49
 
50
+ //轴标签,范围模式,百分比模式
63
51
  if (numericalRangeModel == "percentage") {
64
52
  var _max = defaultPercentageMax === "" ? 100 : defaultPercentageMax;
65
-
66
53
  var _min = defaultPercentageMin === "" ? 100 : defaultPercentageMin;
67
-
68
54
  bottom = min * _min / 100;
69
55
  top = max * _max / 100;
70
56
  }
71
-
72
57
  switch (mode) {
73
58
  case "count":
74
59
  newDomain[0] = bottom != "" ? bottom : Math.floor(domain[0] / minCount) * minCount;
75
60
  newDomain[1] = top != "" ? top : Math.ceil(domain[1] / maxCount) * maxCount;
76
61
  break;
77
-
78
62
  case "step":
79
63
  if (defaultTop != "") {
80
64
  newDomain = [domain[1], domain[1]];
81
-
82
65
  while (newDomain[0] > domain[0]) {
83
66
  newDomain[0] -= step;
84
67
  }
85
68
  } else {
86
69
  newDomain = [domain[0], domain[0]];
87
-
88
70
  while (newDomain[1] < domain[1]) {
89
71
  newDomain[1] += step;
90
72
  }
91
73
  }
92
-
93
74
  break;
94
75
  }
95
-
96
76
  return newDomain;
97
77
  };
98
-
99
78
  var getTickCount = function getTickCount(domain, count, decimal) {
100
79
  var multiple = Math.pow(10, decimal);
101
80
  var gap = domain[1] * multiple - domain[0] * multiple;
102
-
103
81
  if (gap < count) {
104
82
  return Math.max(2, 1 + gap);
105
83
  }
106
-
107
84
  return count;
108
85
  };
109
-
110
86
  var scales = {
111
87
  linear: _d3Scale.scaleLinear,
112
88
  log: _d3Scale.scaleLog,
@@ -114,64 +90,62 @@ var scales = {
114
90
  utc: _d3Scale.scaleUtc,
115
91
  ordinal: _utils.band
116
92
  };
93
+
117
94
  /**
118
95
  * x/y/z轴
119
96
  * @param {Array} axes 轴列表数组
120
97
  * @param {Object} context 其中需要包括
121
98
  * @returns {Map} 返回所有轴
122
99
  */
123
-
124
- var _default = function _default(_ref) {
100
+ var _default = exports["default"] = function _default(_ref) {
125
101
  var axes = _ref.axes,
126
- _ref$context = _ref.context,
127
- chartWidth = _ref$context.width,
128
- chartHeight = _ref$context.height,
129
- controlInfo = _ref.controlInfo;
102
+ _ref$context = _ref.context,
103
+ chartWidth = _ref$context.width,
104
+ chartHeight = _ref$context.height,
105
+ controlInfo = _ref.controlInfo;
130
106
  var isC = controlInfo.isC,
131
- cHeight = controlInfo.cHeight,
132
- cWidth = controlInfo.cWidth,
133
- cPercent = controlInfo.cPercent;
107
+ cHeight = controlInfo.cHeight,
108
+ cWidth = controlInfo.cWidth,
109
+ cPercent = controlInfo.cPercent;
134
110
  var width = chartWidth;
135
111
  var height = chartHeight - cHeight;
136
-
137
112
  var _axes = (0, _react.useMemo)(function () {
138
113
  var tmp = new Map();
139
114
  var xAxisPositions = new Set(); //用Set去重,去掉重复的x轴
140
-
141
115
  axes.forEach(function (item) {
142
116
  var _item$config$label = item.config.label,
143
- extent = _item$config$label.extent,
144
- percentageExtent = _item$config$label.percentageExtent,
145
- _item$config$label$nu = _item$config$label.numericalRangeModel,
146
- numericalRangeModel = _item$config$label$nu === void 0 ? "value" : _item$config$label$nu,
147
- _item$config$label$sh = _item$config$label.showLast,
148
- showLast = _item$config$label$sh === void 0 ? false : _item$config$label$sh,
149
- _item$config$label$de = _item$config$label.decimal,
150
- decimal = _item$config$label$de === void 0 ? 0 : _item$config$label$de,
151
- type = item.type,
152
- orientation = item.orientation,
153
- ticks = item.ticks,
154
- reverse = item.reverse,
155
- _item$tickCount = item.tickCount,
156
- count = _item$tickCount === void 0 ? 1 : _item$tickCount,
157
- _item$step = item.step,
158
- step = _item$step === void 0 ? 1 : _item$step,
159
- domain = item.domain,
160
- axisType = item.axisType,
161
- _item$paddingOuter = item.paddingOuter,
162
- paddingOuter = _item$paddingOuter === void 0 ? 0 : _item$paddingOuter,
163
- auto = item.auto,
164
- mode = item.mode,
165
- carousel = item.carousel,
166
- config = item.config,
167
- isClipAxis = item.isClipAxis,
168
- bottomClipAxisCount = item.bottomClipAxisCount,
169
- topClipAxisCount = item.topClipAxisCount,
170
- bottomClipAxisStep = item.bottomClipAxisStep,
171
- topClipAxisStep = item.topClipAxisStep,
172
- clipValue = item.clipValue,
173
- clipPosition = item.clipPosition; //如果是断轴类型,输出一套完全不同的values
174
-
117
+ extent = _item$config$label.extent,
118
+ percentageExtent = _item$config$label.percentageExtent,
119
+ _item$config$label$nu = _item$config$label.numericalRangeModel,
120
+ numericalRangeModel = _item$config$label$nu === void 0 ? "value" : _item$config$label$nu,
121
+ _item$config$label$sh = _item$config$label.showLast,
122
+ showLast = _item$config$label$sh === void 0 ? false : _item$config$label$sh,
123
+ _item$config$label$de = _item$config$label.decimal,
124
+ decimal = _item$config$label$de === void 0 ? 0 : _item$config$label$de,
125
+ type = item.type,
126
+ orientation = item.orientation,
127
+ ticks = item.ticks,
128
+ reverse = item.reverse,
129
+ _item$tickCount = item.tickCount,
130
+ count = _item$tickCount === void 0 ? 1 : _item$tickCount,
131
+ _item$step = item.step,
132
+ step = _item$step === void 0 ? 1 : _item$step,
133
+ domain = item.domain,
134
+ axisType = item.axisType,
135
+ _item$paddingOuter = item.paddingOuter,
136
+ paddingOuter = _item$paddingOuter === void 0 ? 0 : _item$paddingOuter,
137
+ auto = item.auto,
138
+ mode = item.mode,
139
+ carousel = item.carousel,
140
+ config = item.config,
141
+ isClipAxis = item.isClipAxis,
142
+ bottomClipAxisCount = item.bottomClipAxisCount,
143
+ topClipAxisCount = item.topClipAxisCount,
144
+ bottomClipAxisStep = item.bottomClipAxisStep,
145
+ topClipAxisStep = item.topClipAxisStep,
146
+ clipValue = item.clipValue,
147
+ clipPosition = item.clipPosition;
148
+ //如果是断轴类型,输出一套完全不同的values
175
149
  /**
176
150
  * 获取轴的:朝向direction,起点位置start,终点位置end
177
151
  * @param {*} orientation
@@ -180,13 +154,10 @@ var _default = function _default(_ref) {
180
154
  * @param {*} paddingOuter
181
155
  * @returns { start, end, direction }
182
156
  */
183
-
184
157
  function getChartsConfig(orientation, width, height, paddingOuter) {
185
158
  var direction = orientation === "top" || orientation === "bottom" ? "horizontal" : orientation === "left" || orientation === "right" ? "vertical" : "";
186
159
  var length = direction === "horizontal" ? width : direction === "vertical" ? height : 0;
187
-
188
160
  var _paddingOuter = paddingOuter * length;
189
-
190
161
  var start = _paddingOuter / 2;
191
162
  var end = length - start;
192
163
  return {
@@ -197,6 +168,7 @@ var _default = function _default(_ref) {
197
168
  _paddingOuter: _paddingOuter
198
169
  };
199
170
  }
171
+
200
172
  /**
201
173
  * 设置scaler
202
174
  * @param {*} scales
@@ -205,16 +177,14 @@ var _default = function _default(_ref) {
205
177
  * @param {*} 屏幕坐标的范围
206
178
  * @returns
207
179
  */
208
-
209
-
210
180
  function setScaler(scales, type, domain, range) {
211
181
  //比例将抽象数据的维度映射到可视表示形式。虽然最常用于将数据编码为位置,例如将时间和温度映射到散点图中的水平和垂直位置
212
182
  var scaler = scales[type]().domain(domain).range(range);
213
183
  scaler.type = type;
214
184
  if (type !== "ordinal") scaler.clamp(true); //scaler.nice().clamp(true)
215
-
216
185
  return scaler;
217
186
  }
187
+
218
188
  /**
219
189
  * 获取所有标签数据
220
190
  * @param {*} scaler
@@ -222,11 +192,10 @@ var _default = function _default(_ref) {
222
192
  * @param {*} tickCount
223
193
  * @returns
224
194
  */
225
-
226
-
227
195
  function getAllTicks(scaler, ticks, tickCount) {
228
196
  return ticks ? ticks : scaler.ticks ? scaler.ticks(tickCount) : scaler.domain();
229
197
  }
198
+
230
199
  /**
231
200
  * 计算非自动模式下的标签集合
232
201
  * @param {*} allTicks
@@ -240,11 +209,8 @@ var _default = function _default(_ref) {
240
209
  * @param {*} step
241
210
  * @returns
242
211
  */
243
-
244
-
245
212
  function getTicks(allTicks, type, carousel, showLast, auto, mode, newDomain, tickCount, step) {
246
213
  var _ticks = allTicks;
247
-
248
214
  if (type === "ordinal") {
249
215
  if (carousel === false) {
250
216
  _ticks = (0, _utils.getTicksOfAxis)(_ticks, +tickCount, showLast);
@@ -255,7 +221,6 @@ var _default = function _default(_ref) {
255
221
  case "count":
256
222
  _ticks = (0, _utils2.getYTicks)(newDomain[1], newDomain[0], +tickCount);
257
223
  break;
258
-
259
224
  case "step":
260
225
  var newStep = +step;
261
226
  newStep = (newDomain[1] - newDomain[0]) / newStep > 30 ? Math.ceil((newDomain[1] - newDomain[0]) / 30) : newStep;
@@ -264,19 +229,17 @@ var _default = function _default(_ref) {
264
229
  }
265
230
  }
266
231
  }
267
-
268
232
  return _ticks;
269
- } //断轴相关
270
-
271
-
233
+ }
234
+ //断轴相关
272
235
  var _isClipAxis = isClipAxis,
273
- clipAxisDomain = [],
274
- clipAxisCount = [],
275
- clipAxisTickCount = [],
276
- clipAxisStep = [];
236
+ clipAxisDomain = [],
237
+ clipAxisCount = [],
238
+ clipAxisTickCount = [],
239
+ clipAxisStep = [];
277
240
  var _count = count,
278
- _step = step; //计算topDomain,bottomDomain,当断轴值为设置不合理的时候,不开启断轴
279
-
241
+ _step = step;
242
+ //计算topDomain,bottomDomain,当断轴值为设置不合理的时候,不开启断轴
280
243
  if (isClipAxis && (clipValue > domain[1] || clipValue < domain[0])) {
281
244
  _isClipAxis = false;
282
245
  _count = topClipAxisCount;
@@ -286,30 +249,25 @@ var _default = function _default(_ref) {
286
249
  clipAxisCount = [topClipAxisCount, bottomClipAxisCount];
287
250
  clipAxisStep = [topClipAxisStep, bottomClipAxisStep];
288
251
  }
289
-
290
252
  if (_isClipAxis) {
291
253
  var getClipAxisRange = function getClipAxisRange(start, end, clipPosition, clipMargin) {
292
254
  var topRange = [(end - start) * (clipPosition / 100) - clipMargin / 2, start];
293
255
  var bottomRange = [end, (end - start) * (clipPosition / 100) + clipMargin / 2];
294
256
  return [topRange, bottomRange];
295
257
  }; //计算range填入scaler参数
296
-
297
-
298
258
  clipAxisDomain.forEach(function (domain, index) {
299
259
  clipAxisTickCount.push(getTickCount(domain, clipAxisCount[index], decimal));
300
260
  });
301
-
302
261
  var _getChartsConfig = getChartsConfig(orientation, width, height, paddingOuter),
303
- start = _getChartsConfig.start,
304
- end = _getChartsConfig.end,
305
- direction = _getChartsConfig.direction,
306
- _paddingOuter = _getChartsConfig._paddingOuter,
307
- length = _getChartsConfig.length;
308
-
262
+ start = _getChartsConfig.start,
263
+ end = _getChartsConfig.end,
264
+ direction = _getChartsConfig.direction,
265
+ _paddingOuter = _getChartsConfig._paddingOuter,
266
+ length = _getChartsConfig.length;
309
267
  var clipMargin = 10;
310
268
  var clipAxisRange = getClipAxisRange(start, end, clipPosition, clipMargin);
311
- var newClipAxisDomain = []; //如果非自适应模式,计算新的domain,传入scaler,适配强制步长或者数量强制
312
-
269
+ var newClipAxisDomain = [];
270
+ //如果非自适应模式,计算新的domain,传入scaler,适配强制步长或者数量强制
313
271
  if (!isNaN(domain[1]) && !auto) {
314
272
  clipAxisDomain.forEach(function (domain, index) {
315
273
  newClipAxisDomain.push(getNewDomain(domain, mode, clipAxisStep[index]));
@@ -317,14 +275,13 @@ var _default = function _default(_ref) {
317
275
  } else {
318
276
  //如果为刻度自适应,使用原先domain直接传入scaler,使用scaler.ticks来计算出标签集合
319
277
  newClipAxisDomain = clipAxisDomain;
320
- } //设置scaler,scaler会将数值映射真实的坐标(svg坐标)
321
-
322
-
278
+ }
279
+ //设置scaler,scaler会将数值映射真实的坐标(svg坐标)
323
280
  var clipAxisScaler = [];
324
281
  newClipAxisDomain.forEach(function (domain, index) {
325
282
  clipAxisScaler.push(setScaler(scales, type, domain, clipAxisRange[index]));
326
- }); //clipAxisAllTicks作用是使用scaler.ticks方法,来计算标签集合
327
-
283
+ });
284
+ //clipAxisAllTicks作用是使用scaler.ticks方法,来计算标签集合
328
285
  var clipAxisAllTicks = [];
329
286
  clipAxisScaler.forEach(function (scaler, index) {
330
287
  clipAxisAllTicks.push(getAllTicks(scaler, ticks, clipAxisTickCount[index]));
@@ -351,29 +308,24 @@ var _default = function _default(_ref) {
351
308
  } else {
352
309
  //计算真正需要的tickCount,如果domain区间太小,不能完全按照count来,需要减少count数
353
310
  var tickCount = type == "ordinal" ? _count : getTickCount(domain, _count, decimal);
354
-
355
311
  var _getChartsConfig2 = getChartsConfig(orientation, width, height, paddingOuter),
356
- _start = _getChartsConfig2.start,
357
- _end = _getChartsConfig2.end,
358
- _direction = _getChartsConfig2.direction,
359
- _paddingOuter2 = _getChartsConfig2._paddingOuter,
360
- _length = _getChartsConfig2.length;
361
-
312
+ _start = _getChartsConfig2.start,
313
+ _end = _getChartsConfig2.end,
314
+ _direction = _getChartsConfig2.direction,
315
+ _paddingOuter2 = _getChartsConfig2._paddingOuter,
316
+ _length = _getChartsConfig2.length;
362
317
  var range = _direction === "horizontal" ? [_start, _end] : _direction === "vertical" ? [_end, _start] : [0, 0];
363
318
  if (reverse) range = [range[1], range[0]];
364
319
  var newDomain = domain;
365
320
  var fixedDomain = extent && extent.min != "" && extent.max != ""; //判断配置项中是否强制了最大最小值,如果已经被强制了,就不计算newDomain
366
-
367
321
  if (type !== "ordinal" && !isNaN(domain[1]) && !auto && !fixedDomain) {
368
322
  newDomain = getNewDomain(domain, mode, _step, extent, numericalRangeModel, percentageExtent);
369
323
  }
370
-
371
324
  var scaler = scales[type]().domain(newDomain).range(range);
372
325
  scaler.type = type;
373
326
  if (type !== "ordinal") scaler.clamp(true);
374
327
  var allTicks = ticks ? ticks : scaler.ticks ? scaler.ticks(tickCount) : scaler.domain();
375
328
  var _ticks = allTicks;
376
-
377
329
  if (type === "ordinal") {
378
330
  if (carousel === false || isC) {
379
331
  _ticks = (0, _utils.getTicksOfAxis)(_ticks, +tickCount, showLast);
@@ -384,7 +336,6 @@ var _default = function _default(_ref) {
384
336
  case "count":
385
337
  _ticks = (0, _utils2.getYTicks)(newDomain[1], newDomain[0], +tickCount);
386
338
  break;
387
-
388
339
  case "step":
389
340
  var newStep = +_step;
390
341
  newStep = (newDomain[1] - newDomain[0]) / newStep > 30 ? Math.ceil((newDomain[1] - newDomain[0]) / 30) : newStep;
@@ -393,12 +344,9 @@ var _default = function _default(_ref) {
393
344
  }
394
345
  }
395
346
  }
396
-
397
347
  var _lengthWithoutPaddingOuter = _length - _paddingOuter2;
398
-
399
348
  if (type == "linear" && config.on) {
400
349
  var zeroPosition = scaler(0);
401
-
402
350
  if (!isNaN(zeroPosition)) {
403
351
  if (_direction === "horizontal") {
404
352
  xAxisPositions.add(JSON.stringify({
@@ -413,33 +361,26 @@ var _default = function _default(_ref) {
413
361
  }
414
362
  }
415
363
  }
416
-
417
364
  var _step2 = _lengthWithoutPaddingOuter / allTicks.length;
418
-
419
365
  var controlCfg = {
420
366
  controlStep: 0,
421
367
  controlDragScaler: null
422
368
  };
423
-
424
369
  if (isC) {
425
370
  controlCfg.controlStep = _step2 / cPercent;
426
371
  controlCfg.controlDragScaler = scaler.copy().range([_start / cPercent, _end / cPercent]);
427
-
428
372
  var _getChartsConfig3 = getChartsConfig(orientation, cWidth, height, paddingOuter),
429
- start_ = _getChartsConfig3.start,
430
- end_ = _getChartsConfig3.end,
431
- direction_ = _getChartsConfig3.direction,
432
- outer = _getChartsConfig3._paddingOuter,
433
- len = _getChartsConfig3.length;
434
-
373
+ start_ = _getChartsConfig3.start,
374
+ end_ = _getChartsConfig3.end,
375
+ direction_ = _getChartsConfig3.direction,
376
+ outer = _getChartsConfig3._paddingOuter,
377
+ len = _getChartsConfig3.length;
435
378
  var _range = direction_ === "horizontal" ? [start_, end_] : direction_ === "vertical" ? [end_, start_] : [0, 0];
436
-
437
379
  scaler = scales[type]().domain(newDomain).range(_range);
438
380
  scaler.type = type;
439
381
  var controlOuter = len - outer;
440
382
  _step2 = controlOuter / allTicks.length;
441
383
  }
442
-
443
384
  tmp.set(axisType, _objectSpread(_objectSpread(_objectSpread({}, item), {}, {
444
385
  count: _count,
445
386
  isClipAxis: _isClipAxis,
@@ -464,8 +405,5 @@ var _default = function _default(_ref) {
464
405
  }));
465
406
  return tmp;
466
407
  }, [axes, controlInfo]);
467
-
468
408
  return _axes;
469
- };
470
-
471
- exports["default"] = _default;
409
+ };