StripLine Class
TOC
Collapse the table of content
Expand the table of content

StripLine Class

.NET Framework (current version)
 

Represents the strip lines on a chart.

Namespace:   System.Web.UI.DataVisualization.Charting
Assembly:  System.Web.DataVisualization (in System.Web.DataVisualization.dll)

System.Object
  System.Web.UI.DataVisualization.Charting.ChartElement
    System.Web.UI.DataVisualization.Charting.StripLine

public class StripLine : ChartElement, IChartMapArea

NameDescription
System_CAPS_pubmethodStripLine()

Initializes a new instance of the StripLine class.

NameDescription
System_CAPS_pubpropertyBackColor

Gets or sets the background color of the strip line.

System_CAPS_pubpropertyBackGradientStyle

Gets or sets the gradient style of the strip line.

System_CAPS_pubpropertyBackHatchStyle

Gets or sets the hatching style of the strip line.

System_CAPS_pubpropertyBackImage

Gets or sets the background image of the strip line.

System_CAPS_pubpropertyBackImageAlignment

Gets or sets the background image alignment.

System_CAPS_pubpropertyBackImageTransparentColor

Gets or sets the color of a strip line background image that will be implemented as transparent.

System_CAPS_pubpropertyBackImageWrapMode

Gets or sets the drawing mode of the background image of the strip line.

System_CAPS_pubpropertyBackSecondaryColor

Gets or sets the secondary color of the strip line background.

System_CAPS_pubpropertyBorderColor

Gets or sets the border color of a strip line.

System_CAPS_pubpropertyBorderDashStyle

Gets or sets the border style of the strip line.

System_CAPS_pubpropertyBorderWidth

Gets or sets the border width of the strip line.

System_CAPS_pubpropertyFont

Gets or sets the font used for the strip line text.

System_CAPS_pubpropertyForeColor

Gets or sets the color of the strip line text.

System_CAPS_pubpropertyInterval

Gets or sets the interval for a strip line, and determines if the strip line is drawn once or repeatedly.

System_CAPS_pubpropertyIntervalOffset

Gets or sets the offset of grid lines, tick marks, strip lines and axis labels.

System_CAPS_pubpropertyIntervalOffsetType

Gets or sets the interval offset type of the strip line.

System_CAPS_pubpropertyIntervalType

Gets or sets the interval type of a StripLine object.

System_CAPS_pubpropertyMapAreaAttributes

Gets or sets the map area attributes of the strip line.

System_CAPS_pubpropertyName

Gets the name of the strip line.

System_CAPS_pubpropertyPostBackValue

Gets or sets the postback value that can be processed on a Click event.

System_CAPS_pubpropertyStripWidth

Gets or sets the width of a strip line.

System_CAPS_pubpropertyStripWidthType

Gets or sets the unit of measurement for the StripWidth property.

System_CAPS_pubpropertyTag

Gets or sets an object associated with this chart element.(Inherited from ChartElement.)

System_CAPS_pubpropertyText

Gets or sets the text for the strip line.

System_CAPS_pubpropertyTextAlignment

Gets or sets the text alignment of the strip line.

System_CAPS_pubpropertyTextLineAlignment

Gets or sets the text line alignment of strip line text.

System_CAPS_pubpropertyTextOrientation

Gets or sets the text orientation.

System_CAPS_pubpropertyToolTip

Gets or sets the tooltip of a strip line.

System_CAPS_pubpropertyUrl

Gets or sets the destination URL or anchor point of the strip line.

NameDescription
System_CAPS_pubmethodDispose()

Releases the resources used by the ChartElement.(Inherited from ChartElement.)

System_CAPS_protmethodDispose(Boolean)

Releases the unmanaged resources used by the StripLine and optionally releases the managed resources.(Overrides ChartElement.Dispose(Boolean).)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified Object is equal to the current ChartElement.(Inherited from ChartElement.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Returns a hash function for a particular type.(Inherited from ChartElement.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current Object.(Inherited from ChartElement.)

Strip lines, or strips, are horizontal or vertical ranges that shade the background of a chart in regular or custom intervals. You can use strip lines to:

  • Improve readability for looking up individual values on the chart.

  • Separate data points when reading the chart.

  • Highlight dates that occur at regular intervals, for example, to identify weekend data points.

  • Highlight a specific key range of data.

  • Add a threshold line at a specific constant value.

A single StripLine object can either be drawn once, or repeatedly, for a given interval. This action is controlled by the Interval property. When a value of -1 is assigned to the Interval property, one strip line will be drawn. When a non-zero value is assigned to the Interval property, a strip line will be drawn repeatedly at each given interval. The location where a strip line is drawn is also affected by the IntervalOffset and IntervalOffsetType properties of the strip line.

Strip lines are always associated with an Axis object. They can be added at both design time and run time.

To add a horizontal or vertical line to display a threshold, set the StripWidth property to a value of 0.0. This will result in a line being drawn. You can use the BorderColor, BorderDashStyle and BorderWidth properties for the color, width and style of the line. No chart background properties (Back*) are used when the StripWidth property is set to 0.0.

Use the Text property of the strip line to associate text with a strip line. The placement and orientation of this text can be controlled by the TextAlignment property.

When multiple strip lines are defined for the same axis, it is possible that the strip lines will overlap. The Z-order of StripLine objects is determined by their order of occurrence in the StripLinesCollection object. This means that the first occurrence is drawn first; the second occurrence is drawn second, and so on.

Strip lines are not supported for the following chart types: Pie, Doughnut, Funnel, Pyramid, Kagi, ThreeLineBreak, PointAndFigure, Polar and Radar.

The following code example demonstrates three applications of strip lines. First, horizontal strip lines are added at recurring intervals. Second, vertical strip lines are added to highlight weekend data points. Lastly, a non-recurring strip line is added to denote the mean of the data points in the first series of the chart.

public partial class StripLines : System.Web.UI.Page 
    {
        protected void Page_Load(object sender, EventArgs e)
        {            
            // Add chart data
            AddChartData();

            // Adds repeating horizontal strip lines.
            AddHorizRepeatingStripLines();

            // Highlights weekend points using strip lines.
            HighlightWeekendsWithStripLines();

            // Adds a threshold line using strip lines.
            AddThresholdStripLine();
        }

        /// <summary>
        /// Adds a week of data with values between 20 and 35.
        /// </summary>
        private void AddChartData()
        {
            // Declare new random variable
            Random rand = new Random();

            // Add a week of data
            for (int i = 0; i < 7; i++) 
            {
                chart1.Series[0].Points.AddXY(DateTime.Now.AddDays(i), rand.Next(20,35));
            }
        }

        /// <summary>
        /// Adds repeating horizontal strip lines at intervals of 5.
        /// </summary>
        private void AddHorizRepeatingStripLines()
        {
            // Instantiate new strip line
            StripLine stripLine1 = new StripLine();
            stripLine1.StripWidth = 0;
            stripLine1.BorderColor = Color.Black;
            stripLine1.BorderWidth = 3;
            stripLine1.Interval = 5;

            // Consider adding transparency so that the strip lines are lighter
            stripLine1.BackColor = Color.FromArgb(120, Color.Red);

            stripLine1.BackSecondaryColor = Color.Black;
            stripLine1.BackGradientStyle = GradientStyle.LeftRight;

            // Add the strip line to the chart
            chart1.ChartAreas[0].AxisY.StripLines.Add(stripLine1);
        }

        /// <summary>
        /// Adds strip lines to highlight weekend values.
        /// </summary>
        private void HighlightWeekendsWithStripLines()
        {
            // Set strip line to highlight weekends
            StripLine stripLine2 = new StripLine();
            stripLine2.BackColor = Color.FromArgb(120, Color.Gold);            
            stripLine2.IntervalOffset = -1.5;
            stripLine2.IntervalOffsetType = DateTimeIntervalType.Days;
            stripLine2.Interval = 1;
            stripLine2.IntervalType = DateTimeIntervalType.Weeks;
            stripLine2.StripWidth = 2;
            stripLine2.StripWidthType = DateTimeIntervalType.Days;

            // Add strip line to the chart
            chart1.ChartAreas[0].AxisX.StripLines.Add(stripLine2);

            // Set the axis label to show the name of the day
            // This is done in order to demonstrate that weekends are highlighted
            chart1.ChartAreas[0].AxisX.LabelStyle.Format = "ddd";
        }

        /// <summary>
        /// Adds a horizontal threshold strip line at the calculated mean 
        /// value of all data points in the first series of the chart.
        /// </summary>
        private void AddThresholdStripLine()
        {
            StripLine stripLine3 = new StripLine();

            // Set threshold line so that it is only shown once
            stripLine3.Interval = 0;

            // Set the threshold line to be drawn at the calculated mean of the first series
            stripLine3.IntervalOffset = chart1.DataManipulator.Statistics.Mean(chart1.Series[0].Name);

            stripLine3.BackColor = Color.DarkGreen;
            stripLine3.StripWidth = 0.25;

            // Set text properties for the threshold line
            stripLine3.Text = "Mean";
            stripLine3.ForeColor = Color.Black;

            // Add strip line to the chart
            chart1.ChartAreas[0].AxisY.StripLines.Add(stripLine3);
        }
    }

.NET Framework
Available since 4.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft