mirror of
https://github.com/pyecharts/pyecharts.git
synced 2025-12-08 20:59:23 +00:00
116 lines
3.1 KiB
Python
116 lines
3.1 KiB
Python
# coding=utf-8
|
||
from example.commons import Collector, Faker
|
||
from pyecharts import options as opts
|
||
from pyecharts.charts import Geo, Page
|
||
from pyecharts.globals import ChartType, SymbolType
|
||
|
||
C = Collector()
|
||
|
||
|
||
@C.funcs
|
||
def geo_base() -> Geo:
|
||
c = (
|
||
Geo()
|
||
.add("geo", [list(z) for z in zip(Faker.provinces, Faker.values())])
|
||
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
|
||
.set_global_opts(
|
||
visualmap_opts=opts.VisualMapOpts(),
|
||
title_opts=opts.TitleOpts(title="Geo-基本实例"),
|
||
)
|
||
)
|
||
return c
|
||
|
||
|
||
@C.funcs
|
||
def geo_visualmap_piecewise() -> Geo:
|
||
c = (
|
||
Geo()
|
||
.add("geo", [list(z) for z in zip(Faker.provinces, Faker.values())])
|
||
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
|
||
.set_global_opts(
|
||
visualmap_opts=opts.VisualMapOpts(is_piecewise=True),
|
||
title_opts=opts.TitleOpts(title="Geo-VisualMap(分段型)"),
|
||
)
|
||
)
|
||
return c
|
||
|
||
|
||
@C.funcs
|
||
def geo_effectscatter() -> Geo:
|
||
c = (
|
||
Geo()
|
||
.add(
|
||
"geo",
|
||
[list(z) for z in zip(Faker.provinces, Faker.values())],
|
||
type_=ChartType.EFFECT_SCATTER,
|
||
)
|
||
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
|
||
.set_global_opts(title_opts=opts.TitleOpts(title="Geo-EffectScatter"))
|
||
)
|
||
return c
|
||
|
||
|
||
@C.funcs
|
||
def geo_heatmap() -> Geo:
|
||
c = (
|
||
Geo()
|
||
.add(
|
||
"geo",
|
||
[list(z) for z in zip(Faker.provinces, Faker.values())],
|
||
type_=ChartType.HEATMAP,
|
||
)
|
||
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
|
||
.set_global_opts(
|
||
visualmap_opts=opts.VisualMapOpts(),
|
||
title_opts=opts.TitleOpts(title="Geo-HeatMap"),
|
||
)
|
||
)
|
||
return c
|
||
|
||
|
||
@C.funcs
|
||
def geo_guangdong() -> Geo:
|
||
c = (
|
||
Geo()
|
||
.add(
|
||
"geo",
|
||
[list(z) for z in zip(Faker.guangdong_city, Faker.values())],
|
||
maptype="广东",
|
||
type_=ChartType.HEATMAP,
|
||
)
|
||
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
|
||
.set_global_opts(
|
||
visualmap_opts=opts.VisualMapOpts(),
|
||
title_opts=opts.TitleOpts(title="Geo-广东地图"),
|
||
)
|
||
)
|
||
return c
|
||
|
||
|
||
@C.funcs
|
||
def geo_lines() -> Geo:
|
||
c = (
|
||
Geo()
|
||
.add(
|
||
"",
|
||
[("广州", 55), ("北京", 66), ("杭州", 77), ("重庆", 88)],
|
||
type_=ChartType.EFFECT_SCATTER,
|
||
color="white",
|
||
)
|
||
.add(
|
||
"geo",
|
||
[("广州", "上海"), ("广州", "北京"), ("广州", "杭州"), ("广州", "重庆")],
|
||
type_=ChartType.LINES,
|
||
effect_opts=opts.EffectOpts(
|
||
symbol=SymbolType.ARROW, symbol_size=6, color="white"
|
||
),
|
||
linestyle_opts=opts.LineStyleOpts(curve=0.2),
|
||
)
|
||
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
|
||
.set_global_opts(title_opts=opts.TitleOpts(title="Geo-Lines"))
|
||
)
|
||
return c
|
||
|
||
|
||
Page().add(*[fn() for fn, _ in C.charts]).render()
|