mirror of
https://github.com/pyecharts/pyecharts.git
synced 2025-12-08 20:59:23 +00:00
66 lines
1.6 KiB
Python
66 lines
1.6 KiB
Python
# coding=utf-8
|
|
from example.commons import Collector, Faker
|
|
from pyecharts import options as opts
|
|
from pyecharts.charts import Page, Pie
|
|
|
|
C = Collector()
|
|
|
|
|
|
@C.funcs
|
|
def pie_base() -> Pie:
|
|
c = (
|
|
Pie()
|
|
.add("", [list(z) for z in zip(Faker.choose(), Faker.values())])
|
|
.set_global_opts(title_opts=opts.TitleOpts(title="Pie-基本示例"))
|
|
.set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
|
|
)
|
|
return c
|
|
|
|
|
|
@C.funcs
|
|
def pie_radius() -> Pie:
|
|
c = (
|
|
Pie()
|
|
.add(
|
|
"",
|
|
[list(z) for z in zip(Faker.choose(), Faker.values())],
|
|
radius=["40%", "75%"],
|
|
)
|
|
.set_global_opts(
|
|
title_opts=opts.TitleOpts(title="Pie-Radius"),
|
|
legend_opts=opts.LegendOpts(
|
|
orient="vertical", pos_top="15%", pos_left="2%"
|
|
),
|
|
)
|
|
.set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
|
|
)
|
|
return c
|
|
|
|
|
|
@C.funcs
|
|
def pie_rosetype() -> Pie:
|
|
v = Faker.choose()
|
|
c = (
|
|
Pie()
|
|
.add(
|
|
"",
|
|
[list(z) for z in zip(v, Faker.values())],
|
|
radius=["30%", "75%"],
|
|
center=["25%", "50%"],
|
|
rosetype="radius",
|
|
label_opts=opts.LabelOpts(is_show=False),
|
|
)
|
|
.add(
|
|
"",
|
|
[list(z) for z in zip(v, Faker.values())],
|
|
radius=["30%", "75%"],
|
|
center=["75%", "50%"],
|
|
rosetype="area",
|
|
)
|
|
.set_global_opts(title_opts=opts.TitleOpts(title="Pie-玫瑰图示例"))
|
|
)
|
|
return c
|
|
|
|
|
|
Page().add(*[fn() for fn, _ in C.charts]).render()
|