@antv/g6 5.0.44 → 5.0.45

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.
Files changed (170) hide show
  1. package/dist/g6.min.js +11 -11
  2. package/dist/lib/plugins/edge-filter-lens/index.d.ts +2 -2
  3. package/dist/lib/plugins/grid-line.d.ts +19 -1
  4. package/dist/lib/plugins/hull/hull/format.d.ts +9 -0
  5. package/dist/lib/plugins/hull/hull/grid_handle.d.ts +15 -0
  6. package/dist/lib/plugins/hull/hull/index.d.ts +3 -0
  7. package/dist/lib/plugins/hull/hull/monotone-convex-hull-2d.d.ts +2 -0
  8. package/dist/lib/plugins/hull/hull/robust-orientation.d.ts +2 -0
  9. package/dist/lib/plugins/hull/hull/robust-scale.d.ts +1 -0
  10. package/dist/lib/plugins/hull/hull/robust-segment-intersect.d.ts +2 -0
  11. package/dist/lib/plugins/hull/hull/robust-subtract.d.ts +1 -0
  12. package/dist/lib/plugins/hull/hull/robust-sum.d.ts +1 -0
  13. package/dist/lib/plugins/hull/hull/two-product.d.ts +1 -0
  14. package/dist/lib/plugins/hull/hull/two-sum.d.ts +1 -0
  15. package/dist/lib/plugins/toolbar/util.d.ts +4 -0
  16. package/dist/lib/transforms/process-parallel-edges.d.ts +14 -2
  17. package/dist/lib/utils/element.d.ts +9 -9
  18. package/dist/lib/version.d.ts +1 -1
  19. package/esm/plugins/edge-filter-lens/index.d.ts +2 -2
  20. package/esm/plugins/edge-filter-lens/index.js +2 -0
  21. package/esm/plugins/edge-filter-lens/index.js.map +1 -1
  22. package/esm/plugins/fisheye/index.js +3 -0
  23. package/esm/plugins/fisheye/index.js.map +1 -1
  24. package/esm/plugins/grid-line.d.ts +19 -1
  25. package/esm/plugins/grid-line.js +42 -5
  26. package/esm/plugins/grid-line.js.map +1 -1
  27. package/esm/plugins/hull/hull/format.d.ts +9 -0
  28. package/esm/plugins/hull/hull/format.js +20 -0
  29. package/esm/plugins/hull/hull/format.js.map +1 -0
  30. package/esm/plugins/hull/hull/grid_handle.d.ts +15 -0
  31. package/esm/plugins/hull/hull/grid_handle.js +66 -0
  32. package/esm/plugins/hull/hull/grid_handle.js.map +1 -0
  33. package/esm/plugins/hull/hull/index.d.ts +3 -0
  34. package/esm/plugins/hull/hull/index.js +150 -0
  35. package/esm/plugins/hull/hull/index.js.map +1 -0
  36. package/esm/plugins/hull/hull/monotone-convex-hull-2d.d.ts +2 -0
  37. package/esm/plugins/hull/hull/monotone-convex-hull-2d.js +63 -0
  38. package/esm/plugins/hull/hull/monotone-convex-hull-2d.js.map +1 -0
  39. package/esm/plugins/hull/hull/robust-orientation.d.ts +2 -0
  40. package/esm/plugins/hull/hull/robust-orientation.js +145 -0
  41. package/esm/plugins/hull/hull/robust-orientation.js.map +1 -0
  42. package/esm/plugins/hull/hull/robust-scale.d.ts +1 -0
  43. package/esm/plugins/hull/hull/robust-scale.js +47 -0
  44. package/esm/plugins/hull/hull/robust-scale.js.map +1 -0
  45. package/esm/plugins/hull/hull/robust-segment-intersect.d.ts +2 -0
  46. package/esm/plugins/hull/hull/robust-segment-intersect.js +29 -0
  47. package/esm/plugins/hull/hull/robust-segment-intersect.js.map +1 -0
  48. package/esm/plugins/hull/hull/robust-subtract.d.ts +1 -0
  49. package/esm/plugins/hull/hull/robust-subtract.js +161 -0
  50. package/esm/plugins/hull/hull/robust-subtract.js.map +1 -0
  51. package/esm/plugins/hull/hull/robust-sum.d.ts +1 -0
  52. package/esm/plugins/hull/hull/robust-sum.js +155 -0
  53. package/esm/plugins/hull/hull/robust-sum.js.map +1 -0
  54. package/esm/plugins/hull/hull/two-product.d.ts +1 -0
  55. package/esm/plugins/hull/hull/two-product.js +24 -0
  56. package/esm/plugins/hull/hull/two-product.js.map +1 -0
  57. package/esm/plugins/hull/hull/two-sum.d.ts +1 -0
  58. package/esm/plugins/hull/hull/two-sum.js +15 -0
  59. package/esm/plugins/hull/hull/two-sum.js.map +1 -0
  60. package/esm/plugins/hull/index.js +1 -1
  61. package/esm/plugins/hull/index.js.map +1 -1
  62. package/esm/plugins/minimap/index.js +1 -1
  63. package/esm/plugins/minimap/index.js.map +1 -1
  64. package/esm/plugins/toolbar/index.js +6 -3
  65. package/esm/plugins/toolbar/index.js.map +1 -1
  66. package/esm/plugins/toolbar/util.d.ts +4 -0
  67. package/esm/plugins/toolbar/util.js.map +1 -1
  68. package/esm/runtime/graph.js +1 -1
  69. package/esm/runtime/graph.js.map +1 -1
  70. package/esm/runtime/layout.js +4 -4
  71. package/esm/runtime/layout.js.map +1 -1
  72. package/esm/transforms/process-parallel-edges.d.ts +14 -2
  73. package/esm/transforms/process-parallel-edges.js +35 -10
  74. package/esm/transforms/process-parallel-edges.js.map +1 -1
  75. package/esm/utils/edge.js +5 -4
  76. package/esm/utils/edge.js.map +1 -1
  77. package/esm/utils/element.d.ts +9 -9
  78. package/esm/utils/element.js +30 -20
  79. package/esm/utils/element.js.map +1 -1
  80. package/esm/version.d.ts +1 -1
  81. package/esm/version.js +1 -1
  82. package/lib/plugins/edge-filter-lens/index.d.ts +2 -2
  83. package/lib/plugins/edge-filter-lens/index.js +2 -0
  84. package/lib/plugins/edge-filter-lens/index.js.map +1 -1
  85. package/lib/plugins/fisheye/index.js +3 -0
  86. package/lib/plugins/fisheye/index.js.map +1 -1
  87. package/lib/plugins/grid-line.d.ts +19 -1
  88. package/lib/plugins/grid-line.js +41 -4
  89. package/lib/plugins/grid-line.js.map +1 -1
  90. package/lib/plugins/hull/hull/format.d.ts +9 -0
  91. package/lib/plugins/hull/hull/format.js +23 -0
  92. package/lib/plugins/hull/hull/format.js.map +1 -0
  93. package/lib/plugins/hull/hull/grid_handle.d.ts +15 -0
  94. package/lib/plugins/hull/hull/grid_handle.js +71 -0
  95. package/lib/plugins/hull/hull/grid_handle.js.map +1 -0
  96. package/lib/plugins/hull/hull/index.d.ts +3 -0
  97. package/lib/plugins/hull/hull/index.js +153 -0
  98. package/lib/plugins/hull/hull/index.js.map +1 -0
  99. package/lib/plugins/hull/hull/monotone-convex-hull-2d.d.ts +2 -0
  100. package/lib/plugins/hull/hull/monotone-convex-hull-2d.js +68 -0
  101. package/lib/plugins/hull/hull/monotone-convex-hull-2d.js.map +1 -0
  102. package/lib/plugins/hull/hull/robust-orientation.d.ts +2 -0
  103. package/lib/plugins/hull/hull/robust-orientation.js +146 -0
  104. package/lib/plugins/hull/hull/robust-orientation.js.map +1 -0
  105. package/lib/plugins/hull/hull/robust-scale.d.ts +1 -0
  106. package/lib/plugins/hull/hull/robust-scale.js +49 -0
  107. package/lib/plugins/hull/hull/robust-scale.js.map +1 -0
  108. package/lib/plugins/hull/hull/robust-segment-intersect.d.ts +2 -0
  109. package/lib/plugins/hull/hull/robust-segment-intersect.js +35 -0
  110. package/lib/plugins/hull/hull/robust-segment-intersect.js.map +1 -0
  111. package/lib/plugins/hull/hull/robust-subtract.d.ts +1 -0
  112. package/lib/plugins/hull/hull/robust-subtract.js +163 -0
  113. package/lib/plugins/hull/hull/robust-subtract.js.map +1 -0
  114. package/lib/plugins/hull/hull/robust-sum.d.ts +1 -0
  115. package/lib/plugins/hull/hull/robust-sum.js +157 -0
  116. package/lib/plugins/hull/hull/robust-sum.js.map +1 -0
  117. package/lib/plugins/hull/hull/two-product.d.ts +1 -0
  118. package/lib/plugins/hull/hull/two-product.js +26 -0
  119. package/lib/plugins/hull/hull/two-product.js.map +1 -0
  120. package/lib/plugins/hull/hull/two-sum.d.ts +1 -0
  121. package/lib/plugins/hull/hull/two-sum.js +17 -0
  122. package/lib/plugins/hull/hull/two-sum.js.map +1 -0
  123. package/lib/plugins/hull/index.js +2 -5
  124. package/lib/plugins/hull/index.js.map +1 -1
  125. package/lib/plugins/minimap/index.js +1 -1
  126. package/lib/plugins/minimap/index.js.map +1 -1
  127. package/lib/plugins/toolbar/index.js +6 -3
  128. package/lib/plugins/toolbar/index.js.map +1 -1
  129. package/lib/plugins/toolbar/util.d.ts +4 -0
  130. package/lib/plugins/toolbar/util.js.map +1 -1
  131. package/lib/runtime/graph.js +1 -1
  132. package/lib/runtime/graph.js.map +1 -1
  133. package/lib/runtime/layout.js +4 -4
  134. package/lib/runtime/layout.js.map +1 -1
  135. package/lib/transforms/process-parallel-edges.d.ts +14 -2
  136. package/lib/transforms/process-parallel-edges.js +35 -10
  137. package/lib/transforms/process-parallel-edges.js.map +1 -1
  138. package/lib/utils/edge.js +5 -4
  139. package/lib/utils/edge.js.map +1 -1
  140. package/lib/utils/element.d.ts +9 -9
  141. package/lib/utils/element.js +30 -20
  142. package/lib/utils/element.js.map +1 -1
  143. package/lib/version.d.ts +1 -1
  144. package/lib/version.js +1 -1
  145. package/package.json +3 -4
  146. package/src/plugins/edge-filter-lens/index.ts +4 -4
  147. package/src/plugins/fisheye/index.ts +2 -0
  148. package/src/plugins/grid-line.ts +72 -8
  149. package/src/plugins/hull/hull/README.md +1 -0
  150. package/src/plugins/hull/hull/format.ts +29 -0
  151. package/src/plugins/hull/hull/grid_handle.ts +73 -0
  152. package/src/plugins/hull/hull/index.ts +203 -0
  153. package/src/plugins/hull/hull/monotone-convex-hull-2d.ts +76 -0
  154. package/src/plugins/hull/hull/robust-orientation.ts +443 -0
  155. package/src/plugins/hull/hull/robust-scale.ts +53 -0
  156. package/src/plugins/hull/hull/robust-segment-intersect.ts +29 -0
  157. package/src/plugins/hull/hull/robust-subtract.ts +187 -0
  158. package/src/plugins/hull/hull/robust-sum.ts +175 -0
  159. package/src/plugins/hull/hull/two-product.ts +31 -0
  160. package/src/plugins/hull/hull/two-sum.ts +17 -0
  161. package/src/plugins/hull/index.ts +1 -1
  162. package/src/plugins/minimap/index.ts +4 -8
  163. package/src/plugins/toolbar/index.ts +1 -1
  164. package/src/plugins/toolbar/util.ts +4 -0
  165. package/src/runtime/graph.ts +1 -1
  166. package/src/runtime/layout.ts +4 -4
  167. package/src/transforms/process-parallel-edges.ts +41 -10
  168. package/src/utils/edge.ts +5 -4
  169. package/src/utils/element.ts +33 -22
  170. 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
- this.renderMinimap();
145
- this.renderMask();
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() {
@@ -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
  /**
@@ -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
  /**
@@ -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 (const options of pipeline) {
104
- const index = pipeline.indexOf(options);
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 (const options of pipeline) {
139
- const index = pipeline.indexOf(options);
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);
@@ -78,6 +78,12 @@ export class ProcessParallelEdges extends BaseTransform<ProcessParallelEdgesOpti
78
78
  super(context, Object.assign({}, ProcessParallelEdges.defaultOptions, options));
79
79
  }
80
80
 
81
+ /**
82
+ * <zh/> 在每次绘制前处理平行边
83
+ *
84
+ * <en/> Process parallel edges before each drawing
85
+ * @param input
86
+ */
81
87
  public beforeDraw(input: DrawData): DrawData {
82
88
  const edges = this.getAffectedParallelEdges(input);
83
89
 
@@ -90,6 +96,12 @@ export class ProcessParallelEdges extends BaseTransform<ProcessParallelEdgesOpti
90
96
  return input;
91
97
  }
92
98
 
99
+ /**
100
+ * <zh/> 获取受影响的平行边
101
+ *
102
+ * <en/> Get affected parallel edges
103
+ * @param input
104
+ */
93
105
  private getAffectedParallelEdges = (input: DrawData): Map<ID, EdgeData> => {
94
106
  const {
95
107
  add: { edges: edgesToAdd },
@@ -240,9 +252,9 @@ export class ProcessParallelEdges extends BaseTransform<ProcessParallelEdgesOpti
240
252
  }
241
253
 
242
254
  /**
243
- * <zh/> 按照端点分组
255
+ * <zh/> 优化的按照端点分组方法,时间复杂度O(n)
244
256
  *
245
- * <en/> Group by endpoints
257
+ * <en/> Optimized method to group by endpoints, time complexity O(n)
246
258
  * @param edges - <zh/> 边集合 | <en/> Edges
247
259
  * @returns <zh/> 端点分组后的边集合 | <en/> Edges grouped by endpoints
248
260
  */
@@ -250,6 +262,7 @@ export const groupByEndpoints = (edges: Map<ID, EdgeData>) => {
250
262
  const edgeMap = new Map<string, EdgeData[]>();
251
263
  const processedEdgesSet = new Set<ID>();
252
264
  const reverses: Record<string, boolean> = {};
265
+ const includedEdgesInGroup = new Map<string, Set<ID>>();
253
266
 
254
267
  for (const [id, edge] of edges) {
255
268
  if (processedEdgesSet.has(id)) continue;
@@ -257,18 +270,36 @@ export const groupByEndpoints = (edges: Map<ID, EdgeData>) => {
257
270
  const { source, target } = edge;
258
271
  const sourceTarget = `${source}-${target}`;
259
272
 
260
- if (!edgeMap.has(sourceTarget)) edgeMap.set(sourceTarget, []);
261
- edgeMap.get(sourceTarget)!.push(edge);
262
- processedEdgesSet.add(id);
273
+ if (!edgeMap.has(sourceTarget)) {
274
+ edgeMap.set(sourceTarget, []);
275
+ includedEdgesInGroup.set(sourceTarget, new Set<ID>());
276
+ }
277
+
278
+ const sourceTargetEdges = edgeMap.get(sourceTarget);
279
+ const includedEdges = includedEdgesInGroup.get(sourceTarget);
280
+
281
+ if (sourceTargetEdges && includedEdges && !includedEdges.has(id)) {
282
+ sourceTargetEdges.push(edge);
283
+ includedEdges.add(id);
284
+ processedEdgesSet.add(id);
285
+ }
263
286
 
264
287
  for (const [otherId, sedge] of edges) {
265
- if (processedEdgesSet.has(otherId)) continue;
288
+ if (processedEdgesSet.has(otherId) || otherId === id) continue;
266
289
 
267
290
  if (isParallelEdges(edge, sedge)) {
268
- edgeMap.get(sourceTarget)!.push(sedge);
269
- processedEdgesSet.add(otherId);
270
- if (source === sedge.target && target === sedge.source) {
271
- reverses[`${sedge.source}|${sedge.target}|${edgeMap.get(sourceTarget)!.length - 1}`] = true;
291
+ const groupEdges = edgeMap.get(sourceTarget);
292
+ const includedGroupEdges = includedEdgesInGroup.get(sourceTarget);
293
+
294
+ if (groupEdges && includedGroupEdges && !includedGroupEdges.has(otherId)) {
295
+ groupEdges.push(sedge);
296
+ includedGroupEdges.add(otherId);
297
+
298
+ if (source === sedge.target && target === sedge.source) {
299
+ reverses[`${sedge.source}|${sedge.target}|${groupEdges.length - 1}`] = true;
300
+ }
301
+
302
+ processedEdgesSet.add(otherId);
272
303
  }
273
304
  }
274
305
  }
package/src/utils/edge.ts CHANGED
@@ -241,9 +241,10 @@ export function getCubicPath(sourcePoint: Point, targetPoint: Point, controlPoin
241
241
  * @returns <zh/> 返回绘制折线的路径 | <en/> Returns the path for drawing a polyline
242
242
  */
243
243
  export function getPolylinePath(points: Point[], radius = 0, z = false): PathArray {
244
+ const targetIndex = points.length - 1;
244
245
  const sourcePoint = points[0];
245
- const targetPoint = points[points.length - 1];
246
- const controlPoints = points.slice(1, points.length - 1);
246
+ const targetPoint = points[targetIndex];
247
+ const controlPoints = points.slice(1, targetIndex);
247
248
  const pathArray: PathArray = [['M', sourcePoint[0], sourcePoint[1]]];
248
249
  controlPoints.forEach((midPoint, i) => {
249
250
  const prevPoint = controlPoints[i - 1] || sourcePoint;
@@ -390,7 +391,7 @@ export function getCubicLoopPath(
390
391
 
391
392
  // 3. 如果定义了连接桩,调整端点以与连接桩边界相交 | If the port is defined, adjust the endpoint to intersect with the port boundary
392
393
  if (sourcePort) sourcePoint = getPortConnectionPoint(sourcePort, controlPoints[0]);
393
- if (targetPort) targetPoint = getPortConnectionPoint(targetPort, controlPoints[controlPoints.length - 1]);
394
+ if (targetPort) targetPoint = getPortConnectionPoint(targetPort, controlPoints.at(-1) as Point);
394
395
 
395
396
  return getCubicPath(sourcePoint, targetPoint, controlPoints);
396
397
  }
@@ -463,7 +464,7 @@ export function getPolylineLoopPath(
463
464
 
464
465
  // 3. 如果定义了连接桩,调整端点以与连接桩边界相交 | If the port is defined, adjust the endpoint to intersect with the port boundary
465
466
  if (sourcePort) sourcePoint = getPortConnectionPoint(sourcePort, controlPoints[0]);
466
- if (targetPort) targetPoint = getPortConnectionPoint(targetPort, controlPoints[controlPoints.length - 1]);
467
+ if (targetPort) targetPoint = getPortConnectionPoint(targetPort, controlPoints.at(-1) as Point);
467
468
 
468
469
  return getPolylinePath([sourcePoint, ...controlPoints, targetPoint], radius);
469
470
  }