コード例 #1
0
def test_geo_china_scatter(patched):
    fixture = "geo_options.json"
    patched.return_value = "1"
    cities = [("鄂尔多斯", 12), ("招远", 12), ("舟山", 12), ("齐齐哈尔", 14), ("盐城", 15)]
    geo = Geo("全国主要城市空气质量", "data from pm2.5")
    attr, value = geo.cast(cities)
    geo.add(
        "",
        attr,
        value,
        visual_range=[0, 200],
        visual_text_color="#fff",
        is_legend_show=False,
        symbol_size=15,
        is_visualmap=True,
        tooltip_formatter="{b}",
        label_emphasis_textsize=15,
        label_emphasis_pos="right",
    )
    actual_options = json.dumps(geo.options,
                                sort_keys=True,
                                indent=4,
                                cls=DefaultJsonEncoder)
    expected = get_fixture_content(fixture)
    for a, b in zip(actual_options.split("\n"), expected.split("\n")):
        eq_(a.strip(), b.strip())
コード例 #2
0
ファイル: test_options.py プロジェクト: MandyCh/pyecharts
def test_geo_china_scatter(patched):
    fixture = "geo_options.json"
    patched.return_value = "1"
    cities = [("鄂尔多斯", 12), ("招远", 12), ("舟山", 12), ("齐齐哈尔", 14), ("盐城", 15)]
    geo = Geo("全国主要城市空气质量", "data from pm2.5")
    attr, value = geo.cast(cities)
    geo.add(
        "",
        attr,
        value,
        visual_range=[0, 200],
        visual_text_color="#fff",
        is_legend_show=False,
        symbol_size=15,
        is_visualmap=True,
        tooltip_formatter="{b}",
        label_emphasis_textsize=15,
        label_emphasis_pos="right",
    )
    actual_options = json.dumps(
        geo.options, sort_keys=True, indent=4, cls=DefaultJsonEncoder
    )
    expected = get_fixture_content(fixture)
    for a, b in zip(actual_options.split("\n"), expected.split("\n")):
        eq_(a.strip(), b.strip())
コード例 #3
0
def test_kline_default(patched):
    fixture = "kline_options.json"
    patched.return_value = "1"
    kline = Kline("K 线图-默认示例")
    kline.add("日K", DATE, data)
    actual_options = dumps_actual_options(kline.options)
    expected = get_fixture_content(fixture)
    for a, b in zip(actual_options.split("\n"), expected.split("\n")):
        eq_(a.strip(), b.strip())
コード例 #4
0
ファイル: test_options.py プロジェクト: Jesszen/pyecharts
def test_kline_default(patched):
    patched.return_value = "1"
    kline = Kline("K 线图-默认示例")
    kline.add("日K", DATE, data)
    actual_options = json.dumps(
        kline.options, sort_keys=True, indent=4, cls=DefaultJsonEncoder
    )
    expected = get_fixture_content("kline_options.json")
    for a, b in zip(actual_options.split("\n"), expected.split("\n")):
        eq_(a.strip(), b.strip())
コード例 #5
0
ファイル: test_options.py プロジェクト: vsmawoex/pyecharts
def test_kline_default(patched):
    patched.return_value = "1"
    kline = Kline("K 线图-默认示例")
    kline.add("日K", DATE, data)
    actual_options = json.dumps(kline.options,
                                sort_keys=True,
                                indent=4,
                                cls=DefaultJsonEncoder)
    expected = get_fixture_content("kline_options.json")
    for a, b in zip(actual_options.split("\n"), expected.split("\n")):
        eq_(a.strip(), b.strip())
コード例 #6
0
def test_scatter3d_default(patched):
    fixture = "scatter3d_options.json"
    patched.return_value = "1"

    data = [[1, 1, 1] for _ in range(3)]
    scatter3d = Scatter3D("3D 散点图示例", width=1200, height=600)
    scatter3d.add("", data, is_visualmap=True, visual_range_color=RANGE_COLOR)
    actual_options = dumps_actual_options(scatter3d.options)
    expected = get_fixture_content(fixture)
    for a, b in zip(actual_options.split("\n"), expected.split("\n")):
        eq_(a.strip(), b.strip())
コード例 #7
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())
コード例 #8
0
def test_scatter_option(patched):
    fixture = "scatter_options.json"
    patched.return_value = "1"
    v1 = [10, 20, 30, 40, 50, 60]
    v2 = [10, 20, 30, 40, 50, 60]
    scatter = Scatter("scatter test")
    scatter.add("A", v1, v2)
    scatter.add("B", v1[::-1], v2)
    actual_options = dumps_actual_options(scatter.options)
    expected = get_fixture_content(fixture)
    for a, b in zip(actual_options.split("\n"), expected.split("\n")):
        eq_(a.strip(), b.strip())
コード例 #9
0
ファイル: test_options.py プロジェクト: Jesszen/pyecharts
def test_scatter_option(patched):
    patched.return_value = "1"
    v1 = [10, 20, 30, 40, 50, 60]
    v2 = [10, 20, 30, 40, 50, 60]
    scatter = Scatter("scatter test")
    scatter.add("A", v1, v2)
    scatter.add("B", v1[::-1], v2)
    actual_options = json.dumps(
        scatter.options, sort_keys=True, indent=4, cls=DefaultJsonEncoder
    )
    expected = get_fixture_content("scatter_options.json")
    for a, b in zip(actual_options.split("\n"), expected.split("\n")):
        eq_(a.strip(), b.strip())
コード例 #10
0
ファイル: test_options.py プロジェクト: vsmawoex/pyecharts
def test_scatter_option(patched):
    patched.return_value = "1"
    v1 = [10, 20, 30, 40, 50, 60]
    v2 = [10, 20, 30, 40, 50, 60]
    scatter = Scatter("scatter test")
    scatter.add("A", v1, v2)
    scatter.add("B", v1[::-1], v2)
    actual_options = json.dumps(scatter.options,
                                sort_keys=True,
                                indent=4,
                                cls=DefaultJsonEncoder)
    expected = get_fixture_content("scatter_options.json")
    for a, b in zip(actual_options.split("\n"), expected.split("\n")):
        eq_(a.strip(), b.strip())
コード例 #11
0
def test_line3d_default(patched):
    fixture = "line3d_options.json"
    patched.return_value = "1"
    _data = list(create_line3d_data())
    line3d = Line3D("3D 折线图示例", width=1200, height=600)
    line3d.add(
        "",
        _data,
        is_visualmap=True,
        visual_range_color=RANGE_COLOR,
        visual_range=[0, 30],
        grid3d_rotate_sensitivity=5,
    )
    actual_options = dumps_actual_options(line3d.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_polar_type_scatter_one(patched):
    fixture = "polar_options.json"
    patched.return_value = "1"
    data = [i for i in range(101)]
    polar = Polar("Polar")
    polar.add(
        "",
        data,
        boundary_gap=False,
        type="scatter",
        is_splitline_show=False,
        is_axisline_show=True,
    )
    actual_options = dumps_actual_options(polar.options)
    expected = get_fixture_content(fixture)
    for a, b in zip(actual_options.split("\n"), expected.split("\n")):
        eq_(a.strip(), b.strip())
コード例 #13
0
ファイル: test_options.py プロジェクト: Jesszen/pyecharts
def test_polar_type_scatter_one(patched):
    patched.return_value = "1"
    data = [i for i in range(101)]
    polar = Polar("极坐标系-散点图示例")
    polar.add(
        "",
        data,
        boundary_gap=False,
        type="scatter",
        is_splitline_show=False,
        is_axisline_show=True,
    )
    actual_options = json.dumps(
        polar.options, sort_keys=True, indent=4, cls=DefaultJsonEncoder
    )
    expected = get_fixture_content("polar_options.json")
    for a, b in zip(actual_options.split("\n"), expected.split("\n")):
        eq_(a.strip(), b.strip())
コード例 #14
0
ファイル: test_options.py プロジェクト: Jesszen/pyecharts
def test_line3d_default(patched):
    patched.return_value = "1"
    _data = list(create_line3d_data())
    line3d = Line3D("3D 折线图示例", width=1200, height=600)
    line3d.add(
        "",
        _data,
        is_visualmap=True,
        visual_range_color=RANGE_COLOR,
        visual_range=[0, 30],
        grid3d_rotate_sensitivity=5,
    )
    actual_options = json.dumps(
        line3d.options, sort_keys=True, indent=4, cls=DefaultJsonEncoder
    )
    expected = get_fixture_content("line3d_options.json")
    for a, b in zip(actual_options.split("\n"), expected.split("\n")):
        eq_(a.strip(), b.strip())
コード例 #15
0
ファイル: test_options.py プロジェクト: vsmawoex/pyecharts
def test_polar_type_scatter_one(patched):
    patched.return_value = "1"
    data = [i for i in range(101)]
    polar = Polar("极坐标系-散点图示例")
    polar.add(
        "",
        data,
        boundary_gap=False,
        type="scatter",
        is_splitline_show=False,
        is_axisline_show=True,
    )
    actual_options = json.dumps(polar.options,
                                sort_keys=True,
                                indent=4,
                                cls=DefaultJsonEncoder)
    expected = get_fixture_content("polar_options.json")
    for a, b in zip(actual_options.split("\n"), expected.split("\n")):
        eq_(a.strip(), b.strip())
コード例 #16
0
def test_bar3d_default(patched):
    fixture = "bar3d_options.json"
    patched.return_value = "1"
    bar3d = Bar3D("3D 柱状图示例", width=1200, height=600)
    bar3d.add(
        "",
        X_TIME,
        Y_WEEK,
        [[1, 1, 1]],
        is_visualmap=True,
        visual_range=[0, 20],
        visual_range_color=RANGE_COLOR,
        grid3d_width=200,
        grid3d_depth=80,
    )
    actual_options = dumps_actual_options(bar3d.options)
    expected = get_fixture_content(fixture)

    for a, b in zip(actual_options.split("\n"), expected.split("\n")):
        eq_(a.strip(), b.strip())
コード例 #17
0
def test_bar_default(patched):
    fixture = "bar_options.json"
    patched.return_value = "1"
    attr = [
        "Jan",
        "Feb",
        "Mar",
        "Apr",
        "May",
        "Jun",
        "Jul",
        "Aug",
        "Sep",
        "Oct",
        "Nov",
        "Dec",
    ]
    v1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
    v2 = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
    bar = Bar("Bar chart", "precipitation and evaporation one year")
    bar.add(
        "precipitation",
        attr,
        v1,
        mark_line=["average"],
        mark_point=["max", "min"],
    )
    bar.add(
        "evaporation",
        attr,
        v2,
        mark_line=["average"],
        mark_point=["max", "min"],
    )
    actual_options = json.dumps(bar.options,
                                sort_keys=True,
                                indent=4,
                                cls=DefaultJsonEncoder)
    expected = get_fixture_content(fixture)
    for a, b in zip(actual_options.split("\n"), expected.split("\n")):
        eq_(a.strip(), b.strip())
コード例 #18
0
ファイル: test_options.py プロジェクト: MandyCh/pyecharts
def test_bar_default(patched):
    fixture = "bar_options.json"
    patched.return_value = "1"
    attr = [
        "Jan",
        "Feb",
        "Mar",
        "Apr",
        "May",
        "Jun",
        "Jul",
        "Aug",
        "Sep",
        "Oct",
        "Nov",
        "Dec",
    ]
    v1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
    v2 = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
    bar = Bar("Bar chart", "precipitation and evaporation one year")
    bar.add(
        "precipitation",
        attr,
        v1,
        mark_line=["average"],
        mark_point=["max", "min"],
    )
    bar.add(
        "evaporation",
        attr,
        v2,
        mark_line=["average"],
        mark_point=["max", "min"],
    )
    actual_options = json.dumps(
        bar.options, sort_keys=True, indent=4, cls=DefaultJsonEncoder
    )
    expected = get_fixture_content(fixture)
    for a, b in zip(actual_options.split("\n"), expected.split("\n")):
        eq_(a.strip(), b.strip())