数据安全

柱状图分析源代码

2022-06-06  本文已影响0人  Benfrost

效果图——

(可实现动态效果)

源代码——

'''

各中心商品销售数据对比条形图

扩充导入文档

'''

# 定义X轴数据标签

x_label = ['一体机','CDP','CDM','OKR','BCM','EDR']

# 构造第一个中心的销售数据

y1_data = [1,3,4,6,2,4]

# 构造第二个中心的销售数据

y2_data = [2,1,2,3,3,3]

# 构造第三个中心的销售数据

y3_data = [7,6,3,3,1,1]

# 构造第四个中心的销售数据

y4_data = [4,4,3,4,5,2]

# 创建条形图对象

bar = Bar()

bar.set_global_opts(title_opts=opts.TitleOpts(title="各中心销售数据对比图"))

# 设置X轴标签

bar.add_xaxis(x_label)

# 设置第一个中心数据及标签名称

# is_show_background设置添加背景

bar.add_yaxis('A中心',y1_data,is_show_background=True)

# 设置第二个中心数据及标签名称

# is_show_background设置添加背景

bar.add_yaxis('B中心',y2_data,is_show_background=True)

# 设置第三个中心数据及标签名称

# is_show_background设置添加背景

bar.add_yaxis('C中心',y3_data,is_show_background=True)

# 设置第四个中心数据及标签名称

# is_show_background设置添加背景

bar.add_yaxis('D中心',y4_data,is_show_background=True)

# 生成html数据分析图文件,默认文件名称为render.html

bar.render()

上一篇下一篇

猜你喜欢

热点阅读