vrsb has proposed merging lp:~shepilov555/openobject-client/chart-error-fix 
into lp:openobject-client.

Requested reviews:
  OpenERP sa GTK client R&D (openerp-dev-gtk)
Related bugs:
  #607692 Windows gtk client crashes on charts drawing
  https://bugs.launchpad.net/bugs/607692


Fixed a bug with bar charts(see bugreport related). I use more safe way of 
drawing legend.
Merge that please for my company not to rebuild client on each release :)
-- 
https://code.launchpad.net/~shepilov555/openobject-client/chart-error-fix/+merge/31925
Your team OpenERP sa GTK client R&D is requested to review the proposed merge 
of lp:~shepilov555/openobject-client/chart-error-fix into lp:openobject-client.
=== modified file 'bin/tinygraph/__init__.py'
--- bin/tinygraph/__init__.py	2010-01-12 09:24:17 +0000
+++ bin/tinygraph/__init__.py	2010-08-06 04:14:40 +0000
@@ -95,6 +95,7 @@
             subplot.yaxis.grid(True,'major',linestyle='-',color='gray')
 
         colors = choice_colors(max(n,len(axis_group)))
+        legeng_added = False
         for i in range(n):
             datas = data_axis[i]
             ind = map(lambda x: x+width*i*overlap+((1.0-overlap)*n*width)/4, xrange(len(keys)))
@@ -107,22 +108,28 @@
                     color = colors[y]
                 else:
                     color = colors[i]
-                if orientation=='horizontal':
-                    aa = subplot.barh(ind, tuple(value), width, left=yoff, color=color, edgecolor="#333333")[0]
+                if not legeng_added:
+                    if orientation=='horizontal':
+                          aa = subplot.barh(ind, tuple(value), width, left=yoff, color=color, edgecolor="#333333", label=axis_group[y])[0]
+                    else:
+                          aa = subplot.bar(ind, tuple(value), width, bottom=yoff, color=color, edgecolor="#333333", label=axis_group[y])[0]
                 else:
-                    aa = subplot.bar(ind, tuple(value), width, bottom=yoff, color=color, edgecolor="#333333")[0]
+                    if orientation=='horizontal':
+                          aa = subplot.barh(ind, tuple(value), width, left=yoff, color=color, edgecolor="#333333")[0]
+                    else:
+                          aa = subplot.bar(ind, tuple(value), width, bottom=yoff, color=color, edgecolor="#333333")[0]
                 gvalue2.append(aa)
                 for j in range(len(yoff)):
                     yoff[j]+=value[j]
             gvalue.append(aa)
-
+            legeng_added = True
         if True:
             if len(axis_group)>1:
                 axis_group = map(lambda x: x.split('/')[-1], axis_group)
-                subplot.legend(gvalue2,axis_group,shadow=True,loc='best',prop = font_property)
+                subplot.legend(shadow=True,loc='best',prop = font_property)
             else:
                 t1 = [ axis_data[x]['string'] for x in axis[1:]]
-                subplot.legend(gvalue,t1,shadow=True,loc='best',prop = font_property)
+                subplot.legend(shadow=True,loc='best',prop = font_property)
         else:
             pass
     else:

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to