def order7_total_chart(): # 最近七天订单确认成交金额 bar = Bar() bar.add_xaxis(list(d7_order_finish_total_dict.keys())) bar.add_yaxis("金额", list(d7_order_finish_total_dict.values()), itemstyle_opts=opts.ItemStyleOpts(color='orange')) bar.set_global_opts(title_opts=opts.TitleOpts(title="最近七天订单确认成交金额")) return bar.dump_options_with_quotes()
def workhour_get(): p = WorkhourInfo() # 获取最近的12月 df = p.df.dropna()[-12:] xdata = df['月份'].tolist() # fig = Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT)) fig = Bar() fig.add_xaxis(xdata) fig.add_yaxis('总投入', df['实际投入工时'].tolist(), label_opts=opts.LabelOpts(position='inside')) for v in df.columns[6:]: fig.add_yaxis(v, df[v].tolist(), stack='detail', is_selected=False, label_opts=opts.LabelOpts(is_show=False)) fig.set_global_opts( title_opts=opts.TitleOpts(title="最近12月工时投入"), tooltip_opts=opts.TooltipOpts(is_show=True, trigger="axis", axis_pointer_type="shadow"), yaxis_opts=opts.AxisOpts(name='工时'), ) #""" df['投入总工时比率'] = (df['投入总工时比率'] * 100).round(0) maxratio = df['投入总工时比率'].max() maxratio = 100 if maxratio <= 100 else maxratio ratio = df['投入总工时比率'].tolist() line = Line() line.add_xaxis(xdata) line.add_yaxis('投入工时率', ratio, yaxis_index=1) fig.extend_axis(yaxis=opts.AxisOpts(name="投入工时率", type_="value", min_=0, max_=maxratio, axislabel_opts=opts.LabelOpts( formatter="{value} %"))) fig.overlap(line) #""" return fig.dump_options_with_quotes()
def bar_chart(): # 柱状图 bar = Bar() x_y_axis = get_chart_data() bar.add_xaxis(x_y_axis[0]) for j in x_y_axis[1]: for key, value in j.items(): bar.add_yaxis(key, value, label_opts=opts.LabelOpts(is_show=False)) bar.set_series_opts(markpoint_opts=opts.MarkPointOpts(data=[ opts.MarkPointItem(type_="max", name="最大值"), opts.MarkPointItem(type_="min", name="最小值"), ]), ) bar.set_global_opts( title_opts=opts.TitleOpts( title="API耗时统计", subtitle="生产环境", pos_left="30%", title_textstyle_opts=opts.TextStyleOpts(color='red'), subtitle_textstyle_opts=opts.TextStyleOpts(color='blue')), xaxis_opts=opts.AxisOpts( name="运行时间", type_="category", boundary_gap=True, # axislabel_opts=opts.LabelOpts(rotate=15) ), yaxis_opts=opts.AxisOpts(name="实际的响应时间(单位:秒)", # min_=0, # max_=20 ), legend_opts=opts.LegendOpts(type_='scroll', selected_mode='multiple', pos_left='right', pos_top='10%', orient='vertical'), tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="line"), toolbox_opts=opts.ToolboxOpts(is_show=True, pos_left='right'), visualmap_opts=opts.VisualMapOpts(is_show=True, type_="size", min_=0, max_=20, range_text=["最大值", "最小值"]), datazoom_opts=[opts.DataZoomOpts(range_start=50, range_end=100)], ) bar = bar.dump_options_with_quotes() return bar