Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
165
Customization for IGPieChartView
posted

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.

Parents
No Data
Reply
  • 4940
    Offline posted

    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.

Children