windowsforms-8689-controls-and-libraries-chart-control-examples-end-user-interaction-how-to-show-series-labels-only-for-hot-tracked-points.md
This example demonstrates how to make a chart show a series point label only for the point that has been hot-tracked.
To do this, in the ChartControl.CustomDrawSeriesPoint event handler, assign an empty string to the CustomDrawSeriesPointEventArgs.LabelText property of each series point, and then assign the point’s value to the hot-tracked point, which is obtained in the ChartControl.ObjectHotTracked event handler.
using System;
using System.Windows.Forms;
using DevExpress.XtraCharts;
// ...
SeriesPoint m_HotTrackedPoint;
void chartControl1_ObjectHotTracked(object sender, HotTrackEventArgs e)
{
SeriesPoint point = e.AdditionalObject as SeriesPoint;
if (!Object.ReferenceEquals(point, m_HotTrackedPoint))
{
m_HotTrackedPoint = point;
chartControl1.Refresh();
}
}
void chartControl1_CustomDrawSeriesPoint(object sender, CustomDrawSeriesPointEventArgs e)
{
if (!Object.Equals(e.SeriesPoint, m_HotTrackedPoint))
{
e.LabelText = "";
}
}
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraCharts
' ...
Private m_HotTrackedPoint As SeriesPoint
Private Sub chartControl1_ObjectHotTracked(ByVal sender As Object, ByVal e As HotTrackEventArgs) Handles chartControl1.ObjectHotTracked
Dim point As SeriesPoint = TryCast(e.AdditionalObject, SeriesPoint)
If Not Object.ReferenceEquals(point, m_HotTrackedPoint) Then
m_HotTrackedPoint = point
chartControl1.Refresh()
End If
End Sub
Private Sub chartControl1_CustomDrawSeriesPoint(ByVal sender As Object, ByVal e As CustomDrawSeriesPointEventArgs) Handles chartControl1.CustomDrawSeriesPoint
If Not Object.Equals(e.SeriesPoint, m_HotTrackedPoint) Then
e.LabelText = ""
End If
End Sub
The result is shown in the following image.
See Also
How to: Determine a Chart Element the Mouse Pointer Hovers Over
How to: Determine which Series Point Is Under the Test Point
How to: Show Information from a Datasource Field in a Crosshair Cursor Label