def create_charts(data_path, path_html, path_png, length):
    charts = GeoLines("TSP问题:全国34城市为例", '路径:%.3fkm' % (length / 1000),
                      **style.init_style)
    charts.add('', data_path, **style_geo)
    charts.render(path_html)
    make_a_snapshot(path_html, path_png)
    return print('绘图完毕')
Пример #2
0
    def escape(self):
        echart_unsupported_city = [
        "菏泽市", "襄阳市", "恩施州", "湘西州","阿坝州", "延边州",
        "甘孜州", "凉山州", "黔西南州", "黔东南州", "黔南州", "普洱市", "楚雄州", "红河州",
        "文山州", "西双版纳州", "大理州", "德宏州", "怒江州", "迪庆州", "昌都市", "山南市",
        "林芝市", "临夏州", "甘南州", "海北州", "黄南州", "海南州", "果洛州", "玉树州", "海西州",
        "昌吉州", "博州", "克州", "伊犁哈萨克州"]

        data = []
        
        for index, row in df_aqi.iterrows():
            city = row['city']
            aqi = row['aqi']
            if city=='长沙市':
                print(city)
                localAQI=aqi
            if city in echart_unsupported_city:
                continue
        for index, row in df_aqi.iterrows():
            city = row['city']
            aqi = row['aqi']
            if city in echart_unsupported_city:
                continue
            if aqi < localAQI and aqi<20 :
                data.append( ['长沙',city] )
                global lastcity
                lastcity=city
                                
        style = Style(
            title_top="#fff",
            title_pos = "center",
            title_color="#fff",
            width=425,
            height=730,
            background_color="#404a59"
        )
        
        style_geo = style.add(
            is_label_show=True,
            line_curve=0.2,#线条曲度
            line_opacity=0.6,
            legend_text_color="#fff",#图例文字颜色
            legend_pos="right",#图例位置
            geo_effect_symbol="plane",#特效形状
            geo_effect_symbolsize=15,#特效大小
            label_color=['#a6c84c', '#ffa022', '#46bee9'],
            label_pos="right",
            label_formatter="{b}",#//标签内容格式器
            label_text_color="#fff",
        )
        print(data)
        print(lastcity)
        geolines = GeoLines("逃离路线", **style.init_style)
        geolines.add("出发", data, **style_geo)
        geolines.render('aqi.html')
        
        self.webView.load(QUrl("file:///D:/源代码/aqi.html"))
        #self.webView.reload()
        self.webView.repaint()
        self.webView.update()
Пример #3
0
def ewide2(request):
    template = loader.get_template('ewpyecharts.html')

    style = Style(
        title_top="#fff",
        title_pos="center",
        width=1200,
        height=600,
        background_color="#404a59"
    )

    data_guangzhou = [
        ["广州", "上海"],
        ["广州", "北京"],
        ["广州", "南京"],
        ["广州", "重庆"],
        ["广州", "兰州"],
        ["广州", "杭州"]
    ]
    geolines = GeoLines("水务地图可视化--点线图", **style.init_style)
    geolines.add("从广州出发", data_guangzhou, is_legend_show=False)

    context = dict(
        myechart=geolines.render_embed(),
        host=REMOTE_HOST,
        script_list=geolines.get_js_dependencies()
    )
    return HttpResponse(template.render(context, request))
Пример #4
0
def my_Geolines():
    style = Style(title_top="#fff",
                  title_pos="center",
                  width=1200,
                  height=600,
                  background_color="#404a59")

    style_geo = style.add(
        is_label_show=True,
        line_curve=0.2,
        line_opacity=0.6,
        legend_text_color="#eee",
        legend_pos="right",
        geo_effect_symbol="plane",
        geo_effect_symbolsize=15,
        label_color=['#a6c84c', '#ffa022', '#46bee9'],
        label_pos="right",
        label_formatter="{b}",
        label_text_color="#eee",
    )
    data_guangzhou = [["珠海", "番禺区", 55], ["番禺区", "天河区", 6], ["天河区", "南昌", 259]]
    geolines = GeoLines("GeoLines 示例", **style.init_style)
    geolines.add("从广州出发",
                 data_guangzhou,
                 tooltip_formatter="{a} : {c}",
                 **style_geo)
    geolines.render()
Пример #5
0
def plot_geolines(plotting_data, geo_cities_coords):
    # 设置画布的格式
    style = Style(title_pos="center", width=1000, height=800)

    # 部分地理轨迹图的格式
    style_geolines = style.add(
        is_label_show=True,
        line_curve=0.3,  # 轨迹线的弯曲度,0-1
        line_opacity=0.6,  # 轨迹线的透明度,0-1
        geo_effect_symbol='plane',  # 特效的图形,有circle,plane,pin等等
        geo_effect_symbolsize=10,  # 特效图形的大小
        geo_effect_color='#7FFFD4',  # 特效的颜色
        geo_effect_traillength=0.1,  # 特效图形的拖尾效果,0-1
        label_color=['#FFA500', '#FFF68F'],  # 轨迹线的颜色,标签点的颜色,
        border_color='#97FFFF',  # 边界的颜色
        geo_normal_color='#36648B',  # 地图的颜色
        label_formatter='{b}',  # 标签格式
        legend_pos='left')

    # 作图
    geolines = GeoLines('出行轨迹图', **style.init_style)
    geolines.add(
        '从北京出发',
        plotting_data,
        maptype='china',  # 地图的类型,可以是省的地方,如'广东',也可以是地市,如'东莞'等等
        geo_cities_coords=geo_cities_coords,
        **style_geolines)

    # 发布,得到图形的html文件
    geolines.render()
Пример #6
0
def test_geolines():
    data_guangzhou = [["广州", "上海"], ["广州", "北京"], ["广州", "南京"], ["广州", "重庆"],
                      ["广州", "兰州"], ["广州", "杭州"]]
    data_beijing = [["北京", "上海"], ["北京", "广州"], ["北京", "南京"], ["北京", "重庆"],
                    ["北京", "兰州"], ["北京", "杭州"]]
    '''
    data_all = [
        ["北京", "上海"],
        ["北京", "广州"],
        ["北京", "南京"],
        ["北京", "重庆"],
        ["北京", "兰州"],
        ["北京", "杭州"],
        ["广州", "上海"],
        ["广州", "北京"],
        ["广州", "南京"],
        ["广州", "重庆"],
        ["广州", "兰州"],
        ["广州", "杭州"]       
        ]
        '''
    lines = GeoLines("GeoLines 示例", **style.init_style)
    lines.add("从广州出发", data_guangzhou, **style_geo)
    lines.add("从北京出发", data_beijing, **style_geo)
    #lines.add("ALL", data_all, **style_geo)
    lines.show_config()
    lines.render('geolines.html')
Пример #7
0
def ewide5(request):

    template = loader.get_template('ewpyecharts.html')
    style = Style(title_top="#fff",
                  title_pos="center",
                  width=1200,
                  height=600,
                  background_color="#404a59")
    style_geo = style.add(
        is_label_show=True,
        line_curve=0.2,
        line_opacity=0.6,
        legend_text_color="#eee",
        legend_pos="right",
        geo_effect_symbol="plane",
        geo_effect_symbolsize=15,
        label_color=['#a6c84c', '#ffa022', '#46bee9'],
        label_pos="right",
        label_formatter="{b}",
        label_text_color="#eee",
    )
    data_guangzhou = [["广州", "上海"], ["广州", "北京"], ["广州", "南京"], ["广州", "重庆"],
                      ["广州", "兰州"], ["广州", "杭州"]]
    data_beijing = [["北京", "上海"], ["北京", "广州"], ["北京", "南京"], ["北京", "重庆"],
                    ["北京", "兰州"], ["北京", "杭州"]]
    geolines1 = GeoLines("GeoLines 示例", **style.init_style)
    geolines1.add("从广州出发", data_guangzhou, **style_geo)
    geolines1.add("从北京出发", data_beijing, **style_geo)

    # geo.show_config()
    context = dict(myechart=geolines1.render_embed(),
                   host=REMOTE_HOST,
                   script_list=geolines1.get_js_dependencies())
    return HttpResponse(template.render(context, request))
Пример #8
0
def world_status():
    world = GeoLines('', **style.init_style)
    # 添加国际城市地理坐标
    sange = get_coordinate('Los Angeles', '美国')
    world.add_coordinate("Los Angeles", sange[0], sange[1])
    road = [
        ['Los Angeles', 'Los Angeles']
    ]
    world.add('', road, **style_geo)
    return world
Пример #9
0
    def getLines(self):
        collection = self.spring['cityroute']
        line_hangzhou = collection.aggregate([
            {'$match': {'from_poi.city.city_name': '杭州'}},
            {'$group': {'_id': '$to_poi.city.city_name', 'count': {'$sum': 1}}}
        ])
        line_beijing = collection.aggregate([
            {'$match': {'from_poi.city.city_name': '北京'}},
            {'$group': {'_id': '$to_poi.city.city_name', 'count': {'$sum': 1}}}
        ])
        line_shanghai = collection.aggregate([
            {'$match': {'from_poi.city.city_name': '上海'}},
            {'$group': {'_id': '$to_poi.city.city_name', 'count': {'$sum': 1}}}
        ])
        line_guangzhou = collection.aggregate([
            {'$match': {'from_poi.city.city_name': '广州'}},
            {'$group': {'_id': '$to_poi.city.city_name', 'count': {'$sum': 1}}}
        ])
        line_shenzhen = collection.aggregate([
            {'$match': {'from_poi.city.city_name': '深圳'}},
            {'$group': {'_id': '$to_poi.city.city_name', 'count': {'$sum': 1}}}
        ])
        line_hangzhou_ = []
        for line in line_hangzhou:
            line_hangzhou_.append(["杭州",line['_id'],line['count']])
        line_beijing_ = []
        for line in line_beijing:
            line_beijing_.append(["北京", line['_id'], line['count']])
        line_shanghai_ = []
        for line in line_shanghai:
            line_shanghai_.append(["上海", line['_id'], line['count']])
        line_guangzhou_ = []
        for line in line_guangzhou:
            line_guangzhou_.append(["广州", line['_id'], line['count']])
        line_shenzhen_ = []
        for line in line_shenzhen:
            line_shenzhen_.append(["深圳", line['_id'], line['count']])

        citylines = GeoLines("春节迁移路线图", **style.init_style)
        citylines.add("从北京出发",
                      line_beijing_,
                      **geo_style)
        citylines.add("从上海出发",
                      line_shanghai_,
                      **geo_style)
        citylines.add("从广州出发",
                      line_guangzhou_,
                      **geo_style)
        citylines.add("从深圳出发",
                      line_shenzhen_,
                      **geo_style)
        citylines.add("从杭州出发",
                      line_hangzhou_,
                      **geo_style)
        citylines.render("results/citylines.html")
Пример #10
0
def test_geolines():
    data_guangzhou = [["广州", "上海"], ["广州", "北京"], ["广州", "南京"], ["广州", "重庆"],
                      ["广州", "兰州"], ["广州", "杭州"]]
    data_beijing = [["北京", "上海"], ["北京", "广州"], ["北京", "南京"], ["北京", "重庆"],
                    ["北京", "兰州"], ["北京", "杭州"]]
    lines = GeoLines("GeoLines 示例", **style.init_style)
    lines.add("从广州出发", data_guangzhou, **style_geo)
    lines.add("从北京出发", data_beijing, **style_geo)
    #lines.add(angle_data, angle_range, area_color, area_opacity, axis_range, bar_category_gap, border_color, boundary_gap, center, calendar_date_range, calendar_cell_size, datazoom_type, datazoom_range, datazoom_orient, datazoom_xaxis_index, datazoom_yaxis_index, effect_brushtype, effect_period, effect_scale, extra_data, geo_emphasis_color, geo_normal_color, geo_cities_coords, geo_effect_period, geo_effect_traillength, geo_effect_color, geo_effect_symbol, geo_effect_symbolsize, graph_layout, graph_gravity, graph_edge_length, graph_repulsion, graph_edge_symbol, graph_edge_symbolsize, grid_width, grid_height, grid_top, grid_bottom, grid_left, grid_right, grid3d_width, grid3d_height, grid3d_depth, grid3d_opacity, grid3d_shading, grid3d_rotate_speed, grid3d_rotate_sensitivity, is_angleaxis_show, is_area_show, is_axisline_show, is_calculable, is_calendar_heatmap, is_clockwise, is_convert, is_datazoom_show, is_fill, is_focusnode, is_geo_effect_show, is_grid3d_rotate, is_label_show, is_label_emphasis, is_legend_show, is_liquid_animation, is_liquid_outline_show, is_more_utils, is_piecewise, is_radiusaxis_show, is_random, is_roam, is_rotatelabel, is_smooth, is_splitline_show, is_stack, is_step, is_symbol_show, is_map_symbol_show, is_visualmap, is_xaxislabel_align, is_yaxislabel_align, is_xaxis_inverse, is_yaxis_inverse, is_xaxis_boundarygap, is_yaxis_boundarygap, is_xaxis_show, is_yaxis_show, item_color, label_color, label_pos, label_text_color, label_text_size, label_formatter, label_emphasis_textcolor, label_emphasis_textsize, label_emphasis_pos, legend_orient, legend_pos, legend_top, legend_selectedmode, legend_text_size, legend_text_color, line_curve, line_opacity, line_type, line_width, line_color, liquid_color, maptype, mark_line, mark_line_symbolsize, mark_line_valuedim, mark_point, mark_point_symbol, mark_point_symbolsize, mark_point_textcolor, radius_data, radius, rosetype, rotate_step, scale_range, shape, start_angle, symbol_size, symbol, sankey_node_width, sankey_node_gap, type, tooltip_tragger, tooltip_tragger_on, tooltip_axispointer_type, tooltip_formatter, tooltip_text_color, tooltip_font_size, treemap_left_depth, treemap_drilldown_icon, treemap_visible_min, visual_orient, visual_range_color, visual_range_size, visual_range_text, visual_range, visual_text_color, visual_pos, visual_top, visual_type, visual_split_number, visual_dimension, word_gap, word_size_range, x_axis, xaxis_margin, xaxis_interval, xaxis_force_interval, xaxis_pos, xaxis_name_gap, xaxis_name_size, xaxis_name_pos, xaxis_name, xaxis_rotate, xaxis_min, xaxis_max, xaxis_type, xaxis3d_name, xaxis3d_name_size, xaxis3d_name_gap, xaxis3d_min, xaxis3d_max, xaxis3d_interval, xaxis3d_margin, yaxis_margin, yaxis_interval, yaxis_force_interval, yaxis_pos, yaxis_formatter, yaxis_rotate, yaxis_min, yaxis_max, yaxis_name_gap, yaxis_name_size, yaxis_name_pos, yaxis_type, yaxis_name, yaxis3d_name, yaxis3d_name_size, yaxis3d_name_gap, yaxis3d_min, yaxis3d_max, yaxis3d_interval, yaxis3d_margin, zaxis3d_name, zaxis3d_name_size, zaxis3d_name_gap, zaxis3d_min, zaxis3d_max, zaxis3d_margin)
    lines.show_config()
    lines.render('geolines_x.html')
Пример #11
0
def test_geolines(patched):
    fixture = "geolines.json"
    patched.return_value = "1"
    data_guangzhou = [["广州", "上海"]]
    data_beijing = [["北京", "上海"]]
    lines = GeoLines("GeoLines 示例", **style.init_style)
    lines.add("从广州出发", data_guangzhou, **style_geo)
    lines.add("从北京出发", data_beijing, **style_geo)
    actual_options = dumps_actual_options(lines.options)
    expected = get_fixture_content(fixture)
    for a, b in zip(actual_options.split("\n"), expected.split("\n")):
        eq_(a.strip(), b.strip())
Пример #12
0
def test_with_full_example():
    line_data = [["广州", "上海"], ["广州", "北京"], ["广州", "南京"], ["广州", "A市"]]

    lines = GeoLines("GeoLines 示例", **style.init_style)

    with assert_raises(ValueError):
        lines.add("从广州出发", line_data, **style_geo)

    assert 0 == len(search_coordinates_by_keyword("A市"))

    lines.add_coordinate("A市", 119.3, 26.08)
    lines.add("从广州出发", line_data, **style_geo)
    lines.render()
Пример #13
0
def test_with_full_example():
    line_data = [["广州", "上海"], ["广州", "北京"], ["广州", "南京"], ["广州", "A市"]]

    lines = GeoLines("GeoLines 示例", **style.init_style)

    with assert_raises(ValueError):
        lines.add("从广州出发", line_data, **style_geo)

    assert 0 == len(search_coordinates_by_keyword("A市"))

    lines.add_coordinate("A市", 119.3, 26.08)
    lines.add("从广州出发", line_data, **style_geo)
    lines.render()
Пример #14
0
    def renderHtml(self, leave_time, html_data):
        plane_map = GeoLines("航线分时展示", **self.style.init_style)  # 相当于设置背景

        for city_name in self.flight_data[leave_time]:

            html_data.append([self.from_city, city_name])
            map_name = '在' + str(leave_time) + '时从' + self.from_city + '起飞的飞机:'
            try:
                plane_map.add(map_name, html_data,
                                   tooltip_formatter="{a} : {c}", **self.style_geo)
            except Exception as e:
                pass  # 忽略无法标识出来的城市

        plane_map.render(self.local + '/t' + str(leave_time+1) + '.html')
Пример #15
0
def test_geolines_value_and_formatter():
    data_guangzhou = [
        ["广州", "上海", 10],
        ["广州", "北京", 20],
        ["广州", "南京", 30],
        ["广州", "重庆", 40],
        ["广州", "兰州", 50],
        ["广州", "杭州", 60],
    ]
    lines = GeoLines("GeoLines 示例", **style.init_style)
    lines.add("从广州出发",
              data_guangzhou,
              tooltip_formatter="{a} : {c}",
              **style_geo)
    html_content = lines._repr_html_()
    assert '"value": 10' in html_content
    assert '"value": 60' in html_content
Пример #16
0
def reload_data(addrs, local, dataset, ip_from):
    local_coord = local[0]
    local_city = local[1]

    road = []
    # 实例化世界地图
    world = GeoLines('', **style.init_style)
    try:
        # 添加本机坐标
        world.add_coordinate(local_city, local_coord[0], local_coord[1])
    except:
        # 重复添加可能会出错?
        pass

    if addrs:
        for ips in addrs:
            ips = loads(ips)
            ip = list(ips.keys())[0]
            is_evil = list(ips.values())[0]
            try:
                info = dataset.city(ip)
                ip_city = info.city.name
                ip_country = info.country.name
                # 经纬度
                ip_coord = [info.location.longitude, info.location.latitude]
                if ip_city and ip_country:
                    world.add_coordinate(ip_city, ip_coord[0], ip_coord[1])
                    path = [ip_city, local_city]
                    road.append(path)
                    if ip_country not in ip_from:
                        ip_from[ip_country] = 1
                    else:
                        ip_from[ip_country] += 1
            except:
                pass
    else:
        road = [['Los Angeles', local_city]]

    world.add('', road, **style_geo)
    option = world.get_options()
    # options中存在 Tooltip 对象,无法直接使用 json.dumps 转换,需要理由 pyecharts 的 TRANSLATOR API函数
    option = TRANSLATOR.translate(option)
    option = option.as_snippet()

    return option, ip_from
Пример #17
0
def gen_render_html(
        nodes_path,
        edges_path,
        output_path=r'../results/energy/figure/2015-2017-finished/city_coop.html'
):
    # 读取节点和边
    nodes = pd.read_csv(nodes_path, delimiter=';')
    edges = pd.read_csv(edges_path, delimiter=';')

    # 设置生成echarts地理流向图的配置
    geocode = {
        nodes.iloc[i]['name']:
        [nodes.iloc[i]['Longitude'], nodes.iloc[i]['Latitude']]
        for i in range(len(nodes))
    }
    style = Style(title_color="#fff",
                  title_pos="center",
                  width=2400,
                  height=1200,
                  background_color="white")
    edge_data = [[
        edges.iloc[i]['source'], edges.iloc[i]['target'],
        edges.iloc[i]['weight']
    ] for i in range(len(edges))]
    style_geo = style.add(line_opacity=0.2, line_color='#2980b9')

    # 渲染
    geolines = GeoLines('城市合作网络', **style.init_style)
    geolines.add("",
                 edge_data,
                 maptype='world',
                 geo_cities_coords=geocode,
                 is_geo_effect_show=False,
                 is_roam=False,
                 symbol_size=0,
                 geo_normal_color='#dcdcdc',
                 border_color='black',
                 **style_geo)

    os.makedirs(os.path.dirname(output_path), exist_ok=True)
    geolines.render(output_path)

    return
Пример #18
0
def test_with_custom_coordinates():
    data_guangzhou = [
        ["广州", "上海"],
        ["广州", "北京"],
        ["广州", "南京"],
        ["广州", "重庆"],
        ["广州", "兰州"],
        ["广州", "A市"],
    ]
    lines = GeoLines("GeoLines 示例", **style.init_style)
    coordinate = lines.get_coordinate("广州")
    assert 2 == len(coordinate)
    with assert_raises(ValueError):
        lines.get_coordinate("A市", raise_exception=True)

    lines.add("从广州出发",
              data_guangzhou,
              geo_cities_coords={"A市": (119.3, 26.08)},
              **style_geo)
    lines.render()
Пример #19
0
def geolines():
    data_beijing = [["北京", "上海"], ["北京", "广州"], ["北京", "南京"], ["北京", "重庆"],
                    ["北京", "兰州"], ["北京", "杭州"]]

    data_guangzhou = [
        ["广州", "上海", 10],
        ["广州", "北京", 20],
        ["广州", "南京", 30],
        ["广州", "重庆", 40],
        ["广州", "兰州", 50],
        ["广州", "杭州", 60],
    ]
    style = Style(title_top="#fff",
                  title_pos="center",
                  width=1200,
                  height=600,
                  background_color="#404a59")

    style_geo = style.add(
        is_label_show=True,
        line_curve=0.2,
        line_opacity=0.6,
        legend_text_color="#eee",
        legend_pos="right",
        geo_effect_symbol="plane",
        geo_effect_symbolsize=15,
        label_color=['#a6c84c', '#ffa022', '#46bee9'],
        label_pos="right",
        label_formatter="{b}",
        label_text_color="#eee",
    )
    geolines = GeoLines("GeoLines", **style.init_style)
    geolines.add("从广州出发", data_guangzhou, **style_geo)
    geolines.add("从北京出发", data_beijing, **style_geo)
    # geolines.render()
    return render_template(
        'geolines.html',
        geolines=geolines.render_embed(),
        host=REMOTE_HOST,
        script_list=geolines.get_js_dependencies(),
    )
Пример #20
0
    def checkFromCity(self, from_city):
        self.from_city = from_city
        # 1、检查输入的城市是否有飞机场
        if self.from_city in self.cities_code:
            # 2、检查输入城市是否能在地图上标识
            try:
                plane_map = GeoLines("航线分时展示", **self.style.init_style)
                plane_map.add('', [[from_city, '大连']],tooltip_formatter="{a} : {c}", **self.style_geo)
            except Exception as e:
                print('抱歉,输入城市无法显示,你可以尝试输入其他城市。')
                return False

            self.from_city_code = self.cities_code[self.from_city]
            if not os.path.exists(self.local):
                os.makedirs(self.local)
            print('初始化链接。。。')

            return True
        else:
            print('起点城市名输入错误,请重新输入')
            return False
Пример #21
0
def test_geolines():
    data_guangzhou = [
        ["广州", "上海"],
        ["广州", "北京"],
        ["广州", "南京"],
        ["广州", "重庆"],
        ["广州", "兰州"],
        ["广州", "杭州"],
    ]
    data_beijing = [
        ["北京", "上海"],
        ["北京", "广州"],
        ["北京", "南京"],
        ["北京", "重庆"],
        ["北京", "兰州"],
        ["北京", "杭州"],
    ]
    lines = GeoLines("GeoLines 示例", **style.init_style)
    lines.add("从广州出发", data_guangzhou, **style_geo)
    lines.add("从北京出发", data_beijing, **style_geo)
    lines.render()
Пример #22
0
    def plot_upstream(self,outputname):
        self.init_dict_trans_isvisit()
        style = Style(
            title_color="#fff",
            title_pos="center",
            width=1510,
            height=840,
            background_color="#404a59" # #404a59"
        )

        style_geo = style.add(
            maptype="china",
            is_label_show=False,
            line_curve=0.1,
            line_opacity=0.6,
            legend_text_color="#eee",
            legend_pos="right",
            geo_effect_symbol="arrow",
            symbol_size=5,
            geo_effect_symbolsize=5,
            label_color=['#a6c84c', '#46bee9','red'],
            label_pos="right",
            label_formatter="{b}",
            label_text_color="#eee",
        )

        geolines = GeoLines(outputname, **style.init_style)
        geolines.add(name = "轻度",data = self.prop_df[self.prop_df['class']=='轻度'][['Source','Target']].values.tolist(),
                     is_legend_show=False,**style_geo)
        geolines.add(name = "中度",data = self.prop_df[self.prop_df['class']=='中度'][['Source','Target']].values.tolist(),
                     is_legend_show=True,**style_geo)
        geolines.add(name = "重度",data = self.prop_df[self.prop_df['class']=='重度'][['Source','Target']].values.tolist(),
                     is_legend_show=True,**style_geo)
        geolines.render(outputname+'.html')
Пример #23
0
def test_with_custom_coordinates():
    data_guangzhou = [
        ["广州", "上海"],
        ["广州", "北京"],
        ["广州", "南京"],
        ["广州", "重庆"],
        ["广州", "兰州"],
        ["广州", "A市"],
    ]
    lines = GeoLines("GeoLines 示例", **style.init_style)
    coordinate = lines.get_coordinate("广州")
    assert 2 == len(coordinate)
    with assert_raises(ValueError):
        lines.get_coordinate("A市", raise_exception=True)

    lines.add(
        "从广州出发",
        data_guangzhou,
        geo_cities_coords={"A市": (119.3, 26.08)},
        **style_geo
    )
    lines.render()
Пример #24
0
def test_geolines():
    data_guangzhou = [
        ["广州", "上海"],
        ["广州", "北京"],
        ["广州", "南京"],
        ["广州", "重庆"],
        ["广州", "兰州"],
        ["广州", "杭州"],
    ]
    data_beijing = [
        ["北京", "上海"],
        ["北京", "广州"],
        ["北京", "南京"],
        ["北京", "重庆"],
        ["北京", "兰州"],
        ["北京", "杭州"],
    ]
    lines = GeoLines("GeoLines 示例", **style.init_style)
    lines.add("从广州出发", data_guangzhou, **style_geo)
    lines.add("从北京出发", data_beijing, **style_geo)
    lines.print_echarts_options()
    lines.render()
Пример #25
0
    def plot_bfs(self, outputname, source_city='上海市', k=5, minimum=300):
        import json
        dict_nn = self.bfs(source_city, k, minimum=minimum)
        jsonstr = json.dumps(dict_nn) 
        filename = open(outputname+'.json', 'w')  # dict转josn
        filename.write(jsonstr)
        style = Style(
            title_color="#fff",
            title_pos="center",
            width=1510,
            height=840,
            background_color="#404a59"  # #404a59"
        )

        style_geo = style.add(
            maptype="china",
            is_label_show=False,
            line_curve=0.1,
            line_opacity=0.6,
            legend_text_color="#eee",
            legend_pos="right",
            geo_effect_symbol="arrow",
            symbol_size=5,
            geo_effect_symbolsize=5,
            label_color=['#a6c84c', '#46bee9', 'red', '#ffa022','green'],#'#a6c84c'
            label_pos="right",
            label_formatter="{b}",
            label_text_color="#eee",
            # geo_cities_coords=airports_geo
        )

        geolines = GeoLines(outputname, **style.init_style)
        for i in range(1,k+1):
            geolines.add(name=str(i)+"阶", data=dict_nn[i],
                         is_legend_show=True, **style_geo)
        geolines.render(outputname+'近邻城市.html')
        return dict_nn
Пример #26
0
def test3():
    style = Style(title_top="#fff",
                  title_pos="center",
                  width=1200,
                  height=600,
                  background_color="404a59")
    style_geo = style.add(
        is_label_show=True,
        line_curve=0.2,
        line_opacity=0.6,
        legend_text_color="#eee",
        legend_pos="right",
        geo_effect_symbol="plane",
        geo_effect_symbolsize=15,
        label_color=['#a6c84c', '#ffa022', '#46bee9'],
        label_pos="right",
        label_formatter="{b}",
        label_text_color="#eee",
    )
    data_guangzhou = [["广州", "上海"], ["广州", "北京"], ["广州", "南京"], ["广州", "重庆"],
                      ["广州", "兰州"], ["广州", "杭州"]]
    geolines = GeoLines("GeoLines 示例", **style.init_style)
    geolines.add("从广州出发", data_guangzhou, **style_geo)
    geolines.render("coordinate.html")
def geolines():
    """地理坐标系线图"""
    data_beijing = [["北京", "上海"], ["北京", "广州"], ["北京", "南京"], ["北京", "重庆"],
                    ["北京", "兰州"], ["北京", "杭州"]]
    data_guangzhou = [
        ["广州", "上海", 10],
        ["广州", "北京", 20],
        ["广州", "南京", 30],
        ["广州", "重庆", 40],
        ["广州", "兰州", 50],
        ["广州", "杭州", 60],
    ]
    data_shanghai = [
        ["上海", "广州", 10],
        ["上海", "北京", 20],
        ["上海", "南京", 30],
        ["上海", "重庆", 40],
        ["上海", "兰州", 50],
        ["上海", "杭州", 60],
    ]
    style = Style(title_top="#fff",
                  title_pos="center",
                  width=1200,
                  height=800,
                  background_color="#404a59")
    style_geo = style.add(
        is_label_show=True,
        line_curve=0.2,
        line_opacity=0.6,
        legend_text_color="#eee",
        legend_pos="right",
        geo_effect_symbol="plane",
        geo_effect_symbolsize=15,
        label_color=['#a6c84c', '#ffa022', '#46bee9'],
        label_pos="right",
        label_formatter="{b}",
        label_text_color="#eee",
    )
    geolines = GeoLines("地理坐标系线图", **style.init_style)
    geolines.add("从广州出发", data_guangzhou, **style_geo)
    geolines.add("从北京出发", data_beijing, **style_geo)
    geolines.add("从上海出发", data_shanghai, **style_geo)
    geolines.render("地理坐标系线图.html")
Пример #28
0
    is_label_show=True,
    line_curve=0.2,
    line_opacity=0.6,
    lengend_text_color='#eee',
    lengend_pos='right',
    geo_effect_symbol='plane',
    geo_effect_symbolsize=15,
    label_color=['#a6c84c', '#ffa022', '#46bee9'],
    label_pos='right',
    label_formatter="{b}",
    label_text_color="#eee",
    legend_selectedmode="single",
)

data_guangzhou = [["广州", "上海"], ["广州", "北京"], ["广州", "南京"], ["广州", "重庆"],
                  ["广州", "兰州"], ["广州", "杭州"]]
data_beijing = [["北京", "上海"], ["北京", "广州"], ["北京", "南京"], ["北京", "重庆"],
                ["北京", "兰州"], ["北京", "杭州"]]

geolines = GeoLines("GeoLines 示例", **style.init_style)
geolines.add("从广州出发",
             data_guangzhou,
             **style_geo,
             is_lengend_show=True,
             legend_top="10%")
geolines.add("从北京出发",
             data_beijing,
             **style_geo,
             is_lengend_show=True,
             legend_top="10%")
geolines.render()
Пример #29
0
def create_charts(data):
    style = Style(width=900, height=900)
    page = Page()
    html=''
    charts = GeoLines("丝绸之路", **style.init_style)

    data_eastnorth = [
        ['西安市', '彬县'],
        ['彬县', '泾川县'],
        ['泾川县', '固原市'],
        ['固原市', '靖远县'],
        ['靖远县', '武威市'],
        ['武威市', '张掖市']
    ]
    charts.add("东段北线", data_eastnorth, **style_geo)

    data_eastmid = [
        ['西安市', '彬县'],
        ['彬县', '泾川县'],
        ['泾川县', '平凉市'],
        ['平凉市', '会宁县'],
        ['会宁县', '兰州市'],
        ['兰州市', '武威市'],
        ['武威市', '张掖市']

    ]
    charts.add("东段中线", data_eastmid, **style_geo)

    data_eastsouth = [
        ['西安市', '凤翔县'],
        ['凤翔县', '天水市'],
        ['天水市', '陇西县'],
        ['陇西县', '临夏市'],
        ['临夏市', '乐都县'],
        ['乐都县', '西宁市'],
        ['西宁市', '张掖市']
    ]
    charts.add("东段南线", data_eastsouth, **style_geo)

    data_hexizoulang = [
        ['张掖', '酒泉'],
        ['酒泉', '玉门'],
        ['玉门', '瓜州']
    ]
    charts.add("河西走廊", data_hexizoulang, geo_cities_coords={
        '张掖': [100.45, 38.93],
        '酒泉': [98.500685, 39.740023],
        '玉门': [97.055736, 40.296519],
        '瓜州': [95.793335, 40.530274]
    }, **style_geo)


    data_westnorth = [
        ['瓜州', '哈密'],
        ['哈密', '伊川'],
        ['伊川', '吉木萨尔'],
        ['吉木萨尔', '乌鲁木齐'],
        ['乌鲁木齐', '伊宁'],
        ['伊宁', '碎叶']
    ]
    charts.add("中段北道", data_westnorth, geo_cities_coords={
        '瓜州': [95.793335, 40.530274],
        '哈密': [93.52294, 42.833441],
        '伊川': [91.435282, 43.430981],
        '吉木萨尔': [89.181374, 44.004888],
        '乌鲁木齐': [87.62214, 43.831179],
        '伊宁': [81.283092, 43.916546],
        '碎叶': [75.283092, 43.831179]
    }, **style_geo)

    data_westmid = [
        ['瓜州', '敦煌'],
        ['敦煌', '玉门关'],
        ['玉门关', '高昌'],
        ['高昌', '焉耆'],
        ['焉耆', '库车'],
        ['库车', '阿克苏'],
        ['阿克苏', '喀什'],
        ['喀什', '大宛']
    ]
    charts.add("中段中道",data_westmid, geo_cities_coords={
        '瓜州': [95.793335, 40.530274],
        '敦煌': [94.6806, 40.148308],
        '玉门关': [93.871678, 40.360147],
        '高昌': [89.192459, 42.948971],
        '焉耆': [86.588696, 42.065708],
        '库车': [82.969034, 41.723448],
        '阿克苏': [80.258894, 41.175899],
        '喀什': [75.975982,39.542678],
        '大宛': [70.258894, 41.175899]
    }, **style_geo)

    data_westsouth = [
        ['瓜州', '敦煌'],
        ['敦煌', '阳关'],
        ['阳关', '若羌县'],
        ['若羌县', '且丰县'],
        ['且丰县', '和田'],
        ['和田', '莎车'],
        ['莎车', '葱岭']
    ]
    charts.add("中段南道", data_westsouth, geo_cities_coords={
        '瓜州': [95.793335, 40.530274],
        '敦煌': [94.6806, 40.148308],
        '阳关': [94.060858, 39.940913],
        '若羌县': [89.060858, 39.940913],
        '且丰县': [86.560858, 38.540919],
        '和田': [79.933681, 37.121827],
        '莎车': [77.249562, 38.422871],
        '葱岭': [72.249562, 37.921827]

    }, **style_geo)
    page.add(charts)
    html=charts.render_embed()

    script = page.get_js_dependencies()
    return html, script
Пример #30
0
# -*- coding:utf-8 -*-
# 制作3D动态航线图

from pyecharts import GeoLines, Style

style = Style(title_top="#fff",
              title_pos="center",
              width=1200,
              height=600,
              background_color="#404a59")

data_guangzhou = [["广州", "上海"], ["广州", "北京"], ["广州", "南京"], ["广州", "重庆"],
                  ["广州", "兰州"], ["广州", "杭州"]]

geolines = GeoLines("GeoLines 示例", **style.init_style)
geolines.add("从广州出发", data_guangzhou, is_legend_show=False)
geolines.render("F:/Python-study-diary/pyechartsss/airport2.html")
Пример #31
0
style = Style(title_top="#fff",
              title_pos="center",
              width=1000,
              height=500,
              background_color="#404a59")

style_geo = style.add(
    is_label_show=True,
    line_curve=0.2,
    line_opacity=0.6,
    legend_text_color="#eee",
    legend_pos="right",
    geo_effect_symbol="plane",
    geo_effect_symbolsize=15,
    label_color=['#a6c84c', '#ffa022', '#46bee9'],
    label_pos="right",
    label_formatter="{b}",
    label_text_color="#eee",
    legend_selectedmode="single",  #指定单例模式
)

data_beijing = [["北京", "上海"], ["北京", "广州"], ["北京", "南京"], ["北京", "重庆"],
                ["北京", "兰州"], ["北京", "杭州"]]

data_guangzhou = [["广州", "上海"], ["广州", "北京"], ["广州", "南京"], ["广州", "重庆"],
                  ["广州", "兰州"], ["广州", "杭州"]]
geolines = GeoLines("GeoLines 示例", **style.init_style)
geolines.add("从广州出发", data_guangzhou, **style_geo)
geolines.add("从北京出发", data_beijing, **style_geo)
geolines.render("地图线.html")
geolines
Пример #32
0
)

data_shanghai=[
    ["上海", "广州"],
    ["上海", "北京"],
    ["上海", "南京"],
    ["上海", "重庆"],
    ["上海", "兰州"],
    ["上海", "杭州"]
]
data_guangzhou=[
    ["广州", "上海", 10],
    ["广州", "北京", 20],
    ["广州", "南京", 30],
    ["广州", "重庆", 40],
    ["广州", "兰州", 50],
    ["广州", "杭州", 60]
]
data_beijing = [
    ["北京", "上海"],
    ["北京", "广州"],
    ["北京", "南京"],
    ["北京", "重庆"],
    ["北京", "兰州"],
    ["北京", "杭州"]
]
geoline=GeoLines('线路示例',**style.init_style)
geoline.add('从上海出发',data_shanghai,maptype='china',is_more_utils=True,**style_geo)
geoline.add('从广州出发',data_guangzhou,maptype='china',tooltip_formatter="{a} : {c}",is_more_utils=True,**style_geo)
geoline.add('从北京出发',data_beijing,maptype='china',is_more_utils=True,**style_geo)
geoline.render()
Пример #33
0
    width=1200,
    height=600,
    background_color="#404a59"
)
data_guangzhou = [
    ["广州", "上海"],
    ["广州", "北京"],
    ["广州", "南京"],
    ["广州", "重庆"],
    ["广州", "兰州"],
    ["广州", "杭州"]
]

style_geo = style.add(
    is_label_show=True,
    line_curve=0.2,
    line_opacity=0.6,
    legend_text_color="#eee",
    legend_pos="right",
    geo_effect_symbol="plane",
    geo_effect_symbolsize=15,
    label_color=['#a6c84c', '#ffa022', '#46bee9'],
    label_pos="right",
    label_formatter="{b}",
    label_text_color="#eee",
)
geolines = GeoLines("GeoLines 示例", **style.init_style)
geolines.add("从广州出发", data_guangzhou, **style_geo)
geolines.render()