mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
For Evil Trout blog part 2: switch between bar chart and table
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user