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

Issue to retain selected datapoint while switching series at runtime

5 Answers 46 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Sivakumar
Top achievements
Rank 1
Sivakumar asked on 08 Apr 2016, 02:48 AM

My chart having logic which switching between Point and Line series at run time.Issue is after switching series chart not retain the selection with new series selected.

 

Please help to resolve this issue.

5 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 08 Apr 2016, 02:55 PM
Hello Sivakumar,

This behavior is expected because when you switch the series you create a new series object different than the previous one which has different DataPoint models. In order to achieve your requirement you can use the SelectedPoints collection of the chart to save your view models when the old series is removed and when you add the new one you can use the saved models to select the new generated data points.

Regards,
Martin
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Sivakumar
Top achievements
Rank 1
answered on 12 Apr 2016, 03:53 AM

I am using same data-point model only.I am just switching the series.I am saving currently selected data point model but i am not sure under which event i can assign this saved data model when new series created. I already tried with series created event but there data point not generated yet.please help

and also chart first series first point need to be selected after chart loaded..please help how to do this also..

Can you please provide sample code ?

0
Sivakumar
Top achievements
Rank 1
answered on 12 Apr 2016, 03:58 AM
Please find code below..
 
private void ChartSeriesProvider_SeriesCreated(object sender, ChartSeriesCreatedEventArgs e)
   {
 
       //todo : retain selected point while switching series
       if (selectedPoint != null)
       {
           var series = selectedPoint.Presenter as CategoricalSeries;
           //var pointToSelect = series.DataPoints[nextSelectedIndex - 1];
       }
 
       //select firstpoint
       if (chart.SelectedPoints.Count == 0)
       {
           var pointToSelect = (e.Series as CategoricalSeries).DataPoints[0];
           pointToSelect.IsSelected = true;
       }
 
   }
[quote]Your quote goes here[/quote]
0
Accepted
Martin Ivanov
Telerik team
answered on 12 Apr 2016, 03:10 PM
Hello Sivakumar,

The data points of the series are not yet generated in the SeriesCreated event and this is why you cannot get them. You can use the DataBindingComplete event of the series instead.

I created a small example demonstrating a possible approach for achieving your requirement. I hope it works for you.

Regards,
Martin
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Sivakumar
Top achievements
Rank 1
answered on 13 Apr 2016, 01:06 AM
Thanks Martin...Your solution is working
Tags
ChartView
Asked by
Sivakumar
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Sivakumar
Top achievements
Rank 1
Share this question
or