[billreminder] Make chart widget handle empty sets of data.
- From: Og B. Maciel <ogmaciel src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [billreminder] Make chart widget handle empty sets of data.
- Date: Wed, 25 Nov 2009 14:04:25 +0000 (UTC)
commit fcf43af70944b467b79c2c822ac6814b5a4508cf
Author: Og B. Maciel <ogmaciel gnome org>
Date: Wed Nov 25 09:04:14 2009 -0500
Make chart widget handle empty sets of data.
src/gui/maindialog.py | 22 ++++++++++++----------
src/gui/widgets/chartwidget.py | 7 ++++++-
2 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/src/gui/maindialog.py b/src/gui/maindialog.py
index 076cf16..2fcea7d 100644
--- a/src/gui/maindialog.py
+++ b/src/gui/maindialog.py
@@ -304,16 +304,18 @@ class MainDialog:
self.btnUnpaid.set_is_important(True)
def _populate_chart(self, status, start, end):
- chartdata = []
- records = self.actions.get_monthly_totals(start, end)
- #records = []
- #for rec in records:
- # chartdata.append([field for field in rec])
- #if chartdata:
- print records
- if records:
- records = [(c,float(t)) for c,t in records]
- self.chart.plot(records)
+
+ records = []
+
+ try:
+ records = self.actions.get_monthly_totals(start, end)
+ # Chart widget takes data in format (('CategoryName', amount),)
+ records = [(c if c else 'None',float(t)) for c,t in records]
+ except Exception, e:
+ print "%s - %s" % (records, str(e))
+ pass
+
+ self.chart.plot(records)
def _populate_menubar(self):
# Create a UIManager instance
diff --git a/src/gui/widgets/chartwidget.py b/src/gui/widgets/chartwidget.py
index d55a578..2505051 100644
--- a/src/gui/widgets/chartwidget.py
+++ b/src/gui/widgets/chartwidget.py
@@ -20,7 +20,12 @@ class ChartWidget(gtk.HBox):
"""
Populates chart with data passed in.
"""
- pass
+
+ # Clear the image widget if there is no data passed.
+ if not data:
+ self.chart.clear()
+ return
+
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 400, 200)
dataSet = (
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]