예제 #1
0
def get_total_confirm_map():
    total_confirm_dict = get_api.get_total_confirm_dict(api_url)  #分省统计确诊患者总数字典
    total_confirm_list = [[x, total_confirm_dict[x]]
                          for x in list(total_confirm_dict)]  #分省统计确诊患者总数列表
    data_update_time = get_api.get_data_update_time(api_url)  #api数据更新时间
    total_confirm_map = (  #全国确诊统计图
        Map(init_opts=opts.InitOpts()).add(
            "确诊患者", total_confirm_list, "china").set_global_opts(
                title_opts=opts.TitleOpts(
                    title="各省累计确诊患者数",
                    subtitle="数据更新时间:{}".format(data_update_time),
                    pos_right="center",
                    pos_top="5%",
                    title_link='/now_page/',
                    title_target='self'),
                visualmap_opts=opts.VisualMapOpts(max_=1500),
                legend_opts=opts.LegendOpts(is_show=False)))
    total_confirm_map.chart_id = 'totalconfirmmap'
    return total_confirm_map
예제 #2
0
def get_total_death_rate_bar():
    death_rate_dict = get_api.get_death_rate_dict(api_url)  #分省死亡率字典
    data_update_time = get_api.get_data_update_time(api_url)  #api数据更新时间
    total_death_rate_bar = (  #各省死亡率图
        Bar().add_xaxis(list(death_rate_dict.keys())[1:]).add_yaxis(
            "死亡率%", [float(x) for x in death_rate_dict.values()][1:],
            color='red').set_global_opts(
                xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(
                    rotate=-60)),
                title_opts=opts.TitleOpts(
                    title="各省新冠肺炎患者死亡率(%)",
                    subtitle="数据更新时间:{}".format(data_update_time),
                    pos_top="0%",
                    pos_left='center'),
                yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(
                    formatter="{value}%")),
                legend_opts=opts.LegendOpts(is_show=False)).set_series_opts(
                    label_opts=opts.LabelOpts(is_show=False)))
    total_death_rate_bar.chart_id = 'totaldeathratebar'
    return total_death_rate_bar
예제 #3
0
def get_now_confirm_map():
    now_confirm_dict = get_api.get_now_confirm_dict(api_url)  #分省剩余确诊患者字典
    now_confirm_list_with_all_province = [[x, now_confirm_dict[x]]
                                          for x in list(now_confirm_dict)
                                          ]  #分省剩余确诊患者列表
    data_update_time = get_api.get_data_update_time(api_url)  #api数据更新时间
    now_confirm_map = (  #全国剩余确诊统计图
        Map(init_opts=opts.InitOpts()).add(
            "确诊患者", now_confirm_list_with_all_province,
            "china").set_global_opts(
                title_opts=opts.TitleOpts(
                    title="当前各省确诊患者数",
                    subtitle="数据更新时间:{}".format(data_update_time),
                    pos_right="center",
                    pos_top="5%",
                    title_link='/',
                    title_target='self'),
                visualmap_opts=opts.VisualMapOpts(max_=50),
                legend_opts=opts.LegendOpts(is_show=False)))
    now_confirm_map.chart_id = 'nowconfirmmap'
    return now_confirm_map
예제 #4
0
def get_national_death_rate_liquid():
    death_rate_dict = get_api.get_death_rate_dict(api_url)  #分省死亡率字典
    data_update_time = get_api.get_data_update_time(api_url)  #api数据更新时间
    national_death_rate_liquid = (  #全国死亡率liquid图
        Liquid(init_opts=opts.InitOpts(width="400px", height="400px")).add(
            "死亡率", [float(death_rate_dict['中国']) / 100],
            is_outline_show=False,
            center=["35%", "40%"],
            label_opts=opts.LabelOpts(
                font_size=50,
                formatter=JsCode("""function (param) {
                            return (Math.floor(param.value * 10000) / 100) + '%';
                        }"""),
                position="inside")).set_global_opts(title_opts=opts.TitleOpts(
                    title="新冠肺炎全国死亡率",
                    title_link='/death_page/',
                    title_target='self',
                    subtitle="数据更新时间:{}".format(data_update_time),
                    pos_left="15%",
                    pos_top="0%")))
    national_death_rate_liquid.chart_id = 'nationaldeathrateliquid'
    return national_death_rate_liquid
예제 #5
0
def get_now_confirm_pie():
    now_confirm_dict = get_api.get_now_confirm_dict(api_url)  #分省剩余确诊患者字典
    now_confirm_list = [[x, now_confirm_dict[x]]
                        for x in list(now_confirm_dict)
                        if now_confirm_dict[x] != 0]  #分省剩余确诊患者列表(省略无患者省份)
    data_update_time = get_api.get_data_update_time(api_url)  #api数据更新时间
    now_confirm_pie = (  #当前确诊患者地域分布饼图
        Pie(init_opts=opts.InitOpts(width="400px", height="400px")).add(
            "",
            now_confirm_list[1:],
            center=["45%", "60%"],
        ).set_global_opts(
            title_opts=opts.TitleOpts(
                title="当前确诊患者地域分布",
                subtitle="数据更新时间:{}".format(data_update_time),
                pos_left="30%",
                pos_top="0%"),
            legend_opts=opts.LegendOpts(
                orient="vertical", pos_left="85%",
                pos_top='15%')).set_series_opts(label_opts=opts.LabelOpts(
                    formatter="{b}: {c}")))
    now_confirm_pie.chart_id = 'nowconfirmpie'
    return now_confirm_pie