The statistics as five pages of the notebook with markers of their own

Analysis (the club's season as figures and charts), course (the recorded series as
curves, the seasons' finances), winners under their trophies, records (all-time
table, series and records, world cups) and players (transfer history, minutes,
chances). A page with several kinds shows them as tabs; the old list of kinds in
the foot is gone in a career.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-15 20:20:18 +01:00
1 parent 9d94d05db1
commit 9f164b4d61
8 files changed
+239 -173

No files matched your search

+41
View File
@@ -466,3 +466,44 @@ body .pg-btn.pg-go[disabled] {opacity:1;background-color:var(--p-a3);border-colo
.nw-excerpt {display:block;font-size:28dp;line-height:36dp;}
.nw-body {display:block;font-size:36dp;line-height:54dp;}
.pg-root .news-art,.pg-ov .news-art {background-color:transparent;}
/* --- statistics: the club's season as charts, and the archive --- */
.st-course-panel {flex:1.15;}
.st-course {display:flex;flex:none;justify-content:center;}
.st-strip {display:flex;flex:none;gap:6dp;height:100dp;border-radius:18dp;decorator:linear-gradient(180deg,#00000000 0%,#00000000 48%,var(--p-n4) 48%,var(--p-n4) 52%,#00000000 52%,#00000000 100%);}
.st-strip-column {display:block;position:relative;flex:1;max-width:100dp;height:100dp;}
.st-strip-column div {position:absolute;left:10%;right:10%;border-radius:7dp;}
.st-strip-column .won,.st-won {background-color:var(--p-s7);}
.st-strip-column .lost {background-color:var(--p-a7);}
.st-strip-column .drawn {background-color:var(--p-n5);}
.st-lost {background-color:var(--p-a4);}
.st-minutes {display:flex;flex:1;align-items:flex-end;gap:14dp;}
.st-minute {display:flex;flex:1;flex-direction:column;align-items:center;gap:6dp;}
.st-minute-bars {display:flex;align-items:flex-end;gap:9dp;height:260dp;}
.st-minute-bars div {width:45dp;border-radius:11dp 11dp 0 0;}
.st-minute small {display:block;font-size:24dp;line-height:30dp;color:var(--p-n7);}
.st-minute strong {display:block;font-size:26dp;line-height:32dp;font-weight:bold;}
.st-stack {display:flex;flex:1;height:50dp;border-radius:18dp;overflow:hidden;font-size:26dp;font-weight:bold;}
.st-stack div {display:block;height:50dp;line-height:50dp;text-align:center;overflow:hidden;}
.st-stack span {display:block;white-space:nowrap;}
.st-stack .won {background-color:var(--p-s7);color:var(--p-n1);}
.st-stack .drawn {background-color:var(--p-n4);color:var(--p-n9);}
.st-stack .lost {background-color:var(--p-a8);color:var(--p-n1);}
.st-stack .none {background-color:var(--p-n2);color:var(--p-n7);font-weight:normal;}
.st-reading {display:block;font-size:29dp;line-height:40dp;}
.st-scorer {display:block;flex:none;padding:6dp 0;}
.st-scorer-bar {display:flex;height:16dp;margin-top:6dp;border-radius:8dp;background-color:var(--p-n3);overflow:hidden;}
.st-scorer-bar .goals {height:16dp;background-color:var(--p-a6);}
.st-scorer-bar .assists {height:16dp;background-color:var(--p-a3);}
.st-graph {display:flex;flex:1;align-items:center;justify-content:center;min-height:0;}
.st-th {display:flex;align-items:center;gap:12dp;padding:0 18dp;}
.st-th.r {justify-content:flex-end;} .st-th.c {justify-content:center;}
.st-th span {display:block;}
.pg-thead.st-trophies {height:372dp;align-items:flex-end;padding-bottom:14dp;}
.pg-root .st-trophy,.pg-root .st-trophy:hover {align-items:center;width:100%;gap:8dp;padding:16dp 12dp;}
.st-trophy-art {display:block;width:230dp;height:230dp;}
.st-trophy-name {font-size:32dp;line-height:40dp;text-align:center;letter-spacing:0dp;color:var(--p-text);}
.st-trophy-small {display:block;flex:none;width:88dp;height:88dp;}
.st-td .pg-link {max-width:100%;}
.st-text {display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.pg-root .pg-dd .report-picker-popup {min-width:560dp;}
+1 -1
View File
@@ -483,7 +483,7 @@ void App::engine_event(Rml::Event &event) {
else if(action=="engine-open"&&id=="transfer"){menu_=id;transfer_view_=Json::object();transfer_dialog_.clear();engine_transfer_sync();refresh();}
else if(action=="engine-open"&&id=="stadium"){menu_=id;stadium_view_=Json::object();stadium_view_defaults(stadium_view_);engine_stadium_sync();refresh();}
else if(action=="engine-open"&&id=="toto"){menu_=id;engine_toto_sync();refresh();}
else if(action=="engine-open"&&id=="statistics"){menu_=id;engine_reports_sync();engine_statistics_load();}
else if(action=="engine-open"&&(id=="statistics"||id.starts_with("stat-"))){statistics_open(id);}
else if(action=="engine-open"&&id=="load"){engine_files_begin("load");}
else if(action=="engine-open"&&id=="scorers"){menu_=id;engine_reports_sync();engine_rankings_load(engine_rankings_state_.at("league"),engine_rankings_state_.at("scope"));}
else if(action=="engine-open"&&id=="fairplay"){menu_=id;engine_reports_sync();engine_fairplay_load();}
+7 -4
View File
@@ -17,7 +17,7 @@ const std::vector<NotebookSection> &notebook_sections() {
{"club", "Verein", {"stadium", "environment", "advertising"}},
{"finance", "Finanzen", {"balance", "bank", "toto"}},
{"fixtures", "Spielplan", {"calendar", "league", "tables", "other", "friendlies", "postpone", "indoor"}},
{"records", "Statistik", {"statistics", "achievements", "almanac", "fairplay", "highscore"}},
{"records", "Statistik", {"statistics", "stat-trend", "stat-winners", "stat-records", "stat-players", "achievements", "almanac", "fairplay", "highscore"}},
{"inbox", "Posteingang", {"news"}},
{"options", "Optionen", {"settings", "save", "load", "newplayer"}}};
return value;
@@ -28,7 +28,7 @@ std::string notebook_page_label(const std::string &route) {
{"scorers", "Spielerstatistik"}, {"transfer", "Transfermarkt"}, {"contracts", "Verträge"}, {"stadium", "Stadion"}, {"environment", "Umfeld"},
{"advertising", "Werbung"}, {"balance", "Bilanz"}, {"bank", "Bank"}, {"toto", "Toto"}, {"calendar", "Kalender"}, {"league", "Ligaspiele"},
{"tables", "Tabellen"}, {"other", "Übrige Spiele"}, {"friendlies", "Testspiele"}, {"postpone", "Verlegen"}, {"indoor", "Halle"},
{"statistics", "Statistiken"}, {"achievements", "Erfolge"}, {"almanac", "Almanach"}, {"fairplay", "Fairplay"}, {"highscore", "Highscore"},
{"statistics", "Analyse"}, {"stat-trend", "Verlauf"}, {"stat-winners", "Sieger"}, {"stat-records", "Rekorde"}, {"stat-players", "Spieler"}, {"achievements", "Erfolge"}, {"almanac", "Almanach"}, {"fairplay", "Fairplay"}, {"highscore", "Highscore"},
{"news", "Nachrichten"}, {"settings", "Einstellungen"}, {"save", "Speichern"}, {"load", "Laden"}, {"newplayer", "Manager"}};
const auto found = labels.find(route);
return found == labels.end() ? route : found->second;
@@ -198,7 +198,10 @@ std::string App::notebook_shell(const std::function<bool(const std::string &)> &
}
size_t n = 0;
for (const char *r : section.routes) {
const bool here = menu_ == r;
// the statistics are one menu with several pages; the demo has only its first
const bool part = std::string_view(r).starts_with("stat-") || std::string_view(r) == "statistics";
if (!engine_mode_ && std::string_view(r).starts_with("stat-")) continue;
const bool here = part && engine_mode_ ? menu_ == "statistics" && statistics_page_ == r : menu_ == r;
if (here) {
kicker = std::string(section.label) + " · " + std::to_string(n + 1) + " / " + std::to_string(section.routes.size());
heading = notebook_page_label(r);
@@ -207,7 +210,7 @@ std::string App::notebook_shell(const std::function<bool(const std::string &)> &
std::string("nb-sub") + (here ? " active" : ""),
"id=\"page-" + std::string(r) + "\" aria-pressed=\"" + (here ? "true" : "false") + "\" style=\"transform:translateY(" + (here ? std::string("-13") : std::to_string(sub_rest[n % sub_rest.size()])) + "dp) rotate(" +
scalar(sub_turns[n % sub_turns.size()]) + "deg);\"",
enabled(r));
enabled(part ? "statistics" : r));
++n;
}
}
+1 -1
View File
@@ -5,7 +5,7 @@
// The menus that are laid out as a page of the notebook. Every other career menu is still a
// sheet of the old format, shown scaled inside the book.
bool App::page_native() const {
static const std::set<std::string> native{"news", "transfer", "training", "almanac", "tactics", "achievements", "highscore", "balance", "contracts", "environment", "tables", "league", "other", "strengths", "fairplay", "indoor", "scorers"};
static const std::set<std::string> native{"statistics", "news", "transfer", "training", "almanac", "tactics", "achievements", "highscore", "balance", "contracts", "environment", "tables", "league", "other", "strengths", "fairplay", "indoor", "scorers"};
if (menu_ == "calendar" || menu_ == "postpone" || menu_ == "lineup") return notebook_page() && engine_mode_;
// a national coach arranges friendlies on the older sheet
if (menu_ == "friendlies") return notebook_page() && engine_mode_ && engine_data_.contains("desktop") && engine_data_.at("desktop").at("meta").at("scope").at("role") == "club";
+92 -112
View File
@@ -1,35 +1,30 @@
// SPDX-License-Identifier: GPL-3.0-only
// The club's running season as charts, counted by the engine from the almanac
// (read "analysis", modern::club_analysis). Bars are plain boxes so that every figure is
// type; only the points course is a drawing.
// The club's running season as a page of figures and charts, counted by the engine from the
// almanac (read "analysis", modern::club_analysis). Bars are plain boxes so that every figure
// is type; only the points course is a drawing.
std::string App::render_statistics_analysis() {
const auto tabs = [&](const std::string &current) {
std::string out = "<nav class=\"bank-tabs an-tabs\" aria-label=\"Statistikansicht\">";
std::string out = "<nav class=\"pg-tabs\" aria-label=\"Statistikansicht\">";
for (const auto &[id, label] : std::array<std::pair<const char *, const char *>, 2>{{{"analysis", "Vereinsanalyse"}, {"archive", "Archiv"}}})
out += btn("statistics-mode", label, std::string("bank-tab") + (current == id ? " selected" : ""),
"id=\"statistics-mode-" + std::string(id) + "\" data-id=\"" + id + "\" aria-pressed=\"" + (current == id ? "true" : "false") + "\"");
out += btn("statistics-mode", "<span>" + std::string(label) + "</span>", current == id ? "on" : "", "id=\"statistics-mode-" + std::string(id) + "\" data-id=\"" + id + "\" aria-pressed=\"" + (current == id ? "true" : "false") + "\"");
return out + "</nav>";
};
std::string out = "<section class=\"statistics-native an-screen\"><div class=\"an-head\"><div class=\"bank-brand\"><strong>Statistiken</strong><span>Vereinsanalyse</span></div>" + tabs("analysis") + "</div>";
(void)tabs;
std::string out = "<section class=\"pg-page statistics-native\"><div class=\"pg-row\">";
const auto &data = engine_analysis_value_;
if (!data.is_object() || !data.value("available", false))
return out + "<p class=\"an-empty\">" + std::string(engine_busy_ ? "Die Auswertung wird geladen …" : "In dieser Saison ist noch kein Spiel aufgezeichnet.") + "</p></section>";
const auto one = [](double value) {
return out + "</div><div class=\"pg-empty\">" + std::string(engine_busy_ ? "Die Auswertung wird geladen …" : "In dieser Saison ist noch kein Spiel aufgezeichnet.") + "</div></section>";
const auto fixed = [](double value, int digits) {
std::ostringstream text;
text << std::fixed << std::setprecision(1) << value;
text << std::fixed << std::setprecision(digits) << value;
auto result = text.str();
std::replace(result.begin(), result.end(), '.', ',');
return result;
};
const auto two = [](double value) {
std::ostringstream text;
text << std::fixed << std::setprecision(2) << value;
auto result = text.str();
std::replace(result.begin(), result.end(), '.', ',');
return result;
};
const auto card = [](const std::string &css, double x, double y, double w, double h, const std::string &title, const std::string &body) {
return "<div class=\"an-card " + css + "\" style=\"" + rect(x, y, w, h) + "\"><h3>" + title + "</h3>" + body + "</div>";
const auto one = [&](double value) { return fixed(value, 1); };
const auto two = [&](double value) { return fixed(value, 2); };
const auto panel = [&](const std::string &title, const std::string &body, const std::string &css = "pg-grow") {
return "<div class=\"pg-panel pg-col " + css + "\" style=\"" + pg_css("gap:6px;padding:10px 14px;") + "\">" + pg_kicker(title) + body + "</div>";
};
const auto &matches = data.at("matches"), &points = data.at("points"), &league = data.at("league");
const int played = int(matches.size()), league_played = int(points.size());
@@ -40,119 +35,85 @@ std::string App::render_statistics_analysis() {
const double conversion = chances_for ? goals_for * 100.0 / chances_for : 0;
const double league_conversion = league.at("chances").get<int64_t>() ? league.at("goals").get<double>() * 100.0 / league.at("chances").get<double>() : 0;
const int year = data.value("year", 0);
out += "<p class=\"an-sub\">Saison " + std::to_string(year) + "/" + (year % 100 + 1 < 10 ? "0" : "") + std::to_string((year + 1) % 100) +
(data.value("leagueName", std::string()).empty() ? "" : " · " + esc(data.at("leagueName").get<std::string>())) + " · alle Pflicht- und Testspiele aus dem Spielarchiv</p>";
out += "<span class=\"pg-mut pg-grow\">Saison " + std::to_string(year) + "/" + (year % 100 + 1 < 10 ? "0" : "") + std::to_string((year + 1) % 100) +
(data.value("leagueName", std::string()).empty() ? "" : " · " + esc(data.at("leagueName").get<std::string>())) + " · alle Pflicht- und Testspiele aus dem Spielarchiv</span></div>";
// the figures a manager asks for first
const std::array<std::array<std::string, 3>, 6> tiles{{
{std::to_string(played), "Spiele", std::to_string(league_played) + " in der Liga"},
{two(pace), "Punkte je Ligaspiel", "Liga-Schnitt " + two(league_pace)},
{std::to_string(goals_for), "Tore", played ? one(double(goals_for) / played) + " je Spiel" : ""},
{std::to_string(goals_against), "Gegentore", played ? one(double(goals_against) / played) + " je Spiel" : ""},
{one(conversion) + " %", "Chancenverwertung", "Liga-Schnitt " + one(league_conversion) + " %"},
{std::to_string(data.at("cards").at("yellow").get<int>()) + " / " + std::to_string(data.at("cards").at("red").get<int>()), "Gelbe / Rote Karten",
"Gegner " + std::to_string(data.at("cards").at("yellowAgainst").get<int>()) + " / " + std::to_string(data.at("cards").at("redAgainst").get<int>())}}};
for (size_t i = 0; i < tiles.size(); ++i)
out += "<div class=\"an-tile\" style=\"" + rect(30 + double(i) * 428.666, 230, 408.666, 230) + "\"><strong>" + tiles[i][0] + "</strong><span>" + tiles[i][1] + "</span><small>" + tiles[i][2] + "</small></div>";
out += "<div class=\"pg-row\" style=\"" + pg_css("gap:8px;") + "align-items:stretch;\">" + pg_stat("Spiele", std::to_string(played), "davon Liga " + std::to_string(league_played)) + pg_stat("Punkte je Ligaspiel", two(pace), "Liga-Schnitt " + two(league_pace)) +
pg_stat("Tore", std::to_string(goals_for), played ? one(double(goals_for) / played) + " je Spiel" : std::string()) + pg_stat("Gegentore", std::to_string(goals_against), played ? one(double(goals_against) / played) + " je Spiel" : std::string()) +
pg_stat("Chancenverwertung", one(conversion) + " %", "Liga-Schnitt " + one(league_conversion) + " %") +
pg_stat("Gelbe / Rote Karten", std::to_string(data.at("cards").at("yellow").get<int>()) + " / " + std::to_string(data.at("cards").at("red").get<int>()),
"Gegner " + std::to_string(data.at("cards").at("yellowAgainst").get<int>()) + " / " + std::to_string(data.at("cards").at("redAgainst").get<int>())) + "</div><div class=\"pg-body\" style=\"" + pg_css("gap:10px;") + "\">";
const std::string line = theme_ == "silver" ? "#8c491a" : theme_ == "matchday" ? "#2f602c" : "#ebb87f", grey = theme_ == "silver" ? "#82796a" : theme_ == "matchday" ? "#6d7f5b" : "#8f95a1", faint = theme_ == "midnight" ? "#f0ece21c" : "#201e1d1a";
// points after each league match beside the league's average pace; below it every match
{
std::string body;
if (league_played > 1) {
const double top = std::max({points.back().get<double>(), league_pace * league_played, 3.0}) * 1.12;
const auto px = [&](double match) { return 20 + match * 1400.0 / league_played; };
const auto py = [&](double value) { return 300 - value / top * 280; };
const std::string line = theme_ == "silver" ? "#25617a" : "#9ac7d8", gold = theme_ == "silver" ? "#9a7a3a" : "#d9bd7c", faint = theme_ == "silver" ? "#4a433430" : "#dfeaf530";
std::string svg = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 1440 320\"><defs><linearGradient id=\"under\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"" + line +
"\" stop-opacity=\".30\"/><stop offset=\"1\" stop-color=\"" + line + "\" stop-opacity=\".02\"/></linearGradient></defs>";
for (int row = 0; row < 4; ++row) svg += "<line x1=\"20\" y1=\"" + scalar(20 + row * 93.3) + "\" x2=\"1420\" y2=\"" + scalar(20 + row * 93.3) + "\" stroke=\"" + faint + "\" stroke-width=\"2\"/>";
std::string course = scalar(px(0)) + "," + scalar(py(0)) + " ";
for (int i = 0; i < league_played; ++i) course += scalar(px(i + 1)) + "," + scalar(py(points[size_t(i)].get<double>())) + " ";
svg += "<polygon points=\"" + course + scalar(px(league_played)) + ",300\" fill=\"url(#under)\"/><line x1=\"" + scalar(px(0)) + "\" y1=\"" + scalar(py(0)) + "\" x2=\"" + scalar(px(league_played)) + "\" y2=\"" +
scalar(py(league_pace * league_played)) + "\" stroke=\"" + gold + "\" stroke-width=\"5\" stroke-dasharray=\"16 12\"/><polyline points=\"" + course + "\" fill=\"none\" stroke=\"" + line +
"\" stroke-width=\"7\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/><circle cx=\"" + scalar(px(league_played)) + "\" cy=\"" + scalar(py(points.back().get<double>())) + "\" r=\"11\" fill=\"" + line + "\"/></svg>";
body += "<div class=\"an-course\">" + picture(renderer_.diagram("analysis-course", svg, 2880), 1440, 320) + "</div><div class=\"an-axis\"><span>1. Spieltag</span><div class=\"an-legend\"><span class=\"key own\"></span><span>" +
std::to_string(points.back().get<int>()) + " Punkte</span><span class=\"key pace\"></span><span>Liga-Schnitt " + std::to_string(int(std::lround(league_pace * league_played))) + "</span></div><span>" +
std::to_string(league_played) + ". Spieltag</span></div>";
} else body += "<p class=\"an-none\">Der Punkteverlauf beginnt mit dem zweiten Ligaspiel.</p>";
body += "<h4>Alle Spiele · Höhe nach Tordifferenz</h4><div class=\"an-strip\">";
const size_t shown = std::min<size_t>(matches.size(), 40), start = matches.size() - shown;
for (size_t i = start; i < matches.size(); ++i) {
const auto &m = matches[i];
const int balance = m.at("goalsFor").get<int>() - m.at("goalsAgainst").get<int>();
const double height = std::min(std::abs(balance), 4) * 22.0;
const auto label = esc(std::string(m.at("home").get<bool>() ? "Heim" : "Auswärts") + " gegen " + m.at("opponent").get<std::string>() + " " + std::to_string(m.at("goalsFor").get<int>()) + ":" + std::to_string(m.at("goalsAgainst").get<int>()));
body += "<div class=\"an-strip-column\" title=\"" + label + "\"><div class=\"rise\">" + (balance > 0 ? "<div class=\"bar won\" style=\"height:" + scalar(height) + "dp;\"></div>" : std::string()) +
"</div><div class=\"mid " + (balance ? "" : "drawn") + "\"></div><div class=\"fall\">" + (balance < 0 ? "<div class=\"bar lost\" style=\"height:" + scalar(height) + "dp;\"></div>" : std::string()) + "</div></div>";
// --- left: the points course with every match under it, then the goals by quarter of an hour ---
std::string course;
if (league_played > 1) {
const double top = std::max({points.back().get<double>(), league_pace * league_played, 3.0}) * 1.12;
const auto px = [&](double match) { return 20 + match * 1400.0 / league_played; };
const auto py = [&](double value) { return 300 - value / top * 280; };
std::string svg = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 1440 320\">";
for (int row = 0; row < 4; ++row) svg += "<line x1=\"20\" y1=\"" + scalar(20 + row * 93.3) + "\" x2=\"1420\" y2=\"" + scalar(20 + row * 93.3) + "\" stroke=\"" + faint + "\" stroke-width=\"2\"/>";
std::string path = scalar(px(0)) + "," + scalar(py(0)) + " ", dots;
for (int i = 0; i < league_played; ++i) {
path += scalar(px(i + 1)) + "," + scalar(py(points[size_t(i)].get<double>())) + " ";
dots += "<circle cx=\"" + scalar(px(i + 1)) + "\" cy=\"" + scalar(py(points[size_t(i)].get<double>())) + "\" r=\"8\" fill=\"" + line + "\"/>";
}
out += card("an-points", 30, 490, 1500, 710, "Punkteverlauf", body + "</div>");
svg += "<line x1=\"" + scalar(px(0)) + "\" y1=\"" + scalar(py(0)) + "\" x2=\"" + scalar(px(league_played)) + "\" y2=\"" + scalar(py(league_pace * league_played)) + "\" stroke=\"" + grey + "\" stroke-width=\"5\" stroke-dasharray=\"14 12\"/><polyline points=\"" + path +
"\" fill=\"none\" stroke=\"" + line + "\" stroke-width=\"7\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/>" + dots + "</svg>";
course = "<div class=\"pg-legend\"><span class=\"pg-legend-item\"><span class=\"pg-legend-mark\" style=\"height:9dp;background-color:" + line + ";\"></span><span>" + std::to_string(points.back().get<int>()) +
" Punkte</span></span><span class=\"pg-legend-item\"><span class=\"pg-legend-mark\" style=\"height:9dp;background-color:" + grey + ";\"></span><span>Liga-Schnitt " + std::to_string(int(std::lround(league_pace * league_played))) +
"</span></span></div><div class=\"st-course\">" + picture(renderer_.diagram("analysis-course-" + theme_, svg, 2880), 1070, 238) + "</div><div class=\"pg-row pg-mut\" style=\"justify-content:space-between;font-size:" + pg(11) + ";\"><span>1. Spieltag</span><span>" +
std::to_string(league_played) + ". Spieltag</span></div>";
} else course = "<span class=\"pg-mut\" style=\"display:block;\">Der Punkteverlauf beginnt mit dem zweiten Ligaspiel.</span>";
course += "<span class=\"pg-mut\" style=\"display:block;font-size:" + pg(11.5) + ";\">Alle Spiele · Höhe nach Tordifferenz</span><div class=\"st-strip\">";
for (size_t i = matches.size() - std::min<size_t>(matches.size(), 40); i < matches.size(); ++i) {
const auto &m = matches[i];
const int balance = m.at("goalsFor").get<int>() - m.at("goalsAgainst").get<int>();
const double height = std::max(7.0, std::min(std::abs(balance), 4) * 12.0);
course += "<div class=\"st-strip-column\" title=\"" + esc(std::string(m.at("home").get<bool>() ? "Heim" : "Auswärts") + " gegen " + m.at("opponent").get<std::string>() + " " + std::to_string(m.at("goalsFor").get<int>()) + ":" + std::to_string(m.at("goalsAgainst").get<int>())) +
"\"><div class=\"" + (balance > 0 ? "won" : balance < 0 ? "lost" : "drawn") + "\" style=\"height:" + scalar(height) + "dp;" + (balance >= 0 ? "bottom:50%;" : "top:50%;") + "\"></div></div>";
}
// home and away, and what the first goal decided
{
const auto bar = [&](const std::string &label, const Json &r, const std::string &extra) {
const int games = r.at("played");
std::string row = "<div class=\"an-record\"><div class=\"an-record-head\"><span>" + label + "</span><strong>" + extra + "</strong></div><div class=\"an-stack\">";
for (const auto &[key, css, letter] : std::array<std::tuple<const char *, const char *, const char *>, 3>{{{"won", "won", "S"}, {"drawn", "drawn", "U"}, {"lost", "lost", "N"}}}) {
const int count = r.at(key);
if (count) row += "<div class=\"" + std::string(css) + "\" style=\"width:" + scalar(count * 100.0 / std::max(1, games)) + "%;\"><span>" + std::to_string(count) + " " + letter + "</span></div>";
}
if (!games) row += "<div class=\"none\" style=\"width:100%;\"><span>kein Spiel</span></div>";
return row + "</div></div>";
};
const auto ppg = [&](const Json &r) { return r.at("played").get<int>() ? two(r.at("points").get<double>() / r.at("played").get<double>()) + " Punkte je Spiel · " + std::to_string(r.at("goalsFor").get<int>()) + ":" + std::to_string(r.at("goalsAgainst").get<int>()) + " Tore" : std::string("—"); };
const auto share = [&](const Json &r) { return r.at("played").get<int>() ? std::to_string(int(std::lround(r.at("won").get<double>() * 100 / r.at("played").get<double>()))) + " % gewonnen" : std::string("—"); };
out += card("an-records", 1550, 490, 1032, 710, "Heim und Auswärts",
bar("Heim", data.at("home"), ppg(data.at("home"))) + bar("Auswärts", data.at("away"), ppg(data.at("away"))) +
"<h4>Das erste Tor</h4>" + bar("Selbst zuerst getroffen", data.at("firstFor"), share(data.at("firstFor"))) +
bar("Gegner trifft zuerst", data.at("firstAgainst"), share(data.at("firstAgainst"))));
}
// goals by quarter of an hour: scored upwards, conceded downwards
course += "</div>";
int best_bucket = 0, worst_bucket = 0;
std::string minutes = "<div class=\"pg-legend\"><span class=\"pg-legend-item\"><span class=\"pg-legend-mark st-won\"></span><span>erzielt</span></span><span class=\"pg-legend-item\"><span class=\"pg-legend-mark st-lost\"></span><span>kassiert</span></span></div><div class=\"st-minutes\">";
{
const auto &buckets = data.at("buckets");
int greatest = 1;
for (const auto &b : buckets) greatest = std::max({greatest, b.at("for").get<int>(), b.at("against").get<int>()});
std::string body = "<div class=\"an-minutes\">";
for (size_t i = 0; i < buckets.size(); ++i) {
const int scored = buckets[i].at("for"), conceded = buckets[i].at("against");
if (scored > buckets[size_t(best_bucket)].at("for").get<int>()) best_bucket = int(i);
if (conceded > buckets[size_t(worst_bucket)].at("against").get<int>()) worst_bucket = int(i);
const int from = buckets[i].at("from");
body += "<div class=\"an-minute\"><div class=\"rise\"><span>" + std::to_string(scored) + "</span><div class=\"bar won\" style=\"height:" + scalar(scored * 190.0 / greatest) + "dp;\"></div></div><strong>" +
std::to_string(from) + "–" + (i + 1 == buckets.size() ? "Ende" : std::to_string(from + 14)) + "</strong><div class=\"fall\"><div class=\"bar lost\" style=\"height:" + scalar(conceded * 190.0 / greatest) +
"dp;\"></div><span>" + std::to_string(conceded) + "</span></div></div>";
minutes += "<div class=\"st-minute\"><div class=\"st-minute-bars\"><div class=\"st-won\" style=\"height:" + scalar(std::max(4.0, scored * 250.0 / greatest)) + "dp;\"></div><div class=\"st-lost\" style=\"height:" + scalar(std::max(4.0, conceded * 250.0 / greatest)) +
"dp;\"></div></div><small>" + std::to_string(from) + "–" + (i + 1 == buckets.size() ? "Ende" : std::to_string(from + 14)) + "</small><strong>" + std::to_string(scored) + " : " + std::to_string(conceded) + "</strong></div>";
}
out += card("an-minutes-card", 30, 1230, 960, 620, "Tore nach Spielminute", body + "</div><div class=\"an-axis\"><div class=\"an-legend\"><span class=\"key won\"></span><span>erzielt</span><span class=\"key lost\"></span><span>kassiert</span></div></div>");
}
out += "<div class=\"pg-col\" style=\"flex:1.5;" + pg_css("gap:10px;") + "\">" + panel("Punkteverlauf", course, "st-course-panel") + panel("Tore nach Spielminute", minutes + "</div>") + "</div>";
// the club's scorers: goals solid, assists light
{
const auto &scorers = data.at("scorers");
int greatest = 1;
for (const auto &row : scorers) greatest = std::max(greatest, row.at("goals").get<int>() + row.at("assists").get<int>());
std::string body;
for (size_t i = 0; i < scorers.size() && i < 7; ++i) {
const auto &row = scorers[i];
const int goals = row.at("goals"), assists = row.at("assists");
body += "<div class=\"an-scorer\"><span class=\"name\">" + esc(row.at("name").get<std::string>()) + "</span><div class=\"an-scorer-bar\"><div class=\"goals\" style=\"width:" + scalar(goals * 100.0 / greatest) +
"%;\"></div><div class=\"assists\" style=\"width:" + scalar(assists * 100.0 / greatest) + "%;\"></div></div><span class=\"sum\">" + std::to_string(goals) + " T · " + std::to_string(assists) + " V</span></div>";
}
if (scorers.empty()) body = "<p class=\"an-none\">Noch kein Tor erzielt.</p>";
out += card("an-scorers", 1010, 1230, 800, 620, "Tore und Vorlagen", body);
}
// how the goals came about, and a reading of the season
// --- middle: home and away with what the first goal decided, then how the goals came about ---
const auto record = [&](const std::string &label, const Json &r) {
const int games = r.at("played");
std::string row = "<div class=\"pg-row\" style=\"" + pg_css("gap:10px;") + "\"><strong style=\"display:block;flex:none;width:" + pg(74) + ";\">" + label + "</strong><div class=\"st-stack\">";
for (const auto &[key, css, letter] : std::array<std::tuple<const char *, const char *, const char *>, 3>{{{"won", "won", "S"}, {"drawn", "drawn", "U"}, {"lost", "lost", "N"}}})
if (const int count = r.at(key); count) row += "<div class=\"" + std::string(css) + "\" style=\"flex:" + std::to_string(count) + ";\"><span>" + std::to_string(count) + " " + letter + "</span></div>";
if (!games) row += "<div class=\"none\" style=\"flex:1;\"><span>kein Spiel</span></div>";
return row + "</div><span class=\"pg-r\" style=\"display:block;flex:none;width:" + pg(96) + ";\">" + (games ? two(r.at("points").get<double>() / games) + " Pkt./Sp." : std::string("—")) + "</span></div>";
};
const auto first = [&](const std::string &label, const Json &r) {
const int games = r.at("played");
return "<div class=\"pg-kv\"><span>" + label + "</span><strong>" + std::to_string(games) + (games == 1 ? " Spiel" : " Spiele") + " · " + (games ? std::to_string(int(std::lround(r.at("won").get<double>() * 100 / games))) + " % gewonnen" : std::string("—")) + "</strong></div>";
};
std::string kinds_body;
{
const auto &kinds = data.at("kinds");
constexpr std::array<const char *, 4> names{"Aus dem Spiel", "Elfmeter / Freistoß", "Nachschuss", "Nach Ecke"};
int greatest = 1;
for (const auto &k : kinds) greatest = std::max(greatest, k.at("for").get<int>());
std::string body;
int total = 0;
for (const auto &k : kinds) total += k.at("for").get<int>();
for (size_t i = 0; i < kinds.size() && i < 4; ++i)
body += "<div class=\"an-kind\"><span class=\"name\">" + std::string(names[i]) + "</span><div class=\"bank-part-track\"><div style=\"width:" + scalar(kinds[i].at("for").get<int>() * 100.0 / greatest) +
"%;\"></div></div><span class=\"sum\">" + std::to_string(kinds[i].at("for").get<int>()) + "</span></div>";
kinds_body += "<div class=\"pg-row\" style=\"" + pg_css("gap:8px;") + "\"><span style=\"display:block;flex:none;width:" + pg(140) + ";\">" + std::string(names[i]) + "</span>" + pg_bar(kinds[i].at("for").get<int>() * 100.0 / std::max(1, total)) +
"<strong class=\"pg-r\" style=\"display:block;flex:none;width:" + pg(28) + ";\">" + std::to_string(kinds[i].at("for").get<int>()) + "</strong></div>";
const auto &buckets = data.at("buckets");
const auto span = [&](int index) { const int from = buckets[size_t(index)].at("from"); return std::to_string(from) + ". bis " + (index == 5 ? std::string("letzten") : std::to_string(from + 14) + ".") + " Minute"; };
std::string reading = league_played ? (pace > league_pace + .15 ? "Die Mannschaft punktet über dem Liga-Schnitt (" : pace < league_pace - .15 ? "Die Mannschaft punktet unter dem Liga-Schnitt (" : "Die Mannschaft punktet im Liga-Schnitt (") +
@@ -160,7 +121,26 @@ std::string App::render_statistics_analysis() {
if (chances_for) reading += "Aus " + std::to_string(chances_for) + " Chancen wurden " + std::to_string(goals_for) + " Tore; der Gegner kam zu " + std::to_string(chances_against) + " Chancen. ";
if (goals_for) reading += "Die meisten Tore fielen von der " + span(best_bucket) + ". ";
if (goals_against) reading += "Die meisten Gegentore fielen von der " + span(worst_bucket) + ".";
out += card("an-kinds", 1830, 1230, 752, 620, "Torarten", body + "<div class=\"an-reading\"><h4>Analyse</h4><p>" + reading + "</p></div>");
kinds_body += pg_kicker("Analyse", "margin-top:6px;") + "<span class=\"st-reading\">" + esc(reading) + "</span>";
}
return out + "</section>";
out += "<div class=\"pg-col\" style=\"flex:1;" + pg_css("gap:10px;") + "\">" +
panel("Heim und Auswärts", record("Heim", data.at("home")) + record("Auswärts", data.at("away")) + pg_kicker("Das erste Tor", "margin-top:8px;") + first("Selbst zuerst getroffen", data.at("firstFor")) + first("Gegner trifft zuerst", data.at("firstAgainst"))) +
panel("Torarten", kinds_body) + "</div>";
// --- right: the club's scorers, goals solid and assists light ---
std::string scorers_body;
{
const auto &scorers = data.at("scorers");
int greatest = 1;
for (const auto &row : scorers) greatest = std::max(greatest, row.at("goals").get<int>() + row.at("assists").get<int>());
for (size_t i = 0; i < scorers.size() && i < 12; ++i) {
const auto &row = scorers[i];
const int goals = row.at("goals"), assists = row.at("assists");
scorers_body += "<div class=\"st-scorer\"><div class=\"pg-row\" style=\"justify-content:space-between;\"><strong class=\"pg-nowrap\">" + esc(row.at("name").get<std::string>()) + "</strong><span style=\"display:block;flex:none;\">" + std::to_string(goals) + " T · " +
std::to_string(assists) + " V</span></div><div class=\"st-scorer-bar\"><div class=\"goals\" style=\"width:" + scalar(goals * 100.0 / greatest) + "%;\"></div><div class=\"assists\" style=\"width:" + scalar(assists * 100.0 / greatest) + "%;\"></div></div></div>";
}
if (scorers.empty()) scorers_body = "<span class=\"pg-mut\" style=\"display:block;\">Noch kein Tor erzielt.</span>";
}
out += "<div class=\"pg-col\" style=\"flex:1;\">" + panel("Tore und Vorlagen", scorers_body) + "</div>";
return out + "</div></section>";
}
+21
View File
@@ -20,6 +20,10 @@ bool App::statistics_action(const std::string &action,Rml::Element *target) {
if(id=="analysis"||id=="archive"){statistics_mode_=id;focus_after_render_="statistics-mode-"+std::string(id=="analysis"?"analysis":"analysis");refresh();}
return true;
}
if(action=="statistics-section"&&target) {
if(statistics_picker_select("stat-section",target->GetAttribute<Rml::String>("data-id",""))){focus_after_render_=target->GetId();refresh();}
return true;
}
if(action=="statistics-trophy-close") {
if(statistics_trophy_.contains("asset")) {
focus_after_render_=statistics_trophy_.value("return_focus","");statistics_trophy_=Json::object();refresh();
@@ -84,3 +88,20 @@ bool App::statistics_event(Rml::Event &event) {
}
event.StopImmediatePropagation();return true;
}
// The kinds of the archive that share a page of the notebook, the first one being shown when
// the page opens: the course of the seasons, the title holders, the records, the players.
std::vector<int> App::statistics_page_sections(const std::string &page) {
if(page=="stat-trend")return {2,5};
if(page=="stat-winners")return {7};
if(page=="stat-records")return {3,6,4};
if(page=="stat-players")return {1,8,0};
return {};
}
void App::statistics_open(const std::string &page) {
statistics_page_=page;statistics_mode_=page=="statistics"?"analysis":"archive";
if(const auto group=statistics_page_sections(page);!group.empty()) {
if(!statistics_view_.is_object())statistics_view_=Json::object();
if(std::find(group.begin(),group.end(),statistics_view_.value("section",7))==group.end())statistics_view_["section"]=group.front();
}
menu_="statistics";engine_reports_sync();engine_statistics_load();
}
+71 -55
View File
@@ -75,92 +75,108 @@ std::string App::statistics_trophy_asset(const std::string &id) const {
}
return {};
}
// The archive of the statistics as a page: one table per kind, the winners under their
// trophies, the recorded series as curves; the kinds are chosen in the foot.
std::string App::render_statistics() {
statistics_remember_scroll();
if((!source_&&!engine_mode_)||!world_)return "<p>Statistiken sind nicht verfügbar.</p>";
const std::string unavailable = "<div class=\"pg-page\"><div class=\"pg-empty\">Statistiken sind nicht verfügbar.</div></div>";
if((!source_&&!engine_mode_)||!world_)return unavailable;
if(engine_mode_&&statistics_mode_=="analysis")return render_statistics_analysis()+render_report_detail();
const auto group=engine_mode_?statistics_page_sections(statistics_page_):std::vector<int>{};
const auto data=statistics_data();
if(!data.value("ok",false))return "<p>Statistiken sind nicht verfügbar.</p>";
if(!data.value("ok",false))return unavailable;
const int section=data.at("section").get<int>(),category=data.at("category").get<int>();
const bool winners=section==7,minutes=section==8,finals=section==4&&data.at("country")==3;
std::string out="<section class=\"statistics-native statistics-section-"+std::to_string(section)+(finals?" statistics-finals":"")+"\"><div class=\"statistics-panel\">"+(engine_mode_?btn("statistics-mode","‹ Vereinsanalyse","statistics-back","id=\"statistics-mode-analysis\" data-id=\"analysis\""):std::string())+"<h2 class=\"statistics-heading\">"+esc(data.at("title").get<std::string>())+"</h2>";
if(winners)out+="<p class=\"statistics-winner-note\">"+statistics_text(data.value("note",""))+"</p>";
if(engine_mode_&&!data.value("available",false)){out+="<p class=\"statistics-empty\">"+statistics_text(data.value("reason","")=="not_recorded"?"Diese Auswertung wurde in der Karriere noch nicht aufgezeichnet.":"Keine Statistikdaten für diese Auswahl vorhanden.")+"</p>";}
std::string out="<section class=\"pg-page statistics-native statistics-section-"+std::to_string(section)+"\"><div class=\"pg-row\">"+
"<h2 class=\"pg-h pg-grow\" style=\"font-size:"+pg(22)+";line-height:"+pg(28)+";\">"+esc(data.at("title").get<std::string>())+"</h2>"+
(winners&&!data.value("note",std::string()).empty()?"<span class=\"pg-mut\">"+esc(data.value("note",""))+"</span>":std::string());
// the kinds that share this page, as tabs
if(group.size()>1) {
out+="<nav class=\"pg-tabs\" aria-label=\"Statistik\">";
for(const int kind:group)
out+=btn("statistics-section","<span>"+esc(data.at("sections")[size_t(kind)].get<std::string>())+"</span>",kind==section?"on":"","id=\"statistics-section-"+std::to_string(kind)+"\" data-id=\""+std::to_string(kind)+"\" aria-pressed=\""+(kind==section?"true":"false")+"\"");
out+="</nav>";
}
std::string body;
if(engine_mode_&&!data.value("available",false))
body="<div class=\"pg-panel pg-grow\"><div class=\"pg-empty\">"+std::string(data.value("reason","")=="not_recorded"?"Diese Auswertung wurde in der Karriere noch nicht aufgezeichnet.":"Keine Statistikdaten für diese Auswahl vorhanden.")+"</div></div>";
else if(section==2) {
std::string svg="<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 3400 780' width='2496' height='812' preserveAspectRatio='none'><path d='M30 10V730H3380' fill='none' stroke='"+std::string(theme_=="silver"?"#627c8f":"#7d9aae")+"' stroke-width='3'/>";
const auto &series=data.at("series");
for(const auto &curve:series)if(curve.at("active")==true) {
svg+="<polyline points='";
for(const auto &point:curve.at("points"))svg+=scalar(point[0].get<double>())+","+scalar(point[1].get<double>())+" ";
svg+="' fill='none' stroke='"+curve.at("color").get<std::string>()+"' stroke-width='7'/>";
}
svg+="</svg>";
out+="<div class=\"statistics-graph\" role=\"img\" aria-label=\""+std::string(engine_mode_?"Aufgezeichnete Verlaufsreihen · ":"Sechs fiktive Verlaufsreihen · ")+std::string(data.at("absolute")==true?"absolut":"relativ")+"\">"+picture(renderer_.diagram("statistics-analytics",svg,5100),2496,812)+"</div><div class=\"statistics-series\">";
for(size_t k=0;k<series.size();++k) {
const auto &curve=series[k];const bool active=curve.at("active").get<bool>();
out+=btn("statistics-curve","<span class=\"statistics-series-dot\" style=\"background-color:"+curve.at("color").get<std::string>()+";\"></span><span class=\"statistics-series-label\">"+esc(curve.at("name").get<std::string>())+"</span>","statistics-action statistics-series-button",
"id=\"statistics-curve-"+std::to_string(k)+"\" data-index=\""+std::to_string(k)+"\" aria-pressed=\""+(active?"true":"false")+"\" style=\""+rect(double(k%3)*854.666666667,double(k/3)*100,836.666666667,82)+"\"");
// the recorded series: each can be shown or hidden, in its own measure or as a share of its start
const bool absolute=data.at("absolute")==true;
out+="<div class=\"pg-seg\">";
for(int i=0;i<2;++i) {
const bool on=(i==0)==absolute;
out+=btn("statistics-absolute","<span>"+std::string(i?"REL.":"ABS.")+"</span>",std::string(i?"":"first ")+(on?"on":""),on?std::string("style=\"pointer-events:none;\" aria-pressed=\"true\""):std::string("id=\"statistics-absolute\" aria-pressed=\"false\" aria-label=\"Darstellung umschalten\""));
}
out+="</div>";
std::string svg="<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 3400 780' width='2496' height='812' preserveAspectRatio='none'><path d='M30 10V730H3380' fill='none' stroke='"+std::string(theme_=="midnight"?"#8f95a1":"#82796a")+"' stroke-width='3'/>";
const auto &series=data.at("series");
std::string keys;
for(size_t k=0;k<series.size();++k) {
const auto &curve=series[k];const bool active=curve.at("active").get<bool>();
if(active) {
svg+="<polyline points='";
for(const auto &point:curve.at("points"))svg+=scalar(point[0].get<double>())+","+scalar(point[1].get<double>())+" ";
svg+="' fill='none' stroke='"+curve.at("color").get<std::string>()+"' stroke-width='7' stroke-linejoin='round'/>";
}
keys+=pg_button("statistics-curve","<span class=\"pg-legend-mark\" style=\"display:block;width:32dp;height:9dp;margin-right:14dp;background-color:"+curve.at("color").get<std::string>()+";\"></span><span>"+esc(curve.at("name").get<std::string>())+"</span>",active?"on":"",
"id=\"statistics-curve-"+std::to_string(k)+"\" data-index=\""+std::to_string(k)+"\" aria-pressed=\""+(active?"true":"false")+"\"");
}
svg+="</svg>";
body="<div class=\"pg-panel pg-col pg-grow\" style=\""+pg_css("gap:10px;")+"\"><div class=\"pg-row\" style=\"flex-wrap:wrap;"+pg_css("gap:6px;")+"\">"+keys+"</div><div class=\"st-graph\" role=\"img\" aria-label=\""+std::string(engine_mode_?"Aufgezeichnete Verlaufsreihen · ":"Sechs fiktive Verlaufsreihen · ")+
std::string(absolute?"absolut":"relativ")+"\">"+picture(renderer_.diagram("statistics-analytics",svg,5100),2700,878)+"</div></div>";
} else {
const auto &columns=data.at("columns"),&rows=data.at("rows");
const size_t count=columns.size();
const double table_width=2548;
const double first=minutes?table_width*.12:winners?190:table_width*.4;
const double table_width=2740;
const double first=minutes?table_width*.12:winners?210:table_width*.36;
const double rest=count>1?(table_width-first)/double(count-1):0;
const auto width=[&](size_t column){return finals?(column==1?160:1194):column?rest:first;};
const auto width=[&](size_t column){return finals?(column==1?180:(table_width-180)/2):column?rest:first;};
const auto align=[&](size_t column){return finals?(column==0?" r":column==1?" c":""):winners||column<2?"":" r";};
const bool trophies=winners&&std::any_of(columns.begin(),columns.end(),[](const Json &column){return !column.value("trophy","").empty();});
const double head_height=trophies?400:winners?78:76;
out+="<div id=\"statistics-list\" class=\"statistics-list "+std::string(winners?"statistics-winners ":"")+(minutes?"statistics-minutes ":"")+"\" data-scroll-key=\""+esc(statistics_scroll_key(data))+"\"><div class=\"statistics-table\" role=\"table\"><div class=\"statistics-row statistics-head\" role=\"row\" style=\"height:"+scalar(head_height)+"dp;\">";
body="<div class=\"pg-panel pg-col pg-grow\" style=\""+pg_css("gap:0px;padding:4px 12px;")+"\"><div class=\"pg-t\" role=\"table\"><div class=\"pg-thead"+std::string(trophies?" st-trophies":"")+"\" role=\"row\">";
for(size_t c=0;c<count;++c) {
const auto &column=columns[c];
const auto trophy=column.value("trophy","");const auto asset=statistics_trophy_asset(trophy);
std::string heading=statistics_text(column.at("text").get<std::string>());
if(column.contains("round"))heading="<span class=\"statistics-fixture-round\"><span>"+esc(column.at("round").get<std::string>())+"</span></span>"+heading;
if(!trophy.empty()) {
const auto art=asset.empty()?std::string():"<span class=\"statistics-trophy-icon\">"+img(asset,290,290,asset.starts_with("asset:"),false,640)+"</span>";
heading=btn("statistics-trophy",art+"<span class=\"statistics-trophy-label\">"+esc(column.at("text").get<std::string>())+"</span>","statistics-trophy-heading",
std::string heading="<span>"+esc(pg_upper(column.at("text").get<std::string>()))+"</span>";
if(column.contains("round"))heading="<span class=\"pg-tag\">"+esc(column.at("round").get<std::string>())+"</span>"+heading;
if(!trophy.empty())
heading=btn("statistics-trophy",(asset.empty()?std::string():"<span class=\"st-trophy-art\">"+img(asset,230,230,asset.starts_with("asset:"),false,640)+"</span>")+"<span class=\"pg-h st-trophy-name\">"+esc(column.at("text").get<std::string>())+"</span>","pg-card st-trophy",
"id=\"statistics-trophy-heading-"+std::to_string(c)+"\" data-column=\""+std::to_string(c)+"\" data-row=\"-1\" aria-label=\""+esc(column.at("text").get<std::string>()+" · Siegerbild ansehen")+"\" "+(asset.empty()||!column.contains("winner")?"disabled":""));
}
out+="<div class=\"statistics-cell statistics-col-"+std::to_string(c)+"\" role=\"columnheader\" style=\"width:"+scalar(width(c))+"dp;height:"+scalar(head_height)+"dp;\">"+heading+"</div>";
body+="<div class=\"pg-th st-th"+std::string(align(c))+"\" role=\"columnheader\" style=\"width:"+scalar(width(c))+"dp;\">"+heading+"</div>";
}
out+="</div>";
body+="</div><div id=\"statistics-list\" class=\"pg-tbody\" data-scroll-key=\""+esc(statistics_scroll_key(data))+"\">";
for(size_t r=0;r<rows.size();++r) {
const auto &cells=rows[r].at("cells");
const bool world_trophies=section==4&&(data.at("country")==0||data.at("country")==5);
const double row_height=minutes?200:winners?120:world_trophies?110:76;
out+="<div class=\"statistics-row "+std::string(r%2==0?"striped":"")+"\" role=\"row\" style=\"height:"+scalar(row_height)+"dp;\">";
const double row_height=minutes?170:winners?88:world_trophies?104:70;
body+="<div class=\"pg-tr\" role=\"row\" style=\"height:"+scalar(row_height)+"dp;\">";
for(size_t c=0;c<cells.size();++c) {
const auto &value=cells[c];const auto title=value.value("text","");const auto token=std::to_string(r)+"-"+std::to_string(c);
std::string content;
if(value.contains("player")) {
content="<span class=\"statistics-player-prefix\">"+esc(value.value("prefix",""))+"</span>"+btn("player-detail",statistics_text(title),"statistics-player-link","id=\"statistics-player-"+token+"\" data-id=\""+esc(value.at("player").get<std::string>())+"\" data-club=\""+esc(value.value("club",""))+"\" title=\""+esc(title)+"\"");
} else if(value.contains("club")) {
const auto id=value.at("club").get<std::string>();const auto *club=world_->find("clubs",id);const bool reverse=section==1&&c==1;
const auto name="<span class=\"report-club-name\">"+esc(title)+"</span>",badge=crest(club,42);
content=btn("club-detail",reverse?name+badge:badge+name,"report-club-button statistics-club "+std::string(reverse?"name-first ":"")+(data.at("club")==id?"current":""),"id=\"statistics-club-"+token+"\" data-id=\""+esc(id)+"\" title=\""+esc(title)+"\"");
if(value.contains("player"))
content=(value.value("prefix","").empty()?std::string():"<span class=\"pg-mut\">"+esc(value.value("prefix",""))+"</span>")+btn("player-detail","<span>"+esc(title)+"</span>","pg-link","id=\"statistics-player-"+token+"\" data-id=\""+esc(value.at("player").get<std::string>())+"\" data-club=\""+esc(value.value("club",""))+"\" title=\""+esc(title)+"\"");
else if(value.contains("club")) {
const auto id=value.at("club").get<std::string>();const bool reverse=finals&&c==0;
content=btn("club-detail",crest(world_->find("clubs",id),50)+"<span>"+esc(title)+"</span>",std::string("pg-link")+(reverse?" reverse":"")+(data.at("club")==id?"":" plain"),"id=\"statistics-club-"+token+"\" data-id=\""+esc(id)+"\" title=\""+esc(title)+"\"");
} else if(value.contains("trophy")) {
const auto asset=statistics_trophy_asset(value.at("trophy").get<std::string>());
content=btn("statistics-trophy",(asset.empty()?std::string():"<span class=\"statistics-world-trophy-art\">"+img(asset,92,92,asset.starts_with("asset:"),false,256)+"</span>")+statistics_text(title),"statistics-world-trophy","id=\"statistics-trophy-row-"+token+"\" data-row=\""+std::to_string(r)+"\" data-column=\""+std::to_string(c)+"\" "+(asset.empty()?"disabled":""));
} else content=statistics_text(value.value("prefix","")+title);
if(value.contains("round"))content="<span class=\"statistics-fixture-round\"><span>"+esc(value.at("round").get<std::string>())+"</span></span>"+content;
out+="<div class=\"statistics-cell statistics-col-"+std::to_string(c)+" "+esc(value.value("tone",""))+"\" role=\"cell\" style=\"width:"+scalar(width(c))+"dp;height:"+scalar(row_height)+"dp;\">"+content+"</div>";
content=btn("statistics-trophy",(asset.empty()?std::string():"<span class=\"st-trophy-small\">"+img(asset,88,88,asset.starts_with("asset:"),false,256)+"</span>")+"<span>"+esc(title)+"</span>","pg-link","id=\"statistics-trophy-row-"+token+"\" data-row=\""+std::to_string(r)+"\" data-column=\""+std::to_string(c)+"\" "+(asset.empty()?"disabled":""));
} else content="<span class=\"st-text "+esc(value.value("tone",""))+"\">"+esc(value.value("prefix","")+title)+"</span>";
if(value.contains("round"))content="<span class=\"pg-tag\">"+esc(value.at("round").get<std::string>())+"</span>"+content;
body+="<div class=\"pg-td cell st-td"+std::string(align(c))+"\" role=\"cell\" style=\"width:"+scalar(width(c))+"dp;\">"+content+"</div>";
}
out+="</div>";
body+="</div>";
}
if(rows.empty())out+="<p class=\"statistics-empty\">"+statistics_text("Keine Statistikdaten für diese Auswahl vorhanden.")+"</p>";
out+="</div></div>";
if(rows.empty())body+="<div class=\"pg-empty\">Keine Statistikdaten für diese Auswahl vorhanden.</div>";
body+="</div></div></div>";
}
out+="</div><nav class=\"report-footer statistics-footer\" aria-label=\"Statistik und Auswahl\">";
const bool extra=winners||section==2||section==3||section==4;
const bool three=winners&&category==0;
const double width=three?854.666666667:extra?1294:2612;
out+=report_picker("stat-section",0,width);
out+="</div>"+body+"<nav class=\"pg-foot\" aria-label=\"Statistik und Auswahl\">"+(group.empty()?report_picker("stat-section",-1,0):std::string());
if(winners) {
out+=report_picker("stat-category",three?878.666666667:1318,width);
if(three)out+=report_picker("winner-country",1757.333333333,width);
} else if(section==3||section==4)out+=report_picker("stat-country",1318,1294);
else if(section==2)out+=btn("statistics-absolute",statistics_text(data.at("absolute")==true?"ABS.":"REL."),"statistics-action statistics-absolute","id=\"statistics-absolute\" aria-label=\""+std::string(data.at("absolute")==true?"Absolute":"Relative")+" Darstellung; zum Umschalten klicken\" style=\""+rect(1318,0,1294,94)+"\"");
out+=report_picker("stat-category",-1,0);
if(category==0)out+=report_picker("winner-country",-1,0);
} else if(section==3||section==4)out+=report_picker("stat-country",-1,0);
out+="<span class=\"pg-sp\"></span>"+pg_status(winners?"Ein Pokalbild anklicken, um den Sieger groß zu sehen.":section==2?"Eine Reihe anklicken, um ihre Kurve ein- oder auszublenden.":"Spieler- und Vereinsnamen sind anklickbar.");
statistics_restore_pending_=true;
return out+"</nav></section>"+render_report_detail();
}
+5
View File
@@ -6,6 +6,11 @@
std::string render_statistics();
// "analysis": the club's season as charts (engine careers); "archive": the tables of the original
std::string statistics_mode_ = "analysis";
// the page of the statistics that is open: "statistics" (the club's season), or one of the
// groups of the archive: "stat-trend", "stat-winners", "stat-records", "stat-players"
std::string statistics_page_ = "statistics";
static std::vector<int> statistics_page_sections(const std::string &page);
void statistics_open(const std::string &page);
Json engine_analysis_value_;
std::string render_statistics_analysis();
std::vector<std::pair<std::string, std::string>> statistics_picker_items(const std::string &) const;