Commit caa37e9e authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add a protection in the function do_empty against empty database.

parent 9cac7bd4
......@@ -6,6 +6,7 @@ import matplotlib
import re
from datetime import datetime
from gluon import current
from pandas import DataFrame, DatetimeIndex, to_datetime
from reporting_tools import repr_team_project
......@@ -38,7 +39,7 @@ def do_empty(db, selector, target=None):
year = int(year_start)
months = to_datetime(["%i-%02i" % (year, i) for i in xrange(1, 13)])
else:
elif year_start and year_end:
year_start = int(year_start)
year_end = int(year_end)
nyear = year_end - year_start + 1
......@@ -48,6 +49,11 @@ def do_empty(db, selector, target=None):
li.extend(["%i-%02i" % (year, i) for i in xrange(1, 13)])
months = to_datetime(li)
else:
nyear = 1
year = datetime.now().year
months = to_datetime(["%i-%02i" % (year, i) for i in xrange(1, 13)])
df = DataFrame([0]*12*nyear, index=months)
ax = df.plot(legend=False, x_compat=True, ylim=(0, 100), ax=target)
do_tick(ax)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment