Back to Devexpress

ConstantLineTitle Class

corelibraries-devexpress-dot-xtracharts-be3b14e7.md

latest5.5 KB
Original Source

ConstantLineTitle Class

Defines settings for a constant line title.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
public class ConstantLineTitle :
    Title,
    ITextPropertiesProvider,
    IHitTest,
    ISupportTextAntialiasing
vb
Public Class ConstantLineTitle
    Inherits Title
    Implements ITextPropertiesProvider,
               IHitTest,
               ISupportTextAntialiasing

The following members return ConstantLineTitle objects:

Remarks

The ConstantLineTitle class contains settings that define the functionality of constant line titles. In addition to the settings inherited from the base Title class, the ConstantLineTitle class implements the ConstantLineTitle.Alignment and ConstantLineTitle.ShowBelowLine properties that respectively allow you to specify the alignment of the constant line’s title relative to the corresponding axis and the title’s display position relative to its constant line.

An object of the ConstantLineTitle type can be accessed via the ConstantLine.Title property of a constant line.

For more information, refer to Constant Lines.

Example

This example demonstrates how a constant line can be created and customized at runtime.

Since constant lines belong to a diagram’s axis, it’s first required to cast your diagram object to the appropriate diagram’s type. After that, it’s possible to access axes and manage their constant lines collection.

csharp
// Cast the chart's diagram to the XYDiagram type, to access its axes.
XYDiagram diagram = (XYDiagram)chartControl1.Diagram;

// Create a constant line.
ConstantLine constantLine1 = new ConstantLine("Constant Line 1");
diagram.AxisY.ConstantLines.Add(constantLine1);

// Define its axis value.
constantLine1.AxisValue = 7;

// Customize the behavior of the constant line.
constantLine1.Visible = true;
constantLine1.ShowInLegend = true;
constantLine1.LegendText = "Some Threshold";
constantLine1.ShowBehind = false;

// Customize the constant line's title.
constantLine1.Title.Visible = true;
constantLine1.Title.Text = "Constant Line Title";
constantLine1.Title.TextColor = Color.Red;
constantLine1.Title.Antialiasing = false;
constantLine1.Title.Font = new Font("Tahoma", 14, FontStyle.Bold);
constantLine1.Title.ShowBelowLine = true;
constantLine1.Title.Alignment = ConstantLineTitleAlignment.Far;

// Customize the appearance of the constant line.
constantLine1.Color = Color.Red;
constantLine1.LineStyle.DashStyle = DashStyle.Dash;
constantLine1.LineStyle.Thickness = 2;
vb
' Cast the chart's diagram to the XYDiagram type, to access its axes.
Dim diagram As XYDiagram = CType(chartControl1.Diagram, XYDiagram)

' Create a constant line.
Dim constantLine1 As New ConstantLine("Constant Line 1")
diagram.AxisY.ConstantLines.Add(constantLine1)

' Define its axis value.
constantLine1.AxisValue = 7

' Customize the behavior of the constant line.
constantLine1.Visible = True
constantLine1.ShowInLegend = True
constantLine1.LegendText = "Some Threshold"
constantLine1.ShowBehind = False

' Customize the constant line's title.
constantLine1.Title.Visible = True
constantLine1.Title.Text = "Constant Line Title"
constantLine1.Title.TextColor = Color.Red
constantLine1.Title.Antialiasing = False
constantLine1.Title.Font = New Font("Tahoma", 14, FontStyle.Bold)
constantLine1.Title.ShowBelowLine = True
constantLine1.Title.Alignment = ConstantLineTitleAlignment.Far

' Customize the appearance of the constant line.
constantLine1.Color = Color.Red
constantLine1.LineStyle.DashStyle = DashStyle.Dash
constantLine1.LineStyle.Thickness = 2

Inheritance

Object ChartElement TitleBase Title ConstantLineTitle

See Also

ConstantLineTitle Members

Title

Constant Lines

DevExpress.XtraCharts Namespace