Skip to content

Commit

Permalink
fixes rounding problemin StackedBarFace. Fixes etetoolkit#298
Browse files Browse the repository at this point in the history
  • Loading branch information
jhcepas committed Aug 8, 2017
1 parent 20d4be5 commit f66f996
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ete3/treeview/faces.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,9 +1290,8 @@ def paint(self, painter, option, widget):
x = 0
for i, p in enumerate(self.percents):
col = self.colors[i]
w = round((p * total_w) / 100.) # assuming p is between 0 and 100
painter.fillRect(x, 0, w, total_h, QColor(col))
painter.drawRect(x, 0, w, total_h)
w = (p * total_w) / 100. # assuming p is between 0 and 100
painter.fillRect(QRectF(x, 0, w, total_h), QColor(col))
x += w

class StackedBarFace(StaticItemFace):
Expand All @@ -1309,7 +1308,7 @@ def __init__(self, percents, width, height, colors=None, line_color=None):
Face.__init__(self)

if round(sum(percents)) > 100:
raise ValueError("BarItem: percentage values > 100")
raise ValueError("percentage values > 100")

self.type = "item"
self.item = None
Expand Down

0 comments on commit f66f996

Please sign in to comment.