How do I identify the column the mouse is over?
So, I have an SfChart in WPF with a DateTimeCategory x axis and a Fast Candlestick series.
If I wanted to identify exactly which candlestick the mouse is over during a mousewheel event, how would I do that? I recall there was a way to do this in Winforms but that doesn't seem to exist in WPF. The closest I could come was:
var mousePosition = e.GetPosition(sender as SfChart);
Point chartPosition = new Point
{
X = mousePosition.X - ChartViewRecords[0].Chart.SeriesClipRect.Left,
Y = mousePosition.Y - ChartViewRecords[0].Chart.SeriesClipRect.Top
};
double xValue = ChartViewRecords[0].Chart.PointToValue(ChartViewRecords[0].Chart.PrimaryAxis, chartPosition);
int guessColumn = (int)Math.Round(xValue);
It's got 101 candlesticks, I get 110 for the right most one, 10 for the left. But if you change the number of columns, the amount of miss varies, so it's not even consistently one offset value.
Hi Thomas,
From your description, it sounds
like your main goal is to identify the exact candlestick the mouse is hovering
over during a mouse wheel event. Typically, this use case is handled using
the Trackball feature in SfChart, which is designed to provide
detailed information about the data point under the cursor.
The below shared events provide access to the ChartPointInfo, which includes all relevant details about the data point currently under the mouse. This is a more reliable and consistent way to identify the candlestick than manually calculating positions.
Trackball
in WPF Charts control | Syncfusion
Events
in Trackball in WPF Charts control | Syncfusion
Let me know if I’ve misunderstood your use case.
No, that's the use case. I need to spot the exact candlestick so that I can create an annotation there (optionally) but I have been struggling with how to spot the candle location accurately. I will look at the trackball info and get back to you. Currently I'm also having issues with ZoomChanged.NewRange seeming to return wrong values, so I will get back to this tomorrow.
Hi Thomas,
We appreciate your effort in exploring the trackball info. We're patiently waiting for your findings and are happy to assist further once you’ve had a chance to review it.
Regarding the issue with ZoomChanged.NewRange is returning unexpected values, we’d like to continue the discussion in a separate thread.
Thread link: Question about "autoscale" exa... | WPF Forums | Syncfusion®
Looking forward to your feedback.
Best regards,
Arul Jenith B.
- 3 Replies
- 3 Participants
-
TB Thomas Brand
- Aug 13, 2025 09:49 PM UTC
- Aug 15, 2025 10:49 AM UTC