Strip lines like grid lines appear on the chart walls and are primarily used to display repeating ranges. You add a strip line style to the scale by adding and instance of the NScaleStripStyle class to the StripStyles collection of the NScaleConfigurator. The StripStyles collection can contain an unlimited number of NScaleStripStyle objects.
The order in which you add objects to this collection will also define the Z order of the produced stripes – strip lines representing the first strip styles in the collection will be drawn first, strip lines representing the second strip style will be drawn second and so on.
Each strip style object has two properties called Length and Interval which are specified as positive integer values. The length of the stripe specifies how many ranges it will fill and the interval specifies how many ranges it will skip. For example consider you have a scale with major ticks in the range of [0, 100], with a step of 20 - this will produce the following set of ranges to be filled by the stripe:
[0, 20], [20, 40], [40, 60], [60, 80], [80, 100]
Now if the stripe has Length 1 and Interval 2 it will be displayed at the following ranges:
[0, 20], [60, 80]
Note that the ranges [20, 40], [40, 60] and [80, 100] will be skipped.
View Range Order and Scale Range Order
Each range displayed by the scale will have two types of order – view and scale order.
To understand the difference consider the following sequence of ranges:
[0, 20], [20, 40], [40, 60], [60, 80], [80, 100]
and suppose that the scale actually shows values in the range [20, 80] (this can happen if you use zooming and scrolling for example). The View Order of the range [20, 40] is 0 while it’s Scale Order is 1. Therefore if you have a strip style with length 1 and interval one and it’s aligned to the View order of the range it will display at the following ranges:
[20, 40], [60, 80]
Similarly if the strip style is aligned to the scale order it will display at [40, 60].
Interlaced Strips
By default strip styles are synchronized with the major ticks of the scale. In order to display interlaced strips (strips that appear between each other major ticks) you need to write the following code:
C# |
Copy Code
|
NChart chart = nChartControl1.Charts[0];
NAxis primaryY = chart.Axis(StandardAxis.PrimaryY);
NScaleStripStyle stripStyle = new NScaleStripStyle();
stripStyle.SetShowAtWall(ChartWallType.Back, true);
stripStyle.Interlaced = true;
primaryY.ScaleConfigurator.StripStyles.Add(stripStyle);
|
Visual Basic |
Copy Code
|
Dim chart As NChart = NChartControl1.Charts(0)
Dim primaryY As NAxis = chart.Axis(StandardAxis.PrimaryY)
Dim stripStyle As New NScaleStripStyle
stripStyle.SetShowAtWall(ChartWallType.Back, True)
stripStyle.Interlaced = True
primaryY.ScaleConfigurator.StripStyles.Add(stripStyle)
|
As you may guess the Interlaced property of the strip tells it to synchronize the strip to the view order of the major tick ranges so that the strip will start to appear after the first tick on the scale.
Range Strips
Each strip style has an associated range sampler provider that allows you to control the ranges at which it will appear. The following code will display strip lines at each 5 logical units:
C# |
Copy Code
|
NChart chart = chartControl.Charts[0];
NAxis primaryY = chart.Axis(StandardAxis.PrimaryY);
NStandardScaleConfigurator scaleConfigurator = (NStandardScaleConfigurator)primaryY.ScaleConfigurator;
NNumericRangeSamplerProvider rangeSamplerProvider = new NNumericRangeSamplerProvider();
rangeSamplerProvider.SamplingMode = SamplingMode.CustomStep;
rangeSamplerProvider.CustomStep = 5;
NScaleStripStyle stripStyle = new NScaleStripStyle();
stripStyle.SetShowAtWall(ChartWallType.Back, true);
stripStyle.RangeSamplerProvider = rangeSamplerProvider;
scaleConfigurator.StripStyles.Add(stripStyle);
|
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)
Dim rangeSamplerProvider As New NNumericRangeSamplerProvider
rangeSamplerProvider.SamplingMode = SamplingMode.CustomStep
rangeSamplerProvider.CustomStep = 5
Dim stripStyle As New NScaleStripStyle
stripStyle.SetShowAtWall(ChartWallType.Back, True)
stripStyle.RangeSamplerProvider = rangeSamplerProvider
scaleConfigurator.StripStyles.Add(stripStyle)
|
Modifying the Strip Appearance
The strip appearance is controlled from the FillStyle and BorderStyle properties of the NScaleStripStyle.
Related Examples
Windows Forms: Axes \ General \ Strip Lines