示例#1
0
文件: views.py 项目: grand-zz/epos
def table_base(sql, titl) -> Table:
    table = Table()
    # engine = create_engine("mysql+pymysql://root:root@localhost:3306/mysql", encoding="utf-8")
    # session = sessionmaker(bind=engine)
    # df = pd.read_sql(sql, engine)
    # rows=df.values.tolist()
    # headers=df.columns.tolist()
    with SQLPoll() as db:
        students = db.fetch_all(sql, None)
    headers = []
    for student in students:
        headers = list(student.keys())
        break
    c = []
    rows = []
    for student in students:
        c = list(student.values())
        rows += [c]
    if len(rows) == 0:
        headers = ['记录', '数量']
        rows = [['无', 0]]
    table.add(
        headers,
        rows).set_global_opts(title_opts=opts.ComponentTitleOpts(title=titl))
    return table
示例#2
0
def table_base() -> Table:
    table = Table()
    heardes = [
        "课题名称", "课题编号", "年份", "负责人", "负责单位", "课题类型", "领域", "课题方向", "关键词", "URL"
    ]
    res_file = "..\\000LocalData\\caict_k\\research_subject_intergrate.csv"
    res_file_read = open(res_file, 'r', encoding='utf-8')
    res_list = []
    temp_list = []
    res_name_list = []
    for line in res_file_read.readlines():
        line = line.strip().split("|")
        if line[1] not in res_name_list:
            temp_list.append(line[0])
            temp_list.append(line[1].replace("--", "-", 10))
            temp_list.append(line[2])
            temp_list.append(line[3])
            temp_list.append(line[4])
            temp_list.append(line[5])
            temp_list.append(line[6])
            temp_list.append(line[7])
            temp_list.append(line[8])
            temp_list.append(line[10])
            # print(temp_list)
            res_list.append(temp_list)
            temp_list = []
            res_name_list.append(line[1])
    table.add(heardes, res_list).set_global_opts(
        title_opts=opts.ComponentTitleOpts(title="院软课题知识数据表(2010-2019)"))
    return table
示例#3
0
def table_base(data) -> Table:
    table = Table()
    level = ['较低:0~3k', '一般:3k~5k', '中等:5k~8k', '较高:8k~12k', '优秀:12k以上']
    city = ['beijing', "shanghai", 'guang', 'shen', 'cheng']
    table.add(level, data[1]).set_global_opts(
        title_opts=opts.ComponentTitleOpts(title="表格", subtitle="城市"))
    return table
示例#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
示例#5
0
def table_traces(rows) -> Table:
    table = Table()
    headers = ["设备名", "MonkeyError", "条数"]
    table.add(
        headers,
        rows).set_global_opts(title_opts=ComponentTitleOpts(title="错误日志收集"))
    return table
示例#6
0
def table_base(header,row) -> Table:
    table = Table()
    headers = header
    rows = row
    table.add(headers, rows).set_global_opts(
        title_opts=opts.ComponentTitleOpts(title="Table")
    )
    return table
示例#7
0
def table_base(header,row) -> Table:
    table = Table(page_title='未完成项',js_host=r"D:\JGY\600-Data\004-auxiliary辅助文件\\")
    headers = header
    rows = row
    table.add(headers, rows).set_global_opts(
        title_opts=opts.ComponentTitleOpts(title="Table")
    )
    return table
示例#8
0
def _gen_table() -> Table:
    table = Table()

    headers = ["City name", "Area", "Population", "Annual Rainfall"]
    rows = [["Brisbane", 5905, 1857594, 1146.4],
            ["Perth", 5386, 1554769, 869.4]]
    table.add(headers, rows)
    return table
示例#9
0
def getGuanjian():
    data =  pd.DataFrame(pd.read_excel(excel_dir,))
    mean = data.mean()
    print(type(mean))
    table = (Table().add(headers=['关键维度满意度得分','平均分'],rows=[['质量满意度','4.254902'],['包装满意度','4.078431'],['物流速度满意度','3.803922'],['售后满意度','4.117647'],['价格满意度','4.058824'],['支付满意度','4.117647'],]))
    table.render(path='keyScore.html')
    table1 = (Table().add(headers=['关键维度满意度比例','达到满意'],rows=[['质量满意度','0.86'],['包装满意度','0.76'],['物流速度满意度','0.70'],['售后满意度','0.80'],['价格满意度','0.76'],['支付满意度','0.84'],]))
    table1.render(path='keyScale.html')
def test_table_base(fake_writer):
    table = Table()

    headers = ["City name", "Area", "Population", "Annual Rainfall"]
    rows = [["Brisbane", 5905, 1857594, 1146.4],
            ["Perth", 5386, 1554769, 869.4]]
    table.add(headers, rows).render()
    _, content = fake_writer.call_args[0]
    assert_in("fl-table", content)
示例#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
示例#12
0
def _create_table() -> 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],
    ]
    table.add(headers, rows)
    return table
示例#13
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
示例#14
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
示例#15
0
def table_base() -> Table:
    table = Table()

    headers = ["国家", "2012", "2013", "2014", "2015", "2016", "2017", "2018"]
    rows = [
        ["中国", 3.867, 4.158, 4.301, 3.953, 3.685, 4.107, 4.622],
    ]
    table.add(headers, rows).set_global_opts(
        title_opts=opts.ComponentTitleOpts(title="近年中国贸易总额/万亿美元"))
    return table
示例#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
示例#18
0
 def get_table_base(self, _data):
     '''
     plot geo-detail
     :param _data: gps对应的城市分布(dataframe)
     :return: 数据示例
     '''
     table = Table()
     headers = ["City name", "Number"]
     rows = _data
     table.add(headers, rows).set_global_opts(
         title_opts=opts.ComponentTitleOpts(title="Table-Details"))
     return table
示例#19
0
def table_base():
    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)
示例#20
0
def create_base_table(title, x_list, data_list):
    headers = [" "] + x_list
    rows = []
    for key in data_list.keys():
        #print(key)
        row = []
        row.append(key)
        for x in data_list[key]:
            row.append(x)
        #print(row)
        rows.append(row)
    table = Table()
    table.add(headers, rows)
    table.set_global_opts(
        title_opts=opts.ComponentTitleOpts(title=title)
    )
    src_path = "./test/"
    html_file_name = src_path + title + ".html"
    img_file_name = src_path + title + ".png"
    table.render(html_file_name)
    path_wkimg = r'C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe'  # 工具路径
    cfg = imgkit.config(wkhtmltoimage=path_wkimg)
    imgkit.from_file(html_file_name, img_file_name, config=cfg)
    #make_snapshot(snapshot, table.render(html_file_name), img_file_name)
    print(img_file_name+"生成完毕...")
示例#21
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
示例#22
0
def table_base(sql, titl) -> Table:
    # for arg in args:
    #     print(arg)
    table = Table()
    engine = create_engine(
        "mysql+pymysql://root:[email protected]:3306/mysql", encoding="utf-8")
    session = sessionmaker(bind=engine)
    df = pd.read_sql(sql, engine)
    rows = df.values.tolist()
    headers = df.columns.tolist()
    if len(rows) == 0:
        rows = [['无', 0]]
    table.add(
        headers,
        rows).set_global_opts(title_opts=opts.ComponentTitleOpts(title=titl))
    return table
示例#23
0
def image_info(root, path='image_info.html', show_original=False):
    """Show image visualize.
    
    Args:
        root: An image file root.
        path: result save a html file.
        show_original: whether show original image shape.
    Returns:
        A pyecharts polt object.
    """
    shape = read_image(root).shape
    info = PIL.Image.open(root).info
    width = '' if show_original else str(360)+'px'
    height = '' if show_original else str(int(360/shape[1]*shape[0]))+'px'
    image_charts = image_base(root, '', '', width, height)
    headers = ["Attribute", "Info"]
    rows = [['path', root],
            ['size', str(round(os.stat(root).st_size/1024/1024, 2))+'M'],
            ['shape', str(read_image(root).shape)],
            ['jfif', info['jfif']],
            ['jfif_version', info['jfif_version']],
            ['dpi', info['dpi']],
            ['jfif_unit', info['jfif_unit']],
            ['jfif_density', info['jfif_density']]
    ]
    table_charts = Table().add(headers, rows)
    page = Page(layout=Page.SimplePageLayout).add(*[image_charts, table_charts])
    return page.render(path)
           
           
示例#24
0
    def _plot_txt_time(self, stats, ax=None, **kwargs):
        """
        Outputs the statistics for various time frames.
        """
        returns = stats['returns']

        mly_ret = perf.aggregate_returns(returns, 'monthly')
        yly_ret = perf.aggregate_returns(returns, 'yearly')

        mly_pct = mly_ret[mly_ret >= 0].shape[0] / float(mly_ret.shape[0])
        mly_avg_win_pct = np.mean(mly_ret[mly_ret >= 0])
        mly_avg_loss_pct = np.mean(mly_ret[mly_ret < 0])
        mly_max_win_pct = np.max(mly_ret)
        mly_max_loss_pct = np.min(mly_ret)
        yly_pct = yly_ret[yly_ret >= 0].shape[0] / float(yly_ret.shape[0])
        yly_max_win_pct = np.max(yly_ret)
        yly_max_loss_pct = np.min(yly_ret)

        header = ["Performance", "Value"]
        rows = [["Winning Months %", "{:.0%}".format(mly_pct)],
                ["Average Winning Month %", "{:.2%}".format(mly_avg_win_pct)],
                ["Average Losing Month %", "{:.2%}".format(mly_avg_loss_pct)],
                ["Best Month %", "{:.2%}".format(mly_max_win_pct)],
                ["Worst Month %", "{:.2%}".format(mly_max_loss_pct)],
                ["Winning Years %", '{:.0%}'.format(yly_pct)],
                ["Best Year %", '{:.2%}'.format(yly_max_win_pct)],
                ["Worst Year %", '{:.2%}'.format(yly_max_loss_pct)]]

        table = (Table().add(header, rows).set_global_opts(
            title_opts=opts.ComponentTitleOpts(title="Time")))
        return table
示例#25
0
    def table(self):

        table = Table()
        headers = ["项目", "数值", "开始时间", "结束时间"]
        rows = [
            ["最终收益", "{:.2f}%".format(self.endassets*100),"",""],
            ["交易次数", "{}".format(len(self.tradings)),"",""],
            ["平均收益", "{:.2f}%".format(self.averageassets*100),"",""],
            ["开仓次数", "{}".format(self.openpositions),"",""],
            ["清仓次数", "{}".format(self.clearance),"",""],
            ["手续费", "{:.2f}".format(self.data["scomm"].sum()+self.data["bcomm"].sum()),"",""],
            ["最大收益", "{:.2f}%".format(self.maxassets["value"]*100),self.maxassets["begin"],self.maxassets["end"]],
            ["最大回撤", "{:.2f}%".format(self.minassets["value"]*100),self.minassets["begin"],self.minassets["end"]],
        ]
        table.add(headers, rows)
        return table
示例#26
0
	def plot_portfolio(self):
		# 持仓
		total_value = glovar.context.portfolio.total_value	
		if len(glovar.context.value_history)==0:			
			day_return = total_value/glovar.context.portfolio.starting_cash-1
		else:
			day_return = total_value/glovar.context.value_history[-1][-1]-1

		headers = ['股票代码','股票名称','持仓数量','开仓时间','收益率','资金占比']
		rows = []
		value_count = 0
		for security in glovar.context.portfolio.positions.index:
			position = glovar.context.portfolio.positions.loc[security,:]
			if security in self.stock_info.index.values:
				name = self.stock_info.loc[security, 'display_name']
			else:
				name = security[:-5]
			position_amount = position.amount
			position_value = position.value
			profit = (position.price-position.avg_cost)*position.amount*position.multiplier*position.side
			init_time = position.init_time.strftime('%Y-%m-%d %H:%M:%S')
			returns_rate = '{:.2%}'.format(profit/position_value)
			position_rate = '{:.2%}'.format(position_value/total_value)
			value_count += position_value			
			rows.append([security, name, position_amount, init_time, returns_rate, position_rate])
		total_position_rate = value_count/total_value
		title = '{}  当天收益率:{:.2%} 总资产:{:.0f} 持仓比率:{:.2%} 持股{}只'.format(glovar.context.current_dt.strftime('%Y-%m-%d %H:%M:%S'), 
			day_return, total_value, total_position_rate, len(glovar.context.portfolio.positions))
		(
		    Table()
		    .add(headers, rows)
		    .set_global_opts(title_opts=opts.ComponentTitleOpts(title=title))
		    .render(sys.path[0]+'/img/{}/{}/持仓.html'.format(self.run_params['mode'], self.run_params['strategy']))
		)
示例#27
0
 def get_table_base(self, _df, title_name='数据分布', subtitle_name=''):
     '''
     数据详情表 (未使用)
     :param _df:
     :param title_name:
     :param subtitle_name:
     :return:
     '''
     _df = _df.reset_index()
     table = Table()
     headers = _df.columns.tolist()
     rows = _df.values
     table.add(
         headers, rows).set_global_opts(title_opts=opts.ComponentTitleOpts(
             title="Table-{}".format(title_name), subtitle=subtitle_name))
     return table
示例#28
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
示例#29
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
示例#30
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