File size: 5,759 Bytes
69b5d6e | 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 |
document.addEventListener('DOMContentLoaded', function() {
// Register dashboard cards component
if (!customElements.get('dashboard-card')) {
customElements.define('dashboard-card', class extends HTMLElement {});
}
// Portfolio data
const portfolioData = {
"HDFC Bank Ltd": { value: 28425.57, percentage: 9.82, industry: "Banking" },
"Bajaj Holdings & Investment Ltd.": { value: 27400.34, percentage: 9.47, industry: "Holding Companies" },
"Kotak Mahindra Bank Ltd": { value: 26014.42, percentage: 8.99, industry: "Banking" },
"ITC Ltd": { value: 25127.19, percentage: 8.68, industry: "Tobacco" },
"ICICI Bank Ltd": { value: 14669.21, percentage: 5.07, industry: "Banking" },
"Bajaj Finance Ltd.": { value: 13727.38, percentage: 4.74, industry: "Finance" },
"Power Grid Corporation of India Ltd.": { value: 12370.09, percentage: 4.27, industry: "Energy" },
"Tata Consultancy Services Ltd": { value: 12041.54, percentage: 4.16, industry: "IT Services" },
"Infosys Ltd": { value: 10106.66, percentage: 3.49, industry: "IT Services" },
"Mahindra & Mahindra Ltd": { value: 8514.66, percentage: 2.94, industry: "Automobiles" }
};
// Asset allocation data
const assetData = {
labels: ["Equity", "Money Market", "Cash"],
datasets: [{
data: [91.62, 8.32, 0.06],
backgroundColor: ["#4f46e5", "#10b981", "#3b82f6"],
borderWidth: 0
}]
};
// Portfolio history data
const historyData = {
labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep"],
datasets: [{
label: "NAV (₹)",
data: [12.45, 12.52, 12.58, 12.62, 12.71, 12.78, 12.82, 12.88, 12.89],
borderColor: "#4f46e5",
backgroundColor: "rgba(79, 70, 229, 0.1)",
fill: true,
tension: 0.3
}]
};
// Initialize charts
function initCharts() {
// Asset allocation pie chart
const assetCtx = document.getElementById('assetChart').getContext('2d');
new Chart(assetCtx, {
type: 'pie',
data: assetData,
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'right',
},
tooltip: {
callbacks: {
label: function(context) {
return `${context.label}: ${context.raw}%`;
}
}
}
}
}
});
// Top holdings bar chart
const holdingsCtx = document.getElementById('holdingsChart').getContext('2d');
const holdingsLabels = Object.keys(portfolioData);
const holdingsValues = Object.values(portfolioData).map(item => item.value);
new Chart(holdingsCtx, {
type: 'bar',
data: {
labels: holdingsLabels,
datasets: [{
label: 'Value (₹ Cr)',
data: holdingsValues,
backgroundColor: '#4f46e5',
borderRadius: 4
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true,
title: {
display: true,
text: 'Value (₹ Cr)'
}
},
x: {
ticks: {
autoSkip: false,
maxRotation: 45,
minRotation: 45
}
}
},
plugins: {
legend: {
display: false
}
}
}
});
// Portfolio history line chart
const historyCtx = document.getElementById('historyChart').getContext('2d');
new Chart(historyCtx, {
type: 'line',
data: historyData,
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: false,
title: {
display: true,
text: 'NAV (₹)'
}
}
}
}
});
}
// Populate table with portfolio data
function populateTable() {
const tableBody = document.querySelector('tbody');
Object.entries(portfolioData).forEach(([company, data]) => {
const row = document.createElement('tr');
row.innerHTML = `
<td class="px-6 py-4 whitespace-nowrap font-medium text-gray-900">${company}</td>
<td class="px-6 py-4 whitespace-nowrap text-gray-500">${data.industry}</td>
<td class="px-6 py-4 whitespace-nowrap text-gray-900">${data.value.toLocaleString('en-IN')}</td>
<td class="px-6 py-4 whitespace-nowrap text-gray-900">${data.percentage}%</td>
`;
tableBody.appendChild(row);
});
}
// Initialize everything
initCharts();
populateTable();
// Refresh feather icons after dynamic content
setTimeout(() => feather.replace(), 100);
}); |