[Bug Report] Grouping of items to 'Others' messing up the SelectedDataPointIndex

Hi Syncfusion Team,

I've currently explored a bug in the SfChart (using Doughnut Chart Series, but probably also in all other Charts which support grouping)

Using a Doughnut Chart Series which is grouping minor elements to 'Others', leads to mixed up SelectedDataPointIndex (e.g. when using this Index to PushAsync the selected item).
As soon as the Grouping is disabled, the index is right again.

Greetings,

Alexander

3 Replies

MP Michael Prabhu M Syncfusion Team July 5, 2018 11:45 AM UTC

Hi Alexander, 
 
Thanks for contacting us, we have analyzed your query and we have prepared a sample based on your requirement and we were not able to reproduce the issue, it is working fine for us. The sample which we tried to replicate is in the below link. 
 
 
Since we are not aware of your exact scenario, we request you to check our sample and if it does not resolve your issue, can you provide more information like modifying the sample and provide us the replication procedure, so that it will be helpful for us to provide you a better solution at the earliest.  
 
Thanks, 
Michael 




AL Alexander July 5, 2018 12:41 PM UTC

Hello Michael,

your sample works fine for me, however I don't see any real differences in the usage of the chart / grouping.
I have attached a modified version of my project as sample.
As soon as grouping is disabled, the selection of items works fine, but as soon as grouping is enabled, the index is wrong.

Greetings
Alexander

Attachment: Sample_e260d1cf.7z


MP Michael Prabhu M Syncfusion Team July 6, 2018 12:42 PM UTC

Hi Alexander, 

We have analyzed your query and we have achieved this by getting each segment datapoint using DependencyService as per the below code snippet.  
 
Code snippet [C#]:    
public interface IChartDependencyService 
{ 
   object DataPoint(ChartSeries series, int index); 
} 
 
async void OnBalanceSelected(object sender, ChartSelectionChangingEventArgs e) 
{ 
            e.Cancel = true; 
            object datapoint = DependencyService.Get<IChartDependencyService>().DataPoint(Chart.Series[0], e.SelectedDataPointIndex); 
            await Navigation.PushAsync(new PortfolioDetail(datapoint), true); 
} 
 
  

Code snippet [AndroidDependencyService.CS]:    
class AndroidDependencyService : IChartDependencyService 
{ 
        public object DataPoint(ChartSeries series, int index) 
        { 
            var nativeSeries = (Native.DoughnutSeries)SfChartRenderer.GetNativeObject(typeof(ChartSeries), series); 
            var segment = nativeSeries.Segments[index]; 
            PropertyInfo prop = typeof(Native.PieSegment).GetProperty("DataPoint", BindingFlags.NonPublic | BindingFlags.Instance); 
            object datapoint = prop.GetValue(segment, null); 
             
            return datapoint; 
        } 
} 


Code snippet [iOSDependencyService.CS]:    
public class iOSDependencyService : IChartDependencyService 
{ 
        public object DataPoint(ChartSeries series, int index) 
        { 
            var nativeSeries = (Native.SFDoughnutSeries)SfChartRenderer.GetNativeObject(typeof(ChartSeries), series); 
            var segment = nativeSeries.Segments[index]; 
            PropertyInfo prop = typeof(Native.SFPieSegment).GetProperty("DataPoint", BindingFlags.NonPublic | BindingFlags.Instance); 
            object datapoint = prop.GetValue(segment, null); 
 
            return datapoint; 
        } 
} 


Please use object as datatype instead of BalanceUI in  PortfolioDetail method. Because if you enable a Grouping Feature , the last segment contains list of object. Please refer the code snippet. 
Code snippet [C#]:    
 
await Navigation.PushAsync(new PortfolioDetail(datapoint), true); 

Code snippet [C#]:    
 
public PortfolioDetail(object model) 
{ 
       if (model is List<object>) 
       { 
                var viewmodel = model as ObservableCollection<BalanceUI>; 
       } 
       else 
       { 
                var viewmodel = model as BalanceUI; 
       } 
 
} 
You can find the modified sample from the below link. 
Sample:138520
 
Thanks, 
Michael  


Loader.
Up arrow icon