7. Apply Constraints

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

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

Alignment Constraint

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

Affix Constraint