Search code examples
iosswiftios-charts

Using Custom Color with iOS Charts labelTextColor


Does anyone know how to get a custom color to work with labelTextColor in iOS Charts? When I try to plug in a custom color the labels just disappear. For example:

This works:

self.chartView.leftAxis.labelTextColor = UIColor.cyanColor()

But something like this does not:

self.chartView.rightAxis.labelTextColor = UIColor(red: 150, green: 202, blue: 56, alpha: 1)

Solution

  • replace

    self.chartView.rightAxis.labelTextColor = UIColor(red: 150, green: 202, blue: 56, alpha: 1)
    

    with

    self.chartView.rightAxis.labelTextColor = UIColor(red: 150.0/255, green: 202.0/255, blue: 56.0/255, alpha: 1)