@easyv/charts 1.2.1 → 1.2.2
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/commitlint.config.js +1 -1
- package/lib/components/AnimateData.js +34 -34
- package/lib/components/Axis.js +319 -319
- package/lib/components/Band.js +173 -173
- package/lib/components/Brush.js +201 -201
- package/lib/components/Carousel.js +162 -162
- package/lib/components/Chart.js +109 -109
- package/lib/components/ChartContainer.js +58 -58
- package/lib/components/ConicalGradient.js +243 -243
- package/lib/components/ExtentData.js +45 -45
- package/lib/components/FilterData.js +53 -53
- package/lib/components/Label.js +278 -278
- package/lib/components/Legend.js +154 -154
- package/lib/components/Line.js +181 -181
- package/lib/components/Mapping.js +127 -127
- package/lib/components/Marquee.js +97 -0
- package/lib/components/PieChart.js +1069 -1061
- package/lib/components/StackData.js +45 -45
- package/lib/components/StereoBar.js +336 -336
- package/lib/components/Tooltip.js +155 -155
- package/lib/components/index.js +194 -194
- package/lib/formatter/legend.js +91 -91
- package/lib/hooks/index.js +62 -62
- package/lib/hooks/useAnimateData.js +83 -83
- package/lib/hooks/useAxes.js +130 -130
- package/lib/hooks/useCarouselAxisX.js +179 -179
- package/lib/hooks/useExtentData.js +122 -122
- package/lib/hooks/useFilterData.js +107 -107
- package/lib/hooks/useStackData.js +129 -129
- package/lib/index.js +84 -84
- package/lib/utils/index.js +832 -832
- package/package.json +3 -3
- package/src/components/PieChart.js +468 -277
package/lib/components/Axis.js
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports["default"] = void 0;
|
|
11
|
-
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
17
|
-
|
|
18
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
-
|
|
20
|
-
var _utils = require("../utils");
|
|
21
|
-
|
|
22
|
-
var _context = require("../context");
|
|
23
|
-
|
|
24
|
-
var _element = require("../element");
|
|
25
|
-
|
|
26
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
-
|
|
28
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
29
|
-
|
|
30
|
-
var defaultEvent = function defaultEvent() {};
|
|
31
|
-
|
|
32
|
-
var defaultAlign = {
|
|
33
|
-
textAnchor: 'middle',
|
|
34
|
-
dominantBaseline: 'middle'
|
|
35
|
-
};
|
|
36
|
-
var defaultOrientation = 'bottom';
|
|
37
|
-
var defaultTickSize = 6;
|
|
38
|
-
|
|
39
|
-
var defaultFormatter = function defaultFormatter(d, _ref) {
|
|
40
|
-
var suffix = _ref.suffix;
|
|
41
|
-
return d + suffix;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
var getAxesPath = function getAxesPath(orientation, _ref2) {
|
|
45
|
-
var width = _ref2.width,
|
|
46
|
-
height = _ref2.height;
|
|
47
|
-
|
|
48
|
-
switch (orientation) {
|
|
49
|
-
case 'top':
|
|
50
|
-
case 'bottom':
|
|
51
|
-
return 'M-0.5, 0H' + width;
|
|
52
|
-
|
|
53
|
-
case 'left':
|
|
54
|
-
case 'right':
|
|
55
|
-
return 'M0, -0.5V' + (height + 0.5);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = void 0;
|
|
11
|
+
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
+
|
|
16
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
17
|
+
|
|
18
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
+
|
|
20
|
+
var _utils = require("../utils");
|
|
21
|
+
|
|
22
|
+
var _context = require("../context");
|
|
23
|
+
|
|
24
|
+
var _element = require("../element");
|
|
25
|
+
|
|
26
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
+
|
|
28
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
29
|
+
|
|
30
|
+
var defaultEvent = function defaultEvent() {};
|
|
31
|
+
|
|
32
|
+
var defaultAlign = {
|
|
33
|
+
textAnchor: 'middle',
|
|
34
|
+
dominantBaseline: 'middle'
|
|
35
|
+
};
|
|
36
|
+
var defaultOrientation = 'bottom';
|
|
37
|
+
var defaultTickSize = 6;
|
|
38
|
+
|
|
39
|
+
var defaultFormatter = function defaultFormatter(d, _ref) {
|
|
40
|
+
var suffix = _ref.suffix;
|
|
41
|
+
return d + suffix;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
var getAxesPath = function getAxesPath(orientation, _ref2) {
|
|
45
|
+
var width = _ref2.width,
|
|
46
|
+
height = _ref2.height;
|
|
47
|
+
|
|
48
|
+
switch (orientation) {
|
|
49
|
+
case 'top':
|
|
50
|
+
case 'bottom':
|
|
51
|
+
return 'M-0.5, 0H' + width;
|
|
52
|
+
|
|
53
|
+
case 'left':
|
|
54
|
+
case 'right':
|
|
55
|
+
return 'M0, -0.5V' + (height + 0.5);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
58
|
/**
|
|
59
59
|
* 根据坐标轴位置来确定轴标签的垂直对齐方式,水平对齐方式,以及轴标签位于坐标轴的哪个方向
|
|
60
60
|
* @param orientation 坐标轴位置
|
|
@@ -65,266 +65,266 @@ var getAxesPath = function getAxesPath(orientation, _ref2) {
|
|
|
65
65
|
* directionX,
|
|
66
66
|
* directionY
|
|
67
67
|
* }
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
var getLayout = function getLayout(orientation, rotate) {
|
|
72
|
-
switch (orientation) {
|
|
73
|
-
case 'top':
|
|
74
|
-
return {
|
|
75
|
-
dominantBaseline: 'text-after-edge',
|
|
76
|
-
textAnchor: rotate ? 'end' : 'middle',
|
|
77
|
-
directionX: 1,
|
|
78
|
-
directionY: -1
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
case 'bottom':
|
|
82
|
-
return {
|
|
83
|
-
dominantBaseline: 'text-before-edge',
|
|
84
|
-
textAnchor: rotate ? 'start' : 'middle',
|
|
85
|
-
directionX: 1,
|
|
86
|
-
directionY: 1
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
case 'left':
|
|
90
|
-
return {
|
|
91
|
-
dominantBaseline: 'middle',
|
|
92
|
-
textAnchor: 'end',
|
|
93
|
-
directionX: -1,
|
|
94
|
-
directionY: 1
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
case 'right':
|
|
98
|
-
return {
|
|
99
|
-
dominantBaseline: 'middle',
|
|
100
|
-
textAnchor: 'start',
|
|
101
|
-
directionX: 1,
|
|
102
|
-
directionY: 1
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
var AxisLine = function AxisLine(_ref3) {
|
|
108
|
-
var _ref3$orientation = _ref3.orientation,
|
|
109
|
-
orientation = _ref3$orientation === void 0 ? defaultOrientation : _ref3$orientation,
|
|
110
|
-
_ref3$config = _ref3.config,
|
|
111
|
-
show = _ref3$config.show,
|
|
112
|
-
color = _ref3$config.color,
|
|
113
|
-
lineWidth = _ref3$config.lineWidth;
|
|
114
|
-
if (!show) return null;
|
|
115
|
-
var context = (0, _react.useContext)(_context.chartContext);
|
|
116
|
-
return /*#__PURE__*/_react["default"].createElement("path", {
|
|
117
|
-
d: getAxesPath(orientation, context),
|
|
118
|
-
stroke: color,
|
|
119
|
-
strokeWidth: lineWidth
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
var Unit = function Unit(_ref4) {
|
|
124
|
-
var _ref4$config = _ref4.config,
|
|
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$align = _ref4$config$align === void 0 ? defaultAlign : _ref4$config$align;
|
|
139
|
-
var textAnchor = _ref4$config$align.textAnchor;
|
|
140
|
-
if (!show) return null;
|
|
141
|
-
return /*#__PURE__*/_react["default"].createElement("text", {
|
|
142
|
-
className: "__easyv-unit",
|
|
143
|
-
transform: 'translate(' + translateX + ', ' + translateY + ')',
|
|
144
|
-
fontFamily: fontFamily,
|
|
145
|
-
fontSize: fontSize,
|
|
146
|
-
fill: color,
|
|
147
|
-
fontWeight: bold ? 'bold' : 'normal',
|
|
148
|
-
fontStyle: italic ? 'italic' : 'normal',
|
|
149
|
-
letterSpacing: letterSpacing,
|
|
150
|
-
textAnchor: textAnchor
|
|
151
|
-
}, text);
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
var Label = function Label(_ref5) {
|
|
155
|
-
var className = _ref5.className,
|
|
156
|
-
_ref5$orientation = _ref5.orientation,
|
|
157
|
-
orientation = _ref5$orientation === void 0 ? defaultOrientation : _ref5$orientation,
|
|
158
|
-
label = _ref5.label,
|
|
159
|
-
coordinate = _ref5.coordinate,
|
|
160
|
-
_ref5$formatter = _ref5.formatter,
|
|
161
|
-
formatter = _ref5$formatter === void 0 ? defaultFormatter : _ref5$formatter,
|
|
162
|
-
tickSize = _ref5.tickSize,
|
|
163
|
-
_ref5$rotate = _ref5.rotate,
|
|
164
|
-
rotate = _ref5$rotate === void 0 ? 0 : _ref5$rotate,
|
|
165
|
-
config = _ref5.config,
|
|
166
|
-
_ref5$onClick = _ref5.onClick,
|
|
167
|
-
onClick = _ref5$onClick === void 0 ? defaultEvent : _ref5$onClick,
|
|
168
|
-
_ref5$config = _ref5.config,
|
|
169
|
-
show = _ref5$config.show,
|
|
170
|
-
style = _ref5$config.style,
|
|
171
|
-
_ref5$config$translat = _ref5$config.translate,
|
|
172
|
-
translateX = _ref5$config$translat.x,
|
|
173
|
-
translateY = _ref5$config$translat.y,
|
|
174
|
-
_ref5$config$font = _ref5$config.font,
|
|
175
|
-
fontFamily = _ref5$config$font.fontFamily,
|
|
176
|
-
fontSize = _ref5$config$font.fontSize,
|
|
177
|
-
color = _ref5$config$font.color,
|
|
178
|
-
bold = _ref5$config$font.bold,
|
|
179
|
-
italic = _ref5$config$font.italic,
|
|
180
|
-
letterSpacing = _ref5$config$font.letterSpacing;
|
|
181
|
-
if (!show) return null;
|
|
182
|
-
|
|
183
|
-
var _label = formatter(label, config);
|
|
184
|
-
|
|
185
|
-
var _getLayout = getLayout(orientation, rotate),
|
|
186
|
-
dominantBaseline = _getLayout.dominantBaseline,
|
|
187
|
-
textAnchor = _getLayout.textAnchor,
|
|
188
|
-
directionX = _getLayout.directionX,
|
|
189
|
-
directionY = _getLayout.directionY;
|
|
190
|
-
|
|
191
|
-
var isVertical = orientation == 'left' || orientation == 'right';
|
|
192
|
-
var x = (isVertical ? tickSize * directionX : coordinate) + translateX * directionX;
|
|
193
|
-
var y = (isVertical ? coordinate : tickSize * directionY) + translateY * directionY;
|
|
194
|
-
var translateText = 'translate(' + x + ', ' + y + ')';
|
|
195
|
-
|
|
196
|
-
var _style = style && ((0, _typeof2["default"])(style) == 'object' ? style : style(_label));
|
|
197
|
-
|
|
198
|
-
return /*#__PURE__*/_react["default"].createElement("text", {
|
|
199
|
-
className: className,
|
|
200
|
-
style: _objectSpread(_objectSpread({}, _style), {}, {
|
|
201
|
-
whiteSpace: 'pre'
|
|
202
|
-
}),
|
|
203
|
-
onClick: onClick,
|
|
204
|
-
"data-data": JSON.stringify({
|
|
205
|
-
x: label
|
|
206
|
-
}),
|
|
207
|
-
dominantBaseline: dominantBaseline,
|
|
208
|
-
textAnchor: textAnchor,
|
|
209
|
-
fontFamily: fontFamily,
|
|
210
|
-
fontSize: fontSize,
|
|
211
|
-
fill: color,
|
|
212
|
-
fontWeight: bold ? 'bold' : 'normal',
|
|
213
|
-
fontStyle: italic ? 'italic' : 'normal',
|
|
214
|
-
letterSpacing: letterSpacing,
|
|
215
|
-
dx: "0",
|
|
216
|
-
dy: "0",
|
|
217
|
-
transform: Array.isArray(_label) ? rotate !== 0 ? isVertical ? translateText + 'rotate(' + rotate + ')' : 'rotate(' + rotate + ', ' + x + ', ' + y + ')' : isVertical ? translateText : 'translate(' + translateX + ', ' + translateY + ')' : translateText + 'rotate(' + rotate + ')'
|
|
218
|
-
}, !!Array.isArray(_label) ? _label.map(function (item, index) {
|
|
219
|
-
return /*#__PURE__*/_react["default"].createElement("tspan", {
|
|
220
|
-
key: index,
|
|
221
|
-
x: x,
|
|
222
|
-
dy: "1em"
|
|
223
|
-
}, item);
|
|
224
|
-
}) : _label);
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
var _default = /*#__PURE__*/(0, _react.memo)(function (_ref6) {
|
|
228
|
-
var orientation = _ref6.orientation,
|
|
229
|
-
scaler = _ref6.scaler,
|
|
230
|
-
_ref6$tickSize = _ref6.tickSize,
|
|
231
|
-
tickSize = _ref6$tickSize === void 0 ? defaultTickSize : _ref6$tickSize,
|
|
232
|
-
ticks = _ref6.ticks,
|
|
233
|
-
formatter = _ref6.formatter,
|
|
234
|
-
rotate = _ref6.rotate,
|
|
235
|
-
triggerClick = _ref6.triggerClick,
|
|
236
|
-
_ref6$config = _ref6.config,
|
|
237
|
-
on = _ref6$config.on,
|
|
238
|
-
label = _ref6$config.label,
|
|
239
|
-
axisLine = _ref6$config.axisLine,
|
|
240
|
-
tickLine = _ref6$config.tickLine,
|
|
241
|
-
gridLine = _ref6$config.gridLine,
|
|
242
|
-
unit = _ref6$config.unit,
|
|
243
|
-
positions = _ref6.positions;
|
|
244
|
-
if (!(on && ticks.length > 0)) return null;
|
|
245
|
-
|
|
246
|
-
var _useContext = (0, _react.useContext)(_context.chartContext),
|
|
247
|
-
width = _useContext.width,
|
|
248
|
-
height = _useContext.height;
|
|
249
|
-
|
|
250
|
-
var x = orientation == 'right' ? width : 0;
|
|
251
|
-
var y = orientation == 'bottom' ? height : 0;
|
|
252
|
-
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, axisLine && tickLine && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, axisLine && (positions && positions.length ? positions.map(function (_ref7, index) {
|
|
253
|
-
var x = _ref7.x,
|
|
254
|
-
y = _ref7.y;
|
|
255
|
-
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
256
|
-
key: index,
|
|
257
|
-
transform: 'translate(' + x + ', ' + y + ')'
|
|
258
|
-
}, /*#__PURE__*/_react["default"].createElement(AxisLine, {
|
|
259
|
-
orientation: orientation,
|
|
260
|
-
config: axisLine
|
|
261
|
-
}), tickLine && ticks.map(function (tick, index) {
|
|
262
|
-
var coordinate = scaler(tick);
|
|
263
|
-
if (isNaN(coordinate)) return null;
|
|
264
|
-
|
|
265
|
-
var _tickSize = tickLine.tickSize || tickSize;
|
|
266
|
-
|
|
267
|
-
return /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
|
|
268
|
-
className: "__easyv-tickLine",
|
|
269
|
-
key: index,
|
|
270
|
-
config: tickLine
|
|
271
|
-
}, (0, _utils.getTickCoord)({
|
|
272
|
-
orientation: orientation,
|
|
273
|
-
coordinate: coordinate,
|
|
274
|
-
tickSize: _tickSize
|
|
275
|
-
})));
|
|
276
|
-
}));
|
|
277
|
-
}) : /*#__PURE__*/_react["default"].createElement("g", {
|
|
278
|
-
transform: 'translate(' + x + ', ' + y + ')'
|
|
279
|
-
}, /*#__PURE__*/_react["default"].createElement(AxisLine, {
|
|
280
|
-
orientation: orientation,
|
|
281
|
-
config: axisLine
|
|
282
|
-
}), tickLine && ticks.map(function (tick, index) {
|
|
283
|
-
var coordinate = scaler(tick);
|
|
284
|
-
if (isNaN(coordinate)) return null;
|
|
285
|
-
|
|
286
|
-
var _tickSize = tickLine.tickSize || tickSize;
|
|
287
|
-
|
|
288
|
-
return /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
|
|
289
|
-
className: "__easyv-tickLine",
|
|
290
|
-
key: index,
|
|
291
|
-
config: tickLine
|
|
292
|
-
}, (0, _utils.getTickCoord)({
|
|
293
|
-
orientation: orientation,
|
|
294
|
-
coordinate: coordinate,
|
|
295
|
-
tickSize: _tickSize
|
|
296
|
-
})));
|
|
297
|
-
})))), /*#__PURE__*/_react["default"].createElement("g", {
|
|
298
|
-
transform: 'translate(' + x + ', ' + y + ')'
|
|
299
|
-
}, label && gridLine && ticks.map(function (tick, index) {
|
|
300
|
-
var coordinate = scaler(tick);
|
|
301
|
-
if (isNaN(coordinate)) return null;
|
|
302
|
-
|
|
303
|
-
var _tickSize = tickLine.tickSize || tickSize;
|
|
304
|
-
|
|
305
|
-
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
306
|
-
key: index
|
|
307
|
-
}, label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
308
|
-
className: "__easyv-label",
|
|
309
|
-
orientation: orientation,
|
|
310
|
-
coordinate: coordinate,
|
|
311
|
-
config: label,
|
|
312
|
-
label: tick,
|
|
313
|
-
tickSize: _tickSize,
|
|
314
|
-
formatter: formatter,
|
|
315
|
-
rotate: rotate,
|
|
316
|
-
onClick: triggerClick
|
|
317
|
-
}), gridLine && /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
|
|
318
|
-
className: "__easyv-gridLine",
|
|
319
|
-
config: gridLine
|
|
320
|
-
}, (0, _utils.getGridCoord)({
|
|
321
|
-
orientation: orientation,
|
|
322
|
-
coordinate: coordinate,
|
|
323
|
-
end: orientation == 'left' || orientation == 'right' ? width : height
|
|
324
|
-
}))));
|
|
325
|
-
}), unit && /*#__PURE__*/_react["default"].createElement(Unit, {
|
|
326
|
-
config: unit
|
|
327
|
-
})));
|
|
328
|
-
});
|
|
329
|
-
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
var getLayout = function getLayout(orientation, rotate) {
|
|
72
|
+
switch (orientation) {
|
|
73
|
+
case 'top':
|
|
74
|
+
return {
|
|
75
|
+
dominantBaseline: 'text-after-edge',
|
|
76
|
+
textAnchor: rotate ? 'end' : 'middle',
|
|
77
|
+
directionX: 1,
|
|
78
|
+
directionY: -1
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
case 'bottom':
|
|
82
|
+
return {
|
|
83
|
+
dominantBaseline: 'text-before-edge',
|
|
84
|
+
textAnchor: rotate ? 'start' : 'middle',
|
|
85
|
+
directionX: 1,
|
|
86
|
+
directionY: 1
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
case 'left':
|
|
90
|
+
return {
|
|
91
|
+
dominantBaseline: 'middle',
|
|
92
|
+
textAnchor: 'end',
|
|
93
|
+
directionX: -1,
|
|
94
|
+
directionY: 1
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
case 'right':
|
|
98
|
+
return {
|
|
99
|
+
dominantBaseline: 'middle',
|
|
100
|
+
textAnchor: 'start',
|
|
101
|
+
directionX: 1,
|
|
102
|
+
directionY: 1
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
var AxisLine = function AxisLine(_ref3) {
|
|
108
|
+
var _ref3$orientation = _ref3.orientation,
|
|
109
|
+
orientation = _ref3$orientation === void 0 ? defaultOrientation : _ref3$orientation,
|
|
110
|
+
_ref3$config = _ref3.config,
|
|
111
|
+
show = _ref3$config.show,
|
|
112
|
+
color = _ref3$config.color,
|
|
113
|
+
lineWidth = _ref3$config.lineWidth;
|
|
114
|
+
if (!show) return null;
|
|
115
|
+
var context = (0, _react.useContext)(_context.chartContext);
|
|
116
|
+
return /*#__PURE__*/_react["default"].createElement("path", {
|
|
117
|
+
d: getAxesPath(orientation, context),
|
|
118
|
+
stroke: color,
|
|
119
|
+
strokeWidth: lineWidth
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
var Unit = function Unit(_ref4) {
|
|
124
|
+
var _ref4$config = _ref4.config,
|
|
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$align = _ref4$config$align === void 0 ? defaultAlign : _ref4$config$align;
|
|
139
|
+
var textAnchor = _ref4$config$align.textAnchor;
|
|
140
|
+
if (!show) return null;
|
|
141
|
+
return /*#__PURE__*/_react["default"].createElement("text", {
|
|
142
|
+
className: "__easyv-unit",
|
|
143
|
+
transform: 'translate(' + translateX + ', ' + translateY + ')',
|
|
144
|
+
fontFamily: fontFamily,
|
|
145
|
+
fontSize: fontSize,
|
|
146
|
+
fill: color,
|
|
147
|
+
fontWeight: bold ? 'bold' : 'normal',
|
|
148
|
+
fontStyle: italic ? 'italic' : 'normal',
|
|
149
|
+
letterSpacing: letterSpacing,
|
|
150
|
+
textAnchor: textAnchor
|
|
151
|
+
}, text);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
var Label = function Label(_ref5) {
|
|
155
|
+
var className = _ref5.className,
|
|
156
|
+
_ref5$orientation = _ref5.orientation,
|
|
157
|
+
orientation = _ref5$orientation === void 0 ? defaultOrientation : _ref5$orientation,
|
|
158
|
+
label = _ref5.label,
|
|
159
|
+
coordinate = _ref5.coordinate,
|
|
160
|
+
_ref5$formatter = _ref5.formatter,
|
|
161
|
+
formatter = _ref5$formatter === void 0 ? defaultFormatter : _ref5$formatter,
|
|
162
|
+
tickSize = _ref5.tickSize,
|
|
163
|
+
_ref5$rotate = _ref5.rotate,
|
|
164
|
+
rotate = _ref5$rotate === void 0 ? 0 : _ref5$rotate,
|
|
165
|
+
config = _ref5.config,
|
|
166
|
+
_ref5$onClick = _ref5.onClick,
|
|
167
|
+
onClick = _ref5$onClick === void 0 ? defaultEvent : _ref5$onClick,
|
|
168
|
+
_ref5$config = _ref5.config,
|
|
169
|
+
show = _ref5$config.show,
|
|
170
|
+
style = _ref5$config.style,
|
|
171
|
+
_ref5$config$translat = _ref5$config.translate,
|
|
172
|
+
translateX = _ref5$config$translat.x,
|
|
173
|
+
translateY = _ref5$config$translat.y,
|
|
174
|
+
_ref5$config$font = _ref5$config.font,
|
|
175
|
+
fontFamily = _ref5$config$font.fontFamily,
|
|
176
|
+
fontSize = _ref5$config$font.fontSize,
|
|
177
|
+
color = _ref5$config$font.color,
|
|
178
|
+
bold = _ref5$config$font.bold,
|
|
179
|
+
italic = _ref5$config$font.italic,
|
|
180
|
+
letterSpacing = _ref5$config$font.letterSpacing;
|
|
181
|
+
if (!show) return null;
|
|
182
|
+
|
|
183
|
+
var _label = formatter(label, config);
|
|
184
|
+
|
|
185
|
+
var _getLayout = getLayout(orientation, rotate),
|
|
186
|
+
dominantBaseline = _getLayout.dominantBaseline,
|
|
187
|
+
textAnchor = _getLayout.textAnchor,
|
|
188
|
+
directionX = _getLayout.directionX,
|
|
189
|
+
directionY = _getLayout.directionY;
|
|
190
|
+
|
|
191
|
+
var isVertical = orientation == 'left' || orientation == 'right';
|
|
192
|
+
var x = (isVertical ? tickSize * directionX : coordinate) + translateX * directionX;
|
|
193
|
+
var y = (isVertical ? coordinate : tickSize * directionY) + translateY * directionY;
|
|
194
|
+
var translateText = 'translate(' + x + ', ' + y + ')';
|
|
195
|
+
|
|
196
|
+
var _style = style && ((0, _typeof2["default"])(style) == 'object' ? style : style(_label));
|
|
197
|
+
|
|
198
|
+
return /*#__PURE__*/_react["default"].createElement("text", {
|
|
199
|
+
className: className,
|
|
200
|
+
style: _objectSpread(_objectSpread({}, _style), {}, {
|
|
201
|
+
whiteSpace: 'pre'
|
|
202
|
+
}),
|
|
203
|
+
onClick: onClick,
|
|
204
|
+
"data-data": JSON.stringify({
|
|
205
|
+
x: label
|
|
206
|
+
}),
|
|
207
|
+
dominantBaseline: dominantBaseline,
|
|
208
|
+
textAnchor: textAnchor,
|
|
209
|
+
fontFamily: fontFamily,
|
|
210
|
+
fontSize: fontSize,
|
|
211
|
+
fill: color,
|
|
212
|
+
fontWeight: bold ? 'bold' : 'normal',
|
|
213
|
+
fontStyle: italic ? 'italic' : 'normal',
|
|
214
|
+
letterSpacing: letterSpacing,
|
|
215
|
+
dx: "0",
|
|
216
|
+
dy: "0",
|
|
217
|
+
transform: Array.isArray(_label) ? rotate !== 0 ? isVertical ? translateText + 'rotate(' + rotate + ')' : 'rotate(' + rotate + ', ' + x + ', ' + y + ')' : isVertical ? translateText : 'translate(' + translateX + ', ' + translateY + ')' : translateText + 'rotate(' + rotate + ')'
|
|
218
|
+
}, !!Array.isArray(_label) ? _label.map(function (item, index) {
|
|
219
|
+
return /*#__PURE__*/_react["default"].createElement("tspan", {
|
|
220
|
+
key: index,
|
|
221
|
+
x: x,
|
|
222
|
+
dy: "1em"
|
|
223
|
+
}, item);
|
|
224
|
+
}) : _label);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
var _default = /*#__PURE__*/(0, _react.memo)(function (_ref6) {
|
|
228
|
+
var orientation = _ref6.orientation,
|
|
229
|
+
scaler = _ref6.scaler,
|
|
230
|
+
_ref6$tickSize = _ref6.tickSize,
|
|
231
|
+
tickSize = _ref6$tickSize === void 0 ? defaultTickSize : _ref6$tickSize,
|
|
232
|
+
ticks = _ref6.ticks,
|
|
233
|
+
formatter = _ref6.formatter,
|
|
234
|
+
rotate = _ref6.rotate,
|
|
235
|
+
triggerClick = _ref6.triggerClick,
|
|
236
|
+
_ref6$config = _ref6.config,
|
|
237
|
+
on = _ref6$config.on,
|
|
238
|
+
label = _ref6$config.label,
|
|
239
|
+
axisLine = _ref6$config.axisLine,
|
|
240
|
+
tickLine = _ref6$config.tickLine,
|
|
241
|
+
gridLine = _ref6$config.gridLine,
|
|
242
|
+
unit = _ref6$config.unit,
|
|
243
|
+
positions = _ref6.positions;
|
|
244
|
+
if (!(on && ticks.length > 0)) return null;
|
|
245
|
+
|
|
246
|
+
var _useContext = (0, _react.useContext)(_context.chartContext),
|
|
247
|
+
width = _useContext.width,
|
|
248
|
+
height = _useContext.height;
|
|
249
|
+
|
|
250
|
+
var x = orientation == 'right' ? width : 0;
|
|
251
|
+
var y = orientation == 'bottom' ? height : 0;
|
|
252
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, axisLine && tickLine && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, axisLine && (positions && positions.length ? positions.map(function (_ref7, index) {
|
|
253
|
+
var x = _ref7.x,
|
|
254
|
+
y = _ref7.y;
|
|
255
|
+
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
256
|
+
key: index,
|
|
257
|
+
transform: 'translate(' + x + ', ' + y + ')'
|
|
258
|
+
}, /*#__PURE__*/_react["default"].createElement(AxisLine, {
|
|
259
|
+
orientation: orientation,
|
|
260
|
+
config: axisLine
|
|
261
|
+
}), tickLine && ticks.map(function (tick, index) {
|
|
262
|
+
var coordinate = scaler(tick);
|
|
263
|
+
if (isNaN(coordinate)) return null;
|
|
264
|
+
|
|
265
|
+
var _tickSize = tickLine.tickSize || tickSize;
|
|
266
|
+
|
|
267
|
+
return /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
|
|
268
|
+
className: "__easyv-tickLine",
|
|
269
|
+
key: index,
|
|
270
|
+
config: tickLine
|
|
271
|
+
}, (0, _utils.getTickCoord)({
|
|
272
|
+
orientation: orientation,
|
|
273
|
+
coordinate: coordinate,
|
|
274
|
+
tickSize: _tickSize
|
|
275
|
+
})));
|
|
276
|
+
}));
|
|
277
|
+
}) : /*#__PURE__*/_react["default"].createElement("g", {
|
|
278
|
+
transform: 'translate(' + x + ', ' + y + ')'
|
|
279
|
+
}, /*#__PURE__*/_react["default"].createElement(AxisLine, {
|
|
280
|
+
orientation: orientation,
|
|
281
|
+
config: axisLine
|
|
282
|
+
}), tickLine && ticks.map(function (tick, index) {
|
|
283
|
+
var coordinate = scaler(tick);
|
|
284
|
+
if (isNaN(coordinate)) return null;
|
|
285
|
+
|
|
286
|
+
var _tickSize = tickLine.tickSize || tickSize;
|
|
287
|
+
|
|
288
|
+
return /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
|
|
289
|
+
className: "__easyv-tickLine",
|
|
290
|
+
key: index,
|
|
291
|
+
config: tickLine
|
|
292
|
+
}, (0, _utils.getTickCoord)({
|
|
293
|
+
orientation: orientation,
|
|
294
|
+
coordinate: coordinate,
|
|
295
|
+
tickSize: _tickSize
|
|
296
|
+
})));
|
|
297
|
+
})))), /*#__PURE__*/_react["default"].createElement("g", {
|
|
298
|
+
transform: 'translate(' + x + ', ' + y + ')'
|
|
299
|
+
}, label && gridLine && ticks.map(function (tick, index) {
|
|
300
|
+
var coordinate = scaler(tick);
|
|
301
|
+
if (isNaN(coordinate)) return null;
|
|
302
|
+
|
|
303
|
+
var _tickSize = tickLine.tickSize || tickSize;
|
|
304
|
+
|
|
305
|
+
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
306
|
+
key: index
|
|
307
|
+
}, label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
308
|
+
className: "__easyv-label",
|
|
309
|
+
orientation: orientation,
|
|
310
|
+
coordinate: coordinate,
|
|
311
|
+
config: label,
|
|
312
|
+
label: tick,
|
|
313
|
+
tickSize: _tickSize,
|
|
314
|
+
formatter: formatter,
|
|
315
|
+
rotate: rotate,
|
|
316
|
+
onClick: triggerClick
|
|
317
|
+
}), gridLine && /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
|
|
318
|
+
className: "__easyv-gridLine",
|
|
319
|
+
config: gridLine
|
|
320
|
+
}, (0, _utils.getGridCoord)({
|
|
321
|
+
orientation: orientation,
|
|
322
|
+
coordinate: coordinate,
|
|
323
|
+
end: orientation == 'left' || orientation == 'right' ? width : height
|
|
324
|
+
}))));
|
|
325
|
+
}), unit && /*#__PURE__*/_react["default"].createElement(Unit, {
|
|
326
|
+
config: unit
|
|
327
|
+
})));
|
|
328
|
+
});
|
|
329
|
+
|
|
330
330
|
exports["default"] = _default;
|