Node Margins
A node margin specifies additional padding around a node. A layout algorithm that supports margins keeps this area clear of graph elements, except for the labels of this specific node and the incident segments of its edges.
Almost all layout, edge routing, and labeling algorithms provide support for node margins.
They are defined through Layout Data properties called NodeMargin
.
for example, margins for the organic layout are defined via property nodeMargins.
// specify a margin with extra space on the left side
const leftMargin = new Insets(0, 0, 0, 100)
// and another with extra space on the right side
const rightMargin = new Insets(100, 0, 0, 0)
// use LayoutData to define the margins
const layout = new OrganicLayout()
const layoutData = layout.createLayoutData()
layoutData.nodeMargins.mapperFunction = (node) =>
node.tag === 'blue'
? rightMargin
: node.tag === 'green'
? leftMargin
: null
// and apply the layout with additional margins
graph.applyLayout(layout, layoutData)

