corelibraries-devexpress-dot-xtracharts-dot-constantline.md
Gets or sets the constant line’s position along an axis.
Namespace : DevExpress.XtraCharts
Assembly : DevExpress.XtraCharts.v25.2.dll
NuGet Package : DevExpress.Charts
[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
public object AxisValue { get; set; }
<XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)>
Public Property AxisValue As Object
| Type | Description |
|---|---|
| Object |
A Object value that specifies the constant line’s position.
|
The AxisValue property specifies the position of a constant line along its corresponding axis. The value set for the AxisValue property should lie in the range specified by the AxisBase.WholeRange or AxisBase.VisualRange property in order for the constant line to be visible on a diagram.
The following images demonstrate the AxisValue property in action.
| AxisValue = 350 | AxisValue = “Indiana” |
|---|---|
For more information, refer to Constant Lines.
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.
// 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;
' 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
The following code snippets (auto-collected from DevExpress Examples) contain references to the AxisValue property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
dashboard-constant-lines/CS/ConstantLineExtension.Win/ConstantLineModule.cs#L85
if(measure != null)
line.AxisValue = data.GetValue(measure).Value;
} else
if(measure != null)
line.AxisValue = data.GetValue(measure).Value;
} else
if(measure != null)
line.AxisValue = data.GetValue(measure).Value;
} else
if(measure != null)
line.AxisValue = data.GetValue(measure).Value;
} else
If measure IsNot Nothing Then
line.AxisValue = data.GetValue(measure).Value
End If
winforms-chart-create-and-customize-a-constant-line/VB/ConstLines/Form1.vb#L36
' Define its axis value.
constantLine1.AxisValue = 7
' Customize the behavior of the constant line.
See Also