Commit 97ae29c 1 parent 23ec9e0 commit 97ae29c Copy full SHA for 97ae29c
File tree 1 file changed +22
-10
lines changed
1 file changed +22
-10
lines changed Original file line number Diff line number Diff line change @@ -237,16 +237,18 @@ async function generateIncByWeekChart(numberOfDays) {
237
237
} ,
238
238
} ,
239
239
} ) ;
240
- chart . setWidth ( 800 ) ;
241
- chart . setHeight ( 400 ) ;
242
- return chart . getUrl ( ) ;
240
+ // Increase chart size
241
+ chart . setWidth ( 400 ) ;
242
+ chart . setHeight ( 200 ) ;
243
+ return chart . getShortUrl ( ) ;
243
244
}
244
245
245
246
async function generateIncByCategoryChart ( numberOfDays ) {
246
247
const dbResponse = await getIncByCategory ( numberOfDays ) ;
248
+ const sortedCategories = dbResponse . rows . sort ( ( a , b ) => b . count - a . count ) ;
247
249
248
- const labels = dbResponse . rows . map ( ( row ) => row . category ) ;
249
- const data = dbResponse . rows . map ( ( row ) => parseInt ( row . count , 10 ) ) ;
250
+ const labels = sortedCategories . map ( ( row ) => row . category ) ;
251
+ const data = sortedCategories . map ( ( row ) => parseInt ( row . count , 10 ) ) ;
250
252
251
253
// Generate the bar chart URL using QuickChart
252
254
const chart = new QuickChart ( ) ;
@@ -266,13 +268,23 @@ async function generateIncByCategoryChart(numberOfDays) {
266
268
} ,
267
269
options : {
268
270
scales : {
269
- y : {
270
- beginAtZero : true ,
271
+ xAxes : {
272
+ ticks : {
273
+ max : labels . length , // Limit the number of labels to show
274
+ } ,
275
+ } ,
276
+ yAxes : {
277
+ ticks : {
278
+ beginAtZero : true , // Start the y-axis at 0
279
+ stepSize : 1 , // Set the step size to 1
280
+ }
271
281
} ,
272
282
} ,
273
283
} ,
274
284
} ) ;
275
- chart . setWidth ( 800 ) ;
276
- chart . setHeight ( 400 ) ;
277
- return chart . getUrl ( ) ;
285
+
286
+ // Increase chart size
287
+ chart . setWidth ( 400 ) ;
288
+ chart . setHeight ( 200 ) ;
289
+ return chart . getShortUrl ( ) ;
278
290
}
You can’t perform that action at this time.
0 commit comments