Exemple #1
0
 def vars(self, req, data):
     # Sets up the variables for the google charts used in the
     # template
     v = {}
     # 440x220 is the max size
     us_map = MapChart(440, 220)
     us_map.geo_area = 'usa'
     items = data.states.counts()
     us_map.set_codes([state for count, state in items])
     us_map.add_data([count for count, state in items])
     us_map.set_colours(('EEEEEE', '0000FF', '000033'))
     v['us_map_url'] = us_map.get_url()
     country_map = MapChart(440, 220)
     items = data.countries.counts()
     country_map.set_codes([country_code for count, (country_name, country_code) in items])
     country_map.add_data([count for count, (country_name, country_code) in items])
     country_map.set_colours(('EEEEEE', '9999FF', '000033'))
     v['country_map_url'] = country_map.get_url()
     return v