Gridient fill does not seem to work

6 posts, 0 answers
  1. Alex
    Alex avatar
    10 posts
    Member since:
    Apr 2011

    Posted 15 Oct 2014 Link to this post

    I tried to set the backgroundFill to a gradient as follows:
            var gridStyle = chart.gridStyle()
            gridStyle?.backgroundFill = TKGradientFill(colors: [UIColor.redColor(), UIColor.greenColor()], locations: [0, 1])
    But it did not seem to work. I also tried different variations (e.g., not specifying locations, different locations values, etc.) without much success.

    Setting it to a solid color does work though:
            gridStyle?.backgroundFill = TKSolidFill(color: UIColor.redColor())

    Am I specifying the gradient fill correctly? If not, how should I specify?

    Thanks.

    Alex
  2. Adrian
    Admin
    Adrian avatar
    167 posts

    Posted 16 Oct 2014 Link to this post

    Hi Alex,

    TKGradientFill is an abstract class and it should not be instantiated. The correct way to use gradients for the grid's backgroundFill property is to use TKLinearGradientFill or TKRadialGradientFill which inherit from TKGradientFIll. Please consider the code snippet below:
    chart.gridStyle().backgroundFill = TKLinearGradientFill(colors: [UIColor.redColor(), UIColor.greenColor()], locations: [0, 1])

    I hope this helps. If you need further assistance, do not hesitate to contact us.

    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
  4. Alex
    Alex avatar
    10 posts
    Member since:
    Apr 2011

    Posted 16 Oct 2014 in reply to Adrian Link to this post

    Great. That works. Thanks.

    Alex
  5. Adrian
    Admin
    Adrian avatar
    167 posts

    Posted 17 Oct 2014 Link to this post

    Hello Alex,

    Thank you for this update.
    I am happy that the issue is solved now. I will be glad to help in case you need further assistance.

    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.

     
  6. derrick
    derrick avatar
    2 posts
    Member since:
    Sep 2015

    Posted 01 Sep 2015 in reply to Adrian Link to this post

    Can a gradient be applied to an area chart? I'm looking at the iOS demo app and the double curved area chart example has very faint gradients for the red and blue (see attahced). Can I specify what the gradient range should be with "hard" hex values or is there a way to define 1 hex value with opacity or alpha values, like 100% - 40% ?

    In the attached image the red is #fff3f3 (lightest) at the top -to- fbdfdd (darker)
  7. Adrian
    Admin
    Adrian avatar
    167 posts

    Posted 03 Sep 2015 Link to this post

    Hi Derrick,

    Thank you for contacting us.

    Please find the response of my colleague in your other support ticket.
    Do not hesitate to contact us in case you need further assistance.

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