mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
balancechart add interstitials
This commit is contained in:
parent
bd721be1a2
commit
d2291ef870
2 changed files with 20 additions and 4 deletions
|
@ -9,6 +9,7 @@ import javafx.beans.NamedArg;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.chart.*;
|
import javafx.scene.chart.*;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -39,6 +40,21 @@ public class BalanceChart extends LineChart<Number, Number> {
|
||||||
.map(txEntry -> new XYChart.Data<>((Number)txEntry.getBlockTransaction().getDate().getTime(), (Number)txEntry.getBalance(), txEntry))
|
.map(txEntry -> new XYChart.Data<>((Number)txEntry.getBlockTransaction().getDate().getTime(), (Number)txEntry.getBalance(), txEntry))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
int size = balanceDataList.size() * 2;
|
||||||
|
for(int i = 0; i < size; i+= 2) {
|
||||||
|
Data<Number, Number> data = balanceDataList.get(i);
|
||||||
|
|
||||||
|
if(i + 1 < balanceDataList.size()) {
|
||||||
|
Data<Number, Number> nextData = balanceDataList.get(i + 1);
|
||||||
|
Data<Number, Number> interstitialData = new Data<>(nextData.getXValue(), data.getYValue(), null);
|
||||||
|
balanceDataList.add(i + 1, interstitialData);
|
||||||
|
} else {
|
||||||
|
Date now = new Date();
|
||||||
|
Data<Number, Number> interstitialData = new Data<>(now.getTime(), data.getYValue(), null);
|
||||||
|
balanceDataList.add(interstitialData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!balanceDataList.isEmpty()) {
|
if(!balanceDataList.isEmpty()) {
|
||||||
long min = balanceDataList.stream().map(data -> data.getXValue().longValue()).min(Long::compare).get();
|
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();
|
long max = balanceDataList.stream().map(data -> data.getXValue().longValue()).max(Long::compare).get();
|
||||||
|
@ -65,7 +81,7 @@ public class BalanceChart extends LineChart<Number, Number> {
|
||||||
XYChart.Data<Number, Number> data = balanceSeries.getData().get(i);
|
XYChart.Data<Number, Number> data = balanceSeries.getData().get(i);
|
||||||
Node symbol = lookup(".chart-line-symbol.data" + i);
|
Node symbol = lookup(".chart-line-symbol.data" + i);
|
||||||
if(symbol != null) {
|
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");
|
symbol.getStyleClass().add("selected");
|
||||||
selectedEntry = transactionEntry;
|
selectedEntry = transactionEntry;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,14 +12,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.default-color0.chart-series-line {
|
.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;
|
-fx-stroke-width: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chart-line-symbol {
|
.chart-line-symbol {
|
||||||
-fx-background-color: rgba(105, 108, 119, 0.3);
|
-fx-background-color: rgba(105, 108, 119, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
.chart-line-symbol.selected {
|
.chart-line-symbol.selected {
|
||||||
-fx-background-color: rgba(30, 136, 207, 0.8);
|
-fx-background-color: rgba(30, 136, 207, 0.6);
|
||||||
}
|
}
|
Loading…
Reference in a new issue