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?
The SelectedObject property from HitTestArgs is null if mouse is not above a DataPoint (Series). Only when data points are selected the SelectedObject will return a reference to a data point. This example shows how selection works:
C#:
using System;using System.IO;using System.Net;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Media;using System.Windows.Media.Animation;using System.Windows.Navigation;using Infragistics.Windows.Chart;
namespace UntitledProject8{ public partial class Window1 { public Window1() { this.InitializeComponent(); // Insert code required on object creation below this point. }
protected override void OnMouseDown(System.Windows.Input.MouseButtonEventArgs e) { HitTestArgs args = this.Chart1.HitTest(e); base.OnMouseDown(e); } }}
XAML:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igCA="http://infragistics.com/Chart" x:Class="UntitledProject8.Window1" x:Name="Window" Title="Window1" Width="640" Height="480">
<Grid x:Name="LayoutRoot"> <igCA:XamChart Name="Chart1" Margin="8,8,8,8"> <igCA:XamChart.Series> <igCA:Series> <igCA:Series.DataPoints> <igCA:DataPoint Value="2"/> <igCA:DataPoint Value="8"/> <igCA:DataPoint Value="6"/> <igCA:DataPoint Value="7"/> </igCA:Series.DataPoints> </igCA:Series> </igCA:XamChart.Series> </igCA:XamChart> </Grid></Window>
as per above, I cannot get the hittest to return a selected object or pointindex >0 for a 2D chart
The hittest works fine on 3D Charts, but when clicking directly on a 2D datapoint, the selectedobject in hittestargs is always null.
I would assume because the samples only have a 3D selection example, then its a known issue for 2D Charts.
Is this a known issue and is there any workaround ?
removing the Marker from the Series might be a better solution...
But I need the marker to use the data template with a scatter line chart's data points... don't I? Or can I use a data point template with a scatter line chart. The documentation is a little confusing on the subject of data templates with scatter line charts. I need a data template because my points are buttons.
From About DataPointTemplates
You can target the following DataTypes in your DataTemplates:
There is nothing there about scatterline.
using the DataPointTemplate class should suffice. and about removing marker labels, i guess setting the format to " " is your best option.
why doesn't HitTest() behave the same in 2D as it does in 3D? If I have a stacked bar or stacked column chart, I should be able to HitTest() a click over a column or bar in 2D or 3D and get the same behavior. Yet it doesn't.
I am attaching a simple example. You will need to re-add references to your chart dll's to build the application. the application displays a simple stacked column chart that handles double clicks with a HitTest() call. You can switch between 2D and 3D using a dropdown menu. Without using Markers in the 2D chart, how can I get HitTest to return the same object when performed in 2D or 3D?
i saw this submitted as a bug (BR35669) and fixed it today. your issue should be resolved in an upcoming hotfix. you should be able to work around the problem by setting UseDataTemplate = false on your series objects.