This is a migrated thread and some comments may be shown as answers.

How to Set Selected Points in RadCartesianChart?

4 Answers 202 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Ahmed
Top achievements
Rank 1
Ahmed asked on 24 May 2014, 04:22 PM
Hi,,

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


Thanks,,

4 Answers, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 26 May 2014, 08:07 AM
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.
 
0
Ahmed
Top achievements
Rank 1
answered on 27 May 2014, 08:39 AM
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,
0
Peshito
Telerik team
answered on 29 May 2014, 10:42 AM
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.
 
0
Ahmed
Top achievements
Rank 1
answered on 29 May 2014, 02:20 PM
Thanks Peshito,,

The solution worked.
Tags
ChartView
Asked by
Ahmed
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Ahmed
Top achievements
Rank 1
Share this question
or