@antv/layout 0.3.12 → 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -32
- package/dist/3a54d760230d1933f953.worker.js +2 -0
- package/dist/3a54d760230d1933f953.worker.js.map +1 -0
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/lib/Circular.d.ts +40 -0
- package/lib/Supervisor.d.ts +65 -0
- package/lib/index.d.ts +4 -3
- package/lib/registry.d.ts +3 -0
- package/lib/types.d.ts +128 -0
- package/lib/util/gpu.d.ts +22 -22
- package/lib/util/index.d.ts +6 -6
- package/lib/util/math.d.ts +3 -3
- package/lib/worker.d.ts +3 -0
- package/package.json +21 -95
- package/dist/layout.min.js +0 -3
- package/dist/layout.min.js.LICENSE.txt +0 -1
- package/dist/layout.min.js.map +0 -1
- package/es/index.d.ts +0 -3
- package/es/index.js +0 -6
- package/es/index.js.map +0 -1
- package/es/layout/base.d.ts +0 -22
- package/es/layout/base.js +0 -51
- package/es/layout/base.js.map +0 -1
- package/es/layout/circular.d.ts +0 -80
- package/es/layout/circular.js +0 -314
- package/es/layout/circular.js.map +0 -1
- package/es/layout/comboCombined.d.ts +0 -54
- package/es/layout/comboCombined.js +0 -354
- package/es/layout/comboCombined.js.map +0 -1
- package/es/layout/comboForce.d.ts +0 -134
- package/es/layout/comboForce.js +0 -801
- package/es/layout/comboForce.js.map +0 -1
- package/es/layout/concentric.d.ts +0 -67
- package/es/layout/concentric.js +0 -219
- package/es/layout/concentric.js.map +0 -1
- package/es/layout/constants.d.ts +0 -12
- package/es/layout/constants.js +0 -22
- package/es/layout/constants.js.map +0 -1
- package/es/layout/dagre/graph.d.ts +0 -91
- package/es/layout/dagre/graph.js +0 -4
- package/es/layout/dagre/graph.js.map +0 -1
- package/es/layout/dagre/index.d.ts +0 -8
- package/es/layout/dagre/index.js +0 -31
- package/es/layout/dagre/index.js.map +0 -1
- package/es/layout/dagre/src/acyclic.d.ts +0 -6
- package/es/layout/dagre/src/acyclic.js +0 -52
- package/es/layout/dagre/src/acyclic.js.map +0 -1
- package/es/layout/dagre/src/add-border-segments.d.ts +0 -3
- package/es/layout/dagre/src/add-border-segments.js +0 -32
- package/es/layout/dagre/src/add-border-segments.js.map +0 -1
- package/es/layout/dagre/src/coordinate-system.d.ts +0 -6
- package/es/layout/dagre/src/coordinate-system.js +0 -69
- package/es/layout/dagre/src/coordinate-system.js.map +0 -1
- package/es/layout/dagre/src/data/list.d.ts +0 -12
- package/es/layout/dagre/src/data/list.js +0 -48
- package/es/layout/dagre/src/data/list.js.map +0 -1
- package/es/layout/dagre/src/debug.d.ts +0 -3
- package/es/layout/dagre/src/debug.js +0 -24
- package/es/layout/dagre/src/debug.js.map +0 -1
- package/es/layout/dagre/src/greedy-fas.d.ts +0 -3
- package/es/layout/dagre/src/greedy-fas.js +0 -114
- package/es/layout/dagre/src/greedy-fas.js.map +0 -1
- package/es/layout/dagre/src/layout.d.ts +0 -3
- package/es/layout/dagre/src/layout.js +0 -518
- package/es/layout/dagre/src/layout.js.map +0 -1
- package/es/layout/dagre/src/nesting-graph.d.ts +0 -6
- package/es/layout/dagre/src/nesting-graph.js +0 -117
- package/es/layout/dagre/src/nesting-graph.js.map +0 -1
- package/es/layout/dagre/src/normalize.d.ts +0 -6
- package/es/layout/dagre/src/normalize.js +0 -89
- package/es/layout/dagre/src/normalize.js.map +0 -1
- package/es/layout/dagre/src/order/add-subgraph-constraints.d.ts +0 -3
- package/es/layout/dagre/src/order/add-subgraph-constraints.js +0 -27
- package/es/layout/dagre/src/order/add-subgraph-constraints.js.map +0 -1
- package/es/layout/dagre/src/order/barycenter.d.ts +0 -11
- package/es/layout/dagre/src/order/barycenter.js +0 -24
- package/es/layout/dagre/src/order/barycenter.js.map +0 -1
- package/es/layout/dagre/src/order/build-layer-graph.d.ts +0 -3
- package/es/layout/dagre/src/order/build-layer-graph.js +0 -71
- package/es/layout/dagre/src/order/build-layer-graph.js.map +0 -1
- package/es/layout/dagre/src/order/cross-count.d.ts +0 -3
- package/es/layout/dagre/src/order/cross-count.js +0 -65
- package/es/layout/dagre/src/order/cross-count.js.map +0 -1
- package/es/layout/dagre/src/order/index.d.ts +0 -3
- package/es/layout/dagre/src/order/index.js +0 -91
- package/es/layout/dagre/src/order/index.js.map +0 -1
- package/es/layout/dagre/src/order/init-data-order.d.ts +0 -6
- package/es/layout/dagre/src/order/init-data-order.js +0 -25
- package/es/layout/dagre/src/order/init-data-order.js.map +0 -1
- package/es/layout/dagre/src/order/init-order.d.ts +0 -3
- package/es/layout/dagre/src/order/init-order.js +0 -52
- package/es/layout/dagre/src/order/init-order.js.map +0 -1
- package/es/layout/dagre/src/order/resolve-conflicts.d.ts +0 -19
- package/es/layout/dagre/src/order/resolve-conflicts.js +0 -93
- package/es/layout/dagre/src/order/resolve-conflicts.js.map +0 -1
- package/es/layout/dagre/src/order/sort-subgraph.d.ts +0 -7
- package/es/layout/dagre/src/order/sort-subgraph.js +0 -85
- package/es/layout/dagre/src/order/sort-subgraph.js.map +0 -1
- package/es/layout/dagre/src/order/sort.d.ts +0 -7
- package/es/layout/dagre/src/order/sort.js +0 -68
- package/es/layout/dagre/src/order/sort.js.map +0 -1
- package/es/layout/dagre/src/parent-dummy-chains.d.ts +0 -3
- package/es/layout/dagre/src/parent-dummy-chains.js +0 -81
- package/es/layout/dagre/src/parent-dummy-chains.js.map +0 -1
- package/es/layout/dagre/src/position/bk.d.ts +0 -23
- package/es/layout/dagre/src/position/bk.js +0 -370
- package/es/layout/dagre/src/position/bk.js.map +0 -1
- package/es/layout/dagre/src/position/index.d.ts +0 -3
- package/es/layout/dagre/src/position/index.js +0 -51
- package/es/layout/dagre/src/position/index.js.map +0 -1
- package/es/layout/dagre/src/rank/feasible-tree.d.ts +0 -9
- package/es/layout/dagre/src/rank/feasible-tree.js +0 -148
- package/es/layout/dagre/src/rank/feasible-tree.js.map +0 -1
- package/es/layout/dagre/src/rank/index.d.ts +0 -3
- package/es/layout/dagre/src/rank/index.js +0 -53
- package/es/layout/dagre/src/rank/index.js.map +0 -1
- package/es/layout/dagre/src/rank/network-simplex.d.ts +0 -9
- package/es/layout/dagre/src/rank/network-simplex.js +0 -195
- package/es/layout/dagre/src/rank/network-simplex.js.map +0 -1
- package/es/layout/dagre/src/rank/util.d.ts +0 -11
- package/es/layout/dagre/src/rank/util.js +0 -141
- package/es/layout/dagre/src/rank/util.js.map +0 -1
- package/es/layout/dagre/src/util.d.ts +0 -31
- package/es/layout/dagre/src/util.js +0 -261
- package/es/layout/dagre/src/util.js.map +0 -1
- package/es/layout/dagre.d.ts +0 -71
- package/es/layout/dagre.js +0 -433
- package/es/layout/dagre.js.map +0 -1
- package/es/layout/dagreCompound.d.ts +0 -121
- package/es/layout/dagreCompound.js +0 -391
- package/es/layout/dagreCompound.js.map +0 -1
- package/es/layout/er/core.d.ts +0 -1
- package/es/layout/er/core.js +0 -107
- package/es/layout/er/core.js.map +0 -1
- package/es/layout/er/forceGrid.d.ts +0 -8
- package/es/layout/er/forceGrid.js +0 -88
- package/es/layout/er/forceGrid.js.map +0 -1
- package/es/layout/er/grid.d.ts +0 -26
- package/es/layout/er/grid.js +0 -162
- package/es/layout/er/grid.js.map +0 -1
- package/es/layout/er/index.d.ts +0 -29
- package/es/layout/er/index.js +0 -54
- package/es/layout/er/index.js.map +0 -1
- package/es/layout/er/mysqlWorkbench.d.ts +0 -6
- package/es/layout/er/mysqlWorkbench.js +0 -324
- package/es/layout/er/mysqlWorkbench.js.map +0 -1
- package/es/layout/er/type.d.ts +0 -35
- package/es/layout/er/type.js +0 -2
- package/es/layout/er/type.js.map +0 -1
- package/es/layout/force/force-in-a-box.d.ts +0 -28
- package/es/layout/force/force-in-a-box.js +0 -330
- package/es/layout/force/force-in-a-box.js.map +0 -1
- package/es/layout/force/force.d.ts +0 -100
- package/es/layout/force/force.js +0 -340
- package/es/layout/force/force.js.map +0 -1
- package/es/layout/force/index.d.ts +0 -1
- package/es/layout/force/index.js +0 -2
- package/es/layout/force/index.js.map +0 -1
- package/es/layout/force2/ForceNBody.d.ts +0 -7
- package/es/layout/force2/ForceNBody.js +0 -94
- package/es/layout/force2/ForceNBody.js.map +0 -1
- package/es/layout/force2/index.d.ts +0 -119
- package/es/layout/force2/index.js +0 -608
- package/es/layout/force2/index.js.map +0 -1
- package/es/layout/forceAtlas2/body.d.ts +0 -33
- package/es/layout/forceAtlas2/body.js +0 -89
- package/es/layout/forceAtlas2/body.js.map +0 -1
- package/es/layout/forceAtlas2/index.d.ts +0 -115
- package/es/layout/forceAtlas2/index.js +0 -484
- package/es/layout/forceAtlas2/index.js.map +0 -1
- package/es/layout/forceAtlas2/quad.d.ts +0 -27
- package/es/layout/forceAtlas2/quad.js +0 -96
- package/es/layout/forceAtlas2/quad.js.map +0 -1
- package/es/layout/forceAtlas2/quadTree.d.ts +0 -20
- package/es/layout/forceAtlas2/quadTree.js +0 -103
- package/es/layout/forceAtlas2/quadTree.js.map +0 -1
- package/es/layout/fruchterman.d.ts +0 -73
- package/es/layout/fruchterman.js +0 -296
- package/es/layout/fruchterman.js.map +0 -1
- package/es/layout/gForce.d.ts +0 -96
- package/es/layout/gForce.js +0 -399
- package/es/layout/gForce.js.map +0 -1
- package/es/layout/gpu/fruchterman.d.ts +0 -57
- package/es/layout/gpu/fruchterman.js +0 -267
- package/es/layout/gpu/fruchterman.js.map +0 -1
- package/es/layout/gpu/fruchtermanShader.d.ts +0 -4
- package/es/layout/gpu/fruchtermanShader.js +0 -201
- package/es/layout/gpu/fruchtermanShader.js.map +0 -1
- package/es/layout/gpu/gForce.d.ts +0 -68
- package/es/layout/gpu/gForce.js +0 -330
- package/es/layout/gpu/gForce.js.map +0 -1
- package/es/layout/gpu/gForceShader.d.ts +0 -4
- package/es/layout/gpu/gForceShader.js +0 -218
- package/es/layout/gpu/gForceShader.js.map +0 -1
- package/es/layout/grid.d.ts +0 -83
- package/es/layout/grid.js +0 -317
- package/es/layout/grid.js.map +0 -1
- package/es/layout/index.d.ts +0 -22
- package/es/layout/index.js +0 -25
- package/es/layout/index.js.map +0 -1
- package/es/layout/layout.d.ts +0 -26
- package/es/layout/layout.js +0 -97
- package/es/layout/layout.js.map +0 -1
- package/es/layout/mds.d.ts +0 -39
- package/es/layout/mds.js +0 -122
- package/es/layout/mds.js.map +0 -1
- package/es/layout/radial/index.d.ts +0 -1
- package/es/layout/radial/index.js +0 -2
- package/es/layout/radial/index.js.map +0 -1
- package/es/layout/radial/mds.d.ts +0 -15
- package/es/layout/radial/mds.js +0 -38
- package/es/layout/radial/mds.js.map +0 -1
- package/es/layout/radial/radial.d.ts +0 -74
- package/es/layout/radial/radial.js +0 -420
- package/es/layout/radial/radial.js.map +0 -1
- package/es/layout/radial/radialNonoverlapForce.d.ts +0 -50
- package/es/layout/radial/radialNonoverlapForce.js +0 -123
- package/es/layout/radial/radialNonoverlapForce.js.map +0 -1
- package/es/layout/random.d.ts +0 -35
- package/es/layout/random.js +0 -62
- package/es/layout/random.js.map +0 -1
- package/es/layout/types.d.ts +0 -432
- package/es/layout/types.js +0 -2
- package/es/layout/types.js.map +0 -1
- package/es/registy/index.d.ts +0 -3
- package/es/registy/index.js +0 -41
- package/es/registy/index.js.map +0 -1
- package/es/util/array.d.ts +0 -1
- package/es/util/array.js +0 -2
- package/es/util/array.js.map +0 -1
- package/es/util/function.d.ts +0 -6
- package/es/util/function.js +0 -56
- package/es/util/function.js.map +0 -1
- package/es/util/gpu.d.ts +0 -52
- package/es/util/gpu.js +0 -239
- package/es/util/gpu.js.map +0 -1
- package/es/util/index.d.ts +0 -6
- package/es/util/index.js +0 -7
- package/es/util/index.js.map +0 -1
- package/es/util/math.d.ts +0 -48
- package/es/util/math.js +0 -276
- package/es/util/math.js.map +0 -1
- package/es/util/number.d.ts +0 -3
- package/es/util/number.js +0 -7
- package/es/util/number.js.map +0 -1
- package/es/util/object.d.ts +0 -2
- package/es/util/object.js +0 -25
- package/es/util/object.js.map +0 -1
- package/es/util/string.d.ts +0 -2
- package/es/util/string.js +0 -16
- package/es/util/string.js.map +0 -1
- package/lib/index.js +0 -24
- package/lib/index.js.map +0 -1
- package/lib/layout/base.d.ts +0 -22
- package/lib/layout/base.js +0 -56
- package/lib/layout/base.js.map +0 -1
- package/lib/layout/circular.d.ts +0 -80
- package/lib/layout/circular.js +0 -337
- package/lib/layout/circular.js.map +0 -1
- package/lib/layout/comboCombined.d.ts +0 -54
- package/lib/layout/comboCombined.js +0 -390
- package/lib/layout/comboCombined.js.map +0 -1
- package/lib/layout/comboForce.d.ts +0 -134
- package/lib/layout/comboForce.js +0 -826
- package/lib/layout/comboForce.js.map +0 -1
- package/lib/layout/concentric.d.ts +0 -67
- package/lib/layout/concentric.js +0 -243
- package/lib/layout/concentric.js.map +0 -1
- package/lib/layout/constants.d.ts +0 -12
- package/lib/layout/constants.js +0 -25
- package/lib/layout/constants.js.map +0 -1
- package/lib/layout/dagre/graph.d.ts +0 -91
- package/lib/layout/dagre/graph.js +0 -28
- package/lib/layout/dagre/graph.js.map +0 -1
- package/lib/layout/dagre/index.d.ts +0 -8
- package/lib/layout/dagre/index.js +0 -36
- package/lib/layout/dagre/index.js.map +0 -1
- package/lib/layout/dagre/src/acyclic.d.ts +0 -6
- package/lib/layout/dagre/src/acyclic.js +0 -57
- package/lib/layout/dagre/src/acyclic.js.map +0 -1
- package/lib/layout/dagre/src/add-border-segments.d.ts +0 -3
- package/lib/layout/dagre/src/add-border-segments.js +0 -34
- package/lib/layout/dagre/src/add-border-segments.js.map +0 -1
- package/lib/layout/dagre/src/coordinate-system.d.ts +0 -6
- package/lib/layout/dagre/src/coordinate-system.js +0 -71
- package/lib/layout/dagre/src/coordinate-system.js.map +0 -1
- package/lib/layout/dagre/src/data/list.d.ts +0 -12
- package/lib/layout/dagre/src/data/list.js +0 -52
- package/lib/layout/dagre/src/data/list.js.map +0 -1
- package/lib/layout/dagre/src/debug.d.ts +0 -3
- package/lib/layout/dagre/src/debug.js +0 -26
- package/lib/layout/dagre/src/debug.js.map +0 -1
- package/lib/layout/dagre/src/greedy-fas.d.ts +0 -3
- package/lib/layout/dagre/src/greedy-fas.js +0 -144
- package/lib/layout/dagre/src/greedy-fas.js.map +0 -1
- package/lib/layout/dagre/src/layout.d.ts +0 -3
- package/lib/layout/dagre/src/layout.js +0 -535
- package/lib/layout/dagre/src/layout.js.map +0 -1
- package/lib/layout/dagre/src/nesting-graph.d.ts +0 -6
- package/lib/layout/dagre/src/nesting-graph.js +0 -119
- package/lib/layout/dagre/src/nesting-graph.js.map +0 -1
- package/lib/layout/dagre/src/normalize.d.ts +0 -6
- package/lib/layout/dagre/src/normalize.js +0 -91
- package/lib/layout/dagre/src/normalize.js.map +0 -1
- package/lib/layout/dagre/src/order/add-subgraph-constraints.d.ts +0 -3
- package/lib/layout/dagre/src/order/add-subgraph-constraints.js +0 -29
- package/lib/layout/dagre/src/order/add-subgraph-constraints.js.map +0 -1
- package/lib/layout/dagre/src/order/barycenter.d.ts +0 -11
- package/lib/layout/dagre/src/order/barycenter.js +0 -26
- package/lib/layout/dagre/src/order/barycenter.js.map +0 -1
- package/lib/layout/dagre/src/order/build-layer-graph.d.ts +0 -3
- package/lib/layout/dagre/src/order/build-layer-graph.js +0 -73
- package/lib/layout/dagre/src/order/build-layer-graph.js.map +0 -1
- package/lib/layout/dagre/src/order/cross-count.d.ts +0 -3
- package/lib/layout/dagre/src/order/cross-count.js +0 -67
- package/lib/layout/dagre/src/order/cross-count.js.map +0 -1
- package/lib/layout/dagre/src/order/index.d.ts +0 -3
- package/lib/layout/dagre/src/order/index.js +0 -96
- package/lib/layout/dagre/src/order/index.js.map +0 -1
- package/lib/layout/dagre/src/order/init-data-order.d.ts +0 -6
- package/lib/layout/dagre/src/order/init-data-order.js +0 -27
- package/lib/layout/dagre/src/order/init-data-order.js.map +0 -1
- package/lib/layout/dagre/src/order/init-order.d.ts +0 -3
- package/lib/layout/dagre/src/order/init-order.js +0 -54
- package/lib/layout/dagre/src/order/init-order.js.map +0 -1
- package/lib/layout/dagre/src/order/resolve-conflicts.d.ts +0 -19
- package/lib/layout/dagre/src/order/resolve-conflicts.js +0 -98
- package/lib/layout/dagre/src/order/resolve-conflicts.js.map +0 -1
- package/lib/layout/dagre/src/order/sort-subgraph.d.ts +0 -7
- package/lib/layout/dagre/src/order/sort-subgraph.js +0 -90
- package/lib/layout/dagre/src/order/sort-subgraph.js.map +0 -1
- package/lib/layout/dagre/src/order/sort.d.ts +0 -7
- package/lib/layout/dagre/src/order/sort.js +0 -70
- package/lib/layout/dagre/src/order/sort.js.map +0 -1
- package/lib/layout/dagre/src/parent-dummy-chains.d.ts +0 -3
- package/lib/layout/dagre/src/parent-dummy-chains.js +0 -83
- package/lib/layout/dagre/src/parent-dummy-chains.js.map +0 -1
- package/lib/layout/dagre/src/position/bk.d.ts +0 -23
- package/lib/layout/dagre/src/position/bk.js +0 -409
- package/lib/layout/dagre/src/position/bk.js.map +0 -1
- package/lib/layout/dagre/src/position/index.d.ts +0 -3
- package/lib/layout/dagre/src/position/index.js +0 -64
- package/lib/layout/dagre/src/position/index.js.map +0 -1
- package/lib/layout/dagre/src/rank/feasible-tree.d.ts +0 -9
- package/lib/layout/dagre/src/rank/feasible-tree.js +0 -152
- package/lib/layout/dagre/src/rank/feasible-tree.js.map +0 -1
- package/lib/layout/dagre/src/rank/index.d.ts +0 -3
- package/lib/layout/dagre/src/rank/index.js +0 -58
- package/lib/layout/dagre/src/rank/index.js.map +0 -1
- package/lib/layout/dagre/src/rank/network-simplex.d.ts +0 -9
- package/lib/layout/dagre/src/rank/network-simplex.js +0 -205
- package/lib/layout/dagre/src/rank/network-simplex.js.map +0 -1
- package/lib/layout/dagre/src/rank/util.d.ts +0 -11
- package/lib/layout/dagre/src/rank/util.js +0 -146
- package/lib/layout/dagre/src/rank/util.js.map +0 -1
- package/lib/layout/dagre/src/util.d.ts +0 -31
- package/lib/layout/dagre/src/util.js +0 -280
- package/lib/layout/dagre/src/util.js.map +0 -1
- package/lib/layout/dagre.d.ts +0 -71
- package/lib/layout/dagre.js +0 -462
- package/lib/layout/dagre.js.map +0 -1
- package/lib/layout/dagreCompound.d.ts +0 -121
- package/lib/layout/dagreCompound.js +0 -429
- package/lib/layout/dagreCompound.js.map +0 -1
- package/lib/layout/er/core.d.ts +0 -1
- package/lib/layout/er/core.js +0 -147
- package/lib/layout/er/core.js.map +0 -1
- package/lib/layout/er/forceGrid.d.ts +0 -8
- package/lib/layout/er/forceGrid.js +0 -97
- package/lib/layout/er/forceGrid.js.map +0 -1
- package/lib/layout/er/grid.d.ts +0 -26
- package/lib/layout/er/grid.js +0 -177
- package/lib/layout/er/grid.js.map +0 -1
- package/lib/layout/er/index.d.ts +0 -29
- package/lib/layout/er/index.js +0 -80
- package/lib/layout/er/index.js.map +0 -1
- package/lib/layout/er/mysqlWorkbench.d.ts +0 -6
- package/lib/layout/er/mysqlWorkbench.js +0 -326
- package/lib/layout/er/mysqlWorkbench.js.map +0 -1
- package/lib/layout/er/type.d.ts +0 -35
- package/lib/layout/er/type.js +0 -3
- package/lib/layout/er/type.js.map +0 -1
- package/lib/layout/force/force-in-a-box.d.ts +0 -28
- package/lib/layout/force/force-in-a-box.js +0 -357
- package/lib/layout/force/force-in-a-box.js.map +0 -1
- package/lib/layout/force/force.d.ts +0 -100
- package/lib/layout/force/force.js +0 -388
- package/lib/layout/force/force.js.map +0 -1
- package/lib/layout/force/index.d.ts +0 -1
- package/lib/layout/force/index.js +0 -18
- package/lib/layout/force/index.js.map +0 -1
- package/lib/layout/force2/ForceNBody.d.ts +0 -7
- package/lib/layout/force2/ForceNBody.js +0 -98
- package/lib/layout/force2/ForceNBody.js.map +0 -1
- package/lib/layout/force2/index.d.ts +0 -119
- package/lib/layout/force2/index.js +0 -643
- package/lib/layout/force2/index.js.map +0 -1
- package/lib/layout/forceAtlas2/body.d.ts +0 -33
- package/lib/layout/forceAtlas2/body.js +0 -93
- package/lib/layout/forceAtlas2/body.js.map +0 -1
- package/lib/layout/forceAtlas2/index.d.ts +0 -115
- package/lib/layout/forceAtlas2/index.js +0 -509
- package/lib/layout/forceAtlas2/index.js.map +0 -1
- package/lib/layout/forceAtlas2/quad.d.ts +0 -27
- package/lib/layout/forceAtlas2/quad.js +0 -100
- package/lib/layout/forceAtlas2/quad.js.map +0 -1
- package/lib/layout/forceAtlas2/quadTree.d.ts +0 -20
- package/lib/layout/forceAtlas2/quadTree.js +0 -107
- package/lib/layout/forceAtlas2/quadTree.js.map +0 -1
- package/lib/layout/fruchterman.d.ts +0 -73
- package/lib/layout/fruchterman.js +0 -320
- package/lib/layout/fruchterman.js.map +0 -1
- package/lib/layout/gForce.d.ts +0 -96
- package/lib/layout/gForce.js +0 -421
- package/lib/layout/gForce.js.map +0 -1
- package/lib/layout/gpu/fruchterman.d.ts +0 -57
- package/lib/layout/gpu/fruchterman.js +0 -361
- package/lib/layout/gpu/fruchterman.js.map +0 -1
- package/lib/layout/gpu/fruchtermanShader.d.ts +0 -4
- package/lib/layout/gpu/fruchtermanShader.js +0 -8
- package/lib/layout/gpu/fruchtermanShader.js.map +0 -1
- package/lib/layout/gpu/gForce.d.ts +0 -68
- package/lib/layout/gpu/gForce.js +0 -415
- package/lib/layout/gpu/gForce.js.map +0 -1
- package/lib/layout/gpu/gForceShader.d.ts +0 -4
- package/lib/layout/gpu/gForceShader.js +0 -8
- package/lib/layout/gpu/gForceShader.js.map +0 -1
- package/lib/layout/grid.d.ts +0 -83
- package/lib/layout/grid.js +0 -339
- package/lib/layout/grid.js.map +0 -1
- package/lib/layout/index.d.ts +0 -22
- package/lib/layout/index.js +0 -59
- package/lib/layout/index.js.map +0 -1
- package/lib/layout/layout.d.ts +0 -26
- package/lib/layout/layout.js +0 -102
- package/lib/layout/layout.js.map +0 -1
- package/lib/layout/mds.d.ts +0 -39
- package/lib/layout/mds.js +0 -144
- package/lib/layout/mds.js.map +0 -1
- package/lib/layout/radial/index.d.ts +0 -1
- package/lib/layout/radial/index.js +0 -18
- package/lib/layout/radial/index.js.map +0 -1
- package/lib/layout/radial/mds.d.ts +0 -15
- package/lib/layout/radial/mds.js +0 -42
- package/lib/layout/radial/mds.js.map +0 -1
- package/lib/layout/radial/radial.d.ts +0 -74
- package/lib/layout/radial/radial.js +0 -445
- package/lib/layout/radial/radial.js.map +0 -1
- package/lib/layout/radial/radialNonoverlapForce.d.ts +0 -50
- package/lib/layout/radial/radialNonoverlapForce.js +0 -127
- package/lib/layout/radial/radialNonoverlapForce.js.map +0 -1
- package/lib/layout/random.d.ts +0 -35
- package/lib/layout/random.js +0 -84
- package/lib/layout/random.js.map +0 -1
- package/lib/layout/types.d.ts +0 -432
- package/lib/layout/types.js +0 -3
- package/lib/layout/types.js.map +0 -1
- package/lib/registy/index.d.ts +0 -3
- package/lib/registy/index.js +0 -65
- package/lib/registy/index.js.map +0 -1
- package/lib/util/array.js +0 -5
- package/lib/util/array.js.map +0 -1
- package/lib/util/function.js +0 -65
- package/lib/util/function.js.map +0 -1
- package/lib/util/gpu.js +0 -250
- package/lib/util/gpu.js.map +0 -1
- package/lib/util/index.js +0 -23
- package/lib/util/index.js.map +0 -1
- package/lib/util/math.js +0 -289
- package/lib/util/math.js.map +0 -1
- package/lib/util/number.js +0 -13
- package/lib/util/number.js.map +0 -1
- package/lib/util/object.js +0 -43
- package/lib/util/object.js.map +0 -1
- package/lib/util/string.js +0 -20
- package/lib/util/string.js.map +0 -1
- package/src/index.ts +0 -7
- package/src/layout/base.ts +0 -57
- package/src/layout/circular.ts +0 -370
- package/src/layout/comboCombined.ts +0 -397
- package/src/layout/comboForce.ts +0 -873
- package/src/layout/concentric.ts +0 -289
- package/src/layout/constants.ts +0 -22
- package/src/layout/dagre/graph.ts +0 -104
- package/src/layout/dagre/index.ts +0 -31
- package/src/layout/dagre/src/acyclic.ts +0 -58
- package/src/layout/dagre/src/add-border-segments.ts +0 -47
- package/src/layout/dagre/src/coordinate-system.ts +0 -77
- package/src/layout/dagre/src/data/list.ts +0 -60
- package/src/layout/dagre/src/debug.ts +0 -30
- package/src/layout/dagre/src/greedy-fas.ts +0 -144
- package/src/layout/dagre/src/layout.ts +0 -579
- package/src/layout/dagre/src/nesting-graph.ts +0 -143
- package/src/layout/dagre/src/normalize.ts +0 -96
- package/src/layout/dagre/src/order/add-subgraph-constraints.ts +0 -29
- package/src/layout/dagre/src/order/barycenter.ts +0 -26
- package/src/layout/dagre/src/order/build-layer-graph.ts +0 -82
- package/src/layout/dagre/src/order/cross-count.ts +0 -77
- package/src/layout/dagre/src/order/index.ts +0 -105
- package/src/layout/dagre/src/order/init-data-order.ts +0 -27
- package/src/layout/dagre/src/order/init-order.ts +0 -56
- package/src/layout/dagre/src/order/resolve-conflicts.ts +0 -152
- package/src/layout/dagre/src/order/sort-subgraph.ts +0 -105
- package/src/layout/dagre/src/order/sort.ts +0 -76
- package/src/layout/dagre/src/parent-dummy-chains.ts +0 -102
- package/src/layout/dagre/src/position/bk.ts +0 -493
- package/src/layout/dagre/src/position/index.ts +0 -82
- package/src/layout/dagre/src/rank/feasible-tree.ts +0 -165
- package/src/layout/dagre/src/rank/index.ts +0 -54
- package/src/layout/dagre/src/rank/network-simplex.ts +0 -225
- package/src/layout/dagre/src/rank/util.ts +0 -166
- package/src/layout/dagre/src/util.ts +0 -309
- package/src/layout/dagre.ts +0 -460
- package/src/layout/dagreCompound.ts +0 -518
- package/src/layout/er/core.ts +0 -117
- package/src/layout/er/forceGrid.ts +0 -95
- package/src/layout/er/grid.ts +0 -185
- package/src/layout/er/index.ts +0 -68
- package/src/layout/er/mysqlWorkbench.ts +0 -345
- package/src/layout/er/type.ts +0 -39
- package/src/layout/force/force-in-a-box.ts +0 -400
- package/src/layout/force/force.ts +0 -391
- package/src/layout/force/index.ts +0 -1
- package/src/layout/force2/ForceNBody.ts +0 -128
- package/src/layout/force2/index.ts +0 -741
- package/src/layout/forceAtlas2/body.ts +0 -115
- package/src/layout/forceAtlas2/index.ts +0 -556
- package/src/layout/forceAtlas2/quad.ts +0 -115
- package/src/layout/forceAtlas2/quadTree.ts +0 -107
- package/src/layout/fruchterman.ts +0 -361
- package/src/layout/gForce.ts +0 -488
- package/src/layout/gpu/fruchterman.ts +0 -314
- package/src/layout/gpu/fruchtermanShader.ts +0 -203
- package/src/layout/gpu/gForce.ts +0 -407
- package/src/layout/gpu/gForceShader.ts +0 -220
- package/src/layout/grid.ts +0 -404
- package/src/layout/index.ts +0 -47
- package/src/layout/layout.ts +0 -110
- package/src/layout/mds.ts +0 -140
- package/src/layout/radial/index.ts +0 -1
- package/src/layout/radial/mds.ts +0 -51
- package/src/layout/radial/radial.ts +0 -500
- package/src/layout/radial/radialNonoverlapForce.ts +0 -189
- package/src/layout/random.ts +0 -75
- package/src/layout/types.ts +0 -496
- package/src/registy/index.ts +0 -43
- package/src/util/array.ts +0 -1
- package/src/util/function.ts +0 -64
- package/src/util/gpu.ts +0 -256
- package/src/util/index.ts +0 -6
- package/src/util/math.ts +0 -294
- package/src/util/number.ts +0 -8
- package/src/util/object.ts +0 -28
- package/src/util/string.ts +0 -18
package/es/layout/comboForce.js
DELETED
|
@@ -1,801 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileOverview Combo force layout
|
|
3
|
-
* @author shiwu.wyy@antfin.com
|
|
4
|
-
*/
|
|
5
|
-
import { Base } from "./base";
|
|
6
|
-
import { isArray, isNumber, isFunction, traverseTreeUp, isObject, getEdgeTerminal } from "../util";
|
|
7
|
-
/**
|
|
8
|
-
* force layout for graph with combos
|
|
9
|
-
*/
|
|
10
|
-
export class ComboForceLayout extends Base {
|
|
11
|
-
constructor(options) {
|
|
12
|
-
super();
|
|
13
|
-
/** 布局中心 */
|
|
14
|
-
this.center = [0, 0];
|
|
15
|
-
/** 停止迭代的最大迭代数 */
|
|
16
|
-
this.maxIteration = 100;
|
|
17
|
-
/** 重力大小,影响图的紧凑程度 */
|
|
18
|
-
this.gravity = 10;
|
|
19
|
-
/** 群组中心力大小 */
|
|
20
|
-
this.comboGravity = 10;
|
|
21
|
-
/** 默认边长度 */
|
|
22
|
-
this.linkDistance = 10;
|
|
23
|
-
/** 每次迭代位移的衰减相关参数 */
|
|
24
|
-
this.alpha = 1;
|
|
25
|
-
this.alphaMin = 0.001;
|
|
26
|
-
this.alphaDecay = 1 - Math.pow(this.alphaMin, (1 / 300));
|
|
27
|
-
this.alphaTarget = 0;
|
|
28
|
-
/** 节点运动速度衰减参数 */
|
|
29
|
-
this.velocityDecay = 0.6;
|
|
30
|
-
/** 边引力大小 */
|
|
31
|
-
this.edgeStrength = 0.6;
|
|
32
|
-
/** 节点引力大小 */
|
|
33
|
-
this.nodeStrength = 30;
|
|
34
|
-
/** 是否开启防止重叠 */
|
|
35
|
-
this.preventOverlap = false;
|
|
36
|
-
/** 是否开启节点之间的防止重叠 */
|
|
37
|
-
this.preventNodeOverlap = false;
|
|
38
|
-
/** 是否开启 Combo 之间的防止重叠 */
|
|
39
|
-
this.preventComboOverlap = false;
|
|
40
|
-
/** 防止重叠的碰撞力大小 */
|
|
41
|
-
this.collideStrength = undefined;
|
|
42
|
-
/** 防止重叠的碰撞力大小 */
|
|
43
|
-
this.nodeCollideStrength = 0.5;
|
|
44
|
-
/** 防止重叠的碰撞力大小 */
|
|
45
|
-
this.comboCollideStrength = 0.5;
|
|
46
|
-
/** Combo 最小间距,防止重叠时的间隙 */
|
|
47
|
-
this.comboSpacing = 20;
|
|
48
|
-
/** Combo 内部的 padding */
|
|
49
|
-
this.comboPadding = 10;
|
|
50
|
-
/** 优化计算斥力的速度,两节点间距超过 optimizeRangeFactor * width 则不再计算斥力和重叠斥力 */
|
|
51
|
-
this.optimizeRangeFactor = 1;
|
|
52
|
-
/** 每次迭代的回调函数 */
|
|
53
|
-
this.onTick = () => { };
|
|
54
|
-
/** 迭代结束的回调函数 */
|
|
55
|
-
this.onLayoutEnd = () => { };
|
|
56
|
-
/** 根据边两端节点层级差距的调整引力系数的因子,取值范围 [0, 1]。层级差距越大,引力越小 */
|
|
57
|
-
this.depthAttractiveForceScale = 1;
|
|
58
|
-
/** 根据边两端节点层级差距的调整斥力系数的因子,取值范围 [1, Infinity]。层级差距越大,斥力越大 */
|
|
59
|
-
this.depthRepulsiveForceScale = 2;
|
|
60
|
-
/** 内部计算参数 */
|
|
61
|
-
this.nodes = [];
|
|
62
|
-
this.edges = [];
|
|
63
|
-
this.combos = [];
|
|
64
|
-
this.comboTrees = [];
|
|
65
|
-
this.width = 300;
|
|
66
|
-
this.height = 300;
|
|
67
|
-
this.bias = [];
|
|
68
|
-
this.nodeMap = {};
|
|
69
|
-
this.oriComboMap = {};
|
|
70
|
-
this.indexMap = {};
|
|
71
|
-
this.comboMap = {};
|
|
72
|
-
this.previousLayouted = false;
|
|
73
|
-
this.updateCfg(options);
|
|
74
|
-
}
|
|
75
|
-
getDefaultCfg() {
|
|
76
|
-
return {
|
|
77
|
-
maxIteration: 100,
|
|
78
|
-
center: [0, 0],
|
|
79
|
-
gravity: 10,
|
|
80
|
-
speed: 1,
|
|
81
|
-
comboGravity: 30,
|
|
82
|
-
preventOverlap: false,
|
|
83
|
-
preventComboOverlap: true,
|
|
84
|
-
preventNodeOverlap: true,
|
|
85
|
-
nodeSpacing: undefined,
|
|
86
|
-
collideStrength: undefined,
|
|
87
|
-
nodeCollideStrength: 0.5,
|
|
88
|
-
comboCollideStrength: 0.5,
|
|
89
|
-
comboSpacing: 20,
|
|
90
|
-
comboPadding: 10,
|
|
91
|
-
edgeStrength: 0.6,
|
|
92
|
-
nodeStrength: 30,
|
|
93
|
-
linkDistance: 10
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* 执行布局
|
|
98
|
-
*/
|
|
99
|
-
execute() {
|
|
100
|
-
const self = this;
|
|
101
|
-
const nodes = self.nodes;
|
|
102
|
-
const center = self.center;
|
|
103
|
-
self.comboTree = {
|
|
104
|
-
id: "comboTreeRoot",
|
|
105
|
-
depth: -1,
|
|
106
|
-
children: self.comboTrees
|
|
107
|
-
};
|
|
108
|
-
if (!nodes || nodes.length === 0) {
|
|
109
|
-
if (self.onLayoutEnd)
|
|
110
|
-
self.onLayoutEnd();
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
if (nodes.length === 1) {
|
|
114
|
-
nodes[0].x = center[0];
|
|
115
|
-
nodes[0].y = center[1];
|
|
116
|
-
if (self.onLayoutEnd)
|
|
117
|
-
self.onLayoutEnd();
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
self.initVals();
|
|
121
|
-
// layout
|
|
122
|
-
self.run();
|
|
123
|
-
if (self.onLayoutEnd)
|
|
124
|
-
self.onLayoutEnd();
|
|
125
|
-
}
|
|
126
|
-
run() {
|
|
127
|
-
const self = this;
|
|
128
|
-
const nodes = self.nodes;
|
|
129
|
-
const maxIteration = self.previousLayouted
|
|
130
|
-
? self.maxIteration / 5
|
|
131
|
-
: self.maxIteration;
|
|
132
|
-
if (!self.width && typeof window !== "undefined") {
|
|
133
|
-
self.width = window.innerWidth;
|
|
134
|
-
}
|
|
135
|
-
if (!self.height && typeof window !== "undefined") {
|
|
136
|
-
self.height = window.innerHeight;
|
|
137
|
-
}
|
|
138
|
-
const center = self.center;
|
|
139
|
-
const velocityDecay = self.velocityDecay;
|
|
140
|
-
// init the positions to make the nodes with same combo gather around the combo
|
|
141
|
-
const comboMap = self.comboMap;
|
|
142
|
-
if (!self.previousLayouted)
|
|
143
|
-
self.initPos(comboMap);
|
|
144
|
-
// iterate
|
|
145
|
-
for (let i = 0; i < maxIteration; i++) {
|
|
146
|
-
const displacements = [];
|
|
147
|
-
nodes.forEach((_, j) => {
|
|
148
|
-
displacements[j] = { x: 0, y: 0 };
|
|
149
|
-
});
|
|
150
|
-
self.applyCalculate(displacements);
|
|
151
|
-
// gravity for combos
|
|
152
|
-
self.applyComboCenterForce(displacements);
|
|
153
|
-
// move
|
|
154
|
-
nodes.forEach((n, j) => {
|
|
155
|
-
if (!isNumber(n.x) || !isNumber(n.y))
|
|
156
|
-
return;
|
|
157
|
-
n.x += displacements[j].x * velocityDecay;
|
|
158
|
-
n.y += displacements[j].y * velocityDecay;
|
|
159
|
-
});
|
|
160
|
-
self.alpha += (self.alphaTarget - self.alpha) * self.alphaDecay;
|
|
161
|
-
self.onTick();
|
|
162
|
-
}
|
|
163
|
-
// move to center
|
|
164
|
-
const meanCenter = [0, 0];
|
|
165
|
-
nodes.forEach((n) => {
|
|
166
|
-
if (!isNumber(n.x) || !isNumber(n.y))
|
|
167
|
-
return;
|
|
168
|
-
meanCenter[0] += n.x;
|
|
169
|
-
meanCenter[1] += n.y;
|
|
170
|
-
});
|
|
171
|
-
meanCenter[0] /= nodes.length;
|
|
172
|
-
meanCenter[1] /= nodes.length;
|
|
173
|
-
const centerOffset = [center[0] - meanCenter[0], center[1] - meanCenter[1]];
|
|
174
|
-
nodes.forEach((n, j) => {
|
|
175
|
-
if (!isNumber(n.x) || !isNumber(n.y))
|
|
176
|
-
return;
|
|
177
|
-
n.x += centerOffset[0];
|
|
178
|
-
n.y += centerOffset[1];
|
|
179
|
-
});
|
|
180
|
-
// arrange the empty combo
|
|
181
|
-
self.combos.forEach((combo) => {
|
|
182
|
-
const mapped = comboMap[combo.id];
|
|
183
|
-
if (mapped && mapped.empty) {
|
|
184
|
-
combo.x = mapped.cx || combo.x;
|
|
185
|
-
combo.y = mapped.cy || combo.y;
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
self.previousLayouted = true;
|
|
189
|
-
}
|
|
190
|
-
initVals() {
|
|
191
|
-
const self = this;
|
|
192
|
-
const edges = self.edges;
|
|
193
|
-
const nodes = self.nodes;
|
|
194
|
-
const combos = self.combos;
|
|
195
|
-
const count = {};
|
|
196
|
-
const nodeMap = {};
|
|
197
|
-
const indexMap = {};
|
|
198
|
-
nodes.forEach((node, i) => {
|
|
199
|
-
nodeMap[node.id] = node;
|
|
200
|
-
indexMap[node.id] = i;
|
|
201
|
-
});
|
|
202
|
-
self.nodeMap = nodeMap;
|
|
203
|
-
self.indexMap = indexMap;
|
|
204
|
-
const oriComboMap = {};
|
|
205
|
-
combos.forEach((combo) => {
|
|
206
|
-
oriComboMap[combo.id] = combo;
|
|
207
|
-
});
|
|
208
|
-
self.oriComboMap = oriComboMap;
|
|
209
|
-
self.comboMap = self.getComboMap();
|
|
210
|
-
const preventOverlap = self.preventOverlap;
|
|
211
|
-
self.preventComboOverlap = self.preventComboOverlap || preventOverlap;
|
|
212
|
-
self.preventNodeOverlap = self.preventNodeOverlap || preventOverlap;
|
|
213
|
-
const collideStrength = self.collideStrength;
|
|
214
|
-
if (collideStrength) {
|
|
215
|
-
self.comboCollideStrength = collideStrength;
|
|
216
|
-
self.nodeCollideStrength = collideStrength;
|
|
217
|
-
}
|
|
218
|
-
self.comboCollideStrength = self.comboCollideStrength
|
|
219
|
-
? self.comboCollideStrength
|
|
220
|
-
: 0;
|
|
221
|
-
self.nodeCollideStrength = self.nodeCollideStrength
|
|
222
|
-
? self.nodeCollideStrength
|
|
223
|
-
: 0;
|
|
224
|
-
// get edge bias
|
|
225
|
-
for (let i = 0; i < edges.length; ++i) {
|
|
226
|
-
const source = getEdgeTerminal(edges[i], 'source');
|
|
227
|
-
const target = getEdgeTerminal(edges[i], 'target');
|
|
228
|
-
if (count[source])
|
|
229
|
-
count[source]++;
|
|
230
|
-
else
|
|
231
|
-
count[source] = 1;
|
|
232
|
-
if (count[target])
|
|
233
|
-
count[target]++;
|
|
234
|
-
else
|
|
235
|
-
count[target] = 1;
|
|
236
|
-
}
|
|
237
|
-
const bias = [];
|
|
238
|
-
for (let i = 0; i < edges.length; ++i) {
|
|
239
|
-
const source = getEdgeTerminal(edges[i], 'source');
|
|
240
|
-
const target = getEdgeTerminal(edges[i], 'target');
|
|
241
|
-
bias[i] = count[source] / (count[source] + count[target]);
|
|
242
|
-
}
|
|
243
|
-
this.bias = bias;
|
|
244
|
-
const nodeSize = self.nodeSize;
|
|
245
|
-
const nodeSpacing = self.nodeSpacing;
|
|
246
|
-
let nodeSizeFunc;
|
|
247
|
-
let nodeSpacingFunc;
|
|
248
|
-
// nodeSpacing to function
|
|
249
|
-
if (isNumber(nodeSpacing)) {
|
|
250
|
-
nodeSpacingFunc = () => nodeSpacing;
|
|
251
|
-
}
|
|
252
|
-
else if (isFunction(nodeSpacing)) {
|
|
253
|
-
nodeSpacingFunc = nodeSpacing;
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
nodeSpacingFunc = () => 0;
|
|
257
|
-
}
|
|
258
|
-
this.nodeSpacing = nodeSpacingFunc;
|
|
259
|
-
// nodeSize to function
|
|
260
|
-
if (!nodeSize) {
|
|
261
|
-
nodeSizeFunc = (d) => {
|
|
262
|
-
if (d.size) {
|
|
263
|
-
if (isArray(d.size)) {
|
|
264
|
-
const res = d.size[0] > d.size[1] ? d.size[0] : d.size[1];
|
|
265
|
-
return res / 2;
|
|
266
|
-
}
|
|
267
|
-
if (isObject(d.size)) {
|
|
268
|
-
const res = d.size.width > d.size.height ? d.size.width : d.size.height;
|
|
269
|
-
return res / 2;
|
|
270
|
-
}
|
|
271
|
-
return d.size / 2;
|
|
272
|
-
}
|
|
273
|
-
return 10;
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
else if (isFunction(nodeSize)) {
|
|
277
|
-
nodeSizeFunc = (d) => {
|
|
278
|
-
return nodeSize(d);
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
else if (isArray(nodeSize)) {
|
|
282
|
-
const larger = nodeSize[0] > nodeSize[1] ? nodeSize[0] : nodeSize[1];
|
|
283
|
-
const radius = larger / 2;
|
|
284
|
-
nodeSizeFunc = (d) => radius;
|
|
285
|
-
}
|
|
286
|
-
else {
|
|
287
|
-
// number type
|
|
288
|
-
const radius = nodeSize / 2;
|
|
289
|
-
nodeSizeFunc = (d) => radius;
|
|
290
|
-
}
|
|
291
|
-
this.nodeSize = nodeSizeFunc;
|
|
292
|
-
// comboSpacing to function
|
|
293
|
-
const comboSpacing = self.comboSpacing;
|
|
294
|
-
let comboSpacingFunc;
|
|
295
|
-
if (isNumber(comboSpacing)) {
|
|
296
|
-
comboSpacingFunc = () => comboSpacing;
|
|
297
|
-
}
|
|
298
|
-
else if (isFunction(comboSpacing)) {
|
|
299
|
-
comboSpacingFunc = comboSpacing;
|
|
300
|
-
}
|
|
301
|
-
else {
|
|
302
|
-
// null type
|
|
303
|
-
comboSpacingFunc = () => 0;
|
|
304
|
-
}
|
|
305
|
-
this.comboSpacing = comboSpacingFunc;
|
|
306
|
-
// comboPadding to function
|
|
307
|
-
const comboPadding = self.comboPadding;
|
|
308
|
-
let comboPaddingFunc;
|
|
309
|
-
if (isNumber(comboPadding)) {
|
|
310
|
-
comboPaddingFunc = () => comboPadding;
|
|
311
|
-
}
|
|
312
|
-
else if (isArray(comboPadding)) {
|
|
313
|
-
comboPaddingFunc = () => Math.max.apply(null, comboPadding);
|
|
314
|
-
}
|
|
315
|
-
else if (isFunction(comboPadding)) {
|
|
316
|
-
comboPaddingFunc = comboPadding;
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
// null type
|
|
320
|
-
comboPaddingFunc = () => 0;
|
|
321
|
-
}
|
|
322
|
-
this.comboPadding = comboPaddingFunc;
|
|
323
|
-
// linkDistance to function
|
|
324
|
-
let linkDistance = this.linkDistance;
|
|
325
|
-
let linkDistanceFunc;
|
|
326
|
-
if (!linkDistance) {
|
|
327
|
-
linkDistance = 10;
|
|
328
|
-
}
|
|
329
|
-
if (isNumber(linkDistance)) {
|
|
330
|
-
linkDistanceFunc = (d) => {
|
|
331
|
-
return linkDistance;
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
else {
|
|
335
|
-
linkDistanceFunc = linkDistance;
|
|
336
|
-
}
|
|
337
|
-
this.linkDistance = linkDistanceFunc;
|
|
338
|
-
// linkStrength to function
|
|
339
|
-
let edgeStrength = this.edgeStrength;
|
|
340
|
-
let edgeStrengthFunc;
|
|
341
|
-
if (!edgeStrength) {
|
|
342
|
-
edgeStrength = 1;
|
|
343
|
-
}
|
|
344
|
-
if (isNumber(edgeStrength)) {
|
|
345
|
-
edgeStrengthFunc = (d) => {
|
|
346
|
-
return edgeStrength;
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
else {
|
|
350
|
-
edgeStrengthFunc = edgeStrength;
|
|
351
|
-
}
|
|
352
|
-
this.edgeStrength = edgeStrengthFunc;
|
|
353
|
-
// nodeStrength to function
|
|
354
|
-
let nodeStrength = this.nodeStrength;
|
|
355
|
-
let nodeStrengthFunc;
|
|
356
|
-
if (!nodeStrength) {
|
|
357
|
-
nodeStrength = 30;
|
|
358
|
-
}
|
|
359
|
-
if (isNumber(nodeStrength)) {
|
|
360
|
-
nodeStrengthFunc = (d) => {
|
|
361
|
-
return nodeStrength;
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
else {
|
|
365
|
-
nodeStrengthFunc = nodeStrength;
|
|
366
|
-
}
|
|
367
|
-
this.nodeStrength = nodeStrengthFunc;
|
|
368
|
-
}
|
|
369
|
-
initPos(comboMap) {
|
|
370
|
-
const self = this;
|
|
371
|
-
const nodes = self.nodes;
|
|
372
|
-
nodes.forEach((node, i) => {
|
|
373
|
-
const comboId = node.comboId;
|
|
374
|
-
const combo = comboMap[comboId];
|
|
375
|
-
if (comboId && combo) {
|
|
376
|
-
node.x = combo.cx + 100 / (i + 1);
|
|
377
|
-
node.y = combo.cy + 100 / (i + 1);
|
|
378
|
-
}
|
|
379
|
-
else {
|
|
380
|
-
node.x = 100 / (i + 1);
|
|
381
|
-
node.y = 100 / (i + 1);
|
|
382
|
-
}
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
getComboMap() {
|
|
386
|
-
const self = this;
|
|
387
|
-
const nodeMap = self.nodeMap;
|
|
388
|
-
const comboTrees = self.comboTrees;
|
|
389
|
-
const oriComboMap = self.oriComboMap;
|
|
390
|
-
const comboMap = {};
|
|
391
|
-
(comboTrees || []).forEach((ctree) => {
|
|
392
|
-
const treeChildren = [];
|
|
393
|
-
traverseTreeUp(ctree, (treeNode) => {
|
|
394
|
-
if (treeNode.itemType === "node")
|
|
395
|
-
return true; // skip it
|
|
396
|
-
if (!oriComboMap[treeNode.id])
|
|
397
|
-
return true; // means it is hidden, skip it
|
|
398
|
-
if (comboMap[treeNode.id] === undefined) {
|
|
399
|
-
const combo = {
|
|
400
|
-
id: treeNode.id,
|
|
401
|
-
name: treeNode.id,
|
|
402
|
-
cx: 0,
|
|
403
|
-
cy: 0,
|
|
404
|
-
count: 0,
|
|
405
|
-
depth: self.oriComboMap[treeNode.id].depth || 0,
|
|
406
|
-
children: []
|
|
407
|
-
};
|
|
408
|
-
comboMap[treeNode.id] = combo;
|
|
409
|
-
}
|
|
410
|
-
const children = treeNode.children;
|
|
411
|
-
if (children) {
|
|
412
|
-
children.forEach((child) => {
|
|
413
|
-
if (!comboMap[child.id] && !nodeMap[child.id])
|
|
414
|
-
return true; // means it is hidden
|
|
415
|
-
treeChildren.push(child);
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
const c = comboMap[treeNode.id];
|
|
419
|
-
c.cx = 0;
|
|
420
|
-
c.cy = 0;
|
|
421
|
-
if (treeChildren.length === 0) {
|
|
422
|
-
c.empty = true;
|
|
423
|
-
const oriCombo = oriComboMap[treeNode.id];
|
|
424
|
-
c.cx = oriCombo.x;
|
|
425
|
-
c.cy = oriCombo.y;
|
|
426
|
-
}
|
|
427
|
-
treeChildren.forEach((child) => {
|
|
428
|
-
c.count++;
|
|
429
|
-
if (child.itemType !== "node") {
|
|
430
|
-
const childCombo = comboMap[child.id];
|
|
431
|
-
if (isNumber(childCombo.cx))
|
|
432
|
-
c.cx += childCombo.cx;
|
|
433
|
-
if (isNumber(childCombo.cy))
|
|
434
|
-
c.cy += childCombo.cy;
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
const node = nodeMap[child.id];
|
|
438
|
-
// means the node is hidden, skip it
|
|
439
|
-
if (!node)
|
|
440
|
-
return;
|
|
441
|
-
if (isNumber(node.x)) {
|
|
442
|
-
c.cx += node.x;
|
|
443
|
-
}
|
|
444
|
-
if (isNumber(node.y)) {
|
|
445
|
-
c.cy += node.y;
|
|
446
|
-
}
|
|
447
|
-
});
|
|
448
|
-
c.cx /= (c.count || 1);
|
|
449
|
-
c.cy /= (c.count || 1);
|
|
450
|
-
c.children = treeChildren;
|
|
451
|
-
return true;
|
|
452
|
-
});
|
|
453
|
-
});
|
|
454
|
-
return comboMap;
|
|
455
|
-
}
|
|
456
|
-
applyComboCenterForce(displacements) {
|
|
457
|
-
const self = this;
|
|
458
|
-
const gravity = self.gravity;
|
|
459
|
-
const comboGravity = self.comboGravity || gravity;
|
|
460
|
-
const alpha = this.alpha;
|
|
461
|
-
const comboTrees = self.comboTrees;
|
|
462
|
-
const indexMap = self.indexMap;
|
|
463
|
-
const nodeMap = self.nodeMap;
|
|
464
|
-
const comboMap = self.comboMap;
|
|
465
|
-
(comboTrees || []).forEach((ctree) => {
|
|
466
|
-
traverseTreeUp(ctree, (treeNode) => {
|
|
467
|
-
if (treeNode.itemType === "node")
|
|
468
|
-
return true; // skip it
|
|
469
|
-
const combo = comboMap[treeNode.id];
|
|
470
|
-
// means the combo is hidden, skip it
|
|
471
|
-
if (!combo)
|
|
472
|
-
return true;
|
|
473
|
-
const c = comboMap[treeNode.id];
|
|
474
|
-
// higher depth the combo, larger the gravity
|
|
475
|
-
const gravityScale = ((c.depth + 1) / 10) * 0.5;
|
|
476
|
-
// apply combo center force for all the descend nodes in this combo
|
|
477
|
-
// and update the center position and count for this combo
|
|
478
|
-
const comboX = c.cx;
|
|
479
|
-
const comboY = c.cy;
|
|
480
|
-
c.cx = 0;
|
|
481
|
-
c.cy = 0;
|
|
482
|
-
c.children.forEach((child) => {
|
|
483
|
-
if (child.itemType !== "node") {
|
|
484
|
-
const childCombo = comboMap[child.id];
|
|
485
|
-
if (childCombo && isNumber(childCombo.cx))
|
|
486
|
-
c.cx += childCombo.cx;
|
|
487
|
-
if (childCombo && isNumber(childCombo.cy))
|
|
488
|
-
c.cy += childCombo.cy;
|
|
489
|
-
return;
|
|
490
|
-
}
|
|
491
|
-
const node = nodeMap[child.id];
|
|
492
|
-
const vecX = (node.x - comboX) || 0.005;
|
|
493
|
-
const vecY = (node.y - comboY) || 0.005;
|
|
494
|
-
const l = Math.sqrt(vecX * vecX + vecY * vecY);
|
|
495
|
-
const childIdx = indexMap[node.id];
|
|
496
|
-
const params = ((comboGravity * alpha) / l) * gravityScale;
|
|
497
|
-
displacements[childIdx].x -= vecX * params;
|
|
498
|
-
displacements[childIdx].y -= vecY * params;
|
|
499
|
-
if (isNumber(node.x))
|
|
500
|
-
c.cx += node.x;
|
|
501
|
-
if (isNumber(node.y))
|
|
502
|
-
c.cy += node.y;
|
|
503
|
-
});
|
|
504
|
-
c.cx /= (c.count || 1);
|
|
505
|
-
c.cy /= (c.count || 1);
|
|
506
|
-
return true;
|
|
507
|
-
});
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
applyCalculate(displacements) {
|
|
511
|
-
const self = this;
|
|
512
|
-
const comboMap = self.comboMap;
|
|
513
|
-
const nodes = self.nodes;
|
|
514
|
-
// store the vx, vy, and distance to reduce dulplicate calculation
|
|
515
|
-
const vecMap = {};
|
|
516
|
-
nodes.forEach((v, i) => {
|
|
517
|
-
nodes.forEach((u, j) => {
|
|
518
|
-
if (i < j)
|
|
519
|
-
return;
|
|
520
|
-
const vx = (v.x - u.x) || 0.005;
|
|
521
|
-
const vy = (v.y - u.y) || 0.005;
|
|
522
|
-
let vl2 = vx * vx + vy * vy;
|
|
523
|
-
const vl = Math.sqrt(vl2);
|
|
524
|
-
if (vl2 < 1)
|
|
525
|
-
vl2 = vl;
|
|
526
|
-
vecMap[`${v.id}-${u.id}`] = { vx, vy, vl2, vl };
|
|
527
|
-
vecMap[`${u.id}-${v.id}`] = { vl2, vl, vx: -vx, vy: -vy };
|
|
528
|
-
});
|
|
529
|
-
});
|
|
530
|
-
// get the sizes of the combos
|
|
531
|
-
self.updateComboSizes(comboMap);
|
|
532
|
-
self.calRepulsive(displacements, vecMap);
|
|
533
|
-
self.calAttractive(displacements, vecMap);
|
|
534
|
-
const preventComboOverlap = self.preventComboOverlap;
|
|
535
|
-
if (preventComboOverlap)
|
|
536
|
-
self.comboNonOverlapping(displacements, comboMap);
|
|
537
|
-
}
|
|
538
|
-
/**
|
|
539
|
-
* Update the sizes of the combos according to their children
|
|
540
|
-
* Used for combos nonoverlap, but not re-render the combo shapes
|
|
541
|
-
*/
|
|
542
|
-
updateComboSizes(comboMap) {
|
|
543
|
-
const self = this;
|
|
544
|
-
const comboTrees = self.comboTrees;
|
|
545
|
-
const nodeMap = self.nodeMap;
|
|
546
|
-
const nodeSize = self.nodeSize;
|
|
547
|
-
const comboSpacing = self.comboSpacing;
|
|
548
|
-
const comboPadding = self.comboPadding;
|
|
549
|
-
(comboTrees || []).forEach((ctree) => {
|
|
550
|
-
const treeChildren = [];
|
|
551
|
-
traverseTreeUp(ctree, (treeNode) => {
|
|
552
|
-
if (treeNode.itemType === "node")
|
|
553
|
-
return true; // skip it
|
|
554
|
-
const c = comboMap[treeNode.id];
|
|
555
|
-
// means the combo is hidden, skip it
|
|
556
|
-
if (!c)
|
|
557
|
-
return false;
|
|
558
|
-
const children = treeNode.children;
|
|
559
|
-
if (children) {
|
|
560
|
-
children.forEach((child) => {
|
|
561
|
-
// means the combo is hidden.
|
|
562
|
-
if (!comboMap[child.id] && !nodeMap[child.id])
|
|
563
|
-
return;
|
|
564
|
-
treeChildren.push(child);
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
c.minX = Infinity;
|
|
568
|
-
c.minY = Infinity;
|
|
569
|
-
c.maxX = -Infinity;
|
|
570
|
-
c.maxY = -Infinity;
|
|
571
|
-
treeChildren.forEach((child) => {
|
|
572
|
-
if (child.itemType !== "node")
|
|
573
|
-
return true; // skip it
|
|
574
|
-
const node = nodeMap[child.id];
|
|
575
|
-
if (!node)
|
|
576
|
-
return true; // means it is hidden
|
|
577
|
-
const r = nodeSize(node);
|
|
578
|
-
const nodeMinX = node.x - r;
|
|
579
|
-
const nodeMinY = node.y - r;
|
|
580
|
-
const nodeMaxX = node.x + r;
|
|
581
|
-
const nodeMaxY = node.y + r;
|
|
582
|
-
if (c.minX > nodeMinX)
|
|
583
|
-
c.minX = nodeMinX;
|
|
584
|
-
if (c.minY > nodeMinY)
|
|
585
|
-
c.minY = nodeMinY;
|
|
586
|
-
if (c.maxX < nodeMaxX)
|
|
587
|
-
c.maxX = nodeMaxX;
|
|
588
|
-
if (c.maxY < nodeMaxY)
|
|
589
|
-
c.maxY = nodeMaxY;
|
|
590
|
-
});
|
|
591
|
-
let minSize = self.oriComboMap[treeNode.id].size || 10;
|
|
592
|
-
if (isArray(minSize))
|
|
593
|
-
minSize = minSize[0];
|
|
594
|
-
const maxLength = Math.max(c.maxX - c.minX, c.maxY - c.minY, minSize);
|
|
595
|
-
c.r = maxLength / 2 + comboSpacing(c) / 2 + comboPadding(c);
|
|
596
|
-
return true;
|
|
597
|
-
});
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
|
-
/**
|
|
601
|
-
* prevent the overlappings among combos
|
|
602
|
-
*/
|
|
603
|
-
comboNonOverlapping(displacements, comboMap) {
|
|
604
|
-
const self = this;
|
|
605
|
-
const comboTree = self.comboTree;
|
|
606
|
-
const comboCollideStrength = self.comboCollideStrength;
|
|
607
|
-
const indexMap = self.indexMap;
|
|
608
|
-
const nodeMap = self.nodeMap;
|
|
609
|
-
traverseTreeUp(comboTree, (treeNode) => {
|
|
610
|
-
if (!comboMap[treeNode.id] &&
|
|
611
|
-
!nodeMap[treeNode.id] &&
|
|
612
|
-
treeNode.id !== "comboTreeRoot") {
|
|
613
|
-
return false;
|
|
614
|
-
} // means it is hidden
|
|
615
|
-
const children = treeNode.children;
|
|
616
|
-
// 同个子树下的子 combo 间两两对比
|
|
617
|
-
if (children && children.length > 1) {
|
|
618
|
-
children.forEach((v, i) => {
|
|
619
|
-
if (v.itemType === "node")
|
|
620
|
-
return false; // skip it
|
|
621
|
-
const cv = comboMap[v.id];
|
|
622
|
-
if (!cv)
|
|
623
|
-
return; // means it is hidden, skip it
|
|
624
|
-
children.forEach((u, j) => {
|
|
625
|
-
if (i <= j)
|
|
626
|
-
return false;
|
|
627
|
-
if (u.itemType === "node")
|
|
628
|
-
return false; // skip it
|
|
629
|
-
const cu = comboMap[u.id];
|
|
630
|
-
if (!cu)
|
|
631
|
-
return false; // means it is hidden, skip it
|
|
632
|
-
const vx = (cv.cx - cu.cx) || 0.005;
|
|
633
|
-
const vy = (cv.cy - cu.cy) || 0.005;
|
|
634
|
-
const l = vx * vx + vy * vy;
|
|
635
|
-
const rv = cv.r || 1;
|
|
636
|
-
const ru = cu.r || 1;
|
|
637
|
-
const r = rv + ru;
|
|
638
|
-
const ru2 = ru * ru;
|
|
639
|
-
const rv2 = rv * rv;
|
|
640
|
-
// overlapping
|
|
641
|
-
if (l < r * r) {
|
|
642
|
-
const vnodes = v.children;
|
|
643
|
-
if (!vnodes || vnodes.length === 0)
|
|
644
|
-
return false; // skip it
|
|
645
|
-
const unodes = u.children;
|
|
646
|
-
if (!unodes || unodes.length === 0)
|
|
647
|
-
return false; // skip it
|
|
648
|
-
const sqrtl = Math.sqrt(l);
|
|
649
|
-
const ll = ((r - sqrtl) / sqrtl) * comboCollideStrength;
|
|
650
|
-
const xl = vx * ll;
|
|
651
|
-
const yl = vy * ll;
|
|
652
|
-
const rratio = ru2 / (rv2 + ru2);
|
|
653
|
-
const irratio = 1 - rratio;
|
|
654
|
-
// 两兄弟 combo 的子节点上施加斥力
|
|
655
|
-
vnodes.forEach((vn) => {
|
|
656
|
-
if (vn.itemType !== "node")
|
|
657
|
-
return false; // skip it
|
|
658
|
-
if (!nodeMap[vn.id])
|
|
659
|
-
return; // means it is hidden, skip it
|
|
660
|
-
const vindex = indexMap[vn.id];
|
|
661
|
-
unodes.forEach((un) => {
|
|
662
|
-
if (un.itemType !== "node")
|
|
663
|
-
return false;
|
|
664
|
-
if (!nodeMap[un.id])
|
|
665
|
-
return false; // means it is hidden, skip it
|
|
666
|
-
const uindex = indexMap[un.id];
|
|
667
|
-
displacements[vindex].x += xl * rratio;
|
|
668
|
-
displacements[vindex].y += yl * rratio;
|
|
669
|
-
displacements[uindex].x -= xl * irratio;
|
|
670
|
-
displacements[uindex].y -= yl * irratio;
|
|
671
|
-
});
|
|
672
|
-
});
|
|
673
|
-
}
|
|
674
|
-
});
|
|
675
|
-
});
|
|
676
|
-
}
|
|
677
|
-
return true;
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
/**
|
|
681
|
-
* Calculate the repulsive force between each node pair
|
|
682
|
-
* @param displacements The array stores the displacements for nodes
|
|
683
|
-
* @param vecMap The map stores vector between each node pair
|
|
684
|
-
*/
|
|
685
|
-
calRepulsive(displacements, vecMap) {
|
|
686
|
-
const self = this;
|
|
687
|
-
const nodes = self.nodes;
|
|
688
|
-
const max = self.width * self.optimizeRangeFactor;
|
|
689
|
-
const nodeStrength = self.nodeStrength;
|
|
690
|
-
const alpha = self.alpha;
|
|
691
|
-
const nodeCollideStrength = self.nodeCollideStrength;
|
|
692
|
-
const preventNodeOverlap = self.preventNodeOverlap;
|
|
693
|
-
const nodeSizeFunc = self.nodeSize;
|
|
694
|
-
const nodeSpacingFunc = self.nodeSpacing;
|
|
695
|
-
const scale = self.depthRepulsiveForceScale;
|
|
696
|
-
const center = self.center;
|
|
697
|
-
nodes.forEach((v, i) => {
|
|
698
|
-
if (!v.x || !v.y)
|
|
699
|
-
return;
|
|
700
|
-
// center gravity
|
|
701
|
-
if (center) {
|
|
702
|
-
const gravity = self.gravity;
|
|
703
|
-
const vecX = (v.x - center[0]) || 0.005;
|
|
704
|
-
const vecY = (v.y - center[1]) || 0.005;
|
|
705
|
-
const l = Math.sqrt(vecX * vecX + vecY * vecY);
|
|
706
|
-
displacements[i].x -= (vecX * gravity * alpha) / l;
|
|
707
|
-
displacements[i].y -= (vecY * gravity * alpha) / l;
|
|
708
|
-
}
|
|
709
|
-
nodes.forEach((u, j) => {
|
|
710
|
-
if (i === j) {
|
|
711
|
-
return;
|
|
712
|
-
}
|
|
713
|
-
if (!u.x || !u.y)
|
|
714
|
-
return;
|
|
715
|
-
const { vl2, vl } = vecMap[`${v.id}-${u.id}`];
|
|
716
|
-
if (vl > max)
|
|
717
|
-
return;
|
|
718
|
-
const { vx, vy } = vecMap[`${v.id}-${u.id}`];
|
|
719
|
-
let depthDiff = Math.log(Math.abs(u.depth - v.depth) / 10) + 1 || 1;
|
|
720
|
-
depthDiff = depthDiff < 1 ? 1 : depthDiff;
|
|
721
|
-
if (u.comboId !== v.comboId)
|
|
722
|
-
depthDiff += 1;
|
|
723
|
-
const depthParam = depthDiff ? Math.pow(scale, depthDiff) : 1;
|
|
724
|
-
const params = ((nodeStrength(u) * alpha) / vl2) * depthParam;
|
|
725
|
-
displacements[i].x += vx * params;
|
|
726
|
-
displacements[i].y += vy * params;
|
|
727
|
-
// prevent node overlappings
|
|
728
|
-
if (i < j && preventNodeOverlap) {
|
|
729
|
-
const ri = (nodeSizeFunc(v) + nodeSpacingFunc(v)) || 1;
|
|
730
|
-
const rj = (nodeSizeFunc(u) + nodeSpacingFunc(u)) || 1;
|
|
731
|
-
const r = ri + rj;
|
|
732
|
-
if (vl2 < r * r) {
|
|
733
|
-
const ll = ((r - vl) / vl) * nodeCollideStrength;
|
|
734
|
-
const rj2 = rj * rj;
|
|
735
|
-
let rratio = rj2 / (ri * ri + rj2);
|
|
736
|
-
const xl = vx * ll;
|
|
737
|
-
const yl = vy * ll;
|
|
738
|
-
displacements[i].x += xl * rratio;
|
|
739
|
-
displacements[i].y += yl * rratio;
|
|
740
|
-
rratio = 1 - rratio;
|
|
741
|
-
displacements[j].x -= xl * rratio;
|
|
742
|
-
displacements[j].y -= yl * rratio;
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
});
|
|
746
|
-
});
|
|
747
|
-
}
|
|
748
|
-
/**
|
|
749
|
-
* Calculate the attractive force between the node pair with edge
|
|
750
|
-
* @param displacements The array stores the displacements for nodes
|
|
751
|
-
* @param vecMap The map stores vector between each node pair
|
|
752
|
-
*/
|
|
753
|
-
calAttractive(displacements, vecMap) {
|
|
754
|
-
const self = this;
|
|
755
|
-
const edges = self.edges;
|
|
756
|
-
const linkDistance = self.linkDistance;
|
|
757
|
-
const alpha = self.alpha;
|
|
758
|
-
const edgeStrength = self.edgeStrength;
|
|
759
|
-
const bias = self.bias;
|
|
760
|
-
const scale = self.depthAttractiveForceScale;
|
|
761
|
-
edges.forEach((e, i) => {
|
|
762
|
-
const source = getEdgeTerminal(e, 'source');
|
|
763
|
-
const target = getEdgeTerminal(e, 'target');
|
|
764
|
-
if (!source || !target || source === target)
|
|
765
|
-
return;
|
|
766
|
-
const uIndex = self.indexMap[source];
|
|
767
|
-
const vIndex = self.indexMap[target];
|
|
768
|
-
const u = self.nodeMap[source];
|
|
769
|
-
const v = self.nodeMap[target];
|
|
770
|
-
if (!u || !v)
|
|
771
|
-
return;
|
|
772
|
-
let depthDiff = u.depth === v.depth ? 0 : Math.log(Math.abs(u.depth - v.depth) / 10);
|
|
773
|
-
if (u.comboId === v.comboId) {
|
|
774
|
-
depthDiff = depthDiff / 2;
|
|
775
|
-
}
|
|
776
|
-
let depthParam = depthDiff ? Math.pow(scale, depthDiff) : 1;
|
|
777
|
-
if (u.comboId !== v.comboId && depthParam === 1) {
|
|
778
|
-
depthParam = scale / 2;
|
|
779
|
-
}
|
|
780
|
-
else if (u.comboId === v.comboId) {
|
|
781
|
-
depthParam = 2;
|
|
782
|
-
}
|
|
783
|
-
if (!isNumber(v.x) || !isNumber(u.x) || !isNumber(v.y) || !isNumber(u.y)) {
|
|
784
|
-
return;
|
|
785
|
-
}
|
|
786
|
-
const { vl, vx, vy } = vecMap[`${target}-${source}`];
|
|
787
|
-
const l = ((vl - linkDistance(e)) / vl) * alpha * edgeStrength(e) * depthParam;
|
|
788
|
-
const vecX = vx * l;
|
|
789
|
-
const vecY = vy * l;
|
|
790
|
-
const b = bias[i];
|
|
791
|
-
displacements[vIndex].x -= vecX * b;
|
|
792
|
-
displacements[vIndex].y -= vecY * b;
|
|
793
|
-
displacements[uIndex].x += vecX * (1 - b);
|
|
794
|
-
displacements[uIndex].y += vecY * (1 - b);
|
|
795
|
-
});
|
|
796
|
-
}
|
|
797
|
-
getType() {
|
|
798
|
-
return "comboForce";
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
//# sourceMappingURL=comboForce.js.map
|