def test_world_map(): value = [95.1, 23.2, 43.3, 66.4, 88.5, 0.1] attr = [ "China", "Canada", "Brazil", "Russia", "United States", "Unknown Country", ] map = Map("世界地图示例", width=1200, height=600) map.add( "", attr, value, maptype="world", is_visualmap=True, visual_text_color="#000", ) map.render() actual_content = get_default_rendering_file_content() # test register map assert 'registerMap("world",' in actual_content # test non-existent country assert "Russia" in actual_content assert "Unknown Country', " not in actual_content
def test_world_map(): value = [95.1, 23.2, 43.3, 66.4, 88.5, 0.1] attr = [ "China", "Canada", "Brazil", "Russia", "United States", "Unknown Country", ] map = Map("世界地图示例", width=1200, height=600) map.add( "", attr, value, maptype="world", is_visualmap=True, visual_text_color='#000', ) map.render() actual_content = get_default_rendering_file_content() # test register map assert "registerMap(\"world\"," in actual_content # test non-existent country assert "Russia" in actual_content assert "Unknown Country', " not in actual_content
def test_polar_draw_snail(): render_polar() content = get_default_rendering_file_content() assert "function custom_polar_render_item(params, api)" in content assert 'return "test"' in content assert '"renderItem": custom_polar_render_item' in content os.unlink("render.html")
def test_label_formatter_with_function(): generic_formatter_t_est(label_formatter=label_formatter) content = get_default_rendering_file_content() assert 'function label_formatter(params)' in content assert 'params.name + \"abc\"' in content assert '"formatter": label_formatter' in content os.unlink('render.html')
def test_xaxis_formatter_with_function(): generic_formatter_t_est(tooltip_formatter=tooltip_formatter) content = get_default_rendering_file_content() assert "function tooltip_formatter(params)" in content assert 'params.name + "abc"' in content assert '"formatter": tooltip_formatter' in content os.unlink("render.html")
def test_online_html(): online() bar = Bar() bar.add("", CLOTHES, [5, 20, 36, 10, 75, 90], is_stack=True) bar.render() html_content = get_default_rendering_file_content() assert ('src="https://pyecharts.github.io/assets/js/echarts.min.js' in html_content) CURRENT_CONFIG.jshost = None CURRENT_CONFIG.hosted_on_github = False
def test_map_show_label(): # show label value = [155, 10, 66, 78] attr = ["福建", "山东", "北京", "上海"] map = Map("全国地图示例", width=1200, height=600) map.add("", attr, value, maptype="china", is_label_show=True) map.on(events.MOUSE_CLICK, on_click) map.render() content = get_default_rendering_file_content() assert "function on_click(params) {" in content assert '("click", on_click);' in content
def test_map_show_label(): # show label value = [155, 10, 66, 78] attr = ["福建", "山东", "北京", "上海"] map = Map("全国地图示例", width=1200, height=600) map.add("", attr, value, maptype='china', is_label_show=True) map.on(events.MOUSE_CLICK, on_click) map.render() content = get_default_rendering_file_content() assert 'function on_click(params) {' in content assert '("click", on_click);' in content
def test_kline_alias_Candlestick(): from pyecharts import Candlestick candlestick = Candlestick("K 线图-自定义标记点风格") candlestick.add("日K", DATE, data, mark_point=["min", "max"], mark_point_symbolsize=80, datazoom_orient='vertical', mark_line_valuedim=['lowest', 'highest']) candlestick.render() actual_content = get_default_rendering_file_content() assert 'candlestick' in actual_content
def test_echarts_position_in_render_html(): value = [20, 190, 253, 77, 65] attr = ['汕头市', '汕尾市', '揭阳市', '阳江市', '肇庆市'] map = Map("广东地图示例", width=1200, height=600, page_title=TITLE) map.add("", attr, value, maptype='广东', is_visualmap=True, visual_text_color='#000') map.render() actual_content = get_default_rendering_file_content() assert TITLE in actual_content
def test_china_map(): value = [155, 10, 66, 78] attr = ["福建", "山东", "北京", "上海"] map = Map("全国地图示例", width=1200, height=600) map.add("", attr, value, maptype="china") map.render() actual_content = get_default_rendering_file_content() # test register map assert 'registerMap("china",' in actual_content # 福建省 assert "\u798f\u5efa" in actual_content # 汕头市 assert "\u4e0a\u6d77" in actual_content
def test_china_map(): value = [155, 10, 66, 78] attr = ["福建", "山东", "北京", "上海"] map = Map("全国地图示例", width=1200, height=600) map.add("", attr, value, maptype='china') map.render() actual_content = get_default_rendering_file_content() # test register map assert "registerMap(\"china\"," in actual_content # 福建省 assert "\u798f\u5efa" in actual_content # 汕头市 assert "\u4e0a\u6d77" in actual_content
def test_echarts_position_in_render_html(): value = [20, 190, 253, 77, 65] attr = ["汕头市", "汕尾市", "揭阳市", "阳江市", "肇庆市"] map = Map("广东地图示例", width=1200, height=600, page_title=TITLE) map.add( "", attr, value, maptype="广东", is_visualmap=True, visual_text_color="#000", ) map.render() actual_content = get_default_rendering_file_content() assert TITLE in actual_content
def test_kline_user_define_markline_style(): title = "K 线图-自定义标记点风格" kline = Kline(title) kline.add("日K", DATE, data, mark_point=["min", "max"], mark_point_symbolsize=80, datazoom_orient='vertical', mark_line_valuedim=['lowest', 'highest']) kline.render() actual_content = get_default_rendering_file_content() assert 'lowest' in actual_content assert 'highest' in actual_content assert json.dumps(title) in actual_content
def test_echarts_position_in_render_html(): value = [20, 190, 253, 77, 65] attr = ["汕头市", "汕尾市", "揭阳市", "阳江市", "肇庆市"] map = Map("广东地图示例", width=1200, height=600, page_title=TITLE) map.add( "", attr, value, maptype="广东", is_visualmap=True, visual_text_color="#000", ) map.render() actual_content = get_default_rendering_file_content() assert TITLE in actual_content
def test_map_with_custom_name_map(): # show label value = [155, 10, 66, 78] attr = ["福建", "山东", "北京", "上海"] map = Map("全国地图示例", width=1200, height=600) map.add("", attr, value, maptype='china', is_label_show=True, name_map={'test': '--magic--'}) map.render() content = get_default_rendering_file_content() assert '--magic--' in content assert 'nameMap' in content
def test_kline_alias_Candlestick(): from pyecharts import Candlestick candlestick = Candlestick("K 线图-自定义标记点风格") candlestick.add( "日K", DATE, data, mark_point=["min", "max"], mark_point_symbolsize=80, datazoom_orient="vertical", mark_line_valuedim=["lowest", "highest"], ) candlestick.render() actual_content = get_default_rendering_file_content() assert "candlestick" in actual_content
def test_kline_user_define_markline_style(): title = "K 线图-自定义标记点风格" kline = Kline(title) kline.add( "日K", DATE, data, mark_point=["min", "max"], mark_point_symbolsize=80, datazoom_orient="vertical", mark_line_valuedim=["lowest", "highest"], ) kline.render() actual_content = get_default_rendering_file_content() assert "lowest" in actual_content assert "highest" in actual_content assert json.dumps(title) in actual_content
def test_echarts_position_in_render_html(): value = [20, 190, 253, 77, 65] attr = ['汕头市', '汕尾市', '揭阳市', '阳江市', '肇庆市'] map = Map("广东地图示例", width=1200, height=600) map.add("", attr, value, maptype='广东', is_map_symbol_show=False, is_visualmap=True, visual_text_color='#000') map.render() content = get_default_rendering_file_content() echarts_position = content.find('exports.echarts') guangdong_position = content.find(json.dumps('广东')) assert echarts_position < guangdong_position assert '"showLegendSymbol": false' in content
def test_map_with_custom_name_map(): # show label value = [155, 10, 66, 78] attr = ["福建", "山东", "北京", "上海"] map = Map("全国地图示例", width=1200, height=600) map.add( "", attr, value, maptype="china", is_label_show=True, name_map={"test": "--magic--"}, ) map.render() content = get_default_rendering_file_content() assert "--magic--" in content assert "nameMap" in content
def test_echarts_position_in_render_html(): value = [20, 190, 253, 77, 65] attr = ["汕头市", "汕尾市", "揭阳市", "阳江市", "肇庆市"] map = Map("广东地图示例", width=1200, height=600) map.add( "", attr, value, maptype="广东", is_map_symbol_show=False, is_visualmap=True, visual_text_color="#000", ) map.render() content = get_default_rendering_file_content() echarts_position = content.find("exports.echarts") guangdong_position = content.find(json.dumps("广东")) assert echarts_position < guangdong_position assert '"showLegendSymbol": false' in content
def test_echarts_position_in_render_html(): value = [20, 190, 253, 77, 65] attr = ["汕头市", "汕尾市", "揭阳市", "阳江市", "肇庆市"] map = Map("广东地图示例", width=1200, height=600) map.add( "", attr, value, maptype="广东", is_map_symbol_show=False, is_visualmap=True, visual_text_color="#000", ) map.render() content = get_default_rendering_file_content() echarts_position = content.find("exports.echarts") guangdong_position = content.find(json.dumps("广东")) assert echarts_position < guangdong_position assert '"showLegendSymbol": false' in content