W3Cschool
恭喜您成為首批注冊用戶
獲得88經驗值獎勵
pyecharts 內置提供了 10+ 種不同的風格,另外也提供了便捷的定制主題的方法。
默認主題的效果
from pyecharts import options as opts
from pyecharts.charts import Bar
from pyecharts.globals import ThemeType
def theme_default() -> Bar:
c = (
Bar()
# 等價于 Bar(init_opts=opts.InitOpts(theme=ThemeType.WHITE))
.add_xaxis(Faker.choose())
.add_yaxis("商家A", Faker.values())
.add_yaxis("商家B", Faker.values())
.add_yaxis("商家C", Faker.values())
.add_yaxis("商家D", Faker.values())
.set_global_opts(title_opts=opts.TitleOpts("Theme-default"))
)
return c
c = Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))
c = Bar(init_opts=opts.InitOpts(theme=ThemeType.DARK))
c = Bar(init_opts=opts.InitOpts(theme=ThemeType.CHALK))
c = Bar(init_opts=opts.InitOpts(theme=ThemeType.ESSOS))
c = Bar(init_opts=opts.InitOpts(theme=ThemeType.INFOGRAPHIC))
c = Bar(init_opts=opts.InitOpts(theme=ThemeType.MACARONS))
c = Bar(init_opts=opts.InitOpts(theme=ThemeType.PURPLE_PASSION))
c = Bar(init_opts=opts.InitOpts(theme=ThemeType.ROMA))
c = Bar(init_opts=opts.InitOpts(theme=ThemeType.ROMANTIC))
c = Bar(init_opts=opts.InitOpts(theme=ThemeType.SHINE))
c = Bar(init_opts=opts.InitOpts(theme=ThemeType.VINTAGE))
c = Bar(init_opts=opts.InitOpts(theme=ThemeType.WALDEN))
c = Bar(init_opts=opts.InitOpts(theme=ThemeType.WESTEROS))
c = Bar(init_opts=opts.InitOpts(theme=ThemeType.WONDERLAND))
Echarts 提供了主題構建工具,你可以從中構建喜歡的主題,假設你構建的主題文件為 ?myTheme.js
?。
使用自己構建的主題必須由開發(fā)者自己啟動資源文件服務器,這部分內容請參考 進階話題-資源引用,然后你需要進行以下步驟的操作
myTheme.js
? 放入至 ?pyecharts-assets/assets/themes
? 文件夾。 from pyecharts.datasets import register_files
register_files({"myTheme": ["themes/myTheme", "js"]})
c = Bar(init_opts=opts.InitOpts(theme="myTheme"))
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯系方式:
更多建議: