@antv/component 0.8.16 → 0.8.20
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/esm/abstract/html-component.d.ts +2 -40
- package/esm/abstract/html-component.js +0 -1
- package/esm/abstract/html-component.js.map +1 -1
- package/esm/annotation/html.d.ts +0 -35
- package/esm/axis/base.d.ts +3 -3
- package/esm/axis/base.js +5 -3
- package/esm/axis/base.js.map +1 -1
- package/esm/axis/circle.d.ts +10 -1
- package/esm/axis/circle.js +99 -0
- package/esm/axis/circle.js.map +1 -1
- package/esm/axis/line.d.ts +6 -1
- package/esm/axis/overlap/auto-ellipsis.js +3 -3
- package/esm/axis/overlap/auto-ellipsis.js.map +1 -1
- package/esm/crosshair/html.d.ts +0 -67
- package/esm/legend/category.js +8 -6
- package/esm/legend/category.js.map +1 -1
- package/esm/scrollbar/scrollbar.js.map +1 -1
- package/esm/tooltip/html.d.ts +0 -228
- package/esm/types.d.ts +10 -0
- package/esm/util/label.js +23 -9
- package/esm/util/label.js.map +1 -1
- package/esm/util/theme.js +1 -1
- package/esm/util/theme.js.map +1 -1
- package/lib/abstract/html-component.d.ts +2 -40
- package/lib/abstract/html-component.js +0 -1
- package/lib/abstract/html-component.js.map +1 -1
- package/lib/annotation/html.d.ts +0 -35
- package/lib/axis/base.d.ts +3 -3
- package/lib/axis/base.js +5 -3
- package/lib/axis/base.js.map +1 -1
- package/lib/axis/circle.d.ts +10 -1
- package/lib/axis/circle.js +99 -0
- package/lib/axis/circle.js.map +1 -1
- package/lib/axis/line.d.ts +6 -1
- package/lib/axis/overlap/auto-ellipsis.js +3 -3
- package/lib/axis/overlap/auto-ellipsis.js.map +1 -1
- package/lib/crosshair/html.d.ts +0 -67
- package/lib/legend/category.js +8 -6
- package/lib/legend/category.js.map +1 -1
- package/lib/scrollbar/scrollbar.js.map +1 -1
- package/lib/tooltip/html.d.ts +0 -228
- package/lib/types.d.ts +10 -0
- package/lib/util/label.js +22 -8
- package/lib/util/label.js.map +1 -1
- package/lib/util/theme.js +1 -1
- package/lib/util/theme.js.map +1 -1
- package/package.json +2 -2
- package/src/abstract/html-component.ts +0 -1
- package/src/axis/base.ts +6 -4
- package/src/axis/circle.ts +102 -2
- package/src/axis/overlap/auto-ellipsis.ts +3 -3
- package/src/legend/category.ts +5 -4
- package/src/scrollbar/scrollbar.ts +2 -2
- package/src/types.ts +10 -0
- package/src/util/label.ts +24 -9
- package/src/util/theme.ts +1 -1
- package/CHANGELOG.md +0 -80
package/lib/tooltip/html.d.ts
CHANGED
|
@@ -206,234 +206,6 @@ declare class Tooltip<T extends TooltipCfg = TooltipCfg> extends HtmlComponent i
|
|
|
206
206
|
marginLeft?: undefined;
|
|
207
207
|
};
|
|
208
208
|
};
|
|
209
|
-
id: string;
|
|
210
|
-
locationType: string;
|
|
211
|
-
offsetX: number;
|
|
212
|
-
offsetY: number;
|
|
213
|
-
animate: boolean;
|
|
214
|
-
capture: boolean;
|
|
215
|
-
updateAutoRender: boolean;
|
|
216
|
-
animateOption: {
|
|
217
|
-
appear: any;
|
|
218
|
-
update: {
|
|
219
|
-
duration: number;
|
|
220
|
-
easing: string;
|
|
221
|
-
};
|
|
222
|
-
enter: {
|
|
223
|
-
duration: number;
|
|
224
|
-
easing: string;
|
|
225
|
-
};
|
|
226
|
-
leave: {
|
|
227
|
-
duration: number;
|
|
228
|
-
easing: string;
|
|
229
|
-
};
|
|
230
|
-
};
|
|
231
|
-
events: any;
|
|
232
|
-
defaultCfg: {};
|
|
233
|
-
visible: boolean;
|
|
234
|
-
} | {
|
|
235
|
-
name: string;
|
|
236
|
-
type: string;
|
|
237
|
-
x: number;
|
|
238
|
-
y: number;
|
|
239
|
-
items: any[];
|
|
240
|
-
customContent: any;
|
|
241
|
-
containerTpl: string;
|
|
242
|
-
itemTpl: string;
|
|
243
|
-
xCrosshairTpl: string;
|
|
244
|
-
yCrosshairTpl: string;
|
|
245
|
-
title: any;
|
|
246
|
-
showTitle: boolean;
|
|
247
|
-
/**
|
|
248
|
-
* tooltip 限制的区域
|
|
249
|
-
* @type {Region}
|
|
250
|
-
*/
|
|
251
|
-
region: any;
|
|
252
|
-
crosshairsRegion: any;
|
|
253
|
-
containerClassName: string;
|
|
254
|
-
crosshairs: any;
|
|
255
|
-
offset: number;
|
|
256
|
-
position: string;
|
|
257
|
-
domStyles: any;
|
|
258
|
-
defaultStyles: {
|
|
259
|
-
[x: string]: {
|
|
260
|
-
position: string;
|
|
261
|
-
visibility: string;
|
|
262
|
-
zIndex: number;
|
|
263
|
-
transition: string;
|
|
264
|
-
backgroundColor: string;
|
|
265
|
-
boxShadow: string;
|
|
266
|
-
borderRadius: string;
|
|
267
|
-
color: string;
|
|
268
|
-
fontSize: string;
|
|
269
|
-
fontFamily: string;
|
|
270
|
-
lineHeight: string;
|
|
271
|
-
padding: string;
|
|
272
|
-
marginBottom?: undefined;
|
|
273
|
-
margin?: undefined;
|
|
274
|
-
listStyleType?: undefined;
|
|
275
|
-
width?: undefined;
|
|
276
|
-
height?: undefined;
|
|
277
|
-
display?: undefined;
|
|
278
|
-
marginRight?: undefined;
|
|
279
|
-
float?: undefined;
|
|
280
|
-
marginLeft?: undefined;
|
|
281
|
-
} | {
|
|
282
|
-
marginBottom: string;
|
|
283
|
-
position?: undefined;
|
|
284
|
-
visibility?: undefined;
|
|
285
|
-
zIndex?: undefined;
|
|
286
|
-
transition?: undefined;
|
|
287
|
-
backgroundColor?: undefined;
|
|
288
|
-
boxShadow?: undefined;
|
|
289
|
-
borderRadius?: undefined;
|
|
290
|
-
color?: undefined;
|
|
291
|
-
fontSize?: undefined;
|
|
292
|
-
fontFamily?: undefined;
|
|
293
|
-
lineHeight?: undefined;
|
|
294
|
-
padding?: undefined;
|
|
295
|
-
margin?: undefined;
|
|
296
|
-
listStyleType?: undefined;
|
|
297
|
-
width?: undefined;
|
|
298
|
-
height?: undefined;
|
|
299
|
-
display?: undefined;
|
|
300
|
-
marginRight?: undefined;
|
|
301
|
-
float?: undefined;
|
|
302
|
-
marginLeft?: undefined;
|
|
303
|
-
} | {
|
|
304
|
-
margin: string;
|
|
305
|
-
listStyleType: string;
|
|
306
|
-
padding: string;
|
|
307
|
-
position?: undefined;
|
|
308
|
-
visibility?: undefined;
|
|
309
|
-
zIndex?: undefined;
|
|
310
|
-
transition?: undefined;
|
|
311
|
-
backgroundColor?: undefined;
|
|
312
|
-
boxShadow?: undefined;
|
|
313
|
-
borderRadius?: undefined;
|
|
314
|
-
color?: undefined;
|
|
315
|
-
fontSize?: undefined;
|
|
316
|
-
fontFamily?: undefined;
|
|
317
|
-
lineHeight?: undefined;
|
|
318
|
-
marginBottom?: undefined;
|
|
319
|
-
width?: undefined;
|
|
320
|
-
height?: undefined;
|
|
321
|
-
display?: undefined;
|
|
322
|
-
marginRight?: undefined;
|
|
323
|
-
float?: undefined;
|
|
324
|
-
marginLeft?: undefined;
|
|
325
|
-
} | {
|
|
326
|
-
listStyleType: string;
|
|
327
|
-
marginBottom: string;
|
|
328
|
-
position?: undefined;
|
|
329
|
-
visibility?: undefined;
|
|
330
|
-
zIndex?: undefined;
|
|
331
|
-
transition?: undefined;
|
|
332
|
-
backgroundColor?: undefined;
|
|
333
|
-
boxShadow?: undefined;
|
|
334
|
-
borderRadius?: undefined;
|
|
335
|
-
color?: undefined;
|
|
336
|
-
fontSize?: undefined;
|
|
337
|
-
fontFamily?: undefined;
|
|
338
|
-
lineHeight?: undefined;
|
|
339
|
-
padding?: undefined;
|
|
340
|
-
margin?: undefined;
|
|
341
|
-
width?: undefined;
|
|
342
|
-
height?: undefined;
|
|
343
|
-
display?: undefined;
|
|
344
|
-
marginRight?: undefined;
|
|
345
|
-
float?: undefined;
|
|
346
|
-
marginLeft?: undefined;
|
|
347
|
-
} | {
|
|
348
|
-
width: string;
|
|
349
|
-
height: string;
|
|
350
|
-
borderRadius: string;
|
|
351
|
-
display: string;
|
|
352
|
-
marginRight: string;
|
|
353
|
-
position?: undefined;
|
|
354
|
-
visibility?: undefined;
|
|
355
|
-
zIndex?: undefined;
|
|
356
|
-
transition?: undefined;
|
|
357
|
-
backgroundColor?: undefined;
|
|
358
|
-
boxShadow?: undefined;
|
|
359
|
-
color?: undefined;
|
|
360
|
-
fontSize?: undefined;
|
|
361
|
-
fontFamily?: undefined;
|
|
362
|
-
lineHeight?: undefined;
|
|
363
|
-
padding?: undefined;
|
|
364
|
-
marginBottom?: undefined;
|
|
365
|
-
margin?: undefined;
|
|
366
|
-
listStyleType?: undefined;
|
|
367
|
-
float?: undefined;
|
|
368
|
-
marginLeft?: undefined;
|
|
369
|
-
} | {
|
|
370
|
-
display: string;
|
|
371
|
-
float: string;
|
|
372
|
-
marginLeft: string;
|
|
373
|
-
position?: undefined;
|
|
374
|
-
visibility?: undefined;
|
|
375
|
-
zIndex?: undefined;
|
|
376
|
-
transition?: undefined;
|
|
377
|
-
backgroundColor?: undefined;
|
|
378
|
-
boxShadow?: undefined;
|
|
379
|
-
borderRadius?: undefined;
|
|
380
|
-
color?: undefined;
|
|
381
|
-
fontSize?: undefined;
|
|
382
|
-
fontFamily?: undefined;
|
|
383
|
-
lineHeight?: undefined;
|
|
384
|
-
padding?: undefined;
|
|
385
|
-
marginBottom?: undefined;
|
|
386
|
-
margin?: undefined;
|
|
387
|
-
listStyleType?: undefined;
|
|
388
|
-
width?: undefined;
|
|
389
|
-
height?: undefined;
|
|
390
|
-
marginRight?: undefined;
|
|
391
|
-
} | {
|
|
392
|
-
position: string;
|
|
393
|
-
width: string;
|
|
394
|
-
backgroundColor: string;
|
|
395
|
-
visibility?: undefined;
|
|
396
|
-
zIndex?: undefined;
|
|
397
|
-
transition?: undefined;
|
|
398
|
-
boxShadow?: undefined;
|
|
399
|
-
borderRadius?: undefined;
|
|
400
|
-
color?: undefined;
|
|
401
|
-
fontSize?: undefined;
|
|
402
|
-
fontFamily?: undefined;
|
|
403
|
-
lineHeight?: undefined;
|
|
404
|
-
padding?: undefined;
|
|
405
|
-
marginBottom?: undefined;
|
|
406
|
-
margin?: undefined;
|
|
407
|
-
listStyleType?: undefined;
|
|
408
|
-
height?: undefined;
|
|
409
|
-
display?: undefined;
|
|
410
|
-
marginRight?: undefined;
|
|
411
|
-
float?: undefined;
|
|
412
|
-
marginLeft?: undefined;
|
|
413
|
-
} | {
|
|
414
|
-
position: string;
|
|
415
|
-
height: string;
|
|
416
|
-
backgroundColor: string;
|
|
417
|
-
visibility?: undefined;
|
|
418
|
-
zIndex?: undefined;
|
|
419
|
-
transition?: undefined;
|
|
420
|
-
boxShadow?: undefined;
|
|
421
|
-
borderRadius?: undefined;
|
|
422
|
-
color?: undefined;
|
|
423
|
-
fontSize?: undefined;
|
|
424
|
-
fontFamily?: undefined;
|
|
425
|
-
lineHeight?: undefined;
|
|
426
|
-
padding?: undefined;
|
|
427
|
-
marginBottom?: undefined;
|
|
428
|
-
margin?: undefined;
|
|
429
|
-
listStyleType?: undefined;
|
|
430
|
-
width?: undefined;
|
|
431
|
-
display?: undefined;
|
|
432
|
-
marginRight?: undefined;
|
|
433
|
-
float?: undefined;
|
|
434
|
-
marginLeft?: undefined;
|
|
435
|
-
};
|
|
436
|
-
};
|
|
437
209
|
container: any;
|
|
438
210
|
updateAutoRender: boolean;
|
|
439
211
|
parent: any;
|
package/lib/types.d.ts
CHANGED
|
@@ -162,6 +162,16 @@ export interface AxisLabelCfg {
|
|
|
162
162
|
* @type {number}
|
|
163
163
|
*/
|
|
164
164
|
offset?: number;
|
|
165
|
+
/**
|
|
166
|
+
* label 在X方向的额外偏移量
|
|
167
|
+
* @type {number}
|
|
168
|
+
*/
|
|
169
|
+
offsetX?: number;
|
|
170
|
+
/**
|
|
171
|
+
* label 在Y方向的额外偏移量
|
|
172
|
+
* @type {number}
|
|
173
|
+
*/
|
|
174
|
+
offsetY?: number;
|
|
165
175
|
/**
|
|
166
176
|
* 文本旋转角度
|
|
167
177
|
* @type {number}
|
package/lib/util/label.js
CHANGED
|
@@ -67,32 +67,46 @@ function testLabel(label, limitLength) {
|
|
|
67
67
|
exports.testLabel = testLabel;
|
|
68
68
|
/** 处理 text shape 的自动省略 */
|
|
69
69
|
function ellipsisLabel(isVertical, label, limitLength, position) {
|
|
70
|
+
var _a;
|
|
70
71
|
if (position === void 0) { position = 'tail'; }
|
|
71
|
-
var text = label.attr('text');
|
|
72
|
+
var text = (_a = label.attr('text')) !== null && _a !== void 0 ? _a : ''; // 避免出现null、undefined
|
|
73
|
+
if (position === 'tail') {
|
|
74
|
+
// component 里的缩略处理做得很糟糕,文字长度测算完全不准确
|
|
75
|
+
// 这里暂时只对 tail 做处理
|
|
76
|
+
var font = util_1.pick(label.attr(), ['fontSize', 'fontFamily', 'fontWeight', 'fontStyle', 'fontVariant']);
|
|
77
|
+
var ellipsisText = util_1.getEllipsisText(text, limitLength, font, '…');
|
|
78
|
+
if (text !== ellipsisText) {
|
|
79
|
+
label.attr('text', ellipsisText);
|
|
80
|
+
label.set('tip', text);
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
label.set('tip', null);
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
72
86
|
var labelLength = getLabelLength(isVertical, label);
|
|
73
87
|
var codeLength = text_1.strLen(text);
|
|
74
|
-
var
|
|
88
|
+
var ellipsisFlag = false;
|
|
75
89
|
if (limitLength < labelLength) {
|
|
76
|
-
var
|
|
90
|
+
var reserveLength = Math.floor((limitLength / labelLength) * codeLength) - ELLIPSIS_CODE_LENGTH; // 计算出来的应该保存的长度
|
|
77
91
|
var newText = void 0;
|
|
78
|
-
if (
|
|
79
|
-
newText = text_1.ellipsisString(text,
|
|
92
|
+
if (reserveLength >= 0) {
|
|
93
|
+
newText = text_1.ellipsisString(text, reserveLength, position);
|
|
80
94
|
}
|
|
81
95
|
else {
|
|
82
96
|
newText = ELLIPSIS_CODE;
|
|
83
97
|
}
|
|
84
98
|
if (newText) {
|
|
85
99
|
label.attr('text', newText);
|
|
86
|
-
|
|
100
|
+
ellipsisFlag = true;
|
|
87
101
|
}
|
|
88
102
|
}
|
|
89
|
-
if (
|
|
103
|
+
if (ellipsisFlag) {
|
|
90
104
|
label.set('tip', text);
|
|
91
105
|
}
|
|
92
106
|
else {
|
|
93
107
|
label.set('tip', null);
|
|
94
108
|
}
|
|
95
|
-
return
|
|
109
|
+
return ellipsisFlag;
|
|
96
110
|
}
|
|
97
111
|
exports.ellipsisLabel = ellipsisLabel;
|
|
98
112
|
//# sourceMappingURL=label.js.map
|
package/lib/util/label.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../src/util/label.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../src/util/label.ts"],"names":[],"mappings":";;;AACA,mCAAgE;AAEhE,+BAAgD;AAEhD,IAAM,aAAa,GAAG,QAAQ,CAAC;AAC/B,IAAM,oBAAoB,GAAG,CAAC,CAAC,CAAC,SAAS;AAEzC,aAAa;AACb,IAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B;;;;;GAKG;AACH,SAAS,yBAAyB,CAAC,MAAkB;IACnD,IAAM,KAAK,GAAa,MAAM,CAAC,GAAG,CAAC,UAAC,KAAK;QACvC,IAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChC,OAAO,YAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAG,IAAM,CAAC;IACtC,CAAC,CAAC,CAAC;IACH,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACxC,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI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B,OAAO,GAAG,qBAAc,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC;SACzD;aAAM;YACL,OAAO,GAAG,aAAa,CAAC;SACzB;QACD,IAAI,OAAO,EAAE;YACX,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC5B,YAAY,GAAG,IAAI,CAAC;SACrB;KACF;IACD,IAAI,YAAY,EAAE;QAChB,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;KACxB;SAAM;QACL,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;KACxB;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAvCD,sCAuCC"}
|
package/lib/util/theme.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = {
|
|
4
|
-
fontFamily: "\n
|
|
4
|
+
fontFamily: "\n BlinkMacSystemFont, \"Segoe UI\", Roboto,\"Helvetica Neue\",\n Helvetica, \"PingFang SC\", \"Hiragino Sans GB\", \"Microsoft YaHei\",\n SimSun, \"sans-serif\"",
|
|
5
5
|
textColor: '#2C3542',
|
|
6
6
|
activeTextColor: '#333333',
|
|
7
7
|
uncheckedColor: '#D8D8D8',
|
package/lib/util/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/util/theme.ts"],"names":[],"mappings":";;AAAA,kBAAe;IACb,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/util/theme.ts"],"names":[],"mappings":";;AAAA,kBAAe;IACb,UAAU,EAAE,sKAGS;IACrB,SAAS,EAAE,SAAS;IACpB,eAAe,EAAE,SAAS;IAC1B,cAAc,EAAE,SAAS;IACzB,SAAS,EAAE,SAAS;IACpB,WAAW,EAAE,SAAS;IACtB,kBAAkB,EAAE,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC;IAChC,oBAAoB,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC;CAClC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/component",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.20",
|
|
4
4
|
"description": "The component module for antv",
|
|
5
5
|
"author": "https://github.com/orgs/antvis/people",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,7 +42,6 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@antv/color-util": "^2.0.3",
|
|
46
45
|
"@antv/g-canvas": "0.5.6",
|
|
47
46
|
"@types/jest": "^24.0.18",
|
|
48
47
|
"conventional-changelog-cli": "^2.1.1",
|
|
@@ -60,6 +59,7 @@
|
|
|
60
59
|
"typescript": "^3.5.3"
|
|
61
60
|
},
|
|
62
61
|
"dependencies": {
|
|
62
|
+
"@antv/color-util": "^2.0.3",
|
|
63
63
|
"@antv/dom-util": "~2.0.1",
|
|
64
64
|
"@antv/g-base": "0.5.6",
|
|
65
65
|
"@antv/matrix-util": "^3.1.0-beta.1",
|
package/src/axis/base.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IGroup } from '@antv/g-base';
|
|
2
2
|
import { ext } from '@antv/matrix-util';
|
|
3
|
-
import { each, filter, get, isFunction, isNil, isNumberEqual, mix, size } from '@antv/util';
|
|
3
|
+
import { each, filter, get, isFunction, isNil, isNumberEqual, mix, size, isArray } from '@antv/util';
|
|
4
4
|
import GroupComponent from '../abstract/group-component';
|
|
5
5
|
import { IList } from '../interfaces';
|
|
6
6
|
import { AxisBaseCfg, ListItem, OptimizeCfg, Point } from '../types';
|
|
@@ -70,6 +70,8 @@ abstract class AxisBase<T extends AxisBaseCfg = AxisBaseCfg> extends GroupCompon
|
|
|
70
70
|
fontWeight: 'normal',
|
|
71
71
|
},
|
|
72
72
|
offset: 10,
|
|
73
|
+
offsetX: 0,
|
|
74
|
+
offsetY: 0,
|
|
73
75
|
},
|
|
74
76
|
title: {
|
|
75
77
|
autoRotate: true,
|
|
@@ -470,7 +472,7 @@ abstract class AxisBase<T extends AxisBaseCfg = AxisBaseCfg> extends GroupCompon
|
|
|
470
472
|
// 获取 label 的配置项
|
|
471
473
|
private getLabelAttrs(tick: ListItem, index: number, ticks: ListItem[]) {
|
|
472
474
|
const labelCfg = this.get('label');
|
|
473
|
-
const { offset, rotate, formatter } = labelCfg;
|
|
475
|
+
const { offset, offsetX, offsetY, rotate, formatter } = labelCfg;
|
|
474
476
|
const point = this.getSidePoint(tick.point, offset);
|
|
475
477
|
const vector = this.getSideVector(offset, point);
|
|
476
478
|
const text = formatter ? formatter(tick.name, tick, index) : tick.name;
|
|
@@ -479,8 +481,8 @@ abstract class AxisBase<T extends AxisBaseCfg = AxisBaseCfg> extends GroupCompon
|
|
|
479
481
|
|
|
480
482
|
const attrs = mix(
|
|
481
483
|
{
|
|
482
|
-
x: point.x,
|
|
483
|
-
y: point.y,
|
|
484
|
+
x: point.x + offsetX,
|
|
485
|
+
y: point.y + offsetY,
|
|
484
486
|
text,
|
|
485
487
|
textAlign: this.getTextAnchor(vector),
|
|
486
488
|
textBaseline: this.getTextBaseline(vector),
|
package/src/axis/circle.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { IGroup } from '@antv/g-base';
|
|
2
|
+
import { each, isNil, isFunction, isObject } from '@antv/util';
|
|
1
3
|
import { vec2 } from '@antv/matrix-util';
|
|
2
|
-
import { CircleAxisCfg, Point } from '../types';
|
|
3
4
|
import AxisBase from './base';
|
|
5
|
+
import * as OverlapUtil from './overlap';
|
|
6
|
+
import type { AxisLabelAutoHideCfg } from '../types';
|
|
7
|
+
import type { CircleAxisCfg, Point, } from '../types';
|
|
4
8
|
|
|
5
9
|
class Circle extends AxisBase<CircleAxisCfg> {
|
|
6
10
|
public getDefaultCfg() {
|
|
@@ -53,7 +57,7 @@ class Circle extends AxisBase<CircleAxisCfg> {
|
|
|
53
57
|
// 获取垂直于坐标轴的向量
|
|
54
58
|
protected getSideVector(offset: number, point: Point) {
|
|
55
59
|
const center = this.get('center');
|
|
56
|
-
const vector: [
|
|
60
|
+
const vector: [number, number] = [point.x - center.x, point.y - center.y];
|
|
57
61
|
const factor = this.get('verticalFactor');
|
|
58
62
|
const vecLen = vec2.length(vector);
|
|
59
63
|
vec2.scale(vector, vector, (factor * offset) / vecLen);
|
|
@@ -76,6 +80,102 @@ class Circle extends AxisBase<CircleAxisCfg> {
|
|
|
76
80
|
y: center.y + Math.sin(angle) * radius,
|
|
77
81
|
};
|
|
78
82
|
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 是否可以执行某一 overlap
|
|
86
|
+
* @param name
|
|
87
|
+
*/
|
|
88
|
+
private canProcessOverlap(name: string) {
|
|
89
|
+
const labelCfg = this.get('label');
|
|
90
|
+
|
|
91
|
+
// 对 autoRotate,如果配置了旋转角度,直接进行固定角度旋转
|
|
92
|
+
if (name === 'autoRotate') {
|
|
93
|
+
return isNil(labelCfg.rotate);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// 默认所有 overlap 都可执行
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
protected processOverlap(labelGroup) {
|
|
101
|
+
const labelCfg = this.get('label');
|
|
102
|
+
const titleCfg = this.get('title');
|
|
103
|
+
const verticalLimitLength = this.get('verticalLimitLength');
|
|
104
|
+
const labelOffset = labelCfg.offset;
|
|
105
|
+
let limitLength = verticalLimitLength;
|
|
106
|
+
let titleHeight = 0;
|
|
107
|
+
let titleSpacing = 0;
|
|
108
|
+
if (titleCfg) {
|
|
109
|
+
titleHeight = titleCfg.style.fontSize;
|
|
110
|
+
titleSpacing = titleCfg.spacing;
|
|
111
|
+
}
|
|
112
|
+
if (limitLength) {
|
|
113
|
+
limitLength = limitLength - labelOffset - titleSpacing - titleHeight;
|
|
114
|
+
}
|
|
115
|
+
const overlapOrder = this.get('overlapOrder');
|
|
116
|
+
each(overlapOrder, (name) => {
|
|
117
|
+
if (labelCfg[name] && this.canProcessOverlap(name)) {
|
|
118
|
+
this.autoProcessOverlap(name, labelCfg[name], labelGroup, limitLength);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
if (titleCfg) {
|
|
122
|
+
if (isNil(titleCfg.offset)) {
|
|
123
|
+
// 调整 title 的 offset
|
|
124
|
+
const { height: length } = labelGroup.getCanvasBBox();
|
|
125
|
+
// 如果用户没有设置 offset,则自动计算
|
|
126
|
+
titleCfg.offset = labelOffset + length + titleSpacing + titleHeight / 2;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private autoProcessOverlap(name: string, value: any, labelGroup: IGroup, limitLength: number) {
|
|
132
|
+
let hasAdjusted = false;
|
|
133
|
+
const util = OverlapUtil[name];
|
|
134
|
+
if (limitLength > 0) {
|
|
135
|
+
if (value === true) {
|
|
136
|
+
// true 形式的配置:使用 overlap 默认的的处理方法进行处理
|
|
137
|
+
hasAdjusted = util.getDefault()(false, labelGroup, limitLength);
|
|
138
|
+
} else if (isFunction(value)) {
|
|
139
|
+
// 回调函数形式的配置: 用户可以传入回调函数
|
|
140
|
+
hasAdjusted = value(false, labelGroup, limitLength);
|
|
141
|
+
} else if (isObject(value)) {
|
|
142
|
+
// object 形式的配置方式:包括 处理方法 type, 和可选参数配置 cfg
|
|
143
|
+
const overlapCfg = value as { type: string; cfg?: AxisLabelAutoHideCfg };
|
|
144
|
+
if (util[overlapCfg.type]) {
|
|
145
|
+
hasAdjusted = util[overlapCfg.type](false, labelGroup, limitLength, overlapCfg.cfg);
|
|
146
|
+
}
|
|
147
|
+
} else if (util[value]) {
|
|
148
|
+
// 字符串类型的配置:按照名称执行 overlap 处理方法
|
|
149
|
+
hasAdjusted = util[value](false, labelGroup, limitLength);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (name === 'autoRotate') {
|
|
153
|
+
// 文本旋转后,文本的对齐方式可能就不合适了
|
|
154
|
+
if (hasAdjusted) {
|
|
155
|
+
const labels = labelGroup.getChildren();
|
|
156
|
+
const verticalFactor = this.get('verticalFactor');
|
|
157
|
+
each(labels, (label) => {
|
|
158
|
+
const textAlign = label.attr('textAlign');
|
|
159
|
+
if (textAlign === 'center') {
|
|
160
|
+
// 居中的文本需要调整旋转度
|
|
161
|
+
const newAlign = verticalFactor > 0 ? 'end' : 'start';
|
|
162
|
+
label.attr('textAlign', newAlign);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
} else if (name === 'autoHide') {
|
|
167
|
+
const children = labelGroup.getChildren().slice(0); // 复制数组,删除时不会出错
|
|
168
|
+
each(children, (label) => {
|
|
169
|
+
if (!label.get('visible')) {
|
|
170
|
+
if (this.get('isRegister')) {
|
|
171
|
+
// 已经注册过了,则删除
|
|
172
|
+
this.unregisterElement(label);
|
|
173
|
+
}
|
|
174
|
+
label.remove(); // 防止 label 数量太多,所以统一删除
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
79
179
|
}
|
|
80
180
|
|
|
81
181
|
export default Circle;
|
|
@@ -4,12 +4,12 @@ import { ellipsisLabel } from '../../util/label';
|
|
|
4
4
|
|
|
5
5
|
function ellipseLabels(isVertical: boolean, labelGroup: IGroup, limitLength: number, position: string): boolean {
|
|
6
6
|
const children = labelGroup.getChildren();
|
|
7
|
-
let
|
|
7
|
+
let ellipsisFlag = false;
|
|
8
8
|
each(children, (label) => {
|
|
9
9
|
const rst = ellipsisLabel(isVertical, label, limitLength, position);
|
|
10
|
-
|
|
10
|
+
ellipsisFlag = ellipsisFlag || rst;
|
|
11
11
|
});
|
|
12
|
-
return
|
|
12
|
+
return ellipsisFlag;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export function getDefault() {
|
package/src/legend/category.ts
CHANGED
|
@@ -501,9 +501,11 @@ class Category extends LegendBase<CategoryLegendCfg> implements IList {
|
|
|
501
501
|
let widthLimit = 0;
|
|
502
502
|
let pageWidth = 0;
|
|
503
503
|
let maxItemWidth = 0;
|
|
504
|
-
|
|
504
|
+
const itemMarginBottom = this.get('itemMarginBottom');
|
|
505
505
|
if (layout === 'horizontal') {
|
|
506
|
-
|
|
506
|
+
const maxRow = this.get('maxRow') || 1;
|
|
507
|
+
const maxRowHeight = itemHeight + (maxRow === 1 ? 0 : itemMarginBottom);
|
|
508
|
+
this.pageHeight = maxRowHeight * maxRow;
|
|
507
509
|
each(subGroups, (item) => {
|
|
508
510
|
const bbox = item.getBBox();
|
|
509
511
|
const width = itemWidth || bbox.width;
|
|
@@ -521,7 +523,7 @@ class Category extends LegendBase<CategoryLegendCfg> implements IList {
|
|
|
521
523
|
}
|
|
522
524
|
pages += 1;
|
|
523
525
|
currentPoint.x = startX;
|
|
524
|
-
currentPoint.y +=
|
|
526
|
+
currentPoint.y += maxRowHeight;
|
|
525
527
|
}
|
|
526
528
|
this.moveElementTo(item, currentPoint);
|
|
527
529
|
item.getParent().setClip({
|
|
@@ -536,7 +538,6 @@ class Category extends LegendBase<CategoryLegendCfg> implements IList {
|
|
|
536
538
|
currentPoint.x += width + itemSpacing;
|
|
537
539
|
});
|
|
538
540
|
} else {
|
|
539
|
-
const itemMarginBottom = this.get('itemMarginBottom');
|
|
540
541
|
each(subGroups, (item) => {
|
|
541
542
|
const bbox = item.getBBox();
|
|
542
543
|
if (bbox.width > pageWidth) {
|
|
@@ -128,7 +128,7 @@ export class Scrollbar extends GroupComponent<ScrollbarCfg> implements ISlider {
|
|
|
128
128
|
private renderTrackShape(group: IGroup) {
|
|
129
129
|
const { trackLen, theme = { default: {} } } = this.cfg;
|
|
130
130
|
const { lineCap, trackColor, size: themeSize } = deepMix({}, DEFAULT_THEME, theme).default;
|
|
131
|
-
const size = get(this.cfg, 'size', themeSize)
|
|
131
|
+
const size = get(this.cfg, 'size', themeSize);
|
|
132
132
|
|
|
133
133
|
const attrs = this.get('isHorizontal')
|
|
134
134
|
? {
|
|
@@ -161,7 +161,7 @@ export class Scrollbar extends GroupComponent<ScrollbarCfg> implements ISlider {
|
|
|
161
161
|
private renderThumbShape(group: IGroup) {
|
|
162
162
|
const { thumbOffset, thumbLen, theme } = this.cfg;
|
|
163
163
|
const { size: themeSize, lineCap, thumbColor } = deepMix({}, DEFAULT_THEME, theme).default;
|
|
164
|
-
const size = get(this.cfg, 'size', themeSize)
|
|
164
|
+
const size = get(this.cfg, 'size', themeSize);
|
|
165
165
|
|
|
166
166
|
const attrs = this.get('isHorizontal')
|
|
167
167
|
? {
|
package/src/types.ts
CHANGED
|
@@ -177,6 +177,16 @@ export interface AxisLabelCfg {
|
|
|
177
177
|
* @type {number}
|
|
178
178
|
*/
|
|
179
179
|
offset?: number;
|
|
180
|
+
/**
|
|
181
|
+
* label 在X方向的额外偏移量
|
|
182
|
+
* @type {number}
|
|
183
|
+
*/
|
|
184
|
+
offsetX?: number;
|
|
185
|
+
/**
|
|
186
|
+
* label 在Y方向的额外偏移量
|
|
187
|
+
* @type {number}
|
|
188
|
+
*/
|
|
189
|
+
offsetY?: number;
|
|
180
190
|
/**
|
|
181
191
|
* 文本旋转角度
|
|
182
192
|
* @type {number}
|
package/src/util/label.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IElement } from '@antv/g-base';
|
|
2
|
-
import { each, isNil } from '@antv/util';
|
|
2
|
+
import { each, isNil, getEllipsisText, pick } from '@antv/util';
|
|
3
3
|
|
|
4
4
|
import { ellipsisString, strLen } from './text';
|
|
5
5
|
|
|
@@ -71,27 +71,42 @@ export function testLabel(label: IElement, limitLength: number): boolean {
|
|
|
71
71
|
|
|
72
72
|
/** 处理 text shape 的自动省略 */
|
|
73
73
|
export function ellipsisLabel(isVertical: boolean, label: IElement, limitLength: number, position: string = 'tail') {
|
|
74
|
-
const text = label.attr('text');
|
|
74
|
+
const text = label.attr('text') ?? ''; // 避免出现null、undefined
|
|
75
|
+
|
|
76
|
+
if (position === 'tail') {
|
|
77
|
+
// component 里的缩略处理做得很糟糕,文字长度测算完全不准确
|
|
78
|
+
// 这里暂时只对 tail 做处理
|
|
79
|
+
const font = pick(label.attr(), ['fontSize', 'fontFamily', 'fontWeight', 'fontStyle', 'fontVariant']);
|
|
80
|
+
const ellipsisText = getEllipsisText(text, limitLength, font, '…') as string;
|
|
81
|
+
if (text !== ellipsisText) {
|
|
82
|
+
label.attr('text', ellipsisText);
|
|
83
|
+
label.set('tip', text);
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
label.set('tip', null);
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
75
90
|
const labelLength = getLabelLength(isVertical, label);
|
|
76
91
|
const codeLength = strLen(text);
|
|
77
|
-
let
|
|
92
|
+
let ellipsisFlag = false;
|
|
78
93
|
if (limitLength < labelLength) {
|
|
79
|
-
const
|
|
94
|
+
const reserveLength = Math.floor((limitLength / labelLength) * codeLength) - ELLIPSIS_CODE_LENGTH; // 计算出来的应该保存的长度
|
|
80
95
|
let newText;
|
|
81
|
-
if (
|
|
82
|
-
newText = ellipsisString(text,
|
|
96
|
+
if (reserveLength >= 0) {
|
|
97
|
+
newText = ellipsisString(text, reserveLength, position);
|
|
83
98
|
} else {
|
|
84
99
|
newText = ELLIPSIS_CODE;
|
|
85
100
|
}
|
|
86
101
|
if (newText) {
|
|
87
102
|
label.attr('text', newText);
|
|
88
|
-
|
|
103
|
+
ellipsisFlag = true;
|
|
89
104
|
}
|
|
90
105
|
}
|
|
91
|
-
if (
|
|
106
|
+
if (ellipsisFlag) {
|
|
92
107
|
label.set('tip', text);
|
|
93
108
|
} else {
|
|
94
109
|
label.set('tip', null);
|
|
95
110
|
}
|
|
96
|
-
return
|
|
111
|
+
return ellipsisFlag;
|
|
97
112
|
}
|