Fossil SCM

Removed the 500px baseline for /stats_report calculations, refactored the bars to now use percentage widths.

stephan 2013-07-20 16:43 trunk
Commit 674a24a3603ed20124570d5f2e77a5c13b810fee
1 file changed +10 -19
+10 -19
--- src/timeline.c
+++ src/timeline.c
@@ -1864,19 +1864,10 @@
18641864
g.zTop, yearPart, zWeek,
18651865
nCount, zWeek);
18661866
}
18671867
db_finalize(&stWeek);
18681868
}
1869
-
1870
-/**
1871
- Pixel width for the longest bar in
1872
- the /stats_report graphs. This is considered
1873
- the 100% value and all lengths are calculated
1874
- as a percentage of this value.
1875
- */
1876
-static int const nStatReportLineWidth = 500;
1877
-
18781869
18791870
/*
18801871
** Implements the "byyear" and "bymonth" reports for /stats_report.
18811872
** If includeMonth is true then it generates the "bymonth" report,
18821873
** else the "byyear" report. If zUserName is not NULL and not empty
@@ -1924,11 +1915,11 @@
19241915
@ <table class='statistics-report-table-events' border='0' cellpadding='2'
19251916
@ cellspacing='0' id='statsTable'>
19261917
@ <thead>
19271918
@ <th>%s(zTimeLabel)</th>
19281919
@ <th>Events</th>
1929
- @ <th><!-- relative commits graph --></th>
1920
+ @ <th width='90%%'><!-- relative commits graph --></th>
19301921
@ </thead><tbody>
19311922
blob_reset(&header);
19321923
/*
19331924
Run the query twice. The first time we calculate the maximum
19341925
number of events for a given row. Maybe someone with better SQL
@@ -1943,11 +1934,11 @@
19431934
db_reset(&query);
19441935
while( SQLITE_ROW == db_step(&query) ){
19451936
char const * zTimeframe = db_column_text(&query, 0);
19461937
int const nCount = db_column_int(&query, 1);
19471938
int const nSize = nCount
1948
- ? (int)(1.0 * nCount / nMaxEvents * nStatReportLineWidth)
1939
+ ? (int)(1.0 * nCount / nMaxEvents * 100)
19491940
: 1;
19501941
showYearTotal = 0;
19511942
if(includeMonth){
19521943
/* For Month/year view, add a separator for each distinct year. */
19531944
if(!*zPrevYear ||
@@ -1992,11 +1983,11 @@
19921983
cgi_printf("'>%s</a>", zTimeframe);
19931984
}
19941985
@ </td><td>%d(nCount)</td>
19951986
@ <td>
19961987
@ <div class='statistics-report-graph-line'
1997
- @ style='height:16px;width:%d(nSize)px;'>
1988
+ @ style='height:16px;width:%d(nSize)%%;'>
19981989
@ </div></td>
19991990
@</tr>
20001991
if(includeWeeks){
20011992
/* This part works fine for months but it terribly slow (4.5s on my PC),
20021993
so it's only shown for by-year for now. Suggestions/patches for
@@ -2060,11 +2051,11 @@
20602051
@ <table class='statistics-report-table-events' border='0'
20612052
@ cellpadding='2' cellspacing='0' id='statsTable'>
20622053
@ <thead><tr>
20632054
@ <th>User</th>
20642055
@ <th>Events</th>
2065
- @ <th><!-- relative commits graph --></th>
2056
+ @ <th width='90%%'><!-- relative commits graph --></th>
20662057
@ </tr></thead><tbody>
20672058
while( SQLITE_ROW == db_step(&query) ){
20682059
int const nCount = db_column_int(&query, 1);
20692060
if(nCount>nMaxEvents){
20702061
nMaxEvents = nCount;
@@ -2073,11 +2064,11 @@
20732064
db_reset(&query);
20742065
while( SQLITE_ROW == db_step(&query) ){
20752066
char const * zUser = db_column_text(&query, 0);
20762067
int const nCount = db_column_int(&query, 1);
20772068
int const nSize = nCount
2078
- ? (int)(1.0 * nCount / nMaxEvents * nStatReportLineWidth)
2069
+ ? (int)(1.0 * nCount / nMaxEvents * 100)
20792070
: 0;
20802071
if(!nCount) continue /* arguable! Possible? */;
20812072
rowClass = ++nRowNumber % 2;
20822073
nEventTotal += nCount;
20832074
@<tr class='row%d(rowClass)'>
@@ -2084,11 +2075,11 @@
20842075
@ <td>
20852076
@ <a href="?view=bymonth&user=%h(zUser)" target="_new">%h(zUser)</a>
20862077
@ </td><td>%d(nCount)</td>
20872078
@ <td>
20882079
@ <div class='statistics-report-graph-line'
2089
- @ style='height:16px;width:%d(nSize)px;'>
2080
+ @ style='height:16px;width:%d(nSize)%%;'>
20902081
@ </div></td>
20912082
@</tr>
20922083
/*
20932084
Potential improvement: calculate the min/max event counts and
20942085
use percent-based graph bars.
@@ -2164,16 +2155,16 @@
21642155
}
21652156
blob_appendf(&sql, "GROUP BY wk ORDER BY wk DESC");
21662157
cgi_printf("<h1>%h</h1>", blob_str(&header));
21672158
blob_reset(&header);
21682159
cgi_printf("<table class='statistics-report-table-events' "
2169
- "border='0' cellpadding='2' "
2160
+ "border='0' cellpadding='2' width='100%%' "
21702161
"cellspacing='0' id='statsTable'>");
21712162
cgi_printf("<thead><tr>"
21722163
"<th>Week</th>"
21732164
"<th>Events</th>"
2174
- "<th><!-- relative commits graph --></th>"
2165
+ "<th width='90%%'><!-- relative commits graph --></th>"
21752166
"</tr></thead>"
21762167
"<tbody>");
21772168
db_prepare(&stWeek, blob_str(&sql));
21782169
blob_reset(&sql);
21792170
while( SQLITE_ROW == db_step(&stWeek) ){
@@ -2185,11 +2176,11 @@
21852176
db_reset(&stWeek);
21862177
while( SQLITE_ROW == db_step(&stWeek) ){
21872178
char const * zWeek = db_column_text(&stWeek,0);
21882179
int const nCount = db_column_int(&stWeek,1);
21892180
int const nSize = nCount
2190
- ? (int)(1.0 * nCount / nMaxEvents * nStatReportLineWidth)
2181
+ ? (int)(1.0 * nCount / nMaxEvents * 100)
21912182
: 0;
21922183
total += nCount;
21932184
cgi_printf("<tr class='row%d'>", ++rowCount % 2 );
21942185
cgi_printf("<td><a href='%s/timeline?yw=%t-%s&n=%d",
21952186
g.zTop, zYear, zWeek, nCount);
@@ -2200,11 +2191,11 @@
22002191
22012192
cgi_printf("<td>%d</td>",nCount);
22022193
cgi_printf("<td>");
22032194
if(nCount){
22042195
cgi_printf("<div class='statistics-report-graph-line'"
2205
- "style='height:16px;width:%dpx;'></div>",
2196
+ "style='height:16px;width:%d%%;'></div>",
22062197
nSize);
22072198
}
22082199
cgi_printf("</td></tr>");
22092200
}
22102201
db_finalize(&stWeek);
22112202
--- src/timeline.c
+++ src/timeline.c
@@ -1864,19 +1864,10 @@
1864 g.zTop, yearPart, zWeek,
1865 nCount, zWeek);
1866 }
1867 db_finalize(&stWeek);
1868 }
1869
1870 /**
1871 Pixel width for the longest bar in
1872 the /stats_report graphs. This is considered
1873 the 100% value and all lengths are calculated
1874 as a percentage of this value.
1875 */
1876 static int const nStatReportLineWidth = 500;
1877
1878
1879 /*
1880 ** Implements the "byyear" and "bymonth" reports for /stats_report.
1881 ** If includeMonth is true then it generates the "bymonth" report,
1882 ** else the "byyear" report. If zUserName is not NULL and not empty
@@ -1924,11 +1915,11 @@
1924 @ <table class='statistics-report-table-events' border='0' cellpadding='2'
1925 @ cellspacing='0' id='statsTable'>
1926 @ <thead>
1927 @ <th>%s(zTimeLabel)</th>
1928 @ <th>Events</th>
1929 @ <th><!-- relative commits graph --></th>
1930 @ </thead><tbody>
1931 blob_reset(&header);
1932 /*
1933 Run the query twice. The first time we calculate the maximum
1934 number of events for a given row. Maybe someone with better SQL
@@ -1943,11 +1934,11 @@
1943 db_reset(&query);
1944 while( SQLITE_ROW == db_step(&query) ){
1945 char const * zTimeframe = db_column_text(&query, 0);
1946 int const nCount = db_column_int(&query, 1);
1947 int const nSize = nCount
1948 ? (int)(1.0 * nCount / nMaxEvents * nStatReportLineWidth)
1949 : 1;
1950 showYearTotal = 0;
1951 if(includeMonth){
1952 /* For Month/year view, add a separator for each distinct year. */
1953 if(!*zPrevYear ||
@@ -1992,11 +1983,11 @@
1992 cgi_printf("'>%s</a>", zTimeframe);
1993 }
1994 @ </td><td>%d(nCount)</td>
1995 @ <td>
1996 @ <div class='statistics-report-graph-line'
1997 @ style='height:16px;width:%d(nSize)px;'>
1998 @ </div></td>
1999 @</tr>
2000 if(includeWeeks){
2001 /* This part works fine for months but it terribly slow (4.5s on my PC),
2002 so it's only shown for by-year for now. Suggestions/patches for
@@ -2060,11 +2051,11 @@
2060 @ <table class='statistics-report-table-events' border='0'
2061 @ cellpadding='2' cellspacing='0' id='statsTable'>
2062 @ <thead><tr>
2063 @ <th>User</th>
2064 @ <th>Events</th>
2065 @ <th><!-- relative commits graph --></th>
2066 @ </tr></thead><tbody>
2067 while( SQLITE_ROW == db_step(&query) ){
2068 int const nCount = db_column_int(&query, 1);
2069 if(nCount>nMaxEvents){
2070 nMaxEvents = nCount;
@@ -2073,11 +2064,11 @@
2073 db_reset(&query);
2074 while( SQLITE_ROW == db_step(&query) ){
2075 char const * zUser = db_column_text(&query, 0);
2076 int const nCount = db_column_int(&query, 1);
2077 int const nSize = nCount
2078 ? (int)(1.0 * nCount / nMaxEvents * nStatReportLineWidth)
2079 : 0;
2080 if(!nCount) continue /* arguable! Possible? */;
2081 rowClass = ++nRowNumber % 2;
2082 nEventTotal += nCount;
2083 @<tr class='row%d(rowClass)'>
@@ -2084,11 +2075,11 @@
2084 @ <td>
2085 @ <a href="?view=bymonth&user=%h(zUser)" target="_new">%h(zUser)</a>
2086 @ </td><td>%d(nCount)</td>
2087 @ <td>
2088 @ <div class='statistics-report-graph-line'
2089 @ style='height:16px;width:%d(nSize)px;'>
2090 @ </div></td>
2091 @</tr>
2092 /*
2093 Potential improvement: calculate the min/max event counts and
2094 use percent-based graph bars.
@@ -2164,16 +2155,16 @@
2164 }
2165 blob_appendf(&sql, "GROUP BY wk ORDER BY wk DESC");
2166 cgi_printf("<h1>%h</h1>", blob_str(&header));
2167 blob_reset(&header);
2168 cgi_printf("<table class='statistics-report-table-events' "
2169 "border='0' cellpadding='2' "
2170 "cellspacing='0' id='statsTable'>");
2171 cgi_printf("<thead><tr>"
2172 "<th>Week</th>"
2173 "<th>Events</th>"
2174 "<th><!-- relative commits graph --></th>"
2175 "</tr></thead>"
2176 "<tbody>");
2177 db_prepare(&stWeek, blob_str(&sql));
2178 blob_reset(&sql);
2179 while( SQLITE_ROW == db_step(&stWeek) ){
@@ -2185,11 +2176,11 @@
2185 db_reset(&stWeek);
2186 while( SQLITE_ROW == db_step(&stWeek) ){
2187 char const * zWeek = db_column_text(&stWeek,0);
2188 int const nCount = db_column_int(&stWeek,1);
2189 int const nSize = nCount
2190 ? (int)(1.0 * nCount / nMaxEvents * nStatReportLineWidth)
2191 : 0;
2192 total += nCount;
2193 cgi_printf("<tr class='row%d'>", ++rowCount % 2 );
2194 cgi_printf("<td><a href='%s/timeline?yw=%t-%s&n=%d",
2195 g.zTop, zYear, zWeek, nCount);
@@ -2200,11 +2191,11 @@
2200
2201 cgi_printf("<td>%d</td>",nCount);
2202 cgi_printf("<td>");
2203 if(nCount){
2204 cgi_printf("<div class='statistics-report-graph-line'"
2205 "style='height:16px;width:%dpx;'></div>",
2206 nSize);
2207 }
2208 cgi_printf("</td></tr>");
2209 }
2210 db_finalize(&stWeek);
2211
--- src/timeline.c
+++ src/timeline.c
@@ -1864,19 +1864,10 @@
1864 g.zTop, yearPart, zWeek,
1865 nCount, zWeek);
1866 }
1867 db_finalize(&stWeek);
1868 }
 
 
 
 
 
 
 
 
 
1869
1870 /*
1871 ** Implements the "byyear" and "bymonth" reports for /stats_report.
1872 ** If includeMonth is true then it generates the "bymonth" report,
1873 ** else the "byyear" report. If zUserName is not NULL and not empty
@@ -1924,11 +1915,11 @@
1915 @ <table class='statistics-report-table-events' border='0' cellpadding='2'
1916 @ cellspacing='0' id='statsTable'>
1917 @ <thead>
1918 @ <th>%s(zTimeLabel)</th>
1919 @ <th>Events</th>
1920 @ <th width='90%%'><!-- relative commits graph --></th>
1921 @ </thead><tbody>
1922 blob_reset(&header);
1923 /*
1924 Run the query twice. The first time we calculate the maximum
1925 number of events for a given row. Maybe someone with better SQL
@@ -1943,11 +1934,11 @@
1934 db_reset(&query);
1935 while( SQLITE_ROW == db_step(&query) ){
1936 char const * zTimeframe = db_column_text(&query, 0);
1937 int const nCount = db_column_int(&query, 1);
1938 int const nSize = nCount
1939 ? (int)(1.0 * nCount / nMaxEvents * 100)
1940 : 1;
1941 showYearTotal = 0;
1942 if(includeMonth){
1943 /* For Month/year view, add a separator for each distinct year. */
1944 if(!*zPrevYear ||
@@ -1992,11 +1983,11 @@
1983 cgi_printf("'>%s</a>", zTimeframe);
1984 }
1985 @ </td><td>%d(nCount)</td>
1986 @ <td>
1987 @ <div class='statistics-report-graph-line'
1988 @ style='height:16px;width:%d(nSize)%%;'>
1989 @ </div></td>
1990 @</tr>
1991 if(includeWeeks){
1992 /* This part works fine for months but it terribly slow (4.5s on my PC),
1993 so it's only shown for by-year for now. Suggestions/patches for
@@ -2060,11 +2051,11 @@
2051 @ <table class='statistics-report-table-events' border='0'
2052 @ cellpadding='2' cellspacing='0' id='statsTable'>
2053 @ <thead><tr>
2054 @ <th>User</th>
2055 @ <th>Events</th>
2056 @ <th width='90%%'><!-- relative commits graph --></th>
2057 @ </tr></thead><tbody>
2058 while( SQLITE_ROW == db_step(&query) ){
2059 int const nCount = db_column_int(&query, 1);
2060 if(nCount>nMaxEvents){
2061 nMaxEvents = nCount;
@@ -2073,11 +2064,11 @@
2064 db_reset(&query);
2065 while( SQLITE_ROW == db_step(&query) ){
2066 char const * zUser = db_column_text(&query, 0);
2067 int const nCount = db_column_int(&query, 1);
2068 int const nSize = nCount
2069 ? (int)(1.0 * nCount / nMaxEvents * 100)
2070 : 0;
2071 if(!nCount) continue /* arguable! Possible? */;
2072 rowClass = ++nRowNumber % 2;
2073 nEventTotal += nCount;
2074 @<tr class='row%d(rowClass)'>
@@ -2084,11 +2075,11 @@
2075 @ <td>
2076 @ <a href="?view=bymonth&user=%h(zUser)" target="_new">%h(zUser)</a>
2077 @ </td><td>%d(nCount)</td>
2078 @ <td>
2079 @ <div class='statistics-report-graph-line'
2080 @ style='height:16px;width:%d(nSize)%%;'>
2081 @ </div></td>
2082 @</tr>
2083 /*
2084 Potential improvement: calculate the min/max event counts and
2085 use percent-based graph bars.
@@ -2164,16 +2155,16 @@
2155 }
2156 blob_appendf(&sql, "GROUP BY wk ORDER BY wk DESC");
2157 cgi_printf("<h1>%h</h1>", blob_str(&header));
2158 blob_reset(&header);
2159 cgi_printf("<table class='statistics-report-table-events' "
2160 "border='0' cellpadding='2' width='100%%' "
2161 "cellspacing='0' id='statsTable'>");
2162 cgi_printf("<thead><tr>"
2163 "<th>Week</th>"
2164 "<th>Events</th>"
2165 "<th width='90%%'><!-- relative commits graph --></th>"
2166 "</tr></thead>"
2167 "<tbody>");
2168 db_prepare(&stWeek, blob_str(&sql));
2169 blob_reset(&sql);
2170 while( SQLITE_ROW == db_step(&stWeek) ){
@@ -2185,11 +2176,11 @@
2176 db_reset(&stWeek);
2177 while( SQLITE_ROW == db_step(&stWeek) ){
2178 char const * zWeek = db_column_text(&stWeek,0);
2179 int const nCount = db_column_int(&stWeek,1);
2180 int const nSize = nCount
2181 ? (int)(1.0 * nCount / nMaxEvents * 100)
2182 : 0;
2183 total += nCount;
2184 cgi_printf("<tr class='row%d'>", ++rowCount % 2 );
2185 cgi_printf("<td><a href='%s/timeline?yw=%t-%s&n=%d",
2186 g.zTop, zYear, zWeek, nCount);
@@ -2200,11 +2191,11 @@
2191
2192 cgi_printf("<td>%d</td>",nCount);
2193 cgi_printf("<td>");
2194 if(nCount){
2195 cgi_printf("<div class='statistics-report-graph-line'"
2196 "style='height:16px;width:%d%%;'></div>",
2197 nSize);
2198 }
2199 cgi_printf("</td></tr>");
2200 }
2201 db_finalize(&stWeek);
2202

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button