I'm plotting X-Y data using ScatterLine series in a XamChart.
I'm using the XamChart.MouseMove to display the X-Y values in a couple text boxes as the user mouses over the chart. Something like this:
void OnChartMouseMove(object sender, MouseEventArgs e){ var args = chart.HitTest(e); var x = args.XValue; var y = args.YValue;
XValueTextBlock.Text = String.Format("X: {0:G5}", x); YValueTextBlock.Text = String.Format("Y: {0:G5}", y);}
Everything works well until the user changes the application window size, resulting in a resized XamChart. After that, the values of HitTestArgs.XValue and HitTestArgs.YValue are incorrect.
Has anyone else seen this problem? Anyone know how to work around?
This sample illustrates the problem. When you run it., the window starts out at 300 x 300 and the values in the textblock are correct. If you maximize the Window and mouse over the chart, the values are incorrect.
<Window x:Class="HitTestTest.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ig="clr-namespace:Infragistics.Windows.Chart;assembly=Infragistics3.Wpf.Chart.v8.2" Title="Window1" Height="300" Width="300"> <DockPanel> <TextBlock DockPanel.Dock="Bottom" x:Name="textBlock" TextAlignment="Center" /> <ig:XamChart x:Name="xamChart" MouseMove="xamChart_MouseMove"> <ig:XamChart.Series> <ig:Series x:Name="xamSeries" ChartType="ScatterLine" DataMapping="ValueX=X;ValueY=Y" /> </ig:XamChart.Series> </ig:XamChart> </DockPanel></Window>
using System;using System.Windows;using System.Windows.Input;
namespace HitTestTest{ public partial class Window1 : Window { public Window1() { InitializeComponent();
this.Loaded += delegate { xamSeries.DataSource = new Point[] { new Point { X = 0, Y = 0 }, new Point { X = 10, Y = 10}, }; }; }
private void xamChart_MouseMove(object sender, MouseEventArgs e) { var args = xamChart.HitTest(e); textBlock.Text = String.Format("({0:0.0},{1:0.0})", args.XValue, args.YValue); } }}
Thanks for the sample code you provided. I've just tested this using the latest service release 9.1.20091.2091 and it works as expected. Which build are you using in your application? Probably it could be an known issue which was already logged in our tracking system and fixed. Let me know if you can resolve the issue with the latest service release.
Vlad
Yes. After getting the latest release, the HitTest works as expected after resizing the chart. Thanks!