Skip to content

Add Gradient to Bar Chart - BarChartDataSet #4385

Description

@svgupta97

I have tried researching trying to figure out how to add a gradient to my bar chart. However I am not able to to implement it. Many people have done something similar to :

let gradientColors = [UIColor.cyan.cgColor, UIColor.clear.cgColor] as CFArray // Colors of the gradient
let colorLocations:[CGFloat] = [1.0, 0.0] // Positioning of the gradient
let gradient = CGGradient.init(colorsSpace: CGColorSpaceCreateDeviceRGB(), colors: gradientColors, locations: colorLocations) // Gradient Object
yourDataSetName.fill = Fill.fillWithLinearGradient(gradient!, angle: 90.0) // Set the Gradient
set.drawFilledEnabled = true // Draw the Gradient

However it seems like this only works for line graphs since .drawFilledEnabled and .fill does not work with BarChartDataSet.

I get the error:
Value of type 'BarChartDataSet' has no member 'drawFilledEnabled' and
Value of type 'BarChartDataSet' has no member 'fill'

Would really appreciate if I can get some help on this! Thank you!!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions