Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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