From 41774bda487d9929b5765ed4bf76031c82e01e6a Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Wed, 28 Aug 2019 11:18:01 +0200 Subject: [PATCH] Group burned BSQ by day --- .../main/dao/economy/supply/SupplyView.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/main/dao/economy/supply/SupplyView.java b/desktop/src/main/java/bisq/desktop/main/dao/economy/supply/SupplyView.java index 43b0b77b033..6cb4b51519f 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/economy/supply/SupplyView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/economy/supply/SupplyView.java @@ -82,6 +82,7 @@ public class SupplyView extends ActivatableView implements DaoStateListener { private static final String MONTH = "month"; + private static final String DAY = "day"; private final DaoFacade daoFacade; private DaoStateService daoStateService; @@ -113,6 +114,7 @@ private SupplyView(DaoFacade daoFacade, public void initialize() { ADJUSTERS.put(MONTH, TemporalAdjusters.firstDayOfMonth()); + ADJUSTERS.put(DAY, TemporalAdjusters.ofDateAdjuster(d -> d)); createSupplyIncreasedInformation(); createSupplyReducedInformation(); @@ -161,7 +163,7 @@ private void createSupplyIncreasedInformation() { seriesBSQIssued = new XYChart.Series<>(); - createChart(seriesBSQIssued, Res.get("dao.factsAndFigures.supply.issued")); + createChart(seriesBSQIssued, Res.get("dao.factsAndFigures.supply.issued"), "MMM uu"); } private void createSupplyReducedInformation() { @@ -173,7 +175,7 @@ private void createSupplyReducedInformation() { Res.get("dao.factsAndFigures.supply.invalidTxs"), Layout.FIRST_ROW_AND_GROUP_DISTANCE).second; seriesBSQBurnt = new XYChart.Series<>(); - createChart(seriesBSQBurnt, Res.get("dao.factsAndFigures.supply.burnt")); + createChart(seriesBSQBurnt, Res.get("dao.factsAndFigures.supply.burnt"), "d MMM"); } private void createSupplyLockedInformation() { @@ -193,7 +195,8 @@ private void createSupplyLockedInformation() { Res.get("dao.factsAndFigures.supply.totalConfiscatedAmount")).second; } - private void createChart(XYChart.Series series, String seriesLabel) { + @SuppressWarnings("unchecked") + private void createChart(XYChart.Series series, String seriesLabel, String datePattern) { NumberAxis xAxis = new NumberAxis(); xAxis.setForceZeroInRange(false); xAxis.setAutoRanging(true); @@ -205,7 +208,7 @@ private void createChart(XYChart.Series series, String seriesLab public String toString(Number timestamp) { LocalDateTime localDateTime = LocalDateTime.ofEpochSecond(timestamp.longValue(), 0, OffsetDateTime.now(ZoneId.systemDefault()).getOffset()); - return localDateTime.format(DateTimeFormatter.ofPattern("MMM uu", GlobalSettings.getLocale())); + return localDateTime.format(DateTimeFormatter.ofPattern(datePattern, GlobalSettings.getLocale())); } @Override @@ -296,15 +299,15 @@ private void updateCharts() { Set burntTxs = new HashSet<>(daoStateService.getBurntFeeTxs()); burntTxs.addAll(daoStateService.getInvalidTxs()); - Map> burntBsqByMonth = burntTxs.stream() + Map> burntBsqByDay = burntTxs.stream() .sorted(Comparator.comparing(Tx::getTime)) .collect(Collectors.groupingBy(item -> new Date(item.getTime()).toLocalDate() - .with(ADJUSTERS.get(MONTH)))); + .with(ADJUSTERS.get(DAY)))); - List> updatedBurntBsq = burntBsqByMonth.keySet().stream() + List> updatedBurntBsq = burntBsqByDay.keySet().stream() .map(date -> { ZonedDateTime zonedDateTime = date.atStartOfDay(ZoneId.systemDefault()); - return new XYChart.Data(zonedDateTime.toInstant().getEpochSecond(), burntBsqByMonth.get(date) + return new XYChart.Data(zonedDateTime.toInstant().getEpochSecond(), burntBsqByDay.get(date) .stream() .mapToDouble(Tx::getBurntBsq) .sum()