Nodes in the chart can be positioned either using layouts, or using coordinates. The right positioning of items in the chart helps to detangle the data and visualize how items are connected.
Layouts transform connected data into networks that highlight connections, patterns and outliers which would be difficult to spot in the raw data. You can run a layout by passing an object with the layout name to the layout prop, which applies to any nodes with no specified coordinates. ReGraph uses the organic layout by default. See also the Layouts documentation for details.
Alternatively, you can pass an object with custom node coordinates to the positions prop, which will move nodes into the specified positions. See also the Custom Layouts documentation for details.
When using organic layout, the two ways can be combined - passing coordinates into positions prop fixes these nodes in the chart even when organic layout is run.
There are two types of x and y coordinates:
- World coordinates represent absolute positions within the chart, where 0, 0 is the center of the chart. They correspond exactly to the positions of a node. When integrating with Leaflet, world coordinates are represented as
lngandlat. - View coordinates represent pixel positions relative to the viewport, where 0, 0 is the top-left corner of the view. Positions of events such as
onClickare reported in view coordinates. View coordinates change whenever the user pans the view.
You can convert between the two options using the viewCoordinates and worldCoordinates instance methods.
ReGraph Example
