StripLine Clase

Definición

Representa las franjas en un gráfico.

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
Herencia
StripLine
Implementaciones

Ejemplos

En el ejemplo de código siguiente se muestran tres aplicaciones de líneas de franja. En primer lugar, las líneas horizontales se agregan a intervalos periódicos. En segundo lugar, se agregan líneas verticales para resaltar los puntos de datos de fin de semana. Por último, se agrega una línea de franja no periódica para indicar la media de los puntos de datos de la primera serie del gráfico.

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);  
        }  
    }  

Comentarios

Las franjas o franjas son intervalos horizontales o verticales que sombrea el fondo de un gráfico en intervalos regulares o personalizados. Puede usar las franjas para:

  • Mejorar la legibilidad y facilitar la búsqueda de valores individuales en el gráfico.

  • Separe los puntos de datos al leer el gráfico.

  • Resalte las fechas que se producen a intervalos regulares, por ejemplo, para identificar los puntos de datos de fin de semana.

  • Resalte un intervalo clave específico de datos.

  • Agregue una línea de umbral en un valor constante específico.

Un solo StripLine objeto se puede dibujar una vez o repetidamente para un intervalo determinado. Esta acción se controla mediante la Interval propiedad . Cuando se asigna un valor de -1 a la Interval propiedad , se dibujará una línea de franja. Cuando se asigna un valor distinto de cero a la Interval propiedad, una línea de franja se dibujará repetidamente en cada intervalo determinado. La ubicación donde se dibuja una línea de franja también se ve afectada por las IntervalOffset propiedades y IntervalOffsetType de la línea de franja.

Las líneas de franja siempre están asociadas a un Axis objeto . Se pueden agregar en tiempo de diseño y en tiempo de ejecución.

Para agregar una línea horizontal o vertical para mostrar un umbral, establezca la StripWidth propiedad en un valor de 0,0. Esto dará lugar a que se dibuje una línea. Puede usar las BorderColorpropiedades , BorderDashStyle y BorderWidth para el color, el ancho y el estilo de la línea. No se usan propiedades de fondo del gráfico (Back*) cuando la StripWidth propiedad está establecida en 0,0.

Utilice la Text propiedad de la línea de franja para asociar texto a una línea de franja. La propiedad puede controlar la ubicación y la TextAlignment orientación de este texto.

Cuando se definen varias líneas de franja para el mismo eje, es posible que las líneas de franja se superpongan. El orden Z de StripLine los objetos viene determinado por su orden de aparición en el StripLinesCollection objeto . Esto significa que la primera aparición se dibuja primero; la segunda repetición se dibuja en segundo lugar, etc.

Las líneas de tira no son compatibles con los siguientes tipos de gráfico: Pie, Doughnut, Embudo, Pirámide, Kagi, ThreeLineBreak, PointAndFigure, Polar y Radar.

Constructores

StripLine()

Inicializa una nueva instancia de la clase StripLine.

Propiedades

BackColor

Obtiene o establece el color de fondo de la franja.

BackGradientStyle

Obtiene o establece el estilo de degradado de la franja.

BackHatchStyle

Obtiene o establece el estilo de sombreado de la franja.

BackImage

Obtiene o establece la imagen de fondo de la franja.

BackImageAlignment

Obtiene o establece la alineación de la imagen de fondo.

BackImageTransparentColor

Obtiene o establece el color de una imagen de fondo de la franja que se implementará como transparente.

BackImageWrapMode

Obtiene o establece el modo de dibujo de la imagen de fondo de la franja.

BackSecondaryColor

Obtiene o establece el color secundario del fondo de la franja.

BorderColor

Obtiene o establece el color del borde de una franja.

BorderDashStyle

Obtiene o establece el estilo del borde de la franja.

BorderWidth

Obtiene o establece el ancho del borde de la franja.

Font

Obtiene o establece la fuente usada para el texto de la franja.

ForeColor

Obtiene o establece el color del texto de la franja.

Interval

Obtiene o establece el intervalo para una franja y determina si la franja se dibuja una vez o de forma repetida.

IntervalOffset

Obtiene o establece el desplazamiento de líneas de cuadrícula, marcas de paso, franjas y etiquetas de eje.

IntervalOffsetType

Obtiene o establece el tipo de desplazamiento del intervalo de la franja.

IntervalType

Obtiene o establece el tipo de intervalo de un objeto StripLine.

MapAreaAttributes

Obtiene o establece los atributos del área de mapa de la franja.

Name

Obtiene el nombre de la franja.

PostBackValue

Obtiene o establece el valor de postback que se puede procesar en un evento Click.

StripWidth

Obtiene o establece el ancho de una franja.

StripWidthType

Obtiene o establece la unidad de medida para la propiedad StripWidth.

Tag

Obtiene o establece un objeto asociado a este elemento de gráfico.

(Heredado de ChartElement)
Text

Obtiene o establece el texto para la franja.

TextAlignment

Obtiene o establece la alineación del texto de la franja.

TextLineAlignment

Obtiene o establece la alineación de la línea del texto de la franja.

TextOrientation

Obtiene o establece la orientación del texto.

ToolTip

Obtiene o establece la información sobre herramientas de una franja.

Url

Obtiene o establece la dirección URL de destino o el punto de anclaje de la franja.

Métodos

Dispose()

Libera los recursos que usa ChartElement.

(Heredado de ChartElement)
Dispose(Boolean)

Libera los recursos no administrados que usa StripLine y, de forma opcional, libera los recursos administrados.

Equals(Object)

Determina si el objeto Object especificado es igual al objeto ChartElement actual.

(Heredado de ChartElement)
GetHashCode()

Devuelve una función hash para un tipo concreto.

(Heredado de ChartElement)
GetType()

Obtiene el Type de la instancia actual.

(Heredado de Object)
MemberwiseClone()

Crea una copia superficial del Object actual.

(Heredado de Object)
ToString()

Devuelve una cadena que representa el objeto Object actual.

(Heredado de ChartElement)

Se aplica a