@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/src/layout/grid.ts
DELETED
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileOverview grid layout
|
|
3
|
-
* @author shiwu.wyy@antfin.com
|
|
4
|
-
* this algorithm refers to <cytoscape.js> - https://github.com/cytoscape/cytoscape.js/
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { isString, getDegree, isNaN, getFuncByUnknownType, isArray } from "../util";
|
|
8
|
-
import { Base } from "./base";
|
|
9
|
-
import {
|
|
10
|
-
OutNode,
|
|
11
|
-
Edge,
|
|
12
|
-
PointTuple,
|
|
13
|
-
Size,
|
|
14
|
-
IndexMap,
|
|
15
|
-
GridLayoutOptions
|
|
16
|
-
} from "./types";
|
|
17
|
-
|
|
18
|
-
type INode = OutNode & {
|
|
19
|
-
degree: number;
|
|
20
|
-
size: number | PointTuple | Size;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 网格布局
|
|
25
|
-
*/
|
|
26
|
-
export class GridLayout extends Base {
|
|
27
|
-
/** 布局起始点 */
|
|
28
|
-
public begin: PointTuple = [0, 0];
|
|
29
|
-
|
|
30
|
-
/** prevents node overlap, may overflow boundingBox if not enough space */
|
|
31
|
-
public preventOverlap: boolean = true;
|
|
32
|
-
|
|
33
|
-
/** extra spacing around nodes when preventOverlap: true */
|
|
34
|
-
public preventOverlapPadding: number = 10;
|
|
35
|
-
|
|
36
|
-
/** uses all available space on false, uses minimal space on true */
|
|
37
|
-
public condense: boolean = false;
|
|
38
|
-
|
|
39
|
-
/** force num of rows in the grid */
|
|
40
|
-
public rows: number | undefined;
|
|
41
|
-
|
|
42
|
-
/** force num of columns in the grid */
|
|
43
|
-
public cols: number | undefined;
|
|
44
|
-
|
|
45
|
-
/** the spacing between two nodes */
|
|
46
|
-
public nodeSpacing: ((d?: unknown) => number) | number | undefined;
|
|
47
|
-
|
|
48
|
-
/** returns { row, col } for element */
|
|
49
|
-
public position:
|
|
50
|
-
| ((node: INode) => { row?: number; col?: number })
|
|
51
|
-
| undefined;
|
|
52
|
-
|
|
53
|
-
/** a sorting function to order the nodes; e.g. function(a, b){ return a.datapublic ('weight') - b.data('weight') } */
|
|
54
|
-
public sortBy: string = "degree";
|
|
55
|
-
|
|
56
|
-
public nodeSize: number | number[] | { width: number, height: number } | undefined;
|
|
57
|
-
|
|
58
|
-
public nodes: INode[] = [];
|
|
59
|
-
|
|
60
|
-
public edges: Edge[] = [];
|
|
61
|
-
|
|
62
|
-
public width: number = 300;
|
|
63
|
-
|
|
64
|
-
public height: number = 300;
|
|
65
|
-
|
|
66
|
-
private cells: number | undefined;
|
|
67
|
-
|
|
68
|
-
private row: number = 0;
|
|
69
|
-
|
|
70
|
-
private col: number = 0;
|
|
71
|
-
|
|
72
|
-
private splits: number | undefined;
|
|
73
|
-
|
|
74
|
-
private columns: number | undefined;
|
|
75
|
-
|
|
76
|
-
private cellWidth: number = 0;
|
|
77
|
-
|
|
78
|
-
private cellHeight: number = 0;
|
|
79
|
-
|
|
80
|
-
private cellUsed: {
|
|
81
|
-
[key: string]: boolean;
|
|
82
|
-
} = {};
|
|
83
|
-
|
|
84
|
-
private id2manPos: {
|
|
85
|
-
[key: string]: {
|
|
86
|
-
row: number;
|
|
87
|
-
col: number;
|
|
88
|
-
};
|
|
89
|
-
} = {};
|
|
90
|
-
|
|
91
|
-
/** 迭代结束的回调函数 */
|
|
92
|
-
public onLayoutEnd: () => void = () => {};
|
|
93
|
-
|
|
94
|
-
constructor(options?: GridLayoutOptions) {
|
|
95
|
-
super();
|
|
96
|
-
this.updateCfg(options);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
public getDefaultCfg() {
|
|
100
|
-
return {
|
|
101
|
-
begin: [0, 0],
|
|
102
|
-
preventOverlap: true,
|
|
103
|
-
preventOverlapPadding: 10,
|
|
104
|
-
condense: false,
|
|
105
|
-
rows: undefined,
|
|
106
|
-
cols: undefined,
|
|
107
|
-
position: undefined,
|
|
108
|
-
sortBy: "degree",
|
|
109
|
-
nodeSize: 30
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* 执行布局
|
|
115
|
-
*/
|
|
116
|
-
public execute() {
|
|
117
|
-
const self = this;
|
|
118
|
-
const { nodes, edges, begin } = self;
|
|
119
|
-
const n = nodes.length;
|
|
120
|
-
if (n === 0) {
|
|
121
|
-
if (self.onLayoutEnd) self.onLayoutEnd();
|
|
122
|
-
return {
|
|
123
|
-
nodes,
|
|
124
|
-
edges
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
if (n === 1) {
|
|
128
|
-
nodes[0].x = begin[0];
|
|
129
|
-
nodes[0].y = begin[1];
|
|
130
|
-
if (self.onLayoutEnd) self.onLayoutEnd();
|
|
131
|
-
return {
|
|
132
|
-
nodes,
|
|
133
|
-
edges,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
let { sortBy, width, height } = self;
|
|
138
|
-
const { condense, preventOverlapPadding, preventOverlap, nodeSpacing: paramNodeSpacing, nodeSize: paramNodeSize } = self;
|
|
139
|
-
|
|
140
|
-
const layoutNodes: INode[] = [];
|
|
141
|
-
nodes.forEach((node) => {
|
|
142
|
-
layoutNodes.push(node);
|
|
143
|
-
});
|
|
144
|
-
const nodeIdxMap: IndexMap = {};
|
|
145
|
-
layoutNodes.forEach((node, i) => {
|
|
146
|
-
nodeIdxMap[node.id] = i;
|
|
147
|
-
});
|
|
148
|
-
if (
|
|
149
|
-
sortBy === "degree" ||
|
|
150
|
-
!isString(sortBy) ||
|
|
151
|
-
(layoutNodes[0] as any)[sortBy] === undefined
|
|
152
|
-
) {
|
|
153
|
-
sortBy = "degree";
|
|
154
|
-
if (isNaN(nodes[0].degree)) {
|
|
155
|
-
const values = getDegree(layoutNodes.length, nodeIdxMap, edges);
|
|
156
|
-
layoutNodes.forEach((node, i) => {
|
|
157
|
-
node.degree = values[i].all;
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
// sort nodes by value
|
|
162
|
-
layoutNodes.sort(
|
|
163
|
-
(n1, n2) => (n2 as any)[sortBy] - (n1 as any)[sortBy]
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
if (!width && typeof window !== "undefined") {
|
|
167
|
-
width = window.innerWidth;
|
|
168
|
-
}
|
|
169
|
-
if (!height && typeof window !== "undefined") {
|
|
170
|
-
height = window.innerHeight;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const oRows = self.rows;
|
|
174
|
-
const oCols = self.cols != null ? self.cols : self.columns;
|
|
175
|
-
self.cells = n;
|
|
176
|
-
|
|
177
|
-
// if rows or columns were set in self, use those values
|
|
178
|
-
if (oRows != null && oCols != null) {
|
|
179
|
-
self.rows = oRows;
|
|
180
|
-
self.cols = oCols;
|
|
181
|
-
} else if (oRows != null && oCols == null) {
|
|
182
|
-
self.rows = oRows;
|
|
183
|
-
self.cols = Math.ceil(self.cells / self.rows);
|
|
184
|
-
} else if (oRows == null && oCols != null) {
|
|
185
|
-
self.cols = oCols;
|
|
186
|
-
self.rows = Math.ceil(self.cells / self.cols);
|
|
187
|
-
} else {
|
|
188
|
-
// otherwise use the automatic values and adjust accordingly // otherwise use the automatic values and adjust accordingly
|
|
189
|
-
// width/height * splits^2 = cells where splits is number of times to split width
|
|
190
|
-
self.splits = Math.sqrt((self.cells * self.height) / self.width);
|
|
191
|
-
self.rows = Math.round(self.splits);
|
|
192
|
-
self.cols = Math.round((self.width / self.height) * self.splits);
|
|
193
|
-
}
|
|
194
|
-
self.rows = Math.max(self.rows, 1);
|
|
195
|
-
self.cols = Math.max(self.cols, 1);
|
|
196
|
-
if (self.cols * self.rows > self.cells) {
|
|
197
|
-
// otherwise use the automatic values and adjust accordingly
|
|
198
|
-
// if rounding was up, see if we can reduce rows or columns
|
|
199
|
-
const sm = self.small() as number;
|
|
200
|
-
const lg = self.large() as number;
|
|
201
|
-
|
|
202
|
-
// reducing the small side takes away the most cells, so try it first
|
|
203
|
-
if ((sm - 1) * lg >= self.cells) {
|
|
204
|
-
self.small(sm - 1);
|
|
205
|
-
} else if ((lg - 1) * sm >= self.cells) {
|
|
206
|
-
self.large(lg - 1);
|
|
207
|
-
}
|
|
208
|
-
} else {
|
|
209
|
-
// if rounding was too low, add rows or columns
|
|
210
|
-
while (self.cols * self.rows < self.cells) {
|
|
211
|
-
const sm = self.small() as number;
|
|
212
|
-
const lg = self.large() as number;
|
|
213
|
-
|
|
214
|
-
// try to add to larger side first (adds less in multiplication)
|
|
215
|
-
if ((lg + 1) * sm >= self.cells) {
|
|
216
|
-
self.large(lg + 1);
|
|
217
|
-
} else {
|
|
218
|
-
self.small(sm + 1);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
self.cellWidth = width / self.cols;
|
|
224
|
-
self.cellHeight = height / self.rows;
|
|
225
|
-
|
|
226
|
-
if (condense) {
|
|
227
|
-
self.cellWidth = 0;
|
|
228
|
-
self.cellHeight = 0;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
if (preventOverlap || paramNodeSpacing) {
|
|
233
|
-
const nodeSpacing: Function = getFuncByUnknownType(10, paramNodeSpacing);
|
|
234
|
-
const nodeSize: Function = getFuncByUnknownType(30, paramNodeSize, false);
|
|
235
|
-
layoutNodes.forEach((node) => {
|
|
236
|
-
if (!node.x || !node.y) {
|
|
237
|
-
// for bb
|
|
238
|
-
node.x = 0;
|
|
239
|
-
node.y = 0;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
const res = nodeSize(node) || 30;
|
|
243
|
-
|
|
244
|
-
let nodeW;
|
|
245
|
-
let nodeH;
|
|
246
|
-
|
|
247
|
-
if (isArray(res)) {
|
|
248
|
-
nodeW = res[0];
|
|
249
|
-
nodeH = res[1];
|
|
250
|
-
} else {
|
|
251
|
-
nodeW = res;
|
|
252
|
-
nodeH = res;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
const p = nodeSpacing !== undefined ? nodeSpacing(node) : preventOverlapPadding;
|
|
256
|
-
|
|
257
|
-
const w = nodeW + p;
|
|
258
|
-
const h = nodeH + p;
|
|
259
|
-
|
|
260
|
-
self.cellWidth = Math.max(self.cellWidth, w);
|
|
261
|
-
self.cellHeight = Math.max(self.cellHeight, h);
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
self.cellUsed = {}; // e.g. 'c-0-2' => true
|
|
266
|
-
|
|
267
|
-
// to keep track of current cell position
|
|
268
|
-
self.row = 0;
|
|
269
|
-
self.col = 0;
|
|
270
|
-
|
|
271
|
-
// get a cache of all the manual positions
|
|
272
|
-
self.id2manPos = {};
|
|
273
|
-
for (let i = 0; i < layoutNodes.length; i++) {
|
|
274
|
-
const node = layoutNodes[i];
|
|
275
|
-
let rcPos;
|
|
276
|
-
if (self.position) {
|
|
277
|
-
rcPos = self.position(node);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
if (rcPos && (rcPos.row !== undefined || rcPos.col !== undefined)) {
|
|
281
|
-
// must have at least row or col def'd
|
|
282
|
-
const pos = {
|
|
283
|
-
row: rcPos.row,
|
|
284
|
-
col: rcPos.col
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
if (pos.col === undefined) {
|
|
288
|
-
// find unused col
|
|
289
|
-
pos.col = 0;
|
|
290
|
-
|
|
291
|
-
while (self.used(pos.row, pos.col)) {
|
|
292
|
-
pos.col++;
|
|
293
|
-
}
|
|
294
|
-
} else if (pos.row === undefined) {
|
|
295
|
-
// find unused row
|
|
296
|
-
pos.row = 0;
|
|
297
|
-
|
|
298
|
-
while (self.used(pos.row, pos.col)) {
|
|
299
|
-
pos.row++;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
self.id2manPos[node.id] = pos as { row: number; col: number };
|
|
304
|
-
self.use(pos.row, pos.col);
|
|
305
|
-
}
|
|
306
|
-
self.getPos(node);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
if (self.onLayoutEnd) self.onLayoutEnd();
|
|
310
|
-
|
|
311
|
-
return {
|
|
312
|
-
edges,
|
|
313
|
-
nodes: layoutNodes
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
private small(val?: number): number | undefined {
|
|
318
|
-
const self = this;
|
|
319
|
-
let res: number | undefined;
|
|
320
|
-
const rows = self.rows || 5;
|
|
321
|
-
const cols = self.cols || 5;
|
|
322
|
-
if (val == null) {
|
|
323
|
-
res = Math.min(rows, cols);
|
|
324
|
-
} else {
|
|
325
|
-
const min = Math.min(rows, cols);
|
|
326
|
-
if (min === self.rows) {
|
|
327
|
-
self.rows = val;
|
|
328
|
-
} else {
|
|
329
|
-
self.cols = val;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
return res;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
private large(val?: number): number | undefined {
|
|
336
|
-
const self = this;
|
|
337
|
-
let res: number | undefined;
|
|
338
|
-
const rows = self.rows || 5;
|
|
339
|
-
const cols = self.cols || 5;
|
|
340
|
-
if (val == null) {
|
|
341
|
-
res = Math.max(rows, cols);
|
|
342
|
-
} else {
|
|
343
|
-
const max = Math.max(rows, cols);
|
|
344
|
-
if (max === self.rows) {
|
|
345
|
-
self.rows = val;
|
|
346
|
-
} else {
|
|
347
|
-
self.cols = val;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
return res;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
private used(row: number | undefined, col: number | undefined) {
|
|
354
|
-
const self = this;
|
|
355
|
-
return self.cellUsed[`c-${row}-${col}`] || false;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
private use(row: number | undefined, col: number | undefined) {
|
|
359
|
-
const self = this;
|
|
360
|
-
self.cellUsed[`c-${row}-${col}`] = true;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
private moveToNextCell() {
|
|
364
|
-
const self = this;
|
|
365
|
-
const cols = self.cols || 5;
|
|
366
|
-
self.col++;
|
|
367
|
-
if (self.col >= cols) {
|
|
368
|
-
self.col = 0;
|
|
369
|
-
self.row++;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
private getPos(node: INode) {
|
|
374
|
-
const self = this;
|
|
375
|
-
const { begin, cellWidth, cellHeight } = self;
|
|
376
|
-
let x: number;
|
|
377
|
-
let y: number;
|
|
378
|
-
|
|
379
|
-
// see if we have a manual position set
|
|
380
|
-
const rcPos = self.id2manPos[node.id];
|
|
381
|
-
if (rcPos) {
|
|
382
|
-
x = rcPos.col * cellWidth + cellWidth / 2 + begin[0];
|
|
383
|
-
y = rcPos.row * cellHeight + cellHeight / 2 + begin[1];
|
|
384
|
-
} else {
|
|
385
|
-
// otherwise set automatically
|
|
386
|
-
|
|
387
|
-
while (self.used(self.row, self.col)) {
|
|
388
|
-
self.moveToNextCell();
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
x = self.col * cellWidth + cellWidth / 2 + begin[0];
|
|
392
|
-
y = self.row * cellHeight + cellHeight / 2 + begin[1];
|
|
393
|
-
self.use(self.row, self.col);
|
|
394
|
-
|
|
395
|
-
self.moveToNextCell();
|
|
396
|
-
}
|
|
397
|
-
node.x = x;
|
|
398
|
-
node.y = y;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
public getType() {
|
|
402
|
-
return "grid";
|
|
403
|
-
}
|
|
404
|
-
}
|
package/src/layout/index.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { GridLayout } from "./grid";
|
|
2
|
-
import { RandomLayout } from "./random";
|
|
3
|
-
import { GForceLayout } from "./gForce";
|
|
4
|
-
import { Force2Layout } from "./force2";
|
|
5
|
-
import { ForceLayout } from "./force";
|
|
6
|
-
import { CircularLayout } from "./circular";
|
|
7
|
-
import { DagreLayout } from "./dagre";
|
|
8
|
-
import { DagreCompoundLayout } from "./dagreCompound";
|
|
9
|
-
import { RadialLayout } from "./radial";
|
|
10
|
-
import { ConcentricLayout } from "./concentric";
|
|
11
|
-
import { MDSLayout } from "./mds";
|
|
12
|
-
import { FruchtermanLayout } from "./fruchterman";
|
|
13
|
-
import { FruchtermanGPULayout } from "./gpu/fruchterman";
|
|
14
|
-
import { GForceGPULayout } from "./gpu/gForce";
|
|
15
|
-
import { ComboForceLayout } from "./comboForce";
|
|
16
|
-
import { ComboCombinedLayout } from "./comboCombined";
|
|
17
|
-
import { ForceAtlas2Layout } from "./forceAtlas2";
|
|
18
|
-
import { ERLayout } from './er';
|
|
19
|
-
|
|
20
|
-
import { Layout, Layouts } from "./layout";
|
|
21
|
-
|
|
22
|
-
export { Layout, Layouts };
|
|
23
|
-
|
|
24
|
-
// layout
|
|
25
|
-
export {
|
|
26
|
-
GridLayout,
|
|
27
|
-
RandomLayout,
|
|
28
|
-
GForceLayout,
|
|
29
|
-
Force2Layout,
|
|
30
|
-
ForceLayout,
|
|
31
|
-
CircularLayout,
|
|
32
|
-
DagreLayout,
|
|
33
|
-
DagreCompoundLayout,
|
|
34
|
-
RadialLayout,
|
|
35
|
-
ConcentricLayout,
|
|
36
|
-
MDSLayout,
|
|
37
|
-
FruchtermanLayout,
|
|
38
|
-
FruchtermanGPULayout,
|
|
39
|
-
GForceGPULayout,
|
|
40
|
-
ComboForceLayout,
|
|
41
|
-
ComboCombinedLayout,
|
|
42
|
-
ForceAtlas2Layout,
|
|
43
|
-
ERLayout
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// types file
|
|
47
|
-
export * from "./types";
|
package/src/layout/layout.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { Base } from "./base";
|
|
2
|
-
import { Model, ILayout, Node } from "./types";
|
|
3
|
-
import { getLayoutByName } from "../registy";
|
|
4
|
-
import { GridLayout } from "./grid";
|
|
5
|
-
import { RandomLayout } from "./random";
|
|
6
|
-
import { Force2Layout } from "./force2";
|
|
7
|
-
import { GForceLayout } from "./gForce";
|
|
8
|
-
import { ForceLayout } from "./force";
|
|
9
|
-
import { CircularLayout } from "./circular";
|
|
10
|
-
import { DagreLayout } from "./dagre";
|
|
11
|
-
import { RadialLayout } from "./radial";
|
|
12
|
-
import { ConcentricLayout } from "./concentric";
|
|
13
|
-
import { MDSLayout } from "./mds";
|
|
14
|
-
import { FruchtermanLayout } from "./fruchterman";
|
|
15
|
-
import { FruchtermanGPULayout } from "./gpu/fruchterman";
|
|
16
|
-
import { GForceGPULayout } from "./gpu/gForce";
|
|
17
|
-
import { ComboForceLayout } from "./comboForce";
|
|
18
|
-
import { ComboCombinedLayout } from "./comboCombined";
|
|
19
|
-
import { ForceAtlas2Layout } from "./forceAtlas2";
|
|
20
|
-
import { ERLayout } from "./er";
|
|
21
|
-
import { DagreCompoundLayout } from "./dagreCompound";
|
|
22
|
-
import { isString } from "../util";
|
|
23
|
-
|
|
24
|
-
interface DagreNodeData extends Node {
|
|
25
|
-
layer?: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export class Layout {
|
|
29
|
-
public readonly layoutInstance: Base;
|
|
30
|
-
|
|
31
|
-
constructor(options: ILayout.LayoutOptions) {
|
|
32
|
-
const layoutClass = getLayoutByName(options.type as string);
|
|
33
|
-
this.layoutInstance = new layoutClass(options);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
layout(data: Model) {
|
|
37
|
-
return this.layoutInstance.layout(data);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
updateCfg(cfg: ILayout.LayoutOptions) {
|
|
41
|
-
this.layoutInstance.updateCfg(cfg);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
init(data: Model) {
|
|
45
|
-
this.correctLayers(data.nodes);
|
|
46
|
-
this.layoutInstance.init(data);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* correcting the layers on the node data
|
|
51
|
-
* if min(layer) <= 0, layers should begin from abs(min(layer)) + 1
|
|
52
|
-
* @param nodes
|
|
53
|
-
* @returns
|
|
54
|
-
*/
|
|
55
|
-
correctLayers(nodes: DagreNodeData[] | undefined) {
|
|
56
|
-
if (!nodes?.length) return;
|
|
57
|
-
let minLayer = Infinity;
|
|
58
|
-
const hasLayerNodes: DagreNodeData[] = [];
|
|
59
|
-
nodes.forEach((node) => {
|
|
60
|
-
if (isString(node.layer)) {
|
|
61
|
-
node.layer = parseInt(node.layer, 10);
|
|
62
|
-
}
|
|
63
|
-
// keep node.layer === undefined for TS problem
|
|
64
|
-
if (node.layer === undefined || isNaN(node.layer)) return;
|
|
65
|
-
hasLayerNodes.push(node);
|
|
66
|
-
if (node.layer < minLayer) minLayer = node.layer;
|
|
67
|
-
});
|
|
68
|
-
if (minLayer <= 0) {
|
|
69
|
-
const layerOffset = Math.abs(minLayer) + 1;
|
|
70
|
-
// @ts-ignore
|
|
71
|
-
hasLayerNodes.forEach((node) => node.layer += layerOffset);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
execute() {
|
|
76
|
-
this.layoutInstance.execute();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
getDefaultCfg() {
|
|
80
|
-
return this.layoutInstance.getDefaultCfg();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
destroy() {
|
|
84
|
-
return this.layoutInstance.destroy();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// FIXME
|
|
89
|
-
// FOR G6
|
|
90
|
-
// tslint:disable-next-line
|
|
91
|
-
export const Layouts: { [key: string]: any } = {
|
|
92
|
-
force: ForceLayout,
|
|
93
|
-
fruchterman: FruchtermanLayout,
|
|
94
|
-
forceAtlas2: ForceAtlas2Layout,
|
|
95
|
-
gForce: GForceLayout,
|
|
96
|
-
force2: Force2Layout,
|
|
97
|
-
dagre: DagreLayout,
|
|
98
|
-
dagreCompound: DagreCompoundLayout,
|
|
99
|
-
circular: CircularLayout,
|
|
100
|
-
radial: RadialLayout,
|
|
101
|
-
concentric: ConcentricLayout,
|
|
102
|
-
grid: GridLayout,
|
|
103
|
-
mds: MDSLayout,
|
|
104
|
-
comboForce: ComboForceLayout,
|
|
105
|
-
comboCombined: ComboCombinedLayout,
|
|
106
|
-
random: RandomLayout,
|
|
107
|
-
'gForce-gpu': GForceGPULayout,
|
|
108
|
-
'fruchterman-gpu': FruchtermanGPULayout,
|
|
109
|
-
er: ERLayout,
|
|
110
|
-
};
|
package/src/layout/mds.ts
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileOverview MDS layout
|
|
3
|
-
* @author shiwu.wyy@antfin.com
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { Matrix as MLMatrix, SingularValueDecomposition } from "ml-matrix";
|
|
7
|
-
import { PointTuple, OutNode, Edge, Matrix, MDSLayoutOptions } from "./types";
|
|
8
|
-
import { floydWarshall, getAdjMatrix, scaleMatrix } from "../util";
|
|
9
|
-
import { Base } from "./base";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* mds 布局
|
|
13
|
-
*/
|
|
14
|
-
export class MDSLayout extends Base {
|
|
15
|
-
/** 布局中心 */
|
|
16
|
-
public center: PointTuple = [0, 0];
|
|
17
|
-
|
|
18
|
-
/** 边长度 */
|
|
19
|
-
public linkDistance: number = 50;
|
|
20
|
-
|
|
21
|
-
private scaledDistances: Matrix[];
|
|
22
|
-
|
|
23
|
-
public nodes: OutNode[] = [];
|
|
24
|
-
|
|
25
|
-
public edges: Edge[] = [];
|
|
26
|
-
|
|
27
|
-
/** 迭代结束的回调函数 */
|
|
28
|
-
public onLayoutEnd: () => void = () => {};
|
|
29
|
-
|
|
30
|
-
constructor(options?: MDSLayoutOptions) {
|
|
31
|
-
super();
|
|
32
|
-
this.updateCfg(options);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public getDefaultCfg() {
|
|
36
|
-
return {
|
|
37
|
-
center: [0, 0],
|
|
38
|
-
linkDistance: 50
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* 执行布局
|
|
44
|
-
*/
|
|
45
|
-
public execute() {
|
|
46
|
-
const self = this;
|
|
47
|
-
const { nodes, edges = [] } = self;
|
|
48
|
-
const center = self.center;
|
|
49
|
-
if (!nodes || nodes.length === 0) {
|
|
50
|
-
if (self.onLayoutEnd) self.onLayoutEnd();
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
if (nodes.length === 1) {
|
|
54
|
-
nodes[0].x = center[0];
|
|
55
|
-
nodes[0].y = center[1];
|
|
56
|
-
if (self.onLayoutEnd) self.onLayoutEnd();
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const linkDistance = self.linkDistance;
|
|
60
|
-
// the graph-theoretic distance (shortest path distance) matrix
|
|
61
|
-
const adjMatrix = getAdjMatrix({ nodes, edges }, false);
|
|
62
|
-
const distances = floydWarshall(adjMatrix);
|
|
63
|
-
self.handleInfinity(distances);
|
|
64
|
-
|
|
65
|
-
// scale the ideal edge length acoording to linkDistance
|
|
66
|
-
const scaledD = scaleMatrix(distances, linkDistance);
|
|
67
|
-
self.scaledDistances = scaledD;
|
|
68
|
-
|
|
69
|
-
// get positions by MDS
|
|
70
|
-
const positions = self.runMDS();
|
|
71
|
-
self.positions = positions;
|
|
72
|
-
positions.forEach((p: number[], i: number) => {
|
|
73
|
-
nodes[i].x = p[0] + center[0];
|
|
74
|
-
nodes[i].y = p[1] + center[1];
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
if (self.onLayoutEnd) self.onLayoutEnd();
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
nodes,
|
|
81
|
-
edges
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* mds 算法
|
|
87
|
-
* @return {array} positions 计算后的节点位置数组
|
|
88
|
-
*/
|
|
89
|
-
public runMDS(): PointTuple[] {
|
|
90
|
-
const self = this;
|
|
91
|
-
const dimension = 2;
|
|
92
|
-
const distances = self.scaledDistances;
|
|
93
|
-
|
|
94
|
-
// square distances
|
|
95
|
-
const M = MLMatrix.mul(MLMatrix.pow(distances, 2), -0.5);
|
|
96
|
-
|
|
97
|
-
// double centre the rows/columns
|
|
98
|
-
const rowMeans = M.mean("row");
|
|
99
|
-
const colMeans = M.mean("column");
|
|
100
|
-
const totalMean = M.mean();
|
|
101
|
-
M.add(totalMean)
|
|
102
|
-
.subRowVector(rowMeans)
|
|
103
|
-
.subColumnVector(colMeans);
|
|
104
|
-
|
|
105
|
-
// take the SVD of the double centred matrix, and return the
|
|
106
|
-
// points from it
|
|
107
|
-
const ret = new SingularValueDecomposition(M);
|
|
108
|
-
const eigenValues = MLMatrix.sqrt(ret.diagonalMatrix).diagonal();
|
|
109
|
-
return ret.leftSingularVectors.toJSON().map((row: number[]) => {
|
|
110
|
-
return MLMatrix.mul([row], [eigenValues])
|
|
111
|
-
.toJSON()[0]
|
|
112
|
-
.splice(0, dimension) as PointTuple;
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
public handleInfinity(distances: Matrix[]) {
|
|
117
|
-
let maxDistance = -999999;
|
|
118
|
-
distances.forEach((row) => {
|
|
119
|
-
row.forEach((value) => {
|
|
120
|
-
if (value === Infinity) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
if (maxDistance < value) {
|
|
124
|
-
maxDistance = value;
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
distances.forEach((row, i) => {
|
|
129
|
-
row.forEach((value, j) => {
|
|
130
|
-
if (value === Infinity) {
|
|
131
|
-
distances[i][j] = maxDistance;
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
public getType() {
|
|
138
|
-
return "mds";
|
|
139
|
-
}
|
|
140
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './radial';
|