Commit 6e5452ff authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add the preferences dasboard_start_year.

parent ebef2c12
......@@ -7,6 +7,7 @@ import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
from gluon import current
from gluon.storage import Storage
from graph_tools import (FROM_TO,
LABELY_YEAR,
......@@ -23,6 +24,7 @@ def dashboard():
"""
current_year = request.now.year
dashboard_start = current.app.dashboard_start_year
selector = Storage()
selector.Graph_selectorCumulative = "true"
......@@ -39,7 +41,8 @@ def dashboard():
fig, (ax1, ax2) = plt.subplots(nrows=1, ncols=2, sharey=True)
# the number of publications per year except for the current year
min_year = "2009"
# the starting value is defined in the preferences of the application
min_year = ("" if dashboard_start is None else str(dashboard_start))
max_year = str(current_year - 1)
selector.Graph_selectorCumulative = "false"
......
......@@ -643,6 +643,7 @@
'Stacked Axis': 'Stacked Axis',
'stacked chart': 'stacked chart',
'Stacked Granularity': 'Stacked Granularity',
'Starting year for the dashboard': 'Année de début du tableau de bord',
'state': 'state',
'Statistics': 'Statistique',
'Status': 'Status',
......
......@@ -7,7 +7,7 @@ import pandas as pd
from gluon import current
from model_selector import MONTH_SUBMIT, YEAR_SUBMIT, YEAR_PUBLISH
from model_selector import MONTH_SUBMIT, YEAR_PUBLISH
from pandas import DataFrame, DatetimeIndex, to_datetime
from StringIO import StringIO
......@@ -217,13 +217,12 @@ def linechart(db, selector, target=None, title=None, xlabel=None, ylabel=None):
df.index = DatetimeIndex(df.index)
if df.size == 1:
kwargs = dict(kind="bar", color="white", edgecolor="blue", rot=0)
kwargs = dict(color="lavender", kind="bar", edgecolor="blue", rot=0)
else:
kwargs = dict(kind="line", rot=35, x_compat=True)
kwargs = dict(colormap="Pastel1", kind="line", rot=35, x_compat=True)
ax = df.plot(colormap="Pastel1",
grid=True,
ax = df.plot(grid=True,
legend=False,
ylim=(0, None),
ax=target,
......
# -*- coding: utf-8 -*-
""" NAME
fix_preference_0965 -- add dashboard_start_year
SYNOPSIS
fix_preference_0965 [options]
DESCRIPTION
In the limbra release 0.9.6.5, the preference dashboard_start_year
has been added.
This script add the this preference if it does not exist and with
its value to 2009
OPTIONS
EXAMPLE
> cd limbra/scripts
> run script -S limbra_cppm fix_preference_0965.py
AUTHOR
R. Le Gac -- May 2017
"""
if __name__ == "__main__":
import sys
from plugin_dbui import get_id
DEF = "Starting year for the dashboard"
PROPERTY = "dashboard_start_year"
VALUE = 2009
idrec = get_id(db.preferences, property=PROPERTY)
if idrec is None:
print "\n\tAdd the property", PROPERTY
di = {
"property": PROPERTY,
"value": VALUE,
"definition": T(DEF)}
db.preferences[0] = di
rep = raw_input("\nCommit database changes [y/N]: ")
if rep == 'y':
db.commit()
else:
print "\n\tProperty %s already defined. Exit.\n" % PROPERTY
# exit gently
sys.exit(0)
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