diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index 44d26e8343..1574453f80 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -218,6 +218,38 @@ Sequence Diagram The following sequence diagram illustrates the sequence of interactions involved in the editing of a transaction: ![](./uml/uml-images/processList.png) + +### [Implemented] Insights + +#### Description + +This feature provides insights into the categorized expenses and incomes of the user. It utilizes the Insight +class to calculate and display pie charts representing the distribution of expenses and incomes across +different categories.
+ +#### Design and Implementation + +1. The displayCategoryInsight method iterates through the list of transactions and calculates the total income +and expense amounts for each category. It then calls the displayPieChart method to visualize these insights +using pie charts. + +2. The displayPieChart method creates separate pie charts for income and expense categories using the XChart +library. It customizes the appearance of the charts and adds series for each category with their respective +income or expense amounts. + +3. The indexOf method is a private helper function used to find the index of a specific category within an +array +of categories. + +4. The closeInsightFrames method is responsible for closing any open frames related to insights, specifically +targeting frames related to income and expense insights to ensure proper cleanup and resource management. + +The following is the class diagram for Insights class + +![](./uml/uml-images/insightDiagram.png) + + + ## Product scope ### Target user profile diff --git a/docs/team/vavinan.md b/docs/team/vavinan.md index f5e4fe92e7..57a4a9b9f9 100644 --- a/docs/team/vavinan.md +++ b/docs/team/vavinan.md @@ -14,6 +14,7 @@ It is optimized for use via a Command Line Interface (CLI) and is written in Jav * Developer Guide: * Added implementation details for the feature `delete`. * Added implementation details for the feature `edit`. + * Added implementation details for the feature `insights`. ### Feature 1 - Deleting Transaction 1. Created the `removeTransaction` method to handle deletion of a transaction based on its index in the list. diff --git a/docs/uml/insightDiagram.puml b/docs/uml/insightDiagram.puml new file mode 100644 index 0000000000..37fe06cedd --- /dev/null +++ b/docs/uml/insightDiagram.puml @@ -0,0 +1,57 @@ +@startuml +skinparam classAttributeIconSize 0 +hide abstract circle +hide class circle +hide enum circle +package budgetbuddy.insight { + class Insight { + +displayCategoryInsight(transactionArrayList: ArrayList): void + -displayPieChart(categoryArray: Category[], incomeArray: Double[], expenseArray: Double[]): void + -indexOf(array: Category[], target: Category): int + +closeInsightFrames(): void + } +} + +package budgetbuddy.categories { + enum Category <> { + +Category(categoryNum: int, categoryName: String) + +getCategoryName(): String + +getCategoryNum(): int + } +} + +package budgetbuddy.transaction.type { + abstract class Transaction{ + -category: Category {dependency} + +Transaction(accountNumber: int, accountName: String, + description: String, amount: double, date: String) + +getAmount(): double + +getCategory(): Category + +setCategory(category: Category): void + {abstract} +getTransactionType() : String + } +} + +package org.knowm.xchart { + class PieChart + class PieChartBuilder + class XChartPanel + class PieStyler +} + +class JFrame { + +dispose(): void +} +class JPanel + +Insight ...> Category : " {dependency} " +Insight ..> Transaction: {dependency} +Transaction --> "*" Category: {association} +Insight ..> JFrame :{creates 2} +Insight ..> JPanel: {creates 2} +Insight ..> PieChart: {uses 2} +Insight ..> PieChartBuilder: {uses 2} +Insight ..> XChartPanel :{uses 2} +Insight ..> PieStyler: {uses 2} + +@enduml diff --git a/docs/uml/uml-images/insightDiagram.png b/docs/uml/uml-images/insightDiagram.png new file mode 100644 index 0000000000..e3a2f3f432 Binary files /dev/null and b/docs/uml/uml-images/insightDiagram.png differ