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?β
privateoptionalforceProps:SimulationProps
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:59
linksβ
privatelinks:SimulationLinkDatum\<any>[]
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:64
pathsβ
privatepaths:IConnectionLayerPath[]
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:61
pathsMapβ
privatepathsMap:Record\<string,IConnectionLayerPath[]>
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:62
pointsβ
privatepoints:any[]
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:63
propsβ
privateprops:object
connectionsβ
connections:
IConnectionLayerConnection[]
nodesβ
nodes:
any[]
segmentLength?β
optionalsegmentLength:number
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:53
segmentLengthβ
privatesegmentLength:number
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:60
Methodsβ
createDefaultForceProps()β
protectedcreateDefaultForceProps():SimulationProps
It returns the default D3 force simulation props.
Returnsβ
SimulationProps
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:260
createIdPath()β
protectedcreateIdPath(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()β
protectedcreateLinks():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()β
protectedcreatePath(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()β
protectedcreatePaths():IConnectionLayerPath[]
It creates paths (split connections into segments).
Returnsβ
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:135
createPathsMap()β
protectedcreatePathsMap():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()β
protectedcreatePoints():any[]
It prepares the points for D3 force layout simulator.
Returnsβ
any[]
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:289
getDefaultSegmentLength()β
protectedgetDefaultSegmentLength():number
It returns default size of the segment
Returnsβ
number
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:79
getForceProps()β
protectedgetForceProps():SimulationProps
It returns the D3 force simulation props.
Returnsβ
SimulationProps
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:250
getLinks()β
protectedgetLinks():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()β
protectedgetPoints():any[]
It returns the nodes for D3 force layout simulator.
Returnsβ
any[]
Sourceβ
tools/layers/connection/model/internal/util/D3PathForceSimulator.ts:279
getSimulation()β
protectedgetSimulation():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