Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -1141,15 +1141,20 @@ class GraphGenerator:
|
||||
fig, ax = plt.subplots(figsize=(10, 2.5))
|
||||
|
||||
# Chart data and positions
|
||||
# Use normalized positions (0-100 scale) for uniform bar length
|
||||
categories = ["Very Slow", "Slow", "Average", "Fast", "Very Fast"]
|
||||
positions = [1500, 3000, 4500, 6000, 7500]
|
||||
indicator_pos = rmr_kcal
|
||||
highlight_end = rmr_kcal
|
||||
positions = [10, 30, 50, 70, 90] # Normalized positions on 0-100 scale
|
||||
|
||||
# Main Bar (Background)
|
||||
# Normalize the kcal value to 0-100 scale (assuming range 0-9000 kcal)
|
||||
max_kcal = 9000
|
||||
normalized_value = (rmr_kcal / max_kcal) * 100
|
||||
indicator_pos = normalized_value
|
||||
highlight_end = normalized_value
|
||||
|
||||
# Main Bar (Background) - using 0-100 scale
|
||||
main_bar = FancyBboxPatch(
|
||||
(0, 0.4),
|
||||
9000,
|
||||
100,
|
||||
0.2,
|
||||
boxstyle="round,pad=0,rounding_size=0.1",
|
||||
ec="none",
|
||||
@@ -1168,7 +1173,7 @@ class GraphGenerator:
|
||||
)
|
||||
ax.add_patch(highlight_bar)
|
||||
|
||||
# Text and Labels
|
||||
# Text and Labels (show actual kcal value)
|
||||
ax.text(
|
||||
highlight_end / 2,
|
||||
0.5,
|
||||
@@ -1192,7 +1197,7 @@ class GraphGenerator:
|
||||
|
||||
# Chart Styling
|
||||
ax.set_title("Slow vs Fast Metabolism", fontsize=18, weight="bold", loc="left")
|
||||
ax.set_xlim(0, 9000)
|
||||
ax.set_xlim(0, 100) # Normalized scale for uniformity
|
||||
ax.set_ylim(0, 1)
|
||||
ax.axis("off")
|
||||
|
||||
@@ -1296,6 +1301,7 @@ class GraphGenerator:
|
||||
|
||||
# Chart Styling
|
||||
ax.set_title("Fuel Source", fontsize=18, weight="bold", loc="left")
|
||||
ax.set_xlim(0, 100) # Normalized scale for uniformity
|
||||
ax.set_ylim(0, 1)
|
||||
ax.axis("off")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user