其他分享
首页 > 其他分享> > pyecharts-漏斗图

pyecharts-漏斗图

作者:互联网

pyecharts
echarts

import pyecharts.options as opts
from pyecharts.charts import Funnel

"""
Gallery 使用 pyecharts 1.1.0
参考地址: https://echarts.apache.org/examples/editor.html?c=funnel

目前无法实现的功能:

1、暂时无法对漏斗图的长宽等范围操作进行修改
"""
x_data = ["展现", "点击", "访问", "咨询", "订单"]
y_data = [100, 80, 60, 40, 20]

data = [[x_data[i], y_data[i]] for i in range(len(x_data))]

funnel=(
    Funnel(init_opts=opts.InitOpts(width="600px", height="400px"))
    .add(
        series_name="漏斗转化率",
        data_pair=data,            #  数据集,list
        gap=12,                        #  漏斗每一层级间距
        tooltip_opts=opts.TooltipOpts(trigger="item", formatter="{a} <br/>{b} : {c}%"),
        label_opts=opts.LabelOpts(is_show=True, position="inside"),
        itemstyle_opts=opts.ItemStyleOpts(border_color="#fff", border_width=1),
    )
    .set_global_opts(title_opts=opts.TitleOpts(title="漏斗图", subtitle="总体转化率"))
#     .render("funnel_chart.html")
)
funnel.render_notebook()

标签:funnel,pyecharts,render,漏斗,data,opts
来源: https://www.cnblogs.com/wxyz94/p/15584063.html