Ejemplo n.º 1
0
def test_liquid_grid(fake_writer):
    l1 = (
        Liquid()
        .add("lq", [0.6, 0.7], center=["60%", "50%"])
        .set_global_opts(title_opts=opts.TitleOpts(title="多个 Liquid 显示"))
    )

    l2 = Liquid().add(
        "lq",
        [0.3254],
        center=["25%", "50%"],
        label_opts=opts.LabelOpts(
            font_size=50,
            formatter=JsCode(
                """function (param) {
                        return (Math.floor(param.value * 10000) / 100) + '%';
                    }"""
            ),
            position="inside",
        ),
    )

    c = Grid().add(l1, grid_opts=opts.GridOpts()).add(l2, grid_opts=opts.GridOpts())
    c.render()
    _, content = fake_writer.call_args[0]
    assert_in("center", content)
Ejemplo n.º 2
0
def grid_liquid_favorate_rate() -> Grid:
    l1 = (Liquid().add(
        "好评率",
        [favorate_rate],
        center=["60%", "50%"],
        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="好评率和差评率")))

    l2 = (Liquid().add(
        "差评率",
        [poor_rate],
        center=["25%", "50%"],
        label_opts=opts.LabelOpts(
            font_size=50,
            formatter=JsCode("""function (param) {
                        return (Math.floor(param.value * 10000) / 100) + '%';
                    }"""),
            position="inside",
        ),
    ))

    grid = Grid().add(l2,
                      grid_opts=opts.GridOpts()).add(l1,
                                                     grid_opts=opts.GridOpts())
    return grid
Ejemplo n.º 3
0
def whale_shape_liquid(cate, rate):
    shape = ("path://M367.855,428.202c-3.674-1.385-7.452-1.966-11.146-1"
             ".794c0.659-2.922,0.844-5.85,0.58-8.719 c-0.937-10.407-7."
             "663-19.864-18.063-23.834c-10.697-4.043-22.298-1.168-29.9"
             "02,6.403c3.015,0.026,6.074,0.594,9.035,1.728 c13.626,5."
             "151,20.465,20.379,15.32,34.004c-1.905,5.02-5.177,9.115-9"
             ".22,12.05c-6.951,4.992-16.19,6.536-24.777,3.271 c-13.625"
             "-5.137-20.471-20.371-15.32-34.004c0.673-1.768,1.523-3.423"
             ",2.526-4.992h-0.014c0,0,0,0,0,0.014 c4.386-6.853,8.145-14"
             ".279,11.146-22.187c23.294-61.505-7.689-130.278-69.215-153"
             ".579c-61.532-23.293-130.279,7.69-153.579,69.202 c-6.371,"
             "16.785-8.679,34.097-7.426,50.901c0.026,0.554,0.079,1.121,"
             "0.132,1.688c4.973,57.107,41.767,109.148,98.945,130.793 c58."
             "162,22.008,121.303,6.529,162.839-34.465c7.103-6.893,17.826"
             "-9.444,27.679-5.719c11.858,4.491,18.565,16.6,16.719,28.643 "
             "c4.438-3.126,8.033-7.564,10.117-13.045C389.751,449.992,"
             "382.411,433.709,367.855,428.202z")

    liquid = Liquid()
    # liquid.width = '630px'
    # liquid.height = '350px'
    liquid.add("Liquid", [rate], shape=shape,
               is_outline_show=False).set_global_opts(
                   title_opts=options.TitleOpts(title=cate, pos_left="center"))
    # liquid.add("Liquid", [rate], shape=shape, is_outline_show=False)
    return liquid
Ejemplo n.º 4
0
def liquid_without_outline() -> Liquid:
    c = (
        Liquid()
        .add("lq", [0.6, 0.7, 0.8], is_outline_show=False)
        .set_global_opts(title_opts=opts.TitleOpts(title="Liquid-无边框"))
    )
    return c
Ejemplo n.º 5
0
def liquid_shape_diamond() -> Liquid:
    c = (
        Liquid()
        .add("lq", [0.4, 0.7], is_outline_show=False, shape=SymbolType.DIAMOND)
        .set_global_opts(title_opts=opts.TitleOpts(title="Liquid-Shape-diamond"))
    )
    return c
Ejemplo n.º 6
0
def liquid_shape_arrow() -> Liquid:
    c = (
        Liquid()
        .add("lq", [0.3, 0.7], is_outline_show=False, shape=SymbolType.ARROW)
        .set_global_opts(title_opts=opts.TitleOpts(title="Liquid-Shape-arrow"))
    )
    return c
Ejemplo n.º 7
0
def liquid_shape_rect() -> Liquid:
    c = (
        Liquid()
        .add("lq", [0.3, 0.7], is_outline_show=False, shape=SymbolType.RECT)
        .set_global_opts(title_opts=opts.TitleOpts(title="Liquid-Shape-rect"))
    )
    return c
Ejemplo n.º 8
0
def liquid_base() -> Liquid:
    c = (
        Liquid()
        .add("lq", [0.6, 0.7])
        .set_global_opts(title_opts=opts.TitleOpts(title="Liquid-基本示例"))
    )
    return c
Ejemplo n.º 9
0
def rank_liquid(data) -> Liquid:
    data1 = float(data["line_rank"][:-1]) / 100
    data2 = float(data["note_rank"][:-1]) / 100
    data3 = float(data["time_rank"][:-1]) / 100
    l1 = (Liquid(init_opts=opts.InitOpts(chart_id="代码行数")).add(
        "line_rank",
        [data1],
        center=["15%", "50%"],
        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="user_id:" + k + "的代码行数、注释行数、时间复杂度排名显示", pos_top=60)))

    l2 = Liquid().add(
        "note_rank",
        [data2],
        center=["50%", "50%"],
        label_opts=opts.LabelOpts(
            font_size=50,
            formatter=JsCode("""function (param) {
                        return (Math.floor(param.value * 10000) / 100) + '%';
                    }"""),
            position="inside",
        ),
    )
    l3 = Liquid().add(
        "time_rank",
        [data3],
        center=["85%", "50%"],
        label_opts=opts.LabelOpts(
            font_size=50,
            formatter=JsCode("""function (param) {
                        return (Math.floor(param.value * 10000) / 100) + '%';
                    }"""),
            position="inside",
        ),
    )

    grid = Grid().add(l1, grid_opts=opts.GridOpts()).add(
        l2, grid_opts=opts.GridOpts()).add(l3, grid_opts=opts.GridOpts())
    return grid
Ejemplo n.º 10
0
def liquid_base():
    c = (
        Liquid()
        .add('lq', [0.8,0.6,0.4])
        .set_global_opts(title_opts=opts.TitleOpts('Liquid-base'))
    )

    return c
Ejemplo n.º 11
0
def render_liquid_py():
    with st.echo("below"):
        c = (
            Liquid()
            .add("lq", [0.6, 0.7])
            .set_global_opts(title_opts=opts.TitleOpts(title="Liquid-基本示例"))
        )
        st_pyecharts(c)
Ejemplo n.º 12
0
def liquid_0():
    l1 = (
        Liquid()
        #.add("年度交易总额", [0.75], center=["80%", "50%"])
        .add(
            "年度交易总额",
            [2005],
            center=["80%", "50%"],
            label_opts=opts.LabelOpts(
                font_size=30,
                formatter=JsCode("""function (param) {
                    return (Math.floor(param.value * 100) / 100) + '亿元';
                }"""),
                position="inside",
            ),
        ).set_global_opts(title_opts=opts.TitleOpts(title="年度关键指标")))

    l2 = Liquid().add(
        "年度交易顾客",
        [247],
        center=["20%", "50%"],
        label_opts=opts.LabelOpts(
            font_size=30,
            formatter=JsCode("""function (param) {
                    return (Math.floor(param.value * 100) / 100) + '人';
                }"""),
            position="inside",
        ),
    )
    l3 = Liquid().add(
        "年度交易次数",
        [5836],
        center=["50%", "50%"],
        label_opts=opts.LabelOpts(
            font_size=30,
            formatter=JsCode("""function (param) {
                    return (Math.floor(param.value * 100) / 100) + '万次';
                }"""),
            position="inside",
        ),
    )

    grid = Grid().add(l1, grid_opts=opts.GridOpts()).add(
        l2, grid_opts=opts.GridOpts()).add(l3, grid_opts=opts.GridOpts())
    return grid
Ejemplo n.º 13
0
def get_average_collateral_rate_picture():
    rate = cdb.get_collateral_rate()
    # rate = Decimal(rate).quantize(Decimal('0.00'))
    c = (Liquid().add(
        "lq",
        [rate]).set_global_opts(title_opts=opts.TitleOpts(title="cdc平均抵押率")))
    #gauge = Gauge()
    #gauge.add("", [("抵押率", rate)], min_=0, max_=4).set_global_opts(title_opts=opts.TitleOpts(title="collateral rate"))
    return c
Ejemplo n.º 14
0
 def liquid_html(self, chart_id, title, val):
     # 实例化
     liquid = Liquid(self.init_opts)
     # 绑定id
     liquid.chart_id = chart_id
     # 添加参数
     liquid.add("", [round(val / 100, 4)])
     # 全局参数
     liquid.set_global_opts(title_opts=self.title_opts(title))
     # 返回图表html代码
     return liquid.render_embed()
Ejemplo n.º 15
0
def progress_chart_01(dic):  #进度图

    c = (
        Liquid(init_opts=opts.InitOpts(width=width, height=height)).add(
            "", [dic['share'], dic['share']]).set_global_opts(
                title_opts=opts.TitleOpts(title=dic["titlename"])).render(
                    "./static/html/%s" % dic['htmlname'])
        #.render_embed()
    )
    return c
Ejemplo n.º 16
0
def Score_plot(score, bit, savepath, path_wkimg):
    # 定义函数
    cLiquid = (Liquid().add(
        "水滴图", [score / 100],
        is_outline_show=False,
        is_animation=False,
        label_opts=opts.LabelOpts(is_show=False,
                                  font_size=50,
                                  position="inside")).set_global_opts())

    cLiquid.render(
        'temp.html'
    )  # 定格,括号内为文件名,注意单引号说明文件名省html后缀,双引号文件名,生成后缀,也可以加入路径,默认为代码.py所在的路径或文件夹。

    #########################将html文件转化成图片
    # https://blog.csdn.net/bobyuan888/article/details/108769274
    cfg = imgkit.config(wkhtmltoimage=path_wkimg)
    # 1、将html文件转为图片
    imgkit.from_file('temp.html', savepath, config=cfg)
    ###################截取部分图片
    # 打开一张图
    img = Image.open(savepath)
    # 图片尺寸
    img_size = img.size
    h = img_size[1]  # 图片高度
    w = img_size[0]  # 图片宽度
    x = 0.25 * w
    y = 0.25 * h
    w = 0.4 * w
    h = 0.6 * h
    # 开始截取
    region = img.crop((x, y, x + w, y + h))
    # 保存图片
    region.save(savepath)
    os.remove('temp.html')
    #######################在图片上添加文字
    bk_img = cv2.imread(savepath)
    # 设置需要显示的字体
    fontpath = "font/simsun.ttc"
    font = ImageFont.truetype(fontpath, 50)
    font2 = ImageFont.truetype(fontpath, 20)
    img_pil = Image.fromarray(bk_img)
    draw = ImageDraw.Draw(img_pil)
    # 绘制文字信息
    draw.text((110, 90), str(score) + '分', font=font, fill=(255, 255, 255))
    draw.text((50, 270),
              '* 设备稳定性击败了' + str(bit) + '%同类设备',
              font=font2,
              fill=(0, 0, 255))
    bk_img = np.array(img_pil)
    ####显示图片
    # cv2.imshow("add_text",bk_img)
    # cv2.waitKey()
    ###保存图片
    cv2.imwrite(savepath, bk_img)
Ejemplo n.º 17
0
def multiple_liquid() -> Grid:
    l1 = (Liquid().add("lq", [0.6, 0.7], center=[
        "60%", "50%"
    ]).set_global_opts(title_opts=opts.TitleOpts(title="多个 Liquid 显示")))

    l2 = (Liquid().add(
        "lq",
        [0.3254],
        center=["25%", "50%"],
        label_opts=opts.LabelOpts(
            font_size=50,
            formatter=JsCode("""function (param) {
                        return (Math.floor(param.value * 10000) / 100) + '%';
                    }"""),
            position="inside",
        ),
    ))

    grid = (Grid().add(l1, grid_opts=opts.GridOpts()).add(
        l2, grid_opts=opts.GridOpts()))
    return grid
Ejemplo n.º 18
0
def liquid_data_precision() -> Liquid:
    c = (Liquid().add(
        "lq",
        [0.3254],
        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="Liquid-数据精度")))
    return c
Ejemplo n.º 19
0
 def liquid_html(self, chart_id, title, val):
     # 基本配置
     liquid = Liquid(init_opts=opts.InitOpts(width="100%", height="300px"))
     liquid.set_global_opts(
         title_opts=opts.TitleOpts(
             title="{}-{}".format(self.dt, title),
             pos_left="center",
             title_textstyle_opts=opts.TextStyleOpts(font_size=14, color="white")
         ),
     )
     # 绑定id
     liquid.chart_id = chart_id
     # 添加参数
     liquid.add("", [round(val / 100, 4)])
     return liquid.render_embed()  # 返回图表html代码
Ejemplo n.º 20
0
def liquid_1() -> Grid:
    l1 = (
        Liquid().add(
            "lq",
            [0.8],
            shape=
            "path:// M1986.296938 695.425728H1276.48679l-200.162853-0.316945h-55.904193c-146.135949 0-183.632961-130.48375-183.632961-275.912669v-62.29185c0-145.136354 37.789576-275.937049 183.632961-275.937049h965.877194c146.16033 0 183.632961 130.800695 183.632961 276.229614v62.31623c0 145.428918-37.472632 275.912669-183.632961 275.912669zM1719.405006 37.692055c0-20.893979 15.237732-37.692055 34.327564-37.692055h206.184805c19.065451 0 34.327564 16.798076 34.327564 37.692055v26.135759H1719.405006V37.692055z m-353.320349 0c0-20.893979 15.262113-37.692055 34.327564-37.692055h206.209185c19.065451 0 34.303183 16.798076 34.303183 37.692055v26.135759H1366.084657V37.692055z m-353.612914 0c0-20.893979 15.262113-37.692055 34.327564-37.692055h206.209185c19.04107 0 34.303183 16.798076 34.303183 37.692055v26.135759H1012.471743V37.692055z m230.662698 684.820266h924.893789v130.508131h-75.262208c0.926454 6.631461 1.560344 13.360444 1.560343 20.235709 0 83.161449-68.630747 150.402514-153.474441 150.402514-84.819314 0-153.450061-67.241066-153.45006-150.402514a145.867765 145.867765 0 0 1 1.487202-20.235709h-34.546987c0.950835 6.728983 1.584724 13.555487 1.584725 20.552653 0 83.161449-68.923311 150.402514-153.450061 150.402515-84.819314 0-153.450061-67.241066-153.450061-150.402515 0-6.997167 0.65827-13.823671 1.584724-20.552653H701.426958v-0.316945H438.972255c0.950835 6.728983 1.609105 13.555487 1.609104 20.552654 0 81.601105-66.412133 148.549606-149.963667 150.402514h-2.535559c-84.819314 0-153.474441-67.241066-153.474441-150.402514 0-6.997167 0.65827-13.823671 1.609105-20.552654H37.208106S1.295819 811.915145 0.028039 761.447775c-0.316945-15.554677 23.844004-28.646937 23.502679-46.395848-0.63389-83.478393-8.874455-285.274732 9.21578-329.183781 13.360444-31.767625 37.692055-62.608795 37.692055-62.608795L326.213035 31.767625h465.128735v690.744696h451.792671zM665.831615 146.282231h-172.613033c-54.465751 0-98.618604 43.665246-98.618604 97.521488v195.042975h271.231637V146.282231z",
            center=["70%", "50%"],
            # outline_itemstyle_opts=opts.ItemStyleOpts(color="#74b9f0"),
            is_outline_show=False,
            label_opts=opts.LabelOpts(font_size=15,
                                      formatter='{@score}m³/h',
                                      position="insideRight",
                                      distance=50,
                                      color="#74b9f0"),
        )
        # .set_global_opts(title_opts=opts.TitleOpts(title="多个 Liquid 显示"))
    )

    l2 = Liquid().add(
        "流量",
        [0.67],
        shape=
        "path:// M1247.085714 916.450743H1126.4v-161.792h80.457143c44.266057 0 80.457143-88.970971 80.457143-202.225372 0-113.225143-36.191086-202.196114-80.457143-202.196114H1126.4V228.907886c0-24.283429-16.091429-40.462629-40.228571-40.462629s-40.228571 16.1792-40.228572 40.462629v40.433371h-120.685714V204.624457l28.145371-28.320914c8.045714-8.074971 12.0832-16.149943 12.0832-28.291657V107.549257c24.137143 0 40.228571-16.149943 40.228572-40.433371 0-24.283429-16.091429-40.433371-40.228572-40.433372H643.657143c-24.137143 0-40.228571 16.1792-40.228572 40.433372 0 24.283429 16.091429 40.433371 40.228572 40.433371V148.041143c0 12.141714 4.008229 20.216686 12.0832 28.291657l28.145371 28.320914v64.7168H563.2V148.011886c0-24.283429-88.502857-40.462629-201.142857-40.462629S160.914286 123.757714 160.914286 148.041143v121.329371H80.457143C36.220343 269.341257 0 394.678857 0 552.433371c0 157.754514 36.220343 283.121371 80.457143 283.121372H160.914286v80.896H40.228571C16.091429 916.450743 0 932.600686 0 956.884114c0 24.283429 16.091429 40.433371 40.228571 40.433372h1206.857143c24.137143 0 40.228571-16.1792 40.228572-40.433372 0-24.283429-16.091429-40.433371-40.228572-40.433371zM965.485714 754.658743h-80.457143v-161.792H965.485714v161.792z m-241.371428 0v-161.792h80.457143v161.792h-80.457143z m-80.457143 0h-80.457143v-161.792H643.657143v161.792z m-80.457143 80.896h482.742857v80.896h-482.742857v-80.896z",
        center=["25%", "50%"],
        is_outline_show=False,
        label_opts=opts.LabelOpts(font_size=15,
                                  formatter='{@score}m³/h',
                                  position="inside",
                                  color="#74b9f0"),
    )

    grid = Grid().add(l1,
                      grid_opts=opts.GridOpts()).add(l2,
                                                     grid_opts=opts.GridOpts())
    ch = grid.dump_options_with_quotes()
    return ch
Ejemplo n.º 21
0
def liquid_data_precision() -> Liquid:
    l1 = (
        Liquid()
            .add("lq", [0.6, 0.7], center=["45%", "50%"])
            .set_global_opts(title_opts=opts.TitleOpts(title="多个 Liquid 显示"))
    )

    l2 = Liquid().add(
        "lq",
        [39],
        center=["15%", "50%"],
        label_opts=opts.LabelOpts(
            font_size=50,
            formatter=JsCode(
                """function (param) {
                        return param.value + '℃';
                    }"""
            ),
            position="inside",
        ),
    )
    l3 = Liquid().add(
        "lq",
        [25],
        center=["75%", "50%"],
        label_opts=opts.LabelOpts(
            font_size=50,
            formatter=JsCode(
                """function (param) {
                        return param.value + '℃';
                    }"""
            ),
            position="inside",
        ),
    )
    grid = Grid().add(l1, grid_opts=opts.GridOpts()).add(l2, grid_opts=opts.GridOpts()).add(l3, grid_opts=opts.GridOpts())
    return grid
Ejemplo n.º 22
0
def liquid() -> Grid:
    l1 = (
        Liquid().add(
            "lq",
            [0.8],
            shape=
            "path:// M128 938.666667v-47.530667h381.866667V863.573333a165.802667 165.802667 0 0 1-142.144-163.648V321.706667h-23.978667v-19.456h-50.069333a42.432 42.432 0 0 0-42.304 42.304V488.810667a93.290667 93.290667 0 0 1 66.666666 89.130666v194.474667a93.12 93.12 0 0 1-68.544 89.6v28.224h-46.933333v-27.733333a93.290667 93.290667 0 0 1-70.4-90.154667v-194.325333a93.290667 93.290667 0 0 1 62.805333-87.893334v-145.493333a98.432 98.432 0 0 1 29.76-70.570667 98.389333 98.389333 0 0 1 68.885334-28.053333h50.069333v-19.2h25.706667a165.802667 165.802667 0 0 1 163.541333-141.312 165.696 165.696 0 0 1 165.269333 165.269333v379.221334h24.96v23.701333h46.4V430.165333a83.456 83.456 0 0 1 83.2-83.2 83.456 83.456 0 0 1 83.2 83.2V784.426667a83.754667 83.754667 0 0 1-70.805333 82.261333v24.64h68.544v47.530667z m714.005333-47.530667v-24.405333a83.498667 83.498667 0 0 1-72.341333-82.496v-84.330667H723.2v24.256h-26.752a165.994667 165.994667 0 0 1-139.648 139.306667v27.733333z",
            center=["70%", "50%"],
            # outline_itemstyle_opts=opts.ItemStyleOpts(color="#74b9f0"),
            is_outline_show=False,
            label_opts=opts.LabelOpts(font_size=15,
                                      formatter='{@score}m³/h',
                                      position="inside",
                                      color="#74b9f0"),
        )
        # .set_global_opts(title_opts=opts.TitleOpts(title="多个 Liquid 显示"))
    )

    l2 = Liquid().add(
        "流量",
        [0.67],
        shape=
        "path:// M1050.615743 622.950934a234.158635 234.158635 0 0 1-5.952372-134.696418c10.336646-68.708294 22.657416-152.713545-84.677292-201.996625 7.072442-26.209638 6.784424-56.48353-15.008938-66.980186l-128.008-62.659916c-27.905744-13.696856-100.838302-10.816676-109.318833 7.20045s-32.002 55.619476 27.745734 69.572348 115.2072 85.157322 115.207201 85.157322a99.2062 99.2062 0 0 0 61.027814 32.002c71.652478 25.6016 67.84424 55.619476 56.931558 125.767861a307.219201 307.219201 0 0 0 11.904744 178.507157c38.658416 88.32552 41.058566 228.590287 7.52047 261.872367a101.190324 101.190324 0 0 1-131.2082 4.48028c-47.170948-32.002-48.003-179.467217-43.746734-272.657041a446.71592 446.71592 0 0 0-10.336646-154.153635 154.057629 154.057629 0 0 0-143.336959-104.454528h-46.466904V39.04244a38.850428 38.850428 0 0 0-38.4024-39.04244H115.229282a38.946434 38.946434 0 0 0-38.4024 39.04244v906.87268H38.424482a37.794362 37.794362 0 0 0-38.402401 39.04244v39.04244h689.579099v-39.04244a38.050378 38.050378 0 0 0-38.4024-39.04244h-38.4024V467.645228h46.018876a77.060816 77.060816 0 0 1 71.108444 51.587224 381.879867 381.879867 0 0 1 6.4004 125.479843c-4.256266 91.04569-8.928558 282.609663 78.020877 341.237327a196.268267 196.268267 0 0 0 109.60685 35.2022 164.394275 164.394275 0 0 0 117.831364-48.995062c85.989374-85.317332 29.793862-301.202825 8.832552-349.205826z m-174.474904-323.220201a19.52122 19.52122 0 1 1 19.2012-19.585224 19.2012 19.2012 0 0 1-19.233202 19.68123zM153.43967 116.903306a38.850428 38.850428 0 0 1 38.4024-39.04244h306.483155a38.946434 38.946434 0 0 1 38.4024 39.04244v233.838615a38.946434 38.946434 0 0 1-38.4024 39.042441H191.84207a38.754422 38.754422 0 0 1-38.4024-39.042441z",
        center=["25%", "50%"],
        is_outline_show=False,
        label_opts=opts.LabelOpts(font_size=15,
                                  formatter='{@score}m³/h',
                                  position="insideLeft",
                                  distance=60,
                                  color="#74b9f0"),
    )

    grid = Grid().add(l1,
                      grid_opts=opts.GridOpts()).add(l2,
                                                     grid_opts=opts.GridOpts())
    ch = grid.dump_options_with_quotes()
    return ch
Ejemplo n.º 23
0
def progress_chart(dic):  #进度图

    c = (Liquid(init_opts=opts.InitOpts(width=width, height=height)).add(
        "BUG修复率",
        [dic['share'], dic['share']],
        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=dic["titlename"])).render("./static/html/%s" % dic['htmlname']))
    return c
Ejemplo n.º 24
0
def liquid():
    '''
    就餐人数占总作为数占比水球图
    :return:
    '''
    peo = df2.iloc[-1:, :]
    eat_peo = list(peo['eat_peo'])[0]
    seat = list(peo['seat'])[0]
    weight = round(eat_peo / seat, 2)

    c = (
        Liquid(init_opts=opts.InitOpts(theme=ThemeType.DARK,chart_id=5))
            .add("lq", [weight, weight], is_outline_show=False, shape=SymbolType.ARROW)
            .set_global_opts(title_opts=opts.TitleOpts(title="就餐人数占总座位数比重",
                                                       ))
    )
    return c
Ejemplo n.º 25
0
def liquid_data_precision(title="Liquid-数据精度",
                          text='值',
                          value=[0.7234]) -> Liquid:
    '''
    水球图
    '''
    c = (Liquid().add(
        text,
        value,
        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)))
    return c
Ejemplo n.º 26
0
def render_liquid():
    with st.echo("below"):
        options = {
            "series": [
                {
                    "type": "liquidFill",
                    "data": [0.5, 0.4, 0.3],
                    "color": ["red", "#0f0", "rgb(0, 0, 255)"],
                    "itemStyle": {"opacity": 0.6},
                    "emphasis": {"itemStyle": {"opacity": 0.9}},
                }
            ]
        }
        st_echarts(options)

        c = (
            Liquid()
            .add("lq", [0.6, 0.7])
            .set_global_opts(title_opts=opts.TitleOpts(title="Liquid-基本示例"))
        )
        st_pyecharts(c)
Ejemplo n.º 27
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
Ejemplo n.º 28
0
def bar_base5() -> Bar:
    # 连接database
    conn = pymysql.connect(host="192.168.10.206",
                           port=3306,
                           user="******",
                           passwd="baison8888",
                           db="e3_20192020")
    # 得到一个可以执行SQL语句的光标对象
    cursor = conn.cursor()
    # 查询数据的SQL语句
    sql = """select sum(payment) dt from order_info where FROM_UNIXTIME(pay_time)>='2020-11-01 00:00:00'and FROM_UNIXTIME(pay_time)<='2020-11-13 23:59:59' and order_status!='3';"""
    # 执行SQL语句
    cursor.execute(sql)
    # 获取多条查询数据
    ret = cursor.fetchone()
    cursor.close()
    conn.close()
    # 打印下查询结果
    print(ret)
    print(ret[0])
    gg = ret[0] / Decimal(280000000)
    c = (Liquid().add("lq", [gg, 0.2]).set_global_opts(
        title_opts=opts.TitleOpts(title="已完成目标2.8亿的:")))
    return c
Ejemplo n.º 29
0
from pyecharts import options as opts
from pyecharts.charts import Liquid

c = (Liquid().add("lq", [0.6, 0.7]).set_global_opts(title_opts=opts.TitleOpts(
    title="Liquid-基本示例")).render("Liquid_base.html"))
Ejemplo n.º 30
0
        "name": "Score",
        "type": "category",
        "data": ["Excellent", "Good", "OK", "Bad"],
    },
]

parallel_data = [[12.99, 100, 82, "Good"], [9.99, 80, 77, "OK"],
                 [20, 120, 60, "Excellent"]]
# init_opts=opts.InitOpts(width="800px",height="300px")
parallel = Parallel(init_opts=opts.InitOpts(width="800px", height="300px"))
parallel.add_schema(parallel_axis)
parallel.add(series_name="Related Indexes",
             data=parallel_data,
             linestyle_opts=opts.LineStyleOpts(width=4, opacity=0.5))

liquid = Liquid(init_opts=opts.InitOpts(width="300px", height="300px"))
liquid.add("liquid", [0.6, 0.7, 0.3])
liquid.set_global_opts(title_opts=opts.TitleOpts(title="Basic Example"))

heatmap_data = [[i, j, random.randint(0, 50)] for i in range(7)
                for j in range(7)]
heatmap = HeatMap()
heatmap.add_xaxis(Faker.week)
heatmap.add_yaxis(
    "相关表",
    Faker.week,
    heatmap_data,
    label_opts=opts.LabelOpts(is_show=True, position="inside"),
)

heatmap.set_global_opts(