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
import matplotlib.pyplot as plt
from gluon import current
from import Storage
from graph_tools import (FROM_TO,
......@@ -23,6 +24,7 @@ def dashboard():
current_year =
dashboard_start =
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)
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",
ax = df.plot(grid=True,
ylim=(0, None),
# -*- coding: utf-8 -*-
""" NAME
fix_preference_0965 -- add dashboard_start_year
fix_preference_0965 [options]
In the limbra release, 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
> cd limbra/scripts
> run script -S limbra_cppm
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':
print "\n\tProperty %s already defined. Exit.\n" % PROPERTY
# exit gently
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