def getChartStyle(screenWidth=1900): custom_style = Style(value_colors='blue', plot_background='#FBFBFC', font_family='googlefont:Barlow') if (screenWidth <= 700): custom_style.value_font_size = 35 custom_style.title_font_size = 35 custom_style.tooltip_font_size = 35 elif (screenWidth <= 990): custom_style.value_font_size = 35 custom_style.title_font_size = 35 custom_style.tooltip_font_size = 35 elif (screenWidth <= 1400): custom_style.value_font_size = 35 custom_style.title_font_size = 35 custom_style.tooltip_font_size = 35 else: custom_style.value_font_size = 35 custom_style.title_font_size = 35 custom_style.tooltip_font_size = 35 return custom_style
for i in dic: known_data_country_list.append(i) dic_country_code_with_no_data = {} dic_country_code_with_data = {} for i in a: if a[i].split(',')[0] in known_data_country_list: if len(dic[a[i].split(',')[0]]) != 0: dic_country_code_with_data[i] = float(dic[a[i].split(',')[0]]) else: dic_country_code_with_no_data[i] = '?' import pygal.maps.world from pygal.style import Style custom_style = Style( colors = ('#B22222', '#A9A9A9') ) custom_style.legend_font_size = 10 custom_style.tooltip_font_size = 8 worldmap_chart = pygal.maps.world.World(style = custom_style) worldmap_chart.title = 'CO2 emissions in 2011' worldmap_chart.add('Known data', dic_country_code_with_data) worldmap_chart.add('No data', dic_country_code_with_no_data) worldmap_chart.render_to_file('CO2_emissions.svg')