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

Gridient fill does not seem to work

5 Answers 52 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alex
Top achievements
Rank 1
Alex asked on 15 Oct 2014, 08:34 PM
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

5 Answers, 1 is accepted

Sort by
0
Adrian
Telerik team
answered on 16 Oct 2014, 10:08 AM
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.

0
Alex
Top achievements
Rank 1
answered on 16 Oct 2014, 03:47 PM
Great. That works. Thanks.

Alex
0
Adrian
Telerik team
answered on 17 Oct 2014, 10:29 AM
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.

 
0
derrick
Top achievements
Rank 1
answered on 01 Sep 2015, 06:32 PM
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)
0
Adrian
Telerik team
answered on 03 Sep 2015, 06:59 AM
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
Tags
Chart
Asked by
Alex
Top achievements
Rank 1
Answers by
Adrian
Telerik team
Alex
Top achievements
Rank 1
derrick
Top achievements
Rank 1
Share this question
or