Skip to content

Commit

Permalink
Fix the graph.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtricht committed Dec 1, 2016
1 parent 1e451ca commit 8f83e40
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
23 changes: 17 additions & 6 deletions assets/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<script>
var ctx = document.getElementById("burndownChart");
var totalPoints = {{ .Board.Points }};
var pointsSpentPerDay = [
var pointsSpentPerDay = {
{{- range .Board.CardProgress -}}
{{ .Points }},
{{ .Date.Format "2006-01-02" }}: {{ .Points }},
{{- end -}}
];
};
var days = [
{{- range .Dates -}}
"{{ .Format "2006-01-02" }}",
Expand Down Expand Up @@ -51,12 +51,23 @@
function getActualData() {
actual = [];
tempTotal = totalPoints;
for (i = 0; i < pointsSpentPerDay.length; i++) {
actual[i] = tempTotal - pointsSpentPerDay[i];
tempTotal = tempTotal - pointsSpentPerDay[i];
for (i = 0; i < days.length; i++) {
pointsTemp = pointsSpentPerDay[days[i]] || 0;
actual[i] = tempTotal - pointsTemp;
tempTotal = tempTotal - pointsTemp;
if (isToday(days[i])) {
break;
}
}
return actual;
}
function isToday(date) {
var dateObj = new Date();
var month = dateObj.getUTCMonth() + 1;
var day = ('0' + dateObj.getUTCDate()).slice(-2);
var year = dateObj.getUTCFullYear();
return date == year + "-" + month + "-" + day;
}
</script>
{{ template "footer" }}
{{ end }}
Loading

0 comments on commit 8f83e40

Please sign in to comment.