|
@@ -326,9 +326,14 @@ class FlowBarGraphWithVScale(urwid.Columns):
|
|
|
def set_bar_width(self, width):
|
|
|
self.graph.set_bar_width(width)
|
|
|
|
|
|
- def set_data(self, data, _max, labels=None):
|
|
|
+ def set_caption(self, text):
|
|
|
+ self.graph_caption.set_text(text)
|
|
|
+
|
|
|
+ def set_data(self, data, _max, vscale=None, caption=None):
|
|
|
+ labels = vscale or []
|
|
|
+ caption = caption or u''
|
|
|
top = self.height
|
|
|
- scale = (_max/top)*(top+1)
|
|
|
+ scale = _max*(top+1)/top
|
|
|
self.graph.set_data(data, scale)
|
|
|
if labels is None:
|
|
|
return
|
|
@@ -336,6 +341,7 @@ class FlowBarGraphWithVScale(urwid.Columns):
|
|
|
self.graph_vscale.set_scale([
|
|
|
((x*top)//scale, f'{x:>5.2f} ') for x in labels
|
|
|
], top)
|
|
|
+ self.graph_caption.set_text(caption)
|
|
|
|
|
|
def __init__(self, cols, rows, attr, *args, hatt=None, **kwargs):
|
|
|
self._total_width = cols
|
|
@@ -344,8 +350,12 @@ class FlowBarGraphWithVScale(urwid.Columns):
|
|
|
self._canvas_width = cols - 6
|
|
|
self.graph = FlowBarGraph(rows, attr, hatt=hatt)
|
|
|
self.graph_vscale = FlowGraphVScale(self.graph, [], 0)
|
|
|
+ self.graph_caption = urwid.Text(u'')
|
|
|
super().__init__([
|
|
|
(self._vscale_width, self.graph_vscale),
|
|
|
- (self._canvas_width, self.graph)
|
|
|
+ (self._canvas_width, urwid.Pile([
|
|
|
+ self.graph,
|
|
|
+ self.graph_caption
|
|
|
+ ]))
|
|
|
], *args, **kwargs)
|
|
|
|