@antv/g6 5.0.20 → 5.0.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/README.en-US.md +1 -1
- package/README.md +1 -1
- package/dist/g6.min.js +2 -2
- package/dist/lib/behaviors/base-behavior.d.ts +10 -0
- package/dist/lib/behaviors/collapse-expand.d.ts +4 -4
- package/dist/lib/behaviors/drag-canvas.d.ts +1 -1
- package/dist/lib/behaviors/hover-activate.d.ts +3 -2
- package/dist/lib/elements/edges/line.d.ts +0 -2
- package/dist/lib/elements/shapes/base-shape.d.ts +29 -14
- package/dist/lib/exports.d.ts +4 -4
- package/dist/lib/layouts/base-layout.d.ts +5 -0
- package/dist/lib/plugins/background/index.d.ts +1 -0
- package/dist/lib/plugins/base-plugin.d.ts +5 -0
- package/dist/lib/plugins/bubble-sets.d.ts +1 -0
- package/dist/lib/plugins/contextmenu/index.d.ts +1 -0
- package/dist/lib/plugins/grid-line.d.ts +1 -0
- package/dist/lib/plugins/history/index.d.ts +1 -0
- package/dist/lib/plugins/hull/index.d.ts +1 -0
- package/dist/lib/plugins/legend.d.ts +1 -0
- package/dist/lib/plugins/minimap/index.d.ts +17 -2
- package/dist/lib/plugins/snapline/index.d.ts +10 -0
- package/dist/lib/plugins/timebar.d.ts +1 -0
- package/dist/lib/plugins/toolbar/index.d.ts +1 -0
- package/dist/lib/plugins/tooltip.d.ts +11 -0
- package/dist/lib/plugins/watermark/index.d.ts +1 -0
- package/dist/lib/transforms/base-transform.d.ts +5 -0
- package/dist/lib/transforms/index.d.ts +2 -2
- package/dist/lib/transforms/{position-radial-labels.d.ts → place-radial-labels.d.ts} +4 -4
- package/dist/lib/transforms/process-parallel-edges.d.ts +7 -9
- package/dist/lib/transforms/utils.d.ts +5 -5
- package/dist/lib/utils/bbox.d.ts +12 -3
- package/dist/lib/utils/padding.d.ts +4 -4
- package/dist/lib/utils/prefix.d.ts +1 -1
- package/dist/lib/utils/router/orth.d.ts +1 -1
- package/dist/lib/utils/size.d.ts +3 -1
- package/dist/lib/utils/transform.d.ts +5 -5
- package/dist/lib/version.d.ts +1 -1
- package/esm/behaviors/base-behavior.d.ts +10 -0
- package/esm/behaviors/base-behavior.js +5 -0
- package/esm/behaviors/base-behavior.js.map +1 -1
- package/esm/behaviors/collapse-expand.d.ts +4 -4
- package/esm/behaviors/collapse-expand.js +4 -4
- package/esm/behaviors/drag-canvas.d.ts +1 -1
- package/esm/behaviors/drag-canvas.js +1 -1
- package/esm/behaviors/drag-canvas.js.map +1 -1
- package/esm/behaviors/drag-element.js +1 -0
- package/esm/behaviors/drag-element.js.map +1 -1
- package/esm/behaviors/hover-activate.d.ts +3 -2
- package/esm/behaviors/hover-activate.js +24 -14
- package/esm/behaviors/hover-activate.js.map +1 -1
- package/esm/elements/edges/line.d.ts +0 -2
- package/esm/elements/edges/line.js +0 -2
- package/esm/elements/edges/line.js.map +1 -1
- package/esm/elements/edges/polyline.js.map +1 -1
- package/esm/elements/nodes/html.js +4 -1
- package/esm/elements/nodes/html.js.map +1 -1
- package/esm/elements/shapes/base-shape.d.ts +29 -14
- package/esm/elements/shapes/base-shape.js +29 -14
- package/esm/elements/shapes/base-shape.js.map +1 -1
- package/esm/exports.d.ts +4 -4
- package/esm/exports.js +2 -2
- package/esm/exports.js.map +1 -1
- package/esm/layouts/base-layout.d.ts +5 -0
- package/esm/layouts/base-layout.js +5 -0
- package/esm/layouts/base-layout.js.map +1 -1
- package/esm/plugins/background/index.d.ts +1 -0
- package/esm/plugins/background/index.js +1 -0
- package/esm/plugins/background/index.js.map +1 -1
- package/esm/plugins/base-plugin.d.ts +5 -0
- package/esm/plugins/base-plugin.js +5 -0
- package/esm/plugins/base-plugin.js.map +1 -1
- package/esm/plugins/bubble-sets.d.ts +1 -0
- package/esm/plugins/bubble-sets.js +1 -0
- package/esm/plugins/bubble-sets.js.map +1 -1
- package/esm/plugins/contextmenu/index.d.ts +1 -0
- package/esm/plugins/contextmenu/index.js +1 -0
- package/esm/plugins/contextmenu/index.js.map +1 -1
- package/esm/plugins/grid-line.d.ts +1 -0
- package/esm/plugins/grid-line.js +1 -0
- package/esm/plugins/grid-line.js.map +1 -1
- package/esm/plugins/history/index.d.ts +1 -0
- package/esm/plugins/history/index.js +1 -0
- package/esm/plugins/history/index.js.map +1 -1
- package/esm/plugins/hull/index.d.ts +1 -0
- package/esm/plugins/hull/index.js +1 -0
- package/esm/plugins/hull/index.js.map +1 -1
- package/esm/plugins/legend.d.ts +1 -0
- package/esm/plugins/legend.js +1 -0
- package/esm/plugins/legend.js.map +1 -1
- package/esm/plugins/minimap/index.d.ts +17 -2
- package/esm/plugins/minimap/index.js +25 -6
- package/esm/plugins/minimap/index.js.map +1 -1
- package/esm/plugins/snapline/index.d.ts +10 -0
- package/esm/plugins/snapline/index.js +5 -0
- package/esm/plugins/snapline/index.js.map +1 -1
- package/esm/plugins/timebar.d.ts +1 -0
- package/esm/plugins/timebar.js +1 -0
- package/esm/plugins/timebar.js.map +1 -1
- package/esm/plugins/toolbar/index.d.ts +1 -0
- package/esm/plugins/toolbar/index.js +1 -0
- package/esm/plugins/toolbar/index.js.map +1 -1
- package/esm/plugins/tooltip.d.ts +11 -0
- package/esm/plugins/tooltip.js +6 -0
- package/esm/plugins/tooltip.js.map +1 -1
- package/esm/plugins/watermark/index.d.ts +1 -0
- package/esm/plugins/watermark/index.js +1 -0
- package/esm/plugins/watermark/index.js.map +1 -1
- package/esm/registry/build-in.js +2 -2
- package/esm/registry/build-in.js.map +1 -1
- package/esm/runtime/data.js +14 -2
- package/esm/runtime/data.js.map +1 -1
- package/esm/transforms/base-transform.d.ts +5 -0
- package/esm/transforms/base-transform.js +5 -0
- package/esm/transforms/base-transform.js.map +1 -1
- package/esm/transforms/index.d.ts +2 -2
- package/esm/transforms/index.js +1 -1
- package/esm/transforms/index.js.map +1 -1
- package/esm/transforms/{position-radial-labels.d.ts → place-radial-labels.d.ts} +4 -4
- package/esm/transforms/{position-radial-labels.js → place-radial-labels.js} +3 -3
- package/esm/transforms/place-radial-labels.js.map +1 -0
- package/esm/transforms/process-parallel-edges.d.ts +7 -9
- package/esm/transforms/process-parallel-edges.js.map +1 -1
- package/esm/transforms/utils.d.ts +5 -5
- package/esm/transforms/utils.js +5 -5
- package/esm/utils/bbox.d.ts +12 -3
- package/esm/utils/bbox.js +16 -4
- package/esm/utils/bbox.js.map +1 -1
- package/esm/utils/edge.js +4 -4
- package/esm/utils/edge.js.map +1 -1
- package/esm/utils/padding.d.ts +4 -4
- package/esm/utils/padding.js +4 -4
- package/esm/utils/point.js +3 -0
- package/esm/utils/point.js.map +1 -1
- package/esm/utils/prefix.d.ts +1 -1
- package/esm/utils/prefix.js +1 -1
- package/esm/utils/router/orth.d.ts +1 -1
- package/esm/utils/router/orth.js +27 -11
- package/esm/utils/router/orth.js.map +1 -1
- package/esm/utils/size.d.ts +3 -1
- package/esm/utils/size.js +3 -1
- package/esm/utils/size.js.map +1 -1
- package/esm/utils/transform.d.ts +5 -5
- package/esm/utils/transform.js +5 -5
- package/esm/utils/visibility.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/behaviors/base-behavior.d.ts +10 -0
- package/lib/behaviors/base-behavior.js +5 -0
- package/lib/behaviors/base-behavior.js.map +1 -1
- package/lib/behaviors/collapse-expand.d.ts +4 -4
- package/lib/behaviors/collapse-expand.js +4 -4
- package/lib/behaviors/drag-canvas.d.ts +1 -1
- package/lib/behaviors/drag-canvas.js +1 -1
- package/lib/behaviors/drag-canvas.js.map +1 -1
- package/lib/behaviors/drag-element.js +1 -0
- package/lib/behaviors/drag-element.js.map +1 -1
- package/lib/behaviors/hover-activate.d.ts +3 -2
- package/lib/behaviors/hover-activate.js +24 -14
- package/lib/behaviors/hover-activate.js.map +1 -1
- package/lib/elements/edges/line.d.ts +0 -2
- package/lib/elements/edges/line.js +0 -2
- package/lib/elements/edges/line.js.map +1 -1
- package/lib/elements/edges/polyline.js.map +1 -1
- package/lib/elements/nodes/html.js +3 -0
- package/lib/elements/nodes/html.js.map +1 -1
- package/lib/elements/shapes/base-shape.d.ts +29 -14
- package/lib/elements/shapes/base-shape.js +29 -14
- package/lib/elements/shapes/base-shape.js.map +1 -1
- package/lib/exports.d.ts +4 -4
- package/lib/exports.js +4 -3
- package/lib/exports.js.map +1 -1
- package/lib/layouts/base-layout.d.ts +5 -0
- package/lib/layouts/base-layout.js +5 -0
- package/lib/layouts/base-layout.js.map +1 -1
- package/lib/plugins/background/index.d.ts +1 -0
- package/lib/plugins/background/index.js +1 -0
- package/lib/plugins/background/index.js.map +1 -1
- package/lib/plugins/base-plugin.d.ts +5 -0
- package/lib/plugins/base-plugin.js +5 -0
- package/lib/plugins/base-plugin.js.map +1 -1
- package/lib/plugins/bubble-sets.d.ts +1 -0
- package/lib/plugins/bubble-sets.js +1 -0
- package/lib/plugins/bubble-sets.js.map +1 -1
- package/lib/plugins/contextmenu/index.d.ts +1 -0
- package/lib/plugins/contextmenu/index.js +1 -0
- package/lib/plugins/contextmenu/index.js.map +1 -1
- package/lib/plugins/grid-line.d.ts +1 -0
- package/lib/plugins/grid-line.js +1 -0
- package/lib/plugins/grid-line.js.map +1 -1
- package/lib/plugins/history/index.d.ts +1 -0
- package/lib/plugins/history/index.js +1 -0
- package/lib/plugins/history/index.js.map +1 -1
- package/lib/plugins/hull/index.d.ts +1 -0
- package/lib/plugins/hull/index.js +1 -0
- package/lib/plugins/hull/index.js.map +1 -1
- package/lib/plugins/legend.d.ts +1 -0
- package/lib/plugins/legend.js +1 -0
- package/lib/plugins/legend.js.map +1 -1
- package/lib/plugins/minimap/index.d.ts +17 -2
- package/lib/plugins/minimap/index.js +24 -5
- package/lib/plugins/minimap/index.js.map +1 -1
- package/lib/plugins/snapline/index.d.ts +10 -0
- package/lib/plugins/snapline/index.js +5 -0
- package/lib/plugins/snapline/index.js.map +1 -1
- package/lib/plugins/timebar.d.ts +1 -0
- package/lib/plugins/timebar.js +1 -0
- package/lib/plugins/timebar.js.map +1 -1
- package/lib/plugins/toolbar/index.d.ts +1 -0
- package/lib/plugins/toolbar/index.js +1 -0
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/tooltip.d.ts +11 -0
- package/lib/plugins/tooltip.js +6 -0
- package/lib/plugins/tooltip.js.map +1 -1
- package/lib/plugins/watermark/index.d.ts +1 -0
- package/lib/plugins/watermark/index.js +1 -0
- package/lib/plugins/watermark/index.js.map +1 -1
- package/lib/registry/build-in.js +1 -1
- package/lib/registry/build-in.js.map +1 -1
- package/lib/runtime/data.js +13 -1
- package/lib/runtime/data.js.map +1 -1
- package/lib/transforms/base-transform.d.ts +5 -0
- package/lib/transforms/base-transform.js +5 -0
- package/lib/transforms/base-transform.js.map +1 -1
- package/lib/transforms/index.d.ts +2 -2
- package/lib/transforms/index.js +3 -3
- package/lib/transforms/index.js.map +1 -1
- package/lib/transforms/{position-radial-labels.d.ts → place-radial-labels.d.ts} +4 -4
- package/lib/transforms/{position-radial-labels.js → place-radial-labels.js} +5 -5
- package/lib/transforms/place-radial-labels.js.map +1 -0
- package/lib/transforms/process-parallel-edges.d.ts +7 -9
- package/lib/transforms/process-parallel-edges.js.map +1 -1
- package/lib/transforms/utils.d.ts +5 -5
- package/lib/transforms/utils.js +5 -5
- package/lib/utils/bbox.d.ts +12 -3
- package/lib/utils/bbox.js +19 -6
- package/lib/utils/bbox.js.map +1 -1
- package/lib/utils/edge.js +3 -3
- package/lib/utils/edge.js.map +1 -1
- package/lib/utils/padding.d.ts +4 -4
- package/lib/utils/padding.js +4 -4
- package/lib/utils/point.js +3 -0
- package/lib/utils/point.js.map +1 -1
- package/lib/utils/prefix.d.ts +1 -1
- package/lib/utils/prefix.js +1 -1
- package/lib/utils/router/orth.d.ts +1 -1
- package/lib/utils/router/orth.js +25 -9
- package/lib/utils/router/orth.js.map +1 -1
- package/lib/utils/size.d.ts +3 -1
- package/lib/utils/size.js +3 -1
- package/lib/utils/size.js.map +1 -1
- package/lib/utils/transform.d.ts +5 -5
- package/lib/utils/transform.js +5 -5
- package/lib/utils/visibility.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +11 -11
- package/src/behaviors/base-behavior.ts +10 -0
- package/src/behaviors/collapse-expand.ts +4 -4
- package/src/behaviors/drag-canvas.ts +2 -2
- package/src/behaviors/drag-element.ts +1 -0
- package/src/behaviors/hover-activate.ts +33 -17
- package/src/elements/edges/line.ts +0 -2
- package/src/elements/edges/polyline.ts +2 -0
- package/src/elements/nodes/html.ts +4 -1
- package/src/elements/shapes/base-shape.ts +31 -16
- package/src/exports.ts +4 -2
- package/src/layouts/base-layout.ts +5 -0
- package/src/plugins/background/index.ts +1 -0
- package/src/plugins/base-plugin.ts +5 -0
- package/src/plugins/bubble-sets.ts +1 -0
- package/src/plugins/contextmenu/index.ts +1 -0
- package/src/plugins/grid-line.ts +1 -0
- package/src/plugins/history/index.ts +1 -0
- package/src/plugins/hull/index.ts +1 -0
- package/src/plugins/legend.ts +1 -0
- package/src/plugins/minimap/index.ts +39 -12
- package/src/plugins/snapline/index.ts +10 -0
- package/src/plugins/timebar.ts +1 -0
- package/src/plugins/toolbar/index.ts +1 -0
- package/src/plugins/tooltip.ts +11 -0
- package/src/plugins/watermark/index.ts +1 -0
- package/src/registry/build-in.ts +2 -2
- package/src/runtime/data.ts +15 -3
- package/src/transforms/base-transform.ts +5 -0
- package/src/transforms/index.ts +2 -2
- package/src/transforms/{position-radial-labels.ts → place-radial-labels.ts} +5 -5
- package/src/transforms/process-parallel-edges.ts +7 -9
- package/src/transforms/utils.ts +5 -5
- package/src/utils/bbox.ts +17 -4
- package/src/utils/edge.ts +4 -4
- package/src/utils/padding.ts +4 -4
- package/src/utils/point.ts +2 -0
- package/src/utils/prefix.ts +1 -1
- package/src/utils/router/orth.ts +29 -11
- package/src/utils/size.ts +3 -1
- package/src/utils/transform.ts +5 -5
- package/src/utils/visibility.ts +2 -2
- package/src/version.ts +1 -1
- package/esm/transforms/position-radial-labels.js.map +0 -1
- package/lib/transforms/position-radial-labels.js.map +0 -1
|
@@ -13,7 +13,7 @@ import { BaseTransform } from './base-transform';
|
|
|
13
13
|
*
|
|
14
14
|
* <en/> Options for automatically adjusting the style of node labels according to the radial layout
|
|
15
15
|
*/
|
|
16
|
-
export interface
|
|
16
|
+
export interface PlaceRadialLabelsOptions extends BaseTransformOptions {
|
|
17
17
|
/**
|
|
18
18
|
* <zh/> 偏移量
|
|
19
19
|
*
|
|
@@ -27,13 +27,13 @@ export interface PositionRadialLabelsOptions extends BaseTransformOptions {
|
|
|
27
27
|
*
|
|
28
28
|
* <en/> Automatically adjust the style of node labels according to the radial layout, including position and rotation angle
|
|
29
29
|
*/
|
|
30
|
-
export class
|
|
31
|
-
static defaultOptions: Partial<
|
|
30
|
+
export class PlaceRadialLabels extends BaseTransform<PlaceRadialLabelsOptions> {
|
|
31
|
+
static defaultOptions: Partial<PlaceRadialLabelsOptions> = {
|
|
32
32
|
offset: 5,
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
constructor(context: RuntimeContext, options:
|
|
36
|
-
super(context, Object.assign({},
|
|
35
|
+
constructor(context: RuntimeContext, options: PlaceRadialLabelsOptions) {
|
|
36
|
+
super(context, Object.assign({}, PlaceRadialLabels.defaultOptions, options));
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
private get ref(): NodeData {
|
|
@@ -26,16 +26,14 @@ const CUBIC_LOOP_PLACEMENTS: LoopPlacement[] = [
|
|
|
26
26
|
|
|
27
27
|
export interface ProcessParallelEdgesOptions extends BaseTransformOptions {
|
|
28
28
|
/**
|
|
29
|
-
* <zh/>
|
|
29
|
+
* <zh/> 处理模式
|
|
30
|
+
* - `'merge'`: 将平行边合并为一条边,适用于不需要区分平行边的情况
|
|
31
|
+
* - '`bundle`': 每条边都会与其他所有平行边捆绑在一起,并通过改变曲率与其他边分开。如果一组平行边的数量是奇数,那么中心的边将被绘制为直线,其他的边将被绘制为曲线
|
|
30
32
|
*
|
|
31
|
-
* <en/> Processing mode
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* - bundle: 每条边都会与其他所有平行边捆绑在一起,并通过改变曲率与其他边分开。如果一组平行边的数量是奇数,那么中心的边将被绘制为直线,其他的边将被绘制为曲线
|
|
36
|
-
* <en/>
|
|
37
|
-
* - merge: Merge parallel edges into one edge which is suitable for cases where parallel edges do not need to be distinguished
|
|
38
|
-
* - bundle: Each edge will be bundled with all other parallel edges and separated from them by varying the curvature. If the number of parallel edges in a group is odd, the central edge will be drawn as a straight line, and the others will be drawn as curves
|
|
33
|
+
* <en/> Processing mode
|
|
34
|
+
* - '`merge`': Merge parallel edges into one edge which is suitable for cases where parallel edges do not need to be distinguished
|
|
35
|
+
* - '`bundle`': Each edge will be bundled with all other parallel edges and separated from them by varying the curvature. If the number of parallel edges in a group is odd, the central edge will be drawn as a straight line, and the others will be drawn as curves
|
|
36
|
+
* @defaultValue 'bundle'
|
|
39
37
|
*/
|
|
40
38
|
mode: 'bundle' | 'merge';
|
|
41
39
|
/**
|
package/src/transforms/utils.ts
CHANGED
|
@@ -6,11 +6,11 @@ import type { DrawData, ProcedureData } from './types';
|
|
|
6
6
|
* <zh/> 重新分配绘制任务
|
|
7
7
|
*
|
|
8
8
|
* <en/> Reassign drawing tasks
|
|
9
|
-
* @param input - <zh
|
|
10
|
-
* @param type - <zh
|
|
11
|
-
* @param elementType - <zh
|
|
12
|
-
* @param datum - <zh
|
|
13
|
-
* @param overwrite - <zh
|
|
9
|
+
* @param input - <zh/>绘制数据 | <en/>DrawData
|
|
10
|
+
* @param type - <zh/>类型 | <en/>type
|
|
11
|
+
* @param elementType - <zh/>元素类型 | <en/>element type
|
|
12
|
+
* @param datum - <zh/>数据 | <en/>data
|
|
13
|
+
* @param overwrite - <zh/>是否覆盖现有数据 | <en/>whether to overwrite existing data
|
|
14
14
|
*/
|
|
15
15
|
export function reassignTo(
|
|
16
16
|
input: DrawData,
|
package/src/utils/bbox.ts
CHANGED
|
@@ -150,6 +150,19 @@ export function isPointOutsideBBox(point: Point, bbox: AABB) {
|
|
|
150
150
|
return !isPointInBBox(point, bbox);
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
/**
|
|
154
|
+
* <zh/> 判断点是否位于包围盒中心
|
|
155
|
+
*
|
|
156
|
+
* <en/> When the point is at the center of the bounding box
|
|
157
|
+
* @param point - <zh/> 点 | <en/> Point
|
|
158
|
+
* @param bbox - <zh/> 包围盒 | <en/> Bounding box
|
|
159
|
+
* @returns <zh/> 如果点在包围盒中心返回 true,否则返回 false | <en/> Returns true if the point is at the center of the bounding box, false otherwise
|
|
160
|
+
*/
|
|
161
|
+
export function isPointBBoxCenter(point: Point, bbox: AABB) {
|
|
162
|
+
const { center } = bbox;
|
|
163
|
+
return point[0] === center[0] && point[1] === center[1];
|
|
164
|
+
}
|
|
165
|
+
|
|
153
166
|
/**
|
|
154
167
|
* <zh/> 获取包围盒上离点 `p` 最近的边
|
|
155
168
|
*
|
|
@@ -158,7 +171,7 @@ export function isPointOutsideBBox(point: Point, bbox: AABB) {
|
|
|
158
171
|
* @param p - <zh/> 点 | <en/> Point
|
|
159
172
|
* @returns <zh/> 离点 `p` 最近的边 | <en/> The side nearest to the point `p`
|
|
160
173
|
*/
|
|
161
|
-
export function
|
|
174
|
+
export function getNearestBoundarySide(p: Point, bbox: AABB): 'left' | 'right' | 'top' | 'bottom' {
|
|
162
175
|
const [x, y] = p;
|
|
163
176
|
const [minX, minY] = bbox.min;
|
|
164
177
|
const [maxX, maxY] = bbox.max;
|
|
@@ -171,17 +184,17 @@ export function getNearestSideToPoint(bbox: AABB, p: Point): 'left' | 'right' |
|
|
|
171
184
|
}
|
|
172
185
|
|
|
173
186
|
/**
|
|
174
|
-
* <zh/> 获取包围盒上离点 `p`
|
|
187
|
+
* <zh/> 获取包围盒上离点 `p` 最近的边界点
|
|
175
188
|
*
|
|
176
189
|
* <en/> Get a point on the boundary nearest to the point `p`
|
|
177
190
|
* @param bbox - <zh/> 包围盒 | <en/> Bounding box
|
|
178
191
|
* @param p - <zh/> 点 | <en/> Point
|
|
179
192
|
* @returns <zh/> 离点 `p` 最近的点 | <en/> The point nearest to the point `p`
|
|
180
193
|
*/
|
|
181
|
-
export function
|
|
194
|
+
export function getNearestBoundaryPoint(p: Point, bbox: AABB): Point {
|
|
182
195
|
const ref = clone(p);
|
|
183
196
|
if (isPointInBBox(p, bbox)) {
|
|
184
|
-
const side =
|
|
197
|
+
const side = getNearestBoundarySide(p, bbox);
|
|
185
198
|
switch (side) {
|
|
186
199
|
case 'left':
|
|
187
200
|
ref[0] = bbox.min[0];
|
package/src/utils/edge.ts
CHANGED
|
@@ -15,7 +15,7 @@ import type {
|
|
|
15
15
|
Size,
|
|
16
16
|
Vector2,
|
|
17
17
|
} from '../types';
|
|
18
|
-
import { getBBoxHeight, getBBoxSize, getBBoxWidth,
|
|
18
|
+
import { getBBoxHeight, getBBoxSize, getBBoxWidth, getNearestBoundarySide, getNodeBBox } from './bbox';
|
|
19
19
|
import { isCollapsed } from './collapsibility';
|
|
20
20
|
import { getAllPorts, getNodeConnectionPoint, getPortConnectionPoint, getPortPosition } from './element';
|
|
21
21
|
import { idOf } from './id';
|
|
@@ -481,7 +481,7 @@ export function getPolylineLoopControlPoints(node: Node, sourcePoint: Point, tar
|
|
|
481
481
|
|
|
482
482
|
// 1. 起点和终点相同 | The start and end points are the same
|
|
483
483
|
if (isEqual(sourcePoint, targetPoint)) {
|
|
484
|
-
const side =
|
|
484
|
+
const side = getNearestBoundarySide(sourcePoint, bbox);
|
|
485
485
|
switch (side) {
|
|
486
486
|
case 'left':
|
|
487
487
|
controlPoints.push([sourcePoint[0] - dist, sourcePoint[1]]);
|
|
@@ -505,8 +505,8 @@ export function getPolylineLoopControlPoints(node: Node, sourcePoint: Point, tar
|
|
|
505
505
|
break;
|
|
506
506
|
}
|
|
507
507
|
} else {
|
|
508
|
-
const sourceSide =
|
|
509
|
-
const targetSide =
|
|
508
|
+
const sourceSide = getNearestBoundarySide(sourcePoint, bbox);
|
|
509
|
+
const targetSide = getNearestBoundarySide(targetPoint, bbox);
|
|
510
510
|
// 2. 起点与终点同边 | The start and end points are on the same side
|
|
511
511
|
if (sourceSide === targetSide) {
|
|
512
512
|
const side = sourceSide;
|
package/src/utils/padding.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Padding, STDPadding } from '../types/padding';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* <zh
|
|
4
|
+
* <zh/> 解析 padding
|
|
5
5
|
*
|
|
6
|
-
* <en
|
|
7
|
-
* @param padding - <zh
|
|
8
|
-
* @returns <zh
|
|
6
|
+
* <en/> parse padding
|
|
7
|
+
* @param padding - <zh/> padding | <en/> padding
|
|
8
|
+
* @returns <zh/> 标准 padding | <en/> standard padding
|
|
9
9
|
*/
|
|
10
10
|
export function parsePadding(padding: Padding = 0): STDPadding {
|
|
11
11
|
if (Array.isArray(padding)) {
|
package/src/utils/point.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AABB } from '@antv/g';
|
|
2
|
+
import { isEqual } from '@antv/util';
|
|
2
3
|
import type { Point, PointObject } from '../types';
|
|
3
4
|
import { getBBoxHeight, getBBoxWidth } from './bbox';
|
|
4
5
|
import type { LineSegment } from './line';
|
|
@@ -77,6 +78,7 @@ export function round(point: Point, digits = 0): Point {
|
|
|
77
78
|
* @returns <zh/> 移动后的点 | <en/> the moved point
|
|
78
79
|
*/
|
|
79
80
|
export function moveTo(p: Point, ref: Point, distance: number, reverse = false): Point {
|
|
81
|
+
if (isEqual(p, ref)) return p;
|
|
80
82
|
const direction = reverse ? subtract(p, ref) : subtract(ref, p);
|
|
81
83
|
const normalizedDirection = normalize(direction);
|
|
82
84
|
const moveVector: Point = [normalizedDirection[0] * distance, normalizedDirection[1] * distance];
|
package/src/utils/prefix.ts
CHANGED
package/src/utils/router/orth.ts
CHANGED
|
@@ -5,14 +5,16 @@ import {
|
|
|
5
5
|
getBBoxHeight,
|
|
6
6
|
getBBoxWidth,
|
|
7
7
|
getCombinedBBox,
|
|
8
|
-
|
|
8
|
+
getNearestBoundaryPoint,
|
|
9
|
+
getNearestBoundarySide,
|
|
9
10
|
getNodeBBox,
|
|
11
|
+
isPointBBoxCenter,
|
|
10
12
|
isPointInBBox,
|
|
11
13
|
isPointOnBBoxBoundary,
|
|
12
14
|
isPointOutsideBBox,
|
|
13
15
|
} from '../bbox';
|
|
14
16
|
import { isOrthogonal, moveTo, round } from '../point';
|
|
15
|
-
import { angle, distance, subtract, toVector3 } from '../vector';
|
|
17
|
+
import { angle, distance, subtract, toVector2, toVector3 } from '../vector';
|
|
16
18
|
|
|
17
19
|
export type Direction = 'N' | 'S' | 'W' | 'E' | null;
|
|
18
20
|
|
|
@@ -69,6 +71,12 @@ export function orth(
|
|
|
69
71
|
// source -> target
|
|
70
72
|
if (sourceBBox.intersects(targetBBox)) {
|
|
71
73
|
route = insideNode(from, to, sourceBBox, targetBBox);
|
|
74
|
+
} else if (!isPointBBoxCenter(from, sourceBBox) && !isPointBBoxCenter(to, targetBBox)) {
|
|
75
|
+
const fromWithPadding = getNearestBoundaryPoint(from, sourceBBox);
|
|
76
|
+
const toWithPadding = getNearestBoundaryPoint(to, targetBBox);
|
|
77
|
+
route = pointToPoint(fromWithPadding, toWithPadding, getDirection(fromWithPadding, toWithPadding));
|
|
78
|
+
route.points.unshift(fromWithPadding);
|
|
79
|
+
route.points.push(toWithPadding);
|
|
72
80
|
} else if (!isOrth) {
|
|
73
81
|
route = nodeToNode(from, to, sourceBBox, targetBBox);
|
|
74
82
|
}
|
|
@@ -104,7 +112,7 @@ export function orth(
|
|
|
104
112
|
if (toIdx < len - 1) result.push(to);
|
|
105
113
|
}
|
|
106
114
|
|
|
107
|
-
return result;
|
|
115
|
+
return result.map(toVector2);
|
|
108
116
|
}
|
|
109
117
|
|
|
110
118
|
/**
|
|
@@ -189,9 +197,17 @@ export function pointToPoint(from: Point, to: Point, direction: Direction): Rout
|
|
|
189
197
|
* @returns <zh/> 正交路由 | <en/> orthogonal route
|
|
190
198
|
*/
|
|
191
199
|
export function nodeToPoint(from: Point, to: Point, fromBBox: AABB): Route {
|
|
192
|
-
|
|
200
|
+
if (isPointBBoxCenter(from, fromBBox)) {
|
|
201
|
+
const p = freeJoin(from, to, fromBBox);
|
|
193
202
|
|
|
194
|
-
|
|
203
|
+
return { points: [p], direction: getDirection(p, to) };
|
|
204
|
+
} else {
|
|
205
|
+
const fromWithPadding = getNearestBoundaryPoint(from, fromBBox);
|
|
206
|
+
const isHorizontal = ['left', 'right'].includes(getNearestBoundarySide(from, fromBBox));
|
|
207
|
+
const p: Point = isHorizontal ? [to[0], fromWithPadding[1]] : [fromWithPadding[0], to[1]];
|
|
208
|
+
|
|
209
|
+
return { points: [p], direction: getDirection(p, to) };
|
|
210
|
+
}
|
|
195
211
|
}
|
|
196
212
|
|
|
197
213
|
/**
|
|
@@ -205,9 +221,10 @@ export function nodeToPoint(from: Point, to: Point, fromBBox: AABB): Route {
|
|
|
205
221
|
* @returns <zh/> 正交路由 | <en/> orthogonal route
|
|
206
222
|
*/
|
|
207
223
|
export function pointToNode(from: Point, to: Point, toBBox: AABB, direction: Direction): Route {
|
|
224
|
+
const toWithPadding = isPointBBoxCenter(to, toBBox) ? to : getNearestBoundaryPoint(to, toBBox);
|
|
208
225
|
const points: Point[] = [
|
|
209
|
-
[
|
|
210
|
-
[from[0],
|
|
226
|
+
[toWithPadding[0], from[1]],
|
|
227
|
+
[from[0], toWithPadding[1]],
|
|
211
228
|
];
|
|
212
229
|
const freePoints = points.filter((p) => isPointOutsideBBox(p, toBBox) && !isPointOnBBoxBoundary(p, toBBox, true));
|
|
213
230
|
|
|
@@ -265,6 +282,7 @@ export function nodeToNode(from: Point, to: Point, fromBBox: AABB, toBBox: AABB)
|
|
|
265
282
|
route.direction = endRoute.direction;
|
|
266
283
|
}
|
|
267
284
|
}
|
|
285
|
+
|
|
268
286
|
return route;
|
|
269
287
|
}
|
|
270
288
|
|
|
@@ -292,10 +310,10 @@ export function insideNode(from: Point, to: Point, fromBBox: AABB, toBBox: AABB,
|
|
|
292
310
|
start[0] + halfPerimeter * Math.cos(radians[direction]),
|
|
293
311
|
start[1] + halfPerimeter * Math.sin(radians[direction]),
|
|
294
312
|
];
|
|
295
|
-
// `
|
|
296
|
-
p1 = moveTo(
|
|
313
|
+
// `getNearestBoundaryPoint` returns a point on the boundary, so we need to move it a bit to ensure it's outside the element and then get the correct `p2` via `freeJoin`.
|
|
314
|
+
p1 = moveTo(getNearestBoundaryPoint(ref, boundary), ref, DEFAULT_OFFSET);
|
|
297
315
|
} else {
|
|
298
|
-
p1 = moveTo(
|
|
316
|
+
p1 = moveTo(getNearestBoundaryPoint(start, boundary), start, -DEFAULT_OFFSET);
|
|
299
317
|
}
|
|
300
318
|
|
|
301
319
|
let p2 = freeJoin(p1, end, boundary);
|
|
@@ -305,7 +323,7 @@ export function insideNode(from: Point, to: Point, fromBBox: AABB, toBBox: AABB,
|
|
|
305
323
|
if (isEqual(round(p1), round(p2))) {
|
|
306
324
|
const rad = angle(subtract(p1, start), [1, 0, 0]) + Math.PI / 2;
|
|
307
325
|
p2 = [end[0] + halfPerimeter * Math.cos(rad), end[1] + halfPerimeter * Math.sin(rad), 0];
|
|
308
|
-
p2 = round(moveTo(
|
|
326
|
+
p2 = round(moveTo(getNearestBoundaryPoint(p2, boundary), end, -DEFAULT_OFFSET), 2);
|
|
309
327
|
const p3 = freeJoin(p1, p2, boundary);
|
|
310
328
|
points = [p1, p3, p2];
|
|
311
329
|
}
|
package/src/utils/size.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { STDSize, Size } from '../types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* <zh/> 解析尺寸配置
|
|
4
|
+
* <zh/> 解析尺寸配置
|
|
5
|
+
*
|
|
6
|
+
* <en/> Parse size configuration
|
|
5
7
|
* @param size - <zh/> 尺寸配置 | <en/> size configuration
|
|
6
8
|
* @returns <zh/> 标准尺寸格式 | <en/> standard size format
|
|
7
9
|
*/
|
package/src/utils/transform.ts
CHANGED
|
@@ -26,11 +26,11 @@ export function replaceTranslateInTransform(x: number, y: number, z: number, tra
|
|
|
26
26
|
* <zh/> 重新分配绘制任务
|
|
27
27
|
*
|
|
28
28
|
* <en/> Reassign drawing tasks
|
|
29
|
-
* @param input - <zh
|
|
30
|
-
* @param type - <zh
|
|
31
|
-
* @param elementType - <zh
|
|
32
|
-
* @param datum - <zh
|
|
33
|
-
* @param merge - <zh
|
|
29
|
+
* @param input - <zh/>绘制数据 | <en/>DrawData
|
|
30
|
+
* @param type - <zh/>类型 | <en/>type
|
|
31
|
+
* @param elementType - <zh/>元素类型 | <en/>element type
|
|
32
|
+
* @param datum - <zh/>数据 | <en/>data
|
|
33
|
+
* @param merge - <zh/>是否合并 | <en/>whether to merge
|
|
34
34
|
*/
|
|
35
35
|
export const reassignTo = (
|
|
36
36
|
input: DrawData,
|
package/src/utils/visibility.ts
CHANGED
|
@@ -23,8 +23,8 @@ export function setVisibility(
|
|
|
23
23
|
) {
|
|
24
24
|
if (value === undefined) return;
|
|
25
25
|
|
|
26
|
-
const traverse = (current: DisplayObject, scope = value) => {
|
|
27
|
-
const walk = (val = scope) => (current.childNodes as DisplayObject[]).forEach((node) => traverse(node, val));
|
|
26
|
+
const traverse = (current: DisplayObject, scope = value): void => {
|
|
27
|
+
const walk = (val = scope): void => (current.childNodes as DisplayObject[]).forEach((node) => traverse(node, val));
|
|
28
28
|
|
|
29
29
|
if (filter && !filter(current)) return walk();
|
|
30
30
|
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.0.
|
|
1
|
+
export const version = '5.0.22';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"position-radial-labels.js","sourceRoot":"src/","sources":["transforms/position-radial-labels.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MA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