一、柱状图
from pyecharts.faker import Faker
from pyecharts import options as opts
from pyecharts.charts import Bar
from pyecharts.globals import ThemeType
bar = (
Bar(
init_opts=opts.InitOpts(
animation_opts=opts.AnimationOpts(
animation_delay=1000,
animation_easing="elasticOut"
),#设置动画
theme=ThemeType.MACARONS, #设置主体
width='1200px', #设置宽度
height='800px', #设置高度
)
) # 主题设置
.add_xaxis(Faker.choose()) # x轴 数据类型list
.add_yaxis("商家A", Faker.values())
.add_yaxis("商家B", Faker.values()) # y轴 数据类型list 值为int 或者float
.set_global_opts(
title_opts={"text": "Bar-基本示例", "subtext": "我是副标题"}
) # 设置标题
.render(r"\home\bar_base.html") # 生成html
)
1. Faker
pyecharts/faker.py
Faker.cars # 随机各种中文汽车品牌的列表
Faker.visual_color # 随机颜色列表
Faker.days_attrs # 'number天'字符串列表
Faker.clock # 时间字符串列表
Faker.dogs # 随机各种狗的列表
Faker.guangdong_city # 广东省下面7个市的固定列表
Faker.img_path(r'C:\abc.jpg') # 返回图片路径
Faker.week_en # 英文的星期一到日