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

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

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

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

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

 from example.commons import Faker
from pyecharts import options as opts
from pyecharts.charts import Funnel, Page funnel=(
Funnel()
.add(
"商品",
[list(z) for z in zip(Faker.choose(), Faker.values())],
sort_="ascending",
label_opts=opts.LabelOpts(position="inside"),
)
.set_global_opts(title_opts=opts.TitleOpts(title="Funnel-Sort(ascending)"))
) funnel.render("funnel.html")

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

05-20 12:25