diff --git a/pyfpdb/GuiGraphViewer.py b/pyfpdb/GuiGraphViewer.py index 49a00d20..3505d1f7 100644 --- a/pyfpdb/GuiGraphViewer.py +++ b/pyfpdb/GuiGraphViewer.py @@ -23,6 +23,8 @@ import os #import pokereval try: + import matplotlib + matplotlib.use('GTK') from matplotlib.figure import Figure from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar @@ -90,18 +92,23 @@ class GuiGraphViewer (threading.Thread): #end of def showClicked def getRingProfitGraph(self, name, site): - self.cursor.execute(self.sql.query['getRingWinningsAllGamesPlayerIdSite'], (name, site)) - winnings = self.db.cursor.fetchall() + self.cursor.execute(self.sql.query['getRingWinningsAllGamesPlayerIdSite'], (name, site)) + winnings = self.db.cursor.fetchall() - profit=range(len(winnings)) - for i in profit: - self.cursor.execute(self.sql.query['getRingProfitFromHandId'], (name, winnings[i][0], site)) - spent = self.db.cursor.fetchone() - profit[i]=(i, winnings[i][1]-spent[0]) + profit=range(len(winnings)) + for i in profit: + self.cursor.execute(self.sql.query['getRingProfitFromHandId'], (name, winnings[i][0], site)) + spent = self.db.cursor.fetchone() + if not spent[0] == None: + profit[i]=(i, winnings[i][1]-spent[0]) + else: + profit[i] = (i, 0) + # todo: this probably adds in flat spots on your graph for hands you were not involved in (ie, observing, sitting out, etc) + # and has that counted in your hand totals. Someone needs to figure out the SQL for totally removing any hand you're not in from the equation entirely - y=map(lambda x:float(x[1]), profit) - line = cumsum(y) - return line/100 + y=map(lambda x:float(x[1]), profit) + line = cumsum(y) + return line/100 #end of def getRingProfitGraph def __init__(self, db, settings, querylist, config, debug=True):