Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Fix the issue with the date axis on weight chart, do some cleanup

Roland Geider6a59ca0cc978
diff --git a/weight/templates/weight_overview.html b/weight/templates/weight_overview.html
index b7fd5975f..ee3ca8ee4 100644
--- a/weight/templates/weight_overview.html
+++ b/weight/templates/weight_overview.html
@@ -81,8 +81,7 @@ var y = d3.scale.linear()
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");
- //.ticks(d3.time.days);
-
+
var yAxis = d3.svg.axis()
.scale(y)
.orient("left");
@@ -124,6 +123,7 @@ svg.selectAll(".dot")
.data(data.filter(function(d) { return d.y; }))
.enter().append("circle")
.attr("class", "dot")
+ //.attr("id", ....)
.attr("cx", line.x())
.attr("cy", line.y())
.attr("r", 3.5);
diff --git a/weight/views.py b/weight/views.py
index d9d099988..0e4027d7d 100644
--- a/weight/views.py
+++ b/weight/views.py
@@ -97,10 +97,11 @@ def export_csv(request):
@login_required
def overview(request):
- """Shows an overview of weight data
+ """Shows a plot with the weight data
- More info about the JS can be found here:
- * http://wijmo.com/wiki/index.php/Scatterchart
+ More info about the D3 library can be found here:
+ * https://github.com/mbostock/d3
+ * http://d3js.org/
"""
template_data = {}
weights = WeightEntry.objects.filter(user = request.user)
@@ -109,15 +110,14 @@ def overview(request):
# Process the data to pass it to the JS libraries to generate an SVG image
chart_data = "[\n"
- j = 0
+
for i in weights:
- chart_data += '{x: "%(month)s/%(month)s/%(year)s", y: %(weight)s, id: %(id)s},\n' % {
+ chart_data += '{x: "%(month)s/%(day)s/%(year)s", y: %(weight)s, id: %(id)s},\n' % {
'year': i.creation_date.year,
'month': i.creation_date.month,
'day': i.creation_date.day,
'weight': i.weight,
- 'id': i.id}
- j += 1
+ 'id': '"entry-%s"' % i.id}
chart_data = chart_data.rstrip(',')
chart_data += "]"