Example #1
0
def test_scatter_extra_name():
    def custom_formatter(params):
        return params.value[3]

    data = [[28604, 77, 17096], [31163, 77.4, 27662], [1516, 68, 11546]]
    x_lst = [v[0] for v in data]
    y_lst = [v[1] for v in data]
    extra_data = [v[2] for v in data]
    extra_name = ["point A", "point B", "point C"]
    sc = Scatter()
    sc.add(
        "scatter",
        x_lst,
        y_lst,
        extra_data=extra_data,
        extra_name=extra_name,
        is_visualmap=True,
        visual_dimension=2,
        visual_orient="horizontal",
        visual_type="size",
        visual_range=[17000, 28000],
        visual_text_color="#000",
        tooltip_formatter=custom_formatter,
    )
    assert "point A" in sc._repr_html_()
    assert "point B" in sc._repr_html_()
    assert "point C" in sc._repr_html_()
Example #2
0
def test_scatter_xaxis_type_category():
    scatter = Scatter("散点图示例")
    scatter.add("A", ["a", "b", "c", "d", "e", "f"], v2)
    scatter.add("B", ["a", "b", "c", "d", "e", "f"],
                v1[::-1],
                xaxis_type="category")
    assert '"type": "category"' in scatter._repr_html_()
Example #3
0
def test_scatter_default():
    scatter = Scatter("散点图示例")
    scatter.add("A", v1, v2)
    scatter.add("B", v1[::-1], v2)
    html_content = scatter._repr_html_()
    assert '"type": "value"' in html_content
    assert '"type": "category"' not in html_content
Example #4
0
def test_scatter_xaxis_type_category():
    scatter = Scatter("散点图示例")
    scatter.add("A", ["a", "b", "c", "d", "e", "f"], v2)
    scatter.add(
        "B", ["a", "b", "c", "d", "e", "f"], v1[::-1], xaxis_type="category"
    )
    assert '"type": "category"' in scatter._repr_html_()
Example #5
0
def test_scatter_default():
    scatter = Scatter("散点图示例")
    scatter.add("A", v1, v2)
    scatter.add("B", v1[::-1], v2)
    html_content = scatter._repr_html_()
    assert '"type": "value"' in html_content
    assert '"type": "category"' not in html_content
Example #6
0
def test_scatter_xaxis_type():
    # xAxis type 'value'
    v1 = [10, 20, 30, 40, 50, 60]
    v2 = [10, 20, 30, 40, 50, 60]
    scatter = Scatter("散点图示例")
    scatter.add("A", v1, v2)
    scatter.add("B", v1[::-1], v2)
    html_content = scatter._repr_html_()
    assert '"type": "value"' in html_content
    assert '"type": "category"' not in html_content

    # xAxis type 'category'
    scatter = Scatter("散点图示例")
    scatter.add("A", ["a", "b", "c", "d", "e", "f"], v2)
    scatter.add("B", ["a", "b", "c", "d", "e", "f"],
                v1[::-1],
                xaxis_type="category")
    assert '"type": "category"' in scatter._repr_html_()
Example #7
0
def test_scatter_markline_coords():
    scatter = Scatter("散点图示例")
    scatter.add("A", v1, v2, mark_line_coords=[[10, 10], [30, 30]])
    assert '"coord": [' in scatter._repr_html_()
Example #8
0
def test_scatter_markline_coords():
    scatter = Scatter("散点图示例")
    scatter.add("A", v1, v2, mark_line_coords=[[10, 10], [30, 30]])
    assert '"coord": [' in scatter._repr_html_()