private void fillModel(Date[] dates, Map<Currency, Map<Date, IncomeExpense>> data, ModelMap modelMap) {
Map<Currency, BigDecimal> totalMax = new HashMap<Currency, BigDecimal>();
Map<Currency, IncomeExpense> maxValues = new HashMap<Currency, IncomeExpense>();
Map<Currency, List<NameValuePair<Date, IncomeExpense>>> dataAsSet = new HashMap<Currency, List<NameValuePair<Date, IncomeExpense>>>();
for (Currency currency : data.keySet()) {
IncomeExpense max = maxValues.containsKey(currency) ? maxValues.get(currency) : new IncomeExpense();
List<NameValuePair<Date, IncomeExpense>> orderedData = new ArrayList<NameValuePair<Date, IncomeExpense>>();
for (Date date : dates) {
IncomeExpense value = data.get(currency).get(date);
max.setKey(max.getKey().doubleValue() > value.getKey().doubleValue() ? max.getKey() : value.getKey());
max.setValue(max.getValue().doubleValue() > value.getValue().doubleValue() ? max.getValue() : value.getValue());
orderedData.add(new NameValuePair<Date, IncomeExpense>(date, value));
}
maxValues.put(currency, max);
dataAsSet.put(currency, orderedData);
}