@visactor/vrender-components 0.13.7 → 0.13.8-alpha.4
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 +12 -11
- package/cjs/label/base.js +83 -62
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/overlap/place.d.ts +8 -4
- package/cjs/label/overlap/place.js +14 -2
- package/cjs/label/overlap/place.js.map +1 -1
- package/cjs/label/rect.d.ts +5 -3
- package/cjs/label/rect.js.map +1 -1
- package/cjs/label/symbol.d.ts +5 -3
- package/cjs/label/symbol.js.map +1 -1
- package/cjs/label/type.d.ts +12 -7
- package/cjs/label/type.js.map +1 -1
- package/cjs/segment/segment.js +4 -1
- package/cjs/segment/segment.js.map +1 -1
- package/cjs/segment/type.d.ts +1 -0
- package/cjs/segment/type.js.map +1 -1
- package/cjs/util/common.d.ts +3 -1
- package/cjs/util/common.js +14 -2
- package/cjs/util/common.js.map +1 -1
- package/dist/index.js +170 -86
- 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 +12 -11
- package/es/label/base.js +85 -65
- package/es/label/base.js.map +1 -1
- package/es/label/overlap/place.d.ts +8 -4
- package/es/label/overlap/place.js +11 -0
- package/es/label/overlap/place.js.map +1 -1
- package/es/label/rect.d.ts +5 -3
- package/es/label/rect.js.map +1 -1
- package/es/label/symbol.d.ts +5 -3
- package/es/label/symbol.js.map +1 -1
- package/es/label/type.d.ts +12 -7
- package/es/label/type.js.map +1 -1
- package/es/segment/segment.js +4 -1
- package/es/segment/segment.js.map +1 -1
- package/es/segment/type.d.ts +1 -0
- package/es/segment/type.js.map +1 -1
- package/es/util/common.d.ts +3 -1
- package/es/util/common.js +12 -0
- package/es/util/common.js.map +1 -1
- package/package.json +2 -2
package/es/label/rect.js.map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AM,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,MAAM,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACnD,MAAM,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,MAAM,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAEpD,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAClB,CAAC;;AA7EM,aAAG,GAAG,YAAY,CAAC;AAEnB,2BAAiB,GAA4B;IAClD,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":"rect.js","sourcesContent":["import type { IBoundsLike } from '@visactor/vutils';\nimport { merge } from '@visactor/vutils';\nimport type { ITextGraphicAttribute } from '@visactor/vrender';\nimport type { RectLabelAttrs } from './type';\nimport { LabelBase } from './base';\n\nexport class RectLabel extends LabelBase<RectLabelAttrs> {\n static tag = 'rect-label';\n\n static defaultAttributes: Partial<RectLabelAttrs> = {\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: RectLabelAttrs) {\n super(merge({}, RectLabel.defaultAttributes, attributes));\n }\n\n protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position = 'top', offset = 0) {\n if (!textBounds || !graphicBounds) {\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 rectWidth = Math.abs(graphicBounds.x2 - graphicBounds.x1);\n const rectHeight = Math.abs(graphicBounds.y2 - graphicBounds.y1);\n let anchorX = (graphicBounds.x1 + graphicBounds.x2) / 2;\n let anchorY = (graphicBounds.y1 + graphicBounds.y2) / 2;\n\n let sx = 0;\n let sy = 0;\n\n switch (position) {\n case 'top':\n case 'inside-top':\n sy = -0.5;\n break;\n case 'bottom':\n case 'inside-bottom':\n sy = 0.5;\n break;\n case 'left':\n case 'inside-left':\n sx = -0.5;\n break;\n case 'right':\n case 'inside-right':\n sx = 0.5;\n break;\n }\n\n anchorX += sx * rectWidth;\n anchorY += sy * rectHeight;\n\n let vx = 0;\n let vy = 0;\n\n const isInside = position.includes('inside');\n\n if (position.includes('top')) {\n vy = isInside ? 1 : -1;\n } else if (position.includes('bottom')) {\n vy = isInside ? -1 : 1;\n } else if (position.includes('left')) {\n vx = isInside ? 1 : -1;\n } else if (position.includes('right')) {\n vx = isInside ? -1 : 1;\n }\n\n const x = anchorX + vx * offset + (vx * width) / 2;\n const y = anchorY + vy * offset + (vy * height) / 2;\n\n return { x, y };\n }\n}\n"]}
|
package/es/label/symbol.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { IBoundsLike } from '@visactor/vutils';
|
|
2
|
-
import type { ITextGraphicAttribute } from '@visactor/vrender';
|
|
1
|
+
import type { IBoundsLike } from '@visactor/vutils';
|
|
3
2
|
import type { SymbolLabelAttrs } from './type';
|
|
4
3
|
import { LabelBase } from './base';
|
|
5
4
|
export declare class SymbolLabel extends LabelBase<SymbolLabelAttrs> {
|
|
6
5
|
name: string;
|
|
7
6
|
static defaultAttributes: Partial<SymbolLabelAttrs>;
|
|
8
7
|
constructor(attributes: SymbolLabelAttrs);
|
|
9
|
-
protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position?: string, offset?: number):
|
|
8
|
+
protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position?: string, offset?: number): {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
10
12
|
}
|
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":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,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,CAAC,UAAuB,EAAE,aAA0B,EAAE,QAAQ,GAAG,KAAK,EAAE,MAAM,GAAG,CAAC;QAClG,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,CAAC,GAAG,CAAC,CAAC;QAE1D,IAAI,EAAE,GAAG,CAAC,CAAC;QACX,IAAI,EAAE,GAAG,CAAC,CAAC;QACX,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,IAAI,aAAa,EAAE;YACjB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AG,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;;AA3EM,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 type { IBoundsLike } from '@visactor/vutils';\nimport { merge } 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(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position = 'top', offset = 0) {\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,17 +1,21 @@
|
|
|
1
|
-
import type { EasingType, IGroupGraphicAttribute, ITextGraphicAttribute } from '@visactor/vrender';
|
|
1
|
+
import type { EasingType, IGraphic, IGroupGraphicAttribute, ITextGraphicAttribute, Text } 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;
|
|
8
13
|
export interface BaseLabelAttrs extends IGroupGraphicAttribute {
|
|
9
14
|
type: string;
|
|
15
|
+
baseMarkGroupName: string;
|
|
10
16
|
select?: boolean;
|
|
11
17
|
hover?: boolean;
|
|
12
|
-
data:
|
|
13
|
-
sort?: (graphicA: any, graphicB: any) => number;
|
|
14
|
-
baseMarkGroupName?: string;
|
|
18
|
+
data: LabelItem[];
|
|
15
19
|
textStyle?: Partial<ITextGraphicAttribute>;
|
|
16
20
|
state?: LabelItemStateStyle<ITextGraphicAttribute>;
|
|
17
21
|
position?: Functional<string>;
|
|
@@ -19,6 +23,9 @@ export interface BaseLabelAttrs extends IGroupGraphicAttribute {
|
|
|
19
23
|
overlap?: OverlapAttrs | false;
|
|
20
24
|
smartInvert?: SmartInvertAttrs | false;
|
|
21
25
|
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[];
|
|
22
29
|
}
|
|
23
30
|
export interface OverlapAttrs {
|
|
24
31
|
size?: {
|
|
@@ -28,6 +35,7 @@ export interface OverlapAttrs {
|
|
|
28
35
|
hideOnHit?: boolean;
|
|
29
36
|
clampForce?: boolean;
|
|
30
37
|
avoidBaseMark?: boolean;
|
|
38
|
+
avoidMarks?: string[] | IGraphic[];
|
|
31
39
|
strategy?: Strategy[];
|
|
32
40
|
}
|
|
33
41
|
export interface SmartInvertAttrs {
|
|
@@ -75,9 +83,6 @@ export interface DataLabelAttrs extends IGroupGraphicAttribute {
|
|
|
75
83
|
};
|
|
76
84
|
}
|
|
77
85
|
export type Functional<T> = T | ((data: any) => T);
|
|
78
|
-
export interface ILabelGraphicAttribute extends ITextGraphicAttribute {
|
|
79
|
-
_relatedIndex?: number;
|
|
80
|
-
}
|
|
81
86
|
export interface ILabelAnimation {
|
|
82
87
|
mode?: 'same-time' | 'after' | 'after-all';
|
|
83
88
|
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, IGroupGraphicAttribute, ITextGraphicAttribute } from '@visactor/vrender';\
|
|
1
|
+
{"version":3,"sources":["label/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type { EasingType, IGraphic, IGroupGraphicAttribute, ITextGraphicAttribute, Text } from '@visactor/vrender';\n\nexport type LabelItemStateStyle<T> = {\n hover?: T;\n hover_reverse?: T;\n selected?: T;\n selected_reverse?: T;\n};\n\nexport type LabelItem = {\n // 用于动画\n id?: string;\n // 原始数据\n data?: any;\n [key: string]: any;\n} & ITextGraphicAttribute;\n\nexport interface BaseLabelAttrs extends IGroupGraphicAttribute {\n type: string;\n /**\n * 图元 group 名称\n */\n baseMarkGroupName: 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: LabelItem[];\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 // 排序 or 删减\n dataFilter?: (data: LabelItem[]) => LabelItem[];\n\n /** 自定义布局函数\n * @description 当配置了 customLayoutFunc 后,默认布局和防重叠逻辑将不再生效。(overlap/position/offset不生效)\n */\n customLayoutFunc?: (data: LabelItem[], getRelatedGraphic: (data: LabelItem) => IGraphic) => Text[];\n\n /** 自定义标签躲避函数\n * @description 当配置了 customOverlapFunc 后,会根据 position 和 offset 进行初始布局。配置的防重叠逻辑(overlap)不生效。\n */\n customOverlapFunc?: (label: Text[], getRelatedGraphic: (data: LabelItem) => IGraphic) => Text[];\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 * @default []\n */\n avoidMarks?: string[] | IGraphic[];\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 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/es/segment/segment.js
CHANGED
|
@@ -42,6 +42,7 @@ export class Segment extends AbstractComponent {
|
|
|
42
42
|
this.line = line, this.add(line);
|
|
43
43
|
}
|
|
44
44
|
renderSymbol(attribute, dim) {
|
|
45
|
+
const {autoRotate: autoRotate = !0} = attribute;
|
|
45
46
|
let symbol;
|
|
46
47
|
if (null == attribute ? void 0 : attribute.visible) {
|
|
47
48
|
const startAngle = this._startAngle, endAngle = this._endAngle, {points: points, state: state} = this.attribute, start = points[0], end = points[points.length - 1], {refX: refX = 0, refY: refY = 0, refAngle: refAngle = 0, style: style, symbolType: symbolType, size: size = 12} = attribute;
|
|
@@ -55,7 +56,7 @@ export class Segment extends AbstractComponent {
|
|
|
55
56
|
}, rotate = endAngle + Math.PI / 2), symbol = createSymbol(Object.assign(Object.assign(Object.assign({}, position), {
|
|
56
57
|
symbolType: symbolType,
|
|
57
58
|
size: size,
|
|
58
|
-
angle: rotate + refAngle,
|
|
59
|
+
angle: autoRotate ? rotate + refAngle : 0,
|
|
59
60
|
strokeBoundsBuffer: 0
|
|
60
61
|
}), style)), symbol.name = `${dim}-symbol`, symbol.id = this._getNodeId(`${dim}-symbol`),
|
|
61
62
|
isEmpty(null == state ? void 0 : state.symbol) || (symbol.states = state.symbol),
|
|
@@ -79,6 +80,7 @@ Segment.defaultAttributes = {
|
|
|
79
80
|
},
|
|
80
81
|
startSymbol: {
|
|
81
82
|
visible: !1,
|
|
83
|
+
autoRotate: !0,
|
|
82
84
|
symbolType: "triangle",
|
|
83
85
|
size: 12,
|
|
84
86
|
refX: 0,
|
|
@@ -91,6 +93,7 @@ Segment.defaultAttributes = {
|
|
|
91
93
|
},
|
|
92
94
|
endSymbol: {
|
|
93
95
|
visible: !1,
|
|
96
|
+
autoRotate: !0,
|
|
94
97
|
symbolType: "triangle",
|
|
95
98
|
size: 12,
|
|
96
99
|
refX: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["segment/segment.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,MAAM,OAAO,OAAQ,SAAQ,iBAA8C;IA0CzE,YAAY,UAA6B;QACvC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QA1C1D,SAAI,GAAG,SAAS,CAAC;IA2CjB,CAAC;IAES,gBAAgB;QACxB,MAAM,E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E,KAAK;QACd,UAAU,EAAE,UAAU;QACtB,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,CAAC;SACV;KACF;IACD,SAAS,EAAE;QACT,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,UAAU;QACtB,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,CAAC;SACV;KACF;CACF,CAAC","file":"segment.js","sourcesContent":["/**\n * @description 标签组件\n */\nimport { isEmpty, merge } from '@visactor/vutils';\nimport type { ILine, ISymbol } from '@visactor/vrender';\nimport { createSymbol, createLine } from '@visactor/vrender';\nimport { AbstractComponent } from '../core/base';\nimport type { SegmentAttributes, SymbolAttributes } from './type';\n\nexport class Segment extends AbstractComponent<Required<SegmentAttributes>> {\n name = 'segment';\n\n line!: ILine;\n startSymbol?: ISymbol;\n endSymbol?: ISymbol;\n\n private _startAngle!: number;\n private _endAngle!: number;\n\n static defaultAttributes: Partial<SegmentAttributes> = {\n visible: true,\n lineStyle: {\n lineWidth: 1,\n stroke: '#000'\n },\n startSymbol: {\n visible: false,\n symbolType: 'triangle',\n size: 12,\n refX: 0,\n refY: 0,\n refAngle: 0,\n style: {\n fill: '#000',\n zIndex: 1 // 默认 symbol 绘制在 line 上面\n }\n },\n endSymbol: {\n visible: false,\n symbolType: 'triangle',\n size: 12,\n refX: 0,\n refY: 0,\n refAngle: 0,\n style: {\n fill: '#000',\n zIndex: 1 // 默认 symbol 绘制在 line 上面\n }\n }\n };\n\n constructor(attributes: SegmentAttributes) {\n super(merge({}, Segment.defaultAttributes, attributes));\n }\n\n protected computeLineAngle() {\n const { points } = this.attribute as SegmentAttributes;\n const start = points[0];\n const startInside = points[1];\n const endInside = points[points.length - 2];\n const end = points[points.length - 1];\n const startVector = [start.x - startInside.x, start.y - startInside.y]; // 起点正方向向量\n const startAngle = Math.atan2(startVector[1], startVector[0]); // 起点正方向角度\n const endVector = [end.x - endInside.x, end.y - endInside.y]; // 终点正方向向量\n const endAngle = Math.atan2(endVector[1], endVector[0]); // 终点正方向角度\n\n this._startAngle = startAngle;\n this._endAngle = endAngle;\n }\n protected render() {\n this.removeAllChild();\n const { points, startSymbol, endSymbol, lineStyle, state, visible = true } = this.attribute as SegmentAttributes;\n\n if (!visible) {\n return;\n }\n\n // 计算线的起点和终点角度\n // 计算角度的原因:\n // 1. segment symbol的自动旋转提供参数\n // 2. 使用segment时,需要根据line的角度对附加元素进行自动旋转(比如:markLine的标签, markPoint的装饰线)\n if (points.length > 1) {\n this.computeLineAngle();\n }\n\n // 绘制start和end symbol\n const startSymbolShape = this.renderSymbol(startSymbol as SymbolAttributes, 'start');\n const endSymbolShape = this.renderSymbol(endSymbol as SymbolAttributes, 'end');\n\n this.startSymbol = startSymbolShape;\n this.endSymbol = endSymbolShape;\n\n // 通过改变line起点和终点的方式达到symbol在fill为false的情况下,也可以遮盖line的效果\n let pointsAfterClip = points;\n if (startSymbol?.visible) {\n const startSize = startSymbol?.clip ? startSymbol?.size || 10 : 0;\n const pointsStart = {\n x: points[0].x - (startSize / 2) * (Math.cos(this._startAngle) || 0),\n y: points[0].y - (startSize / 2) * (Math.sin(this._startAngle) || 0)\n };\n pointsAfterClip = [pointsStart, ...pointsAfterClip.slice(1)];\n }\n if (endSymbol?.visible) {\n const endSize = endSymbol?.clip ? endSymbol?.size || 10 : 0;\n const pointsEnd = {\n x: points[points.length - 1].x - (endSize / 2) * (Math.cos(this._endAngle) || 0),\n y: points[points.length - 1].y - (endSize / 2) * (Math.sin(this._endAngle) || 0)\n };\n pointsAfterClip = [...pointsAfterClip.slice(0, pointsAfterClip.length - 1), pointsEnd];\n }\n\n const line = createLine({\n points: pointsAfterClip,\n fill: false,\n ...lineStyle\n });\n\n line.name = 'line';\n line.id = this._getNodeId('line');\n if (!isEmpty(state?.line)) {\n line.states = state.line;\n }\n this.line = line;\n this.add(line);\n }\n\n private renderSymbol(attribute: SymbolAttributes, dim: string): ISymbol | undefined {\n let symbol;\n if (attribute?.visible) {\n const startAngle = this._startAngle;\n const endAngle = this._endAngle;\n const { points, state } = this.attribute as SegmentAttributes;\n const start = points[0];\n const end = points[points.length - 1];\n const { refX = 0, refY = 0, refAngle = 0, style, symbolType, size = 12 } = attribute;\n let position;\n let rotate;\n if (dim === 'start') {\n position = {\n x: start.x + (startAngle ? refX * Math.cos(startAngle) + refY * Math.cos(startAngle - Math.PI / 2) : 0),\n y: start.y + (startAngle ? refX * Math.sin(startAngle) + refY * Math.sin(startAngle - Math.PI / 2) : 0)\n };\n rotate = startAngle + Math.PI / 2; // @chensiji - 加Math.PI / 2是因为:默认symbol的包围盒垂直于line,所以在做自动旋转时需要在line正方向基础上做90度偏移\n } else {\n position = {\n x: end.x + (endAngle ? refX * Math.cos(endAngle) + refY * Math.cos(endAngle - Math.PI / 2) : 0),\n y: end.y + (endAngle ? refX * Math.sin(endAngle) + refY * Math.sin(endAngle - Math.PI / 2) : 0)\n };\n rotate = endAngle + Math.PI / 2;\n }\n\n symbol = createSymbol({\n ...position,\n symbolType: symbolType as string,\n size,\n angle: rotate + refAngle,\n strokeBoundsBuffer: 0,\n ...style\n });\n symbol.name = `${dim}-symbol`;\n symbol.id = this._getNodeId(`${dim}-symbol`);\n\n if (!isEmpty(state?.symbol)) {\n symbol.states = state.symbol;\n }\n\n this.add(symbol);\n }\n return symbol;\n }\n\n /**\n * 外部获取segement起点正方向\n */\n getStartAngle() {\n return this._startAngle;\n }\n\n /**\n * 外部获取segement终点正方向\n */\n getEndAngle() {\n return this._endAngle;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["segment/segment.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kB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AL,KAAK,uBAAL,KAAK,CAAE,MAAM,CAAC,EAAE;gBAC3B,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;aAC9B;YAED,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;SAClB;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAKD,aAAa;QACX,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAKD,WAAW;QACT,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;;AAvKM,yBAAiB,GAA+B;IACrD,OAAO,EAAE,IAAI;IACb,SAAS,EAAE;QACT,SAAS,EAAE,CAAC;QACZ,MAAM,EAAE,MAAM;KACf;IACD,WAAW,EAAE;QACX,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,UAAU;QACtB,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,CAAC;SACV;KACF;IACD,SAAS,EAAE;QACT,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,UAAU;QACtB,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,CAAC;SACV;KACF;CACF,CAAC","file":"segment.js","sourcesContent":["/**\n * @description 标签组件\n */\nimport { isEmpty, merge } from '@visactor/vutils';\nimport type { ILine, ISymbol } from '@visactor/vrender';\nimport { createSymbol, createLine } from '@visactor/vrender';\nimport { AbstractComponent } from '../core/base';\nimport type { SegmentAttributes, SymbolAttributes } from './type';\n\nexport class Segment extends AbstractComponent<Required<SegmentAttributes>> {\n name = 'segment';\n\n line!: ILine;\n startSymbol?: ISymbol;\n endSymbol?: ISymbol;\n\n private _startAngle!: number;\n private _endAngle!: number;\n\n static defaultAttributes: Partial<SegmentAttributes> = {\n visible: true,\n lineStyle: {\n lineWidth: 1,\n stroke: '#000'\n },\n startSymbol: {\n visible: false,\n autoRotate: true,\n symbolType: 'triangle',\n size: 12,\n refX: 0,\n refY: 0,\n refAngle: 0,\n style: {\n fill: '#000',\n zIndex: 1 // 默认 symbol 绘制在 line 上面\n }\n },\n endSymbol: {\n visible: false,\n autoRotate: true,\n symbolType: 'triangle',\n size: 12,\n refX: 0,\n refY: 0,\n refAngle: 0,\n style: {\n fill: '#000',\n zIndex: 1 // 默认 symbol 绘制在 line 上面\n }\n }\n };\n\n constructor(attributes: SegmentAttributes) {\n super(merge({}, Segment.defaultAttributes, attributes));\n }\n\n protected computeLineAngle() {\n const { points } = this.attribute as SegmentAttributes;\n const start = points[0];\n const startInside = points[1];\n const endInside = points[points.length - 2];\n const end = points[points.length - 1];\n const startVector = [start.x - startInside.x, start.y - startInside.y]; // 起点正方向向量\n const startAngle = Math.atan2(startVector[1], startVector[0]); // 起点正方向角度\n const endVector = [end.x - endInside.x, end.y - endInside.y]; // 终点正方向向量\n const endAngle = Math.atan2(endVector[1], endVector[0]); // 终点正方向角度\n\n this._startAngle = startAngle;\n this._endAngle = endAngle;\n }\n protected render() {\n this.removeAllChild();\n const { points, startSymbol, endSymbol, lineStyle, state, visible = true } = this.attribute as SegmentAttributes;\n\n if (!visible) {\n return;\n }\n\n // 计算线的起点和终点角度\n // 计算角度的原因:\n // 1. segment symbol的自动旋转提供参数\n // 2. 使用segment时,需要根据line的角度对附加元素进行自动旋转(比如:markLine的标签, markPoint的装饰线)\n if (points.length > 1) {\n this.computeLineAngle();\n }\n\n // 绘制start和end symbol\n const startSymbolShape = this.renderSymbol(startSymbol as SymbolAttributes, 'start');\n const endSymbolShape = this.renderSymbol(endSymbol as SymbolAttributes, 'end');\n\n this.startSymbol = startSymbolShape;\n this.endSymbol = endSymbolShape;\n\n // 通过改变line起点和终点的方式达到symbol在fill为false的情况下,也可以遮盖line的效果\n let pointsAfterClip = points;\n if (startSymbol?.visible) {\n const startSize = startSymbol?.clip ? startSymbol?.size || 10 : 0;\n const pointsStart = {\n x: points[0].x - (startSize / 2) * (Math.cos(this._startAngle) || 0),\n y: points[0].y - (startSize / 2) * (Math.sin(this._startAngle) || 0)\n };\n pointsAfterClip = [pointsStart, ...pointsAfterClip.slice(1)];\n }\n if (endSymbol?.visible) {\n const endSize = endSymbol?.clip ? endSymbol?.size || 10 : 0;\n const pointsEnd = {\n x: points[points.length - 1].x - (endSize / 2) * (Math.cos(this._endAngle) || 0),\n y: points[points.length - 1].y - (endSize / 2) * (Math.sin(this._endAngle) || 0)\n };\n pointsAfterClip = [...pointsAfterClip.slice(0, pointsAfterClip.length - 1), pointsEnd];\n }\n\n const line = createLine({\n points: pointsAfterClip,\n fill: false,\n ...lineStyle\n });\n\n line.name = 'line';\n line.id = this._getNodeId('line');\n if (!isEmpty(state?.line)) {\n line.states = state.line;\n }\n this.line = line;\n this.add(line);\n }\n\n private renderSymbol(attribute: SymbolAttributes, dim: string): ISymbol | undefined {\n const { autoRotate = true } = attribute;\n let symbol;\n if (attribute?.visible) {\n const startAngle = this._startAngle;\n const endAngle = this._endAngle;\n const { points, state } = this.attribute as SegmentAttributes;\n const start = points[0];\n const end = points[points.length - 1];\n const { refX = 0, refY = 0, refAngle = 0, style, symbolType, size = 12 } = attribute;\n let position;\n let rotate;\n if (dim === 'start') {\n position = {\n x: start.x + (startAngle ? refX * Math.cos(startAngle) + refY * Math.cos(startAngle - Math.PI / 2) : 0),\n y: start.y + (startAngle ? refX * Math.sin(startAngle) + refY * Math.sin(startAngle - Math.PI / 2) : 0)\n };\n rotate = startAngle + Math.PI / 2; // @chensiji - 加Math.PI / 2是因为:默认symbol的包围盒垂直于line,所以在做自动旋转时需要在line正方向基础上做90度偏移\n } else {\n position = {\n x: end.x + (endAngle ? refX * Math.cos(endAngle) + refY * Math.cos(endAngle - Math.PI / 2) : 0),\n y: end.y + (endAngle ? refX * Math.sin(endAngle) + refY * Math.sin(endAngle - Math.PI / 2) : 0)\n };\n rotate = endAngle + Math.PI / 2;\n }\n\n symbol = createSymbol({\n ...position,\n symbolType: symbolType as string,\n size,\n angle: autoRotate ? rotate + refAngle : 0,\n strokeBoundsBuffer: 0,\n ...style\n });\n symbol.name = `${dim}-symbol`;\n symbol.id = this._getNodeId(`${dim}-symbol`);\n\n if (!isEmpty(state?.symbol)) {\n symbol.states = state.symbol;\n }\n\n this.add(symbol);\n }\n return symbol;\n }\n\n /**\n * 外部获取segement起点正方向\n */\n getStartAngle() {\n return this._startAngle;\n }\n\n /**\n * 外部获取segement终点正方向\n */\n getEndAngle() {\n return this._endAngle;\n }\n}\n"]}
|
package/es/segment/type.d.ts
CHANGED
package/es/segment/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["segment/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n IGraphicAttribute,\n IGroupGraphicAttribute,\n ILineGraphicAttribute,\n ISymbolGraphicAttribute,\n SymbolType\n} from '@visactor/vrender';\nimport type { Point, State } from '../core/type';\n\nexport type SymbolAttributes = {\n /** 是否展示 symbol */\n visible: boolean;\n /**\n * symbol 形状,默认为带左右方向的箭头\n */\n symbolType?: SymbolType;\n /**\n * symbol 大小\n */\n size?: number;\n /**\n * symbol 相对line平行方向上的偏移\n */\n refX?: number;\n /**\n * symbol 相对line正交方向上的偏移\n */\n refY?: number;\n /**\n * symbol 相对默认角度的偏移\n * @description (@chensiji: 默认角度为笛卡尔坐标系y正方向,即默认symbol包围盒的角度为笛卡尔坐标系y正方向, 做自动旋转时, 会在此基础上,将包围盒转换到line平行方向上。)\n */\n refAngle?: number;\n /**\n * symbol 是否clip line,即当symbol fill为false时,line在symbol内部的部分是否展示\n * @defalut false\n */\n clip?: boolean;\n /**\n * symbol 样式配置\n */\n style?: Partial<IGraphicAttribute>;\n};\n\nexport interface SegmentAttributes extends IGroupGraphicAttribute {\n /**\n * 可见性\n * @default true\n */\n visible?: boolean;\n points: Point[];\n /** 轴线起始点 symbol 配置 */\n startSymbol?: SymbolAttributes;\n /** 轴线末端 symbol 配置 */\n endSymbol?: SymbolAttributes;\n /**\n * 线样式配置\n */\n lineStyle?: Partial<ILineGraphicAttribute>;\n\n state?: {\n line?: State<Partial<ILineGraphicAttribute>>;\n symbol?: State<Partial<ISymbolGraphicAttribute>>;\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["segment/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n IGraphicAttribute,\n IGroupGraphicAttribute,\n ILineGraphicAttribute,\n ISymbolGraphicAttribute,\n SymbolType\n} from '@visactor/vrender';\nimport type { Point, State } from '../core/type';\n\nexport type SymbolAttributes = {\n /** 是否展示 symbol */\n visible: boolean;\n /**\n * symbol 形状,默认为带左右方向的箭头\n */\n symbolType?: SymbolType;\n /**\n * symbol 大小\n */\n size?: number;\n /**\n * 自动旋转,沿着线的方向,默认 true\n */\n autoRotate?: boolean;\n /**\n * symbol 相对line平行方向上的偏移\n */\n refX?: number;\n /**\n * symbol 相对line正交方向上的偏移\n */\n refY?: number;\n /**\n * symbol 相对默认角度的偏移\n * @description (@chensiji: 默认角度为笛卡尔坐标系y正方向,即默认symbol包围盒的角度为笛卡尔坐标系y正方向, 做自动旋转时, 会在此基础上,将包围盒转换到line平行方向上。)\n */\n refAngle?: number;\n /**\n * symbol 是否clip line,即当symbol fill为false时,line在symbol内部的部分是否展示\n * @defalut false\n */\n clip?: boolean;\n /**\n * symbol 样式配置\n */\n style?: Partial<IGraphicAttribute>;\n};\n\nexport interface SegmentAttributes extends IGroupGraphicAttribute {\n /**\n * 可见性\n * @default true\n */\n visible?: boolean;\n points: Point[];\n /** 轴线起始点 symbol 配置 */\n startSymbol?: SymbolAttributes;\n /** 轴线末端 symbol 配置 */\n endSymbol?: SymbolAttributes;\n /**\n * 线样式配置\n */\n lineStyle?: Partial<ILineGraphicAttribute>;\n\n state?: {\n line?: State<Partial<ILineGraphicAttribute>>;\n symbol?: State<Partial<ISymbolGraphicAttribute>>;\n };\n}\n"]}
|
package/es/util/common.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import { IGraphicAttribute, IGraphic } from '@visactor/vrender';
|
|
1
|
+
import type { IGraphicAttribute, IGraphic, IGroup } from '@visactor/vrender';
|
|
2
2
|
export declare function traverseGroup(group: IGraphic, cb: (node: IGraphic) => boolean | void): void;
|
|
3
3
|
export declare const isVisible: (obj?: Partial<IGraphicAttribute>) => boolean;
|
|
4
|
+
export declare function getMarksByName(root: IGroup, name: string): IGraphic<Partial<IGraphicAttribute>>[];
|
|
5
|
+
export declare function getNoneGroupMarksByName(root: IGroup, name: string): IGraphic<Partial<IGraphicAttribute>>[];
|
package/es/util/common.js
CHANGED
|
@@ -8,4 +8,16 @@ export function traverseGroup(group, cb) {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const isVisible = obj => !isNil(obj) && !1 !== obj.visible;
|
|
11
|
+
|
|
12
|
+
export function getMarksByName(root, name) {
|
|
13
|
+
if (!name) return [];
|
|
14
|
+
const group = root.find((node => node.name === name), !0);
|
|
15
|
+
return group ? group.getChildren() : [];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function getNoneGroupMarksByName(root, name) {
|
|
19
|
+
if (!name) return [];
|
|
20
|
+
const group = root.find((node => node.name === name), !0);
|
|
21
|
+
return group ? group.findAll((node => "group" !== node.type), !0) : [];
|
|
22
|
+
}
|
|
11
23
|
//# sourceMappingURL=common.js.map
|
package/es/util/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["util/common.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,MAAM,UAAU,aAAa,CAAC,KAAe,EAAE,EAAsC;IACnF,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE;QAC3B,MAAM,OAAO,GAAG,EAAE,CAAC,IAAgB,CAAC,CAAC;QACrC,IAAK,IAAe,CAAC,WAAW,IAAI,CAAC,OAAO,EAAE;YAC5C,aAAa,CAAC,IAAgB,EAAE,EAAE,CAAC,CAAC;SACrC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAgC,EAAW,EAAE;IACrE,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE;QACd,OAAO,KAAK,CAAC;KACd;IACD,OAAO,GAAG,CAAC,OAAO,KAAK,KAAK,CAAC;AAC/B,CAAC,CAAC","file":"common.js","sourcesContent":["/**\n * @description 存放工具函数\n */\nimport { IGraphicAttribute, IGraphic, IGroup } from '@visactor/vrender';\nimport { isNil } from '@visactor/vutils';\n\nexport function traverseGroup(group: IGraphic, cb: (node: IGraphic) => boolean | void) {\n group.forEachChildren(node => {\n const stopped = cb(node as IGraphic);\n if ((node as IGroup).isContainer && !stopped) {\n traverseGroup(node as IGraphic, cb);\n }\n });\n}\n\nexport const isVisible = (obj?: Partial<IGraphicAttribute>): boolean => {\n if (isNil(obj)) {\n return false;\n }\n return obj.visible !== false;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["util/common.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,MAAM,UAAU,aAAa,CAAC,KAAe,EAAE,EAAsC;IACnF,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE;QAC3B,MAAM,OAAO,GAAG,EAAE,CAAC,IAAgB,CAAC,CAAC;QACrC,IAAK,IAAe,CAAC,WAAW,IAAI,CAAC,OAAO,EAAE;YAC5C,aAAa,CAAC,IAAgB,EAAE,EAAE,CAAC,CAAC;SACrC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAgC,EAAW,EAAE;IACrE,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE;QACd,OAAO,KAAK,CAAC;KACd;IACD,OAAO,GAAG,CAAC,OAAO,KAAK,KAAK,CAAC;AAC/B,CAAC,CAAC;AAEF,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,IAAY;IACvD,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE,CAAC;KACX;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE,IAAI,CAAW,CAAC;IACpE,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,EAAE,CAAC;KACX;IACD,OAAO,KAAK,CAAC,WAAW,EAAgB,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,IAAY,EAAE,IAAY;IAChE,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE,CAAC;KACX;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE,IAAI,CAAW,CAAC;IACpE,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,EAAE,CAAC;KACX;IACD,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,IAAI,CAA0B,CAAC;AACrF,CAAC","file":"common.js","sourcesContent":["/**\n * @description 存放工具函数\n */\nimport type { IGraphicAttribute, IGraphic, IGroup } from '@visactor/vrender';\nimport { isNil } from '@visactor/vutils';\n\nexport function traverseGroup(group: IGraphic, cb: (node: IGraphic) => boolean | void) {\n group.forEachChildren(node => {\n const stopped = cb(node as IGraphic);\n if ((node as IGroup).isContainer && !stopped) {\n traverseGroup(node as IGraphic, cb);\n }\n });\n}\n\nexport const isVisible = (obj?: Partial<IGraphicAttribute>): boolean => {\n if (isNil(obj)) {\n return false;\n }\n return obj.visible !== false;\n};\n\nexport function getMarksByName(root: IGroup, name: string) {\n if (!name) {\n return [];\n }\n const group = root.find(node => node.name === name, true) as IGroup;\n if (!group) {\n return [];\n }\n return group.getChildren() as IGraphic[];\n}\n\nexport function getNoneGroupMarksByName(root: IGroup, name: string) {\n if (!name) {\n return [];\n }\n const group = root.find(node => node.name === name, true) as IGroup;\n if (!group) {\n return [];\n }\n return group.findAll(node => node.type !== 'group', true) as unknown as IGraphic[];\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.8-alpha.4",
|
|
4
4
|
"description": "components library for dp visualization",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "cjs/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"dist"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@visactor/vrender": "0.13.
|
|
15
|
+
"@visactor/vrender": "0.13.7-alpha.4",
|
|
16
16
|
"@visactor/vutils": "~0.13.0",
|
|
17
17
|
"@visactor/vscale": "~0.13.0",
|
|
18
18
|
"inversify": "6.0.1"
|