Spaces:
Running
Running
remove performance trend graph
Browse files- reports.html +3 -211
reports.html
CHANGED
|
@@ -16,33 +16,8 @@
|
|
| 16 |
<h1 class="text-3xl font-bold text-gray-800 mb-8">Task Reports</h1>
|
| 17 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
|
| 18 |
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
|
| 19 |
-
<div class="flex justify-between items-center mb-4">
|
| 20 |
-
<h2 class="text-xl font-semibold">Performance Trend</h2>
|
| 21 |
-
<div class="flex gap-2">
|
| 22 |
-
<button class="time-period-btn active px-3 py-1 text-sm bg-primary text-white rounded-md" data-period="7">7d</button>
|
| 23 |
-
<button class="time-period-btn px-3 py-1 text-sm bg-gray-100 hover:bg-gray-200 rounded-md" data-period="30">30d</button>
|
| 24 |
-
<button class="time-period-btn px-3 py-1 text-sm bg-gray-100 hover:bg-gray-200 rounded-md" data-period="90">90d</button>
|
| 25 |
-
</div>
|
| 26 |
-
</div>
|
| 27 |
-
<div class="grid grid-cols-3 gap-4 mb-4 text-center">
|
| 28 |
-
<div class="bg-green-100 p-2 rounded-lg">
|
| 29 |
-
<p class="text-sm text-gray-600">Completed</p>
|
| 30 |
-
<p class="font-bold" id="avgCompletion">0/day</p>
|
| 31 |
-
</div>
|
| 32 |
-
<div class="bg-blue-100 p-2 rounded-lg">
|
| 33 |
-
<p class="text-sm text-gray-600">In Progress</p>
|
| 34 |
-
<p class="font-bold" id="inProgressAvg">0/day</p>
|
| 35 |
-
</div>
|
| 36 |
-
<div class="bg-yellow-100 p-2 rounded-lg">
|
| 37 |
-
<p class="text-sm text-gray-600">Pending</p>
|
| 38 |
-
<p class="font-bold" id="pendingAvg">0/day</p>
|
| 39 |
-
</div>
|
| 40 |
-
</div>
|
| 41 |
-
<canvas id="performanceChart" height="300"></canvas>
|
| 42 |
-
</div>
|
| 43 |
-
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
|
| 44 |
<h2 class="text-xl font-semibold mb-4">Task Completion Rate</h2>
|
| 45 |
-
|
| 46 |
</div>
|
| 47 |
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
|
| 48 |
<h2 class="text-xl font-semibold mb-4">Priority Distribution</h2>
|
|
@@ -66,8 +41,9 @@
|
|
| 66 |
<script>
|
| 67 |
document.addEventListener('DOMContentLoaded', () => {
|
| 68 |
const tasks = JSON.parse(localStorage.getItem('tasks')) || [];
|
|
|
|
| 69 |
// Completion chart
|
| 70 |
-
|
| 71 |
const inProgress = tasks.filter(t => t.status === 'in-progress').length;
|
| 72 |
const pending = tasks.filter(t => t.status === 'pending').length;
|
| 73 |
|
|
@@ -98,190 +74,6 @@
|
|
| 98 |
}]
|
| 99 |
}
|
| 100 |
});
|
| 101 |
-
// Enhanced Performance chart with time period selector
|
| 102 |
-
let performanceChart;
|
| 103 |
-
const renderPerformanceChart = (days = 30) => {
|
| 104 |
-
const now = new Date();
|
| 105 |
-
const cutoffDate = new Date(now.setDate(now.getDate() - days)).toISOString();
|
| 106 |
-
const recentTasks = tasks.filter(t => new Date(t.createdAt) >= new Date(cutoffDate));
|
| 107 |
-
|
| 108 |
-
// Group by date and calculate metrics
|
| 109 |
-
const dateMap = {};
|
| 110 |
-
recentTasks.forEach(task => {
|
| 111 |
-
const date = new Date(task.createdAt).toLocaleDateString();
|
| 112 |
-
if (!dateMap[date]) {
|
| 113 |
-
dateMap[date] = {
|
| 114 |
-
completed: 0,
|
| 115 |
-
created: 0,
|
| 116 |
-
pending: 0
|
| 117 |
-
};
|
| 118 |
-
}
|
| 119 |
-
dateMap[date].created++;
|
| 120 |
-
if (task.status === 'completed') dateMap[date].completed++;
|
| 121 |
-
if (task.status === 'pending') dateMap[date].pending++;
|
| 122 |
-
});
|
| 123 |
-
|
| 124 |
-
// Prepare data for chart
|
| 125 |
-
const dates = Object.keys(dateMap).sort();
|
| 126 |
-
const completedData = dates.map(date => dateMap[date].completed);
|
| 127 |
-
const createdData = dates.map(date => dateMap[date].created);
|
| 128 |
-
const pendingData = dates.map(date => dateMap[date].pending);
|
| 129 |
-
|
| 130 |
-
// Calculate stats
|
| 131 |
-
const totalCompleted = recentTasks.filter(t => t.status === 'completed').length;
|
| 132 |
-
// Calculate averages
|
| 133 |
-
const totalInProgress = createdData.reduce((sum, created, i) => sum + (created - completedData[i] - pendingData[i]), 0);
|
| 134 |
-
const totalPending = pendingData.reduce((sum, val) => sum + val, 0);
|
| 135 |
-
|
| 136 |
-
const avgCompleted = (totalCompleted / days).toFixed(1);
|
| 137 |
-
const avgInProgress = (totalInProgress / days).toFixed(1);
|
| 138 |
-
const avgPending = (totalPending / days).toFixed(1);
|
| 139 |
-
|
| 140 |
-
// Update stats displays
|
| 141 |
-
document.getElementById('avgCompletion').textContent = `${avgCompleted}/day`;
|
| 142 |
-
document.getElementById('inProgressAvg').textContent = `${avgInProgress}/day`;
|
| 143 |
-
document.getElementById('pendingAvg').textContent = `${avgPending}/day`;
|
| 144 |
-
// Create or update chart
|
| 145 |
-
const ctx = document.getElementById('performanceChart').getContext('2d');
|
| 146 |
-
|
| 147 |
-
if (performanceChart) {
|
| 148 |
-
performanceChart.data.labels = dates;
|
| 149 |
-
performanceChart.data.datasets[0].data = createdData;
|
| 150 |
-
performanceChart.data.datasets[1].data = completedData;
|
| 151 |
-
performanceChart.data.datasets[2].data = pendingData;
|
| 152 |
-
performanceChart.update();
|
| 153 |
-
} else {
|
| 154 |
-
performanceChart = new Chart(ctx, {
|
| 155 |
-
type: 'line',
|
| 156 |
-
data: {
|
| 157 |
-
labels: dates,
|
| 158 |
-
datasets: [
|
| 159 |
-
{
|
| 160 |
-
label: 'Completed',
|
| 161 |
-
data: completedData,
|
| 162 |
-
borderColor: '#10b981',
|
| 163 |
-
backgroundColor: 'rgba(16, 185, 129, 0.1)',
|
| 164 |
-
borderWidth: 3,
|
| 165 |
-
tension: 0.4,
|
| 166 |
-
pointRadius: 5,
|
| 167 |
-
pointHoverRadius: 7,
|
| 168 |
-
fill: false
|
| 169 |
-
},
|
| 170 |
-
{
|
| 171 |
-
label: 'In Progress',
|
| 172 |
-
data: createdData.map((created, i) => created - completedData[i] - pendingData[i]),
|
| 173 |
-
borderColor: '#3b82f6',
|
| 174 |
-
backgroundColor: 'rgba(59, 130, 246, 0.1)',
|
| 175 |
-
borderWidth: 3,
|
| 176 |
-
tension: 0.4,
|
| 177 |
-
pointRadius: 5,
|
| 178 |
-
pointHoverRadius: 7,
|
| 179 |
-
fill: false,
|
| 180 |
-
borderDash: [5, 5]
|
| 181 |
-
},
|
| 182 |
-
{
|
| 183 |
-
label: 'Pending',
|
| 184 |
-
data: pendingData,
|
| 185 |
-
borderColor: '#f59e0b',
|
| 186 |
-
backgroundColor: 'rgba(245, 158, 11, 0.1)',
|
| 187 |
-
borderWidth: 3,
|
| 188 |
-
tension: 0.4,
|
| 189 |
-
pointRadius: 5,
|
| 190 |
-
pointHoverRadius: 7,
|
| 191 |
-
fill: false
|
| 192 |
-
}
|
| 193 |
-
]
|
| 194 |
-
},
|
| 195 |
-
options: {
|
| 196 |
-
responsive: true,
|
| 197 |
-
maintainAspectRatio: false,
|
| 198 |
-
interaction: {
|
| 199 |
-
mode: 'index',
|
| 200 |
-
intersect: false,
|
| 201 |
-
},
|
| 202 |
-
scales: {
|
| 203 |
-
y: {
|
| 204 |
-
beginAtZero: true,
|
| 205 |
-
title: {
|
| 206 |
-
display: true,
|
| 207 |
-
text: 'Number of Tasks'
|
| 208 |
-
},
|
| 209 |
-
grid: {
|
| 210 |
-
drawBorder: false
|
| 211 |
-
}
|
| 212 |
-
},
|
| 213 |
-
x: {
|
| 214 |
-
grid: {
|
| 215 |
-
display: false
|
| 216 |
-
},
|
| 217 |
-
title: {
|
| 218 |
-
display: true,
|
| 219 |
-
text: 'Date'
|
| 220 |
-
}
|
| 221 |
-
}
|
| 222 |
-
},
|
| 223 |
-
plugins: {
|
| 224 |
-
title: {
|
| 225 |
-
display: true,
|
| 226 |
-
text: 'Task Completion Race',
|
| 227 |
-
font: {
|
| 228 |
-
size: 16,
|
| 229 |
-
weight: 'bold'
|
| 230 |
-
}
|
| 231 |
-
},
|
| 232 |
-
tooltip: {
|
| 233 |
-
callbacks: {
|
| 234 |
-
footer: (context) => {
|
| 235 |
-
const date = context[0].label;
|
| 236 |
-
const created = dateMap[date]?.created || 0;
|
| 237 |
-
const completed = dateMap[date]?.completed || 0;
|
| 238 |
-
const inProgress = created - completed - (dateMap[date]?.pending || 0);
|
| 239 |
-
return [
|
| 240 |
-
`Progress: ${Math.round((completed/created)*100)}%`,
|
| 241 |
-
`Leads: ${completed > inProgress && completed > pendingData[context[0].dataIndex] ? 'Completed' :
|
| 242 |
-
inProgress > pendingData[context[0].dataIndex] ? 'In Progress' : 'Pending'}`
|
| 243 |
-
];
|
| 244 |
-
}
|
| 245 |
-
}
|
| 246 |
-
},
|
| 247 |
-
legend: {
|
| 248 |
-
position: 'top',
|
| 249 |
-
labels: {
|
| 250 |
-
usePointStyle: true,
|
| 251 |
-
pointStyle: 'circle',
|
| 252 |
-
padding: 20,
|
| 253 |
-
font: {
|
| 254 |
-
size: 12,
|
| 255 |
-
weight: 'bold'
|
| 256 |
-
}
|
| 257 |
-
}
|
| 258 |
-
}
|
| 259 |
-
},
|
| 260 |
-
animation: {
|
| 261 |
-
duration: 1000,
|
| 262 |
-
easing: 'easeOutQuart'
|
| 263 |
-
},
|
| 264 |
-
elements: {
|
| 265 |
-
line: {
|
| 266 |
-
tension: 0.4
|
| 267 |
-
}
|
| 268 |
-
}
|
| 269 |
-
}
|
| 270 |
-
});
|
| 271 |
-
}
|
| 272 |
-
};
|
| 273 |
-
|
| 274 |
-
// Initial render
|
| 275 |
-
renderPerformanceChart(30);
|
| 276 |
-
|
| 277 |
-
// Time period selector
|
| 278 |
-
document.querySelectorAll('.time-period-btn').forEach(btn => {
|
| 279 |
-
btn.addEventListener('click', function() {
|
| 280 |
-
document.querySelectorAll('.time-period-btn').forEach(b => b.classList.remove('active', 'bg-primary', 'text-white'));
|
| 281 |
-
this.classList.add('active', 'bg-primary', 'text-white');
|
| 282 |
-
renderPerformanceChart(parseInt(this.dataset.period));
|
| 283 |
-
});
|
| 284 |
-
});
|
| 285 |
// Load comments with add form
|
| 286 |
const commentsContainer = document.getElementById('commentsContainer');
|
| 287 |
commentsContainer.innerHTML = tasks.map(task => `
|
|
|
|
| 16 |
<h1 class="text-3xl font-bold text-gray-800 mb-8">Task Reports</h1>
|
| 17 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
|
| 18 |
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
<h2 class="text-xl font-semibold mb-4">Task Completion Rate</h2>
|
| 20 |
+
<canvas id="completionChart"></canvas>
|
| 21 |
</div>
|
| 22 |
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100">
|
| 23 |
<h2 class="text-xl font-semibold mb-4">Priority Distribution</h2>
|
|
|
|
| 41 |
<script>
|
| 42 |
document.addEventListener('DOMContentLoaded', () => {
|
| 43 |
const tasks = JSON.parse(localStorage.getItem('tasks')) || [];
|
| 44 |
+
|
| 45 |
// Completion chart
|
| 46 |
+
const completed = tasks.filter(t => t.status === 'completed').length;
|
| 47 |
const inProgress = tasks.filter(t => t.status === 'in-progress').length;
|
| 48 |
const pending = tasks.filter(t => t.status === 'pending').length;
|
| 49 |
|
|
|
|
| 74 |
}]
|
| 75 |
}
|
| 76 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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