StripLine 類別

定義

表示圖表的帶狀線。

public ref class StripLine : System::Web::UI::DataVisualization::Charting::ChartElement, System::Web::UI::DataVisualization::Charting::IChartMapArea
public class StripLine : System.Web.UI.DataVisualization.Charting.ChartElement, System.Web.UI.DataVisualization.Charting.IChartMapArea
type StripLine = class
    inherit ChartElement
    interface IChartMapArea
Public Class StripLine
Inherits ChartElement
Implements IChartMapArea
繼承
StripLine
實作

範例

下列程式碼範例示範三個等量線的應用程式。 首先,水準帶狀線會以週期性間隔新增。 其次,會新增垂直帶狀線來醒目提示週末資料點。 最後,加入非週期性帶狀線,表示圖表第一個數列中資料點的平均數。

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   

    ' Adds a week of data with values between 20 and 35.   
    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   

    ' Adds repeating horizontal strip lines at intervals of 5.   
    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   

    ' Adds strip lines to highlight weekend values.   
    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   

    ' Adds a horizontal threshold strip line at the mean value of the first series.  
    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  
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);  
        }  
    }  

備註

帶狀線或帶狀線是水準或垂直範圍,以一般或自訂間隔來著色圖表的背景。 您可以使用區域線:

  • 改善可讀性以在圖表上尋找個別值。

  • 讀取圖表時,請分隔資料點。

  • 例如,醒目提示定期發生的日期,以識別週末資料點。

  • 醒目提示特定索引鍵範圍的資料。

  • 在特定常數值上新增臨界值行。

StripLine 一物件可以針對指定的間隔繪製一次或重複繪製一次。 這個動作是由 Interval 屬性所控制。 將 -1 的值指派給 Interval 屬性時,將會繪製一條帶狀線。 將非零值指派給 Interval 屬性時,將會在每個指定的間隔重複繪製帶狀線。 繪製帶狀線的位置也會受到 IntervalOffset 等量線的 和 IntervalOffsetType 屬性影響。

等量線一律與 物件相關聯 Axis 。 您可以在設計階段和執行時間新增它們。

若要新增水準或垂直線以顯示臨界值,請將 StripWidth 屬性設定為 0.0 的值。 這會導致繪製線條。 您可以針對線條的色彩、寬度和樣式使用 BorderColorBorderDashStyleBorderWidth 屬性。 當 屬性設定為 0.0 時 StripWidthBack* 不會使用圖表背景屬性 () 。

Text使用帶狀線的 屬性,將文字與帶狀線產生關聯。 這個文字的位置和方向可由 屬性控制 TextAlignment

當為相同的軸定義多個帶狀線時,帶狀線可能會重迭。 物件的 Z 順序 StripLine 取決於物件中的 StripLinesCollection 出現順序。 這表示第一次繪製第一個專案;第二個出現次數是繪製第二個,依此類傳。

下列圖表類型不支援帶狀線:圓形圖、環圈圖、漏斗圖、金字塔圖、Kagi、ThreeLineBreak、PointAndFigure、Polar 和 Radar。

建構函式

StripLine()

初始化 StripLine 類別的新執行個體。

屬性

BackColor

取得或設定帶狀線的背景色彩。

BackGradientStyle

取得或設定帶狀線的漸層樣式。

BackHatchStyle

取得或設定帶狀線的影線樣式。

BackImage

取得或設定帶狀線的背景影像。

BackImageAlignment

取得或設定背景影像的對齊方式。

BackImageTransparentColor

取得或設定會以透明繪製之帶狀線背景影像的色彩。

BackImageWrapMode

取得或設定帶狀線背景影像的繪製模式。

BackSecondaryColor

取得或設定帶狀線背景的次要色彩。

BorderColor

取得或設定帶狀線的框線色彩。

BorderDashStyle

取得或設定帶狀線的框線樣式。

BorderWidth

取得或設定帶狀線的框線寬度。

Font

取得或設定用於帶狀線文字的字型。

ForeColor

取得或設定帶狀線文字的色彩。

Interval

取得或設定帶狀線的間隔,並且決定帶狀線只要繪製一次還是重複地繪製。

IntervalOffset

取得或設定格線、刻度標記、帶狀線與座標軸標籤的位移。

IntervalOffsetType

取得或設定帶狀線的間隔位移類型。

IntervalType

取得或設定 StripLine 物件的間隔類型。

MapAreaAttributes

取得或設定帶狀線的對應區域屬性。

Name

取得帶狀線的名稱。

PostBackValue

取得或設定可在 Click 事件上處理的回傳值。

StripWidth

取得或設定帶狀線的寬度。

StripWidthType

取得或設定 StripWidth 屬性的測量單位。

Tag

取得或設定與這個圖表項目關聯的物件。

(繼承來源 ChartElement)
Text

取得或設定帶狀線的文字。

TextAlignment

取得或設定帶狀線文字的對齊方式。

TextLineAlignment

取得或設定帶狀線文字的文字行對齊方式。

TextOrientation

取得或設定文字方向。

ToolTip

取得或設定帶狀線的工具提示。

Url

取得或設定帶狀線的目的 URL 或錨點。

方法

Dispose()

釋放 ChartElement 使用的資源。

(繼承來源 ChartElement)
Dispose(Boolean)

釋放 StripLine 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

Equals(Object)

判斷指定的 Object 是否等於目前的 ChartElement

(繼承來源 ChartElement)
GetHashCode()

傳回特定型別的雜湊函式。

(繼承來源 ChartElement)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回表示目前 Object 的字串。

(繼承來源 ChartElement)

適用於