changeset 454:fc3eebc799fe

fixed bug in empty values
author catherine@Drou
date Wed, 17 Feb 2010 00:02:03 -0500
parents da3317c8fbc0
children f664c32fcb3f
files sqlpython/plothandler.py
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/plothandler.py	Tue Feb 16 21:09:38 2010 -0500
+++ b/sqlpython/plothandler.py	Wed Feb 17 00:02:03 2010 -0500
@@ -1,11 +1,15 @@
 import shelve, pickle, datetime, sys, itertools
-from sqlpython import cx_Oracle
+from sqlpython import cx_Oracle, psycopg2
 shelvename = 'plot.shelve'
 
 try:
     import pylab
     class Plot(object):
-        plottable_types = (cx_Oracle and cx_Oracle.NUMBER, datetime.datetime)
+        plottable_types = [cx_Oracle and cx_Oracle.NUMBER, 
+                           datetime.datetime]
+        if psycopg2:
+            for val in psycopg2.NUMBER.values:
+                plottable_types.append(val)
         #TODO: add non-Oracle types
         def __init__(self):
             self.legends = []
@@ -64,6 +68,7 @@
             self.yplots.append(pylab.pie(self.yserieslists[0], labels=self.xticks or self.xvalues))
             self.legends = [self.legends[0]]
         def draw(self):
+            #import pdb; pdb.set_trace()
             if not self.yserieslists:
                 print 'At least one quantitative column needed to plot.'
                 return None
@@ -78,7 +83,7 @@
                 self.bar()
             pylab.xlabel(self.xlabel)
             pylab.title(self.title)
-            pylab.legend([p[0] for p in self.yplots], self.legends, shadow=True)
+            pylab.legend([p[0] for p in self.yplots], self.legends, shadow=True) #dies for psql on pies
             pylab.show()
             print 'You can edit this plot from the command prompt (outside sqlpython) by running'
             print "ipython -pylab -c 'import sqlpython.plothandler; sqlpython.plothandler.Plot().unshelve()'"