documentationfor yFiles for HTML 2.6

PartitionGridData

Specifies a PartitionGrid for a layout.

Inheritance Hierarchy
LayoutData
PartitionGridData

Remarks

The PartitionCellId mapping has to be specified by either setting the cellIds property, or either or both of the rowIndices and columnIndices properties. When cellIds is set, either the grid property has to be set as well or a LayoutExecutor with automatic table configuration has to be used. Otherwise when rowIndices and columnIndices are used, the size of the grid may be induced by the maximum returned row and column indices. The size is then used to extend the grid if necessary or create a new PartitionGrid if grid is not specified.

Note that cell spanning is only supported using the cellIds.

Default Values of Properties

Examples

The following sample shows how to assign nodes to partition grid cells simply via cell indices:

Assigning nodes to partition grid cells via indices
// Create four nodes and place them in grid cells in the following way
// +---+---+---+
// | 1 | 2 | 3 |
// +---+---+---+
//     | 4 |
//     +---+

const gridData = new PartitionGridData()

const node1 = graph.createNode()
const node2 = graph.createNode()
const node3 = graph.createNode()
const node4 = graph.createNode()

// Assign the nodes to their rows and columns.
// Note that don't have to create or use PartitionGrid directly in this case.
// Setting the indices is enough.
gridData.rowIndices.mapper.set(node1, 0)
gridData.rowIndices.mapper.set(node2, 0)
gridData.rowIndices.mapper.set(node3, 0)
gridData.rowIndices.mapper.set(node4, 1)
gridData.columnIndices.mapper.set(node1, 0)
gridData.columnIndices.mapper.set(node2, 1)
gridData.columnIndices.mapper.set(node3, 2)
gridData.columnIndices.mapper.set(node4, 1)

// Run a layout with the PartitionGridData. Note that the layout-specific
// LayoutData classes that support partition grids (e.g. HierarchicLayoutData)
// also contain a PartitionGridData that can be used directly.
graph.applyLayout(new HierarchicLayout(), gridData)

When used this way there is no need to create a PartitionGrid instance or work with it directly. For more flexibility, e.g. to use cells that span multiple columns or rows, the PartitionGrid can be used as well:

Assigning nodes to partition grid cells via factory methods on the grid
// Create three nodes and place them in grid cells in the following way
// +---+---+
// | 1 | 2 |
// +---+---+
// |   3   |
// +-------+

const node1 = graph.createNode()
const node2 = graph.createNode()
const node3 = graph.createNode()
const node4 = graph.createNode()

// Assign the nodes to their rows and columns.
// Note that don't have to create or use PartitionGrid directly in this case.
// Setting the indices is enough.
const rowIndicesMapper = new Mapper()
rowIndicesMapper.set(node1, 0)
rowIndicesMapper.set(node2, 0)
rowIndicesMapper.set(node3, 0)
rowIndicesMapper.set(node4, 1)
const columnIndicesMapper = new Mapper()
columnIndicesMapper.set(node1, 0)
columnIndicesMapper.set(node2, 1)
columnIndicesMapper.set(node3, 2)
columnIndicesMapper.set(node4, 1)

const gridData = new PartitionGridData({
  rowIndices: rowIndicesMapper,
  columnIndices: columnIndicesMapper
})

// Run a layout with the PartitionGridData. Note that the layout-specific
// LayoutData classes that support partition grids (e.g. HierarchicLayoutData)
// also contain a PartitionGridData that can be used directly.
graph.applyLayout(new HierarchicLayout(), gridData)// Create three nodes and place them in grid cells in the following way
// +---+---+
// | 1 | 2 |
// +---+---+
// |   3   |
// +-------+

const node1 = graph.createNode()
const node2 = graph.createNode()
const node3 = graph.createNode()
const node4 = graph.createNode()

// Assign the nodes to their rows and columns.
// Note that don't have to create or use PartitionGrid directly in this case.
// Setting the indices is enough.
const rowIndicesMapper = new Mapper<INode, number>()
rowIndicesMapper.set(node1, 0)
rowIndicesMapper.set(node2, 0)
rowIndicesMapper.set(node3, 0)
rowIndicesMapper.set(node4, 1)
const columnIndicesMapper = new Mapper<INode, number>()
columnIndicesMapper.set(node1, 0)
columnIndicesMapper.set(node2, 1)
columnIndicesMapper.set(node3, 2)
columnIndicesMapper.set(node4, 1)

const gridData = new PartitionGridData({
  rowIndices: rowIndicesMapper,
  columnIndices: columnIndicesMapper
})

// Run a layout with the PartitionGridData. Note that the layout-specific
// LayoutData classes that support partition grids (e.g. HierarchicLayoutData)
// also contain a PartitionGridData that can be used directly.
graph.applyLayout(new HierarchicLayout(), gridData)

Type Details

yfiles module
view-layout-bridge
yfiles-umd modules
view-layout-bridge
Legacy UMD name
yfiles.layout.PartitionGridData

See Also

Constructors

Properties

Methods