[billreminder] Stopped annoying tracebacks messages about charting widget when empty.



commit 99a998968fb9cedb8813c8707b5abe7e314b82c5
Author: Og B. Maciel <ogmaciel gnome org>
Date:   Wed Nov 4 15:59:14 2009 -0500

    Stopped annoying tracebacks messages about charting widget when empty.

 src/gui/maindialog.py       |    4 ++--
 src/gui/widgets/charting.py |    7 ++++---
 2 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/src/gui/maindialog.py b/src/gui/maindialog.py
index a0db5ad..7f40310 100644
--- a/src/gui/maindialog.py
+++ b/src/gui/maindialog.py
@@ -307,8 +307,8 @@ class MainDialog:
         records = []
         for rec in records:
             chartdata.append([field for field in rec])
-        #if chartdata:
-        self.chart.plot(chartdata)
+        if chartdata:
+            self.chart.plot(chartdata)
 
     def _populate_menubar(self):
         # Create a UIManager instance
diff --git a/src/gui/widgets/charting.py b/src/gui/widgets/charting.py
index 90346a2..4b5e87e 100644
--- a/src/gui/widgets/charting.py
+++ b/src/gui/widgets/charting.py
@@ -138,7 +138,7 @@ class Chart(gtk.DrawingArea):
         if self.orient_vertical:
             # for simple bars figure, when there is way too much data for bars
             # and go to lines (yay!)
-            if len(self.data) == 0 or (widget.allocation.width / len(self.data)) > 30: #this is big enough
+            if not self.data or len(self.data) == 0 or (widget.allocation.width / len(self.data)) > 30: #this is big enough
                 self._bar_chart(context)
             else:
                 self._area_chart(context)
@@ -335,11 +335,12 @@ class Chart(gtk.DrawingArea):
 
     def _bar_chart(self, context):
         rect = self.get_allocation()  #x, y, width, height
-        data, records = self.data, len(self.data)
 
-        if not data:
+        if not self.data:
             return
 
+        data, records = self.data, len(self.data)
+
         # graph box dimensions
         graph_x = self.legend_width or 50 #give some space to scale labels
         graph_width = rect.width + rect.x - graph_x



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]