Diagram Layout

OmniGraffle excels at clarifying complex relationships by providing specialized tools for creating dynamic hierarchical diagrams.

Layout Properties

The Layout class contains the graphic layout information for a canvas. It is the value of the layoutInfo property of the Canvas class. Here are the settable properties:

 

HierarchicalDirection Properties

The HierarchicalDirection properties are the value for the direction property of the Layout class:

 

LayoutType Properties

The LayoutType properties are the value for the type property of the Layout class:

 

Layout Command

The layout() function performs automatic layout of all graphics on this canvas.

TIP: To have a script wait for any actions and redrawing triggered by by the layout() command to complete, use it with a Timer function to delay a specified number of seconds before continuing the script:

var cnvs = document.windows[0].selection.canvas cnvs.layout() Timer.once(5,function(timer){ // perform actions here })

Hierarchical

The hierarchical layout creates layers of equally-ranked objects, extending in one direction.

Hierarchical layout settings
cnvs = document.windows[0].selection.canvas cnvs.layoutInfo.automaticLayout = false // hierarchical (top to bottom) cnvs.layoutInfo.type = LayoutType.Hierarchical cnvs.layoutInfo.direction = HierarchicalDirection.Top cnvs.layoutInfo.rankSeparation = 0.5 cnvs.layoutInfo.objectSeparation = 0.25 cnvs.layout()
omnigraffle:///omnijs-run?script=cnvs%20%3D%20document%2Ewindows%5B0%5D%2Eselection%2Ecanvas%0Acnvs%2ElayoutInfo%2EautomaticLayout%20%3D%20false%0A%2F%2F%20hierarchical%20%28top%20to%20bottom%29%0Acnvs%2ElayoutInfo%2Etype%20%3D%20LayoutType%2EHierarchical%0Acnvs%2ElayoutInfo%2Edirection%20%3D%20HierarchicalDirection%2ETop%0Acnvs%2ElayoutInfo%2ErankSeparation%20%3D%200%2E5%0Acnvs%2ElayoutInfo%2EobjectSeparation%20%3D%200%2E25%0Acnvs%2Elayout%28%29
cnvs = document.windows[0].selection.canvas cnvs.layoutInfo.automaticLayout = false // hierarchical (top to bottom) cnvs.layoutInfo.type = LayoutType.Hierarchical cnvs.layoutInfo.direction = HierarchicalDirection.Bottom cnvs.layoutInfo.rankSeparation = 0.5 cnvs.layoutInfo.objectSeparation = 0.25 cnvs.layout()
omnigraffle:///omnijs-run?script=cnvs%20%3D%20document%2Ewindows%5B0%5D%2Eselection%2Ecanvas%0Acnvs%2ElayoutInfo%2EautomaticLayout%20%3D%20false%0A%2F%2F%20hierarchical%20%28top%20to%20bottom%29%0Acnvs%2ElayoutInfo%2Etype%20%3D%20LayoutType%2EHierarchical%0Acnvs%2ElayoutInfo%2Edirection%20%3D%20HierarchicalDirection%2EBottom%0Acnvs%2ElayoutInfo%2ErankSeparation%20%3D%200%2E5%0Acnvs%2ElayoutInfo%2EobjectSeparation%20%3D%200%2E25%0Acnvs%2Elayout%28%29
hierarchical

Force-Directed

The force-directed layout grows in semi-random directions from the center, rather than in one particular direction from the edge. The top slider determines the length of the connecting lines between objects, and the bottom slider determines how far apart the objects appear in the diagram.

Force-Directed layout settings
cnvs = document.windows[0].selection.canvas cnvs.layoutInfo.automaticLayout = false // force-directed cnvs.layoutInfo.type = LayoutType.ForceDirected cnvs.layoutInfo.forceDirectedLineLength = 2.0 cnvs.layoutInfo.forceDirectedSeparation = 0.75 cnvs.layout()
omnigraffle:///omnijs-run?script=cnvs%20%3D%20document%2Ewindows%5B0%5D%2Eselection%2Ecanvas%0Acnvs%2ElayoutInfo%2EautomaticLayout%20%3D%20false%0A%2F%2F%20force-directed%0Acnvs%2ElayoutInfo%2Etype%20%3D%20LayoutType%2EForceDirected%0Acnvs%2ElayoutInfo%2EforceDirectedLineLength%20%3D%202%2E0%0Acnvs%2ElayoutInfo%2EforceDirectedSeparation%20%3D%200%2E75%0Acnvs%2Elayout%28%29
force-directed

Circular

The circular layout tries to arrange sibling shapes in a circle around their parent.

cnvs = document.windows[0].selection.canvas cnvs.layoutInfo.automaticLayout = false // circular cnvs.layoutInfo.type = LayoutType.Circular cnvs.layoutInfo.circularLineLength = 72 cnvs.layout()
omnigraffle:///omnijs-run?script=cnvs%20%3D%20document%2Ewindows%5B0%5D%2Eselection%2Ecanvas%0Acnvs%2ElayoutInfo%2EautomaticLayout%20%3D%20false%0A%2F%2F%20circular%0Acnvs%2ElayoutInfo%2Etype%20%3D%20LayoutType%2ECircular%0Acnvs%2ElayoutInfo%2EcircularLineLength%20%3D%2072%0Acnvs%2Elayout%28%29
Circular layout settings circular

Radial

The radial layout tries to arrange sibling shapes in arcs around their parent.

Radial layout settings
cnvs = document.windows[0].selection.canvas cnvs.layoutInfo.automaticLayout = false // radial cnvs.layoutInfo.type = LayoutType.Radial cnvs.layoutInfo.radialSeparation = 170 cnvs.layout()
omnigraffle:///omnijs-run?script=cnvs%20%3D%20document%2Ewindows%5B0%5D%2Eselection%2Ecanvas%0Acnvs%2ElayoutInfo%2EautomaticLayout%20%3D%20false%0A%2F%2F%20radial%0Acnvs%2ElayoutInfo%2Etype%20%3D%20LayoutType%2ERadial%0Acnvs%2ElayoutInfo%2EradialSeparation%20%3D%20170%0Acnvs%2Elayout%28%29
radial

Fit Content in View

Here's a script for zooming and centering the diagram in the window view:

var cnvs = document.windows[0].selection.canvas var g = cnvs.graphics var gr = new Group(g) var rect = gr.geometry gr.ungroup() document.windows[0].selection.view.visibleRect = rect document.windows[0].centerVisiblePoint = rect.center
omnigraffle:///omnijs-run?script=var%20cnvs%20%3D%20document%2Ewindows%5B0%5D%2Eselection%2Ecanvas%0Avar%20g%20%3D%20cnvs%2Egraphics%0Avar%20gr%20%3D%20new%20Group%28g%29%0Avar%20rect%20%3D%20%20gr%2Egeometry%0Agr%2Eungroup%28%29%0Adocument%2Ewindows%5B0%5D%2Eselection%2Eview%2EvisibleRect%20%3D%20rect%0Adocument%2Ewindows%5B0%5D%2EcenterVisiblePoint%20%3D%20rect%2Ecenter
UNDER CONSTRUCTION

This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.

DISCLAIMER