kopia lustrzana https://gitlab.com/tomaszg/geostat
Add (disabled) histogram with caching timeline.
Disabled since it gets too wide for old users. Maybe it would be better to css style a table to become a histogram.sql-rework
rodzic
798cfd48b3
commit
cfd521b43c
|
@ -59,6 +59,8 @@ void Cache::set_date(const std::tm& t) {
|
|||
hour = std::to_string(date_tm.tm_hour);
|
||||
std::strftime(tmp, 20, "(%u) %A", &date_tm);
|
||||
day_of_week = tmp;
|
||||
std::strftime(tmp, 20, "%Y %m", &date_tm);
|
||||
year_month = tmp;
|
||||
|
||||
std::strftime(tmp, 20, "%F", &date_tm);
|
||||
date = tmp;
|
||||
|
|
1
cache.h
1
cache.h
|
@ -71,6 +71,7 @@ public:
|
|||
std::time_t date_hidden_t;
|
||||
std::tm date_tm;
|
||||
std::tm date_hidden_tm;
|
||||
std::string year_month;
|
||||
std::string year;
|
||||
std::string mon;
|
||||
std::string day;
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
#include <vector>
|
||||
#include <iterator>
|
||||
|
||||
const int HIST_MAX = 20;
|
||||
|
||||
void htmlencode(std::string& data) {
|
||||
std::string tmp;
|
||||
tmp.reserve(data.size() + 20);
|
||||
|
@ -37,9 +35,13 @@ void htmlencode(std::string& data) {
|
|||
}
|
||||
|
||||
void show_histogram(const Caches& cc, std::string Cache::*ptr, const std::string& caption, bool html, bool sort_by_val) {
|
||||
int HIST_MAX = 20;
|
||||
|
||||
std::map<std::string, int> histogram;
|
||||
std::vector<std::pair<std::string, int>> pairs;
|
||||
|
||||
if (!sort_by_val) HIST_MAX = 1000;
|
||||
|
||||
for (auto el : cc)
|
||||
histogram[el.*ptr]++;
|
||||
std::copy(histogram.begin(), histogram.end(), std::back_inserter(pairs));
|
||||
|
|
36
geo.css
36
geo.css
|
@ -166,6 +166,42 @@ td.dt_zero {
|
|||
padding-top: 0;
|
||||
}
|
||||
|
||||
/* horizontal histogram */
|
||||
|
||||
.histogram.cachingtimeline {
|
||||
flex-direction: row;
|
||||
width: auto;
|
||||
max-width: none;
|
||||
height: 10em;
|
||||
position: static;
|
||||
padding: 0 0 3em 0;
|
||||
align-items: end;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.cachingtimeline > .bar {
|
||||
display: flex;
|
||||
font-size: 1em;
|
||||
line-height: 1;
|
||||
width: 65px;
|
||||
height: var(--percent);
|
||||
background-image: linear-gradient(to right, #7c7 50%, #668);
|
||||
margin: 0 5px;
|
||||
align-items: end;
|
||||
}
|
||||
|
||||
.cachingtimeline > .bar:after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.cachingtimeline > .bar > .text {
|
||||
display: block;
|
||||
height: auto;
|
||||
width: auto;
|
||||
position: relative;
|
||||
top: 2.5em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* collapsible */
|
||||
|
||||
|
|
|
@ -287,7 +287,7 @@ int main(int argc, char** argv) {
|
|||
std::cout << "<html lang=\"en\">\n";
|
||||
std::cout << " <head>\n";
|
||||
std::cout << " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n";
|
||||
std::cout << " <link rel=\"stylesheet\" type=\"text/css\" href=\"geo.css?ver=9\">\n";
|
||||
std::cout << " <link rel=\"stylesheet\" type=\"text/css\" href=\"geo.css?ver=10\">\n";
|
||||
std::cout << " <title>Geocaching stats</title>\n";
|
||||
std::cout << "</head>\n";
|
||||
std::cout << "<body>\n";
|
||||
|
@ -390,6 +390,7 @@ int main(int argc, char** argv) {
|
|||
// std::cout << "Furthest cache: " << far->distance() << " km\n";
|
||||
// far->show();
|
||||
|
||||
// show_histogram(cc, &Cache::year_month, "Caching timeline", 1, 0);
|
||||
show_histogram(cc, &Cache::owner, "Cache owners", 1);
|
||||
show_histogram(cc, &Cache::type, "Cache types", 1);
|
||||
show_histogram(cc, &Cache::size, "Cache sizes", 1);
|
||||
|
|
Ładowanie…
Reference in New Issue