Exemple #1
0
def test_polar_type_scatter_more():
    data_1 = [(10, random.randint(1, 100)) for i in range(300)]
    data_2 = [(11, random.randint(1, 100)) for i in range(300)]
    polar = Polar("极坐标系-散点图示例", width=1200, height=600)
    polar.add("", data_1, type='scatter')
    polar.add("", data_2, type='scatter')
    polar.render()
Exemple #2
0
def test_polor_custom_type():
    def render_item(params, api):
        values = [api.value(0), api.value(1)]
        coord = api.coord(values)
        size = api.size([1, 1], values)
        return {
            "type": "sector",
            "shape": {
                "cx": params.coordSys.cx,
                "cy": params.coordSys.cy,
                "r0": coord[2] - size[0] / 2,
                "r": coord[2] + size[0] / 2,
                "startAngle": coord[3] - size[1] / 2,
                "endAngle": coord[3] + size[1] / 2,
            },
            "style": api.style({"fill": api.visual("color")}),
        }

    polar = Polar("自定义渲染逻辑示例", width=1200, height=600)
    polar.add("", [[
        random.randint(0, 6),
        random.randint(1, 24),
        random.randint(1, 24),
    ] for _ in range(100)],
              render_item=render_item,
              type="custom",
              angle_data=X_TIME,
              radius_data=WEEK,
              is_visualmap=True,
              visual_range=[0, 30])
    html_content = polar._repr_html_()
    assert "function render_item(params, api) {" in html_content
    assert '"type": "custom"' in html_content
Exemple #3
0
def hot_dog_polar_lzx():
    polar_lzx = Polar('各年度热狗大胃王比赛前三名成绩-李兆旭', height=600)
    with open('../data/hot-dog-places.csv') as f:
        data_lzx = list(csv.reader(f))
    style_lzx = dict(type='barAngle', legend_orient='vertical', legend_pos='right')
    polar_lzx.add("First", angle_data=data_lzx[0], data=data_lzx[1], is_stack=True, **style_lzx)
    polar_lzx.add("Second", angle_data=data_lzx[0], data=data_lzx[2], is_stack=True, **style_lzx)
    polar_lzx.add("Third", angle_data=data_lzx[0], data=data_lzx[3], is_stack=True, **style_lzx)
    polar_lzx.render('hot-dog-polar.html')
Exemple #4
0
def test_polar_draw_flower():
    data = []
    for i in range(361):
        t = i / 180 * math.pi
        r = math.sin(2 * t) * math.cos(2 * t)
        data.append([r, i])
    polar = Polar("极坐标系示例", width=1200, height=600)
    polar.add("Flower", data, start_angle=0, symbol=None, axis_range=[0, None])
    polar.render()
Exemple #5
0
def test_polar_draw_love():
    data = []
    for i in range(101):
        theta = i / 100 * 360
        r = 5 * (1 + math.sin(theta / 180 * math.pi))
        data.append([r, theta])
    hour = [i for i in range(1, 25)]
    polar = Polar("极坐标系示例", width=1200, height=600)
    polar.add("Love", data, angle_data=hour, boundary_gap=False, start_angle=0)
    polar.render()
Exemple #6
0
def test_polar_draw_color_flower():
    data = []
    for i in range(361):
        t = i / 180 * math.pi
        r = math.sin(2 * t) * math.cos(2 * t)
        data.append([r, i])
    polar = Polar("极坐标系示例", width=1200, height=600)
    polar.add("Color-Flower", data, start_angle=0, symbol=None,
              axis_range=[0, None], area_color="#f71f24", area_opacity=0.6)
    polar.render()
Exemple #7
0
def test_polar_type_scatter_one():
    data = [(i, random.randint(1, 100)) for i in range(101)]
    polar = Polar("极坐标系-散点图示例")
    polar.add("",
              data,
              boundary_gap=False,
              type='scatter',
              is_splitline_show=False,
              is_axisline_show=True)
    assert '"type": "scatter"' in polar._repr_html_()
Exemple #8
0
def test_polar_type_scatter_one():
    data = [(i, random.randint(1, 100)) for i in range(101)]
    polar = Polar("极坐标系-散点图示例")
    polar.add(
        "",
        data,
        boundary_gap=False,
        type="scatter",
        is_splitline_show=False,
        is_axisline_show=True,
    )
    assert '"type": "scatter"' in polar._repr_html_()
Exemple #9
0
def test_polar_type_barangle():
    polar = Polar("极坐标系-堆叠柱状图示例", width=1200, height=600)
    polar.add("", [1, 2, 3, 4, 3, 5, 1], radius_data=WEEK,
              type='barAngle', is_stack=True)
    polar.add("", [2, 4, 6, 1, 2, 3, 1], radius_data=WEEK,
              type='barAngle', is_stack=True)
    polar.add("", [1, 2, 3, 4, 1, 2, 5], radius_data=WEEK,
              type='barAngle', is_stack=True)
    polar.render()
Exemple #10
0
def test_polar_draw_snail():
    data = []
    for i in range(5):
        for j in range(101):
            theta = j / 100 * 360
            alpha = i * 360 + theta
            r = math.pow(math.e, 0.003 * alpha)
            data.append([r, theta])
    polar = Polar("极坐标系示例")
    polar.add("", data, symbol_size=0, symbol='circle', start_angle=-25,
              is_radiusaxis_show=False, area_color="#f3c5b3",
              area_opacity=0.5, is_angleaxis_show=False)
    polar.render()
Exemple #11
0
def test_polar_type_barangle():
    polar = Polar("极坐标系-堆叠柱状图示例", width=1200, height=600)
    polar.add("", [1, 2, 3, 4, 3, 5, 1],
              radius_data=WEEK,
              type='barAngle',
              is_stack=True)
    polar.add("", [2, 4, 6, 1, 2, 3, 1],
              radius_data=WEEK,
              type='barAngle',
              is_stack=True)
    polar.add("", [1, 2, 3, 4, 1, 2, 5],
              radius_data=WEEK,
              type='barAngle',
              is_stack=True)
    polar.render()
Exemple #12
0
def jizuobiao_duidiezhuzhuang():
    '''极坐标-堆叠柱状图'''

    radius = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    polar = Polar("极坐标系-堆叠柱状图示例", width=1200, height=600)
    polar.add("", [1, 2, 3, 4, 3, 5, 1], radius_data=radius, type='barAngle', is_stack=True)
    polar.add("", [2, 4, 6, 1, 2, 3, 1], radius_data=radius, type='barAngle', is_stack=True)
    polar.add("", [1, 2, 3, 4, 1, 2, 5], radius_data=radius, type='barAngle', is_stack=True)
    polar.render('./info/极坐标-堆叠柱状图.html')
Exemple #13
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())
def draw_polar_flower():
    data = []
    for i in range(361):
        t = i / 180 * math.pi
        r = math.sin(2 * t)  #* math.cos(2 * t)
        data.append([r, i])
    polar = Polar("极坐标系示例", width=1200, height=600)
    polar.add("Flower", data, start_angle=0, symbol=None, axis_range=[0, None])
    polar.show_config()
    polar.render()
Exemple #15
0
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())
def draw_polar_love():
    data = []
    for i in range(101):
        theta = i / 100 * 360
        r = 5 * (1 + math.sin(theta / 180 * math.pi))
        data.append([r, theta])
    hour = [i for i in range(1, 25)]
    polar = Polar("极坐标系示例", width=1200, height=600)
    polar.add("Love", data, angle_data=hour, boundary_gap=False, start_angle=0)
    polar.show_config()
    polar.render()
Exemple #17
0
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())
Exemple #18
0
def test_polar_type_scatter_more():
    data_1 = [(10, random.randint(1, 100)) for i in range(300)]
    data_2 = [(11, random.randint(1, 100)) for i in range(300)]
    polar = Polar("极坐标系-散点图示例", width=1200, height=600)
    polar.add("", data_1, type="scatter")
    polar.add("", data_2, type="scatter")
    polar.render()
Exemple #19
0
def test_polar_type_barradius():
    polar = Polar("极坐标系-堆叠柱状图示例", width=1200, height=600)
    polar.add(
        "A",
        [1, 2, 3, 4, 3, 5, 1],
        radius_data=WEEK,
        type="barRadius",
        is_stack=True,
    )
    polar.add(
        "B",
        [2, 4, 6, 1, 2, 3, 1],
        radius_data=WEEK,
        type="barRadius",
        is_stack=True,
    )
    polar.add(
        "C",
        [1, 2, 3, 4, 1, 2, 5],
        radius_data=WEEK,
        type="barRadius",
        is_stack=True,
    )
    polar.render()
Exemple #20
0
def jizuobiao_huitu():
    '''极坐标-绘制花朵'''
    data = []
    for i in range(361):
        t = i / 180 * math.pi
        r = math.sin(2 * t) * math.cos(2 * t)
        data.append([r, i])
    polar = Polar("极坐标系示例", width=1200, height=600)
    polar.add("Flower", data, start_angle=0, symbol=None, axis_range=[0, None], area_color="#f71f24", area_opacity=0.6)
    polar.render('./info/极坐标-绘制花朵.html')
def draw_polar_snail():
    data = []
    for i in range(5):
        for j in range(101):
            theta = j / 100 * 360
            alpha = i * 360 + theta
            r = math.pow(math.e, 0.003 * alpha)
            data.append([r, theta])
    polar = Polar("极坐标系示例")
    polar.add("",
              data,
              symbol_size=0,
              symbol='circle',
              start_angle=-25,
              is_radiusaxis_show=False,
              area_color="#f3c5b3",
              area_opacity=0.5,
              is_angleaxis_show=False)
    polar.show_config()
    polar.render()
Exemple #22
0
def generate_kfc_dks_distribute_polar_bar_chart():
    # 读取数据
    data = pd.read_excel(input_file_path + '省会城市KFC_MC_德克士.xlsx', sheet_name=0)
    print(data.head())
    city = data['城市'].tolist()
    mc_num = data['麦当劳店面数量'].tolist()
    kfc_num = data['KFC店面数量'].tolist()
    dks_num = data['德克士店面数量'].tolist()
    radius = city
    # polar = Polar('省会城市快餐店数量', width=1200, height=600)
    # polar.add('', mc_num, radius_data=radius, type='barAngle', is_stack=True)
    # polar.add('', kfc_num, radius_data=radius, type='barAngle', is_stack=True)
    # polar.add('', dks_num, radius_data=radius, type='barAngle', is_stack=True)
    # polar.render(output_file_path + 'htmls/省会城市快餐店数量极坐标堆叠柱状图.html')

    polar = Polar('省会城市快餐店数量', width=1200, height=1200)
    polar.add('', mc_num, radius_data=radius, type='barRadius', is_stack=True)
    polar.add('', kfc_num, radius_data=radius, type='barRadius', is_stack=True)
    polar.add('', dks_num, radius_data=radius, type='barRadius', is_stack=True)
    polar.render(output_file_path + 'htmls/省会城市快餐店数量极坐标分类堆叠柱状图.html')
Exemple #23
0
def test_polar_type_barradius():
    polar = Polar("极坐标系-堆叠柱状图示例", width=1200, height=600)
    polar.add(
        "A",
        [1, 2, 3, 4, 3, 5, 1],
        radius_data=WEEK,
        type="barRadius",
        is_stack=True,
    )
    polar.add(
        "B",
        [2, 4, 6, 1, 2, 3, 1],
        radius_data=WEEK,
        type="barRadius",
        is_stack=True,
    )
    polar.add(
        "C",
        [1, 2, 3, 4, 1, 2, 5],
        radius_data=WEEK,
        type="barRadius",
        is_stack=True,
    )
    polar.render()
Exemple #24
0
def test_polar_draw_color_flower():
    data = []
    for i in range(361):
        t = i / 180 * math.pi
        r = math.sin(2 * t) * math.cos(2 * t)
        data.append([r, i])
    polar = Polar("极坐标系示例", width=1200, height=600)
    polar.add("Color-Flower",
              data,
              start_angle=0,
              symbol=None,
              axis_range=[0, None],
              area_color="#f71f24",
              area_opacity=0.6)
    polar.render()
Exemple #25
0
def render_polar():
    data = []
    polar = Polar("polar test")
    polar.add(
        "",
        data,
        symbol_size=0,
        symbol="circle",
        area_color="#f3c5b3",
        type="custom",
        render_item=custom_polar_render_item,
        area_opacity=0.5,
        is_angleaxis_show=False,
    )
    polar.render()
Exemple #26
0
def jizuobiao_huitu2():
    '''极坐标绘制蜗牛'''
    data = []
    for i in range(5):
        for j in range(101):
            theta = j / 100 * 360
            alpha = i * 360 + theta
            # e = 2.718281828459045
            r = math.pow(math.e, 0.003 * alpha)
            data.append([r, theta])
    polar = Polar("极坐标系示例")

    polar.add("", data, symbol_size=0, symbol='circle', start_angle=-25, is_radiusaxis_show=False, area_color="#f3c5b3",
              area_opacity=0.5, is_angleaxis_show=False)

    polar.render('./info/极坐标-蜗牛.html')
Exemple #27
0
def heatmap_polar(df, value, attr1, attr2):
    polar = Polar("自定义渲染逻辑示例", width=1200, height=600)
    polar.add(
    "",
    [
        [
            list(set(df[attr1])).index(df[attr1][i]),
            list(set(df[attr2])).index(df[attr2][i]),
            df[value][i],
        ]
        for i in range(df.shape[0])
    ],
    render_item=render_item,
    type="custom",
    angle_data=list(set(df[attr1])),
    radius_data=list(set(df[attr2])),
    is_visualmap=True,
    visual_range=[0, max(df[value])]
    )
    polar.render()
Exemple #28
0
liquid2.render(path='./data/03-02圆形水球.html')

# 菱形水球
liquid3 = Liquid("水球图示例")
liquid3.add("Liquid", [0.6, 0.5, 0.4, 0.3],
            is_liquid_animation=False,
            shape='diamond')
liquid3.show_config()
#os.mknod('./data/03-03菱形水球.html')  #这个方法只能在linux下使用
#f=open('./data/03-03菱形水球.html','w')
#f.close()
liquid3.render(path='./data/03-03菱形水球.html')

# 极坐标
radius = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
polar = Polar("极坐标系-堆叠柱状图示例", width=1200, height=600)
polar.add("A", [1, 2, 3, 4, 3, 5, 1],
          radius_data=radius,
          type='barRadius',
          is_stack=True)
polar.add("B", [2, 4, 6, 1, 2, 3, 1],
          radius_data=radius,
          type='barRadius',
          is_stack=True)
polar.add("C", [1, 2, 3, 4, 1, 2, 5],
          radius_data=radius,
          type='barRadius',
          is_stack=True)
polar.show_config()
polar.render(path='./data/03-04极坐标.html')
from pyecharts import Polar

radius = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
polar = Polar("极坐标系-堆叠柱状图示例", width=1200, height=600)
polar.add("", [1, 2, 3, 4, 3, 5, 1],
          radius_data=radius,
          type='barAngle',
          is_stack=True)
polar.add("", [2, 4, 6, 1, 2, 3, 1],
          radius_data=radius,
          type='barAngle',
          is_stack=True)
polar.add("", [1, 2, 3, 4, 1, 2, 5],
          radius_data=radius,
          type='barAngle',
          is_stack=True)
polar.show_config()
polar.render()
Exemple #30
0
def test_polar_draw():
    # draw love
    import math
    data = []
    for i in range(101):
        theta = i / 100 * 360
        r = 5 * (1 + math.sin(theta / 180 * math.pi))
        data.append([r, theta])
    hour = [i for i in range(1, 25)]
    polar = Polar("极坐标系示例", width=1200, height=600)
    polar.add("Love", data, angle_data=hour, boundary_gap=False, start_angle=0)
    polar.render()

    # draw flower
    data = []
    for i in range(361):
        t = i / 180 * math.pi
        r = math.sin(2 * t) * math.cos(2 * t)
        data.append([r, i])
    polar = Polar("极坐标系示例", width=1200, height=600)
    polar.add("Flower", data, start_angle=0, symbol=None, axis_range=[0, None])
    polar.render()

    # draw color flower
    data = []
    for i in range(361):
        t = i / 180 * math.pi
        r = math.sin(2 * t) * math.cos(2 * t)
        data.append([r, i])
    polar = Polar("极坐标系示例", width=1200, height=600)
    polar.add("Color-Flower",
              data,
              start_angle=0,
              symbol=None,
              axis_range=[0, None],
              area_color="#f71f24",
              area_opacity=0.6)
    polar.render()

    # draw snail
    data = []
    for i in range(5):
        for j in range(101):
            theta = j / 100 * 360
            alpha = i * 360 + theta
            r = math.pow(math.e, 0.003 * alpha)
            data.append([r, theta])
    polar = Polar("极坐标系示例")
    polar.add("",
              data,
              symbol_size=0,
              symbol='circle',
              start_angle=-25,
              is_radiusaxis_show=False,
              area_color="#f3c5b3",
              area_opacity=0.5,
              is_angleaxis_show=False)
    polar.render()
Exemple #31
0
def test_polar():
    # polar type 'scatter'
    import random
    data = [(i, random.randint(1, 100)) for i in range(101)]
    polar = Polar("极坐标系-散点图示例")
    polar.add("",
              data,
              boundary_gap=False,
              type='scatter',
              is_splitline_show=False,
              is_axisline_show=True)
    assert '"type": "scatter"' in polar._repr_html_()
    polar.render()

    # polar type 'scatter'
    data_1 = [(10, random.randint(1, 100)) for i in range(300)]
    data_2 = [(11, random.randint(1, 100)) for i in range(300)]
    polar = Polar("极坐标系-散点图示例", width=1200, height=600)
    polar.add("", data_1, type='scatter')
    polar.add("", data_2, type='scatter')
    polar.render()

    # polar type 'effectScatter'
    data = [(i, random.randint(1, 100)) for i in range(10)]
    polar = Polar("极坐标系-动态散点图示例", width=1200, height=600)
    polar.add("", data, type='effectScatter', effect_scale=10, effect_period=5)
    assert '"type": "effectScatter"' in polar._repr_html_()
    polar.render()

    # polar type 'barRadius'
    radius = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    polar = Polar("极坐标系-堆叠柱状图示例", width=1200, height=600)
    polar.add("A", [1, 2, 3, 4, 3, 5, 1],
              radius_data=radius,
              type='barRadius',
              is_stack=True)
    polar.add("B", [2, 4, 6, 1, 2, 3, 1],
              radius_data=radius,
              type='barRadius',
              is_stack=True)
    polar.add("C", [1, 2, 3, 4, 1, 2, 5],
              radius_data=radius,
              type='barRadius',
              is_stack=True)
    polar.render()

    # polar type 'barAngle'
    radius = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    polar = Polar("极坐标系-堆叠柱状图示例", width=1200, height=600)
    polar.add("", [1, 2, 3, 4, 3, 5, 1],
              radius_data=radius,
              type='barAngle',
              is_stack=True)
    polar.add("", [2, 4, 6, 1, 2, 3, 1],
              radius_data=radius,
              type='barAngle',
              is_stack=True)
    polar.add("", [1, 2, 3, 4, 1, 2, 5],
              radius_data=radius,
              type='barAngle',
              is_stack=True)
    polar.render()
Exemple #32
0
from pyecharts import Polar
import random
data_1 = [(10, random.randint(1, 100)) for i in range(300)]
data_2 = [(11, random.randint(1, 100)) for i in range(300)]
polar = Polar("极坐标系-散点图示例", width=1200, height=600)
polar.add("", data_1, type='scatter')
polar.add("", data_2, type='scatter')
polar.render()
Exemple #33
0
from pyecharts import Polar
import random
'''
极坐标 示例
'''

polar = Polar("极坐标系-散点图示例")
# data = [(i,random.randint(1,100)) for i in range(101)]
# polar.add("",data,boundary_gap=False,type='scatter',is_angleaxis_show=True,
#           area_color="#f23",is_splitline_show=False)
radius = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
polar.add("A", [1, 2, 3, 4, 3, 5, 1],
          radius_data=radius,
          type='barRadius',
          is_stack=True)
polar.add("B", [2, 4, 6, 1, 2, 3, 1],
          radius_data=radius,
          type="barRadius",
          is_stack=True)
polar.add("C", [1, 2, 3, 4, 1, 2, 5],
          radius_data=radius,
          type="barRadius",
          is_stack=True)

polar.render(path="Polar2.html")
Exemple #34
0
def test_polar():

    # polar_0
    import random
    data = [(i, random.randint(1, 100)) for i in range(101)]
    polar = Polar("极坐标系-散点图示例")
    polar.add("", data, boundary_gap=False, type='scatter', is_splitline_show=False, is_axisline_show=True)
    polar.show_config()
    polar.render()

    # polar_1
    data_1 = [(10, random.randint(1, 100)) for i in range(300)]
    data_2 = [(11, random.randint(1, 100)) for i in range(300)]
    polar = Polar("极坐标系-散点图示例", width=1200, height=600)
    polar.add("", data_1, type='scatter')
    polar.add("", data_2, type='scatter')
    polar.show_config()
    polar.render()

    # porlar_2
    data = [(i, random.randint(1, 100)) for i in range(10)]
    polar = Polar("极坐标系-动态散点图示例", width=1200, height=600)
    polar.add("", data, type='effectScatter', effect_scale=10, effect_period=5)
    polar.show_config()
    polar.render()

    # polar_3
    radius = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    polar = Polar("极坐标系-堆叠柱状图示例", width=1200, height=600)
    polar.add("A", [1, 2, 3, 4, 3, 5, 1], radius_data=radius, type='barRadius', is_stack=True)
    polar.add("B", [2, 4, 6, 1, 2, 3, 1], radius_data=radius, type='barRadius', is_stack=True)
    polar.add("C", [1, 2, 3, 4, 1, 2, 5], radius_data=radius, type='barRadius', is_stack=True)
    polar.show_config()
    polar.render()

    # polar_4
    radius = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    polar = Polar("极坐标系-堆叠柱状图示例", width=1200, height=600)
    polar.add("", [1, 2, 3, 4, 3, 5, 1], radius_data=radius, type='barAngle', is_stack=True)
    polar.add("", [2, 4, 6, 1, 2, 3, 1], radius_data=radius, type='barAngle', is_stack=True)
    polar.add("", [1, 2, 3, 4, 1, 2, 5], radius_data=radius, type='barAngle', is_stack=True)
    polar.show_config()
    polar.render()

    # polar_5
    import math
    data = []
    for i in range(101):
        theta = i / 100 * 360
        r = 5 * (1 + math.sin(theta / 180 * math.pi))
        data.append([r, theta])
    hour = [i for i in range(1, 25)]
    polar = Polar("极坐标系示例", width=1200, height=600)
    polar.add("Love", data, angle_data=hour, boundary_gap=False, start_angle=0)
    polar.show_config()
    polar.render()

    # polar_6
    data = []
    for i in range(361):
        t = i / 180 * math.pi
        r = math.sin(2 * t) * math.cos(2 * t)
        data.append([r, i])
    polar = Polar("极坐标系示例", width=1200, height=600)
    polar.add("Flower", data, start_angle=0, symbol=None, axis_range=[0, None])
    polar.show_config()
    polar.render()

    # polar_7
    data = []
    for i in range(361):
        t = i / 180 * math.pi
        r = math.sin(2 * t) * math.cos(2 * t)
        data.append([r, i])
    polar = Polar("极坐标系示例", width=1200, height=600)
    polar.add("Color-Flower", data, start_angle=0, symbol=None, axis_range=[0, None],
              area_color="#f71f24", area_opacity=0.6)
    polar.show_config()
    polar.render()

    # polar_8
    data = []
    for i in range(5):
        for j in range(101):
            theta = j / 100 * 360
            alpha = i * 360 + theta
            r = math.pow(math.e, 0.003 * alpha)
            data.append([r, theta])
    polar = Polar("极坐标系示例")
    polar.add("", data, symbol_size=0, symbol='circle', start_angle=-25, is_radiusaxis_show=False,
              area_color="#f3c5b3", area_opacity=0.5, is_angleaxis_show=False)
    polar.show_config()
    polar.render()
Exemple #35
0
def test_polar_type_effectscatter():
    data = [(i, random.randint(1, 100)) for i in range(10)]
    polar = Polar("极坐标系-动态散点图示例", width=1200, height=600)
    polar.add("", data, type="effectScatter", effect_scale=10, effect_period=5)
    assert '"type": "effectScatter"' in polar._repr_html_()
Exemple #36
0
def test_polar_type_effectscatter():
    data = [(i, random.randint(1, 100)) for i in range(10)]
    polar = Polar("极坐标系-动态散点图示例", width=1200, height=600)
    polar.add("", data, type='effectScatter', effect_scale=10,
              effect_period=5)
    assert '"type": "effectScatter"' in polar._repr_html_()
Exemple #37
0
Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> # Part 7 Create Polar Coordinates with Pyecharts
>>> from pyecharts import Polar
>>> radius=['Mon','Tus','Wen','Thu','Fri','Sat','Sun']
>>> polar=Polar("Polar Coordinate",width=1200,height=600)
>>> polar.add("XC90",[100,200,300,200,400,500],radius_data=radius,type="barRadius",is_stack=True)
<pyecharts.charts.polar.Polar object at 0x0366D5B0>
>>> polar.add("XC60",[200,100,400,150,300,600],radius_data=radius,type="barRadius",is_stack=True)
<pyecharts.charts.polar.Polar object at 0x0366D5B0>
>>> polar.add("S60",[150,50,300,250,200,500],radius_data=radius,type="barRadius",is_stack=True)
<pyecharts.charts.polar.Polar object at 0x0366D5B0>
>>> polar.add("S90",[120,180,200,350,400,1000],radius_data=radius,type="barRadius",is_stack=True)
<pyecharts.charts.polar.Polar object at 0x0366D5B0>
>>> polar.add("xc40",[250,280,100,150,600,1200],radius_data=radius,type="barRadius",is_stack=True)
<pyecharts.charts.polar.Polar object at 0x0366D5B0>
>>> polar.add("V40",[50,80,200,150,60,120],radius_data=radius,type="barRadius",is_stack=True)
<pyecharts.charts.polar.Polar object at 0x0366D5B0>
>>> polar.add("V60",[130,180,260,150,360,700],radius_data=radius,type="barRadius",is_stack=True)
<pyecharts.charts.polar.Polar object at 0x0366D5B0>
>>> polar.add("PoleStar1",[50,80,20,150,160,220],radius_data=radius,type="barRadius",is_stack=True)
<pyecharts.charts.polar.Polar object at 0x0366D5B0>
>>> polar.render()
>>> 
Exemple #38
0
def create_charts():
    page = Page()

    chart_init = {
        "width": WIDTH,
        "height": HEIGHT,
    }

    data = [(i, random.randint(1, 100)) for i in range(101)]
    chart = Polar("极坐标系-散点图", **chart_init)
    chart.add("",
              data,
              boundary_gap=False,
              type='scatter',
              is_splitline_show=False,
              is_axisline_show=True)
    page.add(chart)

    data_1 = [(10, random.randint(1, 100)) for _ in range(300)]
    data_2 = [(11, random.randint(1, 100)) for _ in range(300)]
    chart = Polar("极坐标系-散点图", **chart_init)
    chart.add("", data_1, type='scatter')
    chart.add("", data_2, type='scatter')
    page.add(chart)

    data = [(i, random.randint(1, 100)) for i in range(10)]
    chart = Polar("极坐标系-动态散点图", **chart_init)
    chart.add("", data, type='effectScatter', effect_scale=10, effect_period=5)
    page.add(chart)

    radius = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    chart = Polar("极坐标系-堆叠柱状图", **chart_init)
    style = {
        "type": 'barRadius',
        "is_stack": True,
    }
    chart.add("A", [1, 2, 3, 4, 3, 5, 1], radius_data=radius, **style)
    chart.add("B", [2, 4, 6, 1, 2, 3, 1], radius_data=radius, **style)
    chart.add("C", [1, 2, 3, 4, 1, 2, 5], radius_data=radius, **style)
    page.add(chart)

    radius = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    chart = Polar("极坐标系-堆叠柱状图", **chart_init)
    style = {
        "type": 'barAngle',
        "is_stack": True,
    }
    chart.add("", [1, 2, 3, 4, 3, 5, 1], radius_data=radius, **style)
    chart.add("", [2, 4, 6, 1, 2, 3, 1], radius_data=radius, **style)
    chart.add("", [1, 2, 3, 4, 1, 2, 5], radius_data=radius, **style)
    page.add(chart)

    data = []
    for i in range(101):
        theta = i / 100 * 360
        r = 5 * (1 + math.sin(theta / 180 * math.pi))
        data.append([r, theta])
    hour = [i for i in range(1, 25)]
    chart = Polar("极坐标系-画爱心", **chart_init)
    chart.add("Love", data, angle_data=hour, boundary_gap=False, start_angle=0)
    page.add(chart)

    data = []
    for i in range(361):
        t = i / 180 * math.pi
        r = math.sin(2 * t) * math.cos(2 * t)
        data.append([r, i])
    chart = Polar("极坐标系-画小花", **chart_init)
    chart.add("Flower", data, start_angle=0, symbol=None, axis_range=[0, None])
    page.add(chart)

    data = []
    for i in range(361):
        t = i / 180 * math.pi
        r = math.sin(2 * t) * math.cos(2 * t)
        data.append([r, i])
    chart = Polar("极坐标系-画红色小花", **chart_init)
    chart.add("Color-Flower",
              data,
              start_angle=0,
              symbol=None,
              axis_range=[0, None],
              area_color="#f71f24",
              area_opacity=0.6)
    page.add(chart)

    data = []
    for i in range(5):
        for j in range(101):
            theta = j / 100 * 360
            alpha = i * 360 + theta
            r = math.pow(math.e, 0.003 * alpha)
            data.append([r, theta])
    chart = Polar("极坐标系-画蜗牛", **chart_init)
    chart.add("",
              data,
              symbol_size=0,
              symbol='circle',
              start_angle=-25,
              is_radiusaxis_show=False,
              area_color="#f3c5b3",
              area_opacity=0.5,
              is_angleaxis_show=False)
    page.add(chart)

    return page
Exemple #39
0
    [14, 116, 87, 131, 1.47, 84, 40, "轻度污染"]
]
parallel = Parallel("平行坐标系-用户自定义指示器")
parallel.config(c_schema=c_schema)
parallel.add("parallel", data, is_random=False)
parallel.render()

# -----------------------------------------------------------------------------
# polar
from pyecharts import Polar
from pyecharts import Page
page = Page()

import random
data = [(i, random.randint(1, 100)) for i in range(101)]  #[(radius, angle)]
polar = Polar("极坐标系")
polar.add("", data, is_random=False)
page.add(polar)

# error
polar2 = Polar("极坐标系-散点图示例")
polar2.add("", data, type='scatter',
          is_splitline_show=False, is_radiusaxis_show=False)
page.add(polar2) 


page.render()


page = Page()
radius = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
Exemple #40
0
def test_polar():

    # polar_0
    import random
    data = [(i, random.randint(1, 100)) for i in range(101)]
    polar = Polar("极坐标系-散点图示例")
    polar.add("", data, boundary_gap=False, type='scatter', is_splitline_show=False,
              is_axisline_show=True)
    polar.render()

    # polar_1
    data_1 = [(10, random.randint(1, 100)) for i in range(300)]
    data_2 = [(11, random.randint(1, 100)) for i in range(300)]
    polar = Polar("极坐标系-散点图示例", width=1200, height=600)
    polar.add("", data_1, type='scatter')
    polar.add("", data_2, type='scatter')
    polar.render()

    # porlar_2
    data = [(i, random.randint(1, 100)) for i in range(10)]
    polar = Polar("极坐标系-动态散点图示例", width=1200, height=600)
    polar.add("", data, type='effectScatter', effect_scale=10, effect_period=5)
    polar.render()

    # polar_3
    radius = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    polar = Polar("极坐标系-堆叠柱状图示例", width=1200, height=600)
    polar.add("A", [1, 2, 3, 4, 3, 5, 1], radius_data=radius, type='barRadius', is_stack=True)
    polar.add("B", [2, 4, 6, 1, 2, 3, 1], radius_data=radius, type='barRadius', is_stack=True)
    polar.add("C", [1, 2, 3, 4, 1, 2, 5], radius_data=radius, type='barRadius', is_stack=True)
    polar.render()

    # polar_4
    radius = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    polar = Polar("极坐标系-堆叠柱状图示例", width=1200, height=600)
    polar.add("", [1, 2, 3, 4, 3, 5, 1], radius_data=radius, type='barAngle', is_stack=True)
    polar.add("", [2, 4, 6, 1, 2, 3, 1], radius_data=radius, type='barAngle', is_stack=True)
    polar.add("", [1, 2, 3, 4, 1, 2, 5], radius_data=radius, type='barAngle', is_stack=True)
    polar.render()

    # polar_5
    import math
    data = []
    for i in range(101):
        theta = i / 100 * 360
        r = 5 * (1 + math.sin(theta / 180 * math.pi))
        data.append([r, theta])
    hour = [i for i in range(1, 25)]
    polar = Polar("极坐标系示例", width=1200, height=600)
    polar.add("Love", data, angle_data=hour, boundary_gap=False, start_angle=0)
    polar.render()

    # polar_6
    data = []
    for i in range(361):
        t = i / 180 * math.pi
        r = math.sin(2 * t) * math.cos(2 * t)
        data.append([r, i])
    polar = Polar("极坐标系示例", width=1200, height=600)
    polar.add("Flower", data, start_angle=0, symbol=None, axis_range=[0, None])
    polar.render()

    # polar_7
    data = []
    for i in range(361):
        t = i / 180 * math.pi
        r = math.sin(2 * t) * math.cos(2 * t)
        data.append([r, i])
    polar = Polar("极坐标系示例", width=1200, height=600)
    polar.add("Color-Flower", data, start_angle=0, symbol=None, axis_range=[0, None],
              area_color="#f71f24", area_opacity=0.6)
    polar.render()

    # polar_8
    data = []
    for i in range(5):
        for j in range(101):
            theta = j / 100 * 360
            alpha = i * 360 + theta
            r = math.pow(math.e, 0.003 * alpha)
            data.append([r, theta])
    polar = Polar("极坐标系示例")
    polar.add("", data, symbol_size=0, symbol='circle', start_angle=-25, is_radiusaxis_show=False,
              area_color="#f3c5b3", area_opacity=0.5, is_angleaxis_show=False)
    polar.render()
Exemple #41
0
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 11 10:07:15 2017

@author: 17549
"""

from pyecharts import Polar
radius=['周一','周二','周三','周四','周五','周六','周日']
polar=Polar("极坐标-堆叠柱状图",width=1200,height=600)
polar.add("A",[1,2,3,4,3,5,1],radius_data=radius,type='barAngle',is_stack=True)
polar.add("B",[2,4,6,1,2,3,1],radius_data=radius,type='barAngle',is_stack=True)
polar.add("C",[1,2,3,4,1,2,5],radius_data=radius,type='barAngle',is_stack=True)
polar.show_config()
polar.render(r"E:\16_极坐标-堆叠柱状图.html")