|
@@ -187,12 +187,15 @@ class MerchantPainter(object):
|
|
|
def _fig_bar_funs(self):
|
|
|
def create():
|
|
|
fig = Figure(figsize=(19, 8))
|
|
|
- ax = fig.subplots()
|
|
|
- ax.set_title('sending order count monitor')
|
|
|
- ax.set(xlabel='merchant id', ylabel='count')
|
|
|
- return ax, fig
|
|
|
+ ax_count, ax_amount = fig.subplots(2, 1)
|
|
|
+ ax_count.set_title('sending order count monitor')
|
|
|
+ ax_count.set(xlabel='merchant id', ylabel='count')
|
|
|
|
|
|
- def flush(ax, fig, xticks=None, xlables=None, yticks=None, ylables=None):
|
|
|
+ ax_amount.set_title('sending order amount monitor')
|
|
|
+ ax_amount.set(xlabel='merchant id', ylabel='amount')
|
|
|
+ return ax_count, ax_amount, fig
|
|
|
+
|
|
|
+ def end(ax, xticks=None, xlables=None, yticks=None, ylables=None):
|
|
|
if xticks is not None:
|
|
|
ax.set_xticks(ticks=xticks)
|
|
|
if xlables is not None:
|
|
@@ -205,13 +208,14 @@ class MerchantPainter(object):
|
|
|
|
|
|
ax.legend()
|
|
|
ax.grid()
|
|
|
- fig.autofmt_xdate()
|
|
|
|
|
|
+ def flush(fig):
|
|
|
+ fig.autofmt_xdate()
|
|
|
buf = BytesIO()
|
|
|
fig.savefig(buf, format="png")
|
|
|
return buf
|
|
|
|
|
|
- return create, flush
|
|
|
+ return create, end,flush
|
|
|
|
|
|
def paint_refilling(self):
|
|
|
tuple_pathes = self._reader.many_tuple_path(self._days, self._mchids, self._card_types, self._spec)
|
|
@@ -220,8 +224,8 @@ class MerchantPainter(object):
|
|
|
return BytesIO()
|
|
|
|
|
|
day_stamp = self._days[0]
|
|
|
- fig_create, fig_flush = self._fig_bar_funs()
|
|
|
- ax, fig = fig_create()
|
|
|
+ fig_create, fig_end, fig_flush = self._fig_bar_funs()
|
|
|
+ ax_count, ax_amount, fig = fig_create()
|
|
|
|
|
|
lables = list()
|
|
|
datas = list()
|
|
@@ -232,11 +236,17 @@ class MerchantPainter(object):
|
|
|
send_count, submit_count, succ_count, fail_count, amounts, lack = ret
|
|
|
logger.debug("mchid=%d send=%d submit=%d succ=%d fail=%d",_mchid,send_count, submit_count, succ_count, fail_count)
|
|
|
|
|
|
- send_count, submit_count, succ_count, fail_count, amounts, lack = zip(*datas)
|
|
|
+ send_count, submit_count, succ_count, fail_count, submit_amount, succ_amount, fail_amount, send_amount, lack = zip(*datas)
|
|
|
+ self.draw_count(ax_count, lables, send_count, submit_count, succ_count, fail_count, fig_end)
|
|
|
+ self.draw_amount(ax_amount, lables, submit_amount, succ_amount, fail_amount, send_amount, lack, fig_end)
|
|
|
+
|
|
|
+ return fig_flush(fig)
|
|
|
+
|
|
|
+ def draw_count(self, ax, lables, send_count, submit_count, succ_count, fail_count, fig_end):
|
|
|
width = 0.24
|
|
|
x_asix = np.arange(len(lables))
|
|
|
|
|
|
- rect_send = ax.bar(x_asix - width * 0.5, list(send_count), width, label='send', align='center')
|
|
|
+ rect_send = ax.bar(x_asix - width * 0.5, list(send_count), width, label='sending', align='center')
|
|
|
rect_submit = ax.bar(x_asix - width * 1.5, list(submit_count), width, label='summit',align='center')
|
|
|
rect_succ = ax.bar(x_asix + width * 0.5, list(succ_count), width, label='succ',align='center')
|
|
|
rect_fail = ax.bar(x_asix + width * 1.5, list(fail_count), width, label='fail', align='center')
|
|
@@ -246,4 +256,22 @@ class MerchantPainter(object):
|
|
|
ax.bar_label(rect_succ, padding=0, rotation=270)
|
|
|
ax.bar_label(rect_fail, padding=0, rotation=270)
|
|
|
|
|
|
- return fig_flush(ax, fig, xticks=x_asix, xlables=lables)
|
|
|
+ fig_end(ax, xticks=x_asix, xlables=lables)
|
|
|
+ pass
|
|
|
+
|
|
|
+ def draw_amount(self, ax, lables, submit_amount, succ_amount, fail_amount, send_amount, lack, fig_end):
|
|
|
+ width = 0.24
|
|
|
+ x_asix = np.arange(len(lables))
|
|
|
+
|
|
|
+ rect_submit = ax.bar(x_asix - width * 1.5, list(submit_amount), width, label='summit',align='center')
|
|
|
+ rect_send = ax.bar(x_asix - width * 0.5, list(send_amount), width, label='sending', align='center')
|
|
|
+ rect_succ = ax.bar(x_asix + width * 0.5, list(succ_amount), width, label='succ',align='center')
|
|
|
+ rect_fail = ax.bar(x_asix + width * 1.5, list(fail_amount), width, label='fail', align='center')
|
|
|
+
|
|
|
+ ax.bar_label(rect_submit, padding=0, rotation=270)
|
|
|
+ ax.bar_label(rect_send, padding=0, rotation=270)
|
|
|
+ ax.bar_label(rect_succ, padding=0, rotation=270)
|
|
|
+ ax.bar_label(rect_fail, padding=0, rotation=270)
|
|
|
+
|
|
|
+ fig_end(ax, xticks=x_asix, xlables=lables)
|
|
|
+ pass
|