Ejemplo n.º 1
0
 def gauge(self, title=None, index=None, accomplish=None, rate=None):
     """
     :param title: 数据可视化的标题(字符串)
     :param index: 业务指标(字符串)
     :param accomplish: 完成率(字符串)
     :param rate: 百分比(int类型)
     :return: 仪表盘
     """
     gauge = Gauge(title)
     gauge.add(index, accomplish, rate)
     self.page.add(gauge)
     self.page.render()
Ejemplo n.º 2
0
def test_gauage_label_setting(fake_writer):
    c = Gauge().add(
        "",
        [("完成率", 66.6)],
        detail_label_opts=opts.LabelOpts(formatter="{value}"),
        title_label_opts=opts.LabelOpts(font_size=40,
                                        color="blue",
                                        font_family="Microsoft YaHei"),
    )
    c.render()
    _, content = fake_writer.call_args[0]
    assert_in("title", content)
    assert_in("detail", content)
Ejemplo n.º 3
0
def index_gauge() -> Gauge:
    # date_list = get_recent_date(7)
    # #分别记录全部事件数目和完成事件数目
    # all_event_count = 0
    # done_event_count = 0
    # for date in date_list:
    #     format_date = date.strftime('%Y-%m-%d')
    #     sql = Event.objects.filter(create_time=format_date).values('achieve').annotate(count=Count('achieve')).values('achieve','count').order_by('achieve')
    #     achieve = list(sql)
    #     # print(achieve[0]['count'])
    # all_event_count = all_event_count + achieve[0]['count'] + achieve[1]['count']
    # done_event_count = done_event_count + achieve[0]['count']

    # done_percent = (done_event_count/all_event_count)
    done_percent = 0.85
    done_percent = round(done_percent*100,1)

    c = (
        Gauge()
        .add("",
             [("", done_percent)],
             radius="100%",
             # title_label_opts=opts.LabelOpts(
             #     font_size=10, font_family="Microsoft YaHei"
             # ),
        )

        .dump_options_with_quotes()
    )
    return c
Ejemplo n.º 4
0
def temp_gauge() -> Gauge:
    (time_list_res, value_list_res) = data_reader(1)
    data = value_list_res[-1]
    c = (
        Gauge().add(
            "温度传感器TS01", [("温度传感器TS01", data)],
            split_number=5,
            max_=60,
            axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(
                color=[(0.3, "#fcde97"), (0.7, "#74b9ed"), (1, "#f9a9af")],
                width=25,
            )),
            detail_label_opts=opts.LabelOpts(formatter="{value}Mpa",
                                             font_size=15),
            title_label_opts=opts.GaugeTitleOpts(is_show=False,
                                                 color="#9966FF")).
        set_global_opts(
            # title_opts=opts.TitleOpts(title="实时气压", title_textstyle_opts=opts.TextStyleOpts(color="#36404e"),
            #                           pos_top=5, pos_left=8),
            legend_opts=opts.LegendOpts(
                is_show=False,
                selected_mode=False,
                item_height=15,
                pos_bottom=0,
                textstyle_opts=opts.TextStyleOpts(
                    color="#36404e")), ).dump_options_with_quotes())

    # print("Gauge done >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
    return c
Ejemplo n.º 5
0
def gauge1() -> Timeline:
    timeline3 = Timeline(init_opts=opts.InitOpts(
        width="270px", height="180px", bg_color="black"))
    for i in range(len(Grid)):
        b = batteryenergy[i] / 900 * 100

        gauge0 = (Gauge(init_opts=opts.InitOpts(
            width="270px", height="180px", bg_color="black")).add(
                series_name="grid",
                data_pair=[["", round(b, 1)]],
                max_=100,
                min_=0,
                start_angle=210,
                split_number=5,
                end_angle=-30,
                axisline_opts=opts.AxisLineOpts(
                    linestyle_opts=opts.LineStyleOpts(color=[(
                        0.3, "#67e0e3"), (0.7, "#37a2da"), (1, "#fd666d")],
                                                      width=20)),
                detail_label_opts=opts.LabelOpts(formatter="{value}%",
                                                 font_size=12),
                radius="80%").set_global_opts(
                    legend_opts=opts.LegendOpts(is_show=False),
                    tooltip_opts=opts.TooltipOpts(
                        is_show=True, formatter="{a} <br/>{b} : {c}%"),
                    title_opts=opts.TitleOpts(
                        "Percentage of battery energy at time {}".format(
                            time[i]),
                        title_textstyle_opts=opts.TextStyleOpts(
                            color="white", font_size=10.5))))
        timeline3.add(gauge0, "{}年".format(i)).add_schema(
            is_timeline_show=True).add_schema(play_interval=2000,
                                              is_auto_play=True,
                                              is_timeline_show=False)
    return timeline3
Ejemplo n.º 6
0
def memory_liquid() -> Gauge:
    mtotal, mused, mfree, stotal, sused, sfree, mpercent = memory()
    c = (
        Gauge()
            .add("", [("", mpercent)])
            .set_global_opts(title_opts=opts.TitleOpts(title="内存负载", pos_left="center"))
    )
    return mtotal, mused, mfree, stotal, sused, sfree, c
Ejemplo n.º 7
0
def gauge_label_title_setting() -> Gauge:
    c = (Gauge().add(
        "",
        [("完成率", 66.6)],
        title_label_opts=opts.LabelOpts(font_size=40,
                                        color="blue",
                                        font_family="Microsoft YaHei"),
    ).set_global_opts(title_opts=opts.TitleOpts(title="Gauge-改变轮盘内的字体")))
    return c
Ejemplo n.º 8
0
def gauge_base():
    c = (
        Gauge()
        .add('', [('完成率', 66.6)])
        .set_global_opts(title_opts=opts.TitleOpts(title='Gauge-base'),
                         legend_opts=opts.LegendOpts(is_show=False))
    )

    return c
Ejemplo n.º 9
0
def draw(grade):
    grade = (int)((grade) * 100)
    c = (Gauge(init_opts=opts.InitOpts(width="450px", height="250px")).add(
        "恶意可能性评估",
        [("", grade)],
        axisline_opts=opts.AxisLineOpts(
            linestyle_opts=opts.LineStyleOpts(color=[(
                0.2, "#00FF00"), (0.4, "#009900"), (
                    0.6, "#FFFF00"), (0.8, "#FF6600"), (1, "#FF0000")],
                                              width=30)),
    ).render("static/test.html"))
Ejemplo n.º 10
0
def gauge(dados, componente, metrica, temaEscuro=False, abrir_local=False):
    if (temaEscuro):
        gauge = Gauge(init_opts=opts.InitOpts(theme=ThemeType.CHALK))
    else:
        gauge = Gauge(init_opts=opts.InitOpts(theme=ThemeType.VINTAGE))

    gauge.add('', [(componente, dados)], start_angle=190, end_angle=-10,
              title_label_opts=opts.GaugeTitleOpts(font_size=28, color=("white" if temaEscuro else "black")),
              detail_label_opts=opts.GaugeDetailOpts(font_size=36, offset_center=[0, "25%"],
                                                     formatter=(str(dados) + str(metrica)),
                                                     color=("white" if temaEscuro else "black")))
    gauge.set_global_opts(title_opts=opts.TitleOpts(title="Uso de " + componente))

    make_snapshot(driver, gauge.render("chart.html"), "chart.png")

    abrirGrafico(abrir_local)
    return 0
Ejemplo n.º 11
0
def Gauge_shiftA()-> Gauge:
    Data_value= fetch_data.OEE_from_input()
    Data_show='{:0.2f}'.format(Data_value[0]*100)
    b=(
        Gauge()
        .add("OEE_shiftA",[{"",Data_show}],axisline_opts = opts.AxisLineOpts(linestyle_opts= opts.LineStyleOpts(
          color =[(0.5, "red"), (0.8, "yellow"), (1, "green")], width = 20)))
          .set_global_opts(
        tooltip_opts=opts.TooltipOpts(is_show=True, formatter="{a} <br/>{b} : {c}%"),)
        .dump_options_with_quotes()
    )
    return b
Ejemplo n.º 12
0
 def gauge_html(self, chart_id, title, val):
     # 实例化
     gauge = Gauge(self.init_opts)
     # 绑定id
     gauge.chart_id = chart_id
     # 添加参数
     gauge.add("", [("", val)], min_=0, max_=100)
     # 全局参数
     gauge.set_global_opts(
         title_opts=self.title_opts(title),  # 标题选项
         legend_opts=options.LegendOpts(is_show=False),  # 不显示图例组件
     )
     # 返回图表html代码
     return gauge.render_embed()
Ejemplo n.º 13
0
def gauge_color() -> Gauge:
    c = (Gauge().add(
        "业务指标",
        [("完成率", 55.5)],
        axisline_opts=opts.AxisLineOpts(
            linestyle_opts=opts.LineStyleOpts(color=[(
                0.3, "#67e0e3"), (0.7, "#37a2da"), (1, "#fd666d")],
                                              width=30)),
    ).set_global_opts(
        title_opts=opts.TitleOpts(title="Gauge-不同颜色"),
        legend_opts=opts.LegendOpts(is_show=False),
    ))
    return c
Ejemplo n.º 14
0
def show_gauge_image():
    gauge = (Gauge().add(
        "KPI完成率",
        [("已完成", 89.3)],
        axisline_opts=options.AxisLineOpts(
            linestyle_opts=options.LineStyleOpts(color=[(
                0.25, "#548C00"), (0.5, "#FF5809"), (0.75,
                                                     "#FF0080"), (1,
                                                                  "#FF0000")],
                                                 width=20)),
    ).set_global_opts(title_opts=options.TitleOpts(title="仪表盘示例"),
                      legend_opts=options.LegendOpts(is_show=True)))
    gauge.render("gauge.html")
Ejemplo n.º 15
0
def get_today_confirm_gauge():
    today_confirm_dict = get_api.get_today_confirm_dict(api_url)  #分省统计当日确诊患者字典
    today_confirm_gauge = (  #今日确诊仪表盘
        Gauge().add(series_name="今日确诊",
                    data_pair=[["今日确诊", int(today_confirm_dict['中国'])]],
                    detail_label_opts=opts.LabelOpts(
                        formatter="{value}人")).set_global_opts(
                            legend_opts=opts.LegendOpts(is_show=False),
                            tooltip_opts=opts.TooltipOpts(
                                is_show=False,
                                formatter="{a} <br/>{b} : {c}人"),
                        ))
    today_confirm_gauge.chart_id = 'todayconfirmgauge'
    return today_confirm_gauge
Ejemplo n.º 16
0
def get_today_no_infect_gauge():
    today_no_infect_num = get_api.get_today_no_infect_num(api_url)  #获取当日无症状感染者
    today_no_infect_gauge = (  #今日无症状仪表
        Gauge().add(series_name="今日无症状",
                    data_pair=[["今日无症状", int(today_no_infect_num)]],
                    detail_label_opts=opts.LabelOpts(
                        formatter="{value}人")).set_global_opts(
                            legend_opts=opts.LegendOpts(is_show=False),
                            tooltip_opts=opts.TooltipOpts(
                                is_show=False,
                                formatter="{a} <br/>{b} : {c}人"),
                        ))
    today_no_infect_gauge.chart_id = 'todaynoinfectgauge'
    return today_no_infect_gauge
Ejemplo n.º 17
0
def gauge_splitnum_label() -> Gauge:
    c = (Gauge().add(
        "业务指标",
        [("完成率", 55.5)],
        split_number=5,
        axisline_opts=opts.AxisLineOpts(
            linestyle_opts=opts.LineStyleOpts(color=[(
                0.3, "#67e0e3"), (0.7, "#37a2da"), (1, "#fd666d")],
                                              width=30)),
        detail_label_opts=opts.LabelOpts(formatter="{value}"),
    ).set_global_opts(
        title_opts=opts.TitleOpts(title="Gauge-分割段数-Label"),
        legend_opts=opts.LegendOpts(is_show=False),
    ))
    return c
Ejemplo n.º 18
0
def gauge_color():
    c = (
        Gauge()
        .add('指标', [('完成率', 55.5)],
             axisline_opts=opts.AxisLineOpts(
                 linestyle_opts=opts.LineStyleOpts(
                     color=[(0.3, '#67e0e3'), (0.7, '#37a2da'), (1, '#fd666d')], width=30
                 )
             ))
        .set_global_opts(
            title_opts=opts.TitleOpts(title='Gauge-diff color'),
            legend_opts=opts.LegendOpts(is_show=False)
        )
    )

    return c
Ejemplo n.º 19
0
def gaugegauge_base_color(data, width, height) -> Gauge:
    c = (
        Gauge(init_opts=opts.InitOpts(width="{}px".format(width), height="{}px".format(height)), )
            .add(
            "整体通过率",
            [("", data)],
            axisline_opts=opts.AxisLineOpts(
                linestyle_opts=opts.LineStyleOpts(
                    color=[(0.3, "#fd666d"), (0.7, "#37a2da"), (1, "#67e0e3")], width=30
                )
            ),
        )
            .set_global_opts(legend_opts=opts.LegendOpts(is_show=False),
                             toolbox_opts=opts.ToolboxOpts(orient='vertical', pos_left='right'))
    )
    return c
Ejemplo n.º 20
0
def gauge_color(x) -> Gauge:

    c1 = (Gauge().add(
        "",
        [("高峰概率", x)],
        axisline_opts=opts.AxisLineOpts(
            linestyle_opts=opts.LineStyleOpts(color=[(
                0.3, "#67e0e3"), (0.7, "#37a2da"), (1, "#fd666d")],
                                              width=30)),
    ).set_global_opts(
        title_opts=opts.TitleOpts(title="警告:预计下周香港出现高峰自杀行为的概率"),
        legend_opts=opts.LegendOpts(is_show=False),
    ))

    #c.render('warning.html')
    return c1
Ejemplo n.º 21
0
def gauge_splitnum_label():
    c = (
        Gauge()
        .add('指标', [('完成率',55.5)], split_number=5,
             axisline_opts=opts.AxisLineOpts(
                 linestyle_opts=opts.LineStyleOpts(
                     color=[(0.3, '#67e0e3'), (0.7, '#37a2da'), (1, '#fd666d')], width=30
                 )
             ),
             label_opts=opts.LabelOpts(formatter='{value}'))
        .set_global_opts(
            title_opts=opts.TitleOpts(title='Gauge-splitnum'),
            legend_opts=opts.LegendOpts(is_show=False)
        )
    )

    return c
Ejemplo n.º 22
0
    def gauge_html(self, chart_id, title, val):
        gauge = Gauge(init_opts=opts.InitOpts(width="100%", height="300px"))
        gauge.set_global_opts(
            title_opts=opts.TitleOpts(
                title="{}-{}".format(self.dt, title),
                title_textstyle_opts=opts.TextStyleOpts(color="white", font_size=14),
                pos_left="center"
            ),
            legend_opts=opts.LegendOpts(is_show=False),
        )
        # 绑定id
        gauge.chart_id = chart_id
        gauge.add(
            series_name="",
            data_pair=[["", val]],
            title_label_opts=opts.LabelOpts(color="white"),
        )

        return gauge.render_embed()  # 返回图表html代码
Ejemplo n.º 23
0
def get_gauge(data_y: list, gauge_name=""):
    gauge = Gauge()
    gauge.add(
        gauge_name,
        [(gauge_name, (sum(data_y) * 100) / (len(data_y) * max(data_y)))],
        axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(
            color=[(0.3, "#67e0e3"), (0.7, "#37a2da"), (1, "#fd666d")],
            width=30), ),
    )
    gauge.set_global_opts(
        # title_opts=opts.TitleOpts(title=gauge_name),
        legend_opts=opts.LegendOpts(is_show=False), )
    return gauge
Ejemplo n.º 24
0
def qiya() -> Gauge:
    c = (
        Gauge()
            .add(
            "实时气压",
            [("校园实时气压/hP", 1006)],
            min_=950,
            max_=1050,
            split_number=10,
            axisline_opts=opts.AxisLineOpts(
                linestyle_opts=opts.LineStyleOpts(
                    color=[(0.3, "#67e0e3"), (0.7, "#37a2da"), (1, "#fd666d")], width=30
                )
            ),
            detail_label_opts=opts.LabelOpts(formatter="{value}"),
        )
            .set_global_opts(
            title_opts=opts.TitleOpts(title="实验中学气象站--气压监测"),
            legend_opts=opts.LegendOpts(is_show=False),
        )

    )
    return c
Ejemplo n.º 25
0
    def getGauge(self, sheet: xlrd.sheet) -> Gauge:
        key = sheet.cell(0, 0).value
        value = sheet.cell(0, 1).value
        g = Gauge()
        g.add(
            series_name=sheet.name,
            data_pair=[(key, value)],
            title_label_opts=opts.LabelOpts(font_size=40,
                                            color="blue",
                                            font_family="Microsoft YaHei"),
        )  #改标题字体颜色

        g.set_global_opts(
            legend_opts=opts.LegendOpts(is_show=False),
            #tooltip_opts=opts.TooltipOpts(is_show=True, formatter="{a} <br/>{b} : {c}%",textstyle_opts=opts.TextStyleOpts(color="#fff")),#图例颜色和显示格式
            title_opts=opts.TitleOpts(title=sheet.name)  #加上图标题
        )
        return g
Ejemplo n.º 26
0
def gauge():
    '''
    销售额仪表盘
    :return:
    '''
    df1['sale_account'] = df1['price'] * df1['sale']
    sale_account = df1['sale_account'].sum()

    c = (
        Gauge(init_opts=opts.InitOpts(theme=ThemeType.DARK,chart_id=3))
            .add(
            "业务指标",
            [("", float(sale_account))],
            split_number=5,
            detail_label_opts=opts.LabelOpts(formatter="{value}"),
            max_=100000
        )
            .set_global_opts(
            title_opts=opts.TitleOpts(title="销售额完成情况",
                                      ),
            legend_opts=opts.LegendOpts(is_show=False),
        )
    )
    return c
Ejemplo n.º 27
0
def NPS(NPS_List):
    Item = NPS_List[0]
    nps = NPS_List[1]
    laber = str(NPS_List[1]) + '%'
    gauge =Gauge(
            init_opts=opts.InitOpts(
                width='400px',
                height='300px'
            )
        )
    gauge.add(
        series_name=Item,
        data_pair=[('NPS',nps)],
        min_=-100,
        max_=100,
        split_number=4,
        axisline_opts=opts.AxisLineOpts(
            linestyle_opts=opts.LineStyleOpts(
                color=[[0.5, "#37a2da"], [1, "#fd666d"]],
                width=30
            )
        ),
        itemstyle_opts=opts.ItemStyleOpts(
            color='rgba(212,105,105,1)'
        ),
        detail_label_opts=opts.LabelOpts(
            font_size=20,
            position='bottom',
            formatter=laber
        )
    )
    gauge.set_global_opts(
        title_opts=opts.TitleOpts(
            subtitle='NPS-' + Item,
            pos_right='center',
            subtitle_textstyle_opts=opts.TextStyleOpts(
                color='rgba(0,0,0,0.8)',
                font_size=16
            )
        ),
        legend_opts=opts.LegendOpts(is_show=False)
    )
    return gauge
Ejemplo n.º 28
0
def BG():
    gauge =Gauge(
            init_opts=opts.InitOpts(
                bg_color={"type": "pattern", "image": JsCode("img"), "repeat": "no-repeat"},
                width='1200px',
                height='300px'
            )
        )
    gauge.set_global_opts(
        title_opts=opts.TitleOpts(
            title='碧桂园集中式商业消费者满意度研究',
            pos_left='center',
            title_textstyle_opts=opts.TextStyleOpts(
                color='rgba(0,0,0,0.8)',
                font_size=20
            )
        )
    )
    gauge.add_js_funcs("var img = new Image(); img.src = 'https://s1.ax1x.com/2020/03/27/GPWPKI.jpg';")
    return gauge
Ejemplo n.º 29
0
import pyecharts.options as opts
from pyecharts.charts import Gauge
"""
Gallery 使用 pyecharts 1.1.0
参考地址: https://echarts.apache.org/examples/editor.html?c=gauge

目前无法实现的功能:

1、暂无
"""

(Gauge().add(series_name="业务指标", data_pair=[["完成率", 55.5]]).set_global_opts(
    legend_opts=opts.LegendOpts(is_show=False),
    tooltip_opts=opts.TooltipOpts(is_show=True,
                                  formatter="{a} <br/>{b} : {c}%"),
).render("gauge.html"))
Ejemplo n.º 30
0
def test_gauge_base():
    c = Gauge().add("", [("完成率", 66.6)])
    eq_(c.theme, "white")
    eq_(c.renderer, "canvas")
    c.render()