Fix XStackBar legend: drop overlapping total text
The right-aligned total overlapped the last legend item and its byte formatting was meaningless for unitless segments. Legend now shows only the segment chips + percentages.
This commit is contained in:
1 parent
841dddcef6
commit
b361a35909
2 files changed
-6
No files matched your search
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 964 B |
@@ -1090,21 +1090,15 @@ class MonitorWidget(Widget):
|
||||
# Legend: color chip + "label 45%" flowing left to right,
|
||||
# wrapping to a second row when the width runs out.
|
||||
lx, ly = 6, bar_y + bar_h + 15
|
||||
line1 = True
|
||||
for label, value, color in segments:
|
||||
text = "%s %.0f%%" % (label, 100.0 * value / total)
|
||||
tw = _text_width(cr, self, text, size=10) + 16
|
||||
if lx + tw > self.width - 4 and lx > 6:
|
||||
lx = 6
|
||||
ly += 14
|
||||
line1 = False
|
||||
_box(cr, lx, ly - 8, 8, 8, color, color)
|
||||
_wtext(cr, self, text, lx + 12, ly, size=10, rgb=_TEXT)
|
||||
lx += tw
|
||||
if line1:
|
||||
_wtext(cr, self, "total %s" % _fmt_bytes(total),
|
||||
self.width - 6, bar_y + bar_h + 15, size=10,
|
||||
rgb=_DIM, align="right")
|
||||
|
||||
def _draw_vertical_bar(self, cr):
|
||||
frac = _range_frac(self)
|
||||
|
||||
Reference in new issue
Block a user