pie chart colours

2 posts, 0 answers
  1. David A
    David A avatar
    1 posts
    Member since:
    Nov 2014

    Posted 18 Nov 2014 Link to this post

    How do I change the colours of the pie chart?
  2. Adrian
    Admin
    Adrian avatar
    167 posts

    Posted 18 Nov 2014 Link to this post

    Hi David,

    Thank you for contacting us.

    To change the colors of the pie slices, you should use TKChartDelegate's chart:paletteItemForSeries:atIndex: method to return a palette item that suits your needs. The following code snippet will change the color of the slice at index 3 to yellow:
    - (TKChartPaletteItem *)chart:(TKChart *)chart paletteItemForSeries:(TKChartSeries *)series atIndex:(NSUInteger)index
    {
        if (index == 3) {
            TKChartPaletteItem *item = [[TKChartPaletteItem alloc] initWithFill:[TKSolidFill solidFillWithColor:[UIColor yellowColor]]];
            return item;
        }
     
         
        return nil;
    }

    Do not forget to set TKChart's delegate:
    _chart.delegate = self;

    More info about custom drawing in TKChart you can find in out documentation.

    I hope this helps. I will be glad to assist you if you need any help.

    Regards,
    Adrian
    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.

     
  3. DevCraft banner
Back to Top