corelibraries-devexpress-dot-xtracharts-dot-constantline-3fd7bb7c.md
Gets or sets a value that specifies whether the constant line is displayed behind the other chart elements on the diagram.
Namespace : DevExpress.XtraCharts
Assembly : DevExpress.XtraCharts.v25.2.dll
NuGet Package : DevExpress.Charts
[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
public bool ShowBehind { get; set; }
<XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)>
Public Property ShowBehind As Boolean
| Type | Description |
|---|---|
| Boolean |
true if the constant line is displayed behind the other chart elements; false if the constant line is displayed in front of the other chart elements.
|
Use the ShowBehind property to specify how the current constant line is displayed within the chart control’s diagram.
Set the ShowBehind property to true if you need to position a constant line behind the other chart elements (such as bars, point markers or lines that connect point markers, for instance) so that these elements overlap the line (including the line’s title) in their intersections.
By default, this property is set to true and a constant line is displayed in front of most chart elements (with the only exception being the filled series labels - those whose FillStyle2D.FillMode property is not set to FillMode.Empty) so that the whole line is visible.
| ShowBehind = False | ShowBehind = True |
|---|---|
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 snippet (auto-collected from DevExpress Examples) contains a reference to the ShowBehind 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.
winforms-chart-create-and-customize-a-constant-line/VB/ConstLines/Form1.vb#L41
constantLine1.LegendText = "Some Threshold"
constantLine1.ShowBehind = False
' Customize the constant line's title.
See Also