Self hosted FLOSS fitness/workout, nutrition and weight tracker
Use the real data to process the chart
Roland Geider51aa6de91bd1
diff --git a/manager/templates/base.html b/manager/templates/base.htmlindex dc4cb5a76..8e856aafa 100644--- a/manager/templates/base.html+++ b/manager/templates/base.html@@ -1,5 +1,5 @@{% load i18n %}-{% load staticfiles %}+{% load staticfiles %}<!DOCTYPE html><html><head>diff --git a/weight/templates/overview.html b/weight/templates/overview.htmlindex df370b516..9601a8e55 100644--- a/weight/templates/overview.html+++ b/weight/templates/overview.html@@ -20,7 +20,7 @@$("#wijscatterchartDefault").wijscatterchart({header: {- text: "Height Versus Weight of 72 Individuals by Gender"+ //text: "Title"},axis: {y: {@@ -38,7 +38,7 @@tickMinor: { position: "outside", style: { stroke: "#7f7f7f"} }},x: {- text: "Height (cm)",+ text: "Date",labels: {style: {fill: "#7f7f7f",@@ -52,7 +52,7 @@showChartLabels: false,hint: {content: function () {- return this.x + ' cm, ' + this.y + ' kg'+ return this.x + ', ' + this.y + ' kg'},contentStyle: {"font-size": "10pt"@@ -67,30 +67,11 @@label: "Female",legendEntry: true,data: {- x: [161.4, 169.0, 166.2, 159.4, 162.5, 159.0, 162.8, 159.0, 179.8, 162.9, 161.0, 151.1, 168.2, 168.9, 173.2,- 174.0, 162.6, 174.0, 162.6, 161.3, 156.2, 149.9, 169.5, 160.0, 175.3, 169.5, 160.0, 172.7, 162.6, 157.5,- 176.5, 164.4, 160.7, 174.0, 163.8],- y: [63.4, 58.2, 58.6, 45.7, 52.2, 48.6, 57.8, 55.6, 66.8, 59.4, 53.6, 73.2, 53.4, 69.0, 58.4,- 73.6, 61.4, 55.5, 63.6, 60.9, 60.0, 46.8, 57.3, 64.1, 63.6, 67.3, 75.5, 68.2, 61.4, 76.8,- 71.8, 55.5, 48.6, 66.4, 67.3]+ x: [{{ data_x }}],+ y: [{{ data_y }}]},visible: true,markerType: "circle"- }, {- label: "Male",- legendEntry: true,- data: {- x: [175.0, 174.0, 165.1, 177.0, 192.0, 176.5, 169.4, 182.1, 179.8, 175.3, 184.9, 177.3, 167.4, 178.1, 168.9,- 174.0, 167.6, 170.2, 167.6, 188.0, 174.0, 176.5, 180.3, 167.6, 188.0, 180.3, 167.6, 183.0, 183.0, 179.1,- 170.2, 177.8, 179.1, 190.5, 177.8, 180.3, 180.3- ],- y: [70.2, 73.4, 70.5, 68.9, 102.3, 68.4, 65.9, 75.7, 84.5, 87.7, 86.4, 73.2, 53.9, 72.0, 55.5,- 70.9, 64.5, 77.3, 72.3, 87.3, 80.0, 82.3, 73.6, 74.1, 85.9, 73.2, 76.3, 65.9, 90.9, 89.1,- 62.3, 82.7, 79.1, 98.2, 84.1, 83.2, 83.2- ]- },- visible: true,- markerType: "diamond"}],seriesStyles: [{@@ -112,20 +93,14 @@-->{% block content %}-<h2>{% if exercise.id %}- {% trans "Edit" %} {{ exercise.name }}- {% else %}- {% trans "New exercise" %}- {% endif %}-</h2>+<h2>{% trans "Weight overview" %}</h2><div id="wijscatterchartDefault"></div>-{% for entry in weights %}-{{ entry }}-{% endfor %}+<a href="/weight/add">{% trans "Add weight entry" %}</a>+{% endblock %}diff --git a/weight/views.py b/weight/views.pyindex 706e7b1d8..1154a108e 100644--- a/weight/views.py+++ b/weight/views.py@@ -12,6 +12,7 @@## You should have received a copy of the GNU Affero General Public License+import loggingimport datetimefrom django.shortcuts import render_to_response@@ -22,6 +23,9 @@ from django.core.context_processors import csrffrom weight.models import WeightEntry++logger = logging.getLogger('workout_manager.custom')+class WeightForm(ModelForm):class Meta:model = WeightEntry@@ -61,7 +65,16 @@ def overview(request):"""Shows an overview of weight data"""template_data = {}+ weights = WeightEntry.objects.all()+ template_data['weights'] = weights++ # Process the data to pass it to the JS libraries to generate an SVG image+ data_y = ', '.join([str(i.weight) for i in weights])+ data_x = ', '.join(["new Date(%s, %s, %s)" % (i.creation_date.year,+ i.creation_date.month,+ i.creation_date.day) for i in weights])- template_data['weights'] = WeightEntry.objects.all()+ template_data['data_x'] = data_x+ template_data['data_y'] = data_yreturn render_to_response('overview.html', template_data)\ No newline at end of file