Stripes are one of the most useful objects when it comes to highlighting information in the chart area. They allow you to highlight a range of values associated with any of the axes by drawing a stripe on a user-specified chart wall. The image on figure 1 shows a typical example of the use of axis stripes.
figure 1.
Creating a New Stripe
Each axis has a collection of AxisStripe objects accessible with the Stripes property of the Axis object. The Add method of the AxisStripeCollection object has two arguments--the stripe begin and end values--and returns a reference to the newly created axis stripe. By default, axis stripes of the vertical and horizontal axes are displayed on the back wall, while stripes of the Depth axis are displayed on the chart floor. The following code adds one stripe and saves the returned reference for later use:
VB.NET | |
---|---|
Dim stripe As AxisStripe = Chart.Axis(StandardAxis.PrimaryY).Stripes.Add(10,20) |
C# | |
---|---|
AxisStripe stripe = Chart.Axis(StandardAxis.PrimaryY).Stripes.Add(10, 20); |
Controlling the Stripe Range
The user can control the range of the axis stripe with the From and To properties of the AxisStripe class. The following code changes the From and To values of the stripe created above:
VB.NET | |
---|---|
|
C# | |
---|---|
stripe.From = 20; |
The range of the axis stripe is automatically connected to the portion of the axis scale displayed by the ruler.
Controlling the Stripe's Appearance
The user can access the FillEffect object controlling the appearance of the stripe through the FillEffect property of the AxisStripe object. The following example will display the created stripe in green:
VB.NET | |
---|---|
stripe.FillEffect.SetSolidColor(Color.Green) |
C# | |
---|---|
stripe.FillEffect.SetSolidColor(Color.Green); |
Displaying the Stripe on the Chart Walls
The SetShowAtWall method displays the axis stripe on the adjacent chart walls. Vertical axis stripes accept only the four vertical chart walls. Horizontal axis stripes accept 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:
VB.NET | |
---|---|
|
C# | |
---|---|
stripe.SetShowAtWall(ChartWallType.Back, true); |
Related Examples
Windows Forms: Axes\Attributes\Stripes