Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -182,35 +182,47 @@ def generate_pdf_report(dataframe, media_tempo_medio_turma, output_pdf_path):
|
|
182 |
pdf.add_table(dataframe)
|
183 |
|
184 |
# Gerar gráficos e adicionar ao PDF
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
top_students = dataframe.nlargest(5, 'Acertos Absolutos')
|
186 |
plt.figure(figsize=(10, 6))
|
187 |
-
plt.bar(top_students['Nome do Aluno'], top_students['Acertos Absolutos'], color='blue')
|
188 |
plt.xlabel('Nome do Aluno')
|
189 |
plt.ylabel('Acertos Absolutos')
|
190 |
plt.title('Top 5 Alunos - Acertos Absolutos')
|
191 |
plt.xticks(rotation=45, ha='right')
|
|
|
192 |
plt.tight_layout()
|
193 |
graph_path = 'top_5_acertos_absolutos.png'
|
194 |
plt.savefig(graph_path)
|
195 |
pdf.add_image(graph_path)
|
196 |
|
197 |
plt.figure(figsize=(10, 6))
|
198 |
-
plt.bar(top_students['Nome do Aluno'], top_students['Média de Acertos'].str.rstrip('%').astype('float'), color='green')
|
199 |
plt.xlabel('Nome do Aluno')
|
200 |
plt.ylabel('Percentual de Acertos (%)')
|
201 |
plt.title('Top 5 Alunos - Percentual de Acertos')
|
202 |
plt.xticks(rotation=45, ha='right')
|
|
|
203 |
plt.tight_layout()
|
204 |
graph_path = 'top_5_percentual_acertos.png'
|
205 |
plt.savefig(graph_path)
|
206 |
pdf.add_image(graph_path)
|
207 |
|
208 |
plt.figure(figsize=(10, 6))
|
209 |
-
plt.bar(top_students['Nome do Aluno'], top_students['Tarefas Completadas'], color='red')
|
210 |
plt.xlabel('Nome do Aluno')
|
211 |
plt.ylabel('Tarefas Completadas')
|
212 |
plt.title('Top 5 Alunos - Tarefas Completadas')
|
213 |
plt.xticks(rotation=45, ha='right')
|
|
|
214 |
plt.tight_layout()
|
215 |
graph_path = 'top_5_tarefas_completadas.png'
|
216 |
plt.savefig(graph_path)
|
@@ -278,3 +290,4 @@ with gr.Blocks() as interface:
|
|
278 |
generate_btn.click(fn=wrapper, inputs=[html_file, excel_files], outputs=[output_html, download_html_btn, download_pdf_btn])
|
279 |
|
280 |
interface.launch()
|
|
|
|
182 |
pdf.add_table(dataframe)
|
183 |
|
184 |
# Gerar gráficos e adicionar ao PDF
|
185 |
+
def add_bar_labels(ax):
|
186 |
+
for bar in ax.patches:
|
187 |
+
height = bar.get_height()
|
188 |
+
ax.annotate(f'{height}',
|
189 |
+
xy=(bar.get_x() + bar.get_width() / 2, height),
|
190 |
+
xytext=(0, 3), # 3 points vertical offset
|
191 |
+
textcoords="offset points",
|
192 |
+
ha='center', va='bottom')
|
193 |
+
|
194 |
top_students = dataframe.nlargest(5, 'Acertos Absolutos')
|
195 |
plt.figure(figsize=(10, 6))
|
196 |
+
ax = plt.bar(top_students['Nome do Aluno'], top_students['Acertos Absolutos'], color='blue')
|
197 |
plt.xlabel('Nome do Aluno')
|
198 |
plt.ylabel('Acertos Absolutos')
|
199 |
plt.title('Top 5 Alunos - Acertos Absolutos')
|
200 |
plt.xticks(rotation=45, ha='right')
|
201 |
+
add_bar_labels(ax)
|
202 |
plt.tight_layout()
|
203 |
graph_path = 'top_5_acertos_absolutos.png'
|
204 |
plt.savefig(graph_path)
|
205 |
pdf.add_image(graph_path)
|
206 |
|
207 |
plt.figure(figsize=(10, 6))
|
208 |
+
ax = plt.bar(top_students['Nome do Aluno'], top_students['Média de Acertos'].str.rstrip('%').astype('float'), color='green')
|
209 |
plt.xlabel('Nome do Aluno')
|
210 |
plt.ylabel('Percentual de Acertos (%)')
|
211 |
plt.title('Top 5 Alunos - Percentual de Acertos')
|
212 |
plt.xticks(rotation=45, ha='right')
|
213 |
+
add_bar_labels(ax)
|
214 |
plt.tight_layout()
|
215 |
graph_path = 'top_5_percentual_acertos.png'
|
216 |
plt.savefig(graph_path)
|
217 |
pdf.add_image(graph_path)
|
218 |
|
219 |
plt.figure(figsize=(10, 6))
|
220 |
+
ax = plt.bar(top_students['Nome do Aluno'], top_students['Tarefas Completadas'], color='red')
|
221 |
plt.xlabel('Nome do Aluno')
|
222 |
plt.ylabel('Tarefas Completadas')
|
223 |
plt.title('Top 5 Alunos - Tarefas Completadas')
|
224 |
plt.xticks(rotation=45, ha='right')
|
225 |
+
add_bar_labels(ax)
|
226 |
plt.tight_layout()
|
227 |
graph_path = 'top_5_tarefas_completadas.png'
|
228 |
plt.savefig(graph_path)
|
|
|
290 |
generate_btn.click(fn=wrapper, inputs=[html_file, excel_files], outputs=[output_html, download_html_btn, download_pdf_btn])
|
291 |
|
292 |
interface.launch()
|
293 |
+
|