Skip to content

Instantly share code, notes, and snippets.

@sheafk
Created August 17, 2016 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sheafk/f5204a75b60b1cc2e5210b60c2aaaca0 to your computer and use it in GitHub Desktop.
Save sheafk/f5204a75b60b1cc2e5210b60c2aaaca0 to your computer and use it in GitHub Desktop.
func setLocationQuotientMap(dictionary: [String : Double]) {
self.usaColorMapView.backgroundColor = UIColor.clearColor()
self.usaColorMapView.setColorForAllStates(UIColor.flatGrayColor())
self.usaColorMapView.performUpdates {
for (state, locationQuotient) in dictionary {
switch locationQuotient {
case 0.20..<0.40 :
self.usaColorMapView.setColor(UIColor.flatRedColor().lightenByPercentage(0.5), forStateByName: state)
case 0.4..<0.8 :
self.usaColorMapView.setColor(UIColor.flatRedColor().lightenByPercentage(0.25), forStateByName: state)
case 0.8..<1.25 :
self.usaColorMapView.setColor(UIColor.flatRedColor(), forStateByName: state)
case 1.25..<2.50 :
self.usaColorMapView.setColor(UIColor.flatRedColor().darkenByPercentage(0.25), forStateByName: state)
case 2.50..<3.50 :
self.usaColorMapView.setColor(UIColor.flatRedColor().darkenByPercentage(0.5), forStateByName: state)
default:
self.usaColorMapView.setColor(UIColor.flatGrayColor(), forStateByName: state)
print("No location quotient for \(state)")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment