Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
HitTest doesn't work in the 2D mode
posted

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? 

Parents
No Data
Reply
  • 739
    posted

    Hi,

    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>

Children