-----------第一步-----------

import json
list_p = [{"action":"浏览商品","PV":50000},
{"action":"放入购物车","PV":35000},
{" action":"生成订单","PV":25000},
{"action":"支付订单","PV" :15000},
{"action":"完成交易","PV":15000},]
with open("demol.json","w",encoding="utf-8")as file:
    data = json.dump(list_p, file, ensure_ascii=False)
print(" Saving finish。 。。")

-------------第二步-----------

from pyecharts import options as opts
from pyecharts.charts import Funnel
import json
with open('funnel.json',encoding='utf-8') as f:
    data = json.load(f)
data_ful = [(i['action'],i['pv']) for i in data['data']]
c = Funnel()
c.add('商品',data_ful)
c.set_global_opts(title_opts=opts.TitleOpts(title='Funnel'))
c.render_notebook()

posted on 2021-11-22 20:35  xuegaochengzi  阅读(84)  评论(0编辑  收藏  举报