StripLine.IntervalOffset Property

.NET Framework (current version)
 

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

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

<BindableAttribute(True)>
<PersistenceModeAttribute(PersistenceMode.Attribute)>
Public Property IntervalOffset As Double

Property Value

Type: System.Double

A double value that represents the interval offset.

The interval offset of minor tick marks and grid lines is never affected by the value of the IntervalOffset property of the Axis object.

The IntervalOffset property setting defines the units of measurement of the offset.

The Interval can be a negative value.

The default value is Auto (0).

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.

Imports System.Web.UI.DataVisualization.Charting

Public Partial Class StripLines 
    Inherits System.Web.UI.Page 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        ' Add chart data before adding strip lines. 
        AddChartData() 

        ' Adds repeating horizontal strip lines. 
        AddHorizRepeatingStripLines() 

        ' Highlights weekend points using strip lines. 
        HighlightWeekendsWithStripLines() 

        ' Adds a threshold line using strip lines. 
        AddThresholdStripLine() 
    End Sub 

    ''' <summary> 
    ''' Adds a week of data with values between 20 and 35. 
    ''' </summary> 
    Private Sub AddChartData() 
        ' Declare new random variable 
        Dim rand As New Random() 
        For i As Integer = 0 To 6 

            ' Add a week of data 
            chart1.Series(0).Points.AddXY(DateTime.Now.AddDays(i), rand.[Next](20, 35)) 
        Next 
    End Sub 

    ''' <summary> 
    ''' Adds repeating horizontal strip lines at intervals of 5. 
    ''' </summary> 
    Private Sub AddHorizRepeatingStripLines() 
        ' Instantiate new strip line 
        Dim stripLine1 As New StripLine() 
        stripLine1.StripWidth = 2.5 
        stripLine1.Interval = 5 

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

        ' Add the strip line to the chart 
        chart1.ChartAreas(0).AxisY.StripLines.Add(stripLine1) 
    End Sub 

    ''' <summary> 
    ''' Adds strip lines to highlight weekend values. 
    ''' </summary> 
    Private Sub HighlightWeekendsWithStripLines() 
        ' Set strip line to highlight weekends 
        Dim stripLine2 As 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" 
    End Sub 

    ''' <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 Sub AddThresholdStripLine() 
        Dim stripLine3 As 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) 
    End Sub 
End Class

.NET Framework
Available since 4.0
Return to top
Show: