Skip to main content

NumericConstantLine Class

The vertical or horizontal straight line that passes through the chart and indicates a qualitative x- or y-axis’s value.

Namespace: DevExpress.XamarinForms.Charts

Assembly: DevExpress.XamarinForms.Charts.dll

NuGet Package: DevExpress.XamarinForms.Charts

Declaration

public class NumericConstantLine :
    ConstantLineBase

Remarks

A constant line is a vertical or horizontal straight line that passes through the chart and indicates a y- or x-axis’s value. A constant line is perpendicular to the axis to which it belongs.

Numeric Constant Line Sample

Add a NumericConstantLine object to the NumericAxisY.ConstantLines or NumericAxisX.ConstantLines collection to create a constant line for a numeric y- or x-axis.

The following properties allow you to define constant line settings:

Property

Description

AxisValue

Gets or sets the constant line position along the numeric axis.

ShowBehind

Specifies whether the constant line is displayed behind series.

VisibleInLegend

Indicates whether the constant line is shown in the chart legend.

LegendText

Gets or sets the text that identifies the constant line in the chart legend.

Title

Gets or sets settings of the constant line title.

Style

Gets or sets the constant line appearance settings.

Example

This example shows how to add a constant line to a numeric y-axis, customize its appearance and show it in the chart legend. To do this, add a NumericConstantLine object with the specified properties to the NumericAxisY.ConstantLines collection.

NumericAxisY Constant Line

<dxc:ChartView>
  <!--...-->

  <dxc:ChartView.AxisY>
      <dxc:NumericAxisY>
          <dxc:NumericAxisY.ConstantLines>
              <dxc:NumericConstantLine AxisValue="{Binding ViewModel.NightTempAverage}"
                                       ShowBehind="True"
                                       VisibleInLegend="True"
                                       LegendText="Average Annual">
                  <!-- Customize the constant line title. -->
                  <dxc:NumericConstantLine.Title>
                      <dxc:ConstantLineTitle Text="{Binding ViewModel.NightTempAverage, StringFormat='{0}°C'}"
                                             Alignment="Far" 
                                             ShowBelowLine="False">
                          <dxc:ConstantLineTitle.Style>
                              <dxc:TitleStyle>
                                  <dxc:TitleStyle.TextStyle>
                                      <dxc:TextStyle Color="#7f43bf" Size="12"/>
                                  </dxc:TitleStyle.TextStyle>
                              </dxc:TitleStyle>
                          </dxc:ConstantLineTitle.Style>
                      </dxc:ConstantLineTitle>
                  </dxc:NumericConstantLine.Title>
                  <!-- Customize the constant line appearance. -->
                  <dxc:NumericConstantLine.Style>
                      <dxc:ConstantLineStyle Stroke="#7f43bf" Thickness="2" Dashes="7 3"/>
                  </dxc:NumericConstantLine.Style>
              </dxc:NumericConstantLine>
          </dxc:NumericAxisY.ConstantLines>
      </dxc:NumericAxisY>
  </dxc:ChartView.AxisY>
</dxc:ChartView>

Inheritance

See Also