Xceed Chart for WinForms v4.4 Documentation
Axis Ruler

Welcome to Xceed Chart for WinForms v4.4 > User Guide > Axes > Axis Ruler

The axis ruler represents the visible part of the entire axis scale. The ruler of each axis is represented by an instance of the AxisRuler class, which is accessible through the Ruler property of the Axis object. The following code obtains the ruler of the PrimaryY axis:

VB.NET  

' there is one chart created by default

Dim chart As Chart = CType(chartControl1.Charts(0), Chart)

Dim ruler As AxisRuler =   chart.Axis(StandardAxis.PrimaryY).Ruler

C#  

// there is one chart created by default

Chart chart = (Chart)nChartControl1.Charts[0];

AxisRuler ruler = chart.Axis(StandardAxis.PrimaryY).Ruler;

Controlling the Start and the End of the Ruler

By default the ruler occupies the entire chart dimension of the respective axis orientation. For example, by default the size of the PrimaryY axis ruler is the entire chart height. It is often useful to control its start and end, for example, if you want to display two line trends on top of each other. The following figure demonstrates a typical horizontally split chart: 



figure 1. 

Programmatically, the start and end of the ruler are represented with percent values of the entire chart dimension, with the PositionStartPercent and PositionEndPercent properties of the AxisRuler class. By default the PositionStartPercent is set to 0 while the PositionEndPercent is set to 100. The following example creates a custom axis and displays it on top of the left axis:

VB.NET  

chart.Axis(StandardAxis.PrimaryY).Ruler.PositionStartPercent = 0

chart.Axis(StandardAxis.PrimaryY).Ruler.PositionEndPercent = 50

 

Dim customAxis As Axis =   chart.Axes.AddCustomAxis(AxisOrientation.Vertical,AxisPredefinedPostion.FrontLeft)

customAxis.Ruler.PositionStartPercent = 50

customAxis.Ruler.PositionEndPercent = 100

C#  

chart.Axis(StandardAxis.PrimaryY).Ruler.PositionStartPercent = 0;

chart.Axis(StandardAxis.PrimaryY).Ruler.PositionEndPercent = 50;

Axis customAxis = chart.Axes.AddCustomAxis(AxisOrientation.Vertical,

AxisPredefinedPostion.FrontLeft);

customAxis.Ruler.PositionStartPercent = 50;

customAxis.Ruler.PositionEndPercent = 100;

Inverting the Ruler

The values scaled on the axis ruler can be displayed in reverse order. The ruler can be inverted using the Inverted property of the AxisRuler object. By default it is set to false. The following code will invert the PrimaryY axis ruler.

VB.NET  
chart.Axis(StandardAxis.PrimaryY).Ruler.Inverted = True
C#  
chart.Axis(StandardAxis.PrimaryY).Ruler.Inverted = true;

Controlling the Paging of the Ruler

Axis rulers can be configured to work in paging mode. When operating in this mode, the axis shows only a fraction of the total axis scale or, in other words, one of the several axis pages. By default rulers do not use paging. 

To enable paging in your chart, you must first determine how you want to specify the ruler page size. You can do this in two ways: either specify the total number of pages that the ruler will possess regardless of the axis scale, or specify a fixed scale size for the axis page and let the page count vary depending on the total axis scale. These two different approaches are the FixedPageCount and FixedPageSize paging modes that are accepted by the PagingMode property of the AxisRuler object, which is of type RulerPagingMode

When the user sets the PagingMode property to FixedPageCount , the PageCount property can be modified, which determines the actual number of pages for the axis. The following example divides the PrimaryY axis into four pages:

VB.NET  

chart.Axis(StandardAxis.PrimaryY).Ruler.PagingMode = CurrentPageMode.FixedPageCount

chart.Axis(StandardAxis.PrimaryY).Ruler.PageCount = 4

C#  

chart.Axis(StandardAxis.PrimaryY).Ruler.PagingMode = CurrentPageMode.FixedPageCount;

chart.Axis(StandardAxis.PrimaryY).Ruler.PageCount = 4;

Analogously, when the PagingMode property is set to FixedPageSize, the user can control the page size using the PageSize property. The following code divides the left axis into 20-unit pages each:

VB.NET  

chart.Axis(StandardAxis.PrimaryY).Ruler.PagingMode = CurrentPageMode.FixedPageSize

chart.Axis(StandardAxis.PrimaryY).Ruler.PageSize = 20

C#  

chart.Axis(StandardAxis.PrimaryY).Ruler.PagingMode = CurrentPageMode.FixedPageSize;

chart.Axis(StandardAxis.PrimaryY).Ruler.PageSize = 20;

Now that the paging mode has been chosen the user must specify the currently shown page of the axis. This can be achieved in two ways: either specify the exact index of an axis page, or simply specify a beginning value. Programmatically, this behavior is controlled with the CurrentPageMode property, which is of type RulerCurrentPageMode. When it is set to Index, the user can modify the CurrentPageIndex property, which specifies the currently displayed page.

VB.NET  

' show the second page of the left axis

chart.Axis(StandardAxis.PrimaryY).Ruler.CurrentPageMode = CurrentPageMode.Index

chart.Axis(StandardAxis.PrimaryY).Ruler.CurrentPageIndex = 1

C#  

// show the second page of the left axis

chart.Axis(StandardAxis.PrimaryY).Ruler.CurrentPageMode = CurrentPageMode.Index;

chart.Axis(StandardAxis.PrimaryY).Ruler.CurrentPageIndex = 1;

When the CurrentPageMode property is set to BeginValue, the user can control the beginning value of the current page using the CurrentPageBeginValue property of the AxisRuler object.

VB.NET  

' show a page beginning from value 3.5

chart.Axis(StandardAxis.PrimaryY).Ruler.CurrentPageMode = CurrentPageMode.Value

chart.Axis(StandardAxis.PrimaryY).Ruler.CurrentPageValue = 3.5

C#  

// show a page beginning from value 3.5

chart.Axis(StandardAxis.PrimaryY).Ruler.CurrentPageMode = CurrentPageMode.Value;

chart.Axis(StandardAxis.PrimaryY).Ruler.CurrentPageValue = 3.5;

Related Examples

Windows Forms: Axes\Ruler\Ruler Size;  Axes\Ruler\Paging

See Also

Axis | AxisRuler