Line series with multiple color datapoint

4 posts, 0 answers
  1. ramya
    ramya avatar
    2 posts
    Member since:
    Jun 2015

    Posted 06 Jun 2015 Link to this post

    Hi 

     

    1)How to give customise color in line series.

    2)Is there a way to change a multiple colors of datapoint in single line series in iOS Native .

     

    Regards,

    Ramya.

  2. Sophi
    Admin
    Sophi avatar
    99 posts

    Posted 08 Jun 2015 Link to this post

    Hello Ramya,

    Thank you for contacting us.

    You can give custom color to TKChartLineSeries by adding a custom TKChartPaletteItem to the palette property of TKChartLineSeries.
    TKChartLineSeries* seriesForIncomes = [[TKChartLineSeries alloc] initWithItems:pointsWithCategoriesAndValues];
    seriesForIncomes.style.palette = [[TKChartPalette alloc] init];
    TKChartPaletteItem *item = [[TKChartPaletteItem alloc] init];
    item.stroke = [TKStroke strokeWithColor:[UIColor purpleColor]];
    [seriesForIncomes.style.palette addPaletteItem:item];

    Yes, there is a way to set different color for every datapoint in your chart. You should adopt TKChartDelegate protocol and implement its chart:paletteItemForPoint:inSeries:  method. 

    -(TKChartPaletteItem *)chart:(TKChart *)chart paletteItemForPoint:(NSUInteger)index inSeries:(TKChartSeries *)series{
        NSArray *colors = [NSArray arrayWithObjects:[UIColor blackColor], [UIColor greenColor], [UIColor redColor], [UIColor orangeColor], [UIColor yellowColor], [UIColor brownColor], nil];
        TKChartPaletteItem *item = [[TKChartPaletteItem alloc] init];
        item.fill = [TKSolidFill solidFillWithColor:[colors objectAtIndex:index]];
        return item;
    }

    I hope this helps.
    If you have any other questions do not hesitate to contact us.

    Regards,
    Sophi
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
  4. ramya
    ramya avatar
    2 posts
    Member since:
    Jun 2015

    Posted 08 Jun 2015 in reply to Sophi Link to this post

    Thank you so much.
  5. Sophi
    Admin
    Sophi avatar
    99 posts

    Posted 08 Jun 2015 Link to this post

    Hey Ramya,

    I am glad I was able to help. If you have other questions do not hesitate to contact us.

    Regards,
    Sophi
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft banner