Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit 930a30dd authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Fix bugs in the graph method do_linechart, do_empty.

parent 005a7cf8
...@@ -55,7 +55,7 @@ def do_empty(db, selector, target=None): ...@@ -55,7 +55,7 @@ def do_empty(db, selector, target=None):
months = to_datetime(["%i-%02i" % (year, i) for i in xrange(1, 13)]) months = to_datetime(["%i-%02i" % (year, i) for i in xrange(1, 13)])
df = DataFrame([0]*12*nyear, index=months) df = DataFrame([0]*12*nyear, index=months)
ax = df.plot(legend=False, x_compat=True, ylim=(0, 100), ax=target) ax = df.plot(legend=False, x_compat=True, ax=target)
do_tick(ax) do_tick(ax)
return ax return ax
...@@ -124,7 +124,7 @@ def do_linechart(publications, selector, target=None): ...@@ -124,7 +124,7 @@ def do_linechart(publications, selector, target=None):
setrows = db(query) setrows = db(query)
if setrows.count() == 0: if setrows.count() == 0:
return do_empty(db, selector) return do_empty(db, selector, target=target)
count = publications.id.count() count = publications.id.count()
rows = setrows.select(publications.submitted, rows = setrows.select(publications.submitted,
...@@ -133,7 +133,7 @@ def do_linechart(publications, selector, target=None): ...@@ -133,7 +133,7 @@ def do_linechart(publications, selector, target=None):
orderby=group_by) orderby=group_by)
# build the list of data points # build the list of data points
data, y = [], 0. data, y, prev_year = [], 0., None
for row in rows: for row in rows:
submitted = row.publications.submitted submitted = row.publications.submitted
...@@ -145,15 +145,25 @@ def do_linechart(publications, selector, target=None): ...@@ -145,15 +145,25 @@ def do_linechart(publications, selector, target=None):
else: else:
y = row[count] y = row[count]
# a continous line when month axis is selected # a continuous line when month axis is selected
if is_month: if is_month:
data.append([submitted[:7], y]) data.append([submitted[:7], y])
# a step line for the year axis # a step line for the year axis
# fill properly holes between year
else: else:
year = int(submitted[:4]) year = int(submitted[:4])
data.append(["%i-06" % (year-1), y])
data.append(["%i-06" % year, y]) if prev_year is not None and prev_year + 1 != year:
for x in xrange(prev_year+1, year):
n = (y if is_cumu else 0.)
data.append(["%i-01-01" % x, n])
data.append(["%i-12-31" % x, n])
data.append(["%i-01-01" % year, y])
data.append(["%i-12-31" % year, y])
prev_year = year
# instantiate the dataframe # instantiate the dataframe
# the index is the time # the index is the time
......
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