File size: 6,595 Bytes
f8b1684 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | 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 = `
<div class="bg-green-50 p-4 rounded-lg border border-green-200">
<div class="flex items-center justify-between">
<h3 class="font-medium text-green-800">Completed</h3>
<span class="text-green-600">
<i data-feather="check-circle"></i>
</span>
</div>
<p class="mt-2 text-2xl font-bold text-green-900">${completed}</p>
<p class="text-sm text-green-600">${Math.round((completed / trainingData.length) * 100)}% of total</p>
</div>
<div class="bg-yellow-50 p-4 rounded-lg border border-yellow-200">
<div class="flex items-center justify-between">
<h3 class="font-medium text-yellow-800">No Change</h3>
<span class="text-yellow-600">
<i data-feather="alert-circle"></i>
</span>
</div>
<p class="mt-2 text-2xl font-bold text-yellow-900">${noChange}</p>
<p class="text-sm text-yellow-600">${Math.round((noChange / trainingData.length) * 100)}% of total</p>
</div>
<div class="bg-red-50 p-4 rounded-lg border border-red-200">
<div class="flex items-center justify-between">
<h3 class="font-medium text-red-800">No Training</h3>
<span class="text-red-600">
<i data-feather="x-circle"></i>
</span>
</div>
<p class="mt-2 text-2xl font-bold text-red-900">${noTraining}</p>
<p class="text-sm text-red-600">${Math.round((noTraining / trainingData.length) * 100)}% of total</p>
</div>
`;
}); |