Round person graph models to one decimal place to reduce svg size
This commit is contained in:
10
utils.py
10
utils.py
@@ -34,10 +34,10 @@ def get_exercise_graph_model(title, estimated_1rm, repetitions, weight, start_da
|
||||
vb_height *= 75 / vb_height # Scale to 75px height
|
||||
|
||||
# Use NumPy arrays for efficient scaling
|
||||
relative_positions = np.array([(date - min_date).days / total_span for date in start_dates])
|
||||
estimated_1rm_scaled = ((np.array(estimated_1rm) - min_e1rm) / e1rm_range) * vb_height
|
||||
repetitions_scaled = ((np.array(repetitions) - min_reps) / reps_range) * vb_height
|
||||
weight_scaled = ((np.array(weight) - min_weight) / weight_range) * vb_height
|
||||
relative_positions = np.round(np.array([(date - min_date).days / total_span for date in start_dates]), 1)
|
||||
estimated_1rm_scaled = np.round(((np.array(estimated_1rm) - min_e1rm) / e1rm_range) * vb_height, 1)
|
||||
repetitions_scaled = np.round(((np.array(repetitions) - min_reps) / reps_range) * vb_height, 1)
|
||||
weight_scaled = np.round(((np.array(weight) - min_weight) / weight_range) * vb_height, 1)
|
||||
|
||||
# Calculate slope and line of best fit
|
||||
slope_kg_per_day = e1rm_range / total_span
|
||||
@@ -57,7 +57,7 @@ def get_exercise_graph_model(title, estimated_1rm, repetitions, weight, start_da
|
||||
if len(np.unique(x_fit)) > degree:
|
||||
coeffs = np.polyfit(x_fit, y_fit, degree)
|
||||
poly_fit = np.poly1d(coeffs)
|
||||
y_best_fit = poly_fit(relative_positions)
|
||||
y_best_fit = np.round(poly_fit(relative_positions), 1)
|
||||
best_fit_points = list(zip(y_best_fit.tolist(), relative_positions.tolist()))
|
||||
else:
|
||||
best_fit_points = []
|
||||
|
||||
Reference in New Issue
Block a user