//定义漏斗图数据
import json
s = [{'action':'浏览商品','py':50000},
{'action':'放入购物车','py':35000},
{'action':'生成订单','py':25000},
{'action':'支付订单','py':15000},
{'action':'完成交易','py':8000},]
with open('E:/ttx/funnel.json','w',encoding='utf-8') as f:
data = json.dump(s,f,ensure_ascii=False)
print("Saving Finish...")
//绘制漏斗图表
from pyecharts.charts import Funnel
from pyecharts import options as opts
import json
with open('E:/ttx/funnel.json','r',encoding='utf-8') as f:
data = json.load(f)
data_ful = [(i['action'],i['py']) for i in data]
c = Funnel()
c.add('商品',data_ful)
c.set_global_opts(title_opts=opts.TitleOpts(title='Funnel'))
c.render_notebook()

posted on
浙公网安备 33010602011771号