Exemple #1
0
def get_bar_chart(year, month):
    record, year, month = data_aggregation(year, month)
    record = MouthCost(record, year, month)
    title = '消费统计'
    if record:
        x, y = record.web_index_bar()
        title = '消费合计:{}元'.format(round(sum([float(i) for i in y[2][1]]), 2))
    else:
        x = ['无数据']
        y = []
    line = draw.draw_balance_line(xaxis=x, yaxis=y, title=title)
    return line.dump_options()
Exemple #2
0
def get_current_month_bar():
    """
    首页条形统计图
    :return: Bar
    """
    record, year, month = data_aggregation(default=True)
    record = MouthCost(record, year, month)
    x, y = record.web_index_bar()
    status, columns = record.to_table()
    markline = list(filter(lambda d: d['name'] == '日付上限',
                           status))[0]['balance']
    bar = draw.draw_balance_bar(xaxis=x, yaxis=y, markline=markline)
    return bar.dump_options()