Skip to content

Commit

Permalink
Fix bar chart legend crash
Browse files Browse the repository at this point in the history
  • Loading branch information
aint committed Nov 16, 2015
1 parent fd1fe4b commit 7e36bd9
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,22 @@ private BarData getData() {
double balance = mAccountsDbAdapter.getAccountsBalance(
Collections.singletonList(account.getUID()), start, end).asDouble();
if (balance != 0) {
stack.add((float) balance);

String accountName = account.getName();
while (labels.contains(accountName)) {
if (!accountToColorMap.containsKey(account.getUID())) {
for (String label : labels) {
if (label.equals(accountName)) {
accountName += " ";
}
}
} else {
break;
}
}
labels.add(accountName);

if (!accountToColorMap.containsKey(account.getUID())) {
Integer color;
if (mUseAccountColor) {
Expand All @@ -221,10 +237,8 @@ private BarData getData() {
}
accountToColorMap.put(account.getUID(), color);
}

stack.add((float) balance);
labels.add(account.getName());
colors.add(accountToColorMap.get(account.getUID()));

Log.d(TAG, mAccountType + tmpDate.toString(" MMMM yyyy ") + account.getName() + " = " + stack.get(stack.size() - 1));
}
}
Expand Down Expand Up @@ -476,8 +490,7 @@ public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
} else {
sum = entry.getNegativeSum() + entry.getPositiveSum();
}
Log.w(TAG, "sum2 = " + sum);
selectedValueTextView.setText(String.format(SELECTED_VALUE_PATTERN, label, value, value / sum * 100));
selectedValueTextView.setText(String.format(SELECTED_VALUE_PATTERN, label.trim(), value, value / sum * 100));
}

@Override
Expand Down

0 comments on commit 7e36bd9

Please sign in to comment.