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
74b2b965
Commit
74b2b965
authored
Feb 25, 2015
by
LE GAC Renaud
Browse files
Improve error reporting to user.
parent
820d3594
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
controllers/report.py
controllers/report.py
+19
-18
No files found.
controllers/report.py
View file @
74b2b965
...
...
@@ -95,32 +95,32 @@ def graph_mpl():
# decode the graph configuration
kwargs
=
json
.
loads
(
graph
.
plot
)
except
(
TypeError
,
ValueError
)
as
e
:
return
INLINE_ALERT
%
(
"Error"
,
e
)
# extract keyword which are not arguments of the DataFrame.plot method
plt_cfg
=
Storage
()
for
k
in
PLT_KEYS
:
plt_cfg
[
k
]
=
kwargs
.
pop
(
k
,
None
)
# generate the plot using a specific set of columns
df
=
report
.
to_df
()
if
plt_cfg
.
index
:
ax
=
df
.
ix
[:,
plt_cfg
.
index
].
plot
(
**
kwargs
)
# generate a plot using all columns of the DataFrame
else
:
ax
=
df
.
T
.
plot
(
**
kwargs
)
# extract keyword which are not arguments of the DataFrame.plot method
plt_cfg
=
Storage
()
for
k
in
PLT_KEYS
:
plt_cfg
[
k
]
=
kwargs
.
pop
(
k
,
None
)
# generate the plot using a specific set of columns
df
=
report
.
to_df
()
if
plt_cfg
.
index
:
ax
=
df
.
ix
[:,
plt_cfg
.
index
].
plot
(
**
kwargs
)
# generate a plot using all columns of the DataFrame
else
:
ax
=
df
.
T
.
plot
(
**
kwargs
)
except
(
IndexError
,
TypeError
,
ValueError
)
as
e
:
return
INLINE_ALERT
%
(
"Error"
,
e
)
# activate minor ticks
ax
.
minorticks_on
()
# set x / y label(s)
if
plt_cfg
.
xlabel
:
ax
.
set_xlabel
(
plt_cfg
.
xlabel
)
ax
.
set_xlabel
(
plt_cfg
.
xlabel
,
x
=
1
,
horizontalalignment
=
'right'
)
if
plt_cfg
.
ylabel
:
ax
.
set_ylabel
(
plt_cfg
.
ylabel
)
ax
.
set_ylabel
(
plt_cfg
.
ylabel
,
y
=
1
,
horizontalalignment
=
'right'
)
# push legend on the top outside the plot
# from http://stackoverflow.com/questions/4700614/how-to-put-the-legend-out-of-the-plot
...
...
@@ -138,7 +138,8 @@ def graph_mpl():
fig
=
ax
.
get_figure
()
fig
.
savefig
(
fi
,
format
=
'svg'
)
fig
.
clear
()
matplotlib
.
pyplot
.
close
(
fig
)
data
=
fi
.
getvalue
()
fi
.
close
()
...
...
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