WIP: Add graphs to workouts list view that show reps/weight, still need to refactor logic and dont display unless plot button(Need to add) is checked

This commit is contained in:
Peter Stockings
2023-04-02 22:36:30 +10:00
parent b128b7fb24
commit c4bd430eaf
3 changed files with 83 additions and 1 deletions

View File

@@ -162,9 +162,52 @@
</div>
</div>
</div>
</div>
</div>
<div class="mt-4 mb-4 w-full grid grid-cols-1 2xl:grid-cols-2 gap-4">
{% for exercise_graph in person['ExerciseGraphs'] %}
<div class="bg-white shadow rounded-lg p-4 sm:p-6 xl:p-8 ">
<div class="flex flex-col items-center">
<div class="flex-shrink-0">
<span class="text-2xl sm:text-3xl leading-none font-bold text-gray-900">{{
exercise_graph['ExerciseName'] }}</span>
</div>
<div id="e-{{ exercise_graph['ExerciseId'] }}"></div>
<script>
Plotly.newPlot("e-{{ exercise_graph['ExerciseId'] }}", [
{
x: {{ exercise_graph['StartDates'] | replace('"', "'") | safe }},
y: {{ exercise_graph['Repititions'] | replace('"', "'") | safe }},
name: 'Reps',
type: 'scatter'
},
{
x: {{ exercise_graph['StartDates'] | replace('"', "'") | safe }},
y: {{ exercise_graph['Weights'] | replace('"', "'") | safe }},
name: 'Weight',
yaxis: 'y2',
type: 'scatter'
}
],
{
title: '{{ exercise_graph['ExerciseName'] }}}',
margin: { t: 0 },
xaxis: { type: 'date', showgrid: false },
yaxis: { title: 'Reps', showgrid: false },
yaxis2: {
title: 'Weight',
overlaying: 'y',
side: 'right', showgrid: false
}
}, config);
</script>
</div>
</div>
{% endfor %}
</div>
{{ render_partial('partials/stats.html', stats=person['Stats']) }}
<button