Beispiel #1
0
def map_visualmap(sumary) -> Map:
    c = (
        Map(init_opts=InitOpts(width="750px", height='1000px')).add(
            "确诊", sumary, "上海", is_map_symbol_show=False,
            label_opts=None).set_global_opts(
                title_opts=TitleOpts(
                    title="分布统计(不含外地来沪和待确认)",
                    subtitle='    市卫健局每日两次发布信息,如未更新,请尝试刷新页面',
                    pos_left='10%',
                    pos_top='top',
                    title_textstyle_opts=TextStyleOpts(font_size=40),
                    subtitle_textstyle_opts=TextStyleOpts(font_size=20),
                ),
                visualmap_opts=VisualMapOpts(
                    max_=70,
                    range_color=['lightblue', 'yellow', 'red'],
                    pos_top='15%',
                    pos_left='12%',
                    item_height='200px',
                    item_width='30px',
                    textstyle_opts=TextStyleOpts(font_size=15)
                    # split_number=50
                ),
                legend_opts=LegendOpts(is_show=False),
                tooltip_opts=TooltipOpts(textstyle_opts=TextStyleOpts(
                    font_size=30)),
            ))
    return c
Beispiel #2
0
def working_analysis(title_list, working_list, leave_list, other_list):
    bar = (Bar(
        init_opts=InitOpts(page_title="中软汇丰业务线返工人数分析", width="1000px")
    ).add_xaxis(title_list).add_yaxis(
        "返工人数", working_list, stack="stack1", category_gap="50%").add_yaxis(
            "休假人数", leave_list, stack="stack1", category_gap="50%").add_yaxis(
                "其他人数", other_list, stack="stack1",
                category_gap="50%").set_series_opts(label_opts=LabelOpts(
                    is_show=False)).set_global_opts(
                        toolbox_opts=ToolboxOpts(is_show=True),
                        title_opts=TitleOpts(title="业务线返工情况数据统计"),
                        legend_opts=LegendOpts(),
                        xaxis_opts=AxisOpts(axislabel_opts=LabelOpts(
                            rotate=45)),
                    ).render("开工情况_bar.html"))

    line = (Line(
        init_opts=InitOpts(page_title="中软汇丰业务线返工人数分析", width="1000px")
    ).add_xaxis(title_list).add_yaxis("返工人数", working_list).add_yaxis(
        "休假人数", leave_list).add_yaxis("其他人数", other_list).set_global_opts(
            toolbox_opts=ToolboxOpts(is_show=True),
            title_opts=TitleOpts(title="业务线返工情况数据统计"),
            legend_opts=LegendOpts()).render("开工情况_line.html"))
Beispiel #3
0
def new_trend(day, newconfirmed, newpending) -> Line:
    line = (
        Line(init_opts=InitOpts()).add_xaxis(day).add_yaxis(
            '新确诊',
            newconfirmed,
            symbol_size=1,
            # symbol='diamond',color='red',
            # is_symbol_show = False,
            itemstyle_opts=ItemStyleOpts(color='red'),
            label_opts=LabelOpts(font_size=15,
                                 color='darkred',
                                 position='inside'),
            linestyle_opts=LineStyleOpts(width=2, color='red'),
            is_connect_nones=True,
            is_smooth=True,
        )
        # .add_yaxis(
        #     '新疑似',newpending,symbol_size=1,
        #     # symbol='triangle',color='blue',
        #     itemstyle_opts=ItemStyleOpts(color='blue'),
        #     label_opts=LabelOpts(font_size=15,color='darkblue',position='inside'),
        #     linestyle_opts=LineStyleOpts(width=2,color='blue'),
        #     is_connect_nones=True,is_smooth=True,
        #     )
        .set_global_opts(
            xaxis_opts=AxisOpts(
                # type_="category",
                axislabel_opts=LabelOpts(is_show=False), ),
            yaxis_opts=AxisOpts(
                # grid_index=1,
                # is_scale=True,
                # split_number=2,
                axislabel_opts=LabelOpts(is_show=False),
                # axisline_opts=AxisLineOpts(is_show=False),
                axistick_opts=AxisTickOpts(is_show=False),
                # splitline_opts=SplitLineOpts(is_show=False),
            ),
            legend_opts=LegendOpts(pos_top='top',
                                   pos_left='55%',
                                   textstyle_opts=TextStyleOpts(font_size=30),
                                   orient='horizontal',
                                   legend_icon='rect'),
        ))
    return line
Beispiel #4
0
                  max_=1,
                  orient="horizontal",
                  pos_right="middle",
                  pos_top="bottom")
}

# pie_opts = {
#     "tooltip_opts": TooltipOpts(),
#     "legend_opts": LegendOpts(orient="vertical", pos_left="left"),
# }

themeriver_opts = {
    "xaxis_opts": AxisOpts(type_="time"),
    "datazoom_opts": [DataZoomOpts(range_start=60, range_end=100)],
    "tooltip_opts": TooltipOpts(trigger_on="mousemove", trigger="item"),
    "legend_opts": LegendOpts(pos_top="top"),
}


def xnpv(rate, cashflows):
    """
    give the current cash value based on future cashflows

    :param rate: float, the preset year rate
    :param cashflows: a list, in which each element is a tuple of the form (date, amount),
        where date is a datetime object and amount is an integer or floating number.
        Cash outflows (investments) are represented with negative amounts,
        and cash inflows (returns) are positive amounts.
    :returns: a single float value which is the NPV of the given cash flows
    """
    chron_order = sorted(cashflows, key=lambda x: x[0])
Beispiel #5
0
def total_trend(day, shdeath, shcured, shsum, shpending) -> Line:
    line = (
        Line(init_opts=InitOpts()).add_xaxis(day)
        # .add_yaxis("全国死亡",y_axis=death,is_connect_nones=True,is_smooth=True)
        .add_yaxis('死亡',
                   shdeath,
                   symbol_size=10,
                   color='black',
                   itemstyle_opts=ItemStyleOpts(color='black'),
                   label_opts=LabelOpts(is_show=False),
                   areastyle_opts=AreaStyleOpts(opacity=0.5, color='black'),
                   stack=1,
                   is_connect_nones=True,
                   is_smooth=True).add_yaxis(
                       '治愈',
                       shcured,
                       symbol_size=10,
                       color='LimeGreen',
                       itemstyle_opts=ItemStyleOpts(color='LimeGreen'),
                       label_opts=LabelOpts(font_size=15, color='ForestGreen'),
                       areastyle_opts=AreaStyleOpts(opacity=0.5,
                                                    color='LimeGreen'),
                       is_connect_nones=True,
                       is_smooth=True).
        add_yaxis(
            '确诊',
            shsum,
            symbol_size=10,
            color='Orange',
            itemstyle_opts=ItemStyleOpts(color='Orange'),
            label_opts=LabelOpts(font_size=15,
                                 color='DarkOrange',
                                 font_weight='bold'),
            areastyle_opts=AreaStyleOpts(opacity=0.5, color='Orange'),
            stack=1,
            is_connect_nones=True,
            is_smooth=True).add_yaxis(
                '疑似',
                shpending,
                symbol_size=10,
                color='LightSkyBlue',
                itemstyle_opts=ItemStyleOpts(color='LightSkyBlue'),
                label_opts=LabelOpts(font_size=15, color='DarkBlue'),
                areastyle_opts=AreaStyleOpts(opacity=0.5,
                                             color='LightSkyBlue'),
                stack=1,
                is_connect_nones=True,
                is_smooth=True).set_global_opts(
                    title_opts=TitleOpts(
                        # title=title,
                        # pos_left='10%',
                        # pos_top='-10%',
                    ),
                    # tooltip_opts=TooltipOpts(formatter="{b} {a}\n {c}人"),
                    datazoom_opts=[
                        DataZoomOpts(
                            range_start=60,
                            range_end=100,
                            xaxis_index=[0, 1],
                        ),
                        DataZoomOpts(range_start=60,
                                     range_end=100,
                                     xaxis_index=[0, 1],
                                     type_='inside'),
                    ],
                    xaxis_opts=AxisOpts(name_gap=50),
                    legend_opts=LegendOpts(
                        pos_top='top',
                        pos_left='10%',
                        textstyle_opts=TextStyleOpts(font_size=30),
                        orient='horizontal',
                        legend_icon='rect'),
                    tooltip_opts=TooltipOpts(textstyle_opts=TextStyleOpts(
                        font_size=30)),
                    graphic_opts=GraphicGroup(
                        graphic_item=GraphicItem(left="12%", top="11%"),
                        children=[
                            GraphicRect(
                                graphic_item=GraphicItem(z=0,
                                                         left="center",
                                                         top="middle"),
                                graphic_shape_opts=GraphicShapeOpts(width=150,
                                                                    height=90),
                                graphic_basicstyle_opts=GraphicBasicStyleOpts(
                                    fill="#fff",
                                    stroke="black",
                                    line_width=3,
                                )),
                            GraphicText(
                                graphic_item=GraphicItem(left="center",
                                                         top="middle",
                                                         z=0),
                                graphic_textstyle_opts=GraphicTextStyleOpts(
                                    text=
                                    f"确诊{shsum[-1]}人\n\n疑似{shpending[-1]}人",
                                    font="bolder 20px sans-serif",
                                    graphic_basicstyle_opts=
                                    GraphicBasicStyleOpts(fill="#333")))
                        ])))
    # line.overlap(bar)
    return line
Beispiel #6
0
                trigger_on="mousemove",
                axis_pointer_type="cross"),
}

heatmap_opts = {
    "visualmap_opts":
    VisualMapOpts(min_=-1,
                  max_=1,
                  orient="horizontal",
                  pos_right="middle",
                  pos_top="bottom")
}

pie_opts = {
    "tooltip_opts": TooltipOpts(),
    "legend_opts": LegendOpts(orient="vertical", pos_left="left"),
}

themeriver_opts = {
    "xaxis_opts": AxisOpts(type_="time"),
    "datazoom_opts": [DataZoomOpts(range_start=60, range_end=100)],
    "tooltip_opts": TooltipOpts(trigger_on="mousemove", trigger="item"),
    "legend_opts": LegendOpts(pos_top="top"),
}


def xnpv(rate, cashflows):
    """
    give the current cash value based on future cashflows

    :param rate: float, the preset year rate