Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

make the graph more flexible with dynamic value.

  • Loading branch information...
commit 06de537b519e54ec150bff092f43c37b647f336c 1 parent c93442d
tzangms authored committed
View
2  django_histograms/templates/histograms/report.html
@@ -20,7 +20,7 @@ <h2 style="padding-top: 1em;">{{ label }} ({{ count }})</h2>
{% if day_labels %}
<span class="label">{{ forloop.counter }}</span>
{% endif %}
- <span class="count" style="height: {% widthratio num total 1000 %}%">
+ <span class="count" style="height: {% widthratio num total ratio %}%">
({{ num }})
</span>
</a>
View
8 django_histograms/utils.py
@@ -110,7 +110,13 @@ def get_report(self):
idx = grouper(data[self.attname])
months[idx][1][day_grouper(data[self.attname])] += data["num"]
months[idx][2] += data["num"]
+
+ total = sum(o for m in months.itervalues() for o in m[1])
+ max_num = max(o for m in months.itervalues() for o in m[1])
+ ratio = total / max_num * 100
+
return {
"results": months.values(),
- "total": sum(o for m in months.itervalues() for o in m[1]),
+ "total": total,
+ "ratio": ratio
}
Please sign in to comment.
Something went wrong with that request. Please try again.