D3PathForceSimulator
geovisto-map / D3PathForceSimulator
Class: D3PathForceSimulator
This class represents the force layout simulator powered by the d3-force library. It takes the nodes and connections and prepares the list paths which can be bent by the D3 force simulation.
A former idea to split the lines into line segments and use the D3 force simulation can be found in the prototype writen by S. Engle (https://gist.github.com/ericfischer/dafc36a3d212da4619dde2d392553c7a) demonstarting forceβdirected edge bundling for graph visualization (by Danny Holten and Jarke J. van Wijk). Further ideas were found in the D3 docs and examples.
Our approach implements a very simple segmentation of the connections which works with the constant maximal length of segments. This causes that short connections won't be segmented, which improves the performance of the simulation. The preferred maximal length of the line segments can be adjusted using props.
Authorβ
Jiri Hynek
Constructorsβ
new D3PathForceSimulator()β
new D3PathForceSimulator(
props
):D3PathForceSimulator
It initializes the object by setting the props.
Parametersβ
β’ props
β’ props.connections: IConnectionLayerConnection
[]
β’ props.nodes: any
[]
β’ props.segmentLength: undefined
| number
Returnsβ
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:69
Propertiesβ
forceProps?β
private
optional
forceProps:SimulationProps
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:59
linksβ
private
links:SimulationLinkDatum
\<any
>[]
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:64
pathsβ
private
paths:IConnectionLayerPath
[]
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:61
pathsMapβ
private
pathsMap:Record
\<string
,IConnectionLayerPath
[]>
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:62
pointsβ
private
points:any
[]
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:63
propsβ
private
props:object
connectionsβ
connections:
IConnectionLayerConnection
[]
nodesβ
nodes:
any
[]
segmentLength?β
optional
segmentLength:number
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:53
segmentLengthβ
private
segmentLength:number
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:60
Methodsβ
createDefaultForceProps()β
protected
createDefaultForceProps():SimulationProps
It returns the default D3 force simulation props.
Returnsβ
SimulationProps
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:260
createIdPath()β
protected
createIdPath(connection
):object
Help function which cretes a struture composed of id of connection and path.
This function is used for animated rendering of paths.
Parametersβ
β’ connection: IConnectionLayerConnection
Returnsβ
object
idβ
id:
string
pathβ
path:
IConnectionLayerPath
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:154
createLinks()β
protected
createLinks():SimulationLinkDatum
\<any
>[]
It creates the links for D3 force layout simulator.
Returnsβ
SimulationLinkDatum
\<any
>[]
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:330
createPath()β
protected
createPath(connection
):IConnectionLayerPath
Help function which takes a connection and split the connection into segments. The number of segments is based on the preferred maximal length of segment.
Parametersβ
β’ connection: IConnectionLayerConnection
Returnsβ
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:167
createPaths()β
protected
createPaths():IConnectionLayerPath
[]
It creates paths (split connections into segments).
Returnsβ
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:135
createPathsMap()β
protected
createPathsMap():Record
\<string
,IConnectionLayerPath
[]>
It creates a structure composed of records (id of connection, list of paths).
id of connections is a string value "from-to".
This function is used for animated rendering of paths.
Returnsβ
Record
\<string
, IConnectionLayerPath
[]>
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:120
createPoints()β
protected
createPoints():any
[]
It prepares the points for D3 force layout simulator.
Returnsβ
any
[]
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:289
getDefaultSegmentLength()β
protected
getDefaultSegmentLength():number
It returns default size of the segment
Returnsβ
number
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:79
getForceProps()β
protected
getForceProps():SimulationProps
It returns the D3 force simulation props.
Returnsβ
SimulationProps
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:250
getLinks()β
protected
getLinks():SimulationLinkDatum
\<any
>[]
It returns the links for D3 force layout simulator.
Returnsβ
SimulationLinkDatum
\<any
>[]
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:320
getPaths()β
getPaths():
IConnectionLayerPath
[]
It returns the paths.
Returnsβ
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:106
getPathsMap()β
getPathsMap():
Record
\<string
,IConnectionLayerPath
[]>
It returns a structure composed of records (id of connection, list of paths).
id of connections is a string value "from-to".
This function is used for animated rendering of paths.
Returnsβ
Record
\<string
, IConnectionLayerPath
[]>
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:90
getPoints()β
protected
getPoints():any
[]
It returns the nodes for D3 force layout simulator.
Returnsβ
any
[]
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:279
getSimulation()β
protected
getSimulation():Simulation
\<any
,undefined
>
It returns the definition of D3 force simulation.
Returnsβ
Simulation
\<any
, undefined
>
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:228
run()β
run(
onTickAction
,onEndAction
):void
It creates creates and runs the D3 force layout simulation.
Parametersβ
β’ onTickAction
β’ onEndAction
Returnsβ
void
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:215