Hi,
There are two questions about customization of IGPieChartView. Thanks in advance.
1. I want to show NO label in my chart, but labels in legend. I can switch labels on/off by setting _infraPieChart.labelsPosition = IGLabelsPositionNone, however, this property will impact labels in chart and legend at same time. Is it possible to just make label visible in Legend ?
2. I want to show Labels in legend in some certain format, like 'LabelName : Value'. Found that there is a method called 'labelWithItem' under IGPieChartViewDelegate, but seems it never gets hit. The other two 'taoWithItem' and 'viewForTooltipWithItem' are working properly. How can I customize labels in legend ?
Regards,
Allen.
Hi Allen,
After testing what you mentioned in #1, I see there is a bug present that affects the connection between labelsPosition property and the legend. In addition, pieChartView:labelWithItem: does appear to be suffering from issues too. I'll be going over these issues with my colleague to make sure we get these fixed as soon as possible and get a service release out.
In the meantime, if you want to customize the labels shown on the pie chart or legend it's possible to create a custom data object that contains a value and label property as shown below.
-(NSMutableArray*) createSimpleData:(int)recordCount{ NSMutableArray * retValue = [[NSMutableArray alloc]init ]; for (int i = 0 ; i < recordCount ; i++) { SimpleData *data = [[SimpleData alloc]initWithValue:i andLabel:[NSString stringWithFormat:@"Slice %d", i]]; [retValue addObject:data]; } return retValue;}
Once you populate the mutable array with your custom data object, you initialize the data source helper.
IGPieChartViewDataSourceHelper _source = [[IGPieChartViewDataSourceHelper alloc] initWithData:_data valuePath:@"value" labelPath:@"label"];
I'm sorry for the issues you've experience and hope my suggestions help.
Hi Torrey,Thanks for your explanation and suggestion. Yes, what you suggest would work for my scenario, as long as we get No.1 fixed so that I can show customized labels in Legend and make labels invisible from chart. Looking forward to next service release. Thanks.Regards,Allen.
We have situation where we want to show the % of the pie slice as of the total pie in the chart label.
Hooking into -(NSString*)pieChartView:(IGPieChartView*)pieChartView label:(NSString*)label item:(IGPieSliceInfo*)item; only works until the pie is exploded.
When the pie explodes the legend label now gets the modified string we created in the -(NSString*)pieChartView:(IGPieChartView*)pieChartView label:(NSString*)label item:(IGPieSliceInfo*)item; method.
Is it a way we can have a different label in the pie and legend when pie chart is exploded?
How can i get IGPieSliceInfo index value in Xamarin c#.
For example I have a pie chart with two slice. One is Ontime and Lateness. I didn't show label on the IGpiechartview. So how can i get the particular slice is click. I am using following code. in this override method i want to get information about clicked slice.
If user click on OnTime slice then i want to get that OnTime slice information. In the following code i am getting value and label but i didn't show the label on slice. There is a way to Hidden the label value on slice.
Thanks,
seshu P.
I want this one in c#
-(IGDataPoint *)pieChartView:(IGPieChartView *)pieChartView pointAtIndex:(int)index{ double value = [(NSNumber*)_data[index] doubleValue]; //any text set here will be displayed in the slices and the legend. NSString *label = [NSString stringWithFormat:@"Item %d", index]; return [[IGCategoryPoint alloc]initWithValue:value andLabel:label];}
That would translate to the GetPointAt method off the datasource helper.
It would look something like this:
public override IGDataPoint GetPointAt (IGPieChartView pieChartView, int index) { double myValue = ((NSNumber)_data [index]).DoubleValue; NSString newString = "someNewString"; return new IGCategoryPoint (myValue, newString); }
My pie chart always contains to slides on is ontime and another one is latetime. When ever user click on ontime slice then i want to get that slice index value. Based on that index value i want show data. How can i get the slice index value when ever user tapped on slice. I want code snippet in C#.net
public override void ItemTapped(IGPieChartView pieChartView, IGPieSliceInfo item, System.Drawing.PointF point) {
}
using this method possible to get slice index.
Cycle through the .dataPoints collection off the chart and find the object
public override void ItemTapped (IGPieChartView pieChartView, IGPieSliceInfo item, System.Drawing.PointF point) { IGCategoryPoint dataPoint = (IGCategoryPoint)item.Item; for (int i = 0; i < pieChartView.DataPoints.Count; i++) { IGCategoryPoint tempObject = pieChartView.DataPoints.GetItem<IGCategoryPoint>(i); if (dataPoint == tempObject) { // now i is your index; int xx = 0; xx++; } } }