From 12d42ea06df3242ad58ed9002a9332e48290ee52 Mon Sep 17 00:00:00 2001 From: adontu06 Date: Wed, 14 May 2025 10:17:02 -0700 Subject: [PATCH] Line and Pie Charts for Expense Transation (Components) --- .../NewTransaction/TransactionLineChart.tsx | 41 +++++++++++++++ .../NewTransaction/TransactionPieChart.tsx | 52 +++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 frontend/components/NewTransaction/TransactionLineChart.tsx create mode 100644 frontend/components/NewTransaction/TransactionPieChart.tsx diff --git a/frontend/components/NewTransaction/TransactionLineChart.tsx b/frontend/components/NewTransaction/TransactionLineChart.tsx new file mode 100644 index 0000000..3536948 --- /dev/null +++ b/frontend/components/NewTransaction/TransactionLineChart.tsx @@ -0,0 +1,41 @@ +import React from "react"; +import { View, Text } from "react-native"; +import { + LineChart, + Line, + XAxis, + YAxis, + CartesianGrid, + Tooltip, + ResponsiveContainer, +} from "recharts"; + +// Dummy data for now – replace with props later if you want +const data = [ + { name: "Mon", amount: 50 }, + { name: "Tue", amount: 80 }, + { name: "Wed", amount: 40 }, + { name: "Thu", amount: 100 }, + { name: "Fri", amount: 60 }, +]; + +const TransactionChart: React.FC = () => { + return ( + + + Daily Spending Amount + + + + + + + + + + + + ); +}; + +export default TransactionChart; \ No newline at end of file diff --git a/frontend/components/NewTransaction/TransactionPieChart.tsx b/frontend/components/NewTransaction/TransactionPieChart.tsx new file mode 100644 index 0000000..afd5d08 --- /dev/null +++ b/frontend/components/NewTransaction/TransactionPieChart.tsx @@ -0,0 +1,52 @@ +import React from "react"; +import { View, Text } from "react-native"; +import { + PieChart, + Pie, + Cell, + Tooltip, + Legend, + ResponsiveContainer, +} from "recharts"; + +// Dummy category-spending data – replace or pass via props +const data = [ + { category: "Food", value: 150 }, + { category: "Drinks", value: 75 }, + { category: "Entertainment", value: 100 }, + { category: "Groceries", value: 125 }, + { category: "Other", value: 50 }, +]; + +const COLORS = ["#8884d8", "#82ca9d", "#ffc658", "#ff8042", "#00C49F"]; + +const CategoryPieChart: React.FC = () => { + return ( + + + Spending by Category + + + + + {data.map((entry, index) => ( + + ))} + + + + + + + ); +}; + +export default CategoryPieChart; \ No newline at end of file