from pyecharts import options as opts
from pyecharts.charts import Gauge
c = (
Gauge(init_opts=opts.InitOpts(width="400px", height="400px"))
.add(series_name="库位利用率",
data_pair=[["hello", 90]], # 设置表盘显示文字和指针指向
radius="73%", #仪表盘半径,默认75%
detail_label_opts=opts.LabelOpts(is_show=False), #是否显示540
axisline_opts=opts.AxisLineOpts(
linestyle_opts=opts.LineStyleOpts(
color = [(0.2,'#00FF00'),(0.5,'#00CDCD'),(0.8,'#fd666d'),(1,'#FF66FF')], # 此处划分为四个区间
width=30, #仪表盘的条宽
type_ = 'solid', #线型'solid'(默认), 'dashed', 'dotted'
opacity = 1, #填充色透明度
)
)
)
.set_global_opts(title_opts=opts.TitleOpts(title='仪表图销售部年度销量',
subtitle = '林老头super',
title_textstyle_opts = opts.TextStyleOpts(color='#FFFF00',
font_size=30,),
subtitle_textstyle_opts={'color':'#D3D3D3',
'font_size':13,
'pos_right':'2'}, # 属性名称需加引号'pos_right':'2'不起作用!
pos_left='left'), # 同时设置主副标题位置
legend_opts=opts.LegendOpts(is_show=False),
tooltip_opts=opts.TooltipOpts(is_show=True, formatter="{a} <br/>{b} : {c}%"),
)
.render("gauge_ex.html")
)
效果如图: