StripLine.IntervalOffsetType Property

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

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

[BindableAttribute(true)]
[PersistenceModeAttribute(PersistenceMode.Attribute)]
public DateTimeIntervalType IntervalOffsetType { get; set; }

Property Value

Type: System.Web.UI.DataVisualization.Charting.DateTimeIntervalType
A DateTimeIntervalType enumeration value that indicates the interval type. The default value is Auto.

By default, this property is set to Auto; the actual value of this property is determined by the IntervalType property.

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

Supported in: 4.5.2, 4.5.1, 4.5, 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft