How to Set Selected Points in RadCartesianChart?

5 posts, 0 answers
  1. Ahmed
    Ahmed avatar
    16 posts
    Member since:
    May 2014

    Posted 24 May 2014 Link to this post

    Hi,,

    How to set the selected points in RadCartesianChart with ScatterPointSeries from the View Model?


    Thanks,,
  2. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 26 May 2014 Link to this post

    Hi,

    Please take a look at our help topic describing and showing how to use the selection behavior.

    Hope that helps.

    Regards,
    Peshito
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Ahmed
    Ahmed avatar
    16 posts
    Member since:
    May 2014

    Posted 27 May 2014 in reply to Peshito Link to this post

    Thanks Peshito,

    I'm able to get the selected points, but what I want is that When the user selected an item in the Gridview (which presents the same collection), I want the same point get selected in the chart view. 

    Note: The ItemsSource for both controls is same QueryableCollectionView. 

    Thanks,
  5. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 29 May 2014 Link to this post

    Hello,

    This can be achieved by wiring to GridView's SelectionChanged event.

    For instance:
    void gridView_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
       {
           var removed = e.RemovedItems;
     
           var add = e.AddedItems;
     
           foreach (var gridViewItem in e.RemovedItems.OfType<MyObject>())
           {
                   foreach (var chartViewItem in (chart.Series[0] as BarSeries).DataPoints)
                   {
                       if (chartViewItem.Value == gridViewItem.ID)
                       {
                           chartViewItem.IsSelected = false;
                       }
               }
           }
     
           foreach (var gridViewItem in e.AddedItems.OfType<MyObject>())
           {
               foreach (var chartViewItem in (chart.Series[0] as BarSeries).DataPoints)
               {
                   if (chartViewItem.Value == gridViewItem.ID)
                   {
                       chartViewItem.IsSelected = true;
                   }
               }
           }
       }
    Using the RemovedItems and AddedItems collections allows you to iterate trough and then depending on a custom logic to select what chart's data points to be selected as well.

    Regards,
    Peshito
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  6. Ahmed
    Ahmed avatar
    16 posts
    Member since:
    May 2014

    Posted 29 May 2014 in reply to Peshito Link to this post

    Thanks Peshito,,

    The solution worked.
Back to Top
UI for WPF is Visual Studio 2017 Ready