[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Collapse]Charts Suite
   [Collapse]Chart Control
    [Expand]Getting Started
    [Expand]Fundamentals
    [Expand]Providing Data
    [Expand]Appearance Customization
    [Expand]End-User Features
    [Expand]Design-Time Features
    [Collapse]Chart Elements
     [Expand]Diagram
     [Expand]Series
      Panes
     [Collapse]Axes
       Primary and Secondary Axes
       Axis Scale Types
       Whole and Visual Ranges
       Axis Layout and Appearance
       Axis Labels
       Axis Titles
       Constant Lines
       Strips
       Scale Breaks
       Tickmarks, Grid Lines, and Interlacing
      Legends
      Chart Titles
      Annotations
    [Expand]Examples
    [Expand]Additional Resources
   [Expand]Chart3D Control
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Constant Lines

A constant line marks a value on an x- or y-axis. The Chart control allows you to draw constant lines behind or in front of the chart's series and modify their appearance.

This document consists of the following sections:

Expanded How to Add a Horizontal Constant Line

The following image shows a horizontal constant line that is positioned in front of series.

To draw a constant line as in the image above, use the following notation for the 2D XY Diagram y-axis:

The markup above uses the following classes and properties:

Class or Property Description
Axis2D.ConstantLinesInFront The collection of constant lines that are drawn in front of series.
ConstantLine A constant line.
ConstantLine.Value Specifies the value that the constant line identifies.
ConstantLine.Title Gets or sets the constant line's title.
ConstantLineTitle The constant line's title.
TitleBase.Content Specifies content in the constant line's title.
Note

  1. Set the ConstantLine.Visible property to false when you need to hide a constant line without removing it from the chart.

  2. The whole axes ranges are calculated automatically based on chart data by default. To draw the constant line through a value that is out of the axis' whole range, extend the range manually. For more information, refer to the Whole and Visual Ranges help document.

To add a constant line at runtime, use to the code below:

Expanded How to Add a Vertical Constant Line

In addition to horizontal y-axis constant lines, you can add vertical x-axis constant lines to a chart. In the image, an x-axis constant line is positioned behind the series.

To draw a constant line as the image above shows, use the following markup for the x-axis:

The code above uses the following classes and properties:

Class or PropertyDescription
Axis2D.ConstantLinesBehind The collection of constant lines drawn behind series.
ConstantLine A constant line.
ConstantLine.Value Specifies a value that a constant line identifies.
ConstantLine.Title Gets or sets the constant line's title.
ConstantLineTitle The title that displays with a constant line.
TitleBase.Content The constant line title's content.

Expanded How to Show a Constant Line in a Legend

You can display a constant line's marker with the specified text in the chart legend.

To display a constant line in the legend, define the ConstantLine.LegendText property. If this property is not specified, a chart legend doesn't display a constant line.

Expanded How to Customize Constant Line Appearance

It is possible to modify the constant line's title position and appearance as follows.

The example below demonstrates how to change the constant line's title presentation:

The code above uses the following classes and properties:

Class or Property Description
ConstantLineTitle A constant line title.
TitleBase.Content The title's content.
TitleBase.ContentTemplate Specifies how the title's content should look like.
ConstantLineTitle.Alignment Specifies title alignment relative to the constant line.
ConstantLineTitle.ShowBelowLine Specifies whether to show the title below the constant line.

You can configure the constant line's style (e.g., thickness or a color).

To change line appearance, use the following markup:

The markup above uses the following classes and properties:

Class or Property Description
ConstantLine.LineStyle Stores the constant line's options such as line thickness.
ConstantLine.Brush Defines the brush used to paint the constant line.
LineStyle The constant line style's options.
LineStyle.DashStyle Specifies the style used to draw the constant line.

Expanded See Also

Is this topic helpful?​​​​​​​