Add extra class specifier to histograms

sql-rework
Tomasz Golinski 2020-03-19 18:31:35 +01:00
rodzic fe6f540bd7
commit 62129dca09
1 zmienionych plików z 9 dodań i 1 usunięć

Wyświetl plik

@ -50,6 +50,14 @@ void show_histogram(const Caches& cc, std::string Cache::*ptr, const std::string
sort(pairs.begin(), pairs.end(), [&](std::pair<std::string, int>& a, std::pair<std::string, int>& b) { return a.first < b.first; });
if (html) {
std::string id;
id.reserve(caption.size());
for (size_t i = 0; i != caption.size(); i++) {
if (caption[i] == ' ') continue;
if (std::isupper(caption[i])) id.push_back(std::tolower(caption[i]));
else id.push_back(caption[i]);
}
int max;
if (sort_by_val)
max = pairs[0].second;
@ -57,7 +65,7 @@ void show_histogram(const Caches& cc, std::string Cache::*ptr, const std::string
max = std::max_element(pairs.begin(), pairs.end(), [&](std::pair<std::string, int>& a, std::pair<std::string, int>& b) { return a.second < b.second; })->second;
int i = 0;
std::cout << "<h2>" << caption << "</h2>\n";
std::cout << "<div class=\"histogram\">\n";
std::cout << "<div class=\"histogram " << id << "\">\n";
for (auto own : pairs) {
htmlencode(own.first);
if (own.first.empty()) own.first = "[unknown]";