Skip to content

Commit

Permalink
Spendings month ordering now always correct
Browse files Browse the repository at this point in the history
A change this will cause, is that we can potentially have 0 values now, if a month has no data, but it is fine.
  • Loading branch information
Bios-Marcel committed Jul 20, 2024
1 parent a315933 commit b68130e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/link/biosmarcel/baka/view/EvaluationView.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,15 @@ private void updateCharts() {
final XYChart.Series<String, Number> categorySeries = new XYChart.Series<>();
categorySeries.setName(category.getKey());

// Hack to ensure that the order is correct in case there are any month values missing for a month, in which
// case we can get incorrectly sorted months.
for (var month = startDate.get().getMonth(); month.getValue() <= endDate.get().getMonth().getValue(); month = month.plus(1)) {
categorySeries.getData().add(new XYChart.Data<>(
renderMonth(month),
0
));
}

for (final var monthToAmount : Objects.requireNonNull(category.getValue()).entrySet()) {
categorySeries.getData().add(new XYChart.Data<>(
renderMonth(monthToAmount.getKey()),
Expand Down

0 comments on commit b68130e

Please sign in to comment.