Add ability to select axis on graphs

This commit is contained in:
Peter Stockings
2023-04-03 14:43:36 +10:00
parent ca3eb48da6
commit d3dccad770

View File

@@ -196,12 +196,15 @@
<div id="e-{{ exercise_graph['ExerciseId'] }}"></div> <div id="e-{{ exercise_graph['ExerciseId'] }}"></div>
<script> <script>
Plotly.newPlot("e-{{ exercise_graph['ExerciseId'] }}", [ Plotly.newPlot("e-{{ exercise_graph['ExerciseId'] }}", [
{% if 'repetitions' in graph_axis %}
{ {
x: {{ exercise_graph['StartDates'] | replace('"', "'") | safe }}, x: {{ exercise_graph['StartDates'] | replace('"', "'") | safe }},
y: {{ exercise_graph['Repetitions'] | replace('"', "'") | safe }}, y: {{ exercise_graph['Repetitions'] | replace('"', "'") | safe }},
name: 'Reps', name: 'Reps',
type: 'scatter' type: 'scatter'
}, },
{% endif %}
{% if 'weight' in graph_axis %}
{ {
x: {{ exercise_graph['StartDates'] | replace('"', "'") | safe }}, x: {{ exercise_graph['StartDates'] | replace('"', "'") | safe }},
y: {{ exercise_graph['Weights'] | replace('"', "'") | safe }}, y: {{ exercise_graph['Weights'] | replace('"', "'") | safe }},
@@ -209,13 +212,16 @@
yaxis: 'y2', yaxis: 'y2',
type: 'scatter' type: 'scatter'
}, },
{% endif %}
{% if 'estimated1rm' in graph_axis %}
{ {
x: {{ exercise_graph['StartDates'] | replace('"', "'") | safe }}, x: {{ exercise_graph['StartDates'] | replace('"', "'") | safe }},
y: {{ exercise_graph['Estimated1RM'] | replace('"', "'") | safe }}, y: {{ exercise_graph['Estimated1RM'] | replace('"', "'") | safe }},
name: 'Estimated 1RM', name: 'Estimated 1RM',
yaxis: 'y3', yaxis: 'y3',
type: 'scatter' type: 'scatter'
} },
{% endif %}
], ],
{ {
margin: { t: 0 }, margin: { t: 0 },