IOS - Customization for Donut Series

Thread is closed for posting
2 posts, 0 answers
  1. Neha
    Neha avatar
    2 posts
    Member since:
    May 2014

    Posted 10 Jun 2014 Link to this post


    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:)
  2. Julian Benkov
    Julian Benkov avatar
    1135 posts

    Posted 13 Jun 2014 Link to this post

    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>
    @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]];

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

    Julian Benkov

    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.

Back to Top