Index: stamper/stamper.py
===================================================================
--- stamper/stamper.py	(revision 28)
+++ stamper/stamper.py	(revision 30)
@@ -4,5 +4,6 @@
 import pygal
 from datetime import datetime, date, timedelta
-from os.path import expanduser, exists
+from os.path import expanduser, exists, islink
+from os import symlink, remove
 from collections import OrderedDict
 
@@ -10,4 +11,5 @@
 STAMPS_FILE = expanduser('~/.workstamps.json')
 DATE_FORMAT = '%Y-%m-%d'
+TIME_FORMAT = '%H:%M:%S'
 DATETIME_FORMAT = '%Y-%m-%d %H:%M'
 HOURS_DAY = 8
@@ -128,4 +130,5 @@
         return filter_from, filter_to
 
+    @property
     def customers(self):
         customers = []
@@ -212,7 +215,52 @@
                                 stamp['action']]))
 
+    def graph_stamps(self, customer=None, stamp_filter=None):
+        """
+        Generate charts with information from the stamps
+        """
+        filter_from, filter_to = self.validate_filter(stamp_filter)
+        chart = pygal.Bar(title='Work hours per day',
+                          range=(0, HOURS_DAY),
+                          x_title='Days',
+                          y_title='Work hours',
+                          x_label_rotation=45)
+
+        details, totals, totals_customers = self.details(customer,
+                                                         filter_from,
+                                                         filter_to)
+        days = []
+        values = {}
+        for c in self.customers:
+            values[c] = []
+
+        found = []
+
+        for day in details:
+            for c in values:
+                seconds = totals_customers[day].get(c, 0)
+                if seconds and c not in found:
+                    found.append(c)
+                human = timedelta(seconds=seconds).__str__()
+                values[c].append({'value': seconds/60.00/60.00,
+                                  'label': day + ': ' + human})
+            days.append(day)
+        chart.x_labels = map(str, days)
+
+        if customer:
+            chart.add(customer, values[customer])
+        else:
+            for c in found:
+                chart.add(c, values[c])
+
+        chart_name = 'chart-%s.svg' % datetime.today().strftime(
+            '%Y-%m-%d_%H%M%S')
+        chart_symlink = 'chart-latest.svg'
+        chart.render_to_file('graphs/' + chart_name)
+        if islink('graphs/'+ chart_symlink):
+            remove('graphs/'+ chart_symlink)
+        symlink(chart_name, 'graphs/'+ chart_symlink)
+
     def show_stamps(self, customer=None, stamp_filter=None, verbose=False,
-        sum=False, graph=False):
-
+        sum=False):
         filter_from, filter_to = self.validate_filter(stamp_filter)
 
@@ -263,43 +311,2 @@
                     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')
