Exemplo n.º 1
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.º 2
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.º 3
0
    def table_picture(self, headers, data):
        '''
        数据类似
         headers = ["City name", "Area", "Population", "Annual Rainfall"]
        data = [
        ["Brisbane", 5905, 1857594, 1146.4],
        ["Adelaide", 1295, 1158259, 600.5],
        ["Darwin", 112, 120900, 1714.7],
        ["Hobart", 1357, 205556, 619.5],
        ["Sydney", 2058, 4336374, 1214.8],
        ["Melbourne", 1566, 3806092, 646.9],
        ["Perth", 5386, 1554769, 869.4],
    ]
        '''
        headers = [""]
        data = [
            []
        ]
        table = (
            Table()
                .add(headers=headers, rows=data)
                .set_global_opts(title_opts=ComponentTitleOpts(title=self.title, subtitle=self.subtitle),
                                 # 添加logo
                                 graphic_opts=self.logo
                                 )
        )

        return table
Exemplo n.º 4
0
def get_eventtable(rows) -> Table:
    table = Table()
    headers = ["序号", "日期", "举报内容", "所属区域", "维度", "经度"]
    for r in rows:
        c = r[2]
        cl = list(c)
        n_w = len(cl)
        idx = int((n_w - 1) / 30)  #每40个词分行
        if (idx < 1):
            continue
        for i in range(idx):
            cl.insert((i + 1) * 30, "\n")
        r[2] = "".join(cl)
    '''                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    headers = ["City name", "Area", "Population", "Annual Rainfall"]
    rows = [
        ["Brisbane", 5905, 1857594, 1146.4],
        ["Adelaide", 1295, 1158259, 600.5],
        ["Darwin", 112, 120900, 1714.7],
        ["Hobart", 1357, 205556, 619.5],
        ["Sydney", 2058, 4336374, 1214.8],
        ["Melbourne", 1566, 3806092, 646.9],
        ["Perth", 5386, 1554769, 869.4],
        ["Sydney", 2058, 4336374, 1214.8],
        ["Melbourne", 1566, 3806092, 646.9],
        ["Perth", 5386, 1554769, 869.4],
    ]
    '''
    table.add(headers, rows).set_global_opts(
        title_opts=ComponentTitleOpts(title="详细举报数据"), )
    return table
Exemplo n.º 5
0
def drawTable(maintitle: str, subtitle: str, colname: list,
              row: list) -> Table:
    # 希望实现得功能:
    # 传入参数,返回一个table
    table = Table()
    tableHeader = colname
    tableRow = row
    tableTitle = maintitle
    tableSubTitle = subtitle
    table.add(tableHeader, tableRow)
    if tableSubTitle != '':
        table.set_global_opts(title_opts=ComponentTitleOpts(
            title=tableTitle, subtitle=tableSubTitle))
    else:
        table.set_global_opts(title_opts=ComponentTitleOpts(title=tableTitle))
    return table
Exemplo n.º 6
0
def statistics(model,
               jupyter=True,
               path='Model Summary.html',
               title="Model Summary",
               subtitle=""):
    t = pd.DataFrame([[
        i.name, i.__class__.__name__, i.trainable, i.dtype, i.input_shape,
        i.output_shape,
        i.count_params()
    ] for i in model.layers],
                     columns=[
                         'layer_custom_name', 'layer_object_name', 'trainable',
                         'dtype', 'input_shape', 'output_shape', 'params'
                     ])
    #     t['output_memory(MB)'] = (t.output_shape.map(lambda x:sum([reduce(lambda y,z:y*z, i[1:]) for i in x]) if isinstance(x, list) else reduce(lambda y,z:y*z, x[1:]))
    #                        *t.dtype.map(lambda x:int(re.sub("\D", "", x))))/32#/1024/1024)
    t.loc['total'] = ['', '', '', '', '', '', t.params.sum()]
    t['input_shape'] = t.input_shape.map(
        lambda x: str(x).replace("),(", "),\n(") if isinstance(x, list) else x)
    t = t.reset_index().rename(columns={'index': ''})
    for i in t.columns:
        t[i] = t[i].astype(str)
    table = Table()
    headers = t.columns.tolist()
    rows = t.values.tolist()
    table.add(headers, rows).set_global_opts(
        title_opts=ComponentTitleOpts(title=title, subtitle=subtitle))
    return table.render_notebook() if jupyter else table.render(path)
Exemplo n.º 7
0
def pic_wordcloud_user_jov_base():
    """
    It is used to respond to requests for chart parameters.

    Returns
    -------
    image : TYPE-IMAGE Component parameters
        DESCRIPTION:IMAGE html parameters.

    """
    
    # get picture
    from wordcloud import WordCloud
    
    data_pair = user_job_wordcloud_freq_query()
    wc = WordCloud(width=1200,height=800,min_font_size=10,max_font_size=100,font_step=2,max_words=10000,background_color="white")
    wc.generate_from_frequencies(dict(data_pair))
    wc.to_file(os.path.join(config.image_dir,"wordcloud_user_job.png"))
    # render picture
    from pyecharts.components import Image
    from pyecharts.options import ComponentTitleOpts
    
    image = Image()
    img_src = (os.path.join(config.image_dir,"wordcloud_user_job.png"))
    image.add(src=img_src,
              style_opts={"width": "1200px", "height": "800px", "style": "margin-top: 20px"},
              )
    image.set_global_opts(title_opts=ComponentTitleOpts(title="User Occupation Analysis"))
    return image
Exemplo n.º 8
0
def title(fea_data, style_data) -> Image:
    image = Image()
    sub_data = ""
    for i in range(len(fea_data)):
        if i == 0: sub_data += "关于面向用例:\n"
        if i == 3: sub_data += "\n关于提交次数:\n"
        if i == 4: sub_data += "\n关于时间偏好:\n"
        if i == 9: sub_data += "\n面对难题:\n"
        sub_data = sub_data + fea_data[i] + "\n"

    for i in range(len(style_data)):
        if i == 0: sub_data += "\n\n代码风格评估:\n"

        sub_data = sub_data + style_data[i]
        if i == 2: sub_data += "\n"
        if i == 3: sub_data += "\n"
        if i == 5: sub_data += "\n"

    # img_src = (
    #     "/Users/amanda/Data_Science/src/可视化/title.png"
    # )
    # image.add(
    #     src=img_src,
    #     style_opts={"width": "200px", "height": "200px", "style": "margin-top: 20px"},
    # )

    image.set_global_opts(title_opts=ComponentTitleOpts(title="PYTHON 用户数据分析",
                                                        subtitle=sub_data))

    return image
Exemplo n.º 9
0
def table_traces(rows) -> Table:
    table = Table()
    headers = ["设备名", "MonkeyError", "条数"]
    table.add(
        headers,
        rows).set_global_opts(title_opts=ComponentTitleOpts(title="错误日志收集"))
    return table
Exemplo n.º 10
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)

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

        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] + ths_)
        t2.set_global_opts(
            title_opts=ComponentTitleOpts(title="缠中说禅因子表", subtitle=""))
        tab.add(t2, "因子表")

        t3 = Table()
        t3.add(["本级别", "次级别"],
               [[k, v] for k, v in eval(self.s['级别映射']).items()])
        t3.set_global_opts(
            title_opts=ComponentTitleOpts(title="缠中说禅级别映射表", subtitle=""))
        tab.add(t3, "级别映射表")

        if file_html:
            tab.render(file_html)
        else:
            return tab
Exemplo n.º 11
0
def createtable(data):

    # 生成pyecharts表格
    table = Table()
    headers = ["提交日期","仪器编号","板号","样品数量","结果均值","ISD"]
    # rows = [[localtime(d.upload_time).strftime("%Y-%m-%d %X"), d.instrument, d.platenum, d.num, d.mean, d.sd] for d in data]
    rows = [[d.upload_time.strftime("%Y-%m-%d %X"), d.instrument, d.platenum, d.num, d.mean, d.sd] for d in data]
    table.add(headers, rows).set_global_opts(title_opts=ComponentTitleOpts(title="结果分布表"))
    return table
Exemplo n.º 12
0
def table_base(data):

    data = data.reset_index().round(4)
    headers = data.columns.tolist()
    cont = data.values.tolist()
    table = Table().add(headers, cont).set_global_opts(
        title_opts=ComponentTitleOpts(title="", subtitle="数据来源:WIND")
    ).set_global_opts()
    return table
Exemplo n.º 13
0
def table_base(rows) -> Table:
    table = Table()
    headers = [
        "设备名", "设备号", "CPU", "总内存", "分辨率", "网络", "耗时(s)", "CPU峰值", "CPU均值",
        "内存峰值", "内存均值", "fps峰值", "fps均值", "开始电量", "结束电量", "上行流量峰值", "上行流量均值",
        "下行流量峰值", "下行流量均值"
    ]
    table.add(headers, rows).set_global_opts(
        title_opts=ComponentTitleOpts(title="手机汇总信息", subtitle=""))
    return table
Exemplo n.º 14
0
def table_base():
    table = Table()

    headers = ["地区", "现有确诊", "累计死亡", "累计治愈"]

    rows = []
    table.add(headers, rows).set_global_opts(
        title_opts=ComponentTitleOpts(title="Table", subtitle="副标题"))
    # table.render("table_base.html")
    return rows
Exemplo n.º 15
0
def table_base(feeds: typing.List) -> Table:
    table = Table()
    headers = ['user', 'action', 'time', 'question', 'vote']
    rows = []
    for f in feeds:
        info = [f.user, f.action, f.time, f.question, f.vote]
        rows.append(info)
        table.add(headers, rows).set_global_opts(title_opts=ComponentTitleOpts(
            title='爬取一天的关注动态', subtitle='利用无头浏览器爬取异步加载页面'))
    table.render('zhihu.html')
    return table
Exemplo n.º 16
0
def table_base():
    table = Table()

    headers = ["地区", "确诊", "死亡", "治愈"]
    rows = [["湖北", 13522, 414, 397], ["浙江", 829, 0, 60], ["广东", 813, 0, 24],
            ["河南", 675, 2, 20], ["湖南", 593, 0, 29], ["安徽", 480, 0, 20],
            ["江西", 476, 2, 19], ["重庆", 344, 2, 9]]
    table.add(headers, rows).set_global_opts(
        title_opts=ComponentTitleOpts(title="Table", subtitle="副标题"))
    # table.render("table_base.html")
    return rows
def draw_Table(Time_List, Score_List, Comment_List, Update_List):
	#绘制评论表格
	table = Table()
	headers = ["评论时间", "情绪值", "评论内容"]
	rows = []
	for index in range(0,1800,30):
		temp = [Time_List[index], Score_List[index], Comment_List[index]]
		rows.append(temp)
	table.add(headers, rows).set_global_opts(
	    title_opts=ComponentTitleOpts(title="时间-情绪-评论文本 抽样数据")
	)
	return table
Exemplo n.º 18
0
def draw_cloud(url,user_id,title = "用户词云"):
    image = Image()

    image.add(
        src=url,
        style_opts={"width": "800px", "height": "500px", "style": "margin-left: 200px"},
    )
    image.set_global_opts(
        title_opts=ComponentTitleOpts(title=title, subtitle="用户:"+str(user_id))
    )

    return image
Exemplo n.º 19
0
 def table(self):
     table = Table()
     if self.obj.type == 0:
         headers = ["用户名", "Rank", "平均Rank", "通过率"]
         rows = [[self.obj.sid, self.obj.rank, self.obj.averageRank, self.obj.passingRate]]
         title = self.obj.sid + "个人信息"
     else:
         headers = ["单位", "Rank", "平均Rank"]
         rows = [[self.obj.sid, self.obj.rank, self.obj.averageRank]]
         title = self.obj.sid + "信息"
     table.add(headers, rows)
     table.set_global_opts(title_opts = ComponentTitleOpts(title = title, title_style = {"style": "text-align:center;font-weight:800;"}))
     self.page.add(table)
Exemplo n.º 20
0
    def table(self):
        print('正在生成表格...')
        table = Table()

        headers = ['商品详情', '商品价格', '商品销量', '店铺名称', '店铺地址', '商品图片', '商品主页']
        rows = [
            list(item.values())
            for item in self.collection.find({}, {'_id': 0})
        ]
        table.add(headers, rows)
        table.set_global_opts(title_opts=ComponentTitleOpts(title="数据源表格汇总"))
        table.render("表格汇总.html")
        print('生成完成')
Exemplo n.º 21
0
def image_base() -> Image:
    image = Image()

    img_src = (
        "https://user-images.githubusercontent.com/19553554/396123"
        "58-499eb2ae-4f91-11e8-8f56-179c4f0bf2df.png"
    )
    image.add(
        src=img_src,
        style_opts={"width": "200px", "height": "200px", "style": "margin-top: 20px"},
    ).set_global_opts(
        title_opts=ComponentTitleOpts(title="Image-基本示例", subtitle="我是副标题支持换行哦")
    )
    return image
Exemplo n.º 22
0
def table_base(Movies) -> Table:
    table = Table()
    headers = ['name', 'score', 'quote', 'cover_url', 'ranking', 'country']
    rows = []
    for movie in Movies:
        info = [
            movie.name, movie.score, movie.quote, movie.cover_url,
            movie.ranking, movie.country
        ]
        rows.append(info)
        table.add(headers, rows).set_global_opts(title_opts=ComponentTitleOpts(
            title='多页爬虫', subtitle='利用URL自动爬取下一页'))
    table.render('douban.html')
    return table
Exemplo n.º 23
0
    def totable(self,arrayAttr,arrayValue,name) -> Table:
        table = Table()

        headers =arrayAttr
        rows = [
            arrayValue
        ]
        table.add(headers, rows).set_global_opts(
            title_opts=ComponentTitleOpts(title="Table-Details", subtitle=name)
        )
        hname = str(time.time()) + '.html'

        table.render('./front-end/table/'+hname)
        return hname
Exemplo n.º 24
0
def table_base() -> Table:
    table = Table()

    headers = ["年份", "华南理工大学", "深圳大学", "广州工业大学", "五邑大学"]
    rows = [
        ["2019", 55, 169, 377, 745],
		["2018", 58, 167, 452, 792],
		["2017", 87, 432, 406, 768],
		["2016", 58, 470, 350, 800],
    ]
    table.add(headers, rows).set_global_opts(
        title_opts=ComponentTitleOpts(title="江门一中最低录取排名(不包含自主招生)")
    )
    return table
Exemplo n.º 25
0
    def take_snapshot(self, file_html, width="950px", height="480px"):
        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)

        headers = ["名称", "数据"]
        rows = [[k, v] for k, v in self.signals.items()]
        table = Table()
        table.add(headers, rows)
        table.set_global_opts(
            title_opts=ComponentTitleOpts(title="缠论信号", subtitle=""))
        tab.add(table, "信号表")
        tab.render(file_html)
Exemplo n.º 26
0
def table_base_zc() -> Table:
    header = []
    for i in rs_1.columns.tolist():
        header.append(i)

    show_list = []
    for row in rs_1.round(2).itertuples():
        show_list.append([row[1], row[2], row[3], row[4], row[5]])

    table_zc = Table()
    table_zc.add(header, show_list)
    table_zc.set_global_opts(
        title_opts=ComponentTitleOpts(title="资产负债表", subtitle="(单位:万元  粒度:季度  币种:HRMB)")
    )
    return table_zc
Exemplo n.º 27
0
def table_base() -> Table:
    table = Table()

    headers = ["City name", "Area", "Population", "Annual Rainfall"]
    rows = [
        ["Brisbane", 5905, 1857594, 1146.4],
        ["Adelaide", 1295, 1158259, 600.5],
        ["Darwin", 112, 120900, 1714.7],
        ["Hobart", 1357, 205556, 619.5],
        ["Sydney", 2058, 4336374, 1214.8],
        ["Melbourne", 1566, 3806092, 646.9],
        ["Perth", 5386, 1554769, 869.4],
    ]
    table.add(headers, rows).set_global_opts(title_opts=ComponentTitleOpts(
        title="Table-基本示例", subtitle="我是副标题支持换行哦"))
    return table
Exemplo n.º 28
0
def table_base_lr() -> Table:
    headers = []
    for i in rs_2.columns.tolist():
        headers.append(i)

    show_list = []
    for row in rs_2.round(2).itertuples():
        # print(row)
        show_list.append([row[1], row[2]])
    # print(numsList)

    table_lr = Table()
    table_lr.add(headers, show_list)
    table_lr.set_global_opts(
        title_opts=ComponentTitleOpts(title="利润表", subtitle="(单位:万元  粒度:季度  币种:HRMB)")
    )
    return table_lr
Exemplo n.º 29
0
def create_table(data, crawl_time):
    table = Table(page_title="TRHX丨CSDN 2020 博客之星实时数据")
    header = [
        "排名", "票数", "编号", "CSDN ID", "CSDN 昵称", "码龄", "文章数", "主页", "投票地址"
    ]
    rows = data
    table.add(header, rows)
    table.set_global_opts(title_opts=ComponentTitleOpts(
        title="CSDN 2020 博客之星实时数据排名(每10分钟更新一次)",
        subtitle='上次更新时间:' + str(crawl_time) +
        '&nbsp;&nbsp;&nbsp;&nbsp;数据来源:https://bss.csdn.net/m/topic/blog_star2020'
        +
        "\n\n作者:TRHX • 鲍勃&nbsp;&nbsp;&nbsp;&nbsp;为作者投上一票吧:https://bss.csdn.net/m/topic/blog_star2020/detail?username=qq_36759224",
        title_style={
            "style": "font-size:20px; font-weight:bold; text-align: center"
        },
        subtitle_style={"style": "font-size:15px; text-align: center"}))
    table.render("csdn_blog_star_2020.html")
Exemplo n.º 30
0
def table_base() -> Table:
    from pyecharts.options import ComponentTitleOpts

    table = Table()

    headers = [
        "Agent name", "Balance", "Signed Contracts", "Executed Contracts"
    ]
    rows = [
        ["Brisbane", 5905, 1857594, 1146.4],
        ["Adelaide", 1295, 1158259, 600.5],
        ["Darwin", 112, 120900, 1714.7],
        ["Hobart", 1357, 205556, 619.5],
        ["Sydney", 2058, 4336374, 1214.8],
        ["Melbourne", 1566, 3806092, 646.9],
        ["Perth", 5386, 1554769, 869.4],
    ]
    table.add(headers, rows).set_global_opts(title_opts=ComponentTitleOpts(
        title="", title_style={"style": "font-size: 18px; font-weight:bold;"}))
    return table