From 6b8c22d13c1ab210ea26dd0de0a0c98ef34967ac Mon Sep 17 00:00:00 2001 From: Peter Stockings Date: Wed, 8 Mar 2023 21:17:49 +1100 Subject: [PATCH] Fix error thrown when successfully submitting workout due to json->JSON and improve look of graphs --- app.py | 16 ++++++++++++---- templates/attemptv2.html | 5 +++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index f3c2a39..7fc2383 100644 --- a/app.py +++ b/app.py @@ -147,13 +147,21 @@ def workout(user_id, workout_id): y_values = [reading.rpm for reading in cadence_readings] fig, ax = plt.subplots() ax.plot(x_values, y_values) - ax.set_xlabel('Time') + # ax.set_xlabel('Time') ax.set_ylabel('Cadence (RPM)') - ax.set_title( - 'Cadence Readings for Workout {}'.format(workout_id)) + + # ax.set_title( + # 'Cadence Readings for Workout {}'.format(workout_id)) + # Hide X and Y axes label marks + ax.xaxis.set_tick_params(labelbottom=False) + # ax.yaxis.set_tick_params(labelleft=False) + # Hide X and Y axes tick marks + ax.set_xticks([]) + # ax.set_yticks([]) # Save the graph to a bytes buffer buffer = io.BytesIO() - plt.savefig(buffer, format='png') + plt.savefig(buffer, format='png', + transparent=True, bbox_inches='tight') buffer.seek(0) # Create a response object with the graph image response = make_response(buffer.getvalue()) diff --git a/templates/attemptv2.html b/templates/attemptv2.html index a6a5431..931d5da 100644 --- a/templates/attemptv2.html +++ b/templates/attemptv2.html @@ -48,6 +48,7 @@ + No image