Nevron .NET Vision Documentation
Major and Minor Ticks

Ticks are usually represented as lines and can appear on both sides of the scale ruler. The scale configurators define two types of ticks – major and minor, where only the NNumericScaleConfigurator (linear and log scales) and NDateTimeScaleConfigurator actually produce minor ticks.

In general major ticks are used to mark important values on the scale and are usually accompanied by a label that displays their value. Minor ticks on the other hand mark less significant values and are usually displayed between the major ticks. By default minor ticks are disabled. This topic will discuss the options provided for tick customization by the NStandardScaleConfigurator derived classes only, as more specific configurators expose ticks styles under different names.

Controlling the Tick Appearance

The NStandardScaleConfigurator has four properties of type NScaleTickStyle that define the appearance of the various ticks that appear on the scale. Following is a description of the meaning of each property:

  • InnerMajorTickStyle - Controls the appearance of major ticks that appear on the inner side of the scale (usually inside the plot area)
  • OuterMajorTickStyle - Controls the appearance of major ticks that appear on the outer side of the scale (usually outside the plot area)
  • InnerMinorTickStyle - Controls the appearance of minor ticks that appear on the inner side of the scale (usually inside the plot area)
  • OuterMinorTickStyle - Controls the appearance of minor ticks that appear on the outer side of the scale (usually outside the plot area)
Note: Major and minor tick appearance may be altered if the tick falls inside a scale section. Scale sections are described in the Scale Sections topic.

The following code will alter the color and length of the major outer ticks:

C#
Copy Code
NChart chart = chartControl.Charts[0];
NAxis primaryY = chart.Axis(StandardAxis.PrimaryY);
NStandardScaleConfigurator scaleConfigurator = (NStandardScaleConfigurator)primaryY.ScaleConfigurator;
scaleConfigurator.OuterMinorTickStyle.LineStyle.Color = Color.Red;
scaleConfigurator.OuterMinorTickStyle.Length = new NLength(6, NGraphicsUnit.Pixel);
Visual Basic
Copy Code
Dim chart As NChart = chartControl.Charts(0)
Dim primaryY As NAxis = chart.Axis(StandardAxis.PrimaryY)
Dim scaleConfigurator As NStandardScaleConfigurator = CType(primaryY.ScaleConfigurator, NStandardScaleConfigurator)
scaleConfigurator.OuterMinorTickStyle.LineStyle.Color = Color.Red
scaleConfigurator.OuterMinorTickStyle.Length = New NLength(6, NGraphicsUnit.Pixel)
Controlling the Major Tick Generation

Major tick generation is controlled through the MajorTickMode property of the NStandardScaleConfigurator accepting values from the MajorTickMode enumeration. The following table shows the possible values you can set to this property:

Value Description
AutoMinDistance The scale will automatically calculate the step depending on the setting of the MinTickDistance property and will not allow ticks to be closer than the specified distance. In this mode the number of scale ticks will increase as the scale is bigger on the screen or printer and decrease when the scale is smaller respectively. This is the default setting.
AutoMaxCount The scale will automatically generate steps depending on the setting of the MaxTickCount property. In this mode the number of ticks will be restricted to the maximum allowed number of ticks. The scale will automatically select a "nice" step given the range of the data. The number of ticks will be constant when the scale is resized.
CustomTicks In this mode you can explicitly specify the values which must be represented with major ticks. You add custom ticks to the scale via the CustomTicks property.
CustomStep In this mode you can explicitly specify a custom step which must be used in the major tick generation. The step is specified with the CustomStep property.
CustomSteps In this mode you can explicitly specify an array of steps that must be used for major tick generation. The steps are specified from the CustomSteps property.

The MinTickDistance and MaxTickCount properties are defined in the NStandardScaleConfigurator and all configurators that inherit from it can access them. The following code will increase the default spacing between ticks on the screen:

C#
Copy Code
NChart chart = chartControl.Charts[0];
NAxis primaryX = chart.Axis(StandardAxis.PrimaryY);
NStandardScaleConfigurator scaleConfigurator = (NStandardScaleConfigurator)primaryX.ScaleConfigurator;

scaleConfigurator.MajorTickMode = MajorTickMode.AutoMinDistance;
scaleConfigurator.MinTickDistance = new NLength(50);
Visual Basic
Copy Code
Dim chart As NChart = chartControl.Charts(0)
Dim primaryY As NAxis = chart.Axis(StandardAxis.PrimaryY)
Dim scaleConfigurator As NStandardScaleConfigurator = CType(primaryY.ScaleConfigurator, NStandardScaleConfigurator)

scaleConfigurator.MajorTickMode = MajorTickMode.AutoMinDistance
scaleConfigurator.MinTickDistance = New NLength(50)

Similarly, if you want the scale to generate a fixed amount of ticks, then you can switch the scale to MajorTickMode.AutoMaxCount and specify the max tick count that is allowed:

C#
Copy Code
NChart chart = chartControl.Charts[0];
NAxis primaryX = chart.Axis(StandardAxis.PrimaryY);
NStandardScaleConfigurator scaleConfigurator = (NStandardScaleConfigurator)primaryX.ScaleConfigurator;

scaleConfigurator.MajorTickMode = MajorTickMode.AutoMaxCount;
scaleConfigurator.MaxTickCount = 20;
Visual Basic
Copy Code
Dim chart As NChart = chartControl.Charts(0)
Dim primaryY As NAxis = chart.Axis(StandardAxis.PrimaryY)
Dim scaleConfigurator As NStandardScaleConfigurator = CType(primaryY.ScaleConfigurator, NStandardScaleConfigurator)

scaleConfigurator.MajorTickMode = MajorTickMode.AutoMaxCount
scaleConfigurator.MaxTickCount = 20

The rest of the major tick modes imply that you have to provide some information to the axis in terms of actual ticks or step to be used when generating the ticks. Because the step or steps can vary in type the CustomStep, CustomSteps and CustomTicks properties are defined in the scale configurator that uses them.

The following table shows the type of values accepted by these properties, depending on the type of the scale configurator:

Scale Configurator Accepted values
NNumericScaleConfigurator

CustomStep accepts values of positive double values.

CustomSteps accepts an array of positive double values.

CustomTicks accepts an array of arbitrary double values.

NDateTimeScaleConfigurator

CustomStep accepts a NDateTimeSpan value.

Custom Step accepts an array of NDateTimeSpan values.

CustomTicks accepts an array of DateTime values.

NOrdinalScaleConfigurator

CustomStep accepts a positive integer value.

CustomSteps accepts an array of positive integer values.

CustomTicks accepts an array of arbitrary integer values.

Minor Ticks
Minor ticks are usually displayed between the major ticks and are not accompanied with a label, because the values they represent are not considered important.
Automatic Minor Ticks

By default the minor ticks are synchronized with the major ticks and separate the range between two major ticks on equal intervals. The number of minor ticks between two major ticks is specified by the MinorTickCount property of the NStandardScale configurator. The following code will set this property to 4 resulting in four minor ticks between each two major ticks:

C#
Copy Code
NChart chart = chartControl.Charts[0];
NAxis primaryX = chart.Axis(StandardAxis.PrimaryY);
NStandardScaleConfigurator scaleConfigurator = (NStandardScaleConfigurator)primaryX.ScaleConfigurator;
scaleConfigurator.MinorTickCount = 4;
Visual Basic
Copy Code
Dim chart As NChart = chartControl.Charts(0)
Dim primaryY As NAxis = chart.Axis(StandardAxis.PrimaryY)
Dim scaleConfigurator As NStandardScaleConfigurator = CType(primaryY.ScaleConfigurator, NStandardScaleConfigurator)
scaleConfigurator.MinorTickCount = 4
Custom Minor Ticks

In order to display custom minor ticks you need to set the AutoMinorTicks property to false and manually specify the tick values. The following example shows how to achieve that:

C#
Copy Code
NChart chart = chartControl.Charts[0];
NAxis primaryY = chart.Axis(StandardAxis.PrimaryY);
NLinearScaleConfigurator scaleConfigurator = (NLinearScaleConfigurator)primaryY.ScaleConfigurator;
scaleConfigurator.AutoMinorTicks = false;
scaleConfigurator.CustomMinorTicks.Add(15);
scaleConfigurator.CustomMinorTicks.Add(30);
scaleConfigurator.CustomMinorTicks.Add(45);
Visual Basic
Copy Code
Dim chart As NChart = chartControl.Charts(0)
Dim primaryY As NAxis = chart.Axis(StandardAxis.PrimaryY)
Dim scaleConfigurator As NLinearScaleConfigurator = CType(primaryY.ScaleConfigurator, NLinearScaleConfigurator)
scaleConfigurator.AutoMinorTicks = False
scaleConfigurator.CustomMinorTicks.Add(15)
scaleConfigurator.CustomMinorTicks.Add(30)
scaleConfigurator.CustomMinorTicks.Add(45)
Related Examples
Windows Forms: Axes \ General \ Ticks
See Also

 

 


©2017. Nevron Software LLC.

Send Feedback