c1 = (
Liquid()
.add('lq',
[0.35],
center=['30%', '50%'],
is_outline_show=False,
shape='circle'
)
.set_global_opts(title_opts=opts.TitleOpts(title='基本水球图-1',pos_top='30',pos_left='10%'))
.render('基本水球图-1.html')
)
水球外形,有circle, rect, roundRect, triangle, diamond, pin, arrow 可选,通过shape参数选取,默认值为circle。c2 = (
Liquid()
.add('lq',
[0.35],
center=['30%', '50%'],
is_outline_show=True,
shape='roundRect'
)
.set_global_opts(title_opts=opts.TitleOpts(title='基本水球图-2',pos_top='30',pos_left='10%'))
.render('基本水球图-2.html')
)
is_outline_show参数可设置是否显示外边框。c3 = (
Liquid()
.add('lq',
[0.75,0.5,0.2],
center=['30%', '50%'],
is_outline_show=True,
shape='roundRect'
)
.set_global_opts(title_opts=opts.TitleOpts(title='基本水球图-3',pos_top='30',pos_left='10%'))
.render('基本水球图-3.html')
)
c4 = (
Liquid()
.add('lq',
[0.6],
center=['30%', '50%'],
is_outline_show=True,
shape='diamond',
color=['#008B8B'],
label_opts = opts.LabelOpts(font_size=30, formatter=JsCode(
"""function (param) {
return ('完成度:'+Math.floor(param.value * 10000) / 100) + '%';
}"""
),position='inside'),
)
.set_global_opts(title_opts=opts.TitleOpts(title='基本水球图-4',pos_top='30',pos_left='10%'))
.render('基本水球图-4.html')
)
l1 = (
Liquid()
.add('lq',
[0.2],
shape='circle',
center=['20%', '50%'],
label_opts=opts.LabelOpts(
font_size=20,
formatter=JsCode(
"""function (param) {
return ('完成度:'+Math.floor(param.value * 10000) / 100) + '%';
}"""
),
position='inside',
),
)
)
l2 = (
Liquid()
.add('lq',
[0.5,0.3],
shape='diamond',
center=['50%', '50%'],
label_opts=opts.LabelOpts(
font_size=20,
formatter=JsCode(
"""function (param) {
return ('完成度:'+Math.floor(param.value * 10000) / 100) + '%';
}"""
),
position='inside',
),
)
)
l3= Liquid().add(
'lq',
[0.85, 0.5, 0.2],
shape='roundRect',
center=['80%', '50%'],
label_opts=opts.LabelOpts(
font_size=20,
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())
grid.render('基本水球图-6.html')
👉 公众号后台回复【可视化项目源码】获取更多可视化代码+数据