Spaces:
Running
Running
| <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> |