[hamster-applet] do not even attempt to draw if there is no data



commit d775e3229102b3ff9c65df1fa843aa9b9327c005
Author: Toms Bauģis <toms baugis gmail com>
Date:   Fri Nov 27 23:21:11 2009 +0000

    do not even attempt to draw if there is no data

 hamster/charting.py |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/hamster/charting.py b/hamster/charting.py
index ff45c0f..75a9616 100644
--- a/hamster/charting.py
+++ b/hamster/charting.py
@@ -238,9 +238,12 @@ class Chart(graphics.Area):
 
 class BarChart(Chart):
     def on_expose(self):
-        context = self.context
         Chart.on_expose(self)
-        
+
+        if not self.data:
+            return
+
+        context = self.context        
         # determine graph dimensions
         if self.show_stack_labels:
             legend_width = self.legend_width or self.longest_label(self.keys)
@@ -464,8 +467,12 @@ class BarChart(Chart):
 
 class HorizontalBarChart(Chart):
     def on_expose(self):
-        context = self.context
         Chart.on_expose(self)
+
+        if not self.data:
+            return
+
+        context = self.context
         rowcount, keys = len(self.keys), self.keys
         
         # push graph to the right, so it doesn't overlap



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