from pyecharts import options as opts
from pyecharts.charts import Map
from pyecharts.faker import Faker
#定义数据
provinces = Faker.provinces
guangdong_city = Faker.guangdong_city
values = Faker.values()
country = Faker.country
print(provinces)
print(values)
#Map方法制作全国地图
c = (
Map()
#.add("商家A", [list(z) for z in zip(provinces, values)], "china",)
.add("商家A", [list(z) for z in zip(guangdong_city, values)], "广东",)
#.add("商家A", [list(z) for z in zip(country, values)], "world")
# 设置全局项
#.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) #不显示标签
.set_global_opts(
# 设置标题名称
title_opts=opts.TitleOpts(
title="Map-VisualMap(连续型)" ,
subtitle="我是副标题-数据只是模拟",
pos_left="center" # 设置标题居中
),
# 设置图例配置项
legend_opts=opts.LegendOpts(
pos_right="right", # 设置为水平居左right
pos_bottom="bottom" # 设置为垂直居下
),
#visualmap_opts=opts.VisualMapOpts(max_=200),
#visualmap_opts=opts.VisualMapOpts(max_=200, is_piecewise=True),
)
)
c.render("map.html") # 生成名为map的本地html文件