From d2291ef870979bfaaea4da786d5d31b55e3ae84f Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 16 Jul 2020 10:48:00 +0200 Subject: [PATCH] balancechart add interstitials --- .../sparrow/control/BalanceChart.java | 18 +++++++++++++++++- .../sparrow/wallet/transactions.css | 6 +++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/BalanceChart.java b/src/main/java/com/sparrowwallet/sparrow/control/BalanceChart.java index 9ac36b1d..cff4fc8c 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/BalanceChart.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/BalanceChart.java @@ -9,6 +9,7 @@ import javafx.beans.NamedArg; import javafx.scene.Node; import javafx.scene.chart.*; +import java.util.Date; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -39,6 +40,21 @@ public class BalanceChart extends LineChart { .map(txEntry -> new XYChart.Data<>((Number)txEntry.getBlockTransaction().getDate().getTime(), (Number)txEntry.getBalance(), txEntry)) .collect(Collectors.toList()); + int size = balanceDataList.size() * 2; + for(int i = 0; i < size; i+= 2) { + Data data = balanceDataList.get(i); + + if(i + 1 < balanceDataList.size()) { + Data nextData = balanceDataList.get(i + 1); + Data interstitialData = new Data<>(nextData.getXValue(), data.getYValue(), null); + balanceDataList.add(i + 1, interstitialData); + } else { + Date now = new Date(); + Data interstitialData = new Data<>(now.getTime(), data.getYValue(), null); + balanceDataList.add(interstitialData); + } + } + if(!balanceDataList.isEmpty()) { long min = balanceDataList.stream().map(data -> data.getXValue().longValue()).min(Long::compare).get(); long max = balanceDataList.stream().map(data -> data.getXValue().longValue()).max(Long::compare).get(); @@ -65,7 +81,7 @@ public class BalanceChart extends LineChart { XYChart.Data data = balanceSeries.getData().get(i); Node symbol = lookup(".chart-line-symbol.data" + i); if(symbol != null) { - if(data.getXValue().equals(transactionEntry.getBlockTransaction().getDate().getTime())) { + if(data.getXValue().equals(transactionEntry.getBlockTransaction().getDate().getTime()) && data.getExtraValue() != null) { symbol.getStyleClass().add("selected"); selectedEntry = transactionEntry; } diff --git a/src/main/resources/com/sparrowwallet/sparrow/wallet/transactions.css b/src/main/resources/com/sparrowwallet/sparrow/wallet/transactions.css index 9bccb8c8..5177578e 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/wallet/transactions.css +++ b/src/main/resources/com/sparrowwallet/sparrow/wallet/transactions.css @@ -12,14 +12,14 @@ } .default-color0.chart-series-line { - -fx-stroke: rgba(105, 108, 119, 0.3); + -fx-stroke: rgba(105, 108, 119, 0.6); -fx-stroke-width: 1px; } .chart-line-symbol { - -fx-background-color: rgba(105, 108, 119, 0.3); + -fx-background-color: rgba(105, 108, 119, 0); } .chart-line-symbol.selected { - -fx-background-color: rgba(30, 136, 207, 0.8); + -fx-background-color: rgba(30, 136, 207, 0.6); } \ No newline at end of file