Index: stamper/stamper.py
===================================================================
--- stamper/stamper.py	(revision 22)
+++ stamper/stamper.py	(revision 23)
@@ -2,4 +2,5 @@
 import json
 import re
+import pygal
 from datetime import datetime, timedelta
 from os.path import expanduser, exists
@@ -110,4 +111,5 @@
         details = OrderedDict()
         totals = OrderedDict()
+        total_customer = OrderedDict()
         for stamp in self.stamps:
             if stamp['customer']:
@@ -125,8 +127,14 @@
                         'action': stamp['action']
                     })
+                customer = stamp['customer']
                 totals[start_day] += worktime
+                if start_day not in total_customer:
+                    total_customer[start_day] = {}
+                if customer not in total_customer[start_day]:
+                    total_customer[start_day][customer] = 0
+                total_customer[start_day][customer] += worktime
         for day in totals:
             totals[day] = str(timedelta(seconds=totals[day]))
-        return details, totals
+        return details, totals, total_customer
 
     def details_by_customer(self, customer):
@@ -153,5 +161,5 @@
 
     def show_stamps(self, customer=None, stamp_filter=None, verbose=False,
-        sum=False):
+        sum=False, graph=False):
         if stamp_filter:
             stamp_filter = self.validate_filter(stamp_filter)
@@ -161,5 +169,5 @@
         if customer:
             seconds=totals.get(customer, 0)
-            total = timedelta(seconds)
+            total = timedelta(seconds=totals.get(customer, 0))
             print(' %(customer)s: %(total)s' % {'customer': customer,
                                                 'total': total})
@@ -167,5 +175,5 @@
             for c in totals:
                 seconds=totals[c]
-                total = timedelta(seconds)
+                total = timedelta(seconds=totals[c])
                 print(' %(customer)s: %(total)s' % {'customer': c,
                                                     'total': total})
@@ -175,5 +183,5 @@
                 details, totals = self.details_by_customer(customer)
             else:
-                details, totals = self.details()
+                details, totals, total_customer = self.details()
             for day in details:
                 print('------ %(day)s ------' % {'day': day})
@@ -201,2 +209,43 @@
                     totalDays, remainingHr, remainingMin, HOURS_DAY
                 ))
+
+        if graph:
+            DAYS = 15
+            list_days = []
+            list_tot = []
+            stackedbar_chart = pygal.StackedBar()
+            stackedbar_chart.title = 'Worked time per day (in hours)'
+
+            if customer:
+                for day, tot in totals.iteritems():
+                    list_days.append(day)
+                    (h, m, s) = tot.split(':')
+                    tot_sec = int(h) * 3600 + int(m) * 60 + int(s)
+                    tot_h = float(tot_sec / float(60) / float(60))
+                    list_tot.append(tot_h)
+                stackedbar_chart.add(customer, list_tot)
+                stackedbar_chart.x_labels = map(str, list_days)
+                stackedbar_chart.render_to_file('graphs/chart-%s.svg' % customer )
+            else:
+                all_customers = self.customers()
+                total_per_customer = {}
+                details, totals, total_customer = self.details()
+                chars = 0
+                total_customer_reverse = total_customer.items()
+                total_customer_reverse.reverse()
+                for day, tot in total_customer_reverse:
+                    if chars < DAYS:
+                        list_days.append(day)
+                        for cust in self.customers():
+                            if cust not in tot:
+                                tot[cust] = 0
+                        for cus, time in tot.iteritems():
+                                tot_h = float(time / float(60) / float(60))
+                                if cus not in total_per_customer:
+                                    total_per_customer[cus] = []
+                                total_per_customer[cus].append(tot_h)
+                    chars = chars + 1
+                for ccus, ctime in total_per_customer.iteritems():
+                    stackedbar_chart.add(ccus, ctime)
+                stackedbar_chart.x_labels = map(str, list_days[-DAYS:])
+                stackedbar_chart.render_to_file('graphs/chart-all.svg')
