コード例 #1
0
def chart(credit_list, time_list):
    bar = Line("学生成绩平均绩点折线图\n")
    bar.add("平均绩点GPA", time_list, credit_list, is_more_utils=True)
    bar.show_config()
    bar.render()
    shutil.move('/home/fty/new-system/render.html',
                '/home/fty/new-system/templates/student.html')

    file = ""
    with open('/home/fty/new-system/templates/student.html', 'r') as f:
        hello = f.read()
        file = hello
        f.close()

    head = '''
    {% extends 'base.html' %}
    {% block page_name %}你好,{{login_user}}{% endblock %}
    {% block body_part3 %}
    <a href="{{ url_for('student') }}" class="nav-link active">
    {% endblock %}
    {% block body_part1 %}
    <span class="glyphicon glyphicon-stats"></span>&ensp;你好,{{login_user}}
    {% endblock %}
    {% block body_part2 %}
    '''
    with open('/home/fty/new-system/templates/student.html', 'w') as f1:
        f1.write(head)
        f1.write(file)
        f1.write('\n')
        f1.write("{% endblock %}")
コード例 #2
0
def line_test(b, num):
    X = pd.Series(unique(b)).values
    Y = pd.Series(num.groupby(b).sum()).values
    line = Line("香飘飘2019/04到2019/05月各省区经销商分销量")
    line.add("", X, Y, mark_point=["average"])
    line.show_config()
    line.render("E:\\py_data_html\\line_test.html")
コード例 #3
0
ファイル: matplot.py プロジェクト: Cris0525/StudyNotes
def chart(lists):
    bar = Line("学生成绩平均绩点折线图")
    bar.add("平均绩点GPA", ["大一(上)", "大一(下)", "大二(上)", "大二(下)", "大三(上)", "大三(下)"],
            [lists[0], lists[1], lists[2], lists[3], lists[4], lists[5]],
            is_more_utils=True)
    bar.show_config()
    bar.render()
    shutil.move('/home/cris/new_system/render.html',
                '/home/cris/new_system/templates/student.html')

    file = ""
    with open('/home/cris/new_system/templates/student.html', 'r') as f:
        hello = f.read()
        file = hello
        f.close()

    head = '''
    {% extends 'base.html' %}
    {% block page_name %}你好,{{login_user}}{% endblock %}
    {% block body_part3 %}
    <a href="{{ url_for('student') }}" class="nav-link active">
    {% endblock %}
    {% block body_part1 %}
    <span class="glyphicon glyphicon-stats"></span>&ensp;你好,{{login_user}}
    {% endblock %}
    {% block body_part2 %}
    '''
    with open('/home/cris/new_system/templates/student.html', 'w') as f1:
        f1.write(head)
        f1.write(file)
        f1.write('\n')
        f1.write("{% endblock %}")
コード例 #4
0
def statistics_for_op_length():
    '''
    本函数用以确定下面函数中的support的值
    fc: 非流失玩家最大动作序列长度20219 最小序列长度1, 流失玩家最大序列长度7323 ,最小序列长度 1
    选取的最小支持度是16,此时剔除掉了非流失玩家用户193 流失玩家用户1497
    '''
    from pyecharts import Line
    fc_user_ops, fc_user_label, sc_user_ops, sc_user_label, tc_user_ops, tc_user_label, action_id = get_op_features_labels_from_pickle(
    )
    ops_length = [[], []]
    [
        ops_length[fc_user_label[user]].append(len(ops))
        for user, ops in fc_user_ops.items()
    ]

    user_length = [[], []]
    c = [0, 0]
    temp = [list(np.sort(ops_length[0])), list(np.sort(ops_length[1]))]
    for support in range(1, max(ops_length[1])):
        # 在1 和 max ops_length[1] 之间集中了大部分的游戏玩家
        for i in [0, 1]:
            for t in temp[i][c[i]:]:
                if t <= support:
                    c[i] += 1
            user_length[i].append(c[i])

    line = Line()
    index = [i for i in range(0, 100)]
    line.add("非流失玩家", index, user_length[0][:100])
    line.add("流失玩家", index, user_length[1][:100])
    line.show_config()
    line.render()
コード例 #5
0
ファイル: summary.py プロジェクト: icechen1219/wechat_robot
def get_line(item_name, subtitle, item_name_list, item_num_list):
    line = Line(item_name,
                subtitle,
                title_text_size=30,
                subtitle_text_size=25,
                title_pos='center')
    line.add("",
             item_name_list,
             item_num_list,
             mark_point=["max", "min"],
             mark_line=["average"],
             title_pos='center',
             xaxis_interval=0,
             xaxis_rotate=27,
             xaxis_label_textsize=20,
             yaxis_label_textsize=20,
             yaxis_name_pos='end',
             yaxis_pos="%50")
    line.show_config()

    grid = Grid(width=1300, height=800)
    grid.add(line,
             grid_top="13%",
             grid_bottom="23%",
             grid_left="15%",
             grid_right="15%")

    out_file_name = './analyse/' + item_name + '.html'
    grid.render(out_file_name)
コード例 #6
0
ファイル: matplot.py プロジェクト: Cris0525/StudyNotes
def chart(lists):
    bar = Line("学生成绩平均绩点折线图")
    bar.add(
        "平均绩点GPA", ["大一(上)", "大一(下)", "大二(上)", "大二(下)", "大三(上)", "大三(下)"],
        [lists[0], lists[1], lists[2], lists[3], lists[4], lists[5], lists[6]],
        is_more_utils=True)
    bar.show_config()
    bar.render()
    #shutil.move('/home/cris/system/flask/render.html','/home/cris/system/flask/templates/html')

    with open('/home/cris/system/flask/render.html', 'r') as f:
        hello = f.read()
        abc = hello

    with open('/home/cris/system/flask/templates/student.html', 'w') as f1:
        f1.write("{% extends 'base.html' %}")
        f1.write('\n')
        f1.write("{% block page_name %}你好,{{login_user}}{% endblock %}")
        f1.write('\n')
        f1.write("{% block body_part1 %}你好,{{login_user}}{% endblock %}")
        f1.write('\n')
        f1.write("{% block body_part2 %}")
        f1.write('\n')
        f1.write(abc)
        f1.write('\n')
        f1.write("{% endblock %}")
コード例 #7
0
ファイル: summary.py プロジェクト: icechen1219/wechat_robot
def all_in_line(item_name, subtitle, _counter1, _counter2, _counter3):
    line = Line(item_name,
                subtitle,
                title_text_size=30,
                subtitle_text_size=18,
                title_pos='center')

    item_name_list, item_num_list = counter2seven_list(_counter1)
    line.add("小群",
             item_name_list,
             item_num_list,
             mark_point=["max"],
             legend_pos='65%',
             xaxis_interval=0,
             xaxis_rotate=27,
             xaxis_label_textsize=20,
             yaxis_label_textsize=20,
             yaxis_name_pos='end',
             yaxis_pos="%50")

    item_name_list, item_num_list = counter2seven_list(_counter2)
    line.add("大群",
             item_name_list,
             item_num_list,
             mark_point=["max"],
             legend_pos='65%',
             xaxis_interval=0,
             xaxis_rotate=27,
             xaxis_label_textsize=20,
             yaxis_label_textsize=20,
             yaxis_name_pos='end',
             yaxis_pos="%50")

    item_name_list, item_num_list = counter2seven_list(_counter3)
    line.add("综合",
             item_name_list,
             item_num_list,
             mark_point=["max"],
             legend_pos='65%',
             xaxis_interval=0,
             xaxis_rotate=27,
             xaxis_label_textsize=20,
             yaxis_label_textsize=20,
             yaxis_name_pos='end',
             yaxis_pos="%50")
    line.show_config()

    grid = Grid(width=1300, height=800)
    grid.add(line,
             grid_top="13%",
             grid_bottom="23%",
             grid_left="15%",
             grid_right="15%")

    out_file_name = './analyse/' + item_name + '.html'
    grid.render(out_file_name)
コード例 #8
0
def draw_line():
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 10, 100]
    v2 = [55, 60, 16, 20, 15, 80]
    line = Line("折线图示例")
    line.add("商家A", attr, v1, mark_point=["average"])
    line.add("商家B", attr, v2, is_smooth=True, mark_line=["max", "average"])
    line.add("商家C", attr, v1, is_step=True, is_label_show=True)
    line.show_config()
    line.render()
コード例 #9
0
ファイル: test_line.py プロジェクト: chumingke/pyecharts
def test_line_user_define_marks():
    line = Line("折线图示例")
    line.add("商家A", CLOTHES, clothes_v1,
             mark_point=["average", "max", "min"],
             mark_point_symbol='diamond', mark_point_textcolor='#40ff27')
    line.add("商家B", CLOTHES, clothes_v2,
             mark_point=["average", "max", "min"],
             mark_point_symbol='arrow', mark_point_symbolsize=40)
    line.show_config()
    line.render()
コード例 #10
0
def create_simple_line():
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 10, 100]
    v2 = [55, 60, 16, 20, 15, 80]
    line = Line("折线图示例")
    line.add("商家A", attr, v1, mark_point=["average"])
    line.add("商家B", attr, v2, is_smooth=True, mark_line=["max", "average"])
    line.show_config()
    line.render()
    print(News.objects.all())
    return line
コード例 #11
0
ファイル: draw.py プロジェクト: yunyan/spiders
    def draw_line(self, figure_name):
        x_axis = []
        points = []
        for i in self.item_collection:
            x_axis.append(i['dealDate'][0])
            points.append(i['unitPrice'][0])

        line = Line(figure_name)
        line.add(figure_name, x_axis, points)
        line.show_config()
        line.render(figure_name + '.html')
コード例 #12
0
    def drawPicture(self, file):
        df = pd.read_excel(file)
        df = pd.DataFrame(df)
        df.fillna(0, inplace=True)
        df['曹操'] = df['曹操'] + df['丞相'] + df['操大怒'] + df['曹丞相'] + df['操大喜']
        df['诸葛亮'] = df['诸葛亮'] + df['孔明曰'] + df['孔明笑'] + df['孔明']
        df['刘备'] = df['刘备'] + df['玄德'] + df['玄德曰'] + df['主公'] + df['刘皇叔'] + \
                   df['刘玄德'] + df['玄德大'] + df['玄德问'] + df['刘豫州'] + df['玄德闻'] + df['玄德乃']
        df['关云长'] = df['关云长'] + df['云长'] + df['关公']
        df['赵云'] = df['赵子龙'] + df['子龙'] + df['赵云']
        df['司马懿'] = df['司马懿'] + df['仲达'] + df['司马']
        df['周瑜'] = df['公瑾'] + df['周瑜']
        df['张飞'] = df['张飞'] + df['翼德']

        del ([
            df['丞相'], df['操大怒'], df['曹丞相'], df['操大喜'], df['孔明曰'], df['孔明笑'],
            df['孔明'], df['玄德'], df['玄德曰'], df['主公'], df['刘皇叔'], df['刘玄德'],
            df['玄德大'], df['玄德问'], df['刘豫州'], df['玄德闻'], df['玄德乃'], df['云长'],
            df['关公'], df['赵子龙'], df['子龙'], df['仲达'], df['司马'], df['公瑾'],
            df['翼德']
        ])

        data = pd.DataFrame(df)

        kings = ['曹操', '刘备', '孙权', '司马懿']
        shuGuo = ['刘备', '关云长', '张飞', '诸葛亮']

        x = [i for i in range(120)]
        s = Scatter('四位当权者活跃回')

        for king in kings:
            s.add('{}'.format(king),
                  x,
                  data[king],
                  xaxis_rotate=60,
                  symbol_size=4)
        s.show_config()
        s.render('四位当权者活跃回.html')
        nameS = Line('蜀国')

        for name in shuGuo:
            nameS.add('{}'.format(name),
                      x,
                      data[name],
                      xaxis_rotate=60,
                      symbol_size=0,
                      area_opacity=0.6)
        nameS.show_config()
        nameS.render('蜀国.html')
コード例 #13
0
def test_line_user_define_marks():
    line = Line("折线图示例")
    line.add("商家A",
             CLOTHES,
             clothes_v1,
             mark_point=["average", "max", "min"],
             mark_point_symbol='diamond',
             mark_point_textcolor='#40ff27')
    line.add("商家B",
             CLOTHES,
             clothes_v2,
             mark_point=["average", "max", "min"],
             mark_point_symbol='arrow',
             mark_point_symbolsize=40)
    line.show_config()
    line.render()
コード例 #14
0
def draw(file_in, file_out):
    '''
    '''
    df = pd.read_csv(file_in, encoding='utf-8')
    print(type(df['留存比']))
    print(df['留存比'].corr(df['随后中位数时间间隔']))

    # 对每一条数据存如列表中
    l1 = df['留存比'].tolist()
    l1 = [e * 1000 for e in l1]
    l2 = df['随后中位数时间间隔'].tolist()

    attr = [i for i in range(len(l1))]

    line = Line("")
    line.add("流失留存比 * 1000", attr, l1)
    line.add("卡顿时间", attr, l2)

    line.show_config()
    line.render(file_out)
コード例 #15
0
ファイル: main.py プロジェクト: sxhylkl/churn_analysis_SDK
    def draw(self):
        from pyecharts import Line
        line = Line("")
        churn_rates = []
        intervals = []
        for k, v in self.op_churn.items():
            churn_rate = v[1] * 1.0 / v[0]
            churn_rates.append(churn_rate)
            intervals.append(self.op_intervals[k])
        attr = [_ for _ in range(len(intervals))]
        churnrates = [rate * 1000 for rate in churn_rates]

        new_intervals = [i for i in intervals[::10]]
        new_churnrates = [c for c in churnrates[::10]]
        attr = [i for i in range(0, len(intervals), 10)]
        line = Line("")
        line.add("动作随后时间间隔", attr, new_intervals)
        line.add("动作留存比 * 1000", attr, new_churnrates)
        line.show_config()
        line.render('./output/render.html')
コード例 #16
0
 def draw_sentiment_pic(self,csv_file1,csv_file2):
     attr1, val1 = [], []
     attr2, val2 = [], []
     info1 = count_sentiment(csv_file1)
     info2 = count_sentiment(csv_file2)
     #字典的items()返回可遍历的(键, 值) 元组数组。
     info1 = sorted(info1.items(), key=lambda x: x[0], reverse=False)  # dict按照键值排序方法
     info2 = sorted(info2.items(), key=lambda x: x[0], reverse=False)  # dict按照键值排序方法
     for each in info1[:-1]:
         attr1.append(each[0])
         val1.append(each[1])
     for each in info2[:-1]:
         attr2.append(each[0])
         val2.append(each[1])
     line = Line("豆瓣影评情感分析图")
     #line.add("", attr, val, is_smooth=True, is_more_utils=True)
     line.add("红海行动", attr1, val1, is_fill=True, line_opacity=0.2, area_opacity=0.4, symbol=None)
     line.add("我不是药神", attr2, val2, is_fill=True, area_color='#000', area_opacity=0.3, is_smooth=True)
     line.show_config()
     line.render("豆瓣影评情感分析图.html")
コード例 #17
0
def draw_fill():
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 10, 100]
    v2 = [55, 60, 16, 20, 15, 80]
    line = Line("折线图-面积图示例")
    line.add("商家A",
             attr,
             v1,
             is_fill=True,
             line_opacity=0.2,
             area_opacity=0.4,
             symbol=None)
    line.add("商家B",
             attr,
             v2,
             is_fill=True,
             area_color='#000',
             area_opacity=0.3,
             is_smooth=True)
    line.show_config()
    line.render()
コード例 #18
0
def run():
    getCSV()
    a , b = wordcount(list_type)
    m, n = wordcount(list_are)
    # # 词云
    # wordcloud = WordCloud(width=1300, height=620)
    # wordcloud.add("", a, b, word_size_range=[20, 100])
    # wordcloud.show_config()
    # wordcloud.render()

    # 柱形表
    # bar = Bar("链家二手房_户型图表", "**************")
    # # bar = Bar("我的第一个图表", "这里是副标题")
    # bar.add("楼盘户型", a, b)
    # bar.show_config()
    # bar.render()

    # attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    # v1 = [11, 12, 13, 10, 10, 10]
    # pie = Pie("饼图示例")
    # pie.add("", a, b, is_label_show=True)
    # pie.show_config()
    # pie.render()

    # line = Line("折线图-面积图示例")
    # line.add("商家A", a, b, is_fill=True, line_opacity=2000000, area_opacity=4000000, symbol=None)
    # # line.add("商家B", m, n, is_fill=True, area_color='#000',line_opacity=200000, area_opacity=300000, symbol=None)
    # line.show_config()
    # line.render()

    line = Line("折线图示例")
    line.add("价格", a, b, mark_point=["average"])
    # line.add("", m, n, is_smooth=True, mark_line=["max", "average"])
    line.show_config()
    line.render()
    line = Line("折线图-阶梯图示例")
    line.add("价格", a, b, is_step=True, is_label_show=True)
    # line.add("商家A", attr, v1, is_step=True, is_label_show=True)
    line.show_config()
    line.render()
コード例 #19
0
def draw_line_mark():
    attr = [
        '周一',
        '周二',
        '周三',
        '周四',
        '周五',
        '周六',
        '周日',
    ]
    line = Line("折线图示例")
    line.add("最高气温",
             attr, [11, 11, 15, 13, 12, 13, 10],
             mark_point=["max", "min"],
             mark_line=["average"])
    line.add("最低气温",
             attr, [1, -2, 2, 5, 3, 2, 0],
             mark_point=["max", "min"],
             mark_line=["average"],
             yaxis_formatter="°C")
    line.show_config()
    line.render()
コード例 #20
0
def test_line():

    # line_0
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 10, 100]
    v2 = [55, 60, 16, 20, 15, 80]
    line = Line("折线图示例")
    line.add("商家A", attr, v1, mark_point=["average"])
    line.add("商家B", attr, v2, is_smooth=True, mark_line=["max", "average"])
    line.show_config()
    line.render()

    # line_1
    line = Line("折线图-数据堆叠示例")
    line.add("商家A", attr, v1, is_stack=True, is_label_show=True)
    line.add("商家B", attr, v2, is_stack=True, is_label_show=True)
    line.show_config()
    line.render()

    # line_2
    line = Line("折线图-阶梯图示例")
    line.add("商家A", attr, v1, is_step=True, is_label_show=True)
    line.show_config()
    line.render()

    # # line_3
    line = Line("折线图-面积图示例")
    line.add("商家A", attr, v1, is_fill=True, line_opacity=0.2, area_opacity=0.4, symbol=None)
    line.add("商家B", attr, v2, is_fill=True, area_color='#000', area_opacity=0.3, is_smooth=True)
    line.show_config()
    line.render()

    # line_4
    attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日', ]
    line = Line("折线图示例")
    line.add("最高气温", attr, [11, 11, 15, 13, 12, 13, 10], mark_point=["max", "min"], mark_line=["average"])
    line.add("最低气温", attr, [1, -2, 2, 5, 3, 2, 0], mark_point=["max", "min"], mark_line=["average"])
    line.show_config()
    line.render()
コード例 #21
0
def wc_access_visible():
    start_time = datetime.datetime.strptime("1998-06-20 22:00:00", '%Y-%m-%d %H:%M:%S')
    end_time = datetime.datetime.strptime("1998-06-25 22:00:00", '%Y-%m-%d %H:%M:%S')

    attr = []
    v1 = []
    logs = open(results_dir + result_file_per_10_min_normalize_revised2, 'r')
    for line_ in logs:  # wc_day49_2.log,13/Jun/1998:14:39:52 +0000,415
        # time_str = line.split(',')[1].split(' ')[0]
        # time_line = datetime.datetime.strptime(time_str, '%d/%b/%Y:%H:%M:%S')
        time_str = line_.split(',')[1]  # wc_day60_1.out,23/Jun/1998:22:10,0.2395
        time_line = datetime.datetime.strptime(time_str, '%d/%b/%Y:%H:%M')
        if start_time < time_line < end_time:
            attr.append(time_str)
            v1.append(float(line_.split(',')[2]))

    line = Line("WC Access per 10 Minute (Normalized) with Random", width=1600)
    # line = Line("WC Access per 10 Minute", width=1600)
    # line.add("A100", attr, v1, mark_point=["average"])
    line.add("users", attr, v1, is_smooth=True, mark_line=["min", "max", "average"])
    line.show_config()
    line.render(results_dir + chart_file)
コード例 #22
0
ファイル: huobi-moniter.py プロジェクト: cyl1231/crawl
def crawl_mail(workQueue):
    date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
    attrs.append(date)
    url = 'https://www.huobi.pro/zh-cn/eos_usdt/exchange/'
    html = get_html(url)
    # 创建request对象
    soup = BeautifulSoup(html, 'lxml')
    # 找出div中的内容
    soup_text = soup.find('div', class_='coin_list')
    btc, eth, eos, xrp = process_result(soup_text.text.strip())
    send_text = btc + " |" + eth + " |" + eos + " |" + xrp
    print send_text
    workQueue.put(btc)
    workQueue.put(eth)
    workQueue.put(eos)
    workQueue.put(xrp)
    while workQueue.qsize() > 0:
        print workQueue.qsize()
        coin = workQueue.get()
        results = coin.split(" ")
        name = results[0]
        price = results[1]
        increase = results[2]
        if cmp(name, "btc") == 0:
            btcs.append(price)
        elif cmp(name, "eos") == 0:
            eoss.append(price)
        elif cmp(name, "eth") == 0:
            eths.append(price)
        elif cmp(name, "xrp") == 0:
            xrps.append(price)
        alertMail(increase, price, send_text)
    line = Line("huobi 主区大盘btc")
    line.add("btc", attrs, btcs, is_smooth=True, mark_line=["max", "average"])
    line.show_config()
    line.render()
コード例 #23
0
      time,
      house,
      mark_line=["average"],
      mark_point=["max", "min"],
      xaxis_name="日期",
      yaxis_name="价格",
      yaxis_name_gap=60)
x.add("地铁房",
      time,
      house1,
      mark_point=["max", "min"],
      xaxis_name="日期",
      yaxis_name="价格",
      yaxis_name_gap=60)
x.add("学区房",
      time,
      house2,
      mark_point=["max", "min"],
      xaxis_name="日期",
      line_color='green',
      yaxis_name="价格",
      yaxis_name_gap=60)
x.add("车位房",
      time,
      house3,
      mark_point=["max", "min"],
      xaxis_name="日期",
      yaxis_name="价格",
      yaxis_name_gap=60)
x.show_config()
x.render()
コード例 #24
0
ファイル: test_line.py プロジェクト: ljwdoc/pyecharts
def test_line():

    # line_0
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 10, 100]
    v2 = [55, 60, 16, 20, 15, 80]
    line = Line("折线图示例")
    line.add("商家A", attr, v1, mark_point=["average"])
    line.add("商家B", attr, v2, is_smooth=True, mark_line=["max", "average"])
    line.show_config()
    line.render()

    # line_0_1
    line = Line("折线图示例")
    line.add("商家A", attr, v1, mark_point=["average", "max", "min"],
             mark_point_symbol='diamond', mark_point_textcolor='#40ff27')
    line.add("商家B", attr, v2, mark_point=["average", "max", "min"],
             mark_point_symbol='arrow', mark_point_symbolsize=40)
    line.show_config()
    line.render()

    # line_1
    line = Line("折线图-数据堆叠示例")
    line.add("商家A", attr, v1, is_stack=True, is_label_show=True)
    line.add("商家B", attr, v2, is_stack=True, is_label_show=True)
    line.show_config()
    line.render()

    # line_2
    line = Line("折线图-阶梯图示例")
    line.add("商家A", attr, v1, is_step=True, is_label_show=True)
    line.show_config()
    line.render()

    # # line_3
    line = Line("折线图-面积图示例")
    line.add("商家A", attr, v1, is_fill=True, line_opacity=0.2, area_opacity=0.4, symbol=None)
    line.add("商家B", attr, v2, is_fill=True, area_color='#000', area_opacity=0.3, is_smooth=True)
    line.show_config()
    line.render()

    # line_4
    attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    line = Line("折线图示例")
    line.add("最高气温", attr, [11, 11, 15, 13, 12, 13, 10], mark_point=["max", "min"], mark_line=["average"])
    line.add("最低气温", attr, [1, -2, 2, 5, 3, 2, 0], mark_point=["max", "min"], mark_line=["average"])
    line.show_config()
    line.render()
コード例 #25
0
def test_line():

    # line_0
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 10, 100]
    v2 = [55, 60, 16, 20, 15, 80]
    line = Line("折线图示例")
    line.add("商家A", attr, v1, mark_point=["average"])
    line.add("商家B", attr, v2, is_smooth=True, mark_line=["max", "average"])
    line.show_config()
    line.render()

    # line_0_1
    line = Line("折线图示例")
    line.add("商家A",
             attr,
             v1,
             mark_point=["average", "max", "min"],
             mark_point_symbol='diamond',
             mark_point_textcolor='#40ff27')
    line.add("商家B",
             attr,
             v2,
             mark_point=["average", "max", "min"],
             mark_point_symbol='arrow',
             mark_point_symbolsize=40)
    line.show_config()
    line.render()

    # line_1
    line = Line("折线图-数据堆叠示例")
    line.add("商家A", attr, v1, is_stack=True, is_label_show=True)
    line.add("商家B", attr, v2, is_stack=True, is_label_show=True)
    line.show_config()
    line.render()

    # line_2
    line = Line("折线图-阶梯图示例")
    line.add("商家A", attr, v1, is_step=True, is_label_show=True)
    line.show_config()
    line.render()

    # line_3
    line = Line("折线图-面积图示例")
    line.add("商家A",
             attr,
             v1,
             is_fill=True,
             line_opacity=0.2,
             area_opacity=0.4,
             symbol=None)
    line.add("商家B",
             attr,
             v2,
             is_fill=True,
             area_color='#000',
             area_opacity=0.3,
             is_smooth=True)
    line.show_config()
    line.render()

    # line_3_1
    import math, random
    line = Line("折线图示例")
    line.add("商家A", attr,
             [math.log10(random.randint(1, 99999)) for _ in range(6)])
    line.add("商家B",
             attr, [math.log10(random.randint(1, 99999999)) for _ in range(6)],
             yaxis_type="log")
    line.show_config()
    line.render()

    # line_4
    attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    line = Line("折线图示例")
    line.add("最高气温",
             attr, [11, 11, 15, 13, 12, 13, 10],
             mark_point=["max", "min"],
             mark_line=["average"])
    line.add("最低气温",
             attr, [1, -2, 2, 5, 3, 2, 0],
             mark_point=["max", "min"],
             mark_line=["average"])
    line.show_config()
    line.render()
コード例 #26
0
#提取中国从疫情开始每一疫情具体数据
tempBaseData = data["data"]["chinaDayList"]
#遍历每天具体数据编程pandas
for item in tempBaseData:
    line = [
        item["date"], item["confirm"], item["suspect"], item["dead"],
        item["heal"], item["nowConfirm"], item["nowSevere"]
    ]
    #创建pandas中的行
    series = pd.Series(line, chinaDayColumnList)
    chinaDaySeriesList.append(series)
#创建表格
chainDayDateFrame = pd.DataFrame(chinaDaySeriesList)
print(chainDayDateFrame)

#生成全国实时疫情趋势图
#创建折线图
line = Line("全国实时疫情趋势图", "人数", width=1200, height=600)
#从表格中拿到所以日期
dateAttr = list(chainDayDateFrame.loc[chainDayDateFrame.index, "date"])
confirm = list(chainDayDateFrame.loc[chainDayDateFrame.index, "confirm"])
suspect = list(chainDayDateFrame.loc[chainDayDateFrame.index, "suspect"])
nowConfirm = list(chainDayDateFrame.loc[chainDayDateFrame.index, "nowConfirm"])
nowSevere = list(chainDayDateFrame.loc[chainDayDateFrame.index, "nowSevere"])
line.add("累计确诊", dateAttr, confirm, mark_point=['max'])
line.add("现有疑似", dateAttr, suspect, mark_point=['max'])
line.add("现有确诊", dateAttr, nowConfirm, mark_point=['max'])
line.add("现有重症", dateAttr, nowSevere, mark_point=['max'])
line.show_config()
line.render(path="./output/全国实时疫情趋势图.html")
コード例 #27
0
ファイル: chinese wodcloud.py プロジェクト: analylx/learn
from pyecharts import Line, Bar, Pie, EffectScatter
# 数据
attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
v1 = [5, 20, 36, 10, 10, 100]
v2 = [55, 60, 16, 20, 15, 80]

# 普通折线图
line = Line('折线图')
line.add('商家A', attr, v1, mark_point=['max'])
line.add('商家B', attr, v2, mark_point=['min'], is_smooth=True)
line.show_config()
line.render(path='./data/01-04折线图.html')

# 阶梯折线图
line2 = Line('阶梯折线图')
line2.add('商家A', attr, v1, is_step=True, is_label_show=True)
line2.show_config()
line2.render(path='./data/01-05阶梯折线图.html')

# 面积折线图
line3 = Line("面积折线图")
line3.add("商家A",
          attr,
          v1,
          is_fill=True,
          line_opacity=0.2,
          area_opacity=0.4,
          symbol=None,
          mark_point=['max'])
line3.add("商家B",
          attr,
コード例 #28
0
def read_content(file_name, filter_ip=['127.0.0.1']):
# 读取日志文件,并生成record和result以及可视化文件
# 过滤本地自动连接的IP
# 完成
	li = []
	# 所有数据
	li_result = []
	# 登录记录
	log_type = []
	# 密钥&密码登录
	log_date_times = []
	# 登录日期时间
	log_ips = []
	# 登录IP
	log_ports = []
	# 登录端口
	log_dates = []
	# 登录日期
	log_times = []
	# 登录时间
	log_users = []
	# 登录用户
	log_sshds = []
	# 登录号,匹配登出时间用
	li_month = (('Jan ', '01-'), ('Feb ', '02-'), ('Mar ', '03-'), ('Apr ', '04-'), ('May ', '05-'), ('Jun ', '06-'), ('Jul ', '07-'), ('Aug ', '08-'), ('Sep ', '09-'), ('Oct ', '10-'), ('Nov ', '11-'), ('Dec ', '12-'))
	# 替换日期
	log_position = os.path.dirname(file_name)

	print("reading the file: %s ..." % file_name, ", time:", datetime.now().strftime('%Y-%m-%d %H:%M:%S'),  file=open("./create_file_log", "a", encoding="utf-8"))

	try:
		# 读取日志文件
		with open(file_name , "rb") as f_code:	   
			code = chardet.detect(f_code.readline())['encoding']
		if code == "ascii":
			code = "utf-8"
		with open(file_name, "r", encoding=code, errors='ignore') as f:
			content = str(f.read())
			
	except Exception as e:
		print("read the file : %s wrong!" % file_name, ", time:", datetime.now().strftime('%Y-%m-%d %H:%M:%S'),  file=open("./create_file_log", "a", encoding="utf-8"))
		return

	for each in li_month:
		content = content.replace(each[0], each[1])
		# 月份格式替换成阿拉伯数字

	li = content.split('\n')
	li_close = []
	close_port_format = re.compile('\[(.*?)\]')
	close_time_format = re.compile("\d\d:\d\d:\d\d")
	date_times_format = re.compile(".{0,8}\d\d:\d\d:\d\d")
	ips_format = re.compile("\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}")
	ports_format = re.compile("port (\d{1,})")
	users_format = re.compile("for (.*?) from")
	sshds_format = re.compile('\[(.*?)\]')

	for each in li:
		# 筛选登录记录
		if "Accepted password" in each:
			if re.findall(ips_format, each)[0] in filter_ip:
				continue
			li_result.append(each)
			log_type.append("password")
			# 密码登录
		if "Accepted publickey" in each:
			if re.findall(ips_format, each)[0] in filter_ip:
				continue
			li_result.append(each)
			log_type.append("publickey")
			# 密钥登录
		if "session closed" in each and "sshd" in each:
			# 登出记录
			close_port = re.findall(close_port_format, each)[0]
			close_user = each.split()[-1]
			close_time = re.findall(close_time_format, each)[0]
			li_close.append((close_port, close_user, close_time))


	for each in li_result:
		log_date_times.append(re.findall(date_times_format, each)[0])
		log_ips.append(re.findall(ips_format, each)[0])
		log_ports.append(re.findall(ports_format, each)[0])
		log_users.append(re.findall(users_format, each)[0])
		log_sshds.append(re.findall(sshds_format, each)[0])

	for each in log_date_times:
		log_dates.append(each[:-9])
		log_times.append(each[-8:])

	if log_dates:
	# 计算年份
		years = 0
		log_dates.reverse()
		start_month = log_dates[0].split('-')[0]
		for i in range(len(log_dates)):
			current_time = log_dates[i].split('-')
			current_month = current_time[0]
			if current_month > start_month:
				years += 1
				start_month = current_month
			log_dates[i] = str(datetime.now().year - years)[-2:] + '-' + log_dates[i]
		log_dates.reverse()
	else:
		print(file_name,":记录为空" , ", time:", datetime.now().strftime('%Y-%m-%d %H:%M:%S'),  file=open("./create_file_log", "a", encoding="utf-8"))

	print("read the file: %s complete" % file_name, ", time:", datetime.now().strftime('%Y-%m-%d %H:%M:%S'),  file=open("./create_file_log", "a", encoding="utf-8"))

	print("creating the file: %s ..." % str(log_position + "/record.csv"), ", time:", datetime.now().strftime('%Y-%m-%d %H:%M:%S'),  file=open("./create_file_log", "a", encoding="utf-8"))
	with open(log_position + "/record.csv", "w", encoding="utf-8") as f:
		head = "date,connect time,close time,use time,user,ip,port,longon type\n"
		f.write(head)
		for i in range(len(log_ips)):
			try:
				# 计算单次登录用时
				log_out_time = "24:00:00"
				for j in li_close:
					if j[0] == log_sshds[i]:
						log_out_time = li_close.pop(li_close.index(j))[2]
						break
				
				log_time_i_format = log_times[i].split(':')
				close_time_i_format = log_out_time.split(':')
				log_time_to_second = int(log_time_i_format[0])*3600 + int(log_time_i_format[1])*60 + int(log_time_i_format[2])
				close_time_to_second = int(close_time_i_format[0])*3600 + int(close_time_i_format[1])*60 + int(close_time_i_format[2])
				if log_out_time == "24:00:00":
					use_time_to_second = 24*60*60 - log_time_to_second
				elif close_time_to_second < log_time_to_second:
					use_time_to_second = 24*3600 - log_time_to_second + close_time_to_second
				else:
					use_time_to_second = close_time_to_second - log_time_to_second

				use_time = time_to_format(use_time_to_second)
				contents = "%s,%s,%s,%s,%s,%s,%s,%s\n" % (log_dates[i], log_times[i], log_out_time, use_time, log_users[i], log_ips[i], log_ports[i], log_type[i])

			except Exception as e:
				contents = "%s,%s,-1,-1,%s,%s,%s,%s\n" % (log_dates[i], log_times[i], log_users[i], log_ips[i], log_ports[i], log_type[i])
			finally:
				f.write(contents)

	print("create the file: %s complete" % str(log_position + "/record.csv"), ", time:", datetime.now().strftime('%Y-%m-%d %H:%M:%S'),  file=open("./create_file_log", "a", encoding="utf-8"))

	print("reading the file: %s ..." % str(log_position + "/result.csv"), ", time:", datetime.now().strftime('%Y-%m-%d %H:%M:%S'),  file=open("./create_file_log", "a", encoding="utf-8"))
	with open(log_position + "/record.csv", "r", encoding="utf-8") as f:
		f.readline()
		li_contents = f.read().split("\n")
		li_contents_result = []
		i = 0
		for each in li_contents:
			datas = each.split(',')
			if datas[0] == "":
				pass
			elif not li_contents_result:
				li_contents_result.append([datas[0], [datas[1], datas[2], datas[3]] + [1]])
				i += 1
			elif li_contents_result[i-1][0] != datas[0]:
				li_contents_result.append([datas[0], [datas[1], datas[2], datas[3]] + [1]])
				i += 1
			else:
				li_contents_result[i-1][1][-1] += 1
				li_contents_result[i-1][1][1] = datas[2]
				log_time_i_format = li_contents_result[i-1][1][2].split(':')

				close_time_i_format = datas[3].split(':')
				log_time_to_second = int(log_time_i_format[0])*3600 + int(log_time_i_format[1])*60 + int(log_time_i_format[2])
				close_time_to_second = int(close_time_i_format[0])*3600 + int(close_time_i_format[1])*60 + int(close_time_i_format[2])
				use_time_to_second = close_time_to_second + log_time_to_second
				use_time = time_to_format(use_time_to_second)
				li_contents_result[i-1][1][2] = use_time

	with open(log_position + "/result.csv", "w", encoding="utf-8") as f:
			head = "date,log time,logout time,day use time, logon times\n"
			f.write(head)
			li_dates = []
			li_use_times = []
			li_logon_times = []
			
			for each in li_contents_result:
				contents = "%s,%s,%s,%s,%d\n" % (each[0], each[1][0],each[1][1],each[1][2],each[1][3])
				f.write(contents)
				li_dates.append(each[0])

				li_use_time_format = each[1][2].split(':')
				li_use_time_to_second = int(li_use_time_format[0])*3600 + int(li_use_time_format[1])*60 + int(li_use_time_format[2])
				if li_use_time_to_second/3600 > 24:
					li_use_times.append(24)
				else:
					li_use_times.append(li_use_time_to_second/3600)
				li_logon_times.append(each[1][3])

	print("read the file: %s complete" % str(log_position + "/result.csv"), ", time:", datetime.now().strftime('%Y-%m-%d %H:%M:%S'),  file=open("./create_file_log", "a", encoding="utf-8"))

	# 生成可视化文件
	# 生成bar.js文件
	print("creating the visual file: %s ..." % str(log_position + "/visual_bar.js"), ", time:", datetime.now().strftime('%Y-%m-%d %H:%M:%S'),  file=open("./create_file_log", "a", encoding="utf-8"))
	bar = Bar("登陆次数/日", "单位:次", width=1200, height=800)
	bar.add("日期", li_dates, li_logon_times,is_more_utils=True)
	config_bar = bar.show_config().replace("True", "true").replace("False", "false").replace("None", "null")
	with open(log_position + "/visual_bar.js", "w", encoding="utf-8") as f:
		content_bar = """var myChart_bar = echarts.init(document.getElementById('bar'));
var option_bar = """ + config_bar + ";\n" + "myChart_bar.setOption(option_bar);"
		f.write(content_bar)	
	print("create the visual file: %s complete" % str(log_position + "/visual_bar.js"), ", time:", datetime.now().strftime('%Y-%m-%d %H:%M:%S'),  file=open("./create_file_log", "a", encoding="utf-8"))


	# 生成line.js文件
	print("creating the visual file: %s ..." % str(log_position + "/visual.html"), ", time:", datetime.now().strftime('%Y-%m-%d %H:%M:%S'),  file=open("./create_file_log", "a", encoding="utf-8"))
	line = Line("总用时/日", "单位:小时", width=1200, height=800)
	line.add("日期", li_dates, li_use_times,is_more_utils=True)
	config_line = line.show_config().replace("True", "true").replace("False", "false").replace("None", "null")

	with open(log_position + "/visual_line.js", "w", encoding="utf-8") as f:
		content_line = """var myChart_line = echarts.init(document.getElementById('line'));
var option_line = """ + config_line + ";\n" + "myChart_line.setOption(option_line);"
		f.write(content_line)
	print("create the visual file: %s complete" % str(log_position + "/visual_line.js"), ", time:", datetime.now().strftime('%Y-%m-%d %H:%M:%S'),  file=open("./create_file_log", "a", encoding="utf-8"))


	# 生成visual_geo.csv/visual_geo_show.csv文件
	print("creating the visual file: %s ..." % str(log_position + "/visual_geo.csv"), ", time:", datetime.now().strftime('%Y-%m-%d %H:%M:%S'),  file=open("./create_file_log", "a", encoding="utf-8"))

	li_ips = []
	set_ips = set()
	di_ips = {}
	di_locs = {}
	with open(log_position + "/record.csv", "r", encoding="utf-8") as f:
		f.readline()
		for each in f.read().split('\n'):

			each = each.split(',')
			if each == '':
				pass
			elif len(each) == 8:
				li_ips.append(each[-3])

	set_ips = set(li_ips)
	for ip in set_ips:
		di_ips[ip] = li_ips.count(ip)

	init_get_country()
	content_geo = "loc,ip,经纬度,times\n"
	content_geo_show = "loc,ip,经纬度,times\n"

	for ip in di_ips.keys():
		# 先过滤私有IP
		if ip[:7] == "192.168" or ip[:3] == "127":
			continue
		elif ip[:3] == "172":
			ip_each = ip.split('.')
			if 16 <= int(ip_each[1]) <= 31:
				continue
		loc, lng_alt = get_loc(ip)
		if loc == "" or lng_alt == "":
			# 说明为国外地址,通过ip138查
			loc, lng_alt = get_loc_ip138(ip)
		if loc == "" or lng_alt == "":
			# ip138再次查询失败
			continue
		content_geo += loc + "," + ip + "," + lng_alt + "," + str(di_ips[ip]) + "\n"
		if loc not in di_locs:
		# {位置:[[ip1,times],[ip2],times],...], all_times]}
			di_locs[loc] = [lng_alt, [(ip, di_ips[ip])], di_ips[ip]]
		else:
			di_locs[loc][1].append((ip, di_ips[ip]))
			di_locs[loc][2] += di_ips[ip]

	# 地理图数据csv内容格式
	# content_geo = """231,1.1.1.1,"116.397026,39.918058",1
	# 231,1.1.1.1,"106.397026,0.918058",2
	# 231,1.1.1.1,"156.397026,70.918058",3
	# """
	with open(log_position + "/visual_geo.csv", "w", encoding="utf-8") as f:
		f.write(content_geo)

	# 地理图csv内容格式
	# 天津市,(106.47.98.130:9次,180.212.36.188:10次),"117.21081309,39.14392990",9
	# 地点,ip群(ip:次数,...),经纬度,总次数
	# 源文件不变,再加一个汇总
	for each in di_locs.keys():
		content_geo_show += each + ",("
		for ip in di_locs[each][1]:
			content_geo_show += ip[0] + " : " + str(ip[1]) + "次,"
		content_geo_show += ")," + di_locs[each][0] + "," + str(di_locs[each][2]) + "\n"

	with open(log_position + "/visual_geo_show.csv", "w", encoding="utf-8") as f:
		f.write(content_geo_show)
		
	print("create the visual file: %s complete" % str(log_position + "/visual_geo.csv"), ", time:", datetime.now().strftime('%Y-%m-%d %H:%M:%S'),  file=open("./create_file_log", "a", encoding="utf-8"))
コード例 #29
0
ファイル: test_grid.py プロジェクト: zhy0313/pyecharts
def test_grid():

    # grid_0
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    bar = Bar("柱状图示例", height=720, is_grid=True)
    bar.add("商家A", attr, v1, is_stack=True, grid_bottom="60%")
    bar.add("商家B", attr, v2, is_stack=True, grid_bottom="60%")
    line = Line("折线图示例", title_top="50%")
    attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    line.add("最高气温",
             attr, [11, 11, 15, 13, 12, 13, 10],
             mark_point=["max", "min"],
             mark_line=["average"])
    line.add("最低气温",
             attr, [1, -2, 2, 5, 3, 2, 0],
             mark_point=["max", "min"],
             mark_line=["average"],
             legend_top="50%")
    bar.grid(line.get_series(), grid_top="60%")
    bar.show_config()
    bar.render()

    # grid_1
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    scatter = Scatter(width=1200, is_grid=True)
    scatter.add("散点图示例", v1, v2, grid_left="60%", legend_pos="70%")
    es = EffectScatter()
    es.add("动态散点图示例", [11, 11, 15, 13, 12, 13, 10], [1, -2, 2, 5, 3, 2, 0],
           effect_scale=6,
           legend_pos="20%")
    scatter.grid(es.get_series(), grid_right="60%")
    scatter.show_config()
    scatter.render()

    # grid_2
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    bar = Bar("柱状图示例", height=720, width=1200, title_pos="65%", is_grid=True)
    bar.add("商家A", attr, v1, is_stack=True, grid_bottom="60%", grid_left="60%")
    bar.add("商家B",
            attr,
            v2,
            is_stack=True,
            grid_bottom="60%",
            grid_left="60%",
            legend_pos="80%")
    line = Line("折线图示例")
    attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    line.add("最高气温",
             attr, [11, 11, 15, 13, 12, 13, 10],
             mark_point=["max", "min"],
             mark_line=["average"])
    line.add("最低气温",
             attr, [1, -2, 2, 5, 3, 2, 0],
             mark_point=["max", "min"],
             mark_line=["average"],
             legend_pos="20%")
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    scatter = Scatter("散点图示例", title_top="50%", title_pos="65%")
    scatter.add("scatter", v1, v2, legend_top="50%", legend_pos="80%")
    es = EffectScatter("动态散点图示例", title_top="50%")
    es.add("es", [11, 11, 15, 13, 12, 13, 10], [1, -2, 2, 5, 3, 2, 0],
           effect_scale=6,
           legend_top="50%",
           legend_pos="20%")
    bar.grid(line.get_series(), grid_bottom="60%", grid_right="60%")
    bar.grid(scatter.get_series(), grid_top="60%", grid_left="60%")
    bar.grid(es.get_series(), grid_top="60%", grid_right="60%")
    bar.show_config()
    bar.render()

    # grid_3
    line = Line("折线图示例", width=1200, is_grid=True)
    attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    line.add("最高气温",
             attr, [11, 11, 15, 13, 12, 13, 10],
             mark_point=["max", "min"],
             mark_line=["average"],
             grid_right="65%")
    line.add("最低气温",
             attr, [1, -2, 2, 5, 3, 2, 0],
             mark_point=["max", "min"],
             mark_line=["average"],
             legend_pos="20%")
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [11, 12, 13, 10, 10, 10]
    pie = Pie("饼图示例", title_pos="45%")
    pie.add("",
            attr,
            v1,
            radius=[30, 55],
            legend_pos="65%",
            legend_orient='vertical')
    line.grid(pie.get_series(), grid_left="60%")
    line.show_config()
    line.render()

    # grid_4
    line = Line("折线图示例", width=1200, is_grid=True)
    attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    line.add("最高气温",
             attr, [11, 11, 15, 13, 12, 13, 10],
             mark_point=["max", "min"],
             mark_line=["average"],
             grid_right="60%")
    line.add("最低气温",
             attr, [1, -2, 2, 5, 3, 2, 0],
             mark_point=["max", "min"],
             mark_line=["average"],
             legend_pos="20%",
             grid_right="60%")
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    value = [20, 40, 60, 80, 100, 120]
    v1 = [[2320.26, 2320.26, 2287.3,
           2362.94], [2300, 2291.3, 2288.26, 2308.38],
          [2295.35, 2346.5, 2295.35, 2345.92],
          [2347.22, 2358.98, 2337.35, 2363.8],
          [2360.75, 2382.48, 2347.89, 2383.76],
          [2383.43, 2385.42, 2371.23, 2391.82],
          [2377.41, 2419.02, 2369.57, 2421.15],
          [2425.92, 2428.15, 2417.58,
           2440.38], [2411, 2433.13, 2403.3, 2437.42],
          [2432.68, 2334.48, 2427.7, 2441.73],
          [2430.69, 2418.53, 2394.22, 2433.89],
          [2416.62, 2432.4, 2414.4, 2443.03],
          [2441.91, 2421.56, 2418.43, 2444.8],
          [2420.26, 2382.91, 2373.53, 2427.07],
          [2383.49, 2397.18, 2370.61, 2397.94],
          [2378.82, 2325.95, 2309.17, 2378.82],
          [2322.94, 2314.16, 2308.76, 2330.88],
          [2320.62, 2325.82, 2315.01, 2338.78],
          [2313.74, 2293.34, 2289.89, 2340.71],
          [2297.77, 2313.22, 2292.03, 2324.63],
          [2322.32, 2365.59, 2308.92, 2366.16],
          [2364.54, 2359.51, 2330.86, 2369.65],
          [2332.08, 2273.4, 2259.25, 2333.54],
          [2274.81, 2326.31, 2270.1, 2328.14],
          [2333.61, 2347.18, 2321.6, 2351.44],
          [2340.44, 2324.29, 2304.27, 2352.02],
          [2326.42, 2318.61, 2314.59, 2333.67],
          [2314.68, 2310.59, 2296.58, 2320.96],
          [2309.16, 2286.6, 2264.83, 2333.29],
          [2282.17, 2263.97, 2253.25, 2286.33],
          [2255.77, 2270.28, 2253.31, 2276.22]]
    kline = Kline("K 线图示例", title_pos="60%")
    kline.add("日K", ["2017/7/{}".format(i + 1) for i in range(31)],
              v1,
              legend_pos="80%")
    line.grid(kline.get_series(), grid_left="55%")
    line.show_config()
    line.render()

    # grid_5
    import random
    x_axis = [
        "12a", "1a", "2a", "3a", "4a", "5a", "6a", "7a", "8a", "9a", "10a",
        "11a", "12p", "1p", "2p", "3p", "4p", "5p", "6p", "7p", "8p", "9p",
        "10p", "11p"
    ]
    y_aixs = [
        "Saturday", "Friday", "Thursday", "Wednesday", "Tuesday", "Monday",
        "Sunday"
    ]
    data = [[i, j, random.randint(0, 50)] for i in range(24) for j in range(7)]
    heatmap = HeatMap("热力图示例", height=700, is_grid=True)
    heatmap.add("热力图直角坐标系",
                x_axis,
                y_aixs,
                data,
                is_visualmap=True,
                visual_top="45%",
                visual_text_color="#000",
                visual_orient='horizontal',
                grid_bottom="60%")
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    bar = Bar("柱状图示例", title_top="52%")
    bar.add("商家A", attr, v1, is_stack=True)
    bar.add("商家B", attr, v2, is_stack=True, legend_top="50%")
    heatmap.grid(bar.get_series(), grid_top="60%")
    heatmap.show_config()
    heatmap.render()
コード例 #30
0
ファイル: test_grid.py プロジェクト: ljwdoc/pyecharts
def test_grid():

    # grid_0
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    bar = Bar("柱状图示例", height=720, is_grid=True)
    bar.add("商家A", attr, v1, is_stack=True, grid_bottom="60%")
    bar.add("商家B", attr, v2, is_stack=True, grid_bottom="60%")
    line = Line("折线图示例", title_top="50%")
    attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    line.add("最高气温", attr, [11, 11, 15, 13, 12, 13, 10], mark_point=["max", "min"], mark_line=["average"])
    line.add("最低气温", attr, [1, -2, 2, 5, 3, 2, 0], mark_point=["max", "min"],
             mark_line=["average"], legend_top="50%")
    bar.grid(line.get_series(), grid_top="60%")
    bar.show_config()
    bar.render()

    # grid_1
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    scatter = Scatter(width=1200, is_grid=True)
    scatter.add("散点图示例", v1, v2, grid_left="60%", legend_pos="70%")
    es = EffectScatter()
    es.add("动态散点图示例", [11, 11, 15, 13, 12, 13, 10], [1, -2, 2, 5, 3, 2, 0],
           effect_scale=6, legend_pos="20%")
    scatter.grid(es.get_series(), grid_right="60%")
    scatter.show_config()
    scatter.render()

    # grid_2
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    bar = Bar("柱状图示例", height=720, width=1200, title_pos="65%", is_grid=True)
    bar.add("商家A", attr, v1, is_stack=True, grid_bottom="60%", grid_left="60%")
    bar.add("商家B", attr, v2, is_stack=True, grid_bottom="60%", grid_left="60%", legend_pos="80%")
    line = Line("折线图示例")
    attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    line.add("最高气温", attr, [11, 11, 15, 13, 12, 13, 10], mark_point=["max", "min"], mark_line=["average"])
    line.add("最低气温", attr, [1, -2, 2, 5, 3, 2, 0], mark_point=["max", "min"],
             mark_line=["average"], legend_pos="20%")
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    scatter = Scatter("散点图示例", title_top="50%", title_pos="65%")
    scatter.add("scatter", v1, v2, legend_top="50%", legend_pos="80%")
    es = EffectScatter("动态散点图示例", title_top="50%")
    es.add("es", [11, 11, 15, 13, 12, 13, 10], [1, -2, 2, 5, 3, 2, 0], effect_scale=6,
           legend_top="50%", legend_pos="20%")
    bar.grid(line.get_series(), grid_bottom="60%", grid_right="60%")
    bar.grid(scatter.get_series(), grid_top="60%", grid_left="60%")
    bar.grid(es.get_series(), grid_top="60%", grid_right="60%")
    bar.show_config()
    bar.render()

    # grid_3
    line = Line("折线图示例", width=1200, is_grid=True)
    attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    line.add("最高气温", attr, [11, 11, 15, 13, 12, 13, 10], mark_point=["max", "min"],
             mark_line=["average"], grid_right="65%")
    line.add("最低气温", attr, [1, -2, 2, 5, 3, 2, 0], mark_point=["max", "min"],
             mark_line=["average"], legend_pos="20%")
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [11, 12, 13, 10, 10, 10]
    pie = Pie("饼图示例", title_pos="45%")
    pie.add("", attr, v1, radius=[30, 55], legend_pos="65%", legend_orient='vertical')
    line.grid(pie.get_series(), grid_left="60%")
    line.show_config()
    line.render()

    # grid_4
    line = Line("折线图示例", width=1200, is_grid=True)
    attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    line.add("最高气温", attr, [11, 11, 15, 13, 12, 13, 10], mark_point=["max", "min"],
             mark_line=["average"], grid_right="60%")
    line.add("最低气温", attr, [1, -2, 2, 5, 3, 2, 0], mark_point=["max", "min"],
             mark_line=["average"], legend_pos="20%", grid_right="60%")
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    value = [20, 40, 60, 80, 100, 120]
    v1 = [[2320.26, 2320.26, 2287.3, 2362.94],
          [2300, 2291.3, 2288.26, 2308.38],
          [2295.35, 2346.5, 2295.35, 2345.92],
          [2347.22, 2358.98, 2337.35, 2363.8],
          [2360.75, 2382.48, 2347.89, 2383.76],
          [2383.43, 2385.42, 2371.23, 2391.82],
          [2377.41, 2419.02, 2369.57, 2421.15],
          [2425.92, 2428.15, 2417.58, 2440.38],
          [2411, 2433.13, 2403.3, 2437.42],
          [2432.68, 2334.48, 2427.7, 2441.73],
          [2430.69, 2418.53, 2394.22, 2433.89],
          [2416.62, 2432.4, 2414.4, 2443.03],
          [2441.91, 2421.56, 2418.43, 2444.8],
          [2420.26, 2382.91, 2373.53, 2427.07],
          [2383.49, 2397.18, 2370.61, 2397.94],
          [2378.82, 2325.95, 2309.17, 2378.82],
          [2322.94, 2314.16, 2308.76, 2330.88],
          [2320.62, 2325.82, 2315.01, 2338.78],
          [2313.74, 2293.34, 2289.89, 2340.71],
          [2297.77, 2313.22, 2292.03, 2324.63],
          [2322.32, 2365.59, 2308.92, 2366.16],
          [2364.54, 2359.51, 2330.86, 2369.65],
          [2332.08, 2273.4, 2259.25, 2333.54],
          [2274.81, 2326.31, 2270.1, 2328.14],
          [2333.61, 2347.18, 2321.6, 2351.44],
          [2340.44, 2324.29, 2304.27, 2352.02],
          [2326.42, 2318.61, 2314.59, 2333.67],
          [2314.68, 2310.59, 2296.58, 2320.96],
          [2309.16, 2286.6, 2264.83, 2333.29],
          [2282.17, 2263.97, 2253.25, 2286.33],
          [2255.77, 2270.28, 2253.31, 2276.22]]
    kline = Kline("K 线图示例", title_pos="60%")
    kline.add("日K", ["2017/7/{}".format(i + 1) for i in range(31)], v1, legend_pos="80%")
    line.grid(kline.get_series(), grid_left="55%")
    line.show_config()
    line.render()

    # grid_5
    import random
    x_axis = ["12a", "1a", "2a", "3a", "4a", "5a", "6a", "7a", "8a", "9a", "10a", "11a",
              "12p", "1p", "2p", "3p", "4p", "5p", "6p", "7p", "8p", "9p", "10p", "11p"]
    y_aixs = ["Saturday", "Friday", "Thursday", "Wednesday", "Tuesday", "Monday", "Sunday"]
    data = [[i, j, random.randint(0, 50)] for i in range(24) for j in range(7)]
    heatmap = HeatMap("热力图示例", height=700, is_grid=True)
    heatmap.add("热力图直角坐标系", x_axis, y_aixs, data, is_visualmap=True, visual_top="45%",
                visual_text_color="#000", visual_orient='horizontal', grid_bottom="60%")
    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    v1 = [5, 20, 36, 10, 75, 90]
    v2 = [10, 25, 8, 60, 20, 80]
    bar = Bar("柱状图示例", title_top="52%")
    bar.add("商家A", attr, v1, is_stack=True)
    bar.add("商家B", attr, v2, is_stack=True, legend_top="50%")
    heatmap.grid(bar.get_series(), grid_top="60%")
    heatmap.show_config()
    heatmap.render()