一彪薛、柱狀圖
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"
),#設(shè)置動畫
theme=ThemeType.MACARONS, #設(shè)置主體
width='1200px', #設(shè)置寬度
height='800px', #設(shè)置高度
)
) # 主題設(shè)置
.add_xaxis(Faker.choose()) # x軸 數(shù)據(jù)類型list
.add_yaxis("商家A", Faker.values())
.add_yaxis("商家B", Faker.values()) # y軸 數(shù)據(jù)類型list 值為int 或者float
.set_global_opts(
title_opts={"text": "Bar-基本示例", "subtext": "我是副標(biāo)題"}
) # 設(shè)置標(biāo)題
.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 # 英文的星期一到日