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