Commit de351d05 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update controller graphs and friends to extract citations plots into PDF.

parent cfc3102f
......@@ -35,6 +35,7 @@ def citations():
histogram)
from plugin_dbui import Selector
from reporting_tools import repr_team_project
mplstyle()
pd.set_option("display.width", None)
......@@ -145,7 +146,12 @@ def citations():
#
# rendering
#
return dict(fig1=fig1, fig2=fig2, fig3=fig3, fig4=fig4)
dct = dict(fig1=fig1,
fig2=fig2,
fig3=fig3,
fig4=fig4,
subtitle=repr_team_project(db, selector))
return dct
def dashboard():
......
......@@ -83,8 +83,7 @@ def estimator_versus_time(ts,
ax = grid[1]
ts.diff().plot(ax=ax,
grid=True,
linewidth=0,
marker="d", markerfacecolor="orange", markersize=8,
drawstyle="steps-mid",
ylim=(-0.01, None))
ax.minorticks_on()
......
......@@ -306,12 +306,15 @@ class Selector(object):
Field("id_teams", "reference teams", label="Team"),
Field("id_projects", "reference projects", label="Project"),
Field("id_authors_roles", "reference authors_roles", label="Role"),
Field("graphs", "string", default=plot_all, label="Graph"))
Field("graphs", "string", default=plot_all, label="Graph"),
Field("format", "string", default="html", label="Format"))
table.id_authors_roles.requires = IS_IN_DB(db, "authors_roles.role")
table.id_projects.requires = IS_IN_DB(db, "projects.project")
table.id_teams.requires = IS_IN_DB(db, "teams.team")
table.format.requires = IS_IN_SET(["html", "pdf"])
table.graphs.requires = IS_IN_SET([plot_all,
T(PLOT_PER_DOMAIN),
T(PLOT_PER_TEAM),
......
......@@ -419,7 +419,8 @@ class ViewportUi(object):
graph_citation_panel = to_panelWithUrlSelector(
virtdb.graph_citation_selector,
baseUrl=URL("graphs", "citations"))
baseUrl=URL("graphs", "citations"),
extField="format")
list_panel = to_panelWithUrlSelector(
virtdb.list_selector,
......
......@@ -31,7 +31,7 @@
}}
<h2 class="dbui-h2" style="margin-bottom: 0ex; font-variant: small-caps;">
1 General
1 General {{=subtitle}}
</h2>
<img src="data:image/svg+xml;base64,{{=data1}}" height=400>
......
{{
#--------------------------------------------------------------------------
#
# The python controller return matplotlib image(s)
#
#--------------------------------------------------------------------------
import base64
import io
import tempfile
from matplotlib.backends.backend_pdf import PdfPages
# save image into a PDF file
with tempfile.NamedTemporaryFile() as fi:
pdf = PdfPages(fi.name)
pdf.savefig(fig1)
pdf.savefig(fig2)
pdf.savefig(fig3)
pdf.savefig(fig4)
pdf.close()
fi.seek(0)
spdf = fi.read()
pass
# return the PDF to user
response.headers['Content-Type']='application/pdf'
response.body = io.StringIO()
s64 = base64.b64encode(spdf).decode("utf-8")
response.write(s64, escape=False)
}}
\ No newline at end of file
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