小白学Python(9)——pyecharts 绘制漏斗图 Funnel

根据pyecharts的介绍一直没有研究明白def和return的用法,无法显示完整的漏斗图,还请各位指点。

小白学Python(9)——pyecharts 绘制漏斗图 Funnel_第1张图片

 

根据上文绘制bar的方法,我更改了代码,做出了漏斗图,不过和demo不一样,而且数据也会随时变化,不知哪里出现了问题:

 

1 from example.commons import Faker
2 from pyecharts import options as opts
3 from pyecharts.charts import Funnel, Page
4 funnel=(
5     Funnel()
6     .set_global_opts(title_opts=opts.TitleOpts(title="主标题", subtitle="副标题"))
7     .add("商品", [list(z) for z in zip(Faker.choose(), Faker.values())])
8 )
9 funnel.render("funnel.html")    

 小白学Python(9)——pyecharts 绘制漏斗图 Funnel_第2张图片

 1 from example.commons import Faker
 2 from pyecharts import options as opts
 3 from pyecharts.charts import Funnel, Page
 4 
 5 funnel=(
 6     Funnel()
 7     .add(
 8             "商品",
 9             [list(z) for z in zip(Faker.choose(), Faker.values())],
10             sort_="ascending",
11             label_opts=opts.LabelOpts(position="inside"),
12         )
13         .set_global_opts(title_opts=opts.TitleOpts(title="Funnel-Sort(ascending)"))
14     )
15     
16 funnel.render("funnel.html")

小白学Python(9)——pyecharts 绘制漏斗图 Funnel_第3张图片

 

转载于:https://www.cnblogs.com/adam012019/p/11395109.html

你可能感兴趣的