def GET(self): user_data = web.input() prd = user_data.product pg = user_data.data from pygal.maps.world import World wm = World(height=400) wm.force_uri_protocol = 'http' wm.title = "產品 " + prd + " 的 " + pg + " 在全球即時分佈的狀態" d = getlist(prd, pg) i = 0 for item in d: x = {} x[incl.countrycode[item[0]]] = item[1] wm.add(str(i + 1) + ". " + item[0], x) i = i + 1 #wm.render_to_file("static/map.svg") wm.disable_xml_declaration = True return '<html>\n <head>\n <title>全球即時分佈圖</title>\n<meta http-equiv="content-type" content="text/html;charset=utf-8"><meta http-equiv="refresh" content="30" />\n<script type="text/javascript" src="http://kozea.github.com/pygal.js/latest/pygal-tooltips.min.js"></script>\n</head>\n<body>\n' + wm.render( is_unicode=True) + '\n </body>\n</html>'
def conlanger_map(): foo = dict([(country.iso.lower(), country.count) for country in country_most_common()]) custom_style = Style(background='#fff', plot_background='#fff', foreground='#ffffff', foreground_light='#ffffff', foreground_dark='#ffffff', opacity='.6', opacity_hover='.9', transition='400ms ease-in', colors=('#527C3A', '#E8537A', '#E95355', '#E87653', '#E89B53')) chart = Worldmap(style=custom_style) chart.no_prefix = True chart.disable_xml_declaration = True chart.show_legend = False chart.add('Conlangers', foo) return chart.render()
def conlanger_map(): foo = dict([(country.iso.lower(), country.count) for country in country_most_common()]) custom_style = Style( background='#fff', plot_background='#fff', foreground='#ffffff', foreground_light='#ffffff', foreground_dark='#ffffff', opacity='.6', opacity_hover='.9', transition='400ms ease-in', colors=('#527C3A', '#E8537A', '#E95355', '#E87653', '#E89B53') ) chart = Worldmap(style=custom_style) chart.no_prefix = True chart.disable_xml_declaration = True chart.show_legend = False chart.add('Conlangers', foo) return chart.render()