@antv/layout 0.3.12 → 1.0.0-alpha.0
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 +3 -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/src/layout/radial/mds.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { PointTuple, Matrix } from '../types';
|
|
2
|
-
import { Matrix as MLMatrix, SingularValueDecomposition } from 'ml-matrix';
|
|
3
|
-
|
|
4
|
-
export default class MDS {
|
|
5
|
-
/** distance matrix */
|
|
6
|
-
public distances: Matrix[];
|
|
7
|
-
|
|
8
|
-
/** dimensions */
|
|
9
|
-
public dimension: number;
|
|
10
|
-
|
|
11
|
-
/** link distance */
|
|
12
|
-
public linkDistance: number;
|
|
13
|
-
|
|
14
|
-
constructor(params: { distances: Matrix[]; dimension?: number; linkDistance: number }) {
|
|
15
|
-
this.distances = params.distances;
|
|
16
|
-
this.dimension = params.dimension || 2;
|
|
17
|
-
this.linkDistance = params.linkDistance;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
public layout(): PointTuple[] {
|
|
21
|
-
const self = this;
|
|
22
|
-
const { dimension, distances, linkDistance } = self;
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
// square distances
|
|
26
|
-
const M = MLMatrix.mul(MLMatrix.pow(distances, 2), -0.5);
|
|
27
|
-
|
|
28
|
-
// double centre the rows/columns
|
|
29
|
-
const rowMeans = M.mean('row');
|
|
30
|
-
const colMeans = M.mean('column');
|
|
31
|
-
const totalMean = M.mean();
|
|
32
|
-
M.add(totalMean).subRowVector(rowMeans).subColumnVector(colMeans);
|
|
33
|
-
|
|
34
|
-
// take the SVD of the double centred matrix, and return the
|
|
35
|
-
// points from it
|
|
36
|
-
const ret = new SingularValueDecomposition(M);
|
|
37
|
-
const eigenValues = MLMatrix.sqrt(ret.diagonalMatrix).diagonal();
|
|
38
|
-
return ret.leftSingularVectors.toJSON().map((row: number[]) => {
|
|
39
|
-
return MLMatrix.mul([row], [eigenValues]).toJSON()[0].splice(0, dimension) as PointTuple;
|
|
40
|
-
});
|
|
41
|
-
} catch {
|
|
42
|
-
const res: PointTuple[] = [];
|
|
43
|
-
for (let i = 0; i < distances.length; i++) {
|
|
44
|
-
const x = Math.random() * linkDistance;
|
|
45
|
-
const y = Math.random() * linkDistance;
|
|
46
|
-
res.push([x, y]);
|
|
47
|
-
}
|
|
48
|
-
return res;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,500 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileOverview random layout
|
|
3
|
-
* @author shiwu.wyy@antfin.com
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
PointTuple,
|
|
8
|
-
Node,
|
|
9
|
-
OutNode,
|
|
10
|
-
Edge,
|
|
11
|
-
Matrix,
|
|
12
|
-
RadialLayoutOptions
|
|
13
|
-
} from "../types";
|
|
14
|
-
import {
|
|
15
|
-
isNaN,
|
|
16
|
-
isArray,
|
|
17
|
-
isFunction,
|
|
18
|
-
isNumber,
|
|
19
|
-
isString,
|
|
20
|
-
floydWarshall,
|
|
21
|
-
getAdjMatrix,
|
|
22
|
-
isObject
|
|
23
|
-
} from "../../util";
|
|
24
|
-
import { Base } from "../base";
|
|
25
|
-
import MDS from "./mds";
|
|
26
|
-
import RadialNonoverlapForce, {
|
|
27
|
-
RadialNonoverlapForceParam
|
|
28
|
-
} from "./radialNonoverlapForce";
|
|
29
|
-
|
|
30
|
-
type INode = OutNode & {
|
|
31
|
-
size?: number | PointTuple;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
function getWeightMatrix(M: Matrix[]) {
|
|
35
|
-
const rows = M.length;
|
|
36
|
-
const cols = M[0].length;
|
|
37
|
-
const result = [];
|
|
38
|
-
for (let i = 0; i < rows; i++) {
|
|
39
|
-
const row = [];
|
|
40
|
-
for (let j = 0; j < cols; j++) {
|
|
41
|
-
if (M[i][j] !== 0) {
|
|
42
|
-
row.push(1 / (M[i][j] * M[i][j]));
|
|
43
|
-
} else {
|
|
44
|
-
row.push(0);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
result.push(row);
|
|
48
|
-
}
|
|
49
|
-
return result;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function getIndexById(array: any[], id: string) {
|
|
53
|
-
let index = -1;
|
|
54
|
-
array.forEach((a, i) => {
|
|
55
|
-
if (a.id === id) {
|
|
56
|
-
index = i;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
return index;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function getEDistance(p1: PointTuple, p2: PointTuple) {
|
|
63
|
-
return Math.sqrt(
|
|
64
|
-
(p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1])
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* 辐射状布局
|
|
70
|
-
*/
|
|
71
|
-
export class RadialLayout extends Base {
|
|
72
|
-
/** 布局中心 */
|
|
73
|
-
public center: PointTuple;
|
|
74
|
-
|
|
75
|
-
/** 停止迭代的最大迭代数 */
|
|
76
|
-
public maxIteration: number = 1000;
|
|
77
|
-
|
|
78
|
-
/** 中心点,默认为数据中第一个点 */
|
|
79
|
-
public focusNode: string | Node | null = null;
|
|
80
|
-
|
|
81
|
-
/** 每一圈半径 */
|
|
82
|
-
public unitRadius: number | null = null;
|
|
83
|
-
|
|
84
|
-
/** 默认边长度 */
|
|
85
|
-
public linkDistance: number = 50;
|
|
86
|
-
|
|
87
|
-
/** 是否防止重叠 */
|
|
88
|
-
public preventOverlap: boolean = false;
|
|
89
|
-
|
|
90
|
-
/** 节点直径 */
|
|
91
|
-
public nodeSize: number | number[] | undefined;
|
|
92
|
-
|
|
93
|
-
/** 节点间距,防止节点重叠时节点之间的最小距离(两节点边缘最短距离) */
|
|
94
|
-
public nodeSpacing: number | Function | undefined;
|
|
95
|
-
|
|
96
|
-
/** 是否必须是严格的 radial 布局,即每一层的节点严格布局在一个环上。preventOverlap 为 true 时生效 */
|
|
97
|
-
public strictRadial: boolean = true;
|
|
98
|
-
|
|
99
|
-
/** 防止重叠步骤的最大迭代次数 */
|
|
100
|
-
public maxPreventOverlapIteration: number = 200;
|
|
101
|
-
|
|
102
|
-
public sortBy: string | undefined;
|
|
103
|
-
|
|
104
|
-
public sortStrength: number = 10;
|
|
105
|
-
|
|
106
|
-
public width: number | undefined;
|
|
107
|
-
|
|
108
|
-
public height: number | undefined;
|
|
109
|
-
|
|
110
|
-
private focusIndex: number | undefined;
|
|
111
|
-
|
|
112
|
-
private distances: Matrix[] | undefined;
|
|
113
|
-
|
|
114
|
-
private eIdealDistances: Matrix[] | undefined;
|
|
115
|
-
|
|
116
|
-
private weights: Matrix[] | undefined;
|
|
117
|
-
|
|
118
|
-
private radii: number[] | undefined;
|
|
119
|
-
|
|
120
|
-
public nodes: INode[] = [];
|
|
121
|
-
|
|
122
|
-
public edges: Edge[] = [];
|
|
123
|
-
|
|
124
|
-
public onLayoutEnd: () => void;
|
|
125
|
-
|
|
126
|
-
constructor(options?: RadialLayoutOptions) {
|
|
127
|
-
super();
|
|
128
|
-
this.updateCfg(options);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
public getDefaultCfg() {
|
|
132
|
-
return {
|
|
133
|
-
maxIteration: 1000,
|
|
134
|
-
focusNode: null,
|
|
135
|
-
unitRadius: null,
|
|
136
|
-
linkDistance: 50,
|
|
137
|
-
preventOverlap: false,
|
|
138
|
-
nodeSize: undefined,
|
|
139
|
-
nodeSpacing: undefined,
|
|
140
|
-
strictRadial: true,
|
|
141
|
-
maxPreventOverlapIteration: 200,
|
|
142
|
-
sortBy: undefined,
|
|
143
|
-
sortStrength: 10
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* 执行布局
|
|
149
|
-
*/
|
|
150
|
-
public execute() {
|
|
151
|
-
const self = this;
|
|
152
|
-
const nodes = self.nodes;
|
|
153
|
-
const edges = self.edges || [];
|
|
154
|
-
if (!nodes || nodes.length === 0) {
|
|
155
|
-
if (self.onLayoutEnd) self.onLayoutEnd();
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (!self.width && typeof window !== "undefined") {
|
|
160
|
-
self.width = window.innerWidth;
|
|
161
|
-
}
|
|
162
|
-
if (!self.height && typeof window !== "undefined") {
|
|
163
|
-
self.height = window.innerHeight;
|
|
164
|
-
}
|
|
165
|
-
if (!self.center) {
|
|
166
|
-
self.center = [self.width! / 2, self.height! / 2];
|
|
167
|
-
}
|
|
168
|
-
const center = self.center;
|
|
169
|
-
|
|
170
|
-
if (nodes.length === 1) {
|
|
171
|
-
nodes[0].x = center[0];
|
|
172
|
-
nodes[0].y = center[1];
|
|
173
|
-
if (self.onLayoutEnd) self.onLayoutEnd();
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
const linkDistance = self.linkDistance;
|
|
177
|
-
// layout
|
|
178
|
-
let focusNode: INode | null = null;
|
|
179
|
-
if (isString(self.focusNode)) {
|
|
180
|
-
let found = false;
|
|
181
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
182
|
-
if (nodes[i].id === self.focusNode) {
|
|
183
|
-
focusNode = nodes[i];
|
|
184
|
-
self.focusNode = focusNode;
|
|
185
|
-
found = true;
|
|
186
|
-
i = nodes.length;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
if (!found) {
|
|
190
|
-
focusNode = null;
|
|
191
|
-
}
|
|
192
|
-
} else {
|
|
193
|
-
focusNode = self.focusNode as INode;
|
|
194
|
-
}
|
|
195
|
-
// default focus node
|
|
196
|
-
if (!focusNode) {
|
|
197
|
-
focusNode = nodes[0];
|
|
198
|
-
self.focusNode = focusNode;
|
|
199
|
-
}
|
|
200
|
-
// the index of the focusNode in data
|
|
201
|
-
let focusIndex = getIndexById(nodes, focusNode.id);
|
|
202
|
-
if (focusIndex < 0) focusIndex = 0;
|
|
203
|
-
self.focusIndex = focusIndex;
|
|
204
|
-
|
|
205
|
-
// the graph-theoretic distance (shortest path distance) matrix
|
|
206
|
-
const adjMatrix = getAdjMatrix({ nodes, edges }, false);
|
|
207
|
-
const D = floydWarshall(adjMatrix);
|
|
208
|
-
const maxDistance = self.maxToFocus(D, focusIndex);
|
|
209
|
-
// replace first node in unconnected component to the circle at (maxDistance + 1)
|
|
210
|
-
self.handleInfinity(D, focusIndex, maxDistance + 1);
|
|
211
|
-
self.distances = D;
|
|
212
|
-
|
|
213
|
-
// the shortest path distance from each node to focusNode
|
|
214
|
-
const focusNodeD = D[focusIndex];
|
|
215
|
-
const width = self.width || 500;
|
|
216
|
-
const height = self.height || 500;
|
|
217
|
-
let semiWidth =
|
|
218
|
-
width - center[0] > center[0] ? center[0] : width - center[0];
|
|
219
|
-
let semiHeight =
|
|
220
|
-
height - center[1] > center[1] ? center[1] : height - center[1];
|
|
221
|
-
if (semiWidth === 0) {
|
|
222
|
-
semiWidth = width / 2;
|
|
223
|
-
}
|
|
224
|
-
if (semiHeight === 0) {
|
|
225
|
-
semiHeight = height / 2;
|
|
226
|
-
}
|
|
227
|
-
// the maxRadius of the graph
|
|
228
|
-
const maxRadius = semiHeight > semiWidth ? semiWidth : semiHeight;
|
|
229
|
-
const maxD = Math.max(...focusNodeD);
|
|
230
|
-
// the radius for each nodes away from focusNode
|
|
231
|
-
const radii: number[] = [];
|
|
232
|
-
focusNodeD.forEach((value, i) => {
|
|
233
|
-
if (!self.unitRadius) {
|
|
234
|
-
self.unitRadius = maxRadius / maxD;
|
|
235
|
-
}
|
|
236
|
-
radii[i] = value * self.unitRadius;
|
|
237
|
-
});
|
|
238
|
-
self.radii = radii;
|
|
239
|
-
|
|
240
|
-
const eIdealD = self.eIdealDisMatrix();
|
|
241
|
-
// const eIdealD = scaleMatrix(D, linkDistance);
|
|
242
|
-
self.eIdealDistances = eIdealD;
|
|
243
|
-
// the weight matrix, Wij = 1 / dij^(-2)
|
|
244
|
-
const W = getWeightMatrix(eIdealD);
|
|
245
|
-
self.weights = W;
|
|
246
|
-
|
|
247
|
-
// the initial positions from mds
|
|
248
|
-
const mds = new MDS({ linkDistance, distances: eIdealD });
|
|
249
|
-
let positions = mds.layout();
|
|
250
|
-
positions.forEach((p: PointTuple) => {
|
|
251
|
-
if (isNaN(p[0])) {
|
|
252
|
-
p[0] = Math.random() * linkDistance;
|
|
253
|
-
}
|
|
254
|
-
if (isNaN(p[1])) {
|
|
255
|
-
p[1] = Math.random() * linkDistance;
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
self.positions = positions;
|
|
259
|
-
positions.forEach((p: PointTuple, i: number) => {
|
|
260
|
-
nodes[i].x = p[0] + center[0];
|
|
261
|
-
nodes[i].y = p[1] + center[1];
|
|
262
|
-
});
|
|
263
|
-
// move the graph to origin, centered at focusNode
|
|
264
|
-
positions.forEach((p: PointTuple) => {
|
|
265
|
-
p[0] -= positions[focusIndex][0];
|
|
266
|
-
p[1] -= positions[focusIndex][1];
|
|
267
|
-
});
|
|
268
|
-
self.run();
|
|
269
|
-
const preventOverlap = self.preventOverlap;
|
|
270
|
-
const nodeSize = self.nodeSize;
|
|
271
|
-
let nodeSizeFunc;
|
|
272
|
-
const strictRadial = self.strictRadial;
|
|
273
|
-
// stagger the overlapped nodes
|
|
274
|
-
if (preventOverlap) {
|
|
275
|
-
const nodeSpacing = self.nodeSpacing;
|
|
276
|
-
let nodeSpacingFunc: Function;
|
|
277
|
-
if (isNumber(nodeSpacing)) {
|
|
278
|
-
nodeSpacingFunc = () => nodeSpacing;
|
|
279
|
-
} else if (isFunction(nodeSpacing)) {
|
|
280
|
-
nodeSpacingFunc = nodeSpacing;
|
|
281
|
-
} else {
|
|
282
|
-
nodeSpacingFunc = () => 0;
|
|
283
|
-
}
|
|
284
|
-
if (!nodeSize) {
|
|
285
|
-
nodeSizeFunc = (d: INode) => {
|
|
286
|
-
if (d.size) {
|
|
287
|
-
if (isArray(d.size)) {
|
|
288
|
-
const res = d.size[0] > d.size[1] ? d.size[0] : d.size[1];
|
|
289
|
-
return res + nodeSpacingFunc(d);
|
|
290
|
-
} if (isObject(d.size)) {
|
|
291
|
-
const res = d.size.width > d.size.height ? d.size.width : d.size.height;
|
|
292
|
-
return res + nodeSpacingFunc(d);
|
|
293
|
-
}
|
|
294
|
-
return d.size + nodeSpacingFunc(d);
|
|
295
|
-
}
|
|
296
|
-
return 10 + nodeSpacingFunc(d);
|
|
297
|
-
};
|
|
298
|
-
} else if (isArray(nodeSize)) {
|
|
299
|
-
nodeSizeFunc = (d: INode) => {
|
|
300
|
-
const res = nodeSize[0] > nodeSize[1] ? nodeSize[0] : nodeSize[1];
|
|
301
|
-
return res + nodeSpacingFunc(d);
|
|
302
|
-
};
|
|
303
|
-
} else {
|
|
304
|
-
nodeSizeFunc = (d: INode) => nodeSize + nodeSpacingFunc(d);
|
|
305
|
-
}
|
|
306
|
-
const nonoverlapForceParams: RadialNonoverlapForceParam = {
|
|
307
|
-
nodes,
|
|
308
|
-
nodeSizeFunc,
|
|
309
|
-
adjMatrix,
|
|
310
|
-
positions,
|
|
311
|
-
radii,
|
|
312
|
-
height,
|
|
313
|
-
width,
|
|
314
|
-
strictRadial,
|
|
315
|
-
focusID: focusIndex,
|
|
316
|
-
iterations: self.maxPreventOverlapIteration || 200,
|
|
317
|
-
k: positions.length / 4.5
|
|
318
|
-
};
|
|
319
|
-
const nonoverlapForce = new RadialNonoverlapForce(nonoverlapForceParams);
|
|
320
|
-
positions = nonoverlapForce.layout();
|
|
321
|
-
}
|
|
322
|
-
// move the graph to center
|
|
323
|
-
positions.forEach((p: PointTuple, i: number) => {
|
|
324
|
-
nodes[i].x = p[0] + center[0];
|
|
325
|
-
nodes[i].y = p[1] + center[1];
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
if (self.onLayoutEnd) self.onLayoutEnd();
|
|
329
|
-
|
|
330
|
-
return {
|
|
331
|
-
nodes,
|
|
332
|
-
edges
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
public run() {
|
|
337
|
-
const self = this;
|
|
338
|
-
const maxIteration = self.maxIteration;
|
|
339
|
-
const positions = self.positions || [];
|
|
340
|
-
const W = self.weights || [];
|
|
341
|
-
const eIdealDis = self.eIdealDistances || [];
|
|
342
|
-
const radii = self.radii || [];
|
|
343
|
-
for (let i = 0; i <= maxIteration; i++) {
|
|
344
|
-
const param = i / maxIteration;
|
|
345
|
-
self.oneIteration(param, positions, radii, eIdealDis, W);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
private oneIteration(
|
|
350
|
-
param: number,
|
|
351
|
-
positions: PointTuple[],
|
|
352
|
-
radii: number[],
|
|
353
|
-
D: Matrix[],
|
|
354
|
-
W: Matrix[]
|
|
355
|
-
) {
|
|
356
|
-
const self = this;
|
|
357
|
-
const vparam = 1 - param;
|
|
358
|
-
const focusIndex = self.focusIndex;
|
|
359
|
-
positions.forEach((v: PointTuple, i: number) => {
|
|
360
|
-
// v
|
|
361
|
-
const originDis = getEDistance(v, [0, 0]);
|
|
362
|
-
const reciODis = originDis === 0 ? 0 : 1 / originDis;
|
|
363
|
-
if (i === focusIndex) {
|
|
364
|
-
return;
|
|
365
|
-
}
|
|
366
|
-
let xMolecule = 0;
|
|
367
|
-
let yMolecule = 0;
|
|
368
|
-
let denominator = 0;
|
|
369
|
-
positions.forEach((u, j) => {
|
|
370
|
-
// u
|
|
371
|
-
if (i === j) {
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
// the euclidean distance between v and u
|
|
375
|
-
const edis = getEDistance(v, u);
|
|
376
|
-
const reciEdis = edis === 0 ? 0 : 1 / edis;
|
|
377
|
-
const idealDis = D[j][i];
|
|
378
|
-
// same for x and y
|
|
379
|
-
denominator += W[i][j];
|
|
380
|
-
// x
|
|
381
|
-
xMolecule += W[i][j] * (u[0] + idealDis * (v[0] - u[0]) * reciEdis);
|
|
382
|
-
// y
|
|
383
|
-
yMolecule += W[i][j] * (u[1] + idealDis * (v[1] - u[1]) * reciEdis);
|
|
384
|
-
});
|
|
385
|
-
const reciR = radii[i] === 0 ? 0 : 1 / radii[i];
|
|
386
|
-
denominator *= vparam;
|
|
387
|
-
denominator += param * reciR * reciR;
|
|
388
|
-
// x
|
|
389
|
-
xMolecule *= vparam;
|
|
390
|
-
xMolecule += param * reciR * v[0] * reciODis;
|
|
391
|
-
v[0] = xMolecule / denominator;
|
|
392
|
-
// y
|
|
393
|
-
yMolecule *= vparam;
|
|
394
|
-
yMolecule += param * reciR * v[1] * reciODis;
|
|
395
|
-
v[1] = yMolecule / denominator;
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
private eIdealDisMatrix(): Matrix[] {
|
|
400
|
-
const self = this;
|
|
401
|
-
const nodes = self.nodes;
|
|
402
|
-
if (!nodes) return [];
|
|
403
|
-
const D = self.distances;
|
|
404
|
-
const linkDis = self.linkDistance;
|
|
405
|
-
const radii = self.radii || [];
|
|
406
|
-
const unitRadius = self.unitRadius || 50;
|
|
407
|
-
const result: Matrix[] = [];
|
|
408
|
-
if (D) {
|
|
409
|
-
D.forEach((row, i) => {
|
|
410
|
-
const newRow: Matrix = [];
|
|
411
|
-
row.forEach((v, j) => {
|
|
412
|
-
if (i === j) {
|
|
413
|
-
newRow.push(0);
|
|
414
|
-
} else if (radii[i] === radii[j]) {
|
|
415
|
-
// i and j are on the same circle
|
|
416
|
-
if (self.sortBy === "data") {
|
|
417
|
-
// sort the nodes on the same circle according to the ordering of the data
|
|
418
|
-
newRow.push(
|
|
419
|
-
(v * (Math.abs(i - j) * self.sortStrength)) /
|
|
420
|
-
(radii[i] / unitRadius)
|
|
421
|
-
);
|
|
422
|
-
} else if (self.sortBy) {
|
|
423
|
-
// sort the nodes on the same circle according to the attributes
|
|
424
|
-
let iValue: number | string =
|
|
425
|
-
((nodes[i] as any)[self.sortBy] as number | string) || 0;
|
|
426
|
-
let jValue: number | string =
|
|
427
|
-
((nodes[j] as any)[self.sortBy] as number | string) || 0;
|
|
428
|
-
if (isString(iValue)) {
|
|
429
|
-
iValue = iValue.charCodeAt(0);
|
|
430
|
-
}
|
|
431
|
-
if (isString(jValue)) {
|
|
432
|
-
jValue = jValue.charCodeAt(0);
|
|
433
|
-
}
|
|
434
|
-
newRow.push(
|
|
435
|
-
(v * (Math.abs(iValue - jValue) * self.sortStrength)) /
|
|
436
|
-
(radii[i] / unitRadius)
|
|
437
|
-
);
|
|
438
|
-
} else {
|
|
439
|
-
newRow.push((v * linkDis) / (radii[i] / unitRadius));
|
|
440
|
-
}
|
|
441
|
-
} else {
|
|
442
|
-
// i and j are on different circle
|
|
443
|
-
// i and j are on different circle
|
|
444
|
-
const link = (linkDis + unitRadius) / 2;
|
|
445
|
-
newRow.push(v * link);
|
|
446
|
-
}
|
|
447
|
-
});
|
|
448
|
-
result.push(newRow);
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
return result;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
private handleInfinity(matrix: Matrix[], focusIndex: number, step: number) {
|
|
455
|
-
const length = matrix.length;
|
|
456
|
-
// 遍历 matrix 中遍历 focus 对应行
|
|
457
|
-
for (let i = 0; i < length; i++) {
|
|
458
|
-
// matrix 关注点对应行的 Inf 项
|
|
459
|
-
if (matrix[focusIndex][i] === Infinity) {
|
|
460
|
-
matrix[focusIndex][i] = step;
|
|
461
|
-
matrix[i][focusIndex] = step;
|
|
462
|
-
// 遍历 matrix 中的 i 行,i 行中非 Inf 项若在 focus 行为 Inf,则替换 focus 行的那个 Inf
|
|
463
|
-
for (let j = 0; j < length; j++) {
|
|
464
|
-
if (matrix[i][j] !== Infinity && matrix[focusIndex][j] === Infinity) {
|
|
465
|
-
matrix[focusIndex][j] = step + matrix[i][j];
|
|
466
|
-
matrix[j][focusIndex] = step + matrix[i][j];
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
// 处理其他行的 Inf。根据该行对应点与 focus 距离以及 Inf 项点 与 focus 距离,决定替换值
|
|
472
|
-
for (let i = 0; i < length; i++) {
|
|
473
|
-
if (i === focusIndex) {
|
|
474
|
-
continue;
|
|
475
|
-
}
|
|
476
|
-
for (let j = 0; j < length; j++) {
|
|
477
|
-
if (matrix[i][j] === Infinity) {
|
|
478
|
-
let minus = Math.abs(matrix[focusIndex][i] - matrix[focusIndex][j]);
|
|
479
|
-
minus = minus === 0 ? 1 : minus;
|
|
480
|
-
matrix[i][j] = minus;
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
private maxToFocus(matrix: Matrix[], focusIndex: number): number {
|
|
487
|
-
let max = 0;
|
|
488
|
-
for (let i = 0; i < matrix[focusIndex].length; i++) {
|
|
489
|
-
if (matrix[focusIndex][i] === Infinity) {
|
|
490
|
-
continue;
|
|
491
|
-
}
|
|
492
|
-
max = matrix[focusIndex][i] > max ? matrix[focusIndex][i] : max;
|
|
493
|
-
}
|
|
494
|
-
return max;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
public getType() {
|
|
498
|
-
return "radial";
|
|
499
|
-
}
|
|
500
|
-
}
|