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 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.º 3
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.º 4
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.º 5
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.º 6
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.º 7
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.º 8
0
from pyecharts.charts import Funnel
data = 
funnel = Funnel()
funnem.add('',data)
funne.render()

#==============================================================================

# 仪表盘

from pyecharts.charts import Gauge
gauge = Gauge()
gauge.add('',[('完成率',60)],
              # 不同颜色
              axisline_opts=opts.AxisLineOpts(
                linestyle_opts=opts.LineStyleOpts(
                    color=[(0.6, "#67e0e3"), (1, "#37a2da")], width=30
                )))
gauge.render(r'D:\PythonSpyder\数据可视化\My PyEcharts\仪表盘(不同颜色).html')

#==============================================================================

# 水球图
from pyecharts.charts import Liquid
liquid = Liquid()
liquid.add('',[0.6])
liquid.render(r'D:\PythonSpyder\数据可视化\My PyEcharts\水球图.html')



Ejemplo n.º 9
0
calendar.set_global_opts(
    visualmap_opts=opts.VisualMapOpts(min_=10, max_=2500, pos_top="center"))
calendar.render_notebook()

# %% [markdown]
# ### Funnel -- 漏斗图

funnel = Funnel()
funnel.add("", list(zip(*[Faker.choose(), Faker.values()])))
funnel.render_notebook()

# %% [markdown]
# ### Gauge -- 仪表盘图

gauge = Gauge()
gauge.add("", [["OK", 75]])
gauge.render_notebook()

# %% [markdown]
# ### Liquid -- 水球图

# Liquid().add("", [0.6, 0.66]).render_notebook()
liquid_1 = Liquid().add("", [0.6, 0.65], center=["20%", "50%"])
liquid_2 = Liquid().add("", [0.3, 0.4], shape="rect", center=["80%", "50%"])
grid = Grid()
grid.add(liquid_1, grid_opts=opts.GridOpts()).add(liquid_2,
                                                  grid_opts=opts.GridOpts())
grid.render_notebook()

# %% [markdown]
# ### Parallel -- 趋势变化图
Ejemplo n.º 10
0
        radius=[40, 75],
        label_text_color=None,
        is_label_show=True,
        legend_orient="vertical",
        legend_pos="left")
pie.render(r".\my_first_Huanxing.html")
"""散点图"""
v1 = [10, 20, 30, 40, 50, 60]
v2 = [10, 20, 30, 40, 50, 60]
scatter = Scatter("散点图示例")
scatter.add("A", v1, v2)
scatter.add("B", v1[::-1], v2)
scatter.render(r".\my_first_Sandian.html")
"""仪表盘"""
gauge = Gauge("业务指标完成率—仪表盘")
gauge.add("业务指标", "完成率", 66.66)
gauge.render(r".\my_first_Yibiaopan.html")
"""热力图"""
x_axis = [
    "12a",
    "1a",
    "2a",
    "3a",
    "4a",
    "5a",
    "6a",
    "7a",
    "8a",
    "9a",
    "10a",
    "11a",