[jToolkit-cvs] jToolkit/widgets chart.py,1.10,1.11
Brought to you by:
davidfraser,
friedelwolff
From: <dav...@us...> - 2004-02-10 09:00:56
|
Update of /cvsroot/jtoolkit/jToolkit/widgets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23855 Modified Files: chart.py Log Message: Added sensible sizing for our chart images Index: chart.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/widgets/chart.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** chart.py 10 Feb 2004 08:56:46 -0000 1.10 --- chart.py 10 Feb 2004 08:57:44 -0000 1.11 *************** *** 27,36 **** self.dpi = 50 - self.figure = new_figure_manager(1,(8,6),72) - self.options = {} self.content_type = 'image/png' widgets.PlainContents.__init__(self, []) self.getdata() def getdata(self): --- 27,36 ---- self.dpi = 50 self.options = {} self.content_type = 'image/png' widgets.PlainContents.__init__(self, []) self.getdata() + self.sizeimage() + self.figure = new_figure_manager(1,(self.im_width,self.im_height),self.dpi) def getdata(self): *************** *** 43,46 **** --- 43,51 ---- return '' + def sizeimage(self): + """Subclasses of this should implement this uniquely""" + self.im_width = 8 + self.im_height = 6 + def option(self, **args): # Save option values in the object's dictionary. *************** *** 84,90 **** chartdata = self.charttable.gettablerows(self.filter) 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] --- 89,95 ---- chartdata = self.charttable.gettablerows(self.filter) if self.xstorageformat == 'DATETIME': ! self.xdata = array([dates.formatdate(row[self.xcolumn],self.xdisplay) for row in chartdata]) else: ! self.xdata = array([str(row[self.xcolumn]) for row in chartdata]) self.ydata = [[row[ycolumn] for row in chartdata] for ycolumn in self.ycolumns] *************** *** 106,112 **** self.figure.get_current_axis().set_ylim([math.floor(ymin),math.ceil(ymax)]) #Set the x labels ! set(self.figure.get_current_axis(), 'xticks', arange(len(self.xdata))) ! set(self.figure.get_current_axis(), 'xticklabels', self.xdata) #Plot each dataset --- 111,121 ---- self.figure.get_current_axis().set_ylim([math.floor(ymin),math.ceil(ymax)]) + #Calculate number of x labels to use - 1 per self.im_width + numLabels = self.im_width-2 + sliceNum = len(self.xdata)/numLabels + #Set the x labels ! self.figure.get_current_axis().set_xticks(arange(len(self.xdata),step=sliceNum)) ! self.figure.get_current_axis().set_xticklabels(self.xdata[:1]+self.xdata[::sliceNum]+self.xdata[-1:],rotation='vertical') #Plot each dataset *************** *** 145,151 **** self.figure.get_current_axis().set_xlim([0,len(self.xdata)+1]) self.figure.get_current_axis().set_ylim([math.floor(ymin),math.ceil(ymax)]) ! set(self.figure.get_current_axis(),'xticks',arange(len(self.xdata))+0.25) ! set(self.figure.get_current_axis(),'xticklabels',self.xdata) self.figure.get_current_axis().bar(arange(len(self.xdata)),self.ydata[0],0.5,color=self.colours) --- 154,165 ---- self.figure.get_current_axis().set_xlim([0,len(self.xdata)+1]) self.figure.get_current_axis().set_ylim([math.floor(ymin),math.ceil(ymax)]) ! self.figure.get_current_axis().set_xticks(arange(len(self.xdata))+0.25) ! self.figure.get_current_axis().set_xticklabels(self.xdata,rotation='vertical') self.figure.get_current_axis().bar(arange(len(self.xdata)),self.ydata[0],0.5,color=self.colours) + def sizeimage(self): + self.im_width = len(self.xdata)*2 + 2 + self.im_height = 8 #This should take tagname length into account + + \ No newline at end of file |