Display liner formula for E1RM over time, and weekly/monthly progress in weight (this part doesnt work well, will probably remove)
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
|
||||
<title>Workout Tracker</title>
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,900&display=swap" rel="stylesheet" />
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="https://cdn.rawgit.com/dreampulse/computer-modern-web-font/master/fonts.css">
|
||||
<link type="text/css" rel="stylesheet" href="/static/css/tail.select.min.css">
|
||||
<script src="/static/js/tail.select.min.js"></script>
|
||||
<script src="/static/js/tailwindcss@3.2.4.js"></script>
|
||||
@@ -14,7 +16,6 @@
|
||||
<script src="/static/js/htmx.min.js" defer></script>
|
||||
<script src="/static/js/hyperscript.min.js" defer></script>
|
||||
<script src="/static/js/sweetalert2@11.js" defer></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -46,7 +46,12 @@
|
||||
<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">{{ title }}</h4>
|
||||
<h4 class="text-l font-semibold text-blue-400 text-center">{{ title }}</h4>
|
||||
<h2 class="text-xs font-semibold text-blue-200 mb-2 text-center" style='font-family: "Computer Modern Sans", sans-serif;'>
|
||||
{% if best_fit_formula %}
|
||||
y = {{ best_fit_formula.slope }}x {% if best_fit_formula.intercept != 0 %}+ {{ best_fit_formula.intercept }}{% endif %}, {{ best_fit_formula.kg_per_week }} kg/week, {{ best_fit_formula.kg_per_month }} kg/month
|
||||
{% endif %}
|
||||
</h2>
|
||||
<svg viewBox="0 0 {{ (vb_width + 2*margin) | int }} {{ (vb_height + 2*margin) | int }}" preserveAspectRatio="none">
|
||||
{% for plot in plots %}
|
||||
<g class="{{ plot.label }}" style="fill: {{ plot.color }}; stroke: {{ plot.color }};">
|
||||
|
||||
13
utils.py
13
utils.py
@@ -260,6 +260,8 @@ def get_exercise_graph_model(title, estimated_1rm, repetitions, weight, start_da
|
||||
relative_positions = [(date - min_date).days / total_span for date in start_dates]
|
||||
|
||||
best_fit_points = []
|
||||
best_fit_formula = {}
|
||||
|
||||
# trry catch LinAlgError
|
||||
try:
|
||||
# Convert relative positions and scaled estimated 1RM values to numpy arrays
|
||||
@@ -272,6 +274,16 @@ def get_exercise_graph_model(title, estimated_1rm, repetitions, weight, start_da
|
||||
# Generate points along the line of best fit
|
||||
y_best_fit = [m * xi + b for xi in x]
|
||||
best_fit_points = list(zip(y_best_fit, relative_positions))
|
||||
|
||||
# Convert the slope from scaled units per day to kg per day
|
||||
slope_kg_per_day = m * (max_e1rm - min_e1rm) / total_span
|
||||
|
||||
best_fit_formula = {
|
||||
'slope': round(m,1),
|
||||
'intercept': round(b,1),
|
||||
'kg_per_week': round(slope_kg_per_day * 7, 1), # Convert to kg/week
|
||||
'kg_per_month': round(slope_kg_per_day * 30, 1) # Convert to kg/month
|
||||
}
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -305,6 +317,7 @@ def get_exercise_graph_model(title, estimated_1rm, repetitions, weight, start_da
|
||||
'vb_height': vb_height,
|
||||
'plots': [repetitions, weight, estimated_1rm],
|
||||
'best_fit_points': best_fit_points,
|
||||
'best_fit_formula': best_fit_formula,
|
||||
'plot_labels': plot_labels
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user