@visactor/vrender-components 0.13.9-alpha.1 → 0.13.9-alpha.5
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/arc.d.ts +69 -0
- package/cjs/label/arc.js +397 -0
- package/cjs/label/arc.js.map +1 -0
- package/cjs/label/base.d.ts +3 -1
- package/cjs/label/base.js +69 -30
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/dataLabel.js +3 -2
- package/cjs/label/dataLabel.js.map +1 -1
- package/cjs/label/index.d.ts +1 -0
- package/cjs/label/index.js +2 -1
- package/cjs/label/index.js.map +1 -1
- package/cjs/label/type.d.ts +41 -2
- package/cjs/label/type.js.map +1 -1
- package/cjs/label/util.d.ts +12 -0
- package/cjs/label/util.js +113 -0
- package/cjs/label/util.js.map +1 -0
- package/cjs/link-path/type.js +1 -2
- package/cjs/marker/base.js +2 -1
- package/cjs/pager/index.js +1 -1
- package/cjs/pager/pager.js +1 -1
- package/cjs/util/common.d.ts +1 -3
- package/cjs/util/common.js +2 -14
- package/cjs/util/common.js.map +1 -1
- package/dist/index.js +853 -61
- 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/arc.d.ts +69 -0
- package/es/label/arc.js +387 -0
- package/es/label/arc.js.map +1 -0
- package/es/label/base.d.ts +3 -1
- package/es/label/base.js +71 -32
- package/es/label/base.js.map +1 -1
- package/es/label/dataLabel.js +4 -1
- package/es/label/dataLabel.js.map +1 -1
- package/es/label/index.d.ts +1 -0
- package/es/label/index.js +2 -0
- package/es/label/index.js.map +1 -1
- package/es/label/type.d.ts +41 -2
- package/es/label/type.js.map +1 -1
- package/es/label/util.d.ts +12 -0
- package/es/label/util.js +99 -0
- package/es/label/util.js.map +1 -0
- package/es/link-path/type.js +1 -2
- package/es/marker/base.js +2 -1
- package/es/pager/index.js +1 -1
- package/es/pager/pager.js +1 -1
- package/es/util/common.d.ts +1 -3
- package/es/util/common.js +0 -12
- package/es/util/common.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.degrees = exports.checkBoundsOverlap = exports.connectLineRadian = exports.lineCirclePoints = exports.isQuadrantRight = exports.isQuadrantLeft = exports.normalizeAngle = exports.computeQuadrant = exports.circlePoint = exports.polarToCartesian = void 0;
|
|
6
|
+
|
|
7
|
+
const vutils_1 = require("@visactor/vutils");
|
|
8
|
+
|
|
9
|
+
function polarToCartesian(point) {
|
|
10
|
+
return point.radius ? {
|
|
11
|
+
x: Math.cos(point.angle) * point.radius,
|
|
12
|
+
y: Math.sin(point.angle) * point.radius
|
|
13
|
+
} : {
|
|
14
|
+
x: 0,
|
|
15
|
+
y: 0
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function circlePoint(x0, y0, radius, radian) {
|
|
20
|
+
const offset = polarToCartesian({
|
|
21
|
+
radius: radius,
|
|
22
|
+
angle: radian
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
x: x0 + offset.x,
|
|
26
|
+
y: y0 + offset.y
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function computeQuadrant(angle) {
|
|
31
|
+
return (angle = normalizeAngle(angle)) > 0 && angle <= Math.PI / 2 ? 2 : angle > Math.PI / 2 && angle <= Math.PI ? 3 : angle > Math.PI && angle <= 3 * Math.PI / 2 ? 4 : 1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function normalizeAngle(angle) {
|
|
35
|
+
for (;angle < 0; ) angle += 2 * Math.PI;
|
|
36
|
+
for (;angle >= 2 * Math.PI; ) angle -= 2 * Math.PI;
|
|
37
|
+
return angle;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isQuadrantLeft(quadrant) {
|
|
41
|
+
return 3 === quadrant || 4 === quadrant;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function isQuadrantRight(quadrant) {
|
|
45
|
+
return 1 === quadrant || 2 === quadrant;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function lineCirclePoints(a, b, c, x0, y0, r) {
|
|
49
|
+
if (0 === a && 0 === b || r <= 0) return [];
|
|
50
|
+
if (0 === a) {
|
|
51
|
+
const y1 = -c / b, fd = r ** 2 - (y1 - y0) ** 2;
|
|
52
|
+
if (fd < 0) return [];
|
|
53
|
+
if (0 === fd) return [ {
|
|
54
|
+
x: x0,
|
|
55
|
+
y: y1
|
|
56
|
+
} ];
|
|
57
|
+
return [ {
|
|
58
|
+
x: Math.sqrt(fd) + x0,
|
|
59
|
+
y: y1
|
|
60
|
+
}, {
|
|
61
|
+
x: -Math.sqrt(fd) + x0,
|
|
62
|
+
y: y1
|
|
63
|
+
} ];
|
|
64
|
+
}
|
|
65
|
+
if (0 === b) {
|
|
66
|
+
const x1 = -c / a, fd = r ** 2 - (x1 - x0) ** 2;
|
|
67
|
+
if (fd < 0) return [];
|
|
68
|
+
if (0 === fd) return [ {
|
|
69
|
+
x: x1,
|
|
70
|
+
y: y0
|
|
71
|
+
} ];
|
|
72
|
+
return [ {
|
|
73
|
+
x: x1,
|
|
74
|
+
y: Math.sqrt(fd) + y0
|
|
75
|
+
}, {
|
|
76
|
+
x: x1,
|
|
77
|
+
y: -Math.sqrt(fd) + y0
|
|
78
|
+
} ];
|
|
79
|
+
}
|
|
80
|
+
const fa = (b / a) ** 2 + 1, fb = 2 * ((c / a + x0) * (b / a) - y0), fd = fb ** 2 - 4 * fa * ((c / a + x0) ** 2 + y0 ** 2 - r ** 2);
|
|
81
|
+
if (fd < 0) return [];
|
|
82
|
+
const y1 = (-fb + Math.sqrt(fd)) / (2 * fa), y2 = (-fb - Math.sqrt(fd)) / (2 * fa), x1 = -(b * y1 + c) / a;
|
|
83
|
+
return 0 === fd ? [ {
|
|
84
|
+
x: x1,
|
|
85
|
+
y: y1
|
|
86
|
+
} ] : [ {
|
|
87
|
+
x: x1,
|
|
88
|
+
y: y1
|
|
89
|
+
}, {
|
|
90
|
+
x: -(b * y2 + c) / a,
|
|
91
|
+
y: y2
|
|
92
|
+
} ];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function connectLineRadian(radius, length) {
|
|
96
|
+
return length > 2 * radius ? NaN : 2 * Math.asin(length / 2 / radius);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function checkBoundsOverlap(boundsA, boundsB) {
|
|
100
|
+
const {x1: ax1, y1: ay1, x2: ax2, y2: ay2} = boundsA, {x1: bx1, y1: by1, x2: bx2, y2: by2} = boundsB;
|
|
101
|
+
return !(ax1 <= bx1 && ax2 <= bx1 || ax1 >= bx2 && ax2 >= bx2 || ay1 <= by1 && ay2 <= by1 || ay1 >= by2 && ay2 >= by2);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
exports.polarToCartesian = polarToCartesian, exports.circlePoint = circlePoint,
|
|
105
|
+
exports.computeQuadrant = computeQuadrant, exports.normalizeAngle = normalizeAngle,
|
|
106
|
+
exports.isQuadrantLeft = isQuadrantLeft, exports.isQuadrantRight = isQuadrantRight,
|
|
107
|
+
exports.lineCirclePoints = lineCirclePoints, exports.connectLineRadian = connectLineRadian,
|
|
108
|
+
exports.checkBoundsOverlap = checkBoundsOverlap;
|
|
109
|
+
|
|
110
|
+
const degrees = angle => (0, vutils_1.isValidNumber)(angle) ? (0, vutils_1.radianToDegree)(angle) : null;
|
|
111
|
+
|
|
112
|
+
exports.degrees = degrees;
|
|
113
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["label/util.ts"],"names":[],"mappings":";;;AAEA,6CAAiE;AAOjE,SAAgB,gBAAgB,CAAC,KAAkB;IACjD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,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACvD,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACvD,OAAO,CAAC,CACN,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC;QAC1B,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC;QAC1B,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC;QAC1B,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC,CAC3B,CAAC;AACJ,CAAC;AATD,gDASC;AAEM,MAAM,OAAO,GAAG,CAAC,KAAc,EAAE,EAAE;IACxC,IAAI,CAAC,IAAA,sBAAa,EAAC,KAAK,CAAC,EAAE;QACzB,OAAO,IAAI,CAAC;KACb;IACD,OAAO,IAAA,uBAAc,EAAC,KAAK,CAAC,CAAC;AAC/B,CAAC,CAAC;AALW,QAAA,OAAO,WAKlB","file":"util.js","sourcesContent":["import type { IPolarPoint, IPoint, Quadrant } from './type';\nimport type { IBoundsLike } from '@visactor/vutils';\nimport { radianToDegree, isValidNumber } from '@visactor/vutils';\n\n/**\n * 极坐标系 -> 直角坐标系\n * @param point\n * @returns\n */\nexport function polarToCartesian(point: IPolarPoint): IPoint {\n if (!point.radius) {\n return { x: 0, y: 0 };\n }\n return {\n x: Math.cos(point.angle) * point.radius,\n y: Math.sin(point.angle) * point.radius\n };\n}\n\n/**\n * 计算圆弧上的点坐标\n * @param x0 圆心 x 坐标\n * @param y0 圆心 y 坐标\n * @param radius 圆弧半径\n * @param radian 点所在弧度\n */\nexport function circlePoint(x0: number, y0: number, radius: number, radian: number): IPoint {\n const offset = polarToCartesian({\n radius,\n angle: radian\n });\n return {\n x: x0 + offset.x,\n y: y0 + offset.y\n };\n}\n\n/**\n * 根据角度计算象限\n * 计算角度所在象限\n * @param angle\n * @returns\n */\nexport function computeQuadrant(angle: number): Quadrant {\n angle = normalizeAngle(angle);\n if (angle > 0 && angle <= Math.PI / 2) {\n return 2;\n } else if (angle > Math.PI / 2 && angle <= Math.PI) {\n return 3;\n } else if (angle > Math.PI && angle <= (3 * Math.PI) / 2) {\n return 4;\n }\n return 1;\n}\n\n/**\n * 角度标准化处理\n * @param angle 弧度角\n */\nexport function normalizeAngle(angle: number): number {\n while (angle < 0) {\n angle += Math.PI * 2;\n }\n while (angle >= Math.PI * 2) {\n angle -= Math.PI * 2;\n }\n return angle;\n}\n\nexport function isQuadrantLeft(quadrant: Quadrant): boolean {\n return quadrant === 3 || quadrant === 4;\n}\n\nexport function isQuadrantRight(quadrant: Quadrant): boolean {\n return quadrant === 1 || quadrant === 2;\n}\n\n/**\n * 计算直线与圆交点\n * 直线方程:ax + by + c = 0\n * 圆方程:(x - x0)^2 + (y - y0)^2 = r^2\n */\nexport function lineCirclePoints(a: number, b: number, c: number, x0: number, y0: number, r: number): IPoint[] {\n if ((a === 0 && b === 0) || r <= 0) {\n return [];\n }\n if (a === 0) {\n const y1 = -c / b;\n const fy = (y1 - y0) ** 2;\n const fd = r ** 2 - fy;\n if (fd < 0) {\n return [];\n } else if (fd === 0) {\n return [{ x: x0, y: y1 }];\n }\n const x1 = Math.sqrt(fd) + x0;\n const x2 = -Math.sqrt(fd) + x0;\n return [\n { x: x1, y: y1 },\n { x: x2, y: y1 }\n ];\n } else if (b === 0) {\n const x1 = -c / a;\n const fx = (x1 - x0) ** 2;\n const fd = r ** 2 - fx;\n if (fd < 0) {\n return [];\n } else if (fd === 0) {\n return [{ x: x1, y: y0 }];\n }\n const y1 = Math.sqrt(fd) + y0;\n const y2 = -Math.sqrt(fd) + y0;\n return [\n { x: x1, y: y1 },\n { x: x1, y: y2 }\n ];\n }\n const fa = (b / a) ** 2 + 1;\n const fb = 2 * ((c / a + x0) * (b / a) - y0);\n const fc = (c / a + x0) ** 2 + y0 ** 2 - r ** 2;\n const fd = fb ** 2 - 4 * fa * fc;\n if (fd < 0) {\n return [];\n }\n const y1 = (-fb + Math.sqrt(fd)) / (2 * fa);\n const y2 = (-fb - Math.sqrt(fd)) / (2 * fa);\n const x1 = -(b * y1 + c) / a;\n const x2 = -(b * y2 + c) / a;\n if (fd === 0) {\n return [{ x: x1, y: y1 }];\n }\n return [\n { x: x1, y: y1 },\n { x: x2, y: y2 }\n ];\n}\n\n/**\n * 根据圆弧两点连接线长度计算弧度\n * @param radius 圆弧半径\n * @param length 连接线长度\n */\nexport function connectLineRadian(radius: number, length: number) {\n if (length > radius * 2) {\n return NaN;\n }\n return Math.asin(length / 2 / radius) * 2;\n}\n\nexport function checkBoundsOverlap(boundsA: IBoundsLike, boundsB: IBoundsLike): boolean {\n const { x1: ax1, y1: ay1, x2: ax2, y2: ay2 } = boundsA;\n const { x1: bx1, y1: by1, x2: bx2, y2: by2 } = boundsB;\n return !(\n (ax1 <= bx1 && ax2 <= bx1) ||\n (ax1 >= bx2 && ax2 >= bx2) ||\n (ay1 <= by1 && ay2 <= by1) ||\n (ay1 >= by2 && ay2 >= by2)\n );\n}\n\nexport const degrees = (angle?: number) => {\n if (!isValidNumber(angle)) {\n return null;\n }\n return radianToDegree(angle);\n};\n"]}
|
package/cjs/link-path/type.js
CHANGED
package/cjs/marker/base.js
CHANGED
package/cjs/pager/index.js
CHANGED
|
@@ -18,4 +18,4 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", {
|
|
19
19
|
value: !0
|
|
20
20
|
}), __exportStar(require("./type"), exports), __exportStar(require("./pager"), exports);
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
package/cjs/pager/pager.js
CHANGED
package/cjs/util/common.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { IGraphicAttribute, IGraphic } 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/cjs/util/common.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.
|
|
5
|
+
}), exports.isVisible = exports.traverseGroup = void 0;
|
|
6
6
|
|
|
7
7
|
const vutils_1 = require("@visactor/vutils");
|
|
8
8
|
|
|
@@ -17,17 +17,5 @@ exports.traverseGroup = traverseGroup;
|
|
|
17
17
|
|
|
18
18
|
const isVisible = obj => !(0, vutils_1.isNil)(obj) && !1 !== obj.visible;
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
if (!name) return [];
|
|
22
|
-
const group = root.find((node => node.name === name), !0);
|
|
23
|
-
return group ? group.getChildren() : [];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function getNoneGroupMarksByName(root, name) {
|
|
27
|
-
if (!name) return [];
|
|
28
|
-
const group = root.find((node => node.name === name), !0);
|
|
29
|
-
return group ? group.findAll((node => "group" !== node.type), !0) : [];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
exports.isVisible = isVisible, exports.getMarksByName = getMarksByName, exports.getNoneGroupMarksByName = getNoneGroupMarksByName;
|
|
20
|
+
exports.isVisible = isVisible;
|
|
33
21
|
//# sourceMappingURL=common.js.map
|
package/cjs/util/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["util/common.ts"],"names":[],"mappings":";;;AAIA,6CAAyC;AAEzC,SAAgB,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;AAPD,sCAOC;AAEM,MAAM,SAAS,GAAG,CAAC,GAAgC,EAAW,EAAE;IACrE,IAAI,IAAA,cAAK,EAAC,GAAG,CAAC,EAAE;QACd,OAAO,KAAK,CAAC;KACd;IACD,OAAO,GAAG,CAAC,OAAO,KAAK,KAAK,CAAC;AAC/B,CAAC,CAAC;AALW,QAAA,SAAS,aAKpB
|
|
1
|
+
{"version":3,"sources":["util/common.ts"],"names":[],"mappings":";;;AAIA,6CAAyC;AAEzC,SAAgB,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;AAPD,sCAOC;AAEM,MAAM,SAAS,GAAG,CAAC,GAAgC,EAAW,EAAE;IACrE,IAAI,IAAA,cAAK,EAAC,GAAG,CAAC,EAAE;QACd,OAAO,KAAK,CAAC;KACd;IACD,OAAO,GAAG,CAAC,OAAO,KAAK,KAAK,CAAC;AAC/B,CAAC,CAAC;AALW,QAAA,SAAS,aAKpB","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"]}
|