Python之pyecharts:利用pyecharts绘制地图十多个地区流动轨迹动态图
Python之pyecharts:利用pyecharts绘制地图十多个地区流动轨迹动态图
相关文章
Python之pyecharts:利用pyecharts绘制地图十多个地区流动轨迹动态图
Python之pyecharts:利用pyecharts绘制地图十多个地区流动轨迹动态图实现
利用pyecharts绘制地图十多个地区流动轨迹动态图
Geo(GeoChartBase)函数
Geo(init_opts=opts.InitOpts())
class Geo Found at: pyecharts.charts.basic_charts.geo
class Geo(GeoChartBase):
"""
<<< geo coordinate system >>>
support scatter plot and line
"""
def __init__(
self,
init_opts:types.Init=opts.InitOpts(),
is_ignore_nonexistent_coord:bool=False):
super().__init__(init_opts=init_opts)
self._coordinate_system = "geo"
self._is_ignore_nonexistent_coord =
is_ignore_nonexistent_coord
def _feed_data(self, data_pair:types.Sequence,
type_:str)->types.Sequence:
result = []
for n, v in data_pair:
try:
if type_ == ChartType.LINES:
f, t = self.get_coordinate(n), self.
get_coordinate(v)
result.append({"name":"{}->{}".format(n, v),
"coords":[f, t]})
else:
lng, lat = self.get_coordinate(n)
result.append({"name":n, "value":[lng, lat,
v]})
except TypeError as err:
if self._is_ignore_nonexistent_coord is not
True:
raise NonexistentCoordinatesException
(err, (n, v))
return result
def add_schema(
self,
maptype:str="china",
is_roam:bool=True,
zoom:types.Optional[types.Numeric]=None,
center:types.Optional[types.Sequence]=None,
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_property:str="name",
selected_mode:types.Union[boolstr]=False,
layout_center:types.Optional[types.Sequence
[str]]=None,
layout_size:types.Union[strtypes.Numeric]=None,
label_opts:types.Label=None,
itemstyle_opts:types.ItemStyle=None,
emphasis_itemstyle_opts:types.ItemStyle=None,
emphasis_label_opts:types.Label=None):
self.js_dependencies.add(maptype)
if center:
assert len(center) == 2
scale_limit = {
"min":min_scale_limit,
"max":max_scale_limit}
if min_scale_limit is None and max_scale_limit is
None:
scale_limit = None
self.options.update(
geo={
"map":maptype,
"zoom":zoom,
"center":center,
"roam":is_roam,
"aspectScale":aspect_scale,
"boundingCoords":bounding_coords,
"scaleLimit":scale_limit,
"nameProperty":name_property,
"selectedMode":selected_mode,
"layoutCenter":layout_center,
"layoutSize":layout_size,
"label":label_opts,
"itemStyle":itemstyle_opts,
"emphasis":{
"itemStyle":emphasis_itemstyle_opts,
"label":emphasis_label_opts}})
return self
赞 (0)