Commit 4bbb5a59 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add transpose and fix issue with index for graph.

parent 5ce5aa96
......@@ -17,7 +17,7 @@ from StringIO import StringIO
# A specific set of keys use to to tune matplotlib rendering
# These keys are in the plot configuration but are not arguments
# of the DataFrame.plot method
PLT_KEYS = ('index', 'xlabel', 'ylabel')
PLT_KEYS = ('index', 'transpose', 'xlabel', 'ylabel')
def graph_extjs():
......@@ -79,8 +79,8 @@ def graph_mpl():
msg = "No %s named %s" % (tablename, graph.report_name)
return INLINE_ALERT % ("Error", msg)
# instantiate the lists/metrics
# instantiate the lists/metrics
config = db[tablename][id]
if tablename == "lists":
......@@ -92,6 +92,8 @@ def graph_mpl():
elif tablename == "metrics2d":
report = Metric2D(config, selector)
df = report.to_df()
# decode the graph configuration
kwargs = json.loads(graph.plot)
......@@ -99,16 +101,19 @@ def graph_mpl():
plt_cfg = Storage()
for k in PLT_KEYS:
plt_cfg[k] = kwargs.pop(k, None)
# transpose
if plt_cfg.transpose:
df = df.T
# generate the plot using a specific set of columns
df = report.to_df()
if plt_cfg.index:
if plt_cfg.index and len(plt_cfg.index) <= len(df.columns):
ax = df.ix[:,plt_cfg.index].plot(**kwargs)
# generate a plot using all columns of the DataFrame
# generate the plot using all columns
ax = df.T.plot(**kwargs)
ax = df.ix[:,:].plot(**kwargs)
except (IndexError, TypeError, ValueError) as e:
return INLINE_ALERT % ("Error", e)
......@@ -58,6 +58,10 @@ The basic keywords
``grid`` or ``legend``
deactivate grid (legend) when it is ``false``.
set the colormap indentify by its name.
Possible values in
``xerr`` and ``yerr``.
set errors bars.
......@@ -77,7 +81,10 @@ The basic keywords
``xlabel``, ``ylabel``
set the label along the *x* and *y*-axis respectively
boolean value to exchange *x* and *y*-axis.
Column addressing
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