In This Topic
Grid lines appear on the chart and gauge plot area as lines with controllable color and pattern. There are two types of grid lines – those that are considered major and are by default synchronized with the values of the major scale ticks and those that are considered minor are by default synchronized with the scale minor ticks. Note that there are types of scales that do not support minor ticks - these include ordinal, price, hierarchic and timeline scales.
In standard scales (the ones derived from NStandardScale) gridline appearance is controlled from the MajorGridLines and MinorGridLines properties, both exposing an object of type NScaleGridLines. The following sections discuss the properties of this object.
Visibility
The visibility of the grid is controlled from the Visible property of the NScaleGridLines object. The following code snippet shows how to make the major grid visible:
C# |
Copy Code
|
scale.MajorGridLines.Visible = true;
|
Appearance
The appearance of the grid lines is controlled from the Stroke property of the NScaleGridLines object. The following code changes the appearance of the grid lines:
C# |
Copy Code
|
scale.MajorGridLines.Visible = true;
scale.MajorGridLines.Stroke.Color = NColor.Red;
scale.MajorGridLines.Stroke.Width = 2;
|
Decoration Range
The NScaleGridLines class has a property called DecorationRange, which allows you to specify how the values at which the grid lines appear will be generated. It accepts classes derived from the base NDecorationRange class. The following table lists the classes that inherit from it:
Decoration Range |
Description |
NMajorTickDecorationRange |
This class provides grid line ranges synchronized with the major tick values of the scale. This range is applied on the major grid by default. |
NMinorTickDecorationRange |
This class provides grid line ranges synchronized with the minor tick values of the scale. This range is applied on the minor grid by default. |
NNumericDecorationRange |
Provides custom specified numeric ranges. |
NDateTimeDecorationRange |
Provides custom specified data time ranges. |
The following code shows how to configure the major grid lines on a scale to show at each 5 logical units visible on the scale:
C# |
Copy Code
|
NNumericDecorationRange numericDecorationRange = new NNumericDecorationRange();
numericDecorationRange.SamplingMode = ENSamplingMode.CustomStep;
numericDecorationRange.CustomStep = 5;
scale.MajorGridLines.DecorationRange = numericDecorationRange;
|