Skip to content

Commit

Permalink
Try to increase width of categories image to have room for mopre cate…
Browse files Browse the repository at this point in the history
…gories being displayed. Also sort categories by count before displaying
  • Loading branch information
Sinan-96 committed Oct 3, 2024
1 parent 23ec9e0 commit 06b7092
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,17 @@ async function generateIncByWeekChart(numberOfDays) {
},
},
});
chart.setWidth(800);
chart.setWidth(1200);
chart.setHeight(400);
return chart.getUrl();
}

async function generateIncByCategoryChart(numberOfDays) {
const dbResponse = await getIncByCategory(numberOfDays);
const sortedCategories = dbResponse.rows.sort((a, b) => b.count - a.count);

const labels = dbResponse.rows.map((row) => row.category);
const data = dbResponse.rows.map((row) => parseInt(row.count, 10));
const labels = sortedCategories.rows.map((row) => row.category);
const data = sortedCategories.rows.map((row) => parseInt(row.count, 10));

// Generate the bar chart URL using QuickChart
const chart = new QuickChart();
Expand All @@ -272,7 +273,7 @@ async function generateIncByCategoryChart(numberOfDays) {
},
},
});
chart.setWidth(800);
chart.setWidth(1200);
chart.setHeight(400);
return chart.getUrl();
}

0 comments on commit 06b7092

Please sign in to comment.