Fossil SCM
Automatically show a piechart in addition to the bar graph on ByUser and ByDayOfWeek activity reports.
Commit
f857ea5410600e3a3bfdcaa141a8ba0b08968e17
Parent
2018ad2cc5c8295…
1 file changed
+23
-11
+23
-11
| --- src/statrep.c | ||
| +++ src/statrep.c | ||
| @@ -406,20 +406,19 @@ | ||
| 406 | 406 | all rows. */ |
| 407 | 407 | stats_report_init_view(); |
| 408 | 408 | stats_report_event_types_menu("byuser", NULL); |
| 409 | 409 | @ <h1>Timeline Events |
| 410 | 410 | @ (%s(stats_report_label_for_type())) by User</h1> |
| 411 | - if( PB("pie") ){ | |
| 412 | - db_multi_exec( | |
| 413 | - "CREATE TEMP TABLE piechart(amt,label);" | |
| 414 | - "INSERT INTO piechart SELECT count(*), user FROM v_reports" | |
| 415 | - " GROUP BY user ORDER BY count(*) DESC;" | |
| 416 | - ); | |
| 417 | - @ <svg width=800 height=600> | |
| 418 | - piechart_render(800, 600, PIE_OTHER); | |
| 419 | - @ </svg> | |
| 420 | - return; | |
| 411 | + db_multi_exec( | |
| 412 | + "CREATE TEMP TABLE piechart(amt,label);" | |
| 413 | + "INSERT INTO piechart SELECT count(*), user FROM v_reports" | |
| 414 | + " GROUP BY user ORDER BY count(*) DESC;" | |
| 415 | + ); | |
| 416 | + if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){ | |
| 417 | + @ <center><svg width=700 height=400> | |
| 418 | + piechart_render(700, 400, PIE_OTHER|PIE_PERCENT); | |
| 419 | + @ </svg></centre><hr/> | |
| 421 | 420 | } |
| 422 | 421 | @ <table class='statistics-report-table-events' border='0' |
| 423 | 422 | @ cellpadding='2' cellspacing='0' id='statsTable'> |
| 424 | 423 | @ <thead><tr> |
| 425 | 424 | @ <th>User</th> |
| @@ -479,11 +478,11 @@ | ||
| 479 | 478 | "CREATE TEMP TABLE statrep(filename, cnt);" |
| 480 | 479 | "INSERT INTO statrep(filename, cnt)" |
| 481 | 480 | " SELECT filename.name, count(distinct mlink.mid)" |
| 482 | 481 | " FROM filename, mlink" |
| 483 | 482 | " WHERE filename.fnid=mlink.fnid" |
| 484 | - " GROUP BY 1" | |
| 483 | + " GROUP BY 1;" | |
| 485 | 484 | ); |
| 486 | 485 | db_prepare(&query, |
| 487 | 486 | "SELECT filename, cnt FROM statrep ORDER BY cnt DESC, filename /*sort*/" |
| 488 | 487 | ); |
| 489 | 488 | mxEvent = db_int(1, "SELECT max(cnt) FROM statrep"); |
| @@ -539,10 +538,23 @@ | ||
| 539 | 538 | "COUNT(*) AS eventCount " |
| 540 | 539 | "FROM v_reports " |
| 541 | 540 | "GROUP BY dow ORDER BY dow"); |
| 542 | 541 | @ <h1>Timeline Events |
| 543 | 542 | @ (%s(stats_report_label_for_type())) by Day of the Week</h1> |
| 543 | + db_multi_exec( | |
| 544 | + "CREATE TEMP TABLE piechart(amt,label);" | |
| 545 | + "INSERT INTO piechart SELECT count(*), cast(mtime %% 7 AS INT) FROM v_reports" | |
| 546 | + " GROUP BY 2 ORDER BY 2;" | |
| 547 | + "UPDATE piechart SET label = CASE label WHEN 0 THEN 'Monday' WHEN 1 THEN 'Tuesday'" | |
| 548 | + " WHEN 2 THEN 'Wednesday' WHEN 3 THEN 'Thursday' WHEN 4 THEN 'Friday'" | |
| 549 | + " WHEN 5 THEN 'Saturday' ELSE 'Sunday' END;" | |
| 550 | + ); | |
| 551 | + if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){ | |
| 552 | + @ <center><svg width=700 height=400> | |
| 553 | + piechart_render(700, 400, PIE_OTHER|PIE_PERCENT); | |
| 554 | + @ </svg></centre><hr/> | |
| 555 | + } | |
| 544 | 556 | @ <table class='statistics-report-table-events' border='0' |
| 545 | 557 | @ cellpadding='2' cellspacing='0' id='statsTable'> |
| 546 | 558 | @ <thead><tr> |
| 547 | 559 | @ <th>DoW</th> |
| 548 | 560 | @ <th>Day</th> |
| 549 | 561 |
| --- src/statrep.c | |
| +++ src/statrep.c | |
| @@ -406,20 +406,19 @@ | |
| 406 | all rows. */ |
| 407 | stats_report_init_view(); |
| 408 | stats_report_event_types_menu("byuser", NULL); |
| 409 | @ <h1>Timeline Events |
| 410 | @ (%s(stats_report_label_for_type())) by User</h1> |
| 411 | if( PB("pie") ){ |
| 412 | db_multi_exec( |
| 413 | "CREATE TEMP TABLE piechart(amt,label);" |
| 414 | "INSERT INTO piechart SELECT count(*), user FROM v_reports" |
| 415 | " GROUP BY user ORDER BY count(*) DESC;" |
| 416 | ); |
| 417 | @ <svg width=800 height=600> |
| 418 | piechart_render(800, 600, PIE_OTHER); |
| 419 | @ </svg> |
| 420 | return; |
| 421 | } |
| 422 | @ <table class='statistics-report-table-events' border='0' |
| 423 | @ cellpadding='2' cellspacing='0' id='statsTable'> |
| 424 | @ <thead><tr> |
| 425 | @ <th>User</th> |
| @@ -479,11 +478,11 @@ | |
| 479 | "CREATE TEMP TABLE statrep(filename, cnt);" |
| 480 | "INSERT INTO statrep(filename, cnt)" |
| 481 | " SELECT filename.name, count(distinct mlink.mid)" |
| 482 | " FROM filename, mlink" |
| 483 | " WHERE filename.fnid=mlink.fnid" |
| 484 | " GROUP BY 1" |
| 485 | ); |
| 486 | db_prepare(&query, |
| 487 | "SELECT filename, cnt FROM statrep ORDER BY cnt DESC, filename /*sort*/" |
| 488 | ); |
| 489 | mxEvent = db_int(1, "SELECT max(cnt) FROM statrep"); |
| @@ -539,10 +538,23 @@ | |
| 539 | "COUNT(*) AS eventCount " |
| 540 | "FROM v_reports " |
| 541 | "GROUP BY dow ORDER BY dow"); |
| 542 | @ <h1>Timeline Events |
| 543 | @ (%s(stats_report_label_for_type())) by Day of the Week</h1> |
| 544 | @ <table class='statistics-report-table-events' border='0' |
| 545 | @ cellpadding='2' cellspacing='0' id='statsTable'> |
| 546 | @ <thead><tr> |
| 547 | @ <th>DoW</th> |
| 548 | @ <th>Day</th> |
| 549 |
| --- src/statrep.c | |
| +++ src/statrep.c | |
| @@ -406,20 +406,19 @@ | |
| 406 | all rows. */ |
| 407 | stats_report_init_view(); |
| 408 | stats_report_event_types_menu("byuser", NULL); |
| 409 | @ <h1>Timeline Events |
| 410 | @ (%s(stats_report_label_for_type())) by User</h1> |
| 411 | db_multi_exec( |
| 412 | "CREATE TEMP TABLE piechart(amt,label);" |
| 413 | "INSERT INTO piechart SELECT count(*), user FROM v_reports" |
| 414 | " GROUP BY user ORDER BY count(*) DESC;" |
| 415 | ); |
| 416 | if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){ |
| 417 | @ <center><svg width=700 height=400> |
| 418 | piechart_render(700, 400, PIE_OTHER|PIE_PERCENT); |
| 419 | @ </svg></centre><hr/> |
| 420 | } |
| 421 | @ <table class='statistics-report-table-events' border='0' |
| 422 | @ cellpadding='2' cellspacing='0' id='statsTable'> |
| 423 | @ <thead><tr> |
| 424 | @ <th>User</th> |
| @@ -479,11 +478,11 @@ | |
| 478 | "CREATE TEMP TABLE statrep(filename, cnt);" |
| 479 | "INSERT INTO statrep(filename, cnt)" |
| 480 | " SELECT filename.name, count(distinct mlink.mid)" |
| 481 | " FROM filename, mlink" |
| 482 | " WHERE filename.fnid=mlink.fnid" |
| 483 | " GROUP BY 1;" |
| 484 | ); |
| 485 | db_prepare(&query, |
| 486 | "SELECT filename, cnt FROM statrep ORDER BY cnt DESC, filename /*sort*/" |
| 487 | ); |
| 488 | mxEvent = db_int(1, "SELECT max(cnt) FROM statrep"); |
| @@ -539,10 +538,23 @@ | |
| 538 | "COUNT(*) AS eventCount " |
| 539 | "FROM v_reports " |
| 540 | "GROUP BY dow ORDER BY dow"); |
| 541 | @ <h1>Timeline Events |
| 542 | @ (%s(stats_report_label_for_type())) by Day of the Week</h1> |
| 543 | db_multi_exec( |
| 544 | "CREATE TEMP TABLE piechart(amt,label);" |
| 545 | "INSERT INTO piechart SELECT count(*), cast(mtime %% 7 AS INT) FROM v_reports" |
| 546 | " GROUP BY 2 ORDER BY 2;" |
| 547 | "UPDATE piechart SET label = CASE label WHEN 0 THEN 'Monday' WHEN 1 THEN 'Tuesday'" |
| 548 | " WHEN 2 THEN 'Wednesday' WHEN 3 THEN 'Thursday' WHEN 4 THEN 'Friday'" |
| 549 | " WHEN 5 THEN 'Saturday' ELSE 'Sunday' END;" |
| 550 | ); |
| 551 | if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){ |
| 552 | @ <center><svg width=700 height=400> |
| 553 | piechart_render(700, 400, PIE_OTHER|PIE_PERCENT); |
| 554 | @ </svg></centre><hr/> |
| 555 | } |
| 556 | @ <table class='statistics-report-table-events' border='0' |
| 557 | @ cellpadding='2' cellspacing='0' id='statsTable'> |
| 558 | @ <thead><tr> |
| 559 | @ <th>DoW</th> |
| 560 | @ <th>Day</th> |
| 561 |