Author: nextgens
Date: 2006-01-07 12:51:40 +0000 (Sat, 07 Jan 2006)
New Revision: 7796

Modified:
   trunk/apps/freeviz/histogram.py
Log:
added a new parameter to the histogram grapher

Modified: trunk/apps/freeviz/histogram.py
===================================================================
--- trunk/apps/freeviz/histogram.py     2006-01-07 10:35:45 UTC (rev 7795)
+++ trunk/apps/freeviz/histogram.py     2006-01-07 12:51:40 UTC (rev 7796)
@@ -1,5 +1,7 @@
 #!/usr/bin/env python

+precision=10
+
 try:
        import gdchart
        from math import floor
@@ -10,17 +12,18 @@

        links = histdata.get()
 except:
-       print "Blame sleon if his api is b0rk3d! :p(comment from sleon: why me 
why me?\nblame nextgens for missing libs!(as sysadmin)"
-       quit
+       pass

-histogram=[0,0,0,0,0,0,0,0,0,0]
+histogram=[]
+for x in range(0,precision):
+        histogram.append(0)
 number_of_connections=len(links)

 #print "They are "+str(number_of_connections)+" connections."

 for connection in links:
        
delta=float(connection[0].get("location"))-float(connection[1].get("location"))
-       index=int(floor(abs(delta*10)))
+       index=int(floor(abs(delta*precision)))
        histogram[index]=histogram[index]+1

 histogram_percents=[ (x*100)/number_of_connections for x in histogram ]
@@ -29,11 +32,14 @@
 x.width = 250
 x.height = 250
 x.xtitle = "Distance"
-x.ytitle = "Percentage"
+x.ytitle = "%"
 x.title = "Histogram of link location distances"
 x.ext_color = [ 0x055202 , 0x169310 , 0x298760 , 0x297987 , 0xc1d72b , 
0xd4f113 , 0xf18113 , 0xf13713 , 0xcf0000 , 0x000000 ]
 x.setData(histogram_percents)
-x.setLabels(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"])
+label=[]
+for column_name in range(0,precision):
+        label.append(str(column_name))
+x.setLabels(label)
 x.draw("/tmp/histogram.png")
 #print histogram
 #print histogram_percents


Reply via email to