Fix crasher in Grapher if no hands returned.
Should alert user or at least draw something in right pane.
This commit is contained in:
parent
90803b297f
commit
3a1ddad58f
|
@ -83,7 +83,10 @@ class GuiGraphViewer (threading.Thread):
|
||||||
self.ax.set_xlabel("Hands", fontsize = 12)
|
self.ax.set_xlabel("Hands", fontsize = 12)
|
||||||
self.ax.set_ylabel("$", fontsize = 12)
|
self.ax.set_ylabel("$", fontsize = 12)
|
||||||
self.ax.grid(color='g', linestyle=':', linewidth=0.2)
|
self.ax.grid(color='g', linestyle=':', linewidth=0.2)
|
||||||
#This line will crash if no hands exist in the query.
|
if(line == None):
|
||||||
|
#TODO: Do something useful like alert user
|
||||||
|
print "No hands returned by graph query"
|
||||||
|
else:
|
||||||
text = "All Hands, " + sitename + str(name) + "\nProfit: $" + str(line[-1]) + "\nTotal Hands: " + str(len(line))
|
text = "All Hands, " + sitename + str(name) + "\nProfit: $" + str(line[-1]) + "\nTotal Hands: " + str(len(line))
|
||||||
|
|
||||||
self.ax.annotate(text,
|
self.ax.annotate(text,
|
||||||
|
@ -92,7 +95,6 @@ class GuiGraphViewer (threading.Thread):
|
||||||
horizontalalignment='left', verticalalignment='top',
|
horizontalalignment='left', verticalalignment='top',
|
||||||
fontsize=10)
|
fontsize=10)
|
||||||
|
|
||||||
|
|
||||||
#Draw plot
|
#Draw plot
|
||||||
self.ax.plot(line,)
|
self.ax.plot(line,)
|
||||||
|
|
||||||
|
@ -106,6 +108,9 @@ class GuiGraphViewer (threading.Thread):
|
||||||
#returns (HandId,Winnings,Costs,Profit)
|
#returns (HandId,Winnings,Costs,Profit)
|
||||||
winnings = self.db.cursor.fetchall()
|
winnings = self.db.cursor.fetchall()
|
||||||
|
|
||||||
|
if(winnings == ()):
|
||||||
|
return None
|
||||||
|
|
||||||
y=map(lambda x:float(x[3]), winnings)
|
y=map(lambda x:float(x[3]), winnings)
|
||||||
line = cumsum(y)
|
line = cumsum(y)
|
||||||
return line/100
|
return line/100
|
||||||
|
|
Loading…
Reference in New Issue
Block a user