Commit 0301692a authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Merge branch '62-2.13.4' into 'master'

62 2.13.4

* Version working with web2py 2.13.4
* Improve the plotting of the dashboard
* Close #62 

See merge request !64
parents 6a79dd42 800a87e8
......@@ -4,8 +4,8 @@
import json
import re
from gluon.dal import smart_query
from plugin_dbui import inline_alert, Selector
from pydal.helpers.methods import smart_query
from reporting_tools import get_converter, repr_team_project
MSG_NO_METRIC = "Please select a metric...."
......
......@@ -45,7 +45,7 @@ def do_empty(db, selector, target=None):
dates = to_datetime(["%i-01-01" % year, "%i-12-31" % year])
df = DataFrame([0]*2, index=dates)
ax = df.plot(legend=False, x_compat=True, ax=target)
ax = df.plot(legend=False, grid=True, x_compat=True, ax=target)
do_tick(ax)
return ax
......@@ -157,6 +157,22 @@ def do_linechart(publications, selector, target=None):
prev_year = year
# always show the twelve months for a single year
# fill the hole with zero
if is_month:
year = selector.year_start
if year and not selector.year_end or \
year == selector.year_end and len(data) < 12:
for i in xrange(1, 13):
x, found = "%s-%02i" % (year, i), False
for tpl in data:
if x == tpl[0]:
found = True
break
if not found:
data.append([x, 0.])
# instantiate the dataframe
# the index is the time
df = DataFrame(data, columns=['time', 'count'])
......@@ -168,7 +184,7 @@ def do_linechart(publications, selector, target=None):
# instantiate the plot
# x_compat is required to have a nice x axis labelling in all cases
# target = axn when the target is specified
kwargs = dict(ax=target, legend=False, x_compat=True)
kwargs = dict(ax=target, grid=True, legend=False, x_compat=True)
# NOTE
# 151103 pandas 0.15.2 / matplotlib 1.3.1
......@@ -313,6 +329,7 @@ def do_stackedchart(publications, selector, graph, target=None):
kwargs = dict(kind='bar', width=1., linewidth=0)
ax = df.plot(colormap="Pastel1",
grid=True,
stacked=True,
ylim=(0, None),
ax=target,
......
......@@ -9,8 +9,8 @@ from list_postprocessing import (clean,
highlight_my_authors,
highlight_my_speaker,
remove_undef)
from gluon.dal import smart_query
from gluon.storage import Storage
from pydal.helpers.methods import smart_query
def format_publication(template, record, funcs=[]):
......@@ -101,16 +101,15 @@ def get_sections(db, selector, row):
query = selector.query(publications)
if selector.year_start and not selector.year_end:
query = (query) & (publications.year == selector.year_start)
query &= publications.year == selector.year_start
elif selector.year_start and selector.year_end:
q_start = publications.year >= selector.year_start
q_end = publications.year <= selector.year_end
query = (query) & ((q_start) & (q_end))
query &= publications.year >= selector.year_start
query &= publications.year <= selector.year_end
if selector.author:
q_author = publications.authors_institute.contains(selector.author)
query = (query) & (q_author)
query &= q_author
# add to the query the directive coming from the section itself
# the publication category and dedicated conditions
......@@ -120,11 +119,11 @@ def get_sections(db, selector, row):
if codes:
q_cat = db.categories.code.belongs(codes)
query = (query) & (q_cat)
query &= q_cat
if section.conditions:
q_conditions = smart_query(publications, section.conditions)
query = (query) & (q_conditions)
query &= q_conditions
section.query = query
......
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