Hi,
I want to get series name and value on the clicked element in the column graph.
For it I handle MouseDown event and call HitTest function. But it returns null reference in his SelectedObject property
It only works properly in the 3d Mode .
What is wrong?
Ok looks like setting Marker.Format=" " with one blank space does the trick. The problem mainly occurs when there are many data points in the same proximity. This is why your example doesn't cause the problem. It looks like we need over 100 data points and some of them need to be ver close to each other. Then the text labels overwhelm the data points. This is not evident becuase I (and others I am guessing) are turning them off by setting Foreground to transparent.
If there is a better way to turn off marker labels than setting Marker.Format = to a blank space string post here.
Well yours works fine for me. Wierd. I'm on vaca next week but when I get back I will try to figure out what I am doing different. I guess one of the main things I do different is dynamically add and remove data points. And I have more series. When I figure it out will post.
Update: Just got another clue. Using snoop I can see that Mouse Enter Events are being block by a TextBlock on some data points. I set the Marker Foreground color to transparent becuase I don't want labels on my data points, but somehow these invisible TextBlocks are blocking the data points from getting a mouse over.
How do we get rid of the Text Labels on Markers?
Format? or LabelDistance?
i tested this out and i was able to get a value for SelectedObject consistently with a ScatterLine chart with 30 points. here is the sample code i used -- please let me know if this works on your machine -- if so, how should i modify this code to reproduce the problem?
private void XamChart_MouseDown(object sender, MouseButtonEventArgs e) { base.OnMouseDown(e); HitTestArgs args = this.XamChart1.HitTest(e); DataPoint selectedPoint = args.SelectedObject as DataPoint; if (selectedPoint != null) { Console.WriteLine("Clicked " + selectedPoint.ChartParameters[0].Value + ", " + selectedPoint.ChartParameters[1].Value); } }
<Window x:Class="WpfApplication37.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igCA="clr-namespace:Infragistics.Windows.Chart;assembly=Infragistics3.Wpf.Chart.v7.2" Title="Window1" Height="300" Width="300"> <igCA:XamChart x:Name="XamChart1" MouseDown="XamChart_MouseDown"> <igCA:XamChart.Series> <igCA:Series ChartType="ScatterLine"> <igCA:Series.Marker> <igCA:Marker /> </igCA:Series.Marker> <igCA:Series.DataPoints> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="1" /> <igCA:ChartParameter Type="ValueY" Value="1" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="2" /> <igCA:ChartParameter Type="ValueY" Value="2" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="3" /> <igCA:ChartParameter Type="ValueY" Value="3" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="4" /> <igCA:ChartParameter Type="ValueY" Value="4" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="5" /> <igCA:ChartParameter Type="ValueY" Value="5" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="6" /> <igCA:ChartParameter Type="ValueY" Value="6" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="7" /> <igCA:ChartParameter Type="ValueY" Value="7" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="8" /> <igCA:ChartParameter Type="ValueY" Value="8" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="9" /> <igCA:ChartParameter Type="ValueY" Value="9" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="10" /> <igCA:ChartParameter Type="ValueY" Value="10" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="11" /> <igCA:ChartParameter Type="ValueY" Value="11" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="12" /> <igCA:ChartParameter Type="ValueY" Value="12" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="13" /> <igCA:ChartParameter Type="ValueY" Value="13" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="14" /> <igCA:ChartParameter Type="ValueY" Value="14" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="15" /> <igCA:ChartParameter Type="ValueY" Value="15" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="16" /> <igCA:ChartParameter Type="ValueY" Value="16" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="17" /> <igCA:ChartParameter Type="ValueY" Value="17" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="18" /> <igCA:ChartParameter Type="ValueY" Value="18" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="19" /> <igCA:ChartParameter Type="ValueY" Value="19" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="20" /> <igCA:ChartParameter Type="ValueY" Value="20" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="21" /> <igCA:ChartParameter Type="ValueY" Value="21" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="22" /> <igCA:ChartParameter Type="ValueY" Value="22" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="23" /> <igCA:ChartParameter Type="ValueY" Value="23" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="24" /> <igCA:ChartParameter Type="ValueY" Value="24" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="25" /> <igCA:ChartParameter Type="ValueY" Value="25" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="26" /> <igCA:ChartParameter Type="ValueY" Value="26" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="27" /> <igCA:ChartParameter Type="ValueY" Value="27" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="28" /> <igCA:ChartParameter Type="ValueY" Value="28" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="29" /> <igCA:ChartParameter Type="ValueY" Value="29" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> <igCA:DataPoint> <igCA:DataPoint.ChartParameters> <igCA:ChartParameter Type="ValueX" Value="30" /> <igCA:ChartParameter Type="ValueY" Value="30" /> </igCA:DataPoint.ChartParameters> </igCA:DataPoint> </igCA:Series.DataPoints> </igCA:Series> </igCA:XamChart.Series> </igCA:XamChart></Window>
Yeah I have seen issues with it in scatterline. Add like 30-40 points. I'd say 80% of my points work, but the other 20 don't, no matter what I do. I am not sure if this is a wpf issue or chart control issue. I even changed my code to use Marker Templates with button click, and for some reason some points refuse to get click/mouse over events. Very strange. And my buttons points are fairly large. As big as the mouse pointer.
SelectedObject returns a DataPoint for me in a simple 2D column chart. what type of chart/datapoint are you clicking on?