Source:
private CategoryDataset setupMonthlyDataset() { SimpleDateFormat df = new SimpleDateFormat("MMM-yyyy"); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); ArrayList<Transaction> transactions = getCampaign().getFinances().getAllTransactions(); Calendar cal = Calendar.getInstance(); String pastMonthYear = ""; Money monthlyRevenue = Money.zero(); Money monthlyExpenditures = Money.zero(); for (int i = 0; i < transactions.size(); i++) { cal.setTime(transactions.get(i).getDate()); if (pastMonthYear.equals(df.format(cal.getTime()))) { if (transactions.get(i).getAmount().isPositive()) { monthlyRevenue = monthlyRevenue.plus(transactions.get(i).getAmount()); } else { monthlyExpenditures = monthlyExpenditures.plus(transactions.get(i).getAmount()); } } else { if (i != 0) { dataset.addValue(monthlyRevenue.getAmount().doubleValue(), resourceMap.getString("graphMonthlyRevenue.text"), pastMonthYear); dataset.addValue(monthlyExpenditures.getAmount().doubleValue(), resourceMap.getString("graphMonthlyExpenditures.text"), pastMonthYear); monthlyRevenue = Money.zero(); monthlyExpenditures = Money.zero(); } pastMonthYear = df.format(cal.getTime()); if (transactions.get(i).getAmount().isPositive()) { monthlyRevenue = transactions.get(i).getAmount(); } else { monthlyExpenditures = transactions.get(i).getAmount(); } } if (i == transactions.size()-1) { dataset.addValue(monthlyRevenue.getAmount().doubleValue(), resourceMap.getString("graphMonthlyRevenue.text"), pastMonthYear); dataset.addValue(monthlyExpenditures.getAmount().doubleValue(), resourceMap.getString("graphMonthlyExpenditures.text"), pastMonthYear); } } return dataset; }

Target:
private CategoryDataset setupMonthlyDataset() { SimpleDateFormat df = new SimpleDateFormat("MMM-yyyy"); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); ArrayList<Transaction> transactions = getCampaign().getFinances().getAllTransactions(); Calendar cal = Calendar.getInstance(); String pastMonthYear = ""; Money monthlyRevenue = Money.zero(); Money monthlyExpenditures = Money.zero(); for (int i = 0; i < transactions.size(); i++) { cal.setTime(transactions.get(i).getDate()); if (pastMonthYear.equals(df.format(cal.getTime()))) { if (transactions.get(i).getAmount().isPositive()) { monthlyRevenue = monthlyRevenue.plus(transactions.get(i).getAmount()); } else { monthlyExpenditures = monthlyExpenditures.plus(transactions.get(i).getAmount().absolute()); } } else { if (i != 0) { dataset.addValue(monthlyRevenue.getAmount().doubleValue(), resourceMap.getString("graphMonthlyRevenue.text"), pastMonthYear); dataset.addValue(monthlyExpenditures.getAmount().doubleValue(), resourceMap.getString("graphMonthlyExpenditures.text"), pastMonthYear); monthlyRevenue = Money.zero(); monthlyExpenditures = Money.zero(); } pastMonthYear = df.format(cal.getTime()); if (transactions.get(i).getAmount().isPositive()) { monthlyRevenue = transactions.get(i).getAmount(); } else { monthlyExpenditures = transactions.get(i).getAmount().absolute(); } } if (i == transactions.size()-1) { dataset.addValue(monthlyRevenue.getAmount().doubleValue(), resourceMap.getString("graphMonthlyRevenue.text"), pastMonthYear); dataset.addValue(monthlyExpenditures.getAmount().doubleValue(), resourceMap.getString("graphMonthlyExpenditures.text"), pastMonthYear); } } return dataset; }