document.addEventListener('DOMContentLoaded', function() { // Sample data - replace with actual API call or data import const trainingData = [ { id: 1, department: "РХМДиЛ", name: "Яковлева О.А", date: "45817", initialPoints: 106, updatedPoints: 107 }, { id: 2, department: "РХМДиЛ", name: "Антипкина Ю.А", date: "45815", initialPoints: 56, updatedPoints: 59 }, { id: 3, department: "РХМДиЛ", name: "Барникова А.В", date: "45818", initialPoints: 143, updatedPoints: 144 }, { id: 4, department: "РХМДиЛ", name: "Бородкина В.В", date: "0", initialPoints: 105, updatedPoints: 105 }, { id: 5, department: "РХМДиЛ", name: "Земскова Ж.Г", date: "Нет тем", initialPoints: 156, updatedPoints: 156 } ]; // Department Chart const departmentCtx = document.getElementById('departmentChart').getContext('2d'); new Chart(departmentCtx, { type: 'bar', data: { labels: ['РХМДиЛ'], datasets: [{ label: 'Average Initial Points', data: [trainingData.reduce((sum, item) => sum + item.initialPoints, 0) / trainingData.length], backgroundColor: 'rgba(59, 130, 246, 0.6)', borderColor: 'rgba(59, 130, 246, 1)', borderWidth: 1 }, { label: 'Average Updated Points', data: [trainingData.reduce((sum, item) => sum + item.updatedPoints, 0) / trainingData.length], backgroundColor: 'rgba(16, 185, 129, 0.6)', borderColor: 'rgba(16, 185, 129, 1)', borderWidth: 1 }] }, options: { responsive: true, scales: { y: { beginAtZero: true } } } }); // Points Improvement Chart const pointsCtx = document.getElementById('pointsChart').getContext('2d'); new Chart(pointsCtx, { type: 'radar', data: { labels: trainingData.map(item => item.name), datasets: [{ label: 'Initial Points', data: trainingData.map(item => item.initialPoints), backgroundColor: 'rgba(255, 99, 132, 0.2)', borderColor: 'rgba(255, 99, 132, 1)', borderWidth: 1 }, { label: 'Updated Points', data: trainingData.map(item => item.updatedPoints), backgroundColor: 'rgba(54, 162, 235, 0.2)', borderColor: 'rgba(54, 162, 235, 1)', borderWidth: 1 }] }, options: { responsive: true, scales: { r: { beginAtZero: true } } } }); // Timeline Chart const timelineCtx = document.getElementById('timelineChart').getContext('2d'); const filteredData = trainingData.filter(item => !isNaN(item.date) && item.date !== "0"); new Chart(timelineCtx, { type: 'line', data: { labels: filteredData.map(item => item.date), datasets: [{ label: 'Points Improvement', data: filteredData.map(item => item.updatedPoints - item.initialPoints), borderColor: 'rgba(168, 85, 247, 1)', backgroundColor: 'rgba(168, 85, 247, 0.1)', borderWidth: 2, fill: true, tension: 0.3 }] }, options: { responsive: true, plugins: { tooltip: { callbacks: { label: function(context) { const index = context.dataIndex; return `${filteredData[index].name}: +${context.raw} points`; } } } }, scales: { y: { beginAtZero: true, title: { display: true, text: 'Points Improvement' } }, x: { title: { display: true, text: 'Training Date' } } } } }); // Status Cards const statusCards = document.getElementById('statusCards'); const completed = trainingData.filter(item => item.updatedPoints > item.initialPoints).length; const noChange = trainingData.filter(item => item.updatedPoints === item.initialPoints).length; const noTraining = trainingData.filter(item => item.date === "0" || item.date === "Нет тем").length; statusCards.innerHTML = `

Completed

${completed}

${Math.round((completed / trainingData.length) * 100)}% of total

No Change

${noChange}

${Math.round((noChange / trainingData.length) * 100)}% of total

No Training

${noTraining}

${Math.round((noTraining / trainingData.length) * 100)}% of total

`; });