edutrack-pro-visualizer / visualize.js
DJANTONY's picture
create cool visualization page for this data.
f8b1684 verified
Raw History Blame Contribute Delete
6.6 kB
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>
`;
});