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.
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
}
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
I suppose it would be helpful then if you explain your intent. When you say you need to map the mouse event coordinates to an axis what exactly are you trying to accomplish? For instance if you are attempting to gather datapoint information then you should be using the DataItemMouseLeftButtonDown event which may expose the element as a DataPointTemplate giving you access to the Series and therefore the axis the series belongs to. If you need an example please let me know.
I tried that already, but the results arent related in a simple way to the axis coordinates. I also tried it with GetPosition(XAxis ..), etc, but not getting anything useful.
if i am following you correctly then this might be what your looking for
private
e.GetPosition(XamChart)