Fossil SCM
Removed the 500px baseline for /stats_report calculations, refactored the bars to now use percentage widths.
Commit
674a24a3603ed20124570d5f2e77a5c13b810fee
Parent
3c78bbb0829e58d…
1 file changed
+10
-19
+10
-19
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -1864,19 +1864,10 @@ | ||
| 1864 | 1864 | g.zTop, yearPart, zWeek, |
| 1865 | 1865 | nCount, zWeek); |
| 1866 | 1866 | } |
| 1867 | 1867 | db_finalize(&stWeek); |
| 1868 | 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 | 1869 | |
| 1879 | 1870 | /* |
| 1880 | 1871 | ** Implements the "byyear" and "bymonth" reports for /stats_report. |
| 1881 | 1872 | ** If includeMonth is true then it generates the "bymonth" report, |
| 1882 | 1873 | ** else the "byyear" report. If zUserName is not NULL and not empty |
| @@ -1924,11 +1915,11 @@ | ||
| 1924 | 1915 | @ <table class='statistics-report-table-events' border='0' cellpadding='2' |
| 1925 | 1916 | @ cellspacing='0' id='statsTable'> |
| 1926 | 1917 | @ <thead> |
| 1927 | 1918 | @ <th>%s(zTimeLabel)</th> |
| 1928 | 1919 | @ <th>Events</th> |
| 1929 | - @ <th><!-- relative commits graph --></th> | |
| 1920 | + @ <th width='90%%'><!-- relative commits graph --></th> | |
| 1930 | 1921 | @ </thead><tbody> |
| 1931 | 1922 | blob_reset(&header); |
| 1932 | 1923 | /* |
| 1933 | 1924 | Run the query twice. The first time we calculate the maximum |
| 1934 | 1925 | number of events for a given row. Maybe someone with better SQL |
| @@ -1943,11 +1934,11 @@ | ||
| 1943 | 1934 | db_reset(&query); |
| 1944 | 1935 | while( SQLITE_ROW == db_step(&query) ){ |
| 1945 | 1936 | char const * zTimeframe = db_column_text(&query, 0); |
| 1946 | 1937 | int const nCount = db_column_int(&query, 1); |
| 1947 | 1938 | int const nSize = nCount |
| 1948 | - ? (int)(1.0 * nCount / nMaxEvents * nStatReportLineWidth) | |
| 1939 | + ? (int)(1.0 * nCount / nMaxEvents * 100) | |
| 1949 | 1940 | : 1; |
| 1950 | 1941 | showYearTotal = 0; |
| 1951 | 1942 | if(includeMonth){ |
| 1952 | 1943 | /* For Month/year view, add a separator for each distinct year. */ |
| 1953 | 1944 | if(!*zPrevYear || |
| @@ -1992,11 +1983,11 @@ | ||
| 1992 | 1983 | cgi_printf("'>%s</a>", zTimeframe); |
| 1993 | 1984 | } |
| 1994 | 1985 | @ </td><td>%d(nCount)</td> |
| 1995 | 1986 | @ <td> |
| 1996 | 1987 | @ <div class='statistics-report-graph-line' |
| 1997 | - @ style='height:16px;width:%d(nSize)px;'> | |
| 1988 | + @ style='height:16px;width:%d(nSize)%%;'> | |
| 1998 | 1989 | @ </div></td> |
| 1999 | 1990 | @</tr> |
| 2000 | 1991 | if(includeWeeks){ |
| 2001 | 1992 | /* This part works fine for months but it terribly slow (4.5s on my PC), |
| 2002 | 1993 | so it's only shown for by-year for now. Suggestions/patches for |
| @@ -2060,11 +2051,11 @@ | ||
| 2060 | 2051 | @ <table class='statistics-report-table-events' border='0' |
| 2061 | 2052 | @ cellpadding='2' cellspacing='0' id='statsTable'> |
| 2062 | 2053 | @ <thead><tr> |
| 2063 | 2054 | @ <th>User</th> |
| 2064 | 2055 | @ <th>Events</th> |
| 2065 | - @ <th><!-- relative commits graph --></th> | |
| 2056 | + @ <th width='90%%'><!-- relative commits graph --></th> | |
| 2066 | 2057 | @ </tr></thead><tbody> |
| 2067 | 2058 | while( SQLITE_ROW == db_step(&query) ){ |
| 2068 | 2059 | int const nCount = db_column_int(&query, 1); |
| 2069 | 2060 | if(nCount>nMaxEvents){ |
| 2070 | 2061 | nMaxEvents = nCount; |
| @@ -2073,11 +2064,11 @@ | ||
| 2073 | 2064 | db_reset(&query); |
| 2074 | 2065 | while( SQLITE_ROW == db_step(&query) ){ |
| 2075 | 2066 | char const * zUser = db_column_text(&query, 0); |
| 2076 | 2067 | int const nCount = db_column_int(&query, 1); |
| 2077 | 2068 | int const nSize = nCount |
| 2078 | - ? (int)(1.0 * nCount / nMaxEvents * nStatReportLineWidth) | |
| 2069 | + ? (int)(1.0 * nCount / nMaxEvents * 100) | |
| 2079 | 2070 | : 0; |
| 2080 | 2071 | if(!nCount) continue /* arguable! Possible? */; |
| 2081 | 2072 | rowClass = ++nRowNumber % 2; |
| 2082 | 2073 | nEventTotal += nCount; |
| 2083 | 2074 | @<tr class='row%d(rowClass)'> |
| @@ -2084,11 +2075,11 @@ | ||
| 2084 | 2075 | @ <td> |
| 2085 | 2076 | @ <a href="?view=bymonth&user=%h(zUser)" target="_new">%h(zUser)</a> |
| 2086 | 2077 | @ </td><td>%d(nCount)</td> |
| 2087 | 2078 | @ <td> |
| 2088 | 2079 | @ <div class='statistics-report-graph-line' |
| 2089 | - @ style='height:16px;width:%d(nSize)px;'> | |
| 2080 | + @ style='height:16px;width:%d(nSize)%%;'> | |
| 2090 | 2081 | @ </div></td> |
| 2091 | 2082 | @</tr> |
| 2092 | 2083 | /* |
| 2093 | 2084 | Potential improvement: calculate the min/max event counts and |
| 2094 | 2085 | use percent-based graph bars. |
| @@ -2164,16 +2155,16 @@ | ||
| 2164 | 2155 | } |
| 2165 | 2156 | blob_appendf(&sql, "GROUP BY wk ORDER BY wk DESC"); |
| 2166 | 2157 | cgi_printf("<h1>%h</h1>", blob_str(&header)); |
| 2167 | 2158 | blob_reset(&header); |
| 2168 | 2159 | cgi_printf("<table class='statistics-report-table-events' " |
| 2169 | - "border='0' cellpadding='2' " | |
| 2160 | + "border='0' cellpadding='2' width='100%%' " | |
| 2170 | 2161 | "cellspacing='0' id='statsTable'>"); |
| 2171 | 2162 | cgi_printf("<thead><tr>" |
| 2172 | 2163 | "<th>Week</th>" |
| 2173 | 2164 | "<th>Events</th>" |
| 2174 | - "<th><!-- relative commits graph --></th>" | |
| 2165 | + "<th width='90%%'><!-- relative commits graph --></th>" | |
| 2175 | 2166 | "</tr></thead>" |
| 2176 | 2167 | "<tbody>"); |
| 2177 | 2168 | db_prepare(&stWeek, blob_str(&sql)); |
| 2178 | 2169 | blob_reset(&sql); |
| 2179 | 2170 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| @@ -2185,11 +2176,11 @@ | ||
| 2185 | 2176 | db_reset(&stWeek); |
| 2186 | 2177 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 2187 | 2178 | char const * zWeek = db_column_text(&stWeek,0); |
| 2188 | 2179 | int const nCount = db_column_int(&stWeek,1); |
| 2189 | 2180 | int const nSize = nCount |
| 2190 | - ? (int)(1.0 * nCount / nMaxEvents * nStatReportLineWidth) | |
| 2181 | + ? (int)(1.0 * nCount / nMaxEvents * 100) | |
| 2191 | 2182 | : 0; |
| 2192 | 2183 | total += nCount; |
| 2193 | 2184 | cgi_printf("<tr class='row%d'>", ++rowCount % 2 ); |
| 2194 | 2185 | cgi_printf("<td><a href='%s/timeline?yw=%t-%s&n=%d", |
| 2195 | 2186 | g.zTop, zYear, zWeek, nCount); |
| @@ -2200,11 +2191,11 @@ | ||
| 2200 | 2191 | |
| 2201 | 2192 | cgi_printf("<td>%d</td>",nCount); |
| 2202 | 2193 | cgi_printf("<td>"); |
| 2203 | 2194 | if(nCount){ |
| 2204 | 2195 | cgi_printf("<div class='statistics-report-graph-line'" |
| 2205 | - "style='height:16px;width:%dpx;'></div>", | |
| 2196 | + "style='height:16px;width:%d%%;'></div>", | |
| 2206 | 2197 | nSize); |
| 2207 | 2198 | } |
| 2208 | 2199 | cgi_printf("</td></tr>"); |
| 2209 | 2200 | } |
| 2210 | 2201 | db_finalize(&stWeek); |
| 2211 | 2202 |
| --- 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 |