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
limbra
limbra
Commits
534b4bef
Commit
534b4bef
authored
Dec 13, 2015
by
LE GAC Renaud
Browse files
Add the base64 string encoding for pdf and png graphic files.
parent
4ff4859e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
controllers/graphs.py
controllers/graphs.py
+7
-1
No files found.
controllers/graphs.py
View file @
534b4bef
...
...
@@ -2,6 +2,7 @@
""" Controllers for building graphs using pandas library
"""
import
base64
import
matplotlib
matplotlib
.
use
(
'Agg'
)
import
matplotlib.pyplot
as
plt
...
...
@@ -90,4 +91,9 @@ def index():
extension
=
request
.
extension
fmt
=
"svg"
if
extension
==
"html"
else
extension
return
dict
(
data
=
savefig
(
ax
.
get_figure
(),
fmt
))
# base64 string encoding
data
=
savefig
(
ax
.
get_figure
(),
fmt
)
if
fmt
in
(
"pdf"
,
"png"
):
data
=
base64
.
b64encode
(
data
)
return
dict
(
data
=
data
)
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