Hello, I am trying to implement the exploding pie slice functionality in my pie chart. I have followed the online example to make the slices explode/un-explode when pressed. However, I would like only one exploded slice to be showing at a time. For when the user selects the slice I have tried to implement the following code:
-(void)pieChartView:(IGPieChartView*)pieChartView tapWithItem:(IGPieSliceInfo*)item atPoint:(CGPoint)point{
if(lastSelectedSlice){
lastSelectedSlice.isExploded = NO;
}
item.isExploded = !item.isExploded;
lastSelectedSlice = item;
I have stepped though this method, and my lastSelectedSlice object seems to be setting correctly the exploded property correctly, however the pie chart only seems to update the state of the selected pie slice. How would I update the other pie slices to show if they are exploded or not?
Hello,
What you could do in your case is to set explodedSlices array to empty array, in this case PieChart will marks all slices as “exploded - NO” , so in tapWithinItem method you could use code like:
bool isExlded =!item.isExploded;
NSMutableIndexSet *exploded = [[NSMutableIndexSet alloc]init];
_infraPieChart.explodedSlices = exploded;
item.isExploded =isExlded;
Please try this suggestion and let me know if this is desired result.
Please let me know if you have any further questions.
Great, that did the trick, and such a simple implementation as well. Thanks!
same thing i want in C# xamarin.ios. please provide me any example
Thanks For Reply,
In my pie chart i am not showing label on pie chart. So there is any way to get that particular label when label in hidden mode. There is any way for label hidden.
My requirement is My piechartview always show two slice. One is OnTime and Second one is LateNess. I didn't show label on slice. So clicking on particular slice i want to get that slice info. Based on that i want to show relavent data. For example user click on ONTime slice then i want to show Ontime. so how can i get that perticular slice data.
Thanks,
Seshu P.
Hi seshacharyulu,
Attached is a C# example of exploding one slice at a time. All that is necessary is to hook into the ItemTapped event and reset the explosions and selections, then set the current item as selected and exploded.
public override void ItemTapped (IGPieChartView pieChartView, IGPieSliceInfo item, PointF point) { NSIndexSet newSet = new NSIndexSet (); pieChartView.ExplodedSlices = newSet; pieChartView.SelectedSlices = newSet; item.IsExploded = !item.IsExploded; item.IsSelected = !item.IsSelected; }