Skip to content

Commit

Permalink
Merge pull request #141 from wwweert123/VisDG
Browse files Browse the repository at this point in the history
Add to DG and fix bugs
  • Loading branch information
wwweert123 authored Nov 1, 2023
2 parents 0544e3f + 59beb3d commit 62ab3bf
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
6 changes: 3 additions & 3 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ the data one upon exiting the program with the `exit` command.

This feature is implemented with the help of [XChart](https://knowm.org/open-source/xchart/), a simple charting library for Java by Knowm.

By typing in the vis command with the appropriate arguments (/s and /t), users will be able to visualize their income or expense
using visualization tools (Piechart, Bar Chart)
By typing in the vis command with the appropriate arguments (`/s` and `/t`), users will be able to visualize their
income or expense using visualization tools (Piechart, Bar Chart or Radar Chart)

Demo:

Expand Down Expand Up @@ -132,7 +132,7 @@ specified cashflow entry according to type using a Hashmap which is returned and

Visualizer's Role:

According to the chart type (Pie/Bar) argument and the Hashmap obtained from the categorizer passed in,
According to the chart type (Pie/Bar/Radar) argument and the Hashmap obtained from the categorizer passed in,
the visualizer displays the specified visualization chart by calling the charting library Xchart.

### Class Diagram
Expand Down
21 changes: 15 additions & 6 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ Use watchlist command to view updated Watchlist

### Visualizing your cashflow: `vis`

Using this command to visualize your income or expenses in a pie chart or bar chart
Using this command to visualize your income or expenses in a pie chart, bar chart or radar chart

Format: `vis /t TYPE /c TOOL`

Expand All @@ -550,10 +550,11 @@ Format: `vis /t TYPE /c TOOL`
| Income Cashflows `Income` |
| Expense Cashflows `Expense` |

| Tool `/c` |
|----------------|
| PieChart `pie` |
| BarChart `bar` |
| Tool `/c` |
|--------------------|
| PieChart `pie` |
| BarChart `bar` |
| RadarChart `radar` |

Example of usage: `vis /t expense /c pie`

Expand All @@ -565,14 +566,22 @@ Displaying piechart for expense

![](images/vis/visOutput.png)

Example of usage: `vis /t expense /c bar`
Example of usage: `vis /t income /c bar`

```
Displaying barchart for income
```

![](images/vis/barOuput.png)

Example of usage: `vis /t income /c radar`

```
Displaying radarchart for income
```

![](images/vis/radarOutput.png)

### Exiting the program: `exit`

Exits the program.
Expand Down
7 changes: 4 additions & 3 deletions docs/diagrams/vis/visualisationClass.puml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ class Categorizer #HoneyDew {
}

class Visualizer #Beige {
+<u>displayChart(chart: String, cashFlowByCat: Map, type: String)
+ <u>displayPieChart(cashFlowByCat: Map, type: String)
+ <u>displayBarChart(cashFlowByCat: Map, type: String)
+<u>displayChart(chart: String, cashflowByCat: HashMap, type: String)
+ <u>displayPieChart(cashflowByCat: HashMap, type: String)
+ <u>displayBarChart(cashflowByCat: HashMap, type: String)
+ <u>displayRadarChart (cashflowByCat: HashMap, type: String)
}

"{abstract}\nCommand" <|-- VisCommand
Expand Down
Binary file added docs/images/vis/radarOutput.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/vis/visualisationClass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static void displayBarChart (HashMap<String, Double> cashflowByCat, Strin
keys.add(set.getKey());
values.add(set.getValue());
}
chart.addSeries("Expense", keys, values);
chart.addSeries(StringUtils.capitalize(type), keys, values);

logger.log(Level.INFO, "Displaying Bar Chart");
JFrame swHR = new SwingWrapper<>(chart).displayChart();
Expand All @@ -112,7 +112,7 @@ public static void displayRadarChart (HashMap<String, Double> cashflowByCat, Str

radarChart.getStyler().setSeriesColors(sliceColors);

String[] keys = new String[0];
String[] keys;
switch (type) {
case "income":
keys = IncomeType.getNames(IncomeType.class);
Expand Down

0 comments on commit 62ab3bf

Please sign in to comment.