[hamster-applet] minor optimisation - do not replot if data is the same



commit ad73e204423e3cfc6ee623bb94453a552a1bb5dd
Author: Toms Bauģis <toms baugis gmail com>
Date:   Sun May 16 00:24:34 2010 +0100

    minor optimisation - do not replot if data is the same

 src/hamster/charting.py |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/src/hamster/charting.py b/src/hamster/charting.py
index a5b73fe..111e749 100644
--- a/src/hamster/charting.py
+++ b/src/hamster/charting.py
@@ -79,6 +79,7 @@ class Chart(graphics.Scene):
 
         self.bars = []
         self.labels = []
+        self.data = None
 
         self.max_width = max_bar_width
         self.legend_width = legend_width
@@ -130,6 +131,12 @@ class Chart(graphics.Scene):
 
 
     def plot(self, keys, data):
+        if data == self.data:
+            self.show()
+            self.redraw()
+            return
+        self.data = data
+
         bars = dict([(bar.key, bar.normalized) for bar in self.bars])
 
         max_val = float(max(data or [0]))
@@ -167,6 +174,8 @@ class Chart(graphics.Scene):
 
 
     def on_enter_frame(self, scene, context):
+        # adjust sizes and positions on redraw
+        
         self.find_colors()
 
         self.plot_area.y = 0



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