Charts: bar chart with gradient

Created on 19 Sep 2015  路  11Comments  路  Source: danielgindi/Charts

Hi,

Does this support two or more gradient color for bars?

Thanks.

All 11 comments

What you mean for the gradient color for bars? It has fill color first; and you can customize the color for each dataSet

I have a requirement to create a graph like this:

screen shot 2015-09-21 at 6 11 06 pm

hmm, it seems you need to implement the gradient layer by yourself. ios-charts does not support this right now.

But for the line chart, we already support the filling - check out drawLinearFill and enable it with dataSet.isDrawFilledEnabled
Feel free to reopen it if you have more questions

Do you have any example code for the gradient fill on the line chart? I cannot seem to reproduce it in Swift. Thank you so much!

Any update on this? Still no gradient layer for Barcharts?

not yet. Busy with Chart 3.0

hi
I would like to know how to make Line Chart(gradient fill)

@Egor1219
Hi, you can do this with for example like this :

        let chartDataSet = LineChartDataSet(values: %%YOUR DATA ENTRIES %%, label: "Temperature")
        // Gradient
        let gradientColors = [UIColor.red.cgColor, UIColor.clear.cgColor] as CFArray // Colors of the gradient
        let colorLocations:[CGFloat] = [0.5, 0.0] // Positioning of the gradient
        let gradient = CGGradient.init(colorsSpace: CGColorSpaceCreateDeviceRGB(), colors: gradientColors, locations: colorLocations) // Gradient Object
        chartDataSet.fill = Fill.fillWithLinearGradient(gradient!, angle: 90.0) // Set the Gradient
        chartDataSet.drawFilledEnabled = true // Draw the Gradient


        chartDataSet.drawCubicEnabled = true
        chartDataSet.cubicIntensity = 0.09

Swift 3

I have created a video tutorial for this task. Kindly refer to my video.

https://www.youtube.com/watch?v=zT6zMyYpkXM&t=13s

@vigyanhoon
Hi! Have you found the solution for BarChartView gradientColors?and coding by Objective-C

Its pretty old issue. I have now moved to front end dev.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kwstasna picture kwstasna  路  3Comments

Bharati555 picture Bharati555  路  4Comments

valeIT picture valeIT  路  3Comments

cilasgimenez picture cilasgimenez  路  4Comments

deepumukundan picture deepumukundan  路  3Comments