• Pyecharts之仪表盘(Gauge)


    Pyecharts之仪表盘(Gauge)

    from snapshot_selenium import snapshot as driver
    
    from pyecharts import options as opts
    from pyecharts.charts import Gauge
    from pyecharts.render import make_snapshot
    
    from pyecharts.globals import CurrentConfig,NotebookType
    
    CurrentConfig.NOTEBOOK_TYPE=NotebookType.JUPYTER_LAB
    

    一.基本概念

    class pyecharts.charts.Gauge

    class Gauge(
        # 初始化配置项,参考 `global_options.InitOpts`
        init_opts: opts.InitOpts = opts.InitOpts()
    )
    

    func pyecharts.charts.Gauge.add

    def add(
        # 系列名称,用于 tooltip 的显示,legend 的图例筛选。
        series_name: str,
    
        # 系列数据项,格式为 [(key1, value1), (key2, value2)]
        data_pair: Sequence,
    
        # 是否选中图例
        is_selected: bool = True,
    
        # 最小的数据值
        min_: Numeric = 0,
    
        # 最大的数据值
        max_: Numeric = 100,
    
        # 仪表盘平均分割段数
        split_number: Numeric = 10,
    
        # 仪表盘半径,可以是相对于容器高宽中较小的一项的一半的百分比,也可以是绝对的数值。
        radius: types.Union[types.Numeric, str] = "75%",
    
        # 仪表盘起始角度。圆心 正右手侧为0度,正上方为 90 度,正左手侧为 180 度。
        start_angle: Numeric = 225,
    
        # 仪表盘结束角度。
        end_angle: Numeric = -45,
    
        # 轮盘内标题文本项标签配置项,参考 `series_options.LabelOpts`
        title_label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
    
        # 轮盘内数据项标签配置项,参考 `series_options.LabelOpts`
        detail_label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
    
        # 提示框组件配置项,参考 `series_options.TooltipOpts`
        tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
    
        # 图元样式配置项,参考 `series_options.ItemStyleOpts`
        itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
    )
    

    二.代码示例

    1.Gauge

    g=(
        Gauge(init_opts=opts.InitOpts(width="1000px",height="600px"))
        .add(
            series_name="业务指标",
            data_pair=[("完成率",55.5),("未达标",20.4)]
        )
        .set_global_opts(
            legend_opts=opts.LegendOpts(is_show=True),
            tooltip_opts=opts.TooltipOpts(is_show=True,formatter="{a} <br/>{b}:{c}")
        )
    )
    
    make_snapshot(driver,g.render("gauge.html"),"gauge.png")
    
    g.load_javascript()
    g.render_notebook()
    
    from pyecharts import options as opts
    from pyecharts.charts import Gauge
    
    c = (
        Gauge()
        .add("", [("完成率", 66.6)],start_angle=-45,end_angle=-135)
        .set_global_opts(title_opts=opts.TitleOpts(title="Gauge-基本示例"))
        #.render("gauge_base.html")
    )
    
    #make_snapshot(driver,c.render("test.html"),"gauge.png")
    
    c.load_javascript()
    c.render_notebook()
    
    
    
  • 相关阅读:
    shell eval命令
    嘟嘟嘟
    07 linkextractor的基本用法
    rabbitmq消息队列
    5. 哨兵集群
    4.主从同步
    3. redis持久化存储
    2. redis 安全
    1.redis基础
    06. scrapy的Request对象
  • 原文地址:https://www.cnblogs.com/LQ6H/p/12940533.html
Copyright © 2020-2023  润新知