Funnel:漏斗图
class pyecharts.charts.Funnel
class Funnel(
# 初始化配置项,参考 `global_options.InitOpts`
init_opts: opts.InitOpts = opts.InitOpts()
)
func pyecharts.charts.Funnel.add
def add(
# 系列名称,用于 tooltip 的显示,legend 的图例筛选。
series_name: str,
# 系列数据项,格式为 [(key1, value1), (key2, value2)]
data_pair: Sequence,
# 是否选中图例
is_selected: bool = True,
# 系列 label 颜色
color: Optional[str] = None,
# 数据排序, 可以取 'ascending','descending','none'(表示按 data 顺序)
sort_: str = "descending",
# 数据图形间距
gap: Numeric = 0,
# 标签配置项,参考 `series_options.LabelOpts`
label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
# 提示框组件配置项,参考 `series_options.TooltipOpts`
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
# 图元样式配置项,参考 `series_options.ItemStyleOpts`
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
)
def funnel_label_inside() -> Funnel:
c = (
Funnel()
.add(
"商品",
[list(z) for z in zip(Faker.choose(), Faker.values())],
label_opts=opts.LabelOpts(position="inside"),
)
.set_global_opts(title_opts=opts.TitleOpts(title="Funnel-Label(inside)"))
)
return c
# 系列数据项,格式为 [(key1, value1), (key2, value2)]
node2:/root/fenxi#cat k13.py
import datetime
import random
from pyecharts import options as opts
from pyecharts.charts import Calendar
from pyecharts.charts import Funnel, Page
from pyecharts.faker import Faker
def funnel_label_inside() -> Funnel:
c = (
Funnel()
.add(
"商品",
[('蛋糕',100),('饮料',80),('香烟',60),('瓜子',50)],
label_opts=opts.LabelOpts(position="inside"),
)
.set_global_opts(title_opts=opts.TitleOpts(title="Funnel-Label(inside)"))
)
return c
funnel_label_inside().render("k13.html")