From 56f2802b4e9f6252a83709141486a94ee15b26eb Mon Sep 17 00:00:00 2001 From: Deepak_K <139794590+Dkghuser@users.noreply.github.com> Date: Sun, 10 Nov 2024 18:44:04 +0530 Subject: [PATCH 1/4] Create pfid.html --- .../pfid.html | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Financial Insights Dashboard: Personal Finance Manager/pfid.html diff --git a/Financial Insights Dashboard: Personal Finance Manager/pfid.html b/Financial Insights Dashboard: Personal Finance Manager/pfid.html new file mode 100644 index 00000000..f34e15ba --- /dev/null +++ b/Financial Insights Dashboard: Personal Finance Manager/pfid.html @@ -0,0 +1,58 @@ + + +
+ + +Budget Status:
+ +Monthly budget is set to $${monthlyBudget}.
`; + + let totalExpenses = expenses.reduce((sum, expense) => sum + expense.amount, 0); + insightsDiv.innerHTML += `Total spending so far: $${totalExpenses}
`; + + if (totalExpenses > monthlyBudget) { + insightsDiv.innerHTML += `Warning: You have exceeded your monthly budget!
`; + } +} + +// Initialize charts and insights +document.addEventListener('DOMContentLoaded', () => { + renderCharts(expenses, monthlyBudget, savingsGoals, investments); + updateInsights(); +}); From 7a51293acee91808ccce78f1990782a91e99077c Mon Sep 17 00:00:00 2001 From: Deepak_K <139794590+Dkghuser@users.noreply.github.com> Date: Sun, 10 Nov 2024 18:45:39 +0530 Subject: [PATCH 4/4] Create chart.js --- .../chart.js | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Financial Insights Dashboard: Personal Finance Manager/chart.js diff --git a/Financial Insights Dashboard: Personal Finance Manager/chart.js b/Financial Insights Dashboard: Personal Finance Manager/chart.js new file mode 100644 index 00000000..7d2eeb3e --- /dev/null +++ b/Financial Insights Dashboard: Personal Finance Manager/chart.js @@ -0,0 +1,55 @@ +// chart.js + +// Function to render all charts +function renderCharts(expenses, monthlyBudget, savingsGoals, investments) { + // Budget Chart + const budgetChart = new Chart(document.getElementById('budgetChart'), { + type: 'doughnut', + data: { + labels: ['Spent', 'Remaining'], + datasets: [{ + data: [expenses.reduce((sum, expense) => sum + expense.amount, 0), monthlyBudget - expenses.reduce((sum, expense) => sum + expense.amount, 0)], + backgroundColor: ['#FF6384', '#36A2EB'], + }] + } + }); + + // Expense Chart + const expenseChart = new Chart(document.getElementById('expenseChart'), { + type: 'pie', + data: { + labels: expenses.map(e => e.category), + datasets: [{ + data: expenses.map(e => e.amount), + backgroundColor: ['#FF6384', '#36A2EB', '#FFCE56', '#4BC0C0'], + }] + } + }); + + // Savings Goal Chart + const goalChart = new Chart(document.getElementById('goalChart'), { + type: 'bar', + data: { + labels: savingsGoals.map(g => g.name), + datasets: [{ + data: savingsGoals.map(g => g.amount), + backgroundColor: '#4BC0C0', + }] + } + }); + + // Investment Chart + const investmentChart = new Chart(document.getElementById('investmentChart'), { + type: 'pie', + data: { + labels: investments.map(i => i.name), + datasets: [{ + data: investments.map(i => i.value), + backgroundColor: ['#FF6384', '#36A2EB', '#FFCE56'], + }] + } + }); +} + +// Export the renderCharts function +export { renderCharts };