Layout

4 min read

The property layout of component <Graphin/> is used to set the layout of Graphin.

  PropertyTypeRequiredDescription
namestringyesname of the layout
optionsLayoutOptionsnocustom configuration of layout

LayoutOptions

Different layout is with different configuration. If layout.name is a custom layout, LayoutOptions also includes the configuration of the custom layout.

CircleOptions

configuration of circle layout

  PropertyTypeDefaultDescription
xnumberCanvasWidth / 2x Coordinates of the Center node
ynumberCanvasHeight / 2y Coordinates of the Center node
rnumberNumber of nodes * 10Radius of the circle
scalenumber0.8Scaling ratio

ConcentricOptions

configuration of concentric layout

  PropertyTypeDefaultDescription
boundingBox{ x1: number; y1:number; w:number; y:number; }{x:0,y:0,w:CanvasWidth,h:CanvasHeight}Range of the layout
minNodeSpacingnumber60Distance between nodes
levelWidth(nodes: Data['nodes'], maxDegree: number) => numberbelowrange of degree in each layer

LevelWidth Default:

const LevelWidth = (nodes: Data['nodes'], maxDegree: number) => {
  /** Number of layers */
  const levelNum = 8;
  return maxDegree / levelNum;
};

GridLOptions

configuration of grid layout

  PropertyTypeDefaultDescription
widthnumberCanvasWidthWidth of the layout
heightnumberCanvasHeightHeight of the layout
nodeSepnumber100Distance between nodes
nodeSizenumber50Size of a node

RadialOptions

configuration of radial layout

  PropertyTypeDefaultDescription
center[number,number][CanvasWidth/2,CanvasHeight/2]Coordinate of the center node
preventOverlapbooleantrueprevent coverage
nodeSizenumber100Size of a node
unitRadiusnumber150Radius of each layer

DagreOptions

configuration of dagre layout

  PropertyTypeDefaultDescription
center[number,number][CanvasWidth / 2, CanvasHeight / 2]coordinate of the center node
nodeSizenumberCanvasHeightsize of a node
nodesepnumber12horizontal distance between nodes
ranksepnumber50vertical distance between nodes
alignstringULposition, see G6 Document for details

ForceOptions

configuration of force layout

  PropertyTypeDefaultDescription
presetLayout{ name: 'random',options:{}}Front layout that is used for switching layout mainly. tweak layout algorithm will be used when the current layout is force
stiffnessnumber200Spring stiffness factor
defSpringLenfunction(edge: Edge, source: Point, target: Point) => number;The default spring length, version 1.1.0 changed to function, can set the initial length for each edge
repulsionnumber200.0 * 5Repulsive force, here refers to the Coulomb constant Ke
dampingnumber0.9Damping coefficient
minEnergyThresholdnumber0.1Minimum energy threshold
maxSpeednumber1000Maximum speed, range interval [0,1000]
MaxIterationsnumber10000001000000 times/(1000/60) = 60000 s = 1 min
animationboleantrueWhether to turn on animation
enableWorkerboleanfalseWhether to start webworker, when big data node rendering, we recommend that you open, can not block UI rendering

Small details of the force layout:

  • edge.data.spring can be used to set the spring length of edge
  • node.layout.force.mass can be used to set the quality of the node