Python全系列 教程
3567个小节阅读:5929.9k
鸿蒙应用开发
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
class pyecharts.charts.Geo
xxxxxxxxxx
class Geo(
# 初始化配置项,参考 `global_options.InitOpts`
init_opts: opts.InitOpts = opts.InitOpts()
# 是否忽略不存在的坐标,默认值为 False,即不忽略
is_ignore_nonexistent_coord: bool = False
)
func pyecharts.charts.Geo.add_schema
xxxxxxxxxx
def add_schema(
# 地图类型,具体参考 pyecharts.datasets.map_filenames.json 文件
maptype: str = "china",
# 是否开启鼠标缩放和平移漫游。
is_roam: bool = True,
# 当前视角的缩放比例。默认为 1
zoom: Optional[Numeric] = None,
# 当前视角的中心点,用经纬度表示。例如:center: [115.97, 29.71]
center: Optional[Sequence] = None,
# 参数用于 scale 地图的长宽比。
aspect_scale: types.Numeric = 0.75,
# 二维数组,定义定位的左上角以及右下角分别所对应的经纬度。
bounding_coords: types.Optional[types.Sequence[types.Numeric]] = None,
# 最小的缩放值。
min_scale_limit: types.Optional[types.Numeric] = None,
# 最大的缩放值。
max_scale_limit: types.Optional[types.Numeric] = None,
# 默认是 'name',针对 GeoJSON 要素的自定义属性名称,作为主键用于关联数据点和 GeoJSON 地理要素。
name_property: str = "name",
# 选中模式,表示是否支持多个选中,默认关闭,支持布尔值和字符串。
# 字符串取值可选'single'表示单选,或者'multiple'表示多选。
selected_mode: types.Union[bool, str] = False,
# pyecharts 暂时没有提供 left/top/right/bottom 的配置
# layoutCenter 和 layoutSize 提供了除了 left/right/top/bottom/width/height 之外的布局手段。
# 在使用 left/right/top/bottom/width/height 的时候
# 可能很难在保持地图高宽比的情况下把地图放在某个盒形区域的正中间,并且保证不超出盒形的范围。
# 此时可以通过 layoutCenter 属性定义地图中心在屏幕中的位置,layoutSize 定义地图的大小。
# 如下示例
# layoutCenter: ['30%', '30%'],
# // 如果宽高比大于 1 则宽度为 100,如果小于 1 则高度为 100,保证了不超过 100x100 的区域
# layoutSize: 100
layout_center: types.Optional[types.Sequence[str]] = None,
# 地图的大小,见 layoutCenter。支持相对于屏幕宽高的百分比或者绝对的像素大小。
layout_size: types.Union[str, types.Numeric] = None,
# # 标签配置项,参考 `series_options.LabelOpts`
label_opts: Union[opts.LabelOpts, dict, None] = None,
# 地图区域的多边形 图形样式。
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] =None,
# 高亮状态下的多边形样式
emphasis_itemstyle_opts: Union[opts.ItemStyleOpts, dict,None] = None,
# 高亮状态下的标签样式。
emphasis_label_opts: Union[opts.LabelOpts, dict, None] =None,
):
func pyecharts.charts.Geo.add
xxxxxxxxxx
def add(
# 系列名称,用于 tooltip 的显示,legend 的图例筛选。
series_name: str,
# 数据项 (坐标点名称,坐标点值)
data_pair: Sequence,
# Geo 图类型,有 scatter, effectScatter, heatmap, lines 4 种,建议使用
# from pyecharts.globals import GeoType
# GeoType.GeoType.EFFECT_SCATTER,GeoType.HEATMAP,GeoType.LINES
type_: str = "scatter",
# 是否选中图例
is_selected: bool = True,
# 标记图形形状
symbol: Optional[str] = None,
# 标记的大小
symbol_size: Numeric = 12,
# 每个点的大小,在地理坐标系(coordinateSystem: 'geo')上有效。
blur_size: types.Numeric = 20,
# 每个点模糊的大小,在地理坐标系(coordinateSystem: 'geo')上有效。
point_size: types.Numeric = 20,
# 系列 label 颜色
color: Optional[str] = None,
# 是否是多段线,在画 lines 图情况下
is_polyline: bool = False,
# 是否启用大规模线图的优化,在数据图形特别多的时候(>=5k)可以开启
is_large: bool = False,
# 特效尾迹的长度。取从 0 到 1 的值,数值越大尾迹越长。默认值 0.2
trail_length: Numeric = 0.2,
# 开启绘制优化的阈值。
large_threshold: Numeric = 2000,
# 配置该系列每一帧渲染的图形数
progressive: types.Numeric = 400,
# 启用渐进式渲染的图形数量阈值,在单个系列的图形数量超过该阈值时启用渐进式渲染。
progressive_threshold: types.Numeric = 3000,
# 标签配置项,参考 `series_options.LabelOpts`
label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
# 涟漪特效配置项,参考 `series_options.EffectOpts`
effect_opts: Union[opts.EffectOpts, dict] = opts.EffectOpts(),
# 线样式配置项,参考 `series_options.LineStyleOpts`
linestyle_opts: Union[opts.LineStyleOpts, dict] = opts.LineStyleOpts(),
# 提示框组件配置项,参考 `series_options.TooltipOpts`
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
# 图元样式配置项,参考 `series_options.ItemStyleOpts`
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
# 这个配置相对非常复杂(参照地址: https://www.echartsjs.com/zh/option.html#series-custom.renderItem)
render_item: types.JsCode = None,
# 这个配置相对非常复杂(参照地址: https://www.echartsjs.com/zh/option.html#series-custom.encode)
encode: types.Union[types.JsCode, dict] = None,
)
func pyecharts.charts.Geo.add_coordinate
新增一个坐标点
xxxxxxxxxx
def add_coordinate(
# 坐标地点名称
name: str,
# 经度
longitude: Numeric,
# 纬度
latitude: Numeric,
)
func pyecharts.charts.Geo.add_coordinate_json
以 JOSN 文件格式新增多个坐标点
xxxxxxxxxx
def add_coordinate_json(
# json 文件格式的坐标数据
# 格式如下
# {
# "阿城": [126.58, 45.32],
# "阿克苏": [80.19, 41.09]
# }
],
json_file: str
)
func pyecharts.charts.Geo.get_coordinate
查询指定地点的坐标
xxxxxxxxxx
def get_coordinate(
# 地点名称
name: str
) -> Sequence
Geo 图的坐标引用自 pyecharts.datasets.COORDINATES
,COORDINATES
是一个支持模糊匹配的字典类。可设置匹配的阈值。
xxxxxxxxxx
from pyecharts.datasets import COORDINATES
# cutoff 为匹配阈值,阈值越高相似性越高,1 为完全相同。默认为 0.6
COORDINATES.cutoff = 0.75
【示例】绘制坐标图
xxxxxxxxxx
from pyecharts import options as opts
from pyecharts.charts import Geo
from pyecharts.faker import Faker
from pyecharts.globals import ChartType
geo=Geo()
geo.add_schema(maptype="china")
geo.add(
"geo",
[list(z) for z in zip(Faker.provinces, Faker.values())],
type_=ChartType.EFFECT_SCATTER, # ChartType.HEATMAP
)
geo.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
geo.set_global_opts(
visualmap_opts=opts.VisualMapOpts(),
title_opts=opts.TitleOpts(title="Geo-基本示 例") )
geo.render_notebook()
【示例】行为轨迹
xxxxxxxxxx
from pyecharts import options as opts
from pyecharts.charts import Geo
from pyecharts.globals import ChartType, SymbolType
geo=Geo()
geo.add_schema(maptype="china")
geo.add( "geo",
[("广州", "上海"),
("广州", "北京"),
("广州", "杭州"),
("广州", "重庆")],
type_=ChartType.LINES,
effect_opts=opts.EffectOpts(
symbol=SymbolType.ARROW,
symbol_size=6, color="blue" ),
linestyle_opts=opts.LineStyleOpts(curve=0.2), )
geo.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
geo.set_global_opts(title_opts=opts.TitleOpts(title="Geo-Lines"))
geo.render_notebook()