In This Topic
Stripes allow you to highlight a range of values. The following image shows a 3D point chart with two stripes attached to the X and Y axes:
Creating a new Axis Stripe
You create an axis stripe by creating an instance of the NAxisStripe class. The following code adds a stripe to the Y axis:
C# |
Copy Code
|
NCartesianChart chart = (NCartesianChart)NChartControl1.Charts[0];
NAxis axis = (NAxis)chart.Axis(StandardAxis.PrimaryY);
NAxisStripe axisStripe = new NAxisStripe();
axis.Stripes.Add(axisStripe);
|
Visual Basic |
Copy Code
|
Dim chart As NCartesianChart = CType(NChartControl1.Charts(0), NCartesianChart)
Dim axis As NAxis = CType(chart.Axis(StandardAxis.PrimaryY), NCartesianAxis)
Dim axisStripe As New NAxisStripe
axis.Stripes.Add(axisStripe)
|
Controlling the stripe range
You can control the range of the axis stripe with the help of the From and To properties of the NAxisStripe object. The following code changes the From an To values of the previously created stripe:
C# |
Copy Code
|
axisStripe.From = 20;
axisStripe.To = 40;
|
Visual Basic |
Copy Code
|
axisStripe.From = 20
axisStripe.To = 40
|
You can also instruct the stripe to include the value in the range of the axis the const line is attached to. This is done with the IncludeFromValueInAxisRange and IncludeTwoValueInAxisRange properties:
C# |
Copy Code
|
stripe.IncludeFromValueInAxisRange = true;
stripe.IncludeToValueInAxisRange = true; |
Visual Basic |
Copy Code
|
stripe.IncludeFromValueInAxisRange = True stripe.IncludeToValueInAxisRange = True
|
Controlling the stripe appearance
In order to change the filling of the stripe you need to touch the FillStyle property of the NAxisStripe object. The following example will change the stripe filling to Green:
C# |
Copy Code
|
axisStripe.FillStyle = new NColorFillStyle(Color.Green);
|
Visual Basic |
Copy Code
|
axisStripe.FillStyle = New NColorFillStyle(Color.Green)
|
Displaying the stripe on the chart walls
The SetShowAtWall method helps you display the axis stripe at the adjacent chart walls. The vertical axis stripes accept only the four vertical chart walls. The horizontal axis stripes accepts only the chart floor and the front and back walls. The Depth axis accepts the chart floor and the left and right walls. The following code shows the stripe on the back and right walls.
C# |
Copy Code
|
axisStripe.SetShowAtWall(ChartWallType.Back, true);
axisStripe.SetShowAtWall(ChartWallType.Right, true);
|
Visual Basic |
Copy Code
|
axisStripe.SetShowAtWall(ChartWallType.Back, True)
axisStripe.SetShowAtWall(ChartWallType.Right, True)
|
Stripe Text
Each stripe can contain text that denotes the stripe meaning. The following code snippet applies text to a stripe with top left alignment and offset:
C# |
Copy Code
|
NAxisStripe yAxisStripe = new NAxisStripe();
yAxisStripe.From = 10;
yAxisStripe.To = 20;
yAxisStripe.TextOffset = new NPointL(2, 2);
yAxisStripe.TextAlignment = ContentAlignment.TopLeft;
yAxisStripe.Text = "This is an axis stripe";
yAxisStripe.SetShowAtWall(ChartWallType.Back, true);
chart.Axis(StandardAxis.PrimaryY).Stripes.Add(yAxisStripe);
|
Visual Basic |
Copy Code
|
Dim yAxisStripe As New NAxisStripe()
yAxisStripe.From = 10
yAxisStripe.To = 20
yAxisStripe.TextOffset = New NPointL(2, 2)
yAxisStripe.TextAlignment = ContentAlignment.TopLeft
yAxisStripe.Text = "This is an axis stripe" yAxisStripe.SetShowAtWall(ChartWallType.Back, True)
chart.Axis(StandardAxis.PrimaryY).Stripes.Add(yAxisStripe)
|
Including in the Axis Range
By default the axis stripe From / To values are not included in the calculation of the axis range the stripe is attached to. In case you need to make sure that
the From / To values of the stripe are included in the axis range you can use the IncludeFromValueInAxisRange and IncludeToValueInAxisRange properties:
C# |
Copy Code
|
stripe.IncludeFromValueInAxisRange = true;
stripe.IncludeToValueInAxisRange = true; |
Visual Basic |
Copy Code
|
stripe.IncludeFromValueInAxisRange = True
stripe.IncludeToValueInAxisRange = True |
Related Examples
Windows forms: Axes \ Attributes \ Stripes
See Also