For Evil Trout blog part 2: switch between bar chart and table

This commit is contained in:
Robin Ward
2013-03-17 15:02:36 -04:00
parent 9511beec11
commit 0b4339c103
4 changed files with 80 additions and 2 deletions

View File

@@ -6,6 +6,18 @@ Discourse.Report.reopenClass({
$.ajax("/admin/reports/" + type, {
type: 'GET',
success: function(json) {
// Add a percent field to each tuple
var maxY = 0;
json.report.data.forEach(function (row) {
if (row.y > maxY) maxY = row.y;
});
if (maxY > 0) {
json.report.data.forEach(function (row) {
row.percentage = Math.round((row.y / maxY) * 100);
});
}
model.mergeAttributes(json.report);
model.set('loaded', true);
}