Fossil

Check-in [f857ea5410]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Automatically show a piechart in addition to the bar graph on ByUser and ByDayOfWeek activity reports.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | piechart
Files: files | file ages | folders
SHA1: f857ea5410600e3a3bfdcaa141a8ba0b08968e17
User & Date: drh 2015-05-09 23:08:37.485
Context
2015-05-10
16:09
Avoid duplicate entries in the output of "fossil finfo" ... (check-in: d9841bef06 user: drh tags: piechart)
2015-05-09
23:08
Automatically show a piechart in addition to the bar graph on ByUser and ByDayOfWeek activity reports. ... (check-in: f857ea5410 user: drh tags: piechart)
19:08
New algorithm for positioning the labels on a piechart. ... (check-in: 2018ad2cc5 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/statrep.c.
404
405
406
407
408
409
410
411
412
413
414
415
416

417
418
419
420
421
422
423
424
425
426
427
                                        row colors */
  int nMaxEvents = 1;                /* max number of events for
                                        all rows. */
  stats_report_init_view();
  stats_report_event_types_menu("byuser", NULL);
  @ <h1>Timeline Events
  @ (%s(stats_report_label_for_type())) by User</h1>
  if( PB("pie") ){
    db_multi_exec(
      "CREATE TEMP TABLE piechart(amt,label);"
      "INSERT INTO piechart SELECT count(*), user FROM v_reports"
                           " GROUP BY user ORDER BY count(*) DESC;"
    );

    @ <svg width=800 height=600>
    piechart_render(800, 600, PIE_OTHER);
    @ </svg>
    return;
  }
  @ <table class='statistics-report-table-events' border='0'
  @ cellpadding='2' cellspacing='0' id='statsTable'>
  @ <thead><tr>
  @ <th>User</th>
  @ <th>Events</th>
  @ <th width='90%%'><!-- relative commits graph --></th>







<
|
|
|
|
|
>
|
|
|
<







404
405
406
407
408
409
410

411
412
413
414
415
416
417
418
419

420
421
422
423
424
425
426
                                        row colors */
  int nMaxEvents = 1;                /* max number of events for
                                        all rows. */
  stats_report_init_view();
  stats_report_event_types_menu("byuser", NULL);
  @ <h1>Timeline Events
  @ (%s(stats_report_label_for_type())) by User</h1>

  db_multi_exec(
    "CREATE TEMP TABLE piechart(amt,label);"
    "INSERT INTO piechart SELECT count(*), user FROM v_reports"
                         " GROUP BY user ORDER BY count(*) DESC;"
  );
  if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
    @ <center><svg width=700 height=400>
    piechart_render(700, 400, PIE_OTHER|PIE_PERCENT);
    @ </svg></centre><hr/>

  }
  @ <table class='statistics-report-table-events' border='0'
  @ cellpadding='2' cellspacing='0' id='statsTable'>
  @ <thead><tr>
  @ <th>User</th>
  @ <th>Events</th>
  @ <th width='90%%'><!-- relative commits graph --></th>
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491

  db_multi_exec(
    "CREATE TEMP TABLE statrep(filename, cnt);"
    "INSERT INTO statrep(filename, cnt)"
    "  SELECT filename.name, count(distinct mlink.mid)"
    "    FROM filename, mlink"
    "   WHERE filename.fnid=mlink.fnid"
    "   GROUP BY 1"
  );
  db_prepare(&query,
    "SELECT filename, cnt FROM statrep ORDER BY cnt DESC, filename /*sort*/"
  );
  mxEvent = db_int(1, "SELECT max(cnt) FROM statrep");
  @ <h1>Check-ins Per File</h1>
  @ <table class='statistics-report-table-events' border='0'







|







476
477
478
479
480
481
482
483
484
485
486
487
488
489
490

  db_multi_exec(
    "CREATE TEMP TABLE statrep(filename, cnt);"
    "INSERT INTO statrep(filename, cnt)"
    "  SELECT filename.name, count(distinct mlink.mid)"
    "    FROM filename, mlink"
    "   WHERE filename.fnid=mlink.fnid"
    "   GROUP BY 1;"
  );
  db_prepare(&query,
    "SELECT filename, cnt FROM statrep ORDER BY cnt DESC, filename /*sort*/"
  );
  mxEvent = db_int(1, "SELECT max(cnt) FROM statrep");
  @ <h1>Check-ins Per File</h1>
  @ <table class='statistics-report-table-events' border='0'
537
538
539
540
541
542
543













544
545
546
547
548
549
550
  db_prepare(&query,
               "SELECT cast(mtime %% 7 AS INTEGER) dow, "
               "COUNT(*) AS eventCount "
               "FROM v_reports "
               "GROUP BY dow ORDER BY dow");
  @ <h1>Timeline Events
  @ (%s(stats_report_label_for_type())) by Day of the Week</h1>













  @ <table class='statistics-report-table-events' border='0'
  @ cellpadding='2' cellspacing='0' id='statsTable'>
  @ <thead><tr>
  @ <th>DoW</th>
  @ <th>Day</th>
  @ <th>Events</th>
  @ <th width='90%%'><!-- relative commits graph --></th>







>
>
>
>
>
>
>
>
>
>
>
>
>







536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
  db_prepare(&query,
               "SELECT cast(mtime %% 7 AS INTEGER) dow, "
               "COUNT(*) AS eventCount "
               "FROM v_reports "
               "GROUP BY dow ORDER BY dow");
  @ <h1>Timeline Events
  @ (%s(stats_report_label_for_type())) by Day of the Week</h1>
  db_multi_exec(
    "CREATE TEMP TABLE piechart(amt,label);"
    "INSERT INTO piechart SELECT count(*), cast(mtime %% 7 AS INT) FROM v_reports"
                         " GROUP BY 2 ORDER BY 2;"
    "UPDATE piechart SET label = CASE label WHEN 0 THEN 'Monday' WHEN 1 THEN 'Tuesday'"
    "  WHEN 2 THEN 'Wednesday' WHEN 3 THEN 'Thursday' WHEN 4 THEN 'Friday'"
    "  WHEN 5 THEN 'Saturday' ELSE 'Sunday' END;"
  );
  if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
    @ <center><svg width=700 height=400>
    piechart_render(700, 400, PIE_OTHER|PIE_PERCENT);
    @ </svg></centre><hr/>
  }
  @ <table class='statistics-report-table-events' border='0'
  @ cellpadding='2' cellspacing='0' id='statsTable'>
  @ <thead><tr>
  @ <th>DoW</th>
  @ <th>Day</th>
  @ <th>Events</th>
  @ <th width='90%%'><!-- relative commits graph --></th>