@visactor/vrender-components 0.13.5 → 0.13.6
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/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/label/base.d.ts +10 -12
- package/cjs/label/base.js +55 -75
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/overlap/place.d.ts +4 -8
- package/cjs/label/overlap/place.js +2 -14
- package/cjs/label/overlap/place.js.map +1 -1
- package/cjs/label/rect.d.ts +3 -5
- package/cjs/label/rect.js.map +1 -1
- package/cjs/label/symbol.d.ts +3 -5
- package/cjs/label/symbol.js.map +1 -1
- package/cjs/label/type.d.ts +7 -11
- package/cjs/label/type.js.map +1 -1
- package/dist/index.js +76 -131
- package/dist/index.min.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/label/base.d.ts +10 -12
- package/es/label/base.js +57 -77
- package/es/label/base.js.map +1 -1
- package/es/label/overlap/place.d.ts +4 -8
- package/es/label/overlap/place.js +0 -11
- package/es/label/overlap/place.js.map +1 -1
- package/es/label/rect.d.ts +3 -5
- package/es/label/rect.js.map +1 -1
- package/es/label/symbol.d.ts +3 -5
- package/es/label/symbol.js.map +1 -1
- package/es/label/type.d.ts +7 -11
- package/es/label/type.js.map +1 -1
- package/package.json +2 -2
package/es/label/symbol.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { IBoundsLike } from '@visactor/vutils';
|
|
2
|
+
import type { ITextGraphicAttribute } from '@visactor/vrender';
|
|
2
3
|
import type { SymbolLabelAttrs } from './type';
|
|
3
4
|
import { LabelBase } from './base';
|
|
4
5
|
export declare class SymbolLabel extends LabelBase<SymbolLabelAttrs> {
|
|
5
6
|
name: string;
|
|
6
7
|
static defaultAttributes: Partial<SymbolLabelAttrs>;
|
|
7
8
|
constructor(attributes: SymbolLabelAttrs);
|
|
8
|
-
protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position?: string, offset?: number):
|
|
9
|
-
x: number;
|
|
10
|
-
y: number;
|
|
11
|
-
};
|
|
9
|
+
protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position?: string, offset?: number): Partial<ITextGraphicAttribute> | undefined;
|
|
12
10
|
}
|
package/es/label/symbol.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["label/symbol.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["label/symbol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAe,MAAM,kBAAkB,CAAC;AAGtD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,MAAM,OAAO,WAAY,SAAQ,SAA2B;IAgB1D,YAAY,UAA4B;QACtC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,WAAW,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAhB9D,SAAI,GAAG,cAAc,CAAC;IAiBtB,CAAC;IAES,QAAQ,CAChB,UAAuB,EACvB,aAA0B,EAC1B,QAAQ,GAAG,KAAK,EAChB,MAAM,GAAG,CAAC;QAEV,IAAI,CAAC,UAAU,EAAE;YACf,OAAO;SACR;QAED,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,UAAU,CAAC;QACtC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QAChC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QAEjC,MAAM,OAAO,GAAG,CAAC,aAAa,CAAC,EAAE,GAAG,aAAa,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QAC1D,MAAM,OAAO,GAAG,CAAC,aAAa,CAAC,EAAE,GAAG,aAAa,CAAC,EAAE,C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C,CAAC;gBACP,EAAE,GAAG,CAAC,CAAC;gBACP,MAAM;SACT;QAED,MAAM,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAC1E,MAAM,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAE3E,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAClB,CAAC;;AAhFM,6BAAiB,GAA8B;IACpD,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,QAAQ;QACtB,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;KAC9B;IACD,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,KAAK;CAChB,CAAC","file":"symbol.js","sourcesContent":["import { merge, IBoundsLike } from '@visactor/vutils';\nimport type { ITextGraphicAttribute } from '@visactor/vrender';\nimport type { SymbolLabelAttrs } from './type';\nimport { LabelBase } from './base';\n\nexport class SymbolLabel extends LabelBase<SymbolLabelAttrs> {\n name = 'symbol-label';\n\n static defaultAttributes: Partial<SymbolLabelAttrs> = {\n textStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'center',\n textBaseline: 'middle',\n boundsPadding: [-1, 0, -1, 0] // to ignore the textBound buf\n },\n position: 'top',\n offset: 5,\n pickable: false\n };\n\n constructor(attributes: SymbolLabelAttrs) {\n super(merge({}, SymbolLabel.defaultAttributes, attributes));\n }\n\n protected labeling(\n textBounds: IBoundsLike,\n graphicBounds: IBoundsLike,\n position = 'top',\n offset = 0\n ): Partial<ITextGraphicAttribute> | undefined {\n if (!textBounds) {\n return;\n }\n\n const { x1, y1, x2, y2 } = textBounds;\n const width = Math.abs(x2 - x1);\n const height = Math.abs(y2 - y1);\n\n const anchorX = (graphicBounds.x1 + graphicBounds.x2) / 2;\n const anchorY = (graphicBounds.y1 + graphicBounds.y2) / 2;\n\n let sx = 0;\n let sy = 0;\n let offsetX = 0;\n let offsetY = 0;\n if (graphicBounds) {\n offsetX = Math.abs(graphicBounds.x1 - graphicBounds.x2) / 2;\n offsetY = Math.abs(graphicBounds.y1 - graphicBounds.y2) / 2;\n }\n\n const angle = {\n 'top-right': -235,\n 'top-left': 235,\n 'bottom-right': 45,\n 'bottom-left': -45\n };\n\n switch (position) {\n case 'top':\n sy = -1;\n break;\n case 'bottom':\n sy = 1;\n break;\n case 'left':\n sx = -1;\n break;\n case 'right':\n sx = 1;\n break;\n case 'bottom-left':\n case 'bottom-right':\n case 'top-left':\n case 'top-right':\n sx = Math.sin(angle[position] * (Math.PI / 180));\n sy = Math.cos(angle[position] * (Math.PI / 180));\n break;\n case 'center':\n sx = 0;\n sy = 0;\n break;\n }\n\n const x = anchorX + sx * (offset + offsetX) + Math.sign(sx) * (width / 2);\n const y = anchorY + sy * (offset + offsetY) + Math.sign(sy) * (height / 2);\n\n return { x, y };\n }\n}\n"]}
|
package/es/label/type.d.ts
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import type { EasingType,
|
|
1
|
+
import type { EasingType, IGroupGraphicAttribute, ITextGraphicAttribute } from '@visactor/vrender';
|
|
2
2
|
export type LabelItemStateStyle<T> = {
|
|
3
3
|
hover?: T;
|
|
4
4
|
hover_reverse?: T;
|
|
5
5
|
selected?: T;
|
|
6
6
|
selected_reverse?: T;
|
|
7
7
|
};
|
|
8
|
-
export type LabelItem = {
|
|
9
|
-
id?: string;
|
|
10
|
-
data?: any;
|
|
11
|
-
[key: string]: any;
|
|
12
|
-
} & ITextGraphicAttribute;
|
|
13
8
|
export interface BaseLabelAttrs extends IGroupGraphicAttribute {
|
|
14
9
|
type: string;
|
|
15
|
-
baseMarkGroupName: string;
|
|
16
10
|
select?: boolean;
|
|
17
11
|
hover?: boolean;
|
|
18
|
-
data:
|
|
12
|
+
data: Functional<(ITextGraphicAttribute & Record<string, any>)[]>;
|
|
13
|
+
sort?: (graphicA: any, graphicB: any) => number;
|
|
14
|
+
baseMarkGroupName?: string;
|
|
19
15
|
textStyle?: Partial<ITextGraphicAttribute>;
|
|
20
16
|
state?: LabelItemStateStyle<ITextGraphicAttribute>;
|
|
21
17
|
position?: Functional<string>;
|
|
@@ -23,9 +19,6 @@ export interface BaseLabelAttrs extends IGroupGraphicAttribute {
|
|
|
23
19
|
overlap?: OverlapAttrs | false;
|
|
24
20
|
smartInvert?: SmartInvertAttrs | false;
|
|
25
21
|
animation?: ILabelAnimation | false;
|
|
26
|
-
dataFilter?: (data: LabelItem[]) => LabelItem[];
|
|
27
|
-
customLayoutFunc?: (data: LabelItem[], getRelatedGraphic: (data: LabelItem) => IGraphic) => Text[];
|
|
28
|
-
customOverlapFunc?: (label: Text[], getRelatedGraphic: (data: LabelItem) => IGraphic) => Text[];
|
|
29
22
|
}
|
|
30
23
|
export interface OverlapAttrs {
|
|
31
24
|
size?: {
|
|
@@ -82,6 +75,9 @@ export interface DataLabelAttrs extends IGroupGraphicAttribute {
|
|
|
82
75
|
};
|
|
83
76
|
}
|
|
84
77
|
export type Functional<T> = T | ((data: any) => T);
|
|
78
|
+
export interface ILabelGraphicAttribute extends ITextGraphicAttribute {
|
|
79
|
+
_relatedIndex?: number;
|
|
80
|
+
}
|
|
85
81
|
export interface ILabelAnimation {
|
|
86
82
|
mode?: 'same-time' | 'after' | 'after-all';
|
|
87
83
|
duration?: number;
|
package/es/label/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["label/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type { EasingType,
|
|
1
|
+
{"version":3,"sources":["label/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type { EasingType, IGroupGraphicAttribute, ITextGraphicAttribute } from '@visactor/vrender';\nimport type { Bounds } from '@visactor/vutils';\n\nexport type LabelItemStateStyle<T> = {\n hover?: T;\n hover_reverse?: T;\n selected?: T;\n selected_reverse?: T;\n};\n\nexport interface BaseLabelAttrs extends IGroupGraphicAttribute {\n type: string;\n /**\n * 是否开启选中交互\n * @default false\n */\n select?: boolean;\n /**\n * 是否开启 hover 交互\n * @default false\n */\n hover?: boolean;\n /**\n * 标签数据\n */\n data: Functional<(ITextGraphicAttribute & Record<string, any>)[]>;\n\n sort?: (graphicA: any, graphicB: any) => number;\n\n /**\n * 图元 group 名称\n * 如果不配置,需要在 data 里指定标签定位 x/y\n */\n baseMarkGroupName?: string;\n\n /** 文本样式,优先级低于 data */\n textStyle?: Partial<ITextGraphicAttribute>;\n\n /** 文本交互样式 */\n state?: LabelItemStateStyle<ITextGraphicAttribute>;\n\n /** 标签默认位置 */\n position?: Functional<string>;\n\n /** 偏移量 */\n offset?: number;\n\n /** 是否开启防重叠\n * @default true\n */\n overlap?: OverlapAttrs | false;\n\n /** 智能反色 */\n smartInvert?: SmartInvertAttrs | false;\n\n /** 动画配置 */\n animation?: ILabelAnimation | false;\n}\n\nexport interface OverlapAttrs {\n /**\n * 防重叠的区域大小\n */\n size?: { width: number; height: number };\n\n /**\n * 发生重叠后,是否隐藏标签\n * @default true\n */\n hideOnHit?: boolean;\n\n /**\n * 是否约束标签在指定 size 的范围内。开启后若标签被区域裁剪,会向内收缩。\n * @default true\n */\n clampForce?: boolean;\n\n /**\n * 是否躲避基础图元\n * @default false\n */\n avoidBaseMark?: boolean;\n\n /**\n * 发生重叠后的躲避策略\n */\n strategy?: Strategy[];\n}\n\nexport interface SmartInvertAttrs {\n /**\n * 文本类型\n * 包含普通文本和大文本,对应不同的对比度标准,label默认为普通文本\n * 'normalText' | 'largeText'\n * @default 'normalText'\n */\n textType?: string;\n /**\n * 自定义对比度阈值\n */\n contrastRatiosThreshold?: number;\n /**\n * 自定义备选label颜色\n */\n alternativeColors?: string | string[];\n}\n\nexport type PositionStrategy = {\n /**\n * 可选位置策略。\n * 若默认位置没有足够的空间放置标签,则考虑 position 内的备选位置。\n */\n type: 'position';\n position?: Functional<LabelPosition[]>;\n};\n\nexport type BoundStrategy = {\n /**\n * 标签配置在图形内部时使用。\n * 当图形大小不足以放下标签,则考虑 position 内的备选位置。\n */\n type: 'bound';\n position?: Functional<LabelPosition[]>;\n};\n\nexport type MoveYStrategy = {\n /**\n * 可选位置策略。\n * 若默认位置没有足够的空间放置标签,则根据 offset 在Y方向上寻找位置。\n */\n type: 'moveY';\n /**\n * Y方向上的尝试的位置偏移量\n */\n offset: Functional<number[]>;\n};\n\nexport type MoveXStrategy = {\n /**\n * 可选位置策略。\n * 若默认位置没有足够的空间放置标签,则根据 offset 在X方向上寻找位置。\n */\n type: 'moveX';\n /**\n * X方向上的尝试的位置偏移量\n */\n offset: Functional<number[]>;\n};\n\nexport type Strategy = PositionStrategy | BoundStrategy | MoveYStrategy | MoveXStrategy;\n\nexport type LabelPosition = SymbolLabelAttrs['position'] | RectLabelAttrs['position'];\n\nexport interface SymbolLabelAttrs extends BaseLabelAttrs {\n type: 'symbol';\n\n /**\n * 标签位置\n * @default 'top'\n */\n position?: Functional<\n 'top' | 'bottom' | 'left' | 'right' | 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'center'\n >;\n}\n\nexport interface RectLabelAttrs extends BaseLabelAttrs {\n type: 'rect';\n\n /**\n * 图元 group 名称\n */\n baseMarkGroupName: string;\n\n /**\n * 标签位置\n * @default 'top'\n */\n position?: Functional<\n 'top' | 'bottom' | 'left' | 'right' | 'inside' | 'inside-top' | 'inside-bottom' | 'inside-right' | 'inside-left'\n >;\n}\n\nexport interface LineLabelAttrs extends BaseLabelAttrs {\n type: 'line';\n\n /**\n * 图元 group 名称\n */\n baseMarkGroupName: string;\n\n /**\n * 标签位置\n * @default 'end'\n */\n position?: Functional<'start' | 'end'>;\n}\n\nexport interface DataLabelAttrs extends IGroupGraphicAttribute {\n dataLabels: (RectLabelAttrs | SymbolLabelAttrs)[];\n /**\n * 防重叠的区域大小\n */\n size: { width: number; height: number };\n}\n\nexport type Functional<T> = T | ((data: any) => T);\n\nexport interface ILabelGraphicAttribute extends ITextGraphicAttribute {\n _relatedIndex?: number;\n}\n\nexport interface ILabelAnimation {\n mode?: 'same-time' | 'after' | 'after-all';\n duration?: number;\n delay?: number;\n easing?: EasingType;\n /** 是否开启 increaseCount 动画\n * @default true\n */\n increaseEffect?: boolean;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visactor/vrender-components",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.6",
|
|
4
4
|
"description": "components library for dp visualization",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "cjs/index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"eslint": "~8.18.0",
|
|
29
29
|
"vite": "3.2.6",
|
|
30
30
|
"typescript": "4.9.5",
|
|
31
|
-
"@internal/bundler": "0.0.1",
|
|
32
31
|
"@internal/ts-config": "0.0.1",
|
|
32
|
+
"@internal/bundler": "0.0.1",
|
|
33
33
|
"@internal/eslint-config": "0.0.1"
|
|
34
34
|
},
|
|
35
35
|
"keywords": [
|