def test_map_globe_in_jupyter(): CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_NOTEBOOK c = MapGlobe().add( "商家A", [list(z) for z in zip(Faker.provinces, Faker.values())], "china" ) content = c.render_notebook()._repr_html_() assert_in("document.createElement('canvas')", content) assert_in("baseTexture", content)
def test_map_base(fake_writer): c = MapGlobe().add( "商家A", [list(z) for z in zip(Faker.provinces, Faker.values())], "china" ) c.render() _, content = fake_writer.call_args[0] assert_in("document.createElement('canvas')", content) assert_equal(c.theme, "white") assert_equal(c.renderer, "canvas") assert_in("baseTexture", content)
def map_globe_base(): data = [x for _, x in POPULATION[1:]] low, high = min(data), max(data) mg = ( MapGlobe() .add_schema() .add( maptype="world", series_name="World Population", data_pair=POPULATION[1:], is_map_symbol_show=False, label_opts=opts.LabelOpts(is_show=False), ) .set_global_opts( visualmap_opts=opts.VisualMapOpts( min_=low, max_=high, range_text=["max", "min"], is_calculable=True, range_color=["lightskyblue", "yellow", "orangered"], ) ) ) mg.render()
def set_map(): map0 = (MapGlobe().add( maptype="world", series_name="World Population", data_pair=get_data_series("confirmed"), is_map_symbol_show=True, label_opts=opts.LabelOpts(is_show=False), )) map0.set_series_opts(label_opts=opts.LabelOpts( is_show=False)).set_global_opts( title_opts=opts.TitleOpts(title="COVID_19 WORLD MAP"), visualmap_opts=opts.VisualMapOpts(max_=800000)) return map0
def get_global_map3D(): # country_name = json.loads(request.args.get('data', type=str))['name'] max_data, min_data, map_data = get.get_word_epidemic(get.get_today()) # map_data : [["Canada",[1,2,3]],...] symbol_size = 12 Global_map = ( MapGlobe(init_opts=opts.InitOpts( width="100%", height="100%", theme=ThemeType.DARK)).add_schema( maptype="world").add("geo", map_data).set_series_opts( label_opts=opts.LabelOpts(is_show=False)). set_global_opts( visualmap_opts=opts.VisualMapOpts( type_="size", is_calculable=True, dimension=0, range_size=[5, 1000], min_=min_data, max_=max_data, # pos_left="600", #javascript will do this. # pos_top="400", # range_text=["High", "Low"], # range_color=["lightskyblue", "yellow", "orangered"], # textstyle_opts=opts.TextStyleOpts(color="#ddd"), ), tooltip_opts=opts.TooltipOpts(is_show=True, formatter=""" function(parameter){ var tool_tip = parameter.name+ "<br/>累计确诊:" + parameter.value[2][0] + "<br/>累计死亡:"+parameter.value[2][1]+ "<br/>累计治愈:"+parameter.value[2][2]; return tool_tip; } """), # title_opts=opts.TitleOpts(title=country_name) )) return Global_map.render_embed()
# ---*- coding: utf-8 -*- # ¥- *--- author---祥彪--¥ import pyecharts.options as opts from pyecharts.charts import MapGlobe from pyecharts.faker import POPULATION data = [x for _, x in POPULATION[1:]] low, high = min(data), max(data) c = (MapGlobe().add_schema().add( maptype="glope", series_name="World Population", data_pair=POPULATION[1:], is_map_symbol_show=False, label_opts=opts.LabelOpts(is_show=False), ).set_global_opts(visualmap_opts=opts.VisualMapOpts( min_=low, max_=high, range_text=["max", "min"], is_calculable=True, range_color=["lightskyblue", "yellow", "orangered"], )).render("map_glope_base.html"))
import pyecharts.options as opts from pyecharts.charts import MapGlobe from pyecharts.faker import POPULATION data = [x for _, x in POPULATION[1:]] low, high = min(data), max(data) c = ( MapGlobe(init_opts=opts.InitOpts(width='1000px', height='1000px', bg_color='#00BBFF')) # .add_schema().add( maptype="world", series_name="World Population", data_pair=POPULATION[1:], is_map_symbol_show=True, label_opts=opts.LabelOpts(is_show=True), ).set_global_opts( title_opts=opts.TitleOpts(title="3D 地球示例"), # 设置地球属性 visualmap_opts=opts.VisualMapOpts( min_=low, max_=high, range_text=["max", "min"], is_calculable=True, range_color=["lightskyblue", "yellow", "orangered"], )).render("world_map_3d.html"))
from pyecharts.charts import MapGlobe, Grid from pyecharts.globals import ThemeType high = max([x for _, x in POPULATION[1:]]) low = min([x for _, x in POPULATION[1:]]) m = ( MapGlobe(init_opts=opts.InitOpts( width="1920px", height="900px", page_title="全球互联网网络地图", theme=ThemeType.WALDEN)).add_schema().add( maptype="world", series_name="World Population", data_pair=POPULATION[1:], is_map_symbol_show=False, label_opts=opts.LabelOpts(is_show=False), ).set_global_opts( # title_opts=opts.TitleOpts(title="全球互联网网络AS号分布图"), visualmap_opts=opts.VisualMapOpts( min_=low, max_=high, range_text=["max", "min"], is_calculable=True, # is_piecewise=True, orient="horizontal", pos_right="20%", range_color=["lightskyblue", "yellow", "orangered"], ))) m.render("geo_global_3D.html")