@antv/g6 5.0.0-beta.11 → 5.0.0-beta.13
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 +2 -2
- package/esm/api-doc/graph.d.ts +3 -3
- package/esm/api-doc/graph.js +3 -3
- package/esm/api-doc/graph.js.map +1 -1
- package/esm/constant/shape.d.ts +1 -1
- package/esm/index.d.ts +12 -62
- package/esm/index.js +4 -5
- package/esm/index.js.map +1 -1
- package/esm/item/item.js +2 -1
- package/esm/item/item.js.map +1 -1
- package/esm/runtime/controller/item.js +34 -16
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/controller/layout.js +1 -3
- package/esm/runtime/controller/layout.js.map +1 -1
- package/esm/runtime/controller/plugin.js +8 -3
- package/esm/runtime/controller/plugin.js.map +1 -1
- package/esm/runtime/graph.d.ts +1 -1
- package/esm/runtime/graph.js +11 -5
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/drag-canvas.d.ts +2 -1
- package/esm/stdlib/behavior/drag-canvas.js +12 -5
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
- package/esm/stdlib/behavior/shortcuts-call.d.ts +2 -2
- package/esm/stdlib/behavior/shortcuts-call.js +12 -5
- package/esm/stdlib/behavior/shortcuts-call.js.map +1 -1
- package/esm/stdlib/behavior/zoom-canvas-3d.js +4 -1
- package/esm/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
- package/esm/stdlib/behavior/zoom-canvas.d.ts +1 -0
- package/esm/stdlib/behavior/zoom-canvas.js +8 -2
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/esm/stdlib/index.d.ts +6 -1
- package/esm/stdlib/index.js +8 -3
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/edge/base.js +5 -1
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/edge/cubic-horizontal.js.map +1 -1
- package/esm/stdlib/item/edge/cubic-vertical.js.map +1 -1
- package/esm/stdlib/item/edge/cubic.js +1 -1
- package/esm/stdlib/item/edge/cubic.js.map +1 -1
- package/esm/stdlib/item/edge/loop.js +1 -1
- package/esm/stdlib/item/edge/loop.js.map +1 -1
- package/esm/stdlib/item/node/base.d.ts +1 -0
- package/esm/stdlib/item/node/base.js +5 -2
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/item/node/cube.d.ts +35 -0
- package/esm/stdlib/item/node/cube.js +54 -0
- package/esm/stdlib/item/node/cube.js.map +1 -0
- package/esm/stdlib/item/node/index.d.ts +3 -0
- package/esm/stdlib/item/node/index.js +3 -0
- package/esm/stdlib/item/node/index.js.map +1 -1
- package/esm/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
- package/esm/stdlib/plugin/edgeFilterLens/index.js +309 -0
- package/esm/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
- package/esm/stdlib/plugin/grid/index.d.ts +1 -1
- package/esm/stdlib/plugin/grid/index.js +3 -4
- package/esm/stdlib/plugin/grid/index.js.map +1 -1
- package/esm/stdlib/plugin/hull/convexHull.d.ts +1 -1
- package/esm/stdlib/plugin/hull/hullComponent.js +2 -3
- package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/esm/stdlib/plugin/hull/util.d.ts +2 -2
- package/esm/stdlib/plugin/hull/util.js +6 -2
- package/esm/stdlib/plugin/hull/util.js.map +1 -1
- package/esm/stdlib/plugin/index.d.ts +1 -0
- package/esm/stdlib/plugin/index.js +1 -0
- package/esm/stdlib/plugin/index.js.map +1 -1
- package/esm/stdlib/plugin/legend/index.d.ts +2 -2
- package/esm/stdlib/plugin/legend/index.js +3 -3
- package/esm/stdlib/plugin/legend/index.js.map +1 -1
- package/esm/stdlib/plugin/menu/index.d.ts +4 -4
- package/esm/stdlib/plugin/menu/index.js +3 -3
- package/esm/stdlib/plugin/menu/index.js.map +1 -1
- package/esm/stdlib/plugin/minimap/index.d.ts +1 -1
- package/esm/stdlib/plugin/minimap/index.js +3 -3
- package/esm/stdlib/plugin/minimap/index.js.map +1 -1
- package/esm/stdlib/plugin/timebar/index.js +2 -2
- package/esm/stdlib/plugin/timebar/index.js.map +1 -1
- package/esm/stdlib/plugin/toolbar/index.d.ts +3 -3
- package/esm/stdlib/plugin/toolbar/index.js +4 -4
- package/esm/stdlib/plugin/toolbar/index.js.map +1 -1
- package/esm/stdlib/plugin/tooltip/index.d.ts +4 -4
- package/esm/stdlib/plugin/tooltip/index.js +3 -4
- package/esm/stdlib/plugin/tooltip/index.js.map +1 -1
- package/esm/stdlib/plugin/types.d.ts +1 -0
- package/esm/stdlib/plugin/watermaker/index.d.ts +78 -0
- package/esm/stdlib/plugin/watermaker/index.js +243 -0
- package/esm/stdlib/plugin/watermaker/index.js.map +1 -0
- package/esm/types/index.d.ts +2 -1
- package/esm/types/index.js +1 -0
- package/esm/types/index.js.map +1 -1
- package/esm/types/plugin.d.ts +1 -1
- package/esm/util/bbox.js +4 -5
- package/esm/util/bbox.js.map +1 -1
- package/esm/util/behavior.d.ts +2 -2
- package/esm/util/behavior.js +2 -2
- package/esm/util/behavior.js.map +1 -1
- package/esm/util/data.d.ts +2 -2
- package/esm/util/data.js.map +1 -1
- package/esm/util/dom.d.ts +15 -0
- package/esm/util/dom.js +29 -0
- package/esm/util/dom.js.map +1 -0
- package/esm/util/extend.d.ts +1 -1
- package/esm/util/extend.js +0 -1
- package/esm/util/extend.js.map +1 -1
- package/esm/util/index.d.ts +7 -52
- package/esm/util/index.js +7 -23
- package/esm/util/index.js.map +1 -1
- package/esm/util/layout.d.ts +1 -1
- package/esm/util/layout.js.map +1 -1
- package/esm/util/loop.d.ts +1 -1
- package/esm/util/math.d.ts +1 -1
- package/esm/util/matrix.d.ts +6 -0
- package/esm/util/matrix.js +48 -0
- package/esm/util/matrix.js.map +1 -0
- package/esm/util/path.js +1 -1
- package/esm/util/path.js.map +1 -1
- package/esm/util/point.d.ts +1 -1
- package/esm/util/polyline.d.ts +2 -1
- package/esm/util/polyline.js +2 -1
- package/esm/util/polyline.js.map +1 -1
- package/esm/util/router.d.ts +1 -1
- package/esm/util/shape.js +12 -12
- package/esm/util/shape.js.map +1 -1
- package/esm/util/shape3d.js +15 -11
- package/esm/util/shape3d.js.map +1 -1
- package/esm/util/text.d.ts +1 -1
- package/esm/util/text.js +3 -2
- package/esm/util/text.js.map +1 -1
- package/lib/api-doc/graph.d.ts +3 -3
- package/lib/api-doc/graph.js +27 -7
- package/lib/api-doc/graph.js.map +1 -1
- package/lib/constant/shape.d.ts +1 -1
- package/lib/index.d.ts +12 -62
- package/lib/index.js +18 -10
- package/lib/index.js.map +1 -1
- package/lib/item/item.js +2 -1
- package/lib/item/item.js.map +1 -1
- package/lib/runtime/controller/item.js +34 -16
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/controller/layout.js +1 -3
- package/lib/runtime/controller/layout.js.map +1 -1
- package/lib/runtime/controller/plugin.js +8 -3
- package/lib/runtime/controller/plugin.js.map +1 -1
- package/lib/runtime/graph.d.ts +1 -1
- package/lib/runtime/graph.js +12 -5
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/drag-canvas.d.ts +2 -1
- package/lib/stdlib/behavior/drag-canvas.js +12 -5
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
- package/lib/stdlib/behavior/shortcuts-call.d.ts +2 -2
- package/lib/stdlib/behavior/shortcuts-call.js +12 -5
- package/lib/stdlib/behavior/shortcuts-call.js.map +1 -1
- package/lib/stdlib/behavior/zoom-canvas-3d.js +4 -1
- package/lib/stdlib/behavior/zoom-canvas-3d.js.map +1 -1
- package/lib/stdlib/behavior/zoom-canvas.d.ts +1 -0
- package/lib/stdlib/behavior/zoom-canvas.js +8 -2
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/lib/stdlib/index.d.ts +6 -1
- package/lib/stdlib/index.js +8 -3
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/edge/base.js +5 -1
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/edge/cubic-horizontal.js.map +1 -1
- package/lib/stdlib/item/edge/cubic-vertical.js.map +1 -1
- package/lib/stdlib/item/edge/cubic.js +2 -2
- package/lib/stdlib/item/edge/cubic.js.map +1 -1
- package/lib/stdlib/item/edge/loop.js +3 -3
- package/lib/stdlib/item/edge/loop.js.map +1 -1
- package/lib/stdlib/item/node/base.d.ts +1 -0
- package/lib/stdlib/item/node/base.js +5 -2
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/item/node/cube.d.ts +35 -0
- package/lib/stdlib/item/node/cube.js +58 -0
- package/lib/stdlib/item/node/cube.js.map +1 -0
- package/lib/stdlib/item/node/index.d.ts +3 -0
- package/lib/stdlib/item/node/index.js +3 -0
- package/lib/stdlib/item/node/index.js.map +1 -1
- package/lib/stdlib/plugin/edgeFilterLens/index.d.ts +66 -0
- package/lib/stdlib/plugin/edgeFilterLens/index.js +313 -0
- package/lib/stdlib/plugin/edgeFilterLens/index.js.map +1 -0
- package/lib/stdlib/plugin/grid/index.d.ts +1 -1
- package/lib/stdlib/plugin/grid/index.js +6 -7
- package/lib/stdlib/plugin/grid/index.js.map +1 -1
- package/lib/stdlib/plugin/hull/convexHull.d.ts +1 -1
- package/lib/stdlib/plugin/hull/hullComponent.js +2 -3
- package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/lib/stdlib/plugin/hull/util.d.ts +2 -2
- package/lib/stdlib/plugin/hull/util.js +26 -22
- package/lib/stdlib/plugin/hull/util.js.map +1 -1
- package/lib/stdlib/plugin/index.d.ts +1 -0
- package/lib/stdlib/plugin/index.js +1 -0
- package/lib/stdlib/plugin/index.js.map +1 -1
- package/lib/stdlib/plugin/legend/index.d.ts +2 -2
- package/lib/stdlib/plugin/legend/index.js +3 -3
- package/lib/stdlib/plugin/legend/index.js.map +1 -1
- package/lib/stdlib/plugin/menu/index.d.ts +4 -4
- package/lib/stdlib/plugin/menu/index.js +6 -6
- package/lib/stdlib/plugin/menu/index.js.map +1 -1
- package/lib/stdlib/plugin/minimap/index.d.ts +1 -1
- package/lib/stdlib/plugin/minimap/index.js +6 -6
- package/lib/stdlib/plugin/minimap/index.js.map +1 -1
- package/lib/stdlib/plugin/timebar/index.js +2 -2
- package/lib/stdlib/plugin/timebar/index.js.map +1 -1
- package/lib/stdlib/plugin/toolbar/index.d.ts +3 -3
- package/lib/stdlib/plugin/toolbar/index.js +5 -5
- package/lib/stdlib/plugin/toolbar/index.js.map +1 -1
- package/lib/stdlib/plugin/tooltip/index.d.ts +4 -4
- package/lib/stdlib/plugin/tooltip/index.js +10 -11
- package/lib/stdlib/plugin/tooltip/index.js.map +1 -1
- package/lib/stdlib/plugin/types.d.ts +1 -0
- package/lib/stdlib/plugin/watermaker/index.d.ts +78 -0
- package/lib/stdlib/plugin/watermaker/index.js +247 -0
- package/lib/stdlib/plugin/watermaker/index.js.map +1 -0
- package/lib/types/index.d.ts +2 -1
- package/lib/types/index.js +3 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/plugin.d.ts +1 -1
- package/lib/util/bbox.js +4 -5
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/behavior.d.ts +2 -2
- package/lib/util/behavior.js +2 -2
- package/lib/util/behavior.js.map +1 -1
- package/lib/util/data.d.ts +2 -2
- package/lib/util/data.js.map +1 -1
- package/lib/util/dom.d.ts +15 -0
- package/lib/util/dom.js +34 -0
- package/lib/util/dom.js.map +1 -0
- package/lib/util/extend.d.ts +1 -1
- package/lib/util/extend.js +0 -1
- package/lib/util/extend.js.map +1 -1
- package/lib/util/index.d.ts +7 -52
- package/lib/util/index.js +23 -23
- package/lib/util/index.js.map +1 -1
- package/lib/util/layout.d.ts +1 -1
- package/lib/util/layout.js.map +1 -1
- package/lib/util/loop.d.ts +1 -1
- package/lib/util/math.d.ts +1 -1
- package/lib/util/matrix.d.ts +6 -0
- package/lib/util/matrix.js +52 -0
- package/lib/util/matrix.js.map +1 -0
- package/lib/util/path.js +2 -2
- package/lib/util/path.js.map +1 -1
- package/lib/util/point.d.ts +1 -1
- package/lib/util/polyline.d.ts +2 -1
- package/lib/util/polyline.js +2 -1
- package/lib/util/polyline.js.map +1 -1
- package/lib/util/router.d.ts +1 -1
- package/lib/util/shape.js +12 -12
- package/lib/util/shape.js.map +1 -1
- package/lib/util/shape3d.js +15 -11
- package/lib/util/shape3d.js.map +1 -1
- package/lib/util/text.d.ts +1 -1
- package/lib/util/text.js +3 -2
- package/lib/util/text.js.map +1 -1
- package/package.json +34 -41
- package/src/api-doc/graph.ts +4 -3
- package/src/constant/shape.ts +1 -1
- package/src/index.ts +5 -6
- package/src/item/item.ts +2 -0
- package/src/runtime/controller/item.ts +33 -14
- package/src/runtime/controller/layout.ts +1 -5
- package/src/runtime/controller/plugin.ts +14 -3
- package/src/runtime/graph.ts +12 -6
- package/src/stdlib/behavior/drag-canvas.ts +19 -7
- package/src/stdlib/behavior/shortcuts-call.ts +13 -4
- package/src/stdlib/behavior/zoom-canvas-3d.ts +4 -1
- package/src/stdlib/behavior/zoom-canvas.ts +15 -2
- package/src/stdlib/index.ts +10 -1
- package/src/stdlib/item/edge/base.ts +5 -2
- package/src/stdlib/item/edge/cubic-horizontal.ts +0 -1
- package/src/stdlib/item/edge/cubic-vertical.ts +0 -1
- package/src/stdlib/item/edge/cubic.ts +1 -1
- package/src/stdlib/item/edge/loop.ts +1 -1
- package/src/stdlib/item/node/base.ts +5 -1
- package/src/stdlib/item/node/cube.ts +102 -0
- package/src/stdlib/item/node/index.ts +3 -0
- package/src/stdlib/plugin/edgeFilterLens/index.ts +387 -0
- package/src/stdlib/plugin/grid/index.ts +6 -6
- package/src/stdlib/plugin/hull/convexHull.ts +1 -1
- package/src/stdlib/plugin/hull/hullComponent.ts +2 -3
- package/src/stdlib/plugin/hull/util.ts +6 -2
- package/src/stdlib/plugin/index.ts +1 -0
- package/src/stdlib/plugin/legend/index.ts +6 -6
- package/src/stdlib/plugin/menu/index.ts +13 -13
- package/src/stdlib/plugin/minimap/index.ts +6 -6
- package/src/stdlib/plugin/timebar/index.ts +4 -4
- package/src/stdlib/plugin/toolbar/index.ts +8 -8
- package/src/stdlib/plugin/tooltip/index.ts +10 -10
- package/src/stdlib/plugin/types.ts +1 -0
- package/src/stdlib/plugin/watermaker/index.ts +302 -0
- package/src/types/index.ts +2 -1
- package/src/types/plugin.ts +1 -1
- package/src/util/bbox.ts +4 -5
- package/src/util/behavior.ts +4 -4
- package/src/util/data.ts +2 -3
- package/src/util/dom.ts +33 -0
- package/src/util/extend.ts +2 -3
- package/src/util/index.ts +7 -24
- package/src/util/layout.ts +3 -2
- package/src/util/loop.ts +1 -1
- package/src/util/math.ts +1 -1
- package/src/util/matrix.ts +66 -0
- package/src/util/path.ts +1 -1
- package/src/util/point.ts +1 -1
- package/src/util/polyline.ts +2 -1
- package/src/util/router.ts +1 -1
- package/src/util/shape.ts +16 -12
- package/src/util/shape3d.ts +19 -10
- package/src/util/text.ts +3 -1
- package/esm/stdlib/plugin/map/index.d.ts +0 -118
- package/esm/stdlib/plugin/map/index.js +0 -683
- package/esm/stdlib/plugin/map/index.js.map +0 -1
- package/lib/stdlib/plugin/map/index.d.ts +0 -118
- package/lib/stdlib/plugin/map/index.js +0 -687
- package/lib/stdlib/plugin/map/index.js.map +0 -1
- package/src/stdlib/plugin/map/index.ts +0 -808
|
@@ -225,9 +225,9 @@ export class ItemController {
|
|
|
225
225
|
|
|
226
226
|
// 0. clear groups on canvas, and create new groups
|
|
227
227
|
graph.canvas.removeChildren();
|
|
228
|
-
const comboGroup = new Group({ id: 'combo-group' });
|
|
229
|
-
const edgeGroup = new Group({ id: 'edge-group' });
|
|
230
|
-
const nodeGroup = new Group({ id: 'node-group' });
|
|
228
|
+
const comboGroup = new Group({ id: 'combo-group', style: { zIndex: 0 } });
|
|
229
|
+
const edgeGroup = new Group({ id: 'edge-group', style: { zIndex: 1 } });
|
|
230
|
+
const nodeGroup = new Group({ id: 'node-group', style: { zIndex: 2 } });
|
|
231
231
|
graph.canvas.appendChild(comboGroup);
|
|
232
232
|
graph.canvas.appendChild(edgeGroup);
|
|
233
233
|
graph.canvas.appendChild(nodeGroup);
|
|
@@ -237,9 +237,18 @@ export class ItemController {
|
|
|
237
237
|
|
|
238
238
|
// Also create transient groups on transient canvas.
|
|
239
239
|
transientCanvas.removeChildren();
|
|
240
|
-
this.transientComboGroup = new Group({
|
|
241
|
-
|
|
242
|
-
|
|
240
|
+
this.transientComboGroup = new Group({
|
|
241
|
+
id: 'combo-group',
|
|
242
|
+
style: { zIndex: 0 },
|
|
243
|
+
});
|
|
244
|
+
this.transientEdgeGroup = new Group({
|
|
245
|
+
id: 'edge-group',
|
|
246
|
+
style: { zIndex: 1 },
|
|
247
|
+
});
|
|
248
|
+
this.transientNodeGroup = new Group({
|
|
249
|
+
id: 'node-group',
|
|
250
|
+
style: { zIndex: 2 },
|
|
251
|
+
});
|
|
243
252
|
transientCanvas.appendChild(this.transientComboGroup);
|
|
244
253
|
transientCanvas.appendChild(this.transientEdgeGroup);
|
|
245
254
|
transientCanvas.appendChild(this.transientNodeGroup);
|
|
@@ -278,14 +287,16 @@ export class ItemController {
|
|
|
278
287
|
theme.node,
|
|
279
288
|
tileOptimize,
|
|
280
289
|
);
|
|
290
|
+
let nodesInView;
|
|
281
291
|
if (renderNodesPromise) {
|
|
282
|
-
await renderNodesPromise;
|
|
292
|
+
nodesInView = await renderNodesPromise;
|
|
283
293
|
}
|
|
284
294
|
this.renderCombos(combos, theme.combo, graphCore);
|
|
285
295
|
const renderEdgesPromise = this.renderEdges(
|
|
286
296
|
edges,
|
|
287
297
|
theme.edge,
|
|
288
298
|
tileOptimize,
|
|
299
|
+
nodesInView,
|
|
289
300
|
);
|
|
290
301
|
if (renderEdgesPromise) {
|
|
291
302
|
await renderEdgesPromise;
|
|
@@ -1115,18 +1126,18 @@ export class ItemController {
|
|
|
1115
1126
|
});
|
|
1116
1127
|
if (delayFirstDraw) {
|
|
1117
1128
|
let requestId;
|
|
1118
|
-
const
|
|
1119
|
-
const sectionNum = Math.ceil(items.length / tileFirstRenderSize);
|
|
1129
|
+
const sectionNum = Math.ceil(itemsOutView.length / tileFirstRenderSize);
|
|
1120
1130
|
const sections = Array.from({ length: sectionNum }, (v, i) =>
|
|
1121
|
-
|
|
1131
|
+
itemsOutView.slice(
|
|
1122
1132
|
i * tileFirstRenderSize,
|
|
1123
1133
|
i * tileFirstRenderSize + tileFirstRenderSize,
|
|
1124
1134
|
),
|
|
1125
1135
|
);
|
|
1136
|
+
sections.unshift(itemsInView);
|
|
1126
1137
|
const update = (resolve) => {
|
|
1127
1138
|
if (!sections.length) {
|
|
1128
1139
|
cancelAnimationFrame(requestId);
|
|
1129
|
-
return resolve();
|
|
1140
|
+
return resolve(itemsInView);
|
|
1130
1141
|
}
|
|
1131
1142
|
sections
|
|
1132
1143
|
.shift()
|
|
@@ -1221,6 +1232,7 @@ export class ItemController {
|
|
|
1221
1232
|
tileFirstRender?: boolean | number;
|
|
1222
1233
|
tileFirstRenderSize?: number;
|
|
1223
1234
|
},
|
|
1235
|
+
nodesInView?: Node[],
|
|
1224
1236
|
): Promise<any> | undefined {
|
|
1225
1237
|
const { edgeExtensions, edgeGroup, itemMap, edgeDataTypeSet, graph } = this;
|
|
1226
1238
|
const { dataTypeField = '' } = edgeTheme;
|
|
@@ -1230,7 +1242,10 @@ export class ItemController {
|
|
|
1230
1242
|
const delayFirstDraw = isNumber(tileFirstRender)
|
|
1231
1243
|
? models.length > tileFirstRender
|
|
1232
1244
|
: tileFirstRender;
|
|
1233
|
-
const
|
|
1245
|
+
const nodesInViewIds = new Set(nodesInView?.map((node) => node.getID()));
|
|
1246
|
+
const edgesInView = [];
|
|
1247
|
+
const edgesOutView = [];
|
|
1248
|
+
models.forEach((edge) => {
|
|
1234
1249
|
const { source, target, id } = edge;
|
|
1235
1250
|
const sourceItem = itemMap.get(source) as Node;
|
|
1236
1251
|
const targetItem = itemMap.get(target) as Node;
|
|
@@ -1276,18 +1291,22 @@ export class ItemController {
|
|
|
1276
1291
|
});
|
|
1277
1292
|
|
|
1278
1293
|
itemMap.set(id, edgeItem);
|
|
1294
|
+
if (nodesInViewIds.has(source) || nodesInViewIds.has(target))
|
|
1295
|
+
edgesInView.push(edgeItem);
|
|
1296
|
+
else edgesOutView.push(edgeItem);
|
|
1279
1297
|
return edgeItem;
|
|
1280
1298
|
});
|
|
1281
1299
|
|
|
1282
1300
|
if (delayFirstDraw) {
|
|
1283
1301
|
let requestId;
|
|
1284
|
-
const sectionNum = Math.ceil(
|
|
1302
|
+
const sectionNum = Math.ceil(edgesOutView.length / tileFirstRenderSize);
|
|
1285
1303
|
const sections = Array.from({ length: sectionNum }, (v, i) =>
|
|
1286
|
-
|
|
1304
|
+
edgesOutView.slice(
|
|
1287
1305
|
i * tileFirstRenderSize,
|
|
1288
1306
|
i * tileFirstRenderSize + tileFirstRenderSize,
|
|
1289
1307
|
),
|
|
1290
1308
|
);
|
|
1309
|
+
sections.unshift(edgesInView);
|
|
1291
1310
|
const update = (resolve) => {
|
|
1292
1311
|
if (!sections.length) {
|
|
1293
1312
|
cancelAnimationFrame(requestId);
|
|
@@ -97,8 +97,6 @@ export class LayoutController {
|
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
this.graph.emit('startlayout');
|
|
101
|
-
|
|
102
100
|
const [width, height] = this.graph.getSize();
|
|
103
101
|
const center = [width / 2, height / 2];
|
|
104
102
|
|
|
@@ -227,8 +225,6 @@ export class LayoutController {
|
|
|
227
225
|
}
|
|
228
226
|
}
|
|
229
227
|
|
|
230
|
-
this.graph.emit('endlayout');
|
|
231
|
-
|
|
232
228
|
// Update nodes' positions.
|
|
233
229
|
this.updateNodesPosition(positions, animate);
|
|
234
230
|
}
|
|
@@ -279,7 +275,7 @@ export class LayoutController {
|
|
|
279
275
|
animationEffectTiming,
|
|
280
276
|
);
|
|
281
277
|
}
|
|
282
|
-
this.graph.emit('
|
|
278
|
+
this.graph.emit('afterlayout');
|
|
283
279
|
this.updateNodesPosition(
|
|
284
280
|
{ nodes: nodePositions, edges: [] },
|
|
285
281
|
animated || animate,
|
|
@@ -116,7 +116,7 @@ export class PluginController {
|
|
|
116
116
|
if (action === 'add') {
|
|
117
117
|
pluginCfgs.forEach((config) => {
|
|
118
118
|
const { key, plugin } = this.initPlugin(config);
|
|
119
|
-
this.addListeners(key, plugin);
|
|
119
|
+
this.addListeners(key, plugin, false);
|
|
120
120
|
});
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
@@ -158,7 +158,7 @@ export class PluginController {
|
|
|
158
158
|
const { plugin } = item;
|
|
159
159
|
plugin.updateCfgs(config);
|
|
160
160
|
this.removeListeners(key);
|
|
161
|
-
this.addListeners(key, plugin);
|
|
161
|
+
this.addListeners(key, plugin, false);
|
|
162
162
|
});
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
@@ -184,7 +184,11 @@ export class PluginController {
|
|
|
184
184
|
return plugin;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
private addListeners = (
|
|
187
|
+
private addListeners = (
|
|
188
|
+
key: string,
|
|
189
|
+
plugin: PluginBase,
|
|
190
|
+
initWithGraph: boolean = true,
|
|
191
|
+
) => {
|
|
188
192
|
const events = plugin.getEvents();
|
|
189
193
|
this.listenersMap[key] = {};
|
|
190
194
|
Object.keys(events).forEach((eventName) => {
|
|
@@ -196,6 +200,13 @@ export class PluginController {
|
|
|
196
200
|
);
|
|
197
201
|
this.graph.on(eventName, listener);
|
|
198
202
|
this.listenersMap[key][eventName] = listener;
|
|
203
|
+
// The plugin is not initiated with graph, some events are not listened, trigger them manually
|
|
204
|
+
if (
|
|
205
|
+
!initWithGraph &&
|
|
206
|
+
['afterrender', 'afterlayout'].includes(eventName)
|
|
207
|
+
) {
|
|
208
|
+
listener({} as any);
|
|
209
|
+
}
|
|
199
210
|
});
|
|
200
211
|
};
|
|
201
212
|
|
package/src/runtime/graph.ts
CHANGED
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
isString,
|
|
22
22
|
map,
|
|
23
23
|
} from '@antv/util';
|
|
24
|
-
import { createDom } from '@antv/dom-util';
|
|
25
24
|
import { History } from '../stdlib/plugin/history';
|
|
26
25
|
import { Command } from '../stdlib/plugin/history/command';
|
|
27
26
|
import type {
|
|
@@ -57,6 +56,7 @@ import { FitViewRules, GraphTransformOptions } from '../types/view';
|
|
|
57
56
|
import { changeRenderer, createCanvas } from '../util/canvas';
|
|
58
57
|
import { formatPadding } from '../util/shape';
|
|
59
58
|
import { getLayoutBounds } from '../util/layout';
|
|
59
|
+
import { createDOM } from '../util/dom';
|
|
60
60
|
import { Plugin as PluginBase } from '../types/plugin';
|
|
61
61
|
import { ComboMapper, EdgeMapper, NodeMapper } from '../types/spec';
|
|
62
62
|
import {
|
|
@@ -71,7 +71,7 @@ import {
|
|
|
71
71
|
import { PluginController } from './controller/plugin';
|
|
72
72
|
import Hook from './hooks';
|
|
73
73
|
|
|
74
|
-
export
|
|
74
|
+
export class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
75
75
|
extends EventEmitter
|
|
76
76
|
implements IGraph<B, T>
|
|
77
77
|
{
|
|
@@ -180,7 +180,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
180
180
|
this.canvas = canvas;
|
|
181
181
|
this.backgroundCanvas = backgroundCanvas;
|
|
182
182
|
this.transientCanvas = transientCanvas;
|
|
183
|
-
this.container = container as
|
|
183
|
+
this.container = container as HTMLElement;
|
|
184
184
|
} else {
|
|
185
185
|
const containerDOM = isString(container)
|
|
186
186
|
? document.getElementById(container as string)
|
|
@@ -236,7 +236,8 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
236
236
|
.getContextService()
|
|
237
237
|
.getDomElement() as unknown as HTMLElement;
|
|
238
238
|
if ($domElement && $domElement.style) {
|
|
239
|
-
|
|
239
|
+
// Make all these 3 canvas doms overlap each other. The container already has `position: relative` style.
|
|
240
|
+
$domElement.style.position = 'absolute';
|
|
240
241
|
$domElement.style.outline = 'none';
|
|
241
242
|
$domElement.tabIndex = 1; // Enable keyboard events
|
|
242
243
|
// Transient canvas should let interactive events go through.
|
|
@@ -881,9 +882,14 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
881
882
|
);
|
|
882
883
|
return;
|
|
883
884
|
}
|
|
885
|
+
const oldSize = [this.specification.width, this.specification.height];
|
|
886
|
+
this.emit('beforesetsize', { oldSize, size: size });
|
|
884
887
|
this.specification.width = size[0];
|
|
885
888
|
this.specification.height = size[1];
|
|
886
889
|
this.canvas.resize(size[0], size[1]);
|
|
890
|
+
this.transientCanvas.resize(size[0], size[1]);
|
|
891
|
+
this.backgroundCanvas.resize(size[0], size[1]);
|
|
892
|
+
this.emit('aftersetsize', { oldSize, size: size });
|
|
887
893
|
}
|
|
888
894
|
|
|
889
895
|
public getCanvasRange(): Bounds {
|
|
@@ -2188,7 +2194,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2188
2194
|
const width = this.getSize()[0];
|
|
2189
2195
|
const height = this.getSize()[1];
|
|
2190
2196
|
|
|
2191
|
-
const vContainerDOM:
|
|
2197
|
+
const vContainerDOM: HTMLElement = createDOM(
|
|
2192
2198
|
'<div id="virtual-image"></div>',
|
|
2193
2199
|
);
|
|
2194
2200
|
const vCanvas = createCanvas(
|
|
@@ -2296,7 +2302,7 @@ export default class Graph<B extends BehaviorRegistry, T extends ThemeRegistry>
|
|
|
2296
2302
|
typeof window !== 'undefined' ? window.devicePixelRatio : 1;
|
|
2297
2303
|
const vWidth = halfX * 2;
|
|
2298
2304
|
const vHeight = halfY * 2;
|
|
2299
|
-
const vContainerDOM:
|
|
2305
|
+
const vContainerDOM: HTMLElement = createDOM(
|
|
2300
2306
|
'<div id="virtual-image"></div>',
|
|
2301
2307
|
);
|
|
2302
2308
|
const vCanvas = createCanvas(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isNumber } from '@antv/util';
|
|
2
|
-
import { ID, IG6GraphEvent } from '../../types';
|
|
3
2
|
import { Behavior } from '../../types/behavior';
|
|
4
3
|
import { Point } from '../../types/common';
|
|
4
|
+
import { ID, IG6GraphEvent } from '../../types';
|
|
5
5
|
|
|
6
6
|
const VALID_TRIGGERS = ['drag', 'directionKeys'];
|
|
7
7
|
export interface DragCanvasOptions {
|
|
@@ -75,6 +75,7 @@ export class DragCanvas extends Behavior {
|
|
|
75
75
|
private hiddenEdgeIds: ID[];
|
|
76
76
|
private hiddenNodeIds: ID[];
|
|
77
77
|
private tileRequestId?: number;
|
|
78
|
+
private lastDragTriggerTime?: number;
|
|
78
79
|
|
|
79
80
|
constructor(options: Partial<DragCanvasOptions>) {
|
|
80
81
|
const finalOptions = Object.assign({}, DEFAULT_OPTIONS, options);
|
|
@@ -236,6 +237,22 @@ export class DragCanvas extends Behavior {
|
|
|
236
237
|
const { eventName, direction, secondaryKeyToDisable } = this.options;
|
|
237
238
|
// disabled key is pressing
|
|
238
239
|
if (secondaryKeyToDisable && this.disableKeydown) return;
|
|
240
|
+
|
|
241
|
+
// begin dragging
|
|
242
|
+
if (!this.dragging) {
|
|
243
|
+
this.hideShapes();
|
|
244
|
+
this.dragging = true;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const now = Date.now();
|
|
248
|
+
const MOUSE_ZOOM_DURATION = 250;
|
|
249
|
+
if (
|
|
250
|
+
this.lastDragTriggerTime &&
|
|
251
|
+
now - this.lastDragTriggerTime < MOUSE_ZOOM_DURATION / 5
|
|
252
|
+
) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
239
256
|
const { graph } = this;
|
|
240
257
|
const { client } = event;
|
|
241
258
|
const diffX = client.x - this.pointerDownAt.x;
|
|
@@ -244,12 +261,6 @@ export class DragCanvas extends Behavior {
|
|
|
244
261
|
if (direction === 'y' && !diffY) return;
|
|
245
262
|
if (direction === 'both' && !diffX && !diffY) return;
|
|
246
263
|
|
|
247
|
-
// begin dragging
|
|
248
|
-
if (!this.dragging) {
|
|
249
|
-
this.hideShapes();
|
|
250
|
-
this.dragging = true;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
264
|
const { dx, dy } = this.formatDisplacement(diffX, diffY);
|
|
254
265
|
graph.translate({ dx, dy });
|
|
255
266
|
|
|
@@ -259,6 +270,7 @@ export class DragCanvas extends Behavior {
|
|
|
259
270
|
if (eventName) {
|
|
260
271
|
this.graph.emit(eventName, { translate: { dx, dy } });
|
|
261
272
|
}
|
|
273
|
+
this.lastDragTriggerTime = now;
|
|
262
274
|
}
|
|
263
275
|
|
|
264
276
|
public onPointerUp() {
|
|
@@ -78,8 +78,6 @@ export class ShortcutsCall extends Behavior {
|
|
|
78
78
|
(codeLowerCase === 'ctrl' && triggerLowerCase === 'control')
|
|
79
79
|
) {
|
|
80
80
|
this.triggerKeydown = true;
|
|
81
|
-
} else {
|
|
82
|
-
this.triggerKeydown = false;
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
83
|
|
|
@@ -114,7 +112,18 @@ export class ShortcutsCall extends Behavior {
|
|
|
114
112
|
}
|
|
115
113
|
}
|
|
116
114
|
|
|
117
|
-
public onKeyUp() {
|
|
118
|
-
|
|
115
|
+
public onKeyUp(e) {
|
|
116
|
+
const code = e.key;
|
|
117
|
+
if (!code) return;
|
|
118
|
+
const { trigger } = this.options;
|
|
119
|
+
const triggerLowerCase = trigger.toLowerCase();
|
|
120
|
+
const codeLowerCase = code.toLowerCase();
|
|
121
|
+
if (
|
|
122
|
+
codeLowerCase === triggerLowerCase ||
|
|
123
|
+
(codeLowerCase === 'control' && triggerLowerCase === 'ctrl') ||
|
|
124
|
+
(codeLowerCase === 'ctrl' && triggerLowerCase === 'control')
|
|
125
|
+
) {
|
|
126
|
+
this.triggerKeydown = false;
|
|
127
|
+
}
|
|
119
128
|
}
|
|
120
129
|
}
|
|
@@ -123,7 +123,10 @@ export class ZoomCanvas3D extends Behavior {
|
|
|
123
123
|
((100 * sign * sensitivity) / currentDistance) *
|
|
124
124
|
Math.sqrt(currentDistance);
|
|
125
125
|
const toDistance = currentDistance + dolly;
|
|
126
|
-
const
|
|
126
|
+
const azimuth = camera.getAzimuth();
|
|
127
|
+
const isFlipped = azimuth < 90 && azimuth > -90 ? 1 : -1;
|
|
128
|
+
const distancePositive = camera.getDistanceVector()[2] < 0 ? 1 : -1;
|
|
129
|
+
const cameraFrontOfFocalPoint = isFlipped * distancePositive > 0;
|
|
127
130
|
|
|
128
131
|
// zoom out constraint
|
|
129
132
|
if (
|
|
@@ -59,7 +59,7 @@ export interface ZoomCanvasOptions {
|
|
|
59
59
|
const DEFAULT_OPTIONS: Required<ZoomCanvasOptions> = {
|
|
60
60
|
enableOptimize: undefined,
|
|
61
61
|
triggerOnItems: true,
|
|
62
|
-
sensitivity:
|
|
62
|
+
sensitivity: 10,
|
|
63
63
|
trigger: 'wheel',
|
|
64
64
|
secondaryKey: '',
|
|
65
65
|
speedUpKey: 'shift',
|
|
@@ -77,6 +77,7 @@ export class ZoomCanvas extends Behavior {
|
|
|
77
77
|
private hiddenNodeIds: ID[];
|
|
78
78
|
private zoomTimer: ReturnType<typeof setTimeout>;
|
|
79
79
|
private tileRequestId?: number;
|
|
80
|
+
private lastWheelTriggerTime?: number;
|
|
80
81
|
|
|
81
82
|
constructor(options: Partial<ZoomCanvasOptions>) {
|
|
82
83
|
const finalOptions = Object.assign({}, DEFAULT_OPTIONS, options);
|
|
@@ -232,15 +233,27 @@ export class ZoomCanvas extends Behavior {
|
|
|
232
233
|
this.hideShapes();
|
|
233
234
|
this.zooming = true;
|
|
234
235
|
}
|
|
236
|
+
|
|
237
|
+
const now = Date.now();
|
|
238
|
+
const MOUSE_ZOOM_DURATION = 250;
|
|
239
|
+
if (
|
|
240
|
+
this.lastWheelTriggerTime &&
|
|
241
|
+
now - this.lastWheelTriggerTime < MOUSE_ZOOM_DURATION / 5
|
|
242
|
+
) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
235
246
|
let zoomRatio = 1;
|
|
236
247
|
if (deltaY < 0) zoomRatio = (100 + sensitivity) / 100;
|
|
237
248
|
if (deltaY > 0) zoomRatio = 100 / (100 + sensitivity);
|
|
238
249
|
const zoomTo = zoomRatio * graph.getZoom();
|
|
239
250
|
if (minZoom && zoomTo < minZoom) return;
|
|
240
251
|
if (maxZoom && zoomTo > maxZoom) return;
|
|
241
|
-
|
|
252
|
+
|
|
242
253
|
graph.zoom(zoomRatio, { x: client.x, y: client.y });
|
|
243
254
|
|
|
255
|
+
this.lastWheelTriggerTime = now;
|
|
256
|
+
|
|
244
257
|
clearTimeout(this.zoomTimer);
|
|
245
258
|
this.zoomTimer = setTimeout(() => {
|
|
246
259
|
this.endZoom();
|
package/src/stdlib/index.ts
CHANGED
|
@@ -32,6 +32,9 @@ const {
|
|
|
32
32
|
EllipseNode,
|
|
33
33
|
ModelRectNode,
|
|
34
34
|
ImageNode,
|
|
35
|
+
CubeNode,
|
|
36
|
+
BaseNode,
|
|
37
|
+
BaseNode3D,
|
|
35
38
|
} = Nodes;
|
|
36
39
|
|
|
37
40
|
const {
|
|
@@ -76,6 +79,7 @@ const {
|
|
|
76
79
|
Toolbar,
|
|
77
80
|
Timebar,
|
|
78
81
|
Snapline,
|
|
82
|
+
EdgeFilterLens,
|
|
79
83
|
} = Plugins;
|
|
80
84
|
|
|
81
85
|
const {
|
|
@@ -96,6 +100,7 @@ const {
|
|
|
96
100
|
import lassoSelector from './selector/lasso';
|
|
97
101
|
import rectSelector from './selector/rect';
|
|
98
102
|
import Hull from './plugin/hull';
|
|
103
|
+
import { WaterMarker } from './plugin/watermaker';
|
|
99
104
|
|
|
100
105
|
const stdLib = {
|
|
101
106
|
transforms: {
|
|
@@ -123,7 +128,6 @@ const stdLib = {
|
|
|
123
128
|
'zoom-canvas': ZoomCanvas,
|
|
124
129
|
'drag-node': DragNode,
|
|
125
130
|
'drag-combo': DragCombo,
|
|
126
|
-
'create-edge': CreateEdge,
|
|
127
131
|
'collapse-expand-combo': CollapseExpandCombo,
|
|
128
132
|
'collapse-expand-tree': CollapseExpandTree,
|
|
129
133
|
'click-select': ClickSelect,
|
|
@@ -246,6 +250,9 @@ const Extensions = {
|
|
|
246
250
|
TriangleNode,
|
|
247
251
|
EllipseNode,
|
|
248
252
|
ModelRectNode,
|
|
253
|
+
CubeNode,
|
|
254
|
+
BaseNode,
|
|
255
|
+
BaseNode3D,
|
|
249
256
|
// edges
|
|
250
257
|
LineEdge,
|
|
251
258
|
CubicEdge,
|
|
@@ -289,6 +296,8 @@ const Extensions = {
|
|
|
289
296
|
Timebar,
|
|
290
297
|
Hull,
|
|
291
298
|
Snapline,
|
|
299
|
+
EdgeFilterLens,
|
|
300
|
+
WaterMarker,
|
|
292
301
|
};
|
|
293
302
|
|
|
294
303
|
export default registery;
|
|
@@ -289,9 +289,10 @@ export abstract class BaseEdge {
|
|
|
289
289
|
const pointOffset = (keyShape as Line | Polyline).getPoint(
|
|
290
290
|
positionPreset.pointRatio[1],
|
|
291
291
|
);
|
|
292
|
-
|
|
292
|
+
let angle = Math.atan(
|
|
293
293
|
(point.y - pointOffset.y) / (point.x - pointOffset.x),
|
|
294
|
-
);
|
|
294
|
+
);
|
|
295
|
+
if (isNaN(angle)) angle = 0;
|
|
295
296
|
|
|
296
297
|
// revert
|
|
297
298
|
isRevert = pointOffset.x < point.x;
|
|
@@ -331,6 +332,7 @@ export abstract class BaseEdge {
|
|
|
331
332
|
maxWidth,
|
|
332
333
|
this.zoomCache.zoom,
|
|
333
334
|
);
|
|
335
|
+
this.zoomCache.wordWrapWidth = wordWrapWidth;
|
|
334
336
|
const style = {
|
|
335
337
|
...this.defaultStyles.labelShape,
|
|
336
338
|
textAlign: positionPreset.textAlign,
|
|
@@ -339,6 +341,7 @@ export abstract class BaseEdge {
|
|
|
339
341
|
...positionStyle,
|
|
340
342
|
...otherStyle,
|
|
341
343
|
};
|
|
344
|
+
this.boundsCache.labelShapeTransform = style.transform;
|
|
342
345
|
return this.upsertShape('text', 'labelShape', style, shapeMap, model);
|
|
343
346
|
}
|
|
344
347
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DisplayObject } from '@antv/g';
|
|
2
|
-
import { vec2 } from '
|
|
2
|
+
import { vec2 } from 'gl-matrix';
|
|
3
3
|
import { Point } from '../../../types/common';
|
|
4
4
|
import { EdgeModelData, EdgeShapeMap } from '../../../types/edge';
|
|
5
5
|
import { State } from '../../../types/item';
|
|
@@ -41,6 +41,7 @@ export abstract class BaseNode {
|
|
|
41
41
|
themeStyles: NodeShapeStyles | ComboShapeStyles;
|
|
42
42
|
mergedStyles: NodeShapeStyles | ComboShapeStyles;
|
|
43
43
|
lodStrategy?: LodStrategyObj;
|
|
44
|
+
enableBalanceShape?: boolean;
|
|
44
45
|
boundsCache: {
|
|
45
46
|
keyShapeLocal?: AABB;
|
|
46
47
|
labelShapeGeometry?: AABB;
|
|
@@ -84,9 +85,10 @@ export abstract class BaseNode {
|
|
|
84
85
|
};
|
|
85
86
|
|
|
86
87
|
constructor(props) {
|
|
87
|
-
const { themeStyles, lodStrategy, zoom } = props;
|
|
88
|
+
const { themeStyles, lodStrategy, enableBalanceShape, zoom } = props;
|
|
88
89
|
if (themeStyles) this.themeStyles = themeStyles;
|
|
89
90
|
this.lodStrategy = lodStrategy;
|
|
91
|
+
this.enableBalanceShape = enableBalanceShape;
|
|
90
92
|
this.boundsCache = {};
|
|
91
93
|
this.zoomCache.zoom = zoom;
|
|
92
94
|
this.zoomCache.balanceRatio = 1 / zoom;
|
|
@@ -306,6 +308,7 @@ export abstract class BaseNode {
|
|
|
306
308
|
keyShapeBox as AABB,
|
|
307
309
|
maxWidth,
|
|
308
310
|
this.zoomCache.zoom,
|
|
311
|
+
this.enableBalanceShape,
|
|
309
312
|
);
|
|
310
313
|
|
|
311
314
|
const positionPreset = {
|
|
@@ -873,6 +876,7 @@ export abstract class BaseNode {
|
|
|
873
876
|
shapeMap: NodeShapeMap | ComboShapeMap,
|
|
874
877
|
zoom: number,
|
|
875
878
|
) {
|
|
879
|
+
if (!this.enableBalanceShape) return;
|
|
876
880
|
// balance the size for label, badges
|
|
877
881
|
const { keyShape, labelShape, labelBackgroundShape } = shapeMap;
|
|
878
882
|
const balanceRatio = 1 / zoom || 1;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { DisplayObject } from '@antv/g';
|
|
2
|
+
import { NodeDisplayModel } from '../../../types';
|
|
3
|
+
import { State } from '../../../types/item';
|
|
4
|
+
import {
|
|
5
|
+
NodeModelData,
|
|
6
|
+
NodeShapeMap,
|
|
7
|
+
NodeShapeStyles,
|
|
8
|
+
} from '../../../types/node';
|
|
9
|
+
import { BaseNode3D } from './base3d';
|
|
10
|
+
|
|
11
|
+
export class CubeNode extends BaseNode3D {
|
|
12
|
+
override defaultStyles = {
|
|
13
|
+
keyShape: {
|
|
14
|
+
latitudeBands: 32,
|
|
15
|
+
longitudeBands: 32,
|
|
16
|
+
width: 10,
|
|
17
|
+
height: 10,
|
|
18
|
+
depth: 10,
|
|
19
|
+
x: 0,
|
|
20
|
+
y: 0,
|
|
21
|
+
z: 0,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
mergedStyles: NodeShapeStyles;
|
|
25
|
+
constructor(props) {
|
|
26
|
+
super(props);
|
|
27
|
+
}
|
|
28
|
+
public draw(
|
|
29
|
+
model: NodeDisplayModel,
|
|
30
|
+
shapeMap: NodeShapeMap,
|
|
31
|
+
diffData?: { previous: NodeModelData; current: NodeModelData },
|
|
32
|
+
diffState?: { previous: State[]; current: State[] },
|
|
33
|
+
): NodeShapeMap {
|
|
34
|
+
const { data = {} } = model;
|
|
35
|
+
|
|
36
|
+
let shapes: NodeShapeMap = { keyShape: undefined };
|
|
37
|
+
|
|
38
|
+
// keyShape
|
|
39
|
+
shapes.keyShape = this.drawKeyShape(model, shapeMap, diffData);
|
|
40
|
+
|
|
41
|
+
// haloShape
|
|
42
|
+
if (data.haloShape && this.drawHaloShape) {
|
|
43
|
+
shapes.haloShape = this.drawHaloShape(model, shapeMap, diffData);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// labelShape
|
|
47
|
+
if (data.labelShape) {
|
|
48
|
+
shapes.labelShape = this.drawLabelShape(model, shapeMap, diffData);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// labelBackgroundShape
|
|
52
|
+
if (data.labelBackgroundShape) {
|
|
53
|
+
shapes.labelBackgroundShape = this.drawLabelBackgroundShape(
|
|
54
|
+
model,
|
|
55
|
+
shapeMap,
|
|
56
|
+
diffData,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// iconShape
|
|
61
|
+
if (data.iconShape) {
|
|
62
|
+
shapes.iconShape = this.drawIconShape(model, shapeMap, diffData);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// badgeShape
|
|
66
|
+
if (data.badgeShapes) {
|
|
67
|
+
const badgeShapes = this.drawBadgeShapes(
|
|
68
|
+
model,
|
|
69
|
+
shapeMap,
|
|
70
|
+
diffData,
|
|
71
|
+
diffState,
|
|
72
|
+
);
|
|
73
|
+
shapes = {
|
|
74
|
+
...shapes,
|
|
75
|
+
...badgeShapes,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// otherShapes
|
|
80
|
+
if (data.otherShapes && this.drawOtherShapes) {
|
|
81
|
+
shapes = {
|
|
82
|
+
...shapes,
|
|
83
|
+
...this.drawOtherShapes(model, shapeMap, diffData),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return shapes;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public drawKeyShape(
|
|
90
|
+
model: NodeDisplayModel,
|
|
91
|
+
shapeMap: NodeShapeMap,
|
|
92
|
+
diffData?: { previous: NodeModelData; current: NodeModelData },
|
|
93
|
+
diffState?: { previous: State[]; current: State[] },
|
|
94
|
+
): DisplayObject {
|
|
95
|
+
return this.upsertShape(
|
|
96
|
+
'cube',
|
|
97
|
+
'keyShape',
|
|
98
|
+
this.mergedStyles.keyShape,
|
|
99
|
+
shapeMap,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|