Spaces:
Running
Running
File size: 20,686 Bytes
5ff1fa4 f6e40df 5ff1fa4 | 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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sector Analysis - Stockfolio PKX</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body class="bg-gray-50">
<!-- Navbar -->
<nav class="bg-white shadow-sm">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex items-center">
<div class="flex-shrink-0 flex items-center">
<i data-feather="trending-up" class="text-primary-500 h-8 w-8"></i>
<span class="ml-2 text-xl font-bold text-gray-900">Stockfolio <span class="text-secondary-500">PKX</span></span>
</div>
<div class="hidden sm:ml-6 sm:flex sm:space-x-8">
<a href="index.html" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">Dashboard</a>
<a href="psx-companies.html" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">PSX Companies</a>
<a href="sector-analysis.html" class="border-primary-500 text-gray-900 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">Sector Analysis</a>
<a href="uac-reports.html" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">UAC Reports</a>
</div>
</div>
<div class="hidden sm:ml-6 sm:flex sm:items-center">
<div class="flex space-x-2">
<a href="#" class="bg-green-500 hover:bg-green-600 text-white px-3 py-1 rounded-full text-sm flex items-center">
<i data-feather="facebook" class="w-4 h-4 mr-1"></i> Login
</a>
<a href="#" class="bg-blue-500 hover:bg-blue-600 text-white px-3 py-1 rounded-full text-sm flex items-center">
<i data-feather="twitter" class="w-4 h-4 mr-1"></i> Login
</a>
<a href="#" class="bg-red-500 hover:bg-red-600 text-white px-3 py-1 rounded-full text-sm flex items-center">
<i data-feather="mail" class="w-4 h-4 mr-1"></i> Login
</a>
</div>
</div>
<div class="-mr-2 flex items-center sm:hidden">
<button type="button" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-primary-500">
<i data-feather="menu"></i>
</button>
</div>
</div>
</div>
</nav>
<!-- Main Content -->
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
<h1 class="text-3xl font-bold text-gray-900 mb-8">PSX Sector Analysis</h1>
<!-- Sector Performance Overview -->
<div class="mb-12">
<h2 class="text-2xl font-semibold text-gray-900 mb-6">Sector Performance</h2>
<div class="bg-white shadow rounded-lg p-6">
<canvas id="sectorPerformanceChart" height="400"></canvas>
</div>
</div>
<!-- Sector Breakdown -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8 mb-12">
<div class="bg-white shadow rounded-lg p-6">
<div class="flex items-center justify-between mb-6">
<h3 class="text-lg font-medium text-gray-900">Sector Weightage</h3>
<span class="px-3 py-1 rounded-full text-sm font-medium bg-primary-100 text-primary-800">
KSE-100
</span>
</div>
<canvas id="sectorWeightageChart" height="300"></canvas>
</div>
<div class="bg-white shadow rounded-lg p-6">
<div class="flex items-center justify-between mb-6">
<h3 class="text-lg font-medium text-gray-900">Top Gainers by Sector</h3>
<span class="px-3 py-1 rounded-full text-sm font-medium bg-green-100 text-green-800">
Today
</span>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Sector</th>
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Change</th>
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Top Stock</th>
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Stock Change</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200" id="sectorGainersTable">
<tr>
<td colspan="4" class="text-center py-8">
<i data-feather="loader" class="animate-spin h-8 w-8 text-primary-500 mx-auto"></i>
<p class="mt-2 text-gray-500">Loading sector data...</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- Sector Comparison -->
<div>
<h2 class="text-2xl font-semibold text-gray-900 mb-6">Sector Comparison</h2>
<div class="bg-white shadow rounded-lg p-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
<div>
<h3 class="text-lg font-medium text-gray-900 mb-4">Select Sectors to Compare</h3>
<div class="space-y-3">
<div class="flex items-center">
<input id="banking" type="checkbox" checked class="h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded">
<label for="banking" class="ml-2 block text-sm text-gray-900">Banking & Finance</label>
</div>
<div class="flex items-center">
<input id="oil" type="checkbox" checked class="h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded">
<label for="oil" class="ml-2 block text-sm text-gray-900">Oil & Gas</label>
</div>
<div class="flex items-center">
<input id="cement" type="checkbox" class="h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded">
<label for="cement" class="ml-2 block text-sm text-gray-900">Cement</label>
</div>
<div class="flex items-center">
<input id="power" type="checkbox" class="h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded">
<label for="power" class="ml-2 block text-sm text-gray-900">Power</label>
</div>
<div class="flex items-center">
<input id="textile" type="checkbox" class="h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded">
<label for="textile" class="ml-2 block text-sm text-gray-900">Textile</label>
</div>
<button class="mt-4 bg-primary-500 hover:bg-primary-600 text-white px-4 py-2 rounded-md">
Update Comparison
</button>
</div>
</div>
<div>
<canvas id="sectorComparisonChart" height="300"></canvas>
</div>
</div>
</div>
</div>
</div>
<!-- Footer -->
<footer class="bg-gray-800">
<div class="max-w-7xl mx-auto py-12 px-4 sm:px-6 lg:px-8">
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
<div>
<h3 class="text-white text-lg font-semibold mb-4">Stockfolio PKX</h3>
<p class="text-gray-300 text-sm">
Pakistan Stock Exchange data and analytics platform with SECP UAC compliance.
</p>
</div>
<div>
<h3 class="text-white text-lg font-semibold mb-4">Quick Links</h3>
<ul class="space-y-2">
<li><a href="index.html" class="text-gray-300 hover:text-white text-sm">Dashboard</a></li>
<li><a href="psx-companies.html" class="text-gray-300 hover:text-white text-sm">PSX Companies</a></li>
<li><a href="sector-analysis.html" class="text-gray-300 hover:text-white text-sm">Sector Analysis</a></li>
<li><a href="uac-reports.html" class="text-gray-300 hover:text-white text-sm">UAC Reports</a></li>
</ul>
</div>
<div>
<h3 class="text-white text-lg font-semibold mb-4">Connect</h3>
<div class="flex space-x-4">
<a href="#" class="sso-login text-gray-300 hover:text-white" data-provider="facebook">
<i data-feather="facebook"></i>
</a>
<a href="#" class="sso-login text-gray-300 hover:text-white" data-provider="twitter">
<i data-feather="twitter"></i>
</a>
<a href="#" class="sso-login text-gray-300 hover:text-white" data-provider="google">
<i data-feather="mail"></i>
</a>
<a href="#" class="text-gray-300 hover:text-white">
<i data-feather="smartphone"></i>
</a>
</div>
</div>
</div>
<div class="mt-8 pt-8 border-t border-gray-700">
<p class="text-gray-300 text-sm text-center">
© 2023 Stockfolio PKX. SECP UAC compliant. All rights reserved.
</p>
</div>
</div>
</footer>
<script>
document.addEventListener('DOMContentLoaded', function() {
feather.replace();
// Load sector data
async function loadSectorData() {
try {
const response = await StockfolioAPI.getSectors();
initCharts(response.data);
renderSectorGainers(response.data.gainers);
} catch (error) {
console.error('Error loading sector data:', error);
document.getElementById('sectorGainersTable').innerHTML = `
<tr>
<td colspan="4" class="text-center py-8 text-red-500">
Failed to load sector data. Please try again later.
</td>
</tr>
`;
}
}
function initCharts(sectorData) {
// Sector Performance Chart
const performanceCtx = document.getElementById('sectorPerformanceChart').getContext('2d');
new Chart(performanceCtx, {
type: 'bar',
data: {
labels: sectorData.performance.map(s => s.sector),
datasets: [{
label: '1 Month Change (%)',
data: sectorData.performance.map(s => s.change),
backgroundColor: sectorData.performance.map(s =>
s.change > 0 ? '#10b981' : '#ef4444'
),
borderWidth: 0
}]
},
options: {
responsive: true,
plugins: {
legend: {
display: false
},
tooltip: {
callbacks: {
label: function(context) {
return `${context.raw > 0 ? '+' : ''}${context.raw}%`;
}
}
}
},
scales: {
y: {
beginAtZero: false,
grid: {
drawBorder: false
},
ticks: {
callback: function(value) {
return value + '%';
}
}
},
x: {
grid: {
display: false
}
}
}
}
});
// Sector Weightage Chart
const weightageCtx = document.getElementById('sectorWeightageChart').getContext('2d');
new Chart(weightageCtx, {
type: 'pie',
data: {
labels: sectorData.weightage.map(s => s.sector),
datasets: [{
data: sectorData.weightage.map(s => s.percentage),
backgroundColor: [
'#10b981',
'#6366f1',
'#f59e0b',
'#ef4444',
'#8b5cf6',
'#14b8a6',
'#ec4899'
],
borderWidth: 0
}]
},
options: {
responsive: true,
plugins: {
legend: {
position: 'right',
labels: {
boxWidth: 12,
padding: 20,
usePointStyle: true,
pointStyle: 'circle'
}
},
tooltip: {
callbacks: {
label: function(context) {
return `${context.label}: ${context.raw}%`;
}
}
}
}
}
});
// Sector Comparison Chart
const comparisonCtx = document.getElementById('sectorComparisonChart').getContext('2d');
new Chart(comparisonCtx, {
type: 'line',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
datasets: [
{
label: 'Banking & Finance',
data: [100, 110, 115, 120, 118, 125],
borderColor: '#10b981',
backgroundColor: 'rgba(16, 185, 129, 0.05)',
borderWidth: 2,
tension: 0.3
},
{
label: 'Oil & Gas',
data: [100, 105, 107, 112, 115, 110],
borderColor: '#6366f1',
backgroundColor: 'rgba(99, 102, 241, 0.05)',
borderWidth: 2,
tension: 0.3
}
]
},
options: {
responsive: true,
plugins: {
tooltip: {
callbacks: {
label: function(context) {
return `${context.dataset.label}: ${context.raw} (${context.raw - 100 > 0 ? '+' : ''}${context.raw - 100}%)`;
}
}
}
},
scales: {
y: {
beginAtZero: false,
min: 90,
grid: {
drawBorder: false
},
ticks: {
callback: function(value) {
return value + ' (Base 100)';
}
}
},
x: {
grid: {
display: false
}
}
}
}
});
}
function renderSectorGainers(gainers) {
const tableBody = document.getElementById('sectorGainersTable');
tableBody.innerHTML = '';
gainers.forEach(gainer => {
const changeClass = gainer.change > 0 ?
'text-green-600' :
'text-red-600';
const changeIcon = gainer.change > 0 ?
'arrow-up-right' :
'arrow-down-left';
const row = document.createElement('tr');
row.innerHTML = `
<td class="px-4 py-4 whitespace-nowrap">${gainer.sector}</td>
<td class="px-4 py-4 whitespace-nowrap ${changeClass}">
<i data-feather="${changeIcon}" class="inline w-4 h-4 mr-1"></i>
${gainer.change > 0 ? '+' : ''}${gainer.change}%
</td>
<td class="px-4 py-4 whitespace-nowrap">${gainer.topStock}</td>
<td class="px-4 py-4 whitespace-nowrap ${changeClass}">
${gainer.stockChange > 0 ? '+' : ''}${gainer.stockChange}%
</td>
`;
tableBody.appendChild(row);
});
feather.replace();
}
loadSectorData();
});
</script>
</body>
</html> |