corelibraries-devexpress-dot-xtracharts-dot-crosshairlegendelementbase-0bf75a92.md
Returns the crosshair line element settings.
Namespace : DevExpress.XtraCharts
Assembly : DevExpress.XtraCharts.v25.2.dll
NuGet Package : DevExpress.Charts
public CrosshairLineElement LineElement { get; }
Public ReadOnly Property LineElement As CrosshairLineElement
| Type | Description |
|---|---|
| CrosshairLineElement |
The object that contains the crosshair’s line element settings.
|
Use the LineElement property to customize the crosshair line appearance when you use the ChartControl.CustomDrawCrosshair event to customize the Crosshair Cursor’s appearance.
Refer to the Crosshair Cursor document for more information.
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:
CrosshairLegendElementBase.AxisLabelElement - Returns the Crosshair Cursor‘s axis label element to change its settings when using the ChartControl.CustomDrawCrosshair event to modify the Crosshair’s appearance.
CrosshairLegendElementBase.LineElement - Returns the crosshair line element settings.
CrosshairLegendElementBase.Series - Returns the series which the Crosshair Cursor highlights.
CrosshairLegendElement.SeriesPoint - Returns the series point which the Crosshair Cursor highlights.
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;
}
}
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
chartControl.CrosshairOptions.ContentShowMode = CrosshairContentShowMode.Legend
chartControl.CrosshairOptions.ShowValueLabels = True
chartControl.CrosshairOptions.ShowValueLine = True
End Sub
Private Sub OnCustomDrawCrosshair(ByVal sender As Object, ByVal e As CustomDrawCrosshairEventArgs) Handles chartControl.CustomDrawCrosshair
For Each legendElement As CrosshairLegendElement In e.CrosshairLegendElements
legendElement.TextColor = If(legendElement.SeriesPoint.Values(0) > ColorSelectorValue, Color.Green, Color.Red)
legendElement.LineElement.Color = legendElement.TextColor
legendElement.AxisLabelElement.BackColor = legendElement.TextColor
Next legendElement
End Sub
See Also
CrosshairLegendElementBase Class