Add BMI to height/weight graph

This commit is contained in:
Gregory Trullemans 2024-04-11 08:42:03 +02:00
parent adaa3fe0e3
commit 8612ea9087
2 changed files with 31 additions and 1 deletions

View File

@ -235,6 +235,9 @@ class WellBeing(Markdownizable, Seasonisable):
Représente l'état psychologique/physique d'un gymnaste
"""
class Meta:
ordering = ["date", ]
gymnast = models.ForeignKey(
Gymnast, on_delete=models.CASCADE, default=None, related_name="wellbeings"
)

View File

@ -205,6 +205,13 @@
gradient_stroke_orange.addColorStop(0.5, 'rgba(255, 159, 64, 0.2)');
gradient_stroke_orange.addColorStop(0.25, 'rgba(255, 159, 64, 0)');
var border_color_green = 'rgb(75, 192, 192)';
var gradient_stroke_green = ctx.createLinearGradient(0, 230, 0, 50);
gradient_stroke_green.addColorStop(1, 'rgba(75, 192, 192, 0.4)');
gradient_stroke_green.addColorStop(0.75, 'rgba(75, 192, 192, 0.3)');
gradient_stroke_green.addColorStop(0.5, 'rgba(75, 192, 192, 0.2)');
gradient_stroke_green.addColorStop(0.25, 'rgba(75, 192, 192, 0)');
var height_values = [
{% for height_weight in height_weight_list %}
{
@ -223,6 +230,15 @@
{% endfor %}
]
var bmi_value = [
{% for height_weight in height_weight_list %}
{
x: '{{ height_weight.date | date:"d-m-Y" }}',
y: '{{ height_weight.bmi }}'
},
{% endfor %}
]
var height_weight_data = {
datasets: [
{
@ -233,6 +249,7 @@
pointBackgroundColor: border_color_pink,
fill: true,
data: height_values,
hidden: true,
},
{
label: 'Height',
@ -241,7 +258,17 @@
borderColor: border_color_orange,
pointBackgroundColor: border_color_orange,
fill: true,
data: weight_values
data: weight_values,
hidden: true,
},
{
label: 'BMI',
cubicInterpolationMode: 'monotone',
backgroundColor: gradient_stroke_green,
borderColor: border_color_green,
pointBackgroundColor: border_color_green,
fill: true,
data: bmi_value,
},
],
};