What controls the layout and spacing on a chart - ZedGraph/ZedGraph GitHub Wiki

NOTE: This page contains information that is specific to ZedGraph version 5.0

The layout of the chart depends heavily on the content, and also on the [scale factor logic](How does the font and chart element scaling logic work). This page gives an overview of the properties that you would use to control the layout.

We can start with a MasterPane layout, which is the basis for the chart used in the ZedGraphControl:

Layout_sample_masterpane_markup.png

See the MasterPane Layout Options page for details on MasterPane layout options. In this diagram, the outer black border represents the pane rect (PaneBase.Rect). The red rectangle containing all of the individual graphs is the client area of the GraphPane, calculated by PaneBase.CalcClientRect(). Each of the margin values is a property of the Margin object, which is contained in the PaneBase class. Since PaneBase is the parent class of both GraphPane and MasterPane, each individual GraphPane also has its own margins similar to the ones shown here. The Title.Gap property is also part of the PaneBase class. The value of Title.Gap is expressed as a fraction of the scaled Title character height. The MasterPane.InnerPaneGap property is specific to the MasterPane class, and controls the spacing between the individual GraphPanes. This property is expressed in Points (1/72nd inch).

Zooming in to the bottom-right chart, we can see the layout properties of a single GraphPane.

Layout_sample_graphPane_markup.png

Margin properties are similar to the Masterpane class, since they are both inherited from PaneBase. The GraphPane.Title.Gap property is expressed as a fraction of the scaled character height of the title. The Legend.Gap is the gap between the legend and the Chart.Rect expressed as fraction of the largest scaled character height used in the legend (each legend entry can optionally use a separate FontSpec class). Note that even though there is no Y2 axis in this case, the right margin is taken from the X axis text so the text does not infringe on the margin.

Further zooming in to an individual scale element, we can look at that spacing:

Layout_scale_markup.png

This shows the individual tic sizes, expressed in Points (1/72nd inch). Also shown are the Axis.Title.Gap and the Axis.Scale.LabelGap properties, both expressed as a fraction of their respective character heights.