Make svg graph more generic, and make line of best fit the last line rendered so its always on top

This commit is contained in:
Peter Stockings
2023-12-09 22:25:37 +11:00
parent 9145011819
commit c5e825f4df
2 changed files with 3 additions and 5 deletions

2
db.py
View File

@@ -535,7 +535,7 @@ class DataBase():
# Return exercise data with SVG dimensions and data points
return {
'exercise_name': topsets[0]['exercise_name'],
'title': topsets[0]['exercise_name'],
'vb_width': vb_width,
'vb_height': vb_height,
'plots': [repetitions, weight, estimated_1rm],

View File

@@ -46,9 +46,8 @@
<div id="popover-{{ unique_id }}" class="absolute t-0 r-0 hidden bg-white border border-gray-300 p-2 z-10">
<!-- Popover content will be dynamically inserted here -->
</div>
<h4 class="text-l font-semibold text-blue-400 mb-2 text-center">{{ exercise_name }}</h4>
<h4 class="text-l font-semibold text-blue-400 mb-2 text-center">{{ title }}</h4>
<svg viewBox="0 0 {{ (vb_width + 2*margin) | int }} {{ (vb_height + 2*margin) | int }}" preserveAspectRatio="none">
<path d="{{ path_best_fit(best_fit_points, vb_height) }}" stroke="gray" stroke-dasharray="2,1" fill="none" stroke-opacity="40%"/>
{% for plot in plots %}
<g class="{{ plot.label }}" style="fill: {{ plot.color }}; stroke: {{ plot.color }};">
{{ plot_line(plot.points, plot.color) }}
@@ -71,8 +70,7 @@
{% endfor %}
</g>
{% for pos in relative_positions %}
{% endfor %}
<path d="{{ path_best_fit(best_fit_points, vb_height) }}" stroke="gray" stroke-dasharray="2,1" fill="none" stroke-opacity="60%"/>
</svg>
<div class="flex justify-center pt-2">
{% for plot in plots %}