Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
tev
plugin_event
Commits
4bbb5a59
Commit
4bbb5a59
authored
Feb 25, 2015
by
LE GAC Renaud
Browse files
Add transpose and fix issue with index for graph.
parent
5ce5aa96
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
9 deletions
+21
-9
controllers/report.py
controllers/report.py
+14
-9
documentations/userguide/appendix_graph.rst
documentations/userguide/appendix_graph.rst
+7
-0
No files found.
controllers/report.py
View file @
4bbb5a59
...
...
@@ -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
try
:
# 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
else
:
ax
=
df
.
T
.
plot
(
**
kwargs
)
ax
=
df
.
ix
[:,:]
.
plot
(
**
kwargs
)
except
(
IndexError
,
TypeError
,
ValueError
)
as
e
:
return
INLINE_ALERT
%
(
"Error"
,
e
)
...
...
documentations/userguide/appendix_graph.rst
View file @
4bbb5a59
...
...
@@ -58,6 +58,10 @@ The basic keywords
``grid`` or ``legend``
deactivate grid (legend) when it is ``false``.
``colormap``
set the colormap indentify by its name.
Possible values in http://matplotlib.org/users/colormaps.html
``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
``tranpose``
boolean value to exchange *x* and *y*-axis.
Column addressing
-----------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment