Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Demonstrate the use of a pie-chart on the Check-ins By User page. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | piechart |
| Files: | files | file ages | folders |
| SHA1: |
04d496504461faa6076af77dfb2a0739 |
| User & Date: | drh 2015-05-07 03:12:53.553 |
Context
|
2015-05-07
| ||
| 14:50 | Merge in the /repo_tabsize page. Update to a post-3.8.10 version of SQLite that support the dbstat virtual table on attached databases, necessary to get the /repo_tabsize to work. ... (check-in: 04942b3113 user: drh tags: piechart) | |
| 03:12 | Demonstrate the use of a pie-chart on the Check-ins By User page. ... (check-in: 04d4965044 user: drh tags: piechart) | |
| 02:57 | Automatically switch in to chromatic mode when the number of wedges is 10 or less. ... (check-in: 8a12c62f0d user: drh tags: piechart) | |
Changes
Changes to src/piechart.c.
| ︙ | ︙ | |||
91 92 93 94 95 96 97 | int l; /* Large arc flag */ int j; /* Wedge number */ double rTotal; /* Total piechart.amt */ double rTooSmall; /* Sum of pieChart.amt entries less than 1/60th */ int nTotal; /* Total number of entries in piechart */ int nTooSmall; /* Number of pieChart.amt entries less than 1/60th */ | | | > | | | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
int l; /* Large arc flag */
int j; /* Wedge number */
double rTotal; /* Total piechart.amt */
double rTooSmall; /* Sum of pieChart.amt entries less than 1/60th */
int nTotal; /* Total number of entries in piechart */
int nTooSmall; /* Number of pieChart.amt entries less than 1/60th */
# define SATURATION 128
# define VALUE 192
# define OTHER_CUTOFF 90.0
cx = 0.5*width;
cy = 0.5*height;
r2 = cx<cy ? cx : cy;
r = r2 - 60.0;
if( r<0.33333*r2 ) r = 0.33333*r2;
h = 0;
db_prepare(&q, "SELECT sum(amt), count(*) FROM piechart");
if( db_step(&q)!=SQLITE_ROW ) return;
rTotal = db_column_double(&q, 0);
nTotal = db_column_int(&q, 1);
db_finalize(&q);
rTooSmall = 0.0;
nTooSmall = 0;
if( (pieFlags & PIE_OTHER)!=0 && nTotal>1 ){
db_prepare(&q, "SELECT sum(amt), count(*) FROM piechart WHERE amt<:amt");
db_bind_double(&q, ":amt", rTotal/OTHER_CUTOFF);
if( db_step(&q)==SQLITE_ROW ){
rTooSmall = db_column_double(&q, 0);
nTooSmall = db_column_double(&q, 1);
}
db_finalize(&q);
}
if( nTooSmall>1 ){
db_prepare(&q, "SELECT amt, label FROM piechart WHERE amt>=:limit"
" UNION ALL SELECT %.17g, '(%d others)';",
rTooSmall, nTooSmall);
db_bind_double(&q, ":limit", rTotal/OTHER_CUTOFF);
nTotal += 1 - nTooSmall;
}else{
db_prepare(&q, "SELECT amt, label FROM piechart");
}
if( nTotal<=10 ) pieFlags |= PIE_CHROMATIC;
for(j=0; db_step(&q)==SQLITE_ROW; j++){
double x = db_column_double(&q,0)/rTotal;
|
| ︙ | ︙ |
Changes to src/statrep.c.
| ︙ | ︙ | |||
402 403 404 405 406 407 408 |
int nEventTotal = 0; /* Total event count */
int rowClass = 0; /* counter for alternating
row colors */
int nMaxEvents = 1; /* max number of events for
all rows. */
stats_report_init_view();
stats_report_event_types_menu("byuser", NULL);
| < < < < < > > > > > > > > > > > > > > > > | 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
int nEventTotal = 0; /* Total event count */
int rowClass = 0; /* counter for alternating
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>
@ </tr></thead><tbody>
db_prepare(&query,
"SELECT user, "
"COUNT(*) AS eventCount "
"FROM v_reports "
"GROUP BY user ORDER BY eventCount DESC");
while( SQLITE_ROW == db_step(&query) ){
const int nCount = db_column_int(&query, 1);
if(nCount>nMaxEvents){
nMaxEvents = nCount;
}
}
db_reset(&query);
|
| ︙ | ︙ |