@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.
- package/.husky/commit-msg +1 -1
- package/lib/components/AnimateData.js +8 -16
- package/lib/components/Axis.js +199 -191
- package/lib/components/Background.js +16 -24
- package/lib/components/Band.js +98 -91
- package/lib/components/BaseLine.js +39 -40
- package/lib/components/Brush.js +29 -46
- package/lib/components/Carousel.js +13 -40
- package/lib/components/CartesianChart.js +66 -86
- package/lib/components/Chart.js +23 -36
- package/lib/components/ChartContainer.js +18 -27
- package/lib/components/ConicalGradient.js +35 -68
- package/lib/components/ExtentData.js +9 -17
- package/lib/components/FilterData.js +16 -27
- package/lib/components/Indicator.js +6 -8
- package/lib/components/Label.js +120 -134
- package/lib/components/Legend.js +41 -66
- package/lib/components/Lighter.js +19 -48
- package/lib/components/Line.js +39 -59
- package/lib/components/LinearGradient.js +14 -20
- package/lib/components/Mapping.js +9 -34
- package/lib/components/Marquee.js +14 -30
- package/lib/components/PieChart.js +306 -400
- package/lib/components/StackData.js +8 -18
- package/lib/components/StereoBar.js +65 -105
- package/lib/components/TextOverflow.js +9 -22
- package/lib/components/Tooltip.js +41 -55
- package/lib/components/index.js +0 -27
- package/lib/context/index.js +0 -2
- 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 -8
- package/lib/hooks/useAnimateData.js +3 -16
- package/lib/hooks/useAxes.js +253 -114
- package/lib/hooks/useCarouselAxisX.js +26 -56
- package/lib/hooks/useExtentData.js +47 -44
- package/lib/hooks/useFilterData.js +8 -29
- package/lib/hooks/useStackData.js +7 -30
- package/lib/hooks/useTooltip.js +26 -43
- package/lib/index.js +0 -15
- package/lib/utils/index.js +95 -247
- package/package.json +55 -54
- package/src/components/Axis.tsx +246 -157
- package/src/components/Band.tsx +91 -56
- package/src/components/BaseLine.js +22 -5
- package/src/components/CartesianChart.js +1 -0
- package/src/components/Label.js +56 -46
- package/src/components/TextOverflow.tsx +1 -2
- package/src/hooks/useAxes.js +336 -117
- package/src/hooks/useExtentData.js +37 -10
package/.husky/commit-msg
CHANGED
|
@@ -1,36 +1,29 @@
|
|
|
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 _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
-
|
|
18
12
|
var _hooks = require("../hooks");
|
|
19
|
-
|
|
20
13
|
var _excluded = ["dataAnimation"],
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
_excluded2 = ["data", "config"];
|
|
15
|
+
/**
|
|
16
|
+
* 用来做图表数据改变(增长)动画(HOC)
|
|
17
|
+
*/
|
|
23
18
|
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); }
|
|
24
|
-
|
|
25
19
|
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; }
|
|
26
|
-
|
|
27
20
|
var _default = function _default(Component) {
|
|
28
21
|
return /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
29
22
|
var data = _ref.data,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
_ref$config = _ref.config,
|
|
24
|
+
dataAnimation = _ref$config.dataAnimation,
|
|
25
|
+
config = (0, _objectWithoutProperties2["default"])(_ref$config, _excluded),
|
|
26
|
+
rest = (0, _objectWithoutProperties2["default"])(_ref, _excluded2);
|
|
34
27
|
return /*#__PURE__*/_react["default"].createElement(Component, (0, _extends2["default"])({}, rest, {
|
|
35
28
|
config: config,
|
|
36
29
|
originData: data,
|
|
@@ -38,5 +31,4 @@ var _default = function _default(Component) {
|
|
|
38
31
|
}));
|
|
39
32
|
});
|
|
40
33
|
};
|
|
41
|
-
|
|
42
34
|
exports["default"] = _default;
|
package/lib/components/Axis.js
CHANGED
|
@@ -1,40 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof3 = 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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
11
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
17
|
-
|
|
18
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
-
|
|
20
13
|
var _utils = require("../utils");
|
|
21
|
-
|
|
22
14
|
var _context = require("../context");
|
|
23
|
-
|
|
24
15
|
var _element = require("../element");
|
|
25
|
-
|
|
26
16
|
var _TextOverflow = _interopRequireDefault(require("./TextOverflow"));
|
|
27
|
-
|
|
28
17
|
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); }
|
|
29
|
-
|
|
30
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(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; }
|
|
31
|
-
|
|
32
19
|
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; }
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
+
* x, y, z轴
|
|
22
|
+
*/
|
|
36
23
|
var defaultEvent = function defaultEvent() {};
|
|
37
|
-
|
|
38
24
|
var defaultAppearance = {
|
|
39
25
|
angle: 0,
|
|
40
26
|
count: 6,
|
|
@@ -43,29 +29,25 @@ var defaultAppearance = {
|
|
|
43
29
|
textOverflow: "ellipsis"
|
|
44
30
|
};
|
|
45
31
|
var defaultAlign = {
|
|
46
|
-
textAnchor:
|
|
47
|
-
dominantBaseline:
|
|
32
|
+
textAnchor: "middle",
|
|
33
|
+
dominantBaseline: "middle"
|
|
48
34
|
};
|
|
49
|
-
var defaultOrientation =
|
|
35
|
+
var defaultOrientation = "bottom";
|
|
50
36
|
var defaultTickSize = 6;
|
|
51
|
-
|
|
52
37
|
var defaultFormatter = function defaultFormatter(d, _ref) {
|
|
53
38
|
var suffix = _ref.suffix;
|
|
54
39
|
return d + suffix;
|
|
55
40
|
};
|
|
56
|
-
|
|
57
41
|
var getAxesPath = function getAxesPath(orientation, _ref2) {
|
|
58
42
|
var width = _ref2.width,
|
|
59
|
-
|
|
60
|
-
|
|
43
|
+
height = _ref2.height;
|
|
61
44
|
switch (orientation) {
|
|
62
|
-
case
|
|
63
|
-
case
|
|
64
|
-
return
|
|
65
|
-
|
|
66
|
-
case
|
|
67
|
-
|
|
68
|
-
return 'M0, -0.5V' + (height + 0.5);
|
|
45
|
+
case "top":
|
|
46
|
+
case "bottom":
|
|
47
|
+
return "M-0.5, 0H" + width;
|
|
48
|
+
case "left":
|
|
49
|
+
case "right":
|
|
50
|
+
return "M0, -0.5V" + (height + 0.5);
|
|
69
51
|
}
|
|
70
52
|
};
|
|
71
53
|
/**
|
|
@@ -78,32 +60,27 @@ var getAxesPath = function getAxesPath(orientation, _ref2) {
|
|
|
78
60
|
* directionY
|
|
79
61
|
* }
|
|
80
62
|
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
63
|
var getLayout = function getLayout(orientation, rotate) {
|
|
84
64
|
switch (orientation) {
|
|
85
|
-
case
|
|
65
|
+
case "top":
|
|
86
66
|
return {
|
|
87
67
|
transform: "translate(-50%,-100%) rotate(".concat(rotate, "deg)"),
|
|
88
68
|
directionX: 1,
|
|
89
69
|
directionY: -1
|
|
90
70
|
};
|
|
91
|
-
|
|
92
|
-
case 'bottom':
|
|
71
|
+
case "bottom":
|
|
93
72
|
return {
|
|
94
73
|
transform: "translate(-50%,0) rotate(".concat(rotate, "deg)"),
|
|
95
74
|
directionX: 1,
|
|
96
75
|
directionY: 1
|
|
97
76
|
};
|
|
98
|
-
|
|
99
|
-
case 'left':
|
|
77
|
+
case "left":
|
|
100
78
|
return {
|
|
101
79
|
transform: "translate(-100%,-50%) rotate(".concat(rotate, "deg)"),
|
|
102
80
|
directionX: -1,
|
|
103
81
|
directionY: 1
|
|
104
82
|
};
|
|
105
|
-
|
|
106
|
-
case 'right':
|
|
83
|
+
case "right":
|
|
107
84
|
return {
|
|
108
85
|
transform: "translate(0,-50%) rotate(".concat(rotate, "deg)"),
|
|
109
86
|
directionX: 1,
|
|
@@ -111,95 +88,104 @@ var getLayout = function getLayout(orientation, rotate) {
|
|
|
111
88
|
};
|
|
112
89
|
}
|
|
113
90
|
};
|
|
114
|
-
|
|
115
91
|
var AxisLine = function AxisLine(_ref3) {
|
|
116
92
|
var _ref3$orientation = _ref3.orientation,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
93
|
+
orientation = _ref3$orientation === void 0 ? defaultOrientation : _ref3$orientation,
|
|
94
|
+
_ref3$config = _ref3.config,
|
|
95
|
+
show = _ref3$config.show,
|
|
96
|
+
color = _ref3$config.color,
|
|
97
|
+
lineWidth = _ref3$config.lineWidth,
|
|
98
|
+
_ref3$isClipAxis = _ref3.isClipAxis,
|
|
99
|
+
isClipAxis = _ref3$isClipAxis === void 0 ? false : _ref3$isClipAxis,
|
|
100
|
+
_ref3$clipAxisRange = _ref3.clipAxisRange,
|
|
101
|
+
clipAxisRange = _ref3$clipAxisRange === void 0 ? [] : _ref3$clipAxisRange;
|
|
122
102
|
if (!show) return null;
|
|
123
103
|
var context = (0, _react.useContext)(_context.chartContext);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
104
|
+
var width = context.width,
|
|
105
|
+
height = context.height;
|
|
106
|
+
if (isClipAxis) {
|
|
107
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, clipAxisRange.map(function (range, index) {
|
|
108
|
+
return /*#__PURE__*/_react["default"].createElement("path", {
|
|
109
|
+
key: index,
|
|
110
|
+
d: "M 0.5,".concat(range[0], " L 0.5,").concat(range[1]),
|
|
111
|
+
stroke: color,
|
|
112
|
+
strokeWidth: lineWidth
|
|
113
|
+
});
|
|
114
|
+
}));
|
|
115
|
+
} else {
|
|
116
|
+
return /*#__PURE__*/_react["default"].createElement("path", {
|
|
117
|
+
d: getAxesPath(orientation, context),
|
|
118
|
+
stroke: color,
|
|
119
|
+
strokeWidth: lineWidth
|
|
120
|
+
});
|
|
121
|
+
}
|
|
129
122
|
};
|
|
130
|
-
|
|
131
123
|
var Unit = function Unit(_ref4) {
|
|
132
124
|
var _ref4$config = _ref4.config,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
125
|
+
show = _ref4$config.show,
|
|
126
|
+
text = _ref4$config.text,
|
|
127
|
+
_ref4$config$font = _ref4$config.font,
|
|
128
|
+
bold = _ref4$config$font.bold,
|
|
129
|
+
color = _ref4$config$font.color,
|
|
130
|
+
fontFamily = _ref4$config$font.fontFamily,
|
|
131
|
+
fontSize = _ref4$config$font.fontSize,
|
|
132
|
+
italic = _ref4$config$font.italic,
|
|
133
|
+
letterSpacing = _ref4$config$font.letterSpacing,
|
|
134
|
+
_ref4$config$translat = _ref4$config.translate,
|
|
135
|
+
translateX = _ref4$config$translat.x,
|
|
136
|
+
translateY = _ref4$config$translat.y,
|
|
137
|
+
_ref4$config$align = _ref4$config.align,
|
|
138
|
+
_ref4$config$align2 = _ref4$config$align === void 0 ? defaultAlign : _ref4$config$align,
|
|
139
|
+
textAnchor = _ref4$config$align2.textAnchor;
|
|
148
140
|
if (!show) return null;
|
|
149
141
|
return /*#__PURE__*/_react["default"].createElement("text", {
|
|
150
142
|
className: "__easyv-unit",
|
|
151
|
-
transform:
|
|
143
|
+
transform: "translate(" + translateX + ", " + translateY + ")",
|
|
152
144
|
fontFamily: fontFamily,
|
|
153
145
|
fontSize: fontSize,
|
|
154
146
|
fill: color,
|
|
155
|
-
fontWeight: bold ?
|
|
156
|
-
fontStyle: italic ?
|
|
147
|
+
fontWeight: bold ? "bold" : "normal",
|
|
148
|
+
fontStyle: italic ? "italic" : "normal",
|
|
157
149
|
letterSpacing: letterSpacing,
|
|
158
150
|
textAnchor: textAnchor
|
|
159
151
|
}, text);
|
|
160
152
|
};
|
|
161
|
-
|
|
162
153
|
var Label = function Label(_ref5) {
|
|
163
154
|
var className = _ref5.className,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
155
|
+
_ref5$orientation = _ref5.orientation,
|
|
156
|
+
orientation = _ref5$orientation === void 0 ? defaultOrientation : _ref5$orientation,
|
|
157
|
+
label = _ref5.label,
|
|
158
|
+
coordinate = _ref5.coordinate,
|
|
159
|
+
_ref5$formatter = _ref5.formatter,
|
|
160
|
+
formatter = _ref5$formatter === void 0 ? defaultFormatter : _ref5$formatter,
|
|
161
|
+
tickSize = _ref5.tickSize,
|
|
162
|
+
_ref5$rotate = _ref5.rotate,
|
|
163
|
+
rotate = _ref5$rotate === void 0 ? 0 : _ref5$rotate,
|
|
164
|
+
config = _ref5.config,
|
|
165
|
+
_ref5$onClick = _ref5.onClick,
|
|
166
|
+
onClick = _ref5$onClick === void 0 ? defaultEvent : _ref5$onClick,
|
|
167
|
+
_ref5$config = _ref5.config,
|
|
168
|
+
show = _ref5$config.show,
|
|
169
|
+
style = _ref5$config.style,
|
|
170
|
+
_ref5$config$translat = _ref5$config.translate,
|
|
171
|
+
translateX = _ref5$config$translat.x,
|
|
172
|
+
translateY = _ref5$config$translat.y,
|
|
173
|
+
font = _ref5$config.font,
|
|
174
|
+
_ref5$config$appearan = _ref5$config.appearance,
|
|
175
|
+
_ref5$config$appearan2 = _ref5$config$appearan === void 0 ? defaultAppearance : _ref5$config$appearan,
|
|
176
|
+
width = _ref5$config$appearan2.width,
|
|
177
|
+
speed = _ref5$config$appearan2.speed,
|
|
178
|
+
textOverflow = _ref5$config$appearan2.textOverflow;
|
|
188
179
|
if (!show) return null;
|
|
189
|
-
|
|
190
180
|
var _label = formatter(label, config);
|
|
191
|
-
|
|
192
181
|
var _getLayout = getLayout(orientation, rotate),
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
var isVertical = orientation == 'left' || orientation == 'right';
|
|
182
|
+
transform = _getLayout.transform,
|
|
183
|
+
directionX = _getLayout.directionX,
|
|
184
|
+
directionY = _getLayout.directionY;
|
|
185
|
+
var isVertical = orientation == "left" || orientation == "right";
|
|
198
186
|
var x = (isVertical ? tickSize * directionX : coordinate) + translateX * directionX;
|
|
199
187
|
var y = (isVertical ? coordinate : tickSize * directionY) + translateY * directionY;
|
|
200
|
-
|
|
201
|
-
var _style = style && ((0, _typeof2["default"])(style) == 'object' ? style : style(_label));
|
|
202
|
-
|
|
188
|
+
var _style = style && ((0, _typeof2["default"])(style) == "object" ? style : style(_label));
|
|
203
189
|
return /*#__PURE__*/_react["default"].createElement("foreignObject", {
|
|
204
190
|
width: "1",
|
|
205
191
|
height: "1",
|
|
@@ -227,53 +213,125 @@ var Label = function Label(_ref5) {
|
|
|
227
213
|
}
|
|
228
214
|
})));
|
|
229
215
|
};
|
|
230
|
-
|
|
231
216
|
var _default = /*#__PURE__*/(0, _react.memo)(function (_ref6) {
|
|
232
217
|
var orientation = _ref6.orientation,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
218
|
+
scaler = _ref6.scaler,
|
|
219
|
+
_ref6$tickSize = _ref6.tickSize,
|
|
220
|
+
tickSize = _ref6$tickSize === void 0 ? defaultTickSize : _ref6$tickSize,
|
|
221
|
+
ticks = _ref6.ticks,
|
|
222
|
+
formatter = _ref6.formatter,
|
|
223
|
+
rotate = _ref6.rotate,
|
|
224
|
+
triggerClick = _ref6.triggerClick,
|
|
225
|
+
_ref6$config = _ref6.config,
|
|
226
|
+
on = _ref6$config.on,
|
|
227
|
+
label = _ref6$config.label,
|
|
228
|
+
axisLine = _ref6$config.axisLine,
|
|
229
|
+
tickLine = _ref6$config.tickLine,
|
|
230
|
+
gridLine = _ref6$config.gridLine,
|
|
231
|
+
unit = _ref6$config.unit,
|
|
232
|
+
config = _ref6.config,
|
|
233
|
+
positions = _ref6.positions,
|
|
234
|
+
xLineRange = _ref6.xLineRange,
|
|
235
|
+
_ref6$isClipAxis = _ref6.isClipAxis,
|
|
236
|
+
isClipAxis = _ref6$isClipAxis === void 0 ? false : _ref6$isClipAxis,
|
|
237
|
+
yLineRange = _ref6.yLineRange,
|
|
238
|
+
clipAxisRange = _ref6.clipAxisRange;
|
|
250
239
|
if (!(on && ticks.length > 0)) return null;
|
|
251
|
-
|
|
252
240
|
var _useContext = (0, _react.useContext)(_context.chartContext),
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
var
|
|
257
|
-
|
|
258
|
-
|
|
241
|
+
width = _useContext.width,
|
|
242
|
+
height = _useContext.height;
|
|
243
|
+
var x = orientation == "right" ? width : 0;
|
|
244
|
+
var y = orientation == "bottom" ? height : 0;
|
|
245
|
+
function drawYAxisTickLine() {
|
|
246
|
+
var draw = function draw(ticks, scaler) {
|
|
247
|
+
return ticks.map(function (tick, index) {
|
|
248
|
+
var coordinate = scaler(tick);
|
|
249
|
+
if (isNaN(coordinate)) return null;
|
|
250
|
+
var _tickSize = tickLine.tickSize || tickSize;
|
|
251
|
+
var gridCoord = (0, _utils.getGridCoord)({
|
|
252
|
+
orientation: orientation,
|
|
253
|
+
coordinate: coordinate,
|
|
254
|
+
end: orientation == "left" || orientation == "right" ? width : height
|
|
255
|
+
});
|
|
256
|
+
var x1 = gridCoord.x1;
|
|
257
|
+
var y1 = gridCoord.y1;
|
|
258
|
+
return !(orientation == "bottom" && (x1 < 0 || x1 > xLineRange) || y1 < 0 || y1 > yLineRange) && /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
|
|
259
|
+
className: "__easyv-tickLine",
|
|
260
|
+
key: index,
|
|
261
|
+
config: tickLine
|
|
262
|
+
}, (0, _utils.getTickCoord)({
|
|
263
|
+
orientation: orientation,
|
|
264
|
+
coordinate: coordinate,
|
|
265
|
+
tickSize: _tickSize
|
|
266
|
+
})));
|
|
267
|
+
});
|
|
268
|
+
};
|
|
269
|
+
if (isClipAxis) {
|
|
270
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, ticks.map(function (ticks, index) {
|
|
271
|
+
return draw(ticks, scaler[index]);
|
|
272
|
+
}));
|
|
273
|
+
} else {
|
|
274
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, draw(ticks, scaler));
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function drawLabel() {
|
|
278
|
+
var draw = function draw(ticks, scaler) {
|
|
279
|
+
return ticks.map(function (tick, index) {
|
|
280
|
+
var coordinate = scaler(tick);
|
|
281
|
+
if (isNaN(coordinate)) return null;
|
|
282
|
+
var _tickSize = tickLine.tickSize || tickSize;
|
|
283
|
+
var gridCoord = (0, _utils.getGridCoord)({
|
|
284
|
+
orientation: orientation,
|
|
285
|
+
coordinate: coordinate,
|
|
286
|
+
end: orientation == 'left' || orientation == 'right' ? width : height
|
|
287
|
+
});
|
|
288
|
+
var x1 = gridCoord.x1;
|
|
289
|
+
var y1 = gridCoord.y1;
|
|
290
|
+
return !(orientation == "bottom" && (x1 < 0 || x1 > xLineRange) || y1 < 0 || y1 > yLineRange) && /*#__PURE__*/_react["default"].createElement("g", {
|
|
291
|
+
key: index
|
|
292
|
+
}, label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
293
|
+
className: "__easyv-label",
|
|
294
|
+
orientation: orientation,
|
|
295
|
+
coordinate: coordinate,
|
|
296
|
+
config: label,
|
|
297
|
+
label: tick,
|
|
298
|
+
tickSize: _tickSize,
|
|
299
|
+
formatter: formatter,
|
|
300
|
+
rotate: rotate,
|
|
301
|
+
onClick: triggerClick
|
|
302
|
+
}), gridLine && /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
|
|
303
|
+
className: "__easyv-gridLine",
|
|
304
|
+
config: gridLine
|
|
305
|
+
}, gridCoord)));
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
if (isClipAxis) {
|
|
309
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, ticks.map(function (ticks, index) {
|
|
310
|
+
return draw(ticks, scaler[index]);
|
|
311
|
+
}));
|
|
312
|
+
} else {
|
|
313
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, draw(ticks, scaler));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, axisLine && tickLine && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, axisLine && (
|
|
317
|
+
// 依据positions来区分x轴y轴,有position为x轴
|
|
318
|
+
positions && positions.length ? positions.map(function (_ref7, index) {
|
|
259
319
|
var x = _ref7.x,
|
|
260
|
-
|
|
320
|
+
y = _ref7.y;
|
|
261
321
|
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
262
322
|
key: index,
|
|
263
|
-
transform:
|
|
323
|
+
transform: "translate(" + x + ", " + y + ")"
|
|
264
324
|
}, /*#__PURE__*/_react["default"].createElement(AxisLine, {
|
|
265
325
|
orientation: orientation,
|
|
266
326
|
config: axisLine
|
|
267
327
|
}), tickLine && ticks.map(function (tick, index) {
|
|
268
328
|
var coordinate = scaler(tick);
|
|
269
329
|
if (isNaN(coordinate)) return null;
|
|
270
|
-
|
|
271
330
|
var _tickSize = tickLine.tickSize || tickSize;
|
|
272
|
-
|
|
273
331
|
var gridCoord = (0, _utils.getGridCoord)({
|
|
274
332
|
orientation: orientation,
|
|
275
333
|
coordinate: coordinate,
|
|
276
|
-
end: orientation ==
|
|
334
|
+
end: orientation == "left" || orientation == "right" ? width : height
|
|
277
335
|
});
|
|
278
336
|
var x1 = gridCoord.x1;
|
|
279
337
|
var y1 = gridCoord.y1;
|
|
@@ -288,66 +346,16 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref6) {
|
|
|
288
346
|
})));
|
|
289
347
|
}));
|
|
290
348
|
}) : /*#__PURE__*/_react["default"].createElement("g", {
|
|
291
|
-
transform:
|
|
349
|
+
transform: "translate(" + x + ", " + y + ")"
|
|
292
350
|
}, /*#__PURE__*/_react["default"].createElement(AxisLine, {
|
|
293
351
|
orientation: orientation,
|
|
294
|
-
config: axisLine
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
var _tickSize = tickLine.tickSize || tickSize;
|
|
300
|
-
|
|
301
|
-
var gridCoord = (0, _utils.getGridCoord)({
|
|
302
|
-
orientation: orientation,
|
|
303
|
-
coordinate: coordinate,
|
|
304
|
-
end: orientation == 'left' || orientation == 'right' ? width : height
|
|
305
|
-
});
|
|
306
|
-
var x1 = gridCoord.x1;
|
|
307
|
-
var y1 = gridCoord.y1;
|
|
308
|
-
return !(orientation == "bottom" && (x1 < 0 || x1 > xLineRange) || y1 < 0 || y1 > yLineRange) && /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
|
|
309
|
-
className: "__easyv-tickLine",
|
|
310
|
-
key: index,
|
|
311
|
-
config: tickLine
|
|
312
|
-
}, (0, _utils.getTickCoord)({
|
|
313
|
-
orientation: orientation,
|
|
314
|
-
coordinate: coordinate,
|
|
315
|
-
tickSize: _tickSize
|
|
316
|
-
})));
|
|
317
|
-
})))), /*#__PURE__*/_react["default"].createElement("g", {
|
|
352
|
+
config: axisLine,
|
|
353
|
+
isClipAxis: isClipAxis,
|
|
354
|
+
clipAxisRange: clipAxisRange
|
|
355
|
+
}), tickLine && drawYAxisTickLine()))), /*#__PURE__*/_react["default"].createElement("g", {
|
|
318
356
|
transform: 'translate(' + x + ', ' + y + ')'
|
|
319
|
-
}, label && gridLine &&
|
|
320
|
-
var coordinate = scaler(tick);
|
|
321
|
-
if (isNaN(coordinate)) return null;
|
|
322
|
-
|
|
323
|
-
var _tickSize = tickLine.tickSize || tickSize;
|
|
324
|
-
|
|
325
|
-
var gridCoord = (0, _utils.getGridCoord)({
|
|
326
|
-
orientation: orientation,
|
|
327
|
-
coordinate: coordinate,
|
|
328
|
-
end: orientation == 'left' || orientation == 'right' ? width : height
|
|
329
|
-
});
|
|
330
|
-
var x1 = gridCoord.x1;
|
|
331
|
-
var y1 = gridCoord.y1;
|
|
332
|
-
return !(orientation == "bottom" && (x1 < 0 || x1 > xLineRange) || y1 < 0 || y1 > yLineRange) && /*#__PURE__*/_react["default"].createElement("g", {
|
|
333
|
-
key: index
|
|
334
|
-
}, label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
335
|
-
className: "__easyv-label",
|
|
336
|
-
orientation: orientation,
|
|
337
|
-
coordinate: coordinate,
|
|
338
|
-
config: label,
|
|
339
|
-
label: tick,
|
|
340
|
-
tickSize: _tickSize,
|
|
341
|
-
formatter: formatter,
|
|
342
|
-
rotate: rotate,
|
|
343
|
-
onClick: triggerClick
|
|
344
|
-
}), gridLine && /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
|
|
345
|
-
className: "__easyv-gridLine",
|
|
346
|
-
config: gridLine
|
|
347
|
-
}, gridCoord)));
|
|
348
|
-
}), unit && /*#__PURE__*/_react["default"].createElement(Unit, {
|
|
357
|
+
}, label && gridLine && drawLabel(), unit && /*#__PURE__*/_react["default"].createElement(Unit, {
|
|
349
358
|
config: unit
|
|
350
359
|
})));
|
|
351
360
|
});
|
|
352
|
-
|
|
353
361
|
exports["default"] = _default;
|
|
@@ -1,43 +1,36 @@
|
|
|
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 _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
10
|
var _utils = require("../utils");
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* 轴类图背景
|
|
18
13
|
*/
|
|
19
14
|
var _default = function _default(_ref) {
|
|
20
15
|
var _ref$axis = _ref.axis,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
ticks = _ref$axis.ticks,
|
|
17
|
+
scaler = _ref$axis.scaler,
|
|
18
|
+
step = _ref$axis.step,
|
|
19
|
+
direction = _ref$axis.direction,
|
|
20
|
+
bandLength = _ref.bandLength,
|
|
21
|
+
_ref$config = _ref.config,
|
|
22
|
+
background = _ref$config.background,
|
|
23
|
+
paddingInner = _ref$config.seriesIntervalWidth,
|
|
24
|
+
paddingOuter = _ref$config.paddingInner,
|
|
25
|
+
length = _ref.length;
|
|
31
26
|
var isVertical = direction === 'vertical';
|
|
32
|
-
|
|
33
27
|
var _getSeriesInfo = (0, _utils.getSeriesInfo)({
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
step: step,
|
|
29
|
+
bandLength: bandLength,
|
|
30
|
+
paddingInner: paddingInner,
|
|
31
|
+
paddingOuter: paddingOuter
|
|
32
|
+
}),
|
|
33
|
+
bandwidth = _getSeriesInfo.width;
|
|
41
34
|
var size = isVertical ? {
|
|
42
35
|
width: length,
|
|
43
36
|
height: bandwidth
|
|
@@ -56,5 +49,4 @@ var _default = function _default(_ref) {
|
|
|
56
49
|
}));
|
|
57
50
|
});
|
|
58
51
|
};
|
|
59
|
-
|
|
60
52
|
exports["default"] = _default;
|