Skip to main content

CrosshairLegendElementBase.AxisLabelElement Property

Returns the Crosshair Cursor‘s axis label element to change its settings when using the ChartControl.CustomDrawCrosshair event to modify the Crosshair’s appearance.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v24.1.dll

NuGet Package: DevExpress.Charts

Declaration

public CrosshairAxisLabelElement AxisLabelElement { get; }

Property Value

Type Description
CrosshairAxisLabelElement

The object that contains the crosshair’s axis label element settings.

Example

This example demonstrates how to modify the Crosshair Cursor’s appearance using the ChartControl.CustomDrawCrosshair event.

In this sample, crosshair content is displayed in a legend. For this, set the CrosshairOptions.ContentShowMode to the Legend value that the CrosshairContentShowMode enumeration contains. Note that you can specify the crosshair’s content show mode for the specified series using the SeriesBase.CrosshairContentShowMode property.

Use the CustomDrawCrosshairEventArgs.CrosshairLegendElements property to obtain the crosshair legend elements’ collection.

To customize crosshair legend element options, use the CrosshairLegendElement class properties:

private void Form1_Load(object sender, System.EventArgs e) {
    chartControl.CrosshairOptions.ContentShowMode = CrosshairContentShowMode.Legend;
    chartControl.CrosshairOptions.ShowValueLabels = true;
    chartControl.CrosshairOptions.ShowValueLine = true;
}
private void OnCustomDrawCrosshair(object sender, CustomDrawCrosshairEventArgs e) {
    foreach(CrosshairLegendElement legendElement in e.CrosshairLegendElements) {
        legendElement.TextColor = (legendElement.SeriesPoint.Values[0] > ColorSelectorValue) ? Color.Green : Color.Red;
        legendElement.LineElement.Color = legendElement.TextColor;
        legendElement.AxisLabelElement.BackColor = legendElement.TextColor;
    }
}
See Also