Exemple #1
0
def aboutMe(request):
    gauge = pyecharts.Gauge('', background_color='#f5f5f5')
    gauge.add('title',
              'Percent',
              80.66,
              scale_range=[0, 100],
              is_more_utils=True)
    gauge.show_config()
    result = gauge.render_embed()
    data = [("海门", 9), ("鄂尔多斯", 10), ("招远", 12), ("舟山", 18), ("齐齐哈尔", 10),
            ("盐城", 15)]
    geo = pyecharts.Geo("全国主要城市空气质量",
                        "data from pm2.5",
                        title_color="#000",
                        title_pos="center",
                        background_color='#f5f5f5')
    attr, value = geo.cast(data)
    geo.add("",
            attr,
            value,
            type="effectScatter",
            is_random=True,
            effect_scale=5,
            is_more_utils=True)
    geo.show_config()
    result1 = geo.render_embed()
    attr = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
    v1 = [20, 33, 133, 124, 24, 313]
    v2 = [2.6, 12, 31, 241, 324, 134]
    bar = pyecharts.Bar('Bar Sample', background_color='#f5f5f5')
    bar.add("A", attr, v1, mark_line=["average"], mark_point=["min", "max"])
    bar.add("B",
            attr,
            v2,
            mark_line=["average"],
            mark_point=["min", "max"],
            is_more_utils=True)
    bar_result = bar.render_embed()
    pie = pyecharts.Pie('', background_color="#f5f5f5")
    pie.add("",
            attr,
            v1,
            is_lable_show=True,
            lable_text_color="#156ACF",
            is_more_utils=True)
    pie.show_config()
    pie_result = pie.render_embed()
    liquid = pyecharts.Liquid('', background_color="#000")
    liquid.add("", [0.66, 0.5], ['diamond'], ['#294D99', '#156ACF'],
               is_more_utils=True)
    liquid.show_config()
    liquid_result = liquid.render_embed()
    return render_to_response(
        'AboutMe.html', {
            'result': result,
            'result1': result1,
            'bar_result': bar_result,
            'pie_result': pie_result,
            'liquid_result': liquid_result
        })
Exemple #2
0
def create_Liquid():
    lq = pyecharts.Liquid("水滴球")
    lq.add("Liquid", [0.8, 0.5, 0.2],
           is_liquid_outline_show=False,
           is_liquid_animation=True)
    # lq.render("LiQuid.html")
    page.add(lq)
def t18(pa):
    shape = ("path://M367.855,428.202c-3.674-1.385-7.452-1.966-11.146-1"
             ".794c0.659-2.922,0.844-5.85,0.58-8.719 c-0.937-10.407-7."
             "663-19.864-18.063-23.834c-10.697-4.043-22.298-1.168-29.9"
             "02,6.403c3.015,0.026,6.074,0.594,9.035,1.728 c13.626,5."
             "151,20.465,20.379,15.32,34.004c-1.905,5.02-5.177,9.115-9"
             ".22,12.05c-6.951,4.992-16.19,6.536-24.777,3.271 c-13.625"
             "-5.137-20.471-20.371-15.32-34.004c0.673-1.768,1.523-3.423"
             ",2.526-4.992h-0.014c0,0,0,0,0,0.014 c4.386-6.853,8.145-14"
             ".279,11.146-22.187c23.294-61.505-7.689-130.278-69.215-153"
             ".579c-61.532-23.293-130.279,7.69-153.579,69.202 c-6.371,"
             "16.785-8.679,34.097-7.426,50.901c0.026,0.554,0.079,1.121,"
             "0.132,1.688c4.973,57.107,41.767,109.148,98.945,130.793 c58."
             "162,22.008,121.303,6.529,162.839-34.465c7.103-6.893,17.826"
             "-9.444,27.679-5.719c11.858,4.491,18.565,16.6,16.719,28.643 "
             "c4.438-3.126,8.033-7.564,10.117-13.045C389.751,449.992,"
             "382.411,433.709,367.855,428.202z")
    liquid = p.Liquid("各新兴职业所占比例")
    liquid.add(next(pa),
               next(pa),
               is_liquid_outline_show=False,
               shape=shape,
               is_toolbox_show=False)
    return liquid
Exemple #4
0
def find(name):
    user = "******"
    password = "******"
    db = pymysql.connect(host="localhost",
                         user=user,
                         password=password,
                         charset="utf8")
    cursor = db.cursor()
    cursor.execute('USE `ujn_a`;')
    names = name + 's'

    cursor.execute('DROP VIEW IF EXISTS {};'.format(names))
    sql_1 = 'CREATE VIEW {} AS SELECT qcwy.xexperience,qcwy.education FROM qcwy WHERE title like "%{}%" '.format(
        names, name)
    cursor.execute(sql_1)

    cursor.execute("select count(*) from " + names)
    alls = cursor.fetchone()[0]

    list1 = ['本科', '硕士', '博士']
    list_edu = []
    list_edu_sql = [
        "select count(*) from {} where education = '{}';".format(names, i)
        for i in list1
    ]
    for i in list_edu_sql:
        cursor.execute(i)
        list_edu.append(cursor.fetchone()[0])

    list2 = ['无工作经验', '1年经验', '2年经验', '3-4年经验', '5-7年经验', '8-9年经验', '10年以上经验']
    list_exp = []
    list_exp_sql = [
        "select count(*) from {} where xexperience = '{}';".format(names, i)
        for i in list2
    ]
    for i in list_exp_sql:
        cursor.execute(i)
        list_exp.append(cursor.fetchone()[0])

    p.configure(global_theme='macarons')  # 设置主题

    bing = p.Pie()
    attr = list2
    v1 = list_exp
    bing.add("",
             attr,
             v1,
             is_label_show=True,
             is_toolbox_show=False,
             legend_top='bottom')
    bing.render('static/html/bing.html')

    list4 = []
    for i in range(3):
        qiu = p.Liquid(title=list1[i],
                       title_pos='center',
                       title_text_size=30,
                       title_top='80%',
                       width=600,
                       height=400)
        list3 = [round(list_edu[i] / alls, 2)]
        list4.extend(list3)
        qiu.add(list1[i],
                list3,
                is_liquid_animation=True,
                is_toolbox_show=False,
                liquid_color=['#21bbff', '#00b6ff', '#23c4ff', '#47c7ff'],
                is_liquid_outline_show=False)
        qiu.render('static/html/qiu{}.html'.format(i + 1))

    # 返回

    n = 1
    e_all = 0
    for i in list_exp[1:]:
        e_all = e_all + i / alls / 21 * n
        n = n + 1

    n = 1
    d_all = 0
    for i in list_edu[1:]:
        d_all = d_all + i / alls / 2 * n
        n = n + 1

    if e_all > d_all:
        if e_all - d_all <= 0.06:
            result = '考研和直接就业都很不错呢'
        else:
            result = '建议您毕业后直接就业哦'
    else:
        result = '建议您准备考研哦'

    if name == '学习': name = '机器学习'

    back = [name, result]
    return back

    return
Exemple #5
0
def aboutMe(request):
    gauge = pyecharts.Gauge('', background_color='#f5f5f5')
    gauge.add('title',
              'Percent',
              80.66,
              scale_range=[0, 100],
              is_more_utils=True)
    gauge.show_config()
    result = gauge.render_embed()
    data = [("宿迁", 9), ("武汉", 10), ("重庆", 12), ("哈尔滨", 18), ("乌鲁木齐", 10),
            ("北京", 15), ("南京", 13)]
    geo = pyecharts.Geo("中国各城市PM2.5含量示意图",
                        "data from pm2.5",
                        title_color="#000",
                        title_pos="center",
                        background_color='#f5f5f5')
    attr, value = geo.cast(data)
    geo.add("",
            attr,
            value,
            type="effectScatter",
            is_random=True,
            effect_scale=5,
            is_more_utils=True)
    geo.show_config()
    result1 = geo.render_embed()
    attr = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
    v1 = [20, 33, 133, 124, 24, 313]
    v2 = [2.6, 12, 31, 241, 324, 134]
    bar = pyecharts.Bar('Bar Sample', background_color='#f5f5f5')
    bar.add("A", attr, v1, mark_line=["average"], mark_point=["min", "max"])
    bar.add("B",
            attr,
            v2,
            mark_line=["average"],
            mark_point=["min", "max"],
            is_more_utils=True)
    bar_result = bar.render_embed()
    pie = pyecharts.Pie('', background_color="#f5f5f5")
    pie.add("",
            attr,
            v1,
            is_lable_show=True,
            lable_text_color="#156ACF",
            is_more_utils=True)
    pie.show_config()
    pie_result = pie.render_embed()
    liquid = pyecharts.Liquid('', background_color="#000")
    liquid.add("", [0.66, 0.5], ['diamond'], ['#294D99', '#156ACF'],
               is_more_utils=True)
    liquid.show_config()
    liquid_result = liquid.render_embed()
    l3d = line3d()
    l3d_result = l3d.render_embed()
    name = [
        'afaaf', 'Tom han', 'ajf oafoa', 'auoj aoudh', 'ad da fa',
        'auohdahb da'
    ]
    value = [
        10000,
        1132,
        414,
        1313,
        3452,
        1413,
    ]
    wordcloud = pyecharts.WordCloud(width=800,
                                    height=400,
                                    background_color="#000")
    wordcloud.add("", name, value, word_size_range=[20, 100], rotate_step=50)
    wordcloud.show_config()
    w = wordcloud.render_embed()
    REMOTE_HOST = "https://pyecharts.github.io/assets/js"
    return render_to_response(
        'AboutMe.html', {
            'result': result,
            'result1': result1,
            'bar_result': bar_result,
            'pie_result': pie_result,
            'liquid_result': liquid_result,
            'l3d_result': l3d_result,
            'host': REMOTE_HOST,
            'script_list': l3d.get_js_dependencies(),
            'w': w
        })