[jToolkit-cvs] jToolkit/widgets chart.py,1.16,1.17
Brought to you by:
davidfraser,
friedelwolff
From: <dav...@us...> - 2004-02-10 09:12:13
|
Update of /cvsroot/jtoolkit/jToolkit/widgets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25878 Modified Files: chart.py Log Message: There are now a minimum of 6 and a maximum of 10 times on each chart (chosen by how well the number of times splits itself for each option, defaulting to 10) Index: chart.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/widgets/chart.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** chart.py 10 Feb 2004 09:08:21 -0000 1.16 --- chart.py 10 Feb 2004 09:09:01 -0000 1.17 *************** *** 115,132 **** 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 if not sliceNum: sliceNum = 1 currentxdata = self.xdata[:1] currentxpos = sliceNum ! while currentxpos < len(self.xdata): currentxdata.append(self.xdata[currentxpos]) currentxpos += sliceNum ! if currentxpos != len(self.xdata)+sliceNum-1: currentxdata.extend(self.xdata[-1:]) #Set the x labels ! self.figure.get_current_axis().set_xticks(arange(len(self.xdata),step=sliceNum)) self.figure.get_current_axis().set_xticklabels(currentxdata,rotation='vertical') --- 115,143 ---- self.figure.get_current_axis().set_ylim([math.floor(ymin),math.ceil(ymax)]) ! #Calculate number of x labels to use - between 6 and 10 ! #First see if anything divides nicely ! xDataLen = len(self.xdata) ! numLabels = None ! for testnum in range(5,10): ! if xDataLen % testnum == 0: ! numLabels = testnum+1 ! ! #Otherwise go for max ! if not numLabels: numLabels = 10 ! ! sliceNum = xDataLen / (numLabels-1) if not sliceNum: sliceNum = 1 + + print xDataLen, numLabels, sliceNum currentxdata = self.xdata[:1] currentxpos = sliceNum ! while currentxpos < xDataLen: currentxdata.append(self.xdata[currentxpos]) currentxpos += sliceNum ! if currentxpos != xDataLen+sliceNum-1: currentxdata.extend(self.xdata[-1:]) #Set the x labels ! self.figure.get_current_axis().set_xticks(arange(xDataLen,step=sliceNum)) self.figure.get_current_axis().set_xticklabels(currentxdata,rotation='vertical') |