Update of /cvsroot/jtoolkit/jToolkit/widgets
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12301
Modified Files:
chart.py
Log Message:
Added capability to specify a datetime value for x axis
Index: chart.py
===================================================================
RCS file: /cvsroot/jtoolkit/jToolkit/widgets/chart.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** chart.py 10 Feb 2004 07:29:41 -0000 1.2
--- chart.py 10 Feb 2004 07:50:11 -0000 1.3
***************
*** 6,9 ****
--- 6,10 ----
import cStringIO
from jToolkit.widgets import widgets
+ from jToolkit.data import dates
# Save the default option values in a module-level dictionary. This way, each
***************
*** 14,21 ****
# This class is just a container for option values.
class SimpleChart(widgets.PlainContents):
! def __init__(self, charttable, xcolumn, ycolumns):
self.charttable = charttable
self.xcolumn = xcolumn
self.ycolumns = ycolumns
if not hasattr(self, 'chartSize'):
self.chartSize = (250,250)
--- 15,24 ----
# This class is just a container for option values.
class SimpleChart(widgets.PlainContents):
! def __init__(self, charttable, xcolumn, ycolumns, xstorageformat='TEXT', xdisplay=''):
self.charttable = charttable
self.xcolumn = xcolumn
self.ycolumns = ycolumns
+ self.xstorageformat = xstorageformat
+ self.xdisplay = xdisplay
if not hasattr(self, 'chartSize'):
self.chartSize = (250,250)
***************
*** 28,32 ****
def getdata(self):
chartdata = self.charttable.gettablerows()
! self.xdata = [str(row[self.xcolumn]) for row in chartdata]
self.ydata = [[row[ycolumn] for row in chartdata] for ycolumn in self.ycolumns]
--- 31,38 ----
def getdata(self):
chartdata = self.charttable.gettablerows()
! if self.xstorageformat == 'DATETIME':
! self.xdata = [dates.formatdate(row[self.xcolumn],self.xdisplay) for row in chartdata]
! else:
! self.xdata = [str(row[self.xcolumn]) for row in chartdata]
self.ydata = [[row[ycolumn] for row in chartdata] for ycolumn in self.ycolumns]
|