-
-
-
-
- {% for section in report.sections %}
-
- {% endfor %}
-
-
-
- {% for section in report.sections %}
-
- {% for item in section.items %}
-
- {% endfor %}
-
- {% endfor %}
-
-
-
-
-
-
- {% for section in report.sections %}
-
- {% for item in section.items %}
-
-
-
-
{{ section.title }}
-
{{ item.label }}
- {% if item.source_labels %}
-
{{ item.source_labels | join(', ') }}
- {% endif %}
-
-
-
-
-{{ item.chart_svg | safe }}
-
-
-
-
-
-
- | Неделя |
- Всего пар |
- Пар проведено |
- Пар пропущено |
- Иные пары |
- Схема |
-
-
-
- {% for week in item.weeks %}
-
- | {{ week.long }} |
- {{ week.total_pairs }} |
- {{ week.conducted_display }} |
- {{ week.missed_display }} |
- {{ week.other_display }} |
- {{ week.scheme_html | safe }} |
-
- {% endfor %}
-
-
-
-
- {% endfor %}
-
- {% endfor %}
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ {% for section in report.sections %}
+
+ {% endfor %}
+
+
+ {% for section in report.sections %}
+
+ {% for item in section.entries %}
+
+ {% endfor %}
+
+ {% endfor %}
+
+
+
+
+
+
+ {% for section in report.sections %}
+
+ {% for item in section.entries %}
+
+
+
+
{{ section.title }}
+
{{ item.label }}
+ {% if item.source_labels %}
+
+ {{ item.source_labels | join(', ') }}
+
+ {% endif %}
+
+
+
+
+
+
+
+
+ {% for week in item.weeks %}
+
+ | {{ week.long }} |
+ {{ week.total_pairs }} |
+ {{ week.conducted_display }} |
+ {{ week.missed_display }} |
+ {{ week.other_display }} |
+
+ {{ week.scheme_html | safe }}
+ |
+
+ {% endfor %}
+
+
+
+
+ {% endfor %}
+
+ {% endfor %}
+
+
+
+
+
+
+
diff --git a/template/report_class.js b/template/report_class.js
index d5036ee..4a992a9 100644
--- a/template/report_class.js
+++ b/template/report_class.js
@@ -1,73 +1,168 @@
(function () {
- function qs(selector, root) {
- return (root || document).querySelector(selector);
- }
+ const chartStore = new Map();
- function qsa(selector, root) {
- return Array.from((root || document).querySelectorAll(selector));
- }
+ function qs(selector, root) {
+ return (root || document).querySelector(selector);
+ }
- function setActiveSection(sectionId) {
- qsa('.section-nav .nav-btn[data-section]').forEach((btn) => {
- btn.classList.toggle('active', btn.dataset.section === sectionId);
- });
+ function qsa(selector, root) {
+ return Array.from((root || document).querySelectorAll(selector));
+ }
- qsa('.class-nav-group').forEach((group) => {
- group.classList.toggle('active', group.dataset.section === sectionId);
- });
+ function buildChartForClass(classId, report) {
+ if (!classId || chartStore.has(classId) || typeof Chart === "undefined") {
+ return;
+ }
- const firstButton = qs(`.class-nav-group.active .class-btn[data-class-id]`);
- if (firstButton) {
- setActiveClass(firstButton.dataset.classId, false);
- }
- }
+ const sections = Array.isArray(report.sections) ? report.sections : [];
+ const entry = sections
+ .flatMap((section) => section.entries || [])
+ .find((item) => item.id === classId);
+ if (!entry) {
+ return;
+ }
- function setActiveClass(classId, scrollIntoView) {
- qsa('.class-btn[data-class-id]').forEach((btn) => {
- btn.classList.toggle('active', btn.dataset.classId === classId);
- });
+ const canvas = qs(`.week-chart[data-chart-for="${classId}"]`);
+ if (!canvas) {
+ return;
+ }
- qsa('.class-block[data-class-id]').forEach((block) => {
- const active = block.dataset.classId === classId;
- block.classList.toggle('active', active);
- if (active && scrollIntoView) {
- block.scrollIntoView({ behavior: 'smooth', block: 'start' });
- }
- });
- }
+ const chartData = entry.chart_data || {};
+ const labels = Array.isArray(chartData.labels) ? chartData.labels : [];
+ const missed = Array.isArray(chartData.missed) ? chartData.missed : [];
+ const other = Array.isArray(chartData.other) ? chartData.other : [];
+ const conducted = Array.isArray(chartData.conducted)
+ ? chartData.conducted
+ : [];
- function init() {
- const report = window.__CLASS_REPORT__ || {};
- const activeSection = report.active_section || '';
- const activeClass = report.active_class || '';
+ if (!labels.length) {
+ const container = canvas.parentElement;
+ if (container) {
+ container.innerHTML = "Нет данных.
";
+ }
+ return;
+ }
- qsa('.section-nav .nav-btn[data-section]').forEach((btn) => {
- btn.addEventListener('click', () => setActiveSection(btn.dataset.section));
- });
+ const chart = new Chart(canvas, {
+ type: "bar",
+ data: {
+ labels,
+ datasets: [
+ {
+ label: "Пропущено",
+ data: missed,
+ backgroundColor: "#ef4444",
+ stack: "pairs",
+ borderRadius: 4,
+ },
+ {
+ label: "Иное",
+ data: other,
+ backgroundColor: "#f59e0b",
+ stack: "pairs",
+ borderRadius: 4,
+ },
+ {
+ label: "Проведено",
+ data: conducted,
+ backgroundColor: "#22c55e",
+ stack: "pairs",
+ borderRadius: 4,
+ },
+ ],
+ },
+ options: {
+ responsive: true,
+ maintainAspectRatio: false,
+ interaction: {
+ mode: "index",
+ intersect: false,
+ },
+ scales: {
+ x: {
+ stacked: true,
+ grid: {
+ display: false,
+ },
+ },
+ y: {
+ stacked: true,
+ beginAtZero: true,
+ ticks: {
+ precision: 0,
+ },
+ },
+ },
+ },
+ });
- qsa('.class-btn[data-class-id]').forEach((btn) => {
- btn.addEventListener('click', () => setActiveClass(btn.dataset.classId, true));
- });
+ chartStore.set(classId, chart);
+ }
- if (activeSection) {
- setActiveSection(activeSection);
- }
+ function setActiveSection(sectionId, report) {
+ qsa(".section-nav .nav-btn[data-section]").forEach((btn) => {
+ btn.classList.toggle("active", btn.dataset.section === sectionId);
+ });
- if (activeClass) {
- setActiveClass(activeClass, false);
- }
- }
+ qsa(".class-nav-group").forEach((group) => {
+ group.classList.toggle("active", group.dataset.section === sectionId);
+ });
- window.printReport = function printReport() {
- window.print();
- };
+ const firstButton = qs(`.class-nav-group.active .class-btn[data-class-id]`);
+ if (firstButton) {
+ setActiveClass(firstButton.dataset.classId, false, report);
+ }
+ }
- if (document.readyState === 'loading') {
- document.addEventListener('DOMContentLoaded', init);
- } else {
- init();
- }
+ function setActiveClass(classId, scrollIntoView, report) {
+ qsa(".class-btn[data-class-id]").forEach((btn) => {
+ btn.classList.toggle("active", btn.dataset.classId === classId);
+ });
+
+ qsa(".class-block[data-class-id]").forEach((block) => {
+ const active = block.dataset.classId === classId;
+ block.classList.toggle("active", active);
+ if (active && scrollIntoView) {
+ block.scrollIntoView({ behavior: "smooth", block: "start" });
+ }
+ });
+
+ buildChartForClass(classId, report);
+ }
+
+ function init() {
+ const report = window.__CLASS_REPORT__ || {};
+ const activeSection = report.active_section || "";
+ const activeClass = report.active_class || "";
+
+ qsa(".section-nav .nav-btn[data-section]").forEach((btn) => {
+ btn.addEventListener("click", () =>
+ setActiveSection(btn.dataset.section, report),
+ );
+ });
+
+ qsa(".class-btn[data-class-id]").forEach((btn) => {
+ btn.addEventListener("click", () =>
+ setActiveClass(btn.dataset.classId, true, report),
+ );
+ });
+
+ if (activeSection) {
+ setActiveSection(activeSection, report);
+ }
+
+ if (activeClass) {
+ setActiveClass(activeClass, false, report);
+ }
+ }
+
+ window.printReport = function printReport() {
+ window.print();
+ };
+
+ if (document.readyState === "loading") {
+ document.addEventListener("DOMContentLoaded", init);
+ } else {
+ init();
+ }
})();
-function printReport() {
- window.print();
-}
diff --git a/template/report_group.html b/template/report_group.html
deleted file mode 100644
index 429b9ef..0000000
--- a/template/report_group.html
+++ /dev/null
@@ -1,77 +0,0 @@
-
-
-
-