7. Apply Constraints

So far we have seen how we can specify the positions of graphical objects using layout and encoding, one more method is to use graphical constraints.

Atlas currently supports two kinds of constraints: align and affix. The align constraint applies to an array of items, and moves the items so that their bounding boxes have the same value at a specified anchor. The figure below illustrates examples of an alignment constraint in the “y” direction with different anchor parameters.

Alignment Constraint

The affix constraint specifies the relative positioning between an item i and a base item along the “x” or “y” direction. When such a constraint is applied, the base item’s position remains unchanged, and item i’s position is changed to satisfy the constraint. The figure below illustrates examples of an affix constraint in the “x” direction with different anchor and offset parameters. If the item and the base item have peers that are generated using repeat, divide or densify, these peers will be taken care automatically.

Affix Constraint