Exemplo n.º 1
0
def create_tab():
    c = (Tab().add(_create_line(), 'Line').add(_create_table(), 'Table').add(
        word_cloud(),
        'WorldCloud').add(_create_timeline(),
                          'Timeline').add(_create_tree(),
                                          'Tree').add(_create_bar(), 'Bar'))
    return c
Exemplo n.º 2
0
def test_tab_render_notebook():
    tab = Tab()
    tab.add(_create_line(), "line-example")
    tab.add(_create_bar(), "bar-example")
    tab.add(_create_table(), "table-example")
    html = tab.render_notebook().__html__()
    assert_in("City name", html)
Exemplo n.º 3
0
    def take_snapshot(self, file_html=None, width="1400px", height="580px"):
        """获取快照

        :param file_html: str
            交易快照保存的 html 文件名
        :param width: str
            图表宽度
        :param height: str
            图表高度
        :return:
        """
        tab = Tab(page_title="{}@{}".format(self.symbol, self.end_dt.strftime("%Y-%m-%d %H:%M")))
        for freq in self.freqs:
            chart = self.kas[freq].to_echarts(width, height)
            tab.add(chart, freq)

        t1 = Table()
        t1.add(["名称", "数据"], [[k, v] for k, v in self.s.items()
                              if "_" in k and isinstance(v, str)
                              and v not in ["Other~其他", "向下", 'Y~是', 'N~否', '向上']])
        t1.set_global_opts(title_opts=ComponentTitleOpts(title="缠中说禅信号表", subtitle=""))
        tab.add(t1, "信号表")

        t2 = Table()
        ths_ = [["同花顺F10",  "http://basic.10jqka.com.cn/{}".format(self.symbol[:6])]]
        t2.add(["名称", "数据"], [[k, v] for k, v in self.s.items() if "_" not in k and v != "Other~其他"] + ths_)
        t2.set_global_opts(title_opts=ComponentTitleOpts(title="缠中说禅因子表", subtitle=""))
        tab.add(t2, "因子表")

        if file_html:
            tab.render(file_html)
        else:
            return tab
Exemplo n.º 4
0
def Create_Combine(my_data, ave_data, exam_name, class_data, grade_data, Exam_Number):
    #历次排名对比
    tab = Tab()
    The_Line = Create_Line(class_data, grade_data)
    tab.add(The_Line, "历次排名")
	
    tab.add(table_base(), "参考上线排名")
	
    #不同考试成绩概况
    t1 = Timeline()
    for i in range(len(ave_data)):
        Now_Bar = Create_Bar(my_data[i], ave_data[i], exam_name[i], "你的成绩", "平均分", False)
        t1.add(Now_Bar, exam_name[i])
    tab.add(t1, "近段考试概况")
    
    #历次单科成绩对比
    for i in range(0, 6):
        clone_score = []
        for j in range(len(exam_name)):
            clone_score.append(my_data[j][i])
        clone_rank = []
        for j in range(len(exam_name)):
            clone_rank.append(All_Exam_RANK[j][i])
            
        tab.add(Create_Line_RANK(clone_score, clone_rank), Subject[i]+"走势")
    tab.render(str(Exam_Number)+"的综合分析.html")
def get_figure_map_all():
    tab_map = Tab(page_title='Map-Area')
    tab_map.add(province_map(label_name='现有确诊', column_name='now_confirm'),
                'COVID-19疫情动态图(cn当日现有确诊病例数)')
    tab_map.add(province_map(label_name='累计确诊', column_name='confirm'),
                'COVID-19疫情动态图(cn当日累计确诊病例数)')
    return tab_map
Exemplo n.º 6
0
def multiple():
    tab = Tab()
    tab.add(geo.set_map("confirmed",200000), "confirmed")
    tab.add(geo.set_map("deaths",30000), "deaths")
    tab.add(geo.set_map("recovered",90000), "recovered")
    tab.render(output_path+"tab_base.html")
    return True
Exemplo n.º 7
0
    def take_snapshot(self, file_html=None, width="1400px", height="580px"):
        """获取快照

        :param file_html: str
            交易快照保存的 html 文件名
        :param width: str
            图表宽度
        :param height: str
            图表高度
        :return:
        """
        tab = Tab(page_title="{}@{}".format(
            self.symbol, self.end_dt.strftime("%Y-%m-%d %H:%M")))
        for freq in self.freqs:
            chart = ka_to_echarts(self.kas[freq], width, height)
            tab.add(chart, freq)

        t1 = Table()
        t1.add(["名称", "数据"], [[k, v] for k, v in self.s.items() if "_" in k])
        t1.set_global_opts(
            title_opts=ComponentTitleOpts(title="缠中说禅信号表", subtitle=""))
        tab.add(t1, "信号表")

        t2 = Table()
        t2.add(["名称", "数据"],
               [[k, v] for k, v in self.s.items() if "_" not in k])
        t2.set_global_opts(
            title_opts=ComponentTitleOpts(title="缠中说禅因子表", subtitle=""))
        tab.add(t2, "因子表")

        if file_html:
            tab.render(file_html)
        else:
            return tab
Exemplo n.º 8
0
def tab_fun():
    line = Line().add_xaxis(Faker.choose()).add_yaxis(
        series_name="xx1",
        y_axis=Faker.values(1, 100),
        itemstyle_opts=opts.ItemStyleOpts(color=Faker.rand_color())).add_yaxis(
            series_name="xx2",
            y_axis=Faker.values(1, 100),
            itemstyle_opts=opts.ItemStyleOpts(
                color=Faker.rand_color())).set_global_opts(
                    title_opts=opts.TitleOpts(title="主标题",
                                              subtitle="副标题",
                                              pos_left="10%"),
                    legend_opts=opts.LegendOpts(pos_left="40%"),
                )
    bar = Bar().add_xaxis(Faker.choose()).add_yaxis(
        series_name="柱1",
        y_axis=Faker.values(1, 100),
        itemstyle_opts=opts.ItemStyleOpts(color=Faker.rand_color())).add_yaxis(
            series_name="柱2",
            y_axis=Faker.values(1, 100),
            itemstyle_opts=opts.ItemStyleOpts(
                color=Faker.rand_color())).set_global_opts(
                    title_opts=opts.TitleOpts(title="主标题",
                                              subtitle="副标题",
                                              pos_left="10%"),
                    legend_opts=opts.LegendOpts(pos_left="40%"),
                )

    Tab().add(chart=line, tab_name="选项卡一").add(
        chart=bar, tab_name="选项卡二").render(path="D:/temp/pyecharts_tab.html")
Exemplo n.º 9
0
def tab_layout(list, title, name):
    tab = Tab()
    tab.add(death_histogram(list, title, name), "每日死亡")
    tab.add(CumulativeDeaths_histogram(list, title, name), '累计死亡')
    tab.add(Confirmed_histogram(list, title, name), "每日确诊")
    tab.add(CumulativeConfirmed_histogram(list, title, name), '累计确诊')
    tab.add(timeline(list, title, name), '时间轴')
    tab.render(name + '.html')
Exemplo n.º 10
0
def tab_base():
    tab = Tab()
    tab.add(bar_datazoom_slider(), "bar-example")
    tab.add(line_markpoint(), "line-example")
    tab.add(pie_rosetype(), "pie-example")
    tab.add(grid_mutil_yaxis(), "grid-example")
    tab.add(table_base(), "table-example")
    tab.render()
Exemplo n.º 11
0
def test_tab_base(fake_writer):
    bar = _create_bar()
    line = _create_line()
    tab = Tab().add(bar, "bar-example").add(line, "line-example")
    tab.render()
    _, content = fake_writer.call_args[0]
    assert_in("bar-example", content)
    assert_in("line-example", content)
Exemplo n.º 12
0
def local_expense():
    c = tab = Tab()
    tab.add(finacial_education_map(), "地方财政教育支出")

    result = Markup(c.render_embed())
    conculsion = "小结:从图1,我们可以看出,这10年间全国各地的财政教育支出都是随年增长的,从地图可以看出广东、四川、山东、河南是全国各省中颜色从浅变深变化最明显的4个城," \
                 "他们的财政教育支出增加的速度很快。"
    return render_template('select.html', result=result, conculsion=conculsion)
Exemplo n.º 13
0
def Tab_WordCloud():
    tab = Tab()
    tab.add(WordCloud_douban_high(), "豆瓣高分词云")
    tab.add(WordCloud_douban_low(), "豆瓣低分词云")
    tab.add(WordCloud_maoyan_high(), "猫眼高分词云")
    tab.add(WordCloud_maoyan_low(), "猫眼低分词云")

    return tab
Exemplo n.º 14
0
def effectScatter():
    c = tab = Tab()
    tab.add(effectscatter_symbol(), "四川特殊教育基本情况")
    result = Markup(c.render_embed())
    return render_template(
        'effectScatter.html',
        result=result,
    )
Exemplo n.º 15
0
def scatter():
    c = tab = Tab()
    tab.add(four_compare(), "四个不同省份对比")
    result = Markup(c.render_embed())
    return render_template(
        'scatter.html',
        result=result,
    )
Exemplo n.º 16
0
def main():
    r = requests.get('http://127.0.0.1:5000/blocktree')
    print(r)
    data = r.json()
    with open("new_all_blocks.json", 'w') as file:
        json.dump(data, file, indent=2)
    file_ = "new_all_blocks.json"
    with open(file_, 'r') as file:
        file_data = json.load(file)
        blocks = file_data.values()
        num = 1
        for block in blocks:
            block_info = block.values()
            for info in block_info:
                data = {}
                for i in info:
                    if info[i]["attribute"] == "head":
                        info[i]["attribute"] = 0
                    elif info[i]["attribute"] == "block":
                        info[i]["attribute"] = 1
                    elif info[i]["attribute"] == "NORMAL":
                        info[i]["attribute"] = 2
                    elif info[i]["attribute"] == "JUSTIFIED":
                        info[i]["attribute"] = 3
                    elif info[i]["attribute"] == "FINALIZED":
                        info[i]["attribute"] = 4
                    info[i].update({'x': 100, 'y': 800})
                data['block'] = list(info.values())
                with open("block%s.json" % num, 'w') as file1:
                    json.dump(data, file1, indent=2)
                num += 1
    tab = Tab()
    for i in range(1, num):
        same_height('block%s.json' % i)
        f = open('block%s.json' % i, )
        data = json.load(f)
        nodes, edges, text = plot(data)
        categories = [
            {
                "name": "head"
            },
            {
                "name": "block"
            },
            {
                "name": "normal checkpoint"
            },
            {
                "name": "justified checkpoint"
            },
            {
                "name": "finalized checkpoint"
            }]

        tab.add(datazoom_slider(nodes, edges, categories, text), "graph%s" % i)

    tab.render('blockchain.html')
Exemplo n.º 17
0
def rank_page2() -> Tab:
    tab=Tab()
    bar_base2015_1().render_notebook()
    bar_base2016_1().render_notebook()
    bar_base2017_1().render_notebook()
    tab.add(bar_base2015_1(), "2015年后二十排名")
    tab.add(bar_base2016_1(), "2016年后二十排名")
    tab.add(bar_base2017_1(), "2017年后二十排名")
    return tab
Exemplo n.º 18
0
def rank_page1() -> Tab:
    tab = Tab()
    bar_base2015().render_notebook()
    bar_base2016().render_notebook()
    bar_base2017().render_notebook()
    tab.add(bar_base2015(), "2015年前二十排名")
    tab.add(bar_base2016(), "2016年前二十排名")
    tab.add(bar_base2017(), "2017年前二十排名")
    return tab
Exemplo n.º 19
0
def detail():
    c = tab = Tab()
    tab.add(schools_map(), "各省特殊教育学校数")
    tab.add(teachers_map(), "特殊教育专任教师数")
    tab.add(recruit_students_map(), "各省特殊教育招生数")
    tab.add(all(), "教育支出与特殊教育在校学生详情")

    result = Markup(c.render_embed())
    return render_template('select.html', result=result)
Exemplo n.º 20
0
def visualize_layer(model, image, layer_name, layer_max_image=32, jupyter=True, path='visualize_layer.html'):
    """network layer visualize.
    
    Args:
        model: a tf.keras model or keras model.
        image: a image array with shape (1, height, width, channel), height and width are necessary.
        layer_name: a list of model layers name.
        layer_max_image: every layer max plot images.
        jupyter: if plot in jupyter, default True.
        path: if jupyter is False, result save a html file.
    Returns:
        A pyecharts polt object.
    """
    if tf.io.gfile.exists('feature_map'):
        tf.io.gfile.rmtree('feature_map')
    tf.io.gfile.makedirs('feature_map')
    if np.ndim(image)==2:
        image = tf.expand_dims(tf.expand_dims(image, 0), -1)
    elif np.ndim(image)==3:
        image = tf.expand_dims(image, 0)
    elif np.ndim(image)==4:
        pass
    else:
        raise ValueError('image shape is error.')
    temp_model = tf.keras.backend.function(model.inputs, [i.output for i in model.layers if i.name in layer_name])
    temp_name = [i.name for i in model.layers if i.name in layer_name]
    result = temp_model(image)
    images_per_row = 16
    count = 0
    name_dict = {}
    tab = Tab()
    for feature, name in zip(result, temp_name):
        if feature.ndim==4:
            if feature.shape[-1]==3:
                display_grid = feature[0,:,:,:].astype('uint8')
            else:
                n_features = feature.shape[-1] if feature.shape[-1]<layer_max_image else layer_max_image
                size = feature.shape[1]
                n_cols = int(np.ceil(n_features/images_per_row))
                display_grid = np.ones((size * n_cols, images_per_row * size),dtype=np.uint8)*255
                for col in range(n_cols):
                    for row in range(images_per_row):
                        if (col+1)*(row+1)>n_features:
                            break
                        channel_image = feature[0, :, :, col * images_per_row + row]
                        channel_image -= channel_image.mean()
                        channel_image /= channel_image.std()
                        channel_image *= 64
                        channel_image += 128
                        channel_image = np.clip(channel_image, 0, 255).astype('uint8')
                        display_grid[col * size : (col + 1) * size, row * size : (row + 1) * size] = channel_image
                display_grid = np.expand_dims(display_grid, axis=-1)
            name_dict[name] = f'./feature_map/{count}.png'
            ImageAug(display_grid).save_image(name_dict[name])
            tab.add(image_base(name_dict[name], name, 'shape='+str(feature.shape)), name)
        count += 1
    return tab.render_notebook() if jupyter else tab.render(path)
Exemplo n.º 21
0
def index():
    tab = Tab()
    tab.add(grid_horizontal(), "Income_Group")
    tab.add(grid_horizontal1(), "Region")
    tab.add(timeline_map(), "map")
    tab.add(bar_base(), "map-data story")
    tab.add(timeline_pie(), "pie")
    tab.add(line_base(), "pie-data story")
    return Markup(tab.render_embed())
Exemplo n.º 22
0
def Gather():
    tab = Tab(page_title='碧桂园集中式商业消费者满意度研究')
    CenterName, Data_Dict = CleanData()
    TabNames = list(Data_Dict.keys())
    for TabName in TabNames:
        Scores_List = Data_Dict[TabName]
        tab.add(Satisfaction(CenterName, TabName, Scores_List), TabName)
    tab.add(NPS(CenterName), 'NPS')
    tab.render('满意度得分展示Demo.html')
Exemplo n.º 23
0
def class_sum_by_subject() -> Tab:
    tab_ = Tab()
    tab_content = add_bar()

    for content, name in zip(tab_content, subjectName_list):
        print(content)
        print(name)
        tab_.add(content, name)

    return tab_
Exemplo n.º 24
0
def get_chart_tab_page(interval):
    bars = get_cdc_trx_counts_sums_bars(interval)

    tab = Tab()
    tab.add(bars[0], "cdc trx counts")
    tab.add(bars[1], "cdc trx sums")
    tab.add(get_supply_line(), "stable token supply")
    tab.add(get_average_collateral_rate_picture(), "average collateral rate")
    tab.add(get_cdc_count_pie(), "cdc count pie")
    return tab
Exemplo n.º 25
0
def tab_charts(chart_list, name_list):
    clen = len(chart_list)
    nlen = len(name_list)
    if clen == nlen:
        tab = Tab()
        for c in range(clen):
            tab.add(chart_list[c], name_list[c])
        return tab
    else:
        print('请确保图表代码与图表名称一一对应')
Exemplo n.º 26
0
def all():
    tab = Tab(page_title='2019年安全公众号统计分析')
    tab.add(article_day_3d(), "公众号文章发布统计")
    tab.add(account_article_num(), "公众号收录文章数")
    tab.add(article_day_num(), "每天收录文章统计")
    tab.add(article_hour_num(), "文章发布时间段")
    tab.add(article_source_url(), "公众号文章来源")
    tab.add(zhaopin(), "公众号文章主题统计")
    tab.add(article_author(), "勤奋作者")
    tab.render(path='./static/year/2019.html')
    print('生成完毕')
def get_figure_area_all():
    tab_area = Tab(page_title='Line-Area')
    tab_area.add(area_line(label_name='累计确诊', column_name='confirm'),
                 'COVID-19各地区病例趋势图(cn当日累计确诊病例)')
    tab_area.add(area_line(label_name='现有确诊', column_name='now_confirm'),
                 'COVID-19各地区病例趋势图(cn当日现有确诊病例)')
    tab_area.add(area_line(label_name='累计治愈', column_name='heal'),
                 'COVID-19各地区病例趋势图(cn当日累计治愈病例)')
    tab_area.add(area_line(label_name='累计死亡', column_name='dead'),
                 'COVID-19各地区病例趋势图(cn当日累计死亡病例)')
    return tab_area
Exemplo n.º 28
0
def test_tab_jshost_custom():
    from pyecharts.globals import CurrentConfig

    default_host = CurrentConfig.ONLINE_HOST
    custom_host = "http://localhost:8888/assets/"
    CurrentConfig.ONLINE_HOST = custom_host
    bar = _create_bar()
    line = _create_line()
    tab = Tab().add(bar, "bar").add(line, "line")
    assert_equal(tab.js_host, custom_host)
    CurrentConfig.ONLINE_HOST = default_host
Exemplo n.º 29
0
def draw_tab(GPU_NUMS=8, user_name='bobo'):

    gpu_summary_log = QN.query_GPU_status("nvidia-smi", user_name, "PID")
    info_columns = ['PID', 'GPU', 'PID_PATH', 'MEM']
    info_multi_tab = Tab()
    gpu_df = pd.DataFrame(gpu_summary_log, columns=info_columns)
    user_stat, gpu_util_stat, all_gpu_info = QN.status_analysis(gpu_df)
    gpu_util_table = table_base(info_columns, gpu_df.values.tolist())
    gpu_pie = P.draw_pie_chart(gpu_util_stat, GPU_count=GPU_NUMS)
    info_multi_tab.add(gpu_pie, "显卡资源利用情况")
    info_multi_tab.add(gpu_util_table, "显卡资源使用明细")
    return info_multi_tab
def depLevels():
    #获取处理后的依赖关系
    depList = getDepList()
    
    timestr = str(datetime.datetime.now())
    g1 = levelRender('request Levels Dependencies' + timestr, 'request', depList)
    g2 = levelRender('underscore Levels Dependencies' + timestr, 'underscore', depList)
    
    tab = Tab()
    tab.add(g1, "request")
    tab.add(g2, "underscore")
    tab.render("./templates/npmLevelDependencies.html")