@antv/g6 5.0.44 → 5.0.46
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/dist/g6.min.js +11 -11
- package/dist/lib/behaviors/zoom-canvas.d.ts +9 -1
- package/dist/lib/elements/nodes/image.d.ts +1 -0
- package/dist/lib/plugins/edge-filter-lens/index.d.ts +2 -2
- package/dist/lib/plugins/grid-line.d.ts +19 -1
- package/dist/lib/plugins/hull/hull/format.d.ts +9 -0
- package/dist/lib/plugins/hull/hull/grid_handle.d.ts +15 -0
- package/dist/lib/plugins/hull/hull/index.d.ts +3 -0
- package/dist/lib/plugins/hull/hull/monotone-convex-hull-2d.d.ts +2 -0
- package/dist/lib/plugins/hull/hull/robust-orientation.d.ts +2 -0
- package/dist/lib/plugins/hull/hull/robust-scale.d.ts +1 -0
- package/dist/lib/plugins/hull/hull/robust-segment-intersect.d.ts +2 -0
- package/dist/lib/plugins/hull/hull/robust-subtract.d.ts +1 -0
- package/dist/lib/plugins/hull/hull/robust-sum.d.ts +1 -0
- package/dist/lib/plugins/hull/hull/two-product.d.ts +1 -0
- package/dist/lib/plugins/hull/hull/two-sum.d.ts +1 -0
- package/dist/lib/plugins/toolbar/util.d.ts +4 -0
- package/dist/lib/registry/register.d.ts +1 -5
- package/dist/lib/transforms/process-parallel-edges.d.ts +14 -2
- package/dist/lib/utils/element.d.ts +9 -9
- package/dist/lib/version.d.ts +1 -1
- package/esm/behaviors/brush-select.js +3 -1
- package/esm/behaviors/brush-select.js.map +1 -1
- package/esm/behaviors/drag-element.js +2 -0
- package/esm/behaviors/drag-element.js.map +1 -1
- package/esm/behaviors/zoom-canvas.d.ts +9 -1
- package/esm/behaviors/zoom-canvas.js +2 -2
- package/esm/behaviors/zoom-canvas.js.map +1 -1
- package/esm/elements/nodes/image.d.ts +1 -0
- package/esm/elements/nodes/image.js +13 -2
- package/esm/elements/nodes/image.js.map +1 -1
- package/esm/plugins/edge-filter-lens/index.d.ts +2 -2
- package/esm/plugins/edge-filter-lens/index.js +2 -0
- package/esm/plugins/edge-filter-lens/index.js.map +1 -1
- package/esm/plugins/fisheye/index.js +3 -0
- package/esm/plugins/fisheye/index.js.map +1 -1
- package/esm/plugins/grid-line.d.ts +19 -1
- package/esm/plugins/grid-line.js +42 -5
- package/esm/plugins/grid-line.js.map +1 -1
- package/esm/plugins/hull/hull/format.d.ts +9 -0
- package/esm/plugins/hull/hull/format.js +20 -0
- package/esm/plugins/hull/hull/format.js.map +1 -0
- package/esm/plugins/hull/hull/grid_handle.d.ts +15 -0
- package/esm/plugins/hull/hull/grid_handle.js +66 -0
- package/esm/plugins/hull/hull/grid_handle.js.map +1 -0
- package/esm/plugins/hull/hull/index.d.ts +3 -0
- package/esm/plugins/hull/hull/index.js +150 -0
- package/esm/plugins/hull/hull/index.js.map +1 -0
- package/esm/plugins/hull/hull/monotone-convex-hull-2d.d.ts +2 -0
- package/esm/plugins/hull/hull/monotone-convex-hull-2d.js +63 -0
- package/esm/plugins/hull/hull/monotone-convex-hull-2d.js.map +1 -0
- package/esm/plugins/hull/hull/robust-orientation.d.ts +2 -0
- package/esm/plugins/hull/hull/robust-orientation.js +145 -0
- package/esm/plugins/hull/hull/robust-orientation.js.map +1 -0
- package/esm/plugins/hull/hull/robust-scale.d.ts +1 -0
- package/esm/plugins/hull/hull/robust-scale.js +47 -0
- package/esm/plugins/hull/hull/robust-scale.js.map +1 -0
- package/esm/plugins/hull/hull/robust-segment-intersect.d.ts +2 -0
- package/esm/plugins/hull/hull/robust-segment-intersect.js +29 -0
- package/esm/plugins/hull/hull/robust-segment-intersect.js.map +1 -0
- package/esm/plugins/hull/hull/robust-subtract.d.ts +1 -0
- package/esm/plugins/hull/hull/robust-subtract.js +161 -0
- package/esm/plugins/hull/hull/robust-subtract.js.map +1 -0
- package/esm/plugins/hull/hull/robust-sum.d.ts +1 -0
- package/esm/plugins/hull/hull/robust-sum.js +155 -0
- package/esm/plugins/hull/hull/robust-sum.js.map +1 -0
- package/esm/plugins/hull/hull/two-product.d.ts +1 -0
- package/esm/plugins/hull/hull/two-product.js +24 -0
- package/esm/plugins/hull/hull/two-product.js.map +1 -0
- package/esm/plugins/hull/hull/two-sum.d.ts +1 -0
- package/esm/plugins/hull/hull/two-sum.js +15 -0
- package/esm/plugins/hull/hull/two-sum.js.map +1 -0
- package/esm/plugins/hull/index.js +1 -1
- package/esm/plugins/hull/index.js.map +1 -1
- package/esm/plugins/minimap/index.js +3 -1
- package/esm/plugins/minimap/index.js.map +1 -1
- package/esm/plugins/toolbar/index.js +6 -3
- package/esm/plugins/toolbar/index.js.map +1 -1
- package/esm/plugins/toolbar/util.d.ts +4 -0
- package/esm/plugins/toolbar/util.js.map +1 -1
- package/esm/registry/register.d.ts +1 -5
- package/esm/registry/register.js +4 -10
- package/esm/registry/register.js.map +1 -1
- package/esm/runtime/graph.js +1 -1
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/layout.js +4 -4
- package/esm/runtime/layout.js.map +1 -1
- package/esm/transforms/process-parallel-edges.d.ts +14 -2
- package/esm/transforms/process-parallel-edges.js +35 -10
- package/esm/transforms/process-parallel-edges.js.map +1 -1
- package/esm/utils/edge.js +5 -4
- package/esm/utils/edge.js.map +1 -1
- package/esm/utils/element.d.ts +9 -9
- package/esm/utils/element.js +30 -20
- package/esm/utils/element.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/behaviors/brush-select.js +3 -1
- package/lib/behaviors/brush-select.js.map +1 -1
- package/lib/behaviors/drag-element.js +2 -0
- package/lib/behaviors/drag-element.js.map +1 -1
- package/lib/behaviors/zoom-canvas.d.ts +9 -1
- package/lib/behaviors/zoom-canvas.js +2 -2
- package/lib/behaviors/zoom-canvas.js.map +1 -1
- package/lib/elements/nodes/image.d.ts +1 -0
- package/lib/elements/nodes/image.js +13 -2
- package/lib/elements/nodes/image.js.map +1 -1
- package/lib/plugins/edge-filter-lens/index.d.ts +2 -2
- package/lib/plugins/edge-filter-lens/index.js +2 -0
- package/lib/plugins/edge-filter-lens/index.js.map +1 -1
- package/lib/plugins/fisheye/index.js +3 -0
- package/lib/plugins/fisheye/index.js.map +1 -1
- package/lib/plugins/grid-line.d.ts +19 -1
- package/lib/plugins/grid-line.js +41 -4
- package/lib/plugins/grid-line.js.map +1 -1
- package/lib/plugins/hull/hull/format.d.ts +9 -0
- package/lib/plugins/hull/hull/format.js +23 -0
- package/lib/plugins/hull/hull/format.js.map +1 -0
- package/lib/plugins/hull/hull/grid_handle.d.ts +15 -0
- package/lib/plugins/hull/hull/grid_handle.js +71 -0
- package/lib/plugins/hull/hull/grid_handle.js.map +1 -0
- package/lib/plugins/hull/hull/index.d.ts +3 -0
- package/lib/plugins/hull/hull/index.js +153 -0
- package/lib/plugins/hull/hull/index.js.map +1 -0
- package/lib/plugins/hull/hull/monotone-convex-hull-2d.d.ts +2 -0
- package/lib/plugins/hull/hull/monotone-convex-hull-2d.js +68 -0
- package/lib/plugins/hull/hull/monotone-convex-hull-2d.js.map +1 -0
- package/lib/plugins/hull/hull/robust-orientation.d.ts +2 -0
- package/lib/plugins/hull/hull/robust-orientation.js +146 -0
- package/lib/plugins/hull/hull/robust-orientation.js.map +1 -0
- package/lib/plugins/hull/hull/robust-scale.d.ts +1 -0
- package/lib/plugins/hull/hull/robust-scale.js +49 -0
- package/lib/plugins/hull/hull/robust-scale.js.map +1 -0
- package/lib/plugins/hull/hull/robust-segment-intersect.d.ts +2 -0
- package/lib/plugins/hull/hull/robust-segment-intersect.js +35 -0
- package/lib/plugins/hull/hull/robust-segment-intersect.js.map +1 -0
- package/lib/plugins/hull/hull/robust-subtract.d.ts +1 -0
- package/lib/plugins/hull/hull/robust-subtract.js +163 -0
- package/lib/plugins/hull/hull/robust-subtract.js.map +1 -0
- package/lib/plugins/hull/hull/robust-sum.d.ts +1 -0
- package/lib/plugins/hull/hull/robust-sum.js +157 -0
- package/lib/plugins/hull/hull/robust-sum.js.map +1 -0
- package/lib/plugins/hull/hull/two-product.d.ts +1 -0
- package/lib/plugins/hull/hull/two-product.js +26 -0
- package/lib/plugins/hull/hull/two-product.js.map +1 -0
- package/lib/plugins/hull/hull/two-sum.d.ts +1 -0
- package/lib/plugins/hull/hull/two-sum.js +17 -0
- package/lib/plugins/hull/hull/two-sum.js.map +1 -0
- package/lib/plugins/hull/index.js +2 -5
- package/lib/plugins/hull/index.js.map +1 -1
- package/lib/plugins/minimap/index.js +3 -1
- package/lib/plugins/minimap/index.js.map +1 -1
- package/lib/plugins/toolbar/index.js +6 -3
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/toolbar/util.d.ts +4 -0
- package/lib/plugins/toolbar/util.js.map +1 -1
- package/lib/registry/register.d.ts +1 -5
- package/lib/registry/register.js +4 -10
- package/lib/registry/register.js.map +1 -1
- package/lib/runtime/graph.js +1 -1
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/layout.js +4 -4
- package/lib/runtime/layout.js.map +1 -1
- package/lib/transforms/process-parallel-edges.d.ts +14 -2
- package/lib/transforms/process-parallel-edges.js +35 -10
- package/lib/transforms/process-parallel-edges.js.map +1 -1
- package/lib/utils/edge.js +5 -4
- package/lib/utils/edge.js.map +1 -1
- package/lib/utils/element.d.ts +9 -9
- package/lib/utils/element.js +30 -20
- package/lib/utils/element.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +9 -10
- package/src/behaviors/brush-select.ts +3 -2
- package/src/behaviors/drag-element.ts +1 -0
- package/src/behaviors/zoom-canvas.ts +10 -2
- package/src/elements/nodes/image.ts +14 -2
- package/src/plugins/edge-filter-lens/index.ts +4 -4
- package/src/plugins/fisheye/index.ts +2 -0
- package/src/plugins/grid-line.ts +72 -8
- package/src/plugins/hull/hull/README.md +1 -0
- package/src/plugins/hull/hull/format.ts +29 -0
- package/src/plugins/hull/hull/grid_handle.ts +73 -0
- package/src/plugins/hull/hull/index.ts +203 -0
- package/src/plugins/hull/hull/monotone-convex-hull-2d.ts +76 -0
- package/src/plugins/hull/hull/robust-orientation.ts +443 -0
- package/src/plugins/hull/hull/robust-scale.ts +53 -0
- package/src/plugins/hull/hull/robust-segment-intersect.ts +29 -0
- package/src/plugins/hull/hull/robust-subtract.ts +187 -0
- package/src/plugins/hull/hull/robust-sum.ts +175 -0
- package/src/plugins/hull/hull/two-product.ts +31 -0
- package/src/plugins/hull/hull/two-sum.ts +17 -0
- package/src/plugins/hull/index.ts +1 -1
- package/src/plugins/minimap/index.ts +6 -8
- package/src/plugins/toolbar/index.ts +1 -1
- package/src/plugins/toolbar/util.ts +4 -0
- package/src/registry/register.ts +5 -8
- package/src/runtime/graph.ts +1 -1
- package/src/runtime/layout.ts +4 -4
- package/src/transforms/process-parallel-edges.ts +41 -10
- package/src/utils/edge.ts +5 -4
- package/src/utils/element.ts +33 -22
- package/src/version.ts +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import { twoProduct } from './two-product';
|
|
4
|
+
import { fastTwoSum as twoSum } from './two-sum';
|
|
5
|
+
|
|
6
|
+
export function scaleLinearExpansion(e: number[], scale: number): number[] {
|
|
7
|
+
const n = e.length;
|
|
8
|
+
|
|
9
|
+
if (n === 1) {
|
|
10
|
+
const ts = twoProduct(e[0], scale);
|
|
11
|
+
if (ts[0]) {
|
|
12
|
+
return ts;
|
|
13
|
+
}
|
|
14
|
+
return [ts[1]];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const g = new Array(2 * n);
|
|
18
|
+
const q: [number, number] = [0.1, 0.1];
|
|
19
|
+
const t: [number, number] = [0.1, 0.1];
|
|
20
|
+
let count = 0;
|
|
21
|
+
|
|
22
|
+
twoProduct(e[0], scale, q);
|
|
23
|
+
if (q[0]) {
|
|
24
|
+
g[count++] = q[0];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
for (let i = 1; i < n; ++i) {
|
|
28
|
+
twoProduct(e[i], scale, t);
|
|
29
|
+
const pq = q[1];
|
|
30
|
+
twoSum(pq, t[0], q);
|
|
31
|
+
if (q[0]) {
|
|
32
|
+
g[count++] = q[0];
|
|
33
|
+
}
|
|
34
|
+
const a = t[1];
|
|
35
|
+
const b = q[1];
|
|
36
|
+
const x = a + b;
|
|
37
|
+
const bv = x - a;
|
|
38
|
+
const y = b - bv;
|
|
39
|
+
q[1] = x;
|
|
40
|
+
if (y) {
|
|
41
|
+
g[count++] = y;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (q[1]) {
|
|
46
|
+
g[count++] = q[1];
|
|
47
|
+
}
|
|
48
|
+
if (count === 0) {
|
|
49
|
+
g[count++] = 0.0;
|
|
50
|
+
}
|
|
51
|
+
g.length = count;
|
|
52
|
+
return g;
|
|
53
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Point } from '../../../types';
|
|
2
|
+
import orient from './robust-orientation';
|
|
3
|
+
|
|
4
|
+
function checkCollinear(a0: Point, a1: Point, b0: Point, b1: Point): boolean {
|
|
5
|
+
for (let d = 0; d < 2; ++d) {
|
|
6
|
+
const x0 = a0[d];
|
|
7
|
+
const y0 = a1[d];
|
|
8
|
+
const [l0, h0] = [Math.min(x0, y0), Math.max(x0, y0)];
|
|
9
|
+
|
|
10
|
+
const x1 = b0[d];
|
|
11
|
+
const y1 = b1[d];
|
|
12
|
+
const [l1, h1] = [Math.min(x1, y1), Math.max(x1, y1)];
|
|
13
|
+
if (h1 < l0 || h0 < l1) return false;
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function segmentsIntersect(a0: Point, a1: Point, b0: Point, b1: Point): boolean {
|
|
19
|
+
const x0 = orient(a0, b0, b1);
|
|
20
|
+
const y0 = orient(a1, b0, b1);
|
|
21
|
+
if ((x0 > 0 && y0 > 0) || (x0 < 0 && y0 < 0)) return false;
|
|
22
|
+
const x1 = orient(b0, a0, a1);
|
|
23
|
+
const y1 = orient(b1, a0, a1);
|
|
24
|
+
if ((x1 > 0 && y1 > 0) || (x1 < 0 && y1 < 0)) return false;
|
|
25
|
+
if (x0 === 0 && y0 === 0 && x1 === 0 && y1 === 0) {
|
|
26
|
+
return checkCollinear(a0, a1, b0, b1);
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function scalarScalar(a: number, b: number): number[] {
|
|
4
|
+
const x = a + b;
|
|
5
|
+
const bv = x - a;
|
|
6
|
+
const av = x - bv;
|
|
7
|
+
const br = b - bv;
|
|
8
|
+
const ar = a - av;
|
|
9
|
+
const y = ar + br;
|
|
10
|
+
|
|
11
|
+
if (y) {
|
|
12
|
+
return [y, x];
|
|
13
|
+
}
|
|
14
|
+
return [x];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function robustSubtract(e: number[], f: number[]): number[] {
|
|
18
|
+
const ne = e.length | 0;
|
|
19
|
+
const nf = f.length | 0;
|
|
20
|
+
|
|
21
|
+
// Base case: scalar subtraction
|
|
22
|
+
if (ne === 1 && nf === 1) {
|
|
23
|
+
return scalarScalar(e[0], -f[0]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const n = ne + nf;
|
|
27
|
+
const g = new Array(n);
|
|
28
|
+
let count = 0;
|
|
29
|
+
|
|
30
|
+
let ep_tr = 0;
|
|
31
|
+
let fp_tr = 0;
|
|
32
|
+
|
|
33
|
+
const abs = Math.abs;
|
|
34
|
+
let ei = e[ep_tr];
|
|
35
|
+
let ea = abs(ei);
|
|
36
|
+
let fi = -f[fp_tr];
|
|
37
|
+
let fa = abs(fi);
|
|
38
|
+
|
|
39
|
+
let a: number, b: number;
|
|
40
|
+
|
|
41
|
+
// Initial comparison to determine `a` and `b`
|
|
42
|
+
if (ea < fa) {
|
|
43
|
+
b = ei;
|
|
44
|
+
ep_tr += 1;
|
|
45
|
+
if (ep_tr < ne) {
|
|
46
|
+
ei = e[ep_tr];
|
|
47
|
+
ea = abs(ei);
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
b = fi;
|
|
51
|
+
fp_tr += 1;
|
|
52
|
+
if (fp_tr < nf) {
|
|
53
|
+
fi = -f[fp_tr];
|
|
54
|
+
fa = abs(fi);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if ((ep_tr < ne && ea < fa) || fp_tr >= nf) {
|
|
59
|
+
a = ei;
|
|
60
|
+
ep_tr += 1;
|
|
61
|
+
if (ep_tr < ne) {
|
|
62
|
+
ei = e[ep_tr];
|
|
63
|
+
ea = abs(ei);
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
a = fi;
|
|
67
|
+
fp_tr += 1;
|
|
68
|
+
if (fp_tr < nf) {
|
|
69
|
+
fi = -f[fp_tr];
|
|
70
|
+
fa = abs(fi);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let x = a + b;
|
|
75
|
+
let bv = x - a;
|
|
76
|
+
let y = b - bv;
|
|
77
|
+
|
|
78
|
+
let q0 = y;
|
|
79
|
+
let q1 = x;
|
|
80
|
+
|
|
81
|
+
let _x: number, _bv: number, _av: number, _br: number, _ar: number;
|
|
82
|
+
|
|
83
|
+
// Main loop for combining expansions
|
|
84
|
+
while (ep_tr < ne && fp_tr < nf) {
|
|
85
|
+
if (ea < fa) {
|
|
86
|
+
a = ei;
|
|
87
|
+
ep_tr += 1;
|
|
88
|
+
if (ep_tr < ne) {
|
|
89
|
+
ei = e[ep_tr];
|
|
90
|
+
ea = abs(ei);
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
a = fi;
|
|
94
|
+
fp_tr += 1;
|
|
95
|
+
if (fp_tr < nf) {
|
|
96
|
+
fi = -f[fp_tr];
|
|
97
|
+
fa = abs(fi);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
b = q0;
|
|
102
|
+
x = a + b;
|
|
103
|
+
bv = x - a;
|
|
104
|
+
y = b - bv;
|
|
105
|
+
|
|
106
|
+
if (y) {
|
|
107
|
+
g[count++] = y;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
_x = q1 + x;
|
|
111
|
+
_bv = _x - q1;
|
|
112
|
+
_av = _x - _bv;
|
|
113
|
+
_br = x - _bv;
|
|
114
|
+
_ar = q1 - _av;
|
|
115
|
+
|
|
116
|
+
q0 = _ar + _br;
|
|
117
|
+
q1 = _x;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Handle remaining elements in `e`
|
|
121
|
+
while (ep_tr < ne) {
|
|
122
|
+
a = ei;
|
|
123
|
+
b = q0;
|
|
124
|
+
x = a + b;
|
|
125
|
+
bv = x - a;
|
|
126
|
+
y = b - bv;
|
|
127
|
+
|
|
128
|
+
if (y) {
|
|
129
|
+
g[count++] = y;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
_x = q1 + x;
|
|
133
|
+
_bv = _x - q1;
|
|
134
|
+
_av = _x - _bv;
|
|
135
|
+
_br = x - _bv;
|
|
136
|
+
_ar = q1 - _av;
|
|
137
|
+
|
|
138
|
+
q0 = _ar + _br;
|
|
139
|
+
q1 = _x;
|
|
140
|
+
|
|
141
|
+
ep_tr += 1;
|
|
142
|
+
if (ep_tr < ne) {
|
|
143
|
+
ei = e[ep_tr];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Handle remaining elements in `f`
|
|
148
|
+
while (fp_tr < nf) {
|
|
149
|
+
a = fi;
|
|
150
|
+
b = q0;
|
|
151
|
+
x = a + b;
|
|
152
|
+
bv = x - a;
|
|
153
|
+
y = b - bv;
|
|
154
|
+
|
|
155
|
+
if (y) {
|
|
156
|
+
g[count++] = y;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
_x = q1 + x;
|
|
160
|
+
_bv = _x - q1;
|
|
161
|
+
_av = _x - _bv;
|
|
162
|
+
_br = x - _bv;
|
|
163
|
+
_ar = q1 - _av;
|
|
164
|
+
|
|
165
|
+
q0 = _ar + _br;
|
|
166
|
+
q1 = _x;
|
|
167
|
+
|
|
168
|
+
fp_tr += 1;
|
|
169
|
+
if (fp_tr < nf) {
|
|
170
|
+
fi = -f[fp_tr];
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Finalize the result
|
|
175
|
+
if (q0) {
|
|
176
|
+
g[count++] = q0;
|
|
177
|
+
}
|
|
178
|
+
if (q1) {
|
|
179
|
+
g[count++] = q1;
|
|
180
|
+
}
|
|
181
|
+
if (!count) {
|
|
182
|
+
g[count++] = 0.0;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
g.length = count;
|
|
186
|
+
return g;
|
|
187
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function scalarScalar(a: number, b: number): number[] {
|
|
4
|
+
const x = a + b;
|
|
5
|
+
const bv = x - a;
|
|
6
|
+
const av = x - bv;
|
|
7
|
+
const br = b - bv;
|
|
8
|
+
const ar = a - av;
|
|
9
|
+
const y = ar + br;
|
|
10
|
+
|
|
11
|
+
if (y) {
|
|
12
|
+
return [y, x];
|
|
13
|
+
}
|
|
14
|
+
return [x];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function linearExpansionSum(e: number[], f: number[]): number[] {
|
|
18
|
+
const ne = e.length | 0;
|
|
19
|
+
const nf = f.length | 0;
|
|
20
|
+
|
|
21
|
+
if (ne === 1 && nf === 1) {
|
|
22
|
+
return scalarScalar(e[0], f[0]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const n = ne + nf;
|
|
26
|
+
const g = new Array(n);
|
|
27
|
+
let count = 0;
|
|
28
|
+
|
|
29
|
+
let ep_tr = 0;
|
|
30
|
+
let fp_tr = 0;
|
|
31
|
+
|
|
32
|
+
const abs = Math.abs;
|
|
33
|
+
let ei = e[ep_tr];
|
|
34
|
+
let ea = abs(ei);
|
|
35
|
+
let fi = f[fp_tr];
|
|
36
|
+
let fa = abs(fi);
|
|
37
|
+
let a, b;
|
|
38
|
+
|
|
39
|
+
if (ea < fa) {
|
|
40
|
+
b = ei;
|
|
41
|
+
ep_tr += 1;
|
|
42
|
+
if (ep_tr < ne) {
|
|
43
|
+
ei = e[ep_tr];
|
|
44
|
+
ea = abs(ei);
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
b = fi;
|
|
48
|
+
fp_tr += 1;
|
|
49
|
+
if (fp_tr < nf) {
|
|
50
|
+
fi = f[fp_tr];
|
|
51
|
+
fa = abs(fi);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if ((ep_tr < ne && ea < fa) || fp_tr >= nf) {
|
|
56
|
+
a = ei;
|
|
57
|
+
ep_tr += 1;
|
|
58
|
+
if (ep_tr < ne) {
|
|
59
|
+
ei = e[ep_tr];
|
|
60
|
+
ea = abs(ei);
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
a = fi;
|
|
64
|
+
fp_tr += 1;
|
|
65
|
+
if (fp_tr < nf) {
|
|
66
|
+
fi = f[fp_tr];
|
|
67
|
+
fa = abs(fi);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let x = a + b;
|
|
72
|
+
let bv = x - a;
|
|
73
|
+
let y = b - bv;
|
|
74
|
+
let q0 = y;
|
|
75
|
+
let q1 = x;
|
|
76
|
+
|
|
77
|
+
let _x, _bv, _av, _br, _ar;
|
|
78
|
+
|
|
79
|
+
while (ep_tr < ne && fp_tr < nf) {
|
|
80
|
+
if (ea < fa) {
|
|
81
|
+
a = ei;
|
|
82
|
+
ep_tr += 1;
|
|
83
|
+
if (ep_tr < ne) {
|
|
84
|
+
ei = e[ep_tr];
|
|
85
|
+
ea = abs(ei);
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
a = fi;
|
|
89
|
+
fp_tr += 1;
|
|
90
|
+
if (fp_tr < nf) {
|
|
91
|
+
fi = f[fp_tr];
|
|
92
|
+
fa = abs(fi);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
b = q0;
|
|
97
|
+
x = a + b;
|
|
98
|
+
bv = x - a;
|
|
99
|
+
y = b - bv;
|
|
100
|
+
|
|
101
|
+
if (y) {
|
|
102
|
+
g[count++] = y;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_x = q1 + x;
|
|
106
|
+
_bv = _x - q1;
|
|
107
|
+
_av = _x - _bv;
|
|
108
|
+
_br = x - _bv;
|
|
109
|
+
_ar = q1 - _av;
|
|
110
|
+
q0 = _ar + _br;
|
|
111
|
+
q1 = _x;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
while (ep_tr < ne) {
|
|
115
|
+
a = ei;
|
|
116
|
+
b = q0;
|
|
117
|
+
x = a + b;
|
|
118
|
+
bv = x - a;
|
|
119
|
+
y = b - bv;
|
|
120
|
+
|
|
121
|
+
if (y) {
|
|
122
|
+
g[count++] = y;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
_x = q1 + x;
|
|
126
|
+
_bv = _x - q1;
|
|
127
|
+
_av = _x - _bv;
|
|
128
|
+
_br = x - _bv;
|
|
129
|
+
_ar = q1 - _av;
|
|
130
|
+
q0 = _ar + _br;
|
|
131
|
+
q1 = _x;
|
|
132
|
+
|
|
133
|
+
ep_tr += 1;
|
|
134
|
+
if (ep_tr < ne) {
|
|
135
|
+
ei = e[ep_tr];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
while (fp_tr < nf) {
|
|
140
|
+
a = fi;
|
|
141
|
+
b = q0;
|
|
142
|
+
x = a + b;
|
|
143
|
+
bv = x - a;
|
|
144
|
+
y = b - bv;
|
|
145
|
+
|
|
146
|
+
if (y) {
|
|
147
|
+
g[count++] = y;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
_x = q1 + x;
|
|
151
|
+
_bv = _x - q1;
|
|
152
|
+
_av = _x - _bv;
|
|
153
|
+
_br = x - _bv;
|
|
154
|
+
_ar = q1 - _av;
|
|
155
|
+
q0 = _ar + _br;
|
|
156
|
+
q1 = _x;
|
|
157
|
+
|
|
158
|
+
fp_tr += 1;
|
|
159
|
+
if (fp_tr < nf) {
|
|
160
|
+
fi = f[fp_tr];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (q0) {
|
|
165
|
+
g[count++] = q0;
|
|
166
|
+
}
|
|
167
|
+
if (q1) {
|
|
168
|
+
g[count++] = q1;
|
|
169
|
+
}
|
|
170
|
+
if (!count) {
|
|
171
|
+
g[count++] = 0.0;
|
|
172
|
+
}
|
|
173
|
+
g.length = count;
|
|
174
|
+
return g;
|
|
175
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const SPLITTER: number = +(Math.pow(2, 27) + 1.0);
|
|
4
|
+
|
|
5
|
+
export function twoProduct(a: number, b: number, result?: [number, number]): [number, number] {
|
|
6
|
+
const x: number = a * b;
|
|
7
|
+
|
|
8
|
+
const c: number = SPLITTER * a;
|
|
9
|
+
const a_big: number = c - a;
|
|
10
|
+
const ahi: number = c - a_big;
|
|
11
|
+
const alo: number = a - ahi;
|
|
12
|
+
|
|
13
|
+
const d: number = SPLITTER * b;
|
|
14
|
+
const b_big: number = d - b;
|
|
15
|
+
const bhi: number = d - b_big;
|
|
16
|
+
const blo: number = b - bhi;
|
|
17
|
+
|
|
18
|
+
const err1: number = x - ahi * bhi;
|
|
19
|
+
const err2: number = err1 - alo * bhi;
|
|
20
|
+
const err3: number = err2 - ahi * blo;
|
|
21
|
+
|
|
22
|
+
const y: number = alo * blo - err3;
|
|
23
|
+
|
|
24
|
+
if (result) {
|
|
25
|
+
result[0] = y;
|
|
26
|
+
result[1] = x;
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return [y, x];
|
|
31
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
export function fastTwoSum(a: number, b: number, result?: [number, number]): [number, number] {
|
|
4
|
+
const x = a + b;
|
|
5
|
+
const bv = x - a;
|
|
6
|
+
const av = x - bv;
|
|
7
|
+
const br = b - bv;
|
|
8
|
+
const ar = a - av;
|
|
9
|
+
|
|
10
|
+
if (result) {
|
|
11
|
+
result[0] = ar + br;
|
|
12
|
+
result[1] = x;
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return [ar + br, x];
|
|
17
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PathArray, isEqual, isFunction } from '@antv/util';
|
|
2
|
-
import hull from 'hull.js';
|
|
3
2
|
import { GraphEvent } from '../../constants';
|
|
4
3
|
import type { ContourStyleProps } from '../../elements/shapes';
|
|
5
4
|
import { Contour } from '../../elements/shapes';
|
|
@@ -10,6 +9,7 @@ import { idOf } from '../../utils/id';
|
|
|
10
9
|
import { positionOf } from '../../utils/position';
|
|
11
10
|
import type { BasePluginOptions } from '../base-plugin';
|
|
12
11
|
import { BasePlugin } from '../base-plugin';
|
|
12
|
+
import { hull } from './hull';
|
|
13
13
|
import { computeHullPath } from './util';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -139,14 +139,10 @@ export class Minimap extends BasePlugin<MinimapOptions> {
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
private setOnRender() {
|
|
142
|
-
this.onRender = debounce(
|
|
143
|
-
()
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
},
|
|
147
|
-
this.options.delay,
|
|
148
|
-
true,
|
|
149
|
-
);
|
|
142
|
+
this.onRender = debounce(() => {
|
|
143
|
+
this.renderMinimap();
|
|
144
|
+
this.renderMask();
|
|
145
|
+
}, this.options.delay);
|
|
150
146
|
}
|
|
151
147
|
|
|
152
148
|
private bindEvents() {
|
|
@@ -396,6 +392,8 @@ export class Minimap extends BasePlugin<MinimapOptions> {
|
|
|
396
392
|
if (!this.mask) {
|
|
397
393
|
this.mask = document.createElement('div');
|
|
398
394
|
this.mask.addEventListener('pointerdown', this.onMaskDragStart);
|
|
395
|
+
this.mask.draggable = true;
|
|
396
|
+
this.mask.addEventListener('dragstart', (event) => event.preventDefault && event.preventDefault());
|
|
399
397
|
}
|
|
400
398
|
|
|
401
399
|
this.container.appendChild(this.mask);
|
|
@@ -111,7 +111,7 @@ export class Toolbar extends BasePlugin<ToolbarOptions> {
|
|
|
111
111
|
return items
|
|
112
112
|
.map(
|
|
113
113
|
(item) => `
|
|
114
|
-
<div class="g6-toolbar-item" value="${item.value}">
|
|
114
|
+
<div class="g6-toolbar-item" value="${item.value}" title="${item.title ?? ''}">
|
|
115
115
|
<svg aria-hidden="true" focusable="false">
|
|
116
116
|
<use xlink:href="#${item.id}"></use>
|
|
117
117
|
</svg>
|
|
@@ -18,6 +18,10 @@ export interface ToolbarItem {
|
|
|
18
18
|
* <en/> The value corresponding to the toolbar item, used as a callback parameter in `onClick`.
|
|
19
19
|
*/
|
|
20
20
|
readonly value: string;
|
|
21
|
+
/**
|
|
22
|
+
* <en/> The title of the toolbar item. The title will be displayed as a tooltip when the mouse hovers over the item.
|
|
23
|
+
*/
|
|
24
|
+
readonly title?: string;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
/**
|
package/src/registry/register.ts
CHANGED
|
@@ -19,10 +19,6 @@ import type { ExtensionRegistry } from './types';
|
|
|
19
19
|
* @param Ctor
|
|
20
20
|
* <zh/> 要注册的扩展类,在使用时创建实例
|
|
21
21
|
*
|
|
22
|
-
* <en/> The extension class to be registered. An instance will be created upon use
|
|
23
|
-
* @param override
|
|
24
|
-
* <zh/> 是否覆盖已注册的扩展
|
|
25
|
-
*
|
|
26
22
|
* <en/> Whether to override the registered extension
|
|
27
23
|
* @remarks
|
|
28
24
|
* <zh/> 内置扩展在项目导入时会自动注册。对于非内置扩展,可以通过 `register` 方法手动注册。扩展只需要注册一次,即可在项目的任何位置使用。
|
|
@@ -42,10 +38,11 @@ export function register<T extends ExtensionCategory>(
|
|
|
42
38
|
category: Loosen<T>,
|
|
43
39
|
type: string,
|
|
44
40
|
Ctor: ExtensionRegistry[T][string],
|
|
45
|
-
override = false,
|
|
46
41
|
) {
|
|
47
42
|
const ext = EXTENSION_REGISTRY[category][type];
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
}
|
|
43
|
+
if (ext) {
|
|
44
|
+
print.warn(`The extension ${type} of ${category} has been registered before, and will be overridden.`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
Object.assign(EXTENSION_REGISTRY[category]!, { [type]: Ctor });
|
|
51
48
|
}
|
package/src/runtime/graph.ts
CHANGED
|
@@ -1399,7 +1399,7 @@ export class Graph extends EventEmitter {
|
|
|
1399
1399
|
* @apiCategory viewport
|
|
1400
1400
|
*/
|
|
1401
1401
|
public async zoomTo(zoom: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void> {
|
|
1402
|
-
this.context.viewport!.transform({ mode: 'absolute', scale: zoom, origin }, animation);
|
|
1402
|
+
await this.context.viewport!.transform({ mode: 'absolute', scale: zoom, origin }, animation);
|
|
1403
1403
|
}
|
|
1404
1404
|
|
|
1405
1405
|
/**
|
package/src/runtime/layout.ts
CHANGED
|
@@ -100,8 +100,8 @@ export class LayoutController {
|
|
|
100
100
|
const pipeline = Array.isArray(layoutOptions) ? layoutOptions : [layoutOptions];
|
|
101
101
|
const { graph } = this.context;
|
|
102
102
|
emit(graph, new GraphLifeCycleEvent(GraphEvent.BEFORE_LAYOUT, { type: 'post' }));
|
|
103
|
-
for (
|
|
104
|
-
const
|
|
103
|
+
for (let index = 0; index < pipeline.length; index++) {
|
|
104
|
+
const options = pipeline[index];
|
|
105
105
|
const data = this.getLayoutData(options);
|
|
106
106
|
const opts = { ...this.presetOptions, ...options };
|
|
107
107
|
|
|
@@ -135,8 +135,8 @@ export class LayoutController {
|
|
|
135
135
|
|
|
136
136
|
let simulation: GraphData = {};
|
|
137
137
|
|
|
138
|
-
for (
|
|
139
|
-
const
|
|
138
|
+
for (let index = 0; index < pipeline.length; index++) {
|
|
139
|
+
const options = pipeline[index];
|
|
140
140
|
|
|
141
141
|
const data = this.getLayoutData(options);
|
|
142
142
|
const result = await this.stepLayout(data, { ...this.presetOptions, ...options, animation: false }, index);
|