@antv/component 0.8.18 → 0.8.22
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/CHANGELOG.md +30 -0
- package/esm/abstract/component.js +1 -1
- package/esm/abstract/component.js.map +1 -1
- 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/circle.d.ts +3 -3
- package/esm/axis/circle.js +22 -21
- package/esm/axis/circle.js.map +1 -1
- package/esm/crosshair/html.d.ts +0 -67
- package/esm/legend/category.d.ts +7 -0
- package/esm/legend/category.js +69 -19
- package/esm/legend/category.js.map +1 -1
- package/esm/tooltip/html.d.ts +0 -228
- package/esm/types.d.ts +17 -0
- package/esm/util/theme.js +1 -1
- package/esm/util/theme.js.map +1 -1
- package/lib/abstract/component.js +1 -1
- package/lib/abstract/component.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/circle.d.ts +3 -3
- package/lib/axis/circle.js +22 -21
- package/lib/axis/circle.js.map +1 -1
- package/lib/crosshair/html.d.ts +0 -67
- package/lib/legend/category.d.ts +7 -0
- package/lib/legend/category.js +69 -19
- package/lib/legend/category.js.map +1 -1
- package/lib/tooltip/html.d.ts +0 -228
- package/lib/types.d.ts +17 -0
- package/lib/util/theme.js +1 -1
- package/lib/util/theme.js.map +1 -1
- package/package.json +3 -3
- package/src/abstract/component.ts +1 -1
- package/src/abstract/html-component.ts +0 -1
- package/src/axis/circle.ts +27 -26
- package/src/legend/category.ts +101 -27
- package/src/types.ts +25 -7
- package/src/util/theme.ts +1 -1
package/lib/types.d.ts
CHANGED
|
@@ -566,6 +566,11 @@ export interface CategoryLegendCfg extends LegendBaseCfg {
|
|
|
566
566
|
* @type {LegendItemValueCfg}
|
|
567
567
|
*/
|
|
568
568
|
itemValue?: LegendItemValueCfg;
|
|
569
|
+
/**
|
|
570
|
+
*
|
|
571
|
+
* @type {LegendRadio}
|
|
572
|
+
*/
|
|
573
|
+
radio?: LegendRadio;
|
|
569
574
|
/**
|
|
570
575
|
* 最大宽度
|
|
571
576
|
* @type {number}
|
|
@@ -771,6 +776,18 @@ export interface LegendItemValueCfg {
|
|
|
771
776
|
* @type {ShapeAttrs}
|
|
772
777
|
*/
|
|
773
778
|
style?: ShapeAttrs | ShapeAttrsCallback;
|
|
779
|
+
/**
|
|
780
|
+
* 图例值和后面的间隔,可以控制和 RadioIcon 的间距
|
|
781
|
+
* @type {number}
|
|
782
|
+
*/
|
|
783
|
+
spacing?: number;
|
|
784
|
+
}
|
|
785
|
+
export interface LegendRadio {
|
|
786
|
+
/**
|
|
787
|
+
* radio 的配置项
|
|
788
|
+
* @type {ShapeAttrs}
|
|
789
|
+
*/
|
|
790
|
+
style?: ShapeAttrs;
|
|
774
791
|
}
|
|
775
792
|
export interface LegendMarkerCfg {
|
|
776
793
|
/**
|
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.22",
|
|
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,8 +59,9 @@
|
|
|
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
|
-
"@antv/g-base": "0.5.
|
|
64
|
+
"@antv/g-base": "^0.5.9",
|
|
65
65
|
"@antv/matrix-util": "^3.1.0-beta.1",
|
|
66
66
|
"@antv/path-util": "~2.0.7",
|
|
67
67
|
"@antv/scale": "~0.3.1",
|
|
@@ -65,7 +65,7 @@ abstract class Component<T extends ComponentCfg = ComponentCfg> extends Base imp
|
|
|
65
65
|
* @param {object} cfg 更新属性
|
|
66
66
|
*/
|
|
67
67
|
public update(cfg: Partial<T>) {
|
|
68
|
-
const defaultCfg = this.get('defaultCfg');
|
|
68
|
+
const defaultCfg = this.get('defaultCfg') || {};
|
|
69
69
|
each(cfg, (value, name) => {
|
|
70
70
|
const originCfg = this.get(name);
|
|
71
71
|
let newCfg = value;
|
package/src/axis/circle.ts
CHANGED
|
@@ -81,22 +81,22 @@ class Circle extends AxisBase<CircleAxisCfg> {
|
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
/**
|
|
85
85
|
* 是否可以执行某一 overlap
|
|
86
86
|
* @param name
|
|
87
87
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// 对 autoRotate,如果配置了旋转角度,直接进行固定角度旋转
|
|
92
|
-
if (name === 'autoRotate') {
|
|
93
|
-
return isNil(labelCfg.rotate);
|
|
94
|
-
}
|
|
88
|
+
private canProcessOverlap(name: string) {
|
|
89
|
+
const labelCfg = this.get('label');
|
|
95
90
|
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
// 对 autoRotate,如果配置了旋转角度,直接进行固定角度旋转
|
|
92
|
+
if (name === 'autoRotate') {
|
|
93
|
+
return isNil(labelCfg.rotate);
|
|
98
94
|
}
|
|
99
95
|
|
|
96
|
+
// 默认所有 overlap 都可执行
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
100
|
protected processOverlap(labelGroup) {
|
|
101
101
|
const labelCfg = this.get('label');
|
|
102
102
|
const titleCfg = this.get('title');
|
|
@@ -121,7 +121,7 @@ class Circle extends AxisBase<CircleAxisCfg> {
|
|
|
121
121
|
if (titleCfg) {
|
|
122
122
|
if (isNil(titleCfg.offset)) {
|
|
123
123
|
// 调整 title 的 offset
|
|
124
|
-
const {height: length} = labelGroup.getCanvasBBox();
|
|
124
|
+
const { height: length } = labelGroup.getCanvasBBox();
|
|
125
125
|
// 如果用户没有设置 offset,则自动计算
|
|
126
126
|
titleCfg.offset = labelOffset + length + titleSpacing + titleHeight / 2;
|
|
127
127
|
}
|
|
@@ -131,22 +131,23 @@ class Circle extends AxisBase<CircleAxisCfg> {
|
|
|
131
131
|
private autoProcessOverlap(name: string, value: any, labelGroup: IGroup, limitLength: number) {
|
|
132
132
|
let hasAdjusted = false;
|
|
133
133
|
const util = OverlapUtil[name];
|
|
134
|
-
if (
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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);
|
|
146
150
|
}
|
|
147
|
-
} else if (util[value]) {
|
|
148
|
-
// 字符串类型的配置:按照名称执行 overlap 处理方法
|
|
149
|
-
hasAdjusted = util[value](false, labelGroup, limitLength);
|
|
150
151
|
}
|
|
151
152
|
if (name === 'autoRotate') {
|
|
152
153
|
// 文本旋转后,文本的对齐方式可能就不合适了
|
package/src/legend/category.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import { IGroup } from '@antv/g-base';
|
|
1
|
+
import { IGroup, IShape } from '@antv/g-base';
|
|
2
2
|
import { clamp, deepMix, each, filter, get, mix, isNumber, isFunction } from '@antv/util';
|
|
3
3
|
import { IList } from '../interfaces';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
CategoryLegendCfg,
|
|
6
|
+
LegendPageNavigatorCfg,
|
|
7
|
+
LegendItemNameCfg,
|
|
8
|
+
LegendMarkerCfg,
|
|
9
|
+
ListItem,
|
|
10
|
+
LegendRadio,
|
|
11
|
+
} from '../types';
|
|
5
12
|
import { ellipsisLabel } from '../util/label';
|
|
6
13
|
import { getMatrixByAngle, getMatrixByTranslate } from '../util/matrix';
|
|
7
14
|
import { getStatesStyle } from '../util/state';
|
|
@@ -36,10 +43,19 @@ const textStyle = {
|
|
|
36
43
|
textAlign: 'start',
|
|
37
44
|
textBaseline: 'middle',
|
|
38
45
|
fontFamily: Theme.fontFamily,
|
|
39
|
-
fontWeight:
|
|
46
|
+
fontWeight: 'normal',
|
|
40
47
|
lineHeight: 12,
|
|
41
48
|
};
|
|
42
49
|
|
|
50
|
+
const RIGHT_ARROW_NAME = 'navigation-arrow-right';
|
|
51
|
+
const LEFT_ARROW_NAME = 'navigation-arrow-left';
|
|
52
|
+
|
|
53
|
+
const ROTATE_MAP = {
|
|
54
|
+
right: (90 * Math.PI) / 180,
|
|
55
|
+
left: ((360 - 90) * Math.PI) / 180,
|
|
56
|
+
up: 0,
|
|
57
|
+
down: (180 * Math.PI) / 180,
|
|
58
|
+
};
|
|
43
59
|
class Category extends LegendBase<CategoryLegendCfg> implements IList {
|
|
44
60
|
private currentPageIndex = 1;
|
|
45
61
|
private totalPagesCnt = 1;
|
|
@@ -64,6 +80,7 @@ class Category extends LegendBase<CategoryLegendCfg> implements IList {
|
|
|
64
80
|
maxWidth: null,
|
|
65
81
|
maxHeight: null,
|
|
66
82
|
marker: {},
|
|
83
|
+
radio: null,
|
|
67
84
|
items: [],
|
|
68
85
|
itemStates: {},
|
|
69
86
|
itemBackground: {},
|
|
@@ -92,7 +109,7 @@ class Category extends LegendBase<CategoryLegendCfg> implements IList {
|
|
|
92
109
|
},
|
|
93
110
|
pageNavigator: DEFAULT_PAGE_NAVIGATOR,
|
|
94
111
|
itemName: {
|
|
95
|
-
spacing: 16, // 如果右边有 value 使用这个间距
|
|
112
|
+
spacing: 16, // 如果右边有 value 或者 RadioIcon 使用这个间距
|
|
96
113
|
style: textStyle,
|
|
97
114
|
},
|
|
98
115
|
marker: {
|
|
@@ -106,6 +123,7 @@ class Category extends LegendBase<CategoryLegendCfg> implements IList {
|
|
|
106
123
|
alignRight: false, // 只有itemWidth 不为 null 时此属性有效
|
|
107
124
|
formatter: null,
|
|
108
125
|
style: textStyle,
|
|
126
|
+
spacing: 6, // 如果右边有 RadioIcon 使用在这个间距
|
|
109
127
|
},
|
|
110
128
|
itemStates: {
|
|
111
129
|
active: {
|
|
@@ -334,7 +352,7 @@ class Category extends LegendBase<CategoryLegendCfg> implements IList {
|
|
|
334
352
|
if (itemHeight < fontSize) {
|
|
335
353
|
itemHeight = fontSize;
|
|
336
354
|
}
|
|
337
|
-
})
|
|
355
|
+
});
|
|
338
356
|
} else if (style) {
|
|
339
357
|
itemHeight = style.fontSize;
|
|
340
358
|
}
|
|
@@ -390,6 +408,7 @@ class Category extends LegendBase<CategoryLegendCfg> implements IList {
|
|
|
390
408
|
...textStyle,
|
|
391
409
|
...(isFunction(style) ? style(item, index, this.getItems()) : style),
|
|
392
410
|
};
|
|
411
|
+
|
|
393
412
|
return this.addShape(container, {
|
|
394
413
|
type: 'text',
|
|
395
414
|
id: this.getElementId(`item-${item.id}-${textName}`),
|
|
@@ -398,6 +417,43 @@ class Category extends LegendBase<CategoryLegendCfg> implements IList {
|
|
|
398
417
|
});
|
|
399
418
|
}
|
|
400
419
|
|
|
420
|
+
private drawRadio(container: IGroup, style: LegendRadio, item: ListItem, itemHeight: number, x: number) {
|
|
421
|
+
const r = itemHeight / 2;
|
|
422
|
+
const lineWidth = (r * 3.6) / 8;
|
|
423
|
+
const [x0, y0] = [x + r, itemHeight / 2 - r];
|
|
424
|
+
const [x1, y1] = [x0 + r, y0 + r];
|
|
425
|
+
const [x2, y2] = [x0, y1 + r];
|
|
426
|
+
const [x3, y3] = [x, y0 + r];
|
|
427
|
+
const { showRadio } = item;
|
|
428
|
+
const attrs = {
|
|
429
|
+
path: [
|
|
430
|
+
['M', x0, y0],
|
|
431
|
+
['A', r, r, 0, 0, 1, x1, y1],
|
|
432
|
+
['L', x1 - lineWidth, y1],
|
|
433
|
+
['L', x1, y1],
|
|
434
|
+
['A', r, r, 0, 0, 1, x2, y2],
|
|
435
|
+
['L', x2, y2 - lineWidth],
|
|
436
|
+
['L', x2, y2],
|
|
437
|
+
['A', r, r, 0, 0, 1, x3, y3],
|
|
438
|
+
['L', x3 + lineWidth, y3],
|
|
439
|
+
['L', x3, y3],
|
|
440
|
+
['A', r, r, 0, 0, 1, x0, y0],
|
|
441
|
+
['L', x0, y0 + lineWidth],
|
|
442
|
+
],
|
|
443
|
+
stroke: '#000000',
|
|
444
|
+
fill: '#ffffff',
|
|
445
|
+
...style,
|
|
446
|
+
opacity: showRadio ? 0.45 : 0,
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
return this.addShape(container, {
|
|
450
|
+
type: 'path',
|
|
451
|
+
id: this.getElementId(`item-${item.id}-radio`),
|
|
452
|
+
name: 'legend-item-radio',
|
|
453
|
+
attrs,
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
|
|
401
457
|
// 绘制图例项
|
|
402
458
|
private drawItem(item: ListItem, index: number, itemHeight: number, itemGroup: IGroup) {
|
|
403
459
|
const groupId = `item-${item.id}`;
|
|
@@ -422,6 +478,7 @@ class Category extends LegendBase<CategoryLegendCfg> implements IList {
|
|
|
422
478
|
const itemName = this.get('itemName');
|
|
423
479
|
const itemValue = this.get('itemValue');
|
|
424
480
|
const itemBackground = this.get('itemBackground');
|
|
481
|
+
const radio = this.get('radio');
|
|
425
482
|
const itemWidth = this.getLimitItemWidth();
|
|
426
483
|
|
|
427
484
|
let curX = 0; // 记录当前 x 的位置
|
|
@@ -446,6 +503,7 @@ class Category extends LegendBase<CategoryLegendCfg> implements IList {
|
|
|
446
503
|
}
|
|
447
504
|
curX = nameShape.getBBox().maxX + itemName.spacing;
|
|
448
505
|
}
|
|
506
|
+
|
|
449
507
|
if (itemValue) {
|
|
450
508
|
const valueShape = this.drawItemText(subGroup, 'value', itemValue, item, itemHeight, curX, index);
|
|
451
509
|
if (itemWidth) {
|
|
@@ -459,7 +517,13 @@ class Category extends LegendBase<CategoryLegendCfg> implements IList {
|
|
|
459
517
|
ellipsisLabel(true, valueShape, clamp(itemWidth - curX, 0, itemWidth));
|
|
460
518
|
}
|
|
461
519
|
}
|
|
520
|
+
curX = valueShape.getBBox().maxX + itemValue.spacing;
|
|
462
521
|
}
|
|
522
|
+
|
|
523
|
+
if (radio) {
|
|
524
|
+
this.drawRadio(subGroup, radio, item, itemHeight, curX);
|
|
525
|
+
}
|
|
526
|
+
|
|
463
527
|
// 添加透明的背景,便于拾取和包围盒计算
|
|
464
528
|
if (itemBackground) {
|
|
465
529
|
const bbox = subGroup.getBBox();
|
|
@@ -623,7 +687,7 @@ class Category extends LegendBase<CategoryLegendCfg> implements IList {
|
|
|
623
687
|
const leftArrow = this.drawArrow(
|
|
624
688
|
subGroup,
|
|
625
689
|
currentPoint,
|
|
626
|
-
|
|
690
|
+
LEFT_ARROW_NAME,
|
|
627
691
|
layout === 'horizontal' ? 'up' : 'left',
|
|
628
692
|
size,
|
|
629
693
|
arrowStyle
|
|
@@ -650,7 +714,7 @@ class Category extends LegendBase<CategoryLegendCfg> implements IList {
|
|
|
650
714
|
const rightArrow = this.drawArrow(
|
|
651
715
|
subGroup,
|
|
652
716
|
currentPoint,
|
|
653
|
-
|
|
717
|
+
RIGHT_ARROW_NAME,
|
|
654
718
|
layout === 'horizontal' ? 'down' : 'right',
|
|
655
719
|
size,
|
|
656
720
|
arrowStyle
|
|
@@ -667,15 +731,12 @@ class Category extends LegendBase<CategoryLegendCfg> implements IList {
|
|
|
667
731
|
const text = `${this.currentPageIndex}/${this.totalPagesCnt}`;
|
|
668
732
|
const textShape = navigation ? navigation.getChildren()[1] : this.getElementByLocalId('navigation-text');
|
|
669
733
|
const leftArrow = navigation
|
|
670
|
-
? navigation.findById(this.getElementId(
|
|
671
|
-
: this.getElementByLocalId(
|
|
734
|
+
? navigation.findById(this.getElementId(LEFT_ARROW_NAME))
|
|
735
|
+
: this.getElementByLocalId(LEFT_ARROW_NAME);
|
|
672
736
|
const rightArrow = navigation
|
|
673
|
-
? navigation.findById(this.getElementId(
|
|
674
|
-
: this.getElementByLocalId(
|
|
675
|
-
const origBBox = textShape.getBBox();
|
|
737
|
+
? navigation.findById(this.getElementId(RIGHT_ARROW_NAME))
|
|
738
|
+
: this.getElementByLocalId(RIGHT_ARROW_NAME);
|
|
676
739
|
textShape.attr('text', text);
|
|
677
|
-
const newBBox = textShape.getBBox();
|
|
678
|
-
textShape.attr('x', textShape.attr('x') - (newBBox.width - origBBox.width) / 2);
|
|
679
740
|
// 更新 left-arrow marker
|
|
680
741
|
leftArrow.attr('opacity', this.currentPageIndex === 1 ? inactiveOpacity : opacity);
|
|
681
742
|
leftArrow.attr('fill', this.currentPageIndex === 1 ? inactiveFill : fill);
|
|
@@ -684,6 +745,12 @@ class Category extends LegendBase<CategoryLegendCfg> implements IList {
|
|
|
684
745
|
rightArrow.attr('opacity', this.currentPageIndex === this.totalPagesCnt ? inactiveOpacity : opacity);
|
|
685
746
|
rightArrow.attr('fill', this.currentPageIndex === this.totalPagesCnt ? inactiveFill : fill);
|
|
686
747
|
rightArrow.attr('cursor', this.currentPageIndex === this.totalPagesCnt ? 'not-allowed' : 'pointer');
|
|
748
|
+
// 更新位置
|
|
749
|
+
let cursorX = leftArrow.getBBox().maxX + 2;
|
|
750
|
+
textShape.attr('x', cursorX);
|
|
751
|
+
cursorX += textShape.getBBox().width + 2;
|
|
752
|
+
this.updateArrowPath(rightArrow, { x: cursorX, y: 0 });
|
|
753
|
+
|
|
687
754
|
}
|
|
688
755
|
|
|
689
756
|
private drawArrow(
|
|
@@ -695,40 +762,47 @@ class Category extends LegendBase<CategoryLegendCfg> implements IList {
|
|
|
695
762
|
style?: LegendPageNavigatorCfg['marker']['style']
|
|
696
763
|
) {
|
|
697
764
|
const { x, y } = currentPoint;
|
|
698
|
-
const rotateMap = {
|
|
699
|
-
right: (90 * Math.PI) / 180,
|
|
700
|
-
left: ((360 - 90) * Math.PI) / 180,
|
|
701
|
-
up: 0,
|
|
702
|
-
down: (180 * Math.PI) / 180,
|
|
703
|
-
};
|
|
704
765
|
const shape = this.addShape(group, {
|
|
705
766
|
type: 'path',
|
|
706
767
|
id: this.getElementId(name),
|
|
707
768
|
name,
|
|
708
769
|
attrs: {
|
|
770
|
+
size,
|
|
771
|
+
direction,
|
|
709
772
|
path: [['M', x + size / 2, y], ['L', x, y + size], ['L', x + size, y + size], ['Z']],
|
|
710
773
|
cursor: 'pointer',
|
|
711
774
|
...style,
|
|
712
775
|
},
|
|
713
776
|
});
|
|
714
|
-
shape.attr('matrix', getMatrixByAngle({ x: x + size / 2, y: y + size / 2 },
|
|
777
|
+
shape.attr('matrix', getMatrixByAngle({ x: x + size / 2, y: y + size / 2 }, ROTATE_MAP[direction]));
|
|
715
778
|
|
|
716
779
|
return shape;
|
|
717
780
|
}
|
|
718
781
|
|
|
782
|
+
/**
|
|
783
|
+
* 更新分页器 arrow 组件
|
|
784
|
+
*/
|
|
785
|
+
private updateArrowPath(arrow: IShape, point: { x: number; y: number }): void {
|
|
786
|
+
const { x, y } = point;
|
|
787
|
+
const { size, direction } = arrow.attr();
|
|
788
|
+
let matrix = getMatrixByAngle({ x: x + size / 2, y: y + size / 2 }, ROTATE_MAP[direction]);
|
|
789
|
+
arrow.attr('path', [['M', x + size / 2, y], ['L', x, y + size], ['L', x + size, y + size], ['Z']]);
|
|
790
|
+
arrow.attr('matrix', matrix);
|
|
791
|
+
}
|
|
792
|
+
|
|
719
793
|
private getCurrentNavigationMatrix() {
|
|
720
794
|
const { currentPageIndex, pageWidth, pageHeight } = this;
|
|
721
795
|
const layout = this.get('layout');
|
|
722
796
|
const translate =
|
|
723
797
|
layout === 'horizontal'
|
|
724
798
|
? {
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
799
|
+
x: 0,
|
|
800
|
+
y: pageHeight * (1 - currentPageIndex),
|
|
801
|
+
}
|
|
728
802
|
: {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
803
|
+
x: pageWidth * (1 - currentPageIndex),
|
|
804
|
+
y: 0,
|
|
805
|
+
};
|
|
732
806
|
|
|
733
807
|
return getMatrixByTranslate(translate);
|
|
734
808
|
}
|
package/src/types.ts
CHANGED
|
@@ -269,7 +269,7 @@ export interface AxisTitleCfg {
|
|
|
269
269
|
* 文本对齐方式
|
|
270
270
|
* @type {string} start, center, end
|
|
271
271
|
*/
|
|
272
|
-
|
|
272
|
+
position?: string;
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
export interface BaseCfg {
|
|
@@ -593,6 +593,11 @@ export interface CategoryLegendCfg extends LegendBaseCfg {
|
|
|
593
593
|
* @type {LegendItemValueCfg}
|
|
594
594
|
*/
|
|
595
595
|
itemValue?: LegendItemValueCfg;
|
|
596
|
+
/**
|
|
597
|
+
*
|
|
598
|
+
* @type {LegendRadio}
|
|
599
|
+
*/
|
|
600
|
+
radio?: LegendRadio;
|
|
596
601
|
/**
|
|
597
602
|
* 最大宽度
|
|
598
603
|
* @type {number}
|
|
@@ -616,11 +621,11 @@ export interface CategoryLegendCfg extends LegendBaseCfg {
|
|
|
616
621
|
/**
|
|
617
622
|
* 是否翻页
|
|
618
623
|
*/
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
+
flipPage?: boolean;
|
|
625
|
+
/**
|
|
626
|
+
* 翻页行数(只适用于横向)
|
|
627
|
+
*/
|
|
628
|
+
maxRow?: number;
|
|
624
629
|
/**
|
|
625
630
|
* 分页器配置
|
|
626
631
|
* @type {LegendPageNavigatorCfg}
|
|
@@ -807,7 +812,20 @@ export interface LegendItemValueCfg {
|
|
|
807
812
|
* 图例项附加值的配置
|
|
808
813
|
* @type {ShapeAttrs}
|
|
809
814
|
*/
|
|
810
|
-
style?: ShapeAttrs
|
|
815
|
+
style?: ShapeAttrs | ShapeAttrsCallback;
|
|
816
|
+
/**
|
|
817
|
+
* 图例值和后面的间隔,可以控制和 RadioIcon 的间距
|
|
818
|
+
* @type {number}
|
|
819
|
+
*/
|
|
820
|
+
spacing?: number;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
export interface LegendRadio {
|
|
824
|
+
/**
|
|
825
|
+
* radio 的配置项
|
|
826
|
+
* @type {ShapeAttrs}
|
|
827
|
+
*/
|
|
828
|
+
style?: ShapeAttrs;
|
|
811
829
|
}
|
|
812
830
|
|
|
813
831
|
export interface LegendMarkerCfg {
|
package/src/util/theme.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
fontFamily: `
|
|
3
|
-
|
|
3
|
+
BlinkMacSystemFont, "Segoe UI", Roboto,"Helvetica Neue",
|
|
4
4
|
Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
|
|
5
5
|
SimSun, "sans-serif"`,
|
|
6
6
|
textColor: '#2C3542',
|