定制化图表的轴线(x轴和y轴)的样式和设置
c1=(
Bar()
.add_xaxis(['力量','智力','敏捷'])
.add_yaxis('全能骑士',
# 系列名称,用于 tooltip 的显示,legend 的图例筛选。
[429,321,296],
#系列数据
)
.add_yaxis('猴子',[352,236,467])
.add_yaxis('幻影刺客',[286,257,447])
.add_yaxis('尸王',[415,365,241])
.add_yaxis('黑暗先知',[342,444,226])
.add_yaxis('剑圣',[384,230,472])
.add_yaxis('冰女',[322,471,266])
.add_yaxis('人马',[510,270,176])
.add_yaxis('风行',[334,400,241])
.set_series_opts(
label_opts=opts.LabelOpts(is_show=False))
#不显示标签
.set_global_opts(
title_opts=opts.TitleOpts(
title='小冰冰传奇46级'))
.render('cr_base.html')
)
前面的不变,set_global_opts 修改为
.set_global_opts(
title_opts=opts.TitleOpts(
title='小冰冰传奇46级'),
xaxis_opts=opts.AxisOpts(name='几个英雄三维属性展示'))
轴的类型
.set_global_opts(xaxis_opts=opts.AxisOpts(type_='value'))
类别(和前面默认的一样)
时间(这里体现不出来)
.set_global_opts(xaxis_opts=opts.AxisOpts(type_='log'))
.set_global_opts(xaxis_opts=opts.AxisOpts(is_show=False))
轴反转
.set_global_opts(xaxis_opts=opts.AxisOpts(is_inverse=True))
.set_global_opts(xaxis_opts=opts.AxisOpts(name='属性名称',
name_location='start'))
.set_global_opts(xaxis_opts=opts.AxisOpts(name='属性名称',
name_location='middle'))
.set_global_opts(xaxis_opts=opts.AxisOpts(name='属性名称',
name_location='end'))
.set_global_opts(xaxis_opts=opts.AxisOpts(name='属性名称',
name_location='middle',
name_gap=30))
.set_global_opts(xaxis_opts=opts.AxisOpts(name='属性名称',
name_location='middle',
name_gap=30,
name_rotate=45))
axislabel_opts: 刻度标签的配置项,可以使用 opts.LabelOpts
进行设置
.set_global_opts(xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(color='red')))
.set_global_opts(xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(font_size=50)))
normal or bold
.set_global_opts(xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(is_show=False)))
.set_global_opts(xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=135)))
.set_global_opts(xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(background_color='green')))
.set_global_opts(xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="属性:{value}")))
刻度线的配置项,可以使用 opts.AxisTickOpts
进行设置
.set_global_opts(xaxis_opts=opts.AxisOpts(axistick_opts=opts.AxisTickOpts(is_show=False)))
.set_global_opts(xaxis_opts=opts.AxisOpts(axistick_opts=opts.AxisTickOpts(length=15)))