Is there an example of how to do this correctly in the silverlight webchart? The examples I found on this site so far dont apply.
Hi,
Is this closer to what you need?
xamWebChart1.DataItemMouseEnter +=new DataItemMouseEventHandler
(xamWebChart1_DataItemMouseEnter);
.....
void xamWebChart1_DataItemMouseEnter(object sender, DataItemMouseEventArgs e)
{
MessageBox.Show("X:" + e.Position.X.ToString() + " Y:" + e.Position.Y.ToString());
}
Sincerely,
Petar Monov
Developer Support Engineer,
Infragistics, Inc
Thank you for responding, but no, that wont work. I need to get the axis coordinates of *any* mouse event on the chart, not just those concerning data items. I eventually worked out the following hack, which I hope will continue to work. It seems like this should be implemented properly by one of your methods but I just couldn't find it:
private Point ConvertMouseToAxisCoordinates(Point p) { // MAJOR HAAXXX -- but gridarea dimensions seem to be more reliable than the axis ones double aw = chart.Scene.GridArea.ActualWidth; double ah = chart.Scene.GridArea.ActualHeight; p.X = p.X * ((xaxis.Maximum - xaxis.Minimum) / aw) + xaxis.Minimum; p.Y = -p.Y * ((yaxis.Maximum - yaxis.Minimum) / ah) + yaxis.Minimum; p.X = Math.Max(xaxis.Minimum, Math.Min(xaxis.Maximum, p.X)); return p; }
private void InsetChart_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { chart.CaptureMouse(); Point p = e.GetPosition(xaxis); p = ConvertMouseToAxisCoordinates(p); .....do stuff with point like update a marker or add datapoints