We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Data Point Selection Question(s)

I have a Column Chart with 2 Series and I have 2 questions:
1) When I click a Column I want to reload other Charts in the same ViewControler, but inside the delegate Class I'm out of scope.
2) When I click a Column of Series 1, I want to deselect the column of Series 2


    public class ChartDelegate : SFChartDelegate
    {

    

        public override void DidDataPointSelect(SFChart chart, SFChartSelectionInfo info)
        {

            var alert = new NBAlert();
            alert.showAlert("Data Point", String.Format("Selected Series:{0}\rSelectedDataPointIndex:{1}\rPreviousSelectedDataPointIndex:{2}",
                                                        info.SelectedSeries.Label,
                                                        info.SelectedDataPointIndex,
                                                        info.PreviousSelectedIndex));
            


            
        }

    }
  

3 Replies

SG Sivaram Ganesan Syncfusion Team November 17, 2016 04:05 PM UTC

Hi Marco, 
 
Thanks for contacting Syncfusion support.  

 
We have created a sample based on your requirement. Please download it from below location.  
  

Please refer following code snippet for reference. 
 
Code snippet  

  

publicclassChartDelegate : SFChartDelegate 
{ 
    publicoverridevoidWillDataPointSelect(SFChart chart, SFChartSelectionChangingInfo info) 
    { 
       varchartView = chart.Superview; 
       if (chartView != null) 
       { 
          foreach (var item inchartView.Subviews) 
          { 
             if (!item.IsEqual(chart)) 
             { 
                var Chart1 = (item asSFChart); 
                if (Chart1 != null) 
                { 
                     ////Query – 1 solution.  

                     NSMutableArrayseriesCollection = Chart1.ValueForKey(newNSString("series")) asNSMutableArray; 
                   for (nuinti = 0; i < seriesCollection.Count; i++) 
                   { 
                     var series = seriesCollection.GetItem<SFSeries>(i);  

                     if (series.SelectedDataPointIndex != -1) 
                         series.SelectedDataPointIndex = -1;  
                     //// series.ReloadData(); Reloads chart    
                   } 
                } 
            } 
        } 
    } 
  

// Query – 2 solution  

 
     NSMutableArraynumberOfSeries = chart.ValueForKey(newNSString("series")) asNSMutableArray; 
     for (nuinti = 0; i < numberOfSeries.Count; i++) 
     { 
        var series = numberOfSeries.GetItem<SFSeries>(i); 
        if ((series != null) && (series != info.SelectedSeries) && series.SelectedDataPointIndex != -1) 
           series.SelectedDataPointIndex = -1; 
     } 
   } 
}   

 
Sample
 
Please get back to us for further assistance on this.

Regards,
 
Sivaram.G 




MV Marco Vicente November 21, 2016 11:27 AM UTC

Thanks. I was able to solve both problems.


SG Sivaram Ganesan Syncfusion Team November 22, 2016 04:40 AM UTC

Hi Marco,

Most welcome.

Please get back to us for further assistance on this.

Regards,
Sivaram.G

SIGN IN To post a reply.
Loader.
Up arrow icon