merge with ray/carl
GuiGraphViewer: configure matplotlib to use GTK properly, add in error handling for graphing across a database with hands the player you've requested wasn't involved in. please see # todo note on that.
This commit is contained in:
		
							parent
							
								
									6e182831ac
								
							
						
					
					
						commit
						5903988e38
					
				|  | @ -23,6 +23,8 @@ import os | ||||||
| #import pokereval | #import pokereval | ||||||
| 
 | 
 | ||||||
| try: | try: | ||||||
|  | 	import matplotlib | ||||||
|  | 	matplotlib.use('GTK') | ||||||
| 	from matplotlib.figure import Figure | 	from matplotlib.figure import Figure | ||||||
| 	from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas | 	from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas | ||||||
| 	from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar | 	from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar | ||||||
|  | @ -90,18 +92,23 @@ class GuiGraphViewer (threading.Thread): | ||||||
| 	#end of def showClicked | 	#end of def showClicked | ||||||
| 
 | 
 | ||||||
| 	def getRingProfitGraph(self, name, site): | 	def getRingProfitGraph(self, name, site): | ||||||
|                 self.cursor.execute(self.sql.query['getRingWinningsAllGamesPlayerIdSite'], (name, site)) | 		self.cursor.execute(self.sql.query['getRingWinningsAllGamesPlayerIdSite'], (name, site)) | ||||||
|                 winnings = self.db.cursor.fetchall() | 		winnings = self.db.cursor.fetchall() | ||||||
| 
 | 
 | ||||||
|                 profit=range(len(winnings)) | 		profit=range(len(winnings)) | ||||||
|                 for i in profit: | 		for i in profit: | ||||||
|                         self.cursor.execute(self.sql.query['getRingProfitFromHandId'], (name, winnings[i][0], site)) | 				self.cursor.execute(self.sql.query['getRingProfitFromHandId'], (name, winnings[i][0], site)) | ||||||
|                         spent = self.db.cursor.fetchone() | 				spent = self.db.cursor.fetchone() | ||||||
|                         profit[i]=(i, winnings[i][1]-spent[0]) | 				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) | 		y=map(lambda x:float(x[1]), profit) | ||||||
|                 line = cumsum(y) | 		line = cumsum(y) | ||||||
|                 return line/100 | 		return line/100 | ||||||
|         #end of def getRingProfitGraph |         #end of def getRingProfitGraph | ||||||
| 
 | 
 | ||||||
| 	def __init__(self, db, settings, querylist, config, debug=True): | 	def __init__(self, db, settings, querylist, config, debug=True): | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user