This is a migrated thread and some comments may be shown as answers.

IOS - Customization for Donut Series

1 Answer 58 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Neha
Top achievements
Rank 1
Neha asked on 10 Jun 2014, 07:22 PM
Hello,

I was wondering on how to customize the color of each donut in the donut series.

It seems its not the same way of doing it as the bar charts.


Thank you:)

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 13 Jun 2014, 06:45 AM
Hello Priya,

Thank you for writing us.

Colors of pie/donut chart series can be customized by implementing the TKChartDelegate protocol and handling its paletteItemForSeries method. The following code snippet demonstrates this:

#import <TelerikUI/TelerikUI.h>
  
@interface PieChart () <TKChartDelegate>
@end
  
@implementation PieChart
  
- (void)viewDidLoad
{
    [super viewDidLoad];
           
    TKChart *pieChart = [[TKChart alloc] initWithFrame:self.view.bounds];
    pieChart.delegate = self;
    [self.view addSubview:pieChart];
 
//...
   
-(TKChartPaletteItem *)chart:(TKChart *)chart paletteItemForSeries:(TKChartSeries *)series atIndex:(NSUInteger)index
{
    CGFloat hue = ( arc4random() % 256 / 256.0 );
    CGFloat saturation = ( arc4random() % 128 / 256.0 ) + 0.5;
    CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5;
    UIColor *fillColor = [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1];
    return [[TKChartPaletteItem alloc] initWithFill:[TKSolidFill solidFillWithColor:fillColor]];
}
  
@end

I hope this helps. Do not hesitate to contact us, if you need further assistance.

Regards,
Julian Benkov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussion
Asked by
Neha
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or