mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-05 05:46:44 +00:00
default to mempool.space, improve mempool size tooltip display
This commit is contained in:
parent
e14349a645
commit
94960567b5
3 changed files with 14 additions and 26 deletions
|
@ -6,6 +6,7 @@ import com.sparrowwallet.sparrow.wallet.SendController;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.NamedArg;
|
import javafx.beans.NamedArg;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.geometry.Point2D;
|
||||||
import javafx.scene.Cursor;
|
import javafx.scene.Cursor;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.chart.*;
|
import javafx.scene.chart.*;
|
||||||
|
@ -63,16 +64,8 @@ public class MempoolSizeFeeRatesChart extends StackedAreaChart<String, Number> {
|
||||||
categoryAxis.setAutoRanging(false);
|
categoryAxis.setAutoRanging(false);
|
||||||
categoryAxis.setCategories(FXCollections.observableArrayList(categories.values()));
|
categoryAxis.setCategories(FXCollections.observableArrayList(categories.values()));
|
||||||
categoryAxis.invalidateRange(new ArrayList<>(categories.values()));
|
categoryAxis.invalidateRange(new ArrayList<>(categories.values()));
|
||||||
|
|
||||||
categoryAxis.setGapStartAndEnd(false);
|
categoryAxis.setGapStartAndEnd(false);
|
||||||
categoryAxis.setTickLabelRotation(0);
|
categoryAxis.setTickLabelRotation(0);
|
||||||
categoryAxis.setOnMouseMoved(mouseEvent -> {
|
|
||||||
String category = categoryAxis.getValueForDisplay(mouseEvent.getX());
|
|
||||||
if(category != null) {
|
|
||||||
Optional<String> time = categories.entrySet().stream().filter(entry -> entry.getValue().equals(category)).map(entry -> dateFormatter.format(entry.getKey())).findFirst();
|
|
||||||
time.ifPresent(s -> tooltip.setGraphic(new ChartTooltip(category, s, getData())));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
NumberAxis numberAxis = (NumberAxis)getYAxis();
|
NumberAxis numberAxis = (NumberAxis)getYAxis();
|
||||||
numberAxis.setTickLabelFormatter(new StringConverter<Number>() {
|
numberAxis.setTickLabelFormatter(new StringConverter<Number>() {
|
||||||
|
@ -88,6 +81,15 @@ public class MempoolSizeFeeRatesChart extends StackedAreaChart<String, Number> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.setOnMouseMoved(mouseEvent -> {
|
||||||
|
Point2D sceneCoords = this.localToScene(mouseEvent.getX(), mouseEvent.getY());
|
||||||
|
String category = categoryAxis.getValueForDisplay(categoryAxis.sceneToLocal(sceneCoords).getX());
|
||||||
|
if(category != null) {
|
||||||
|
Optional<String> time = categories.entrySet().stream().filter(entry -> entry.getValue().equals(category)).map(entry -> dateFormatter.format(entry.getKey())).findFirst();
|
||||||
|
time.ifPresent(s -> tooltip.setGraphic(new ChartTooltip(category, s, getData())));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
long previousFeeRate = 0;
|
long previousFeeRate = 0;
|
||||||
for(Long feeRate : SendController.FEE_RATES_RANGE) {
|
for(Long feeRate : SendController.FEE_RATES_RANGE) {
|
||||||
XYChart.Series<String, Number> series = new XYChart.Series<>();
|
XYChart.Series<String, Number> series = new XYChart.Series<>();
|
||||||
|
@ -161,7 +163,7 @@ public class MempoolSizeFeeRatesChart extends StackedAreaChart<String, Number> {
|
||||||
public ChartTooltip(String category, String time, List<Series<String, Number>> seriesList) {
|
public ChartTooltip(String category, String time, List<Series<String, Number>> seriesList) {
|
||||||
Label title = new Label("At " + time);
|
Label title = new Label("At " + time);
|
||||||
HBox titleBox = new HBox(title);
|
HBox titleBox = new HBox(title);
|
||||||
title.getStyleClass().add("tooltip-title");
|
title.setStyle("-fx-alignment: center; -fx-font-size: 12px; -fx-padding: 0 0 5 0;");
|
||||||
getChildren().add(titleBox);
|
getChildren().add(titleBox);
|
||||||
|
|
||||||
for(int i = seriesList.size() - 1; i >= 0; i--) {
|
for(int i = seriesList.size() - 1; i >= 0; i--) {
|
||||||
|
@ -172,7 +174,7 @@ public class MempoolSizeFeeRatesChart extends StackedAreaChart<String, Number> {
|
||||||
if(mvb >= 0.01) {
|
if(mvb >= 0.01) {
|
||||||
Label label = new Label(series.getName() + ": " + String.format("%.2f", mvb) + " MvB");
|
Label label = new Label(series.getName() + ": " + String.format("%.2f", mvb) + " MvB");
|
||||||
Glyph circle = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.CIRCLE);
|
Glyph circle = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.CIRCLE);
|
||||||
circle.getStyleClass().add("tooltip-series" + i);
|
circle.setStyle("-fx-text-fill: CHART_COLOR_" + (i+1));
|
||||||
label.setGraphic(circle);
|
label.setGraphic(circle);
|
||||||
getChildren().add(label);
|
getChildren().add(label);
|
||||||
}
|
}
|
||||||
|
|
|
@ -606,7 +606,8 @@ public class ElectrumServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
FeeRatesSource feeRatesSource = Config.get().getFeeRatesSource();
|
FeeRatesSource feeRatesSource = Config.get().getFeeRatesSource();
|
||||||
if(feeRatesSource != null && Network.get().equals(Network.MAINNET)) {
|
feeRatesSource = (feeRatesSource == null ? FeeRatesSource.MEMPOOL_SPACE : feeRatesSource);
|
||||||
|
if(Network.get().equals(Network.MAINNET)) {
|
||||||
targetBlocksFeeRatesSats.putAll(feeRatesSource.getBlockTargetFeeRates(targetBlocksFeeRatesSats));
|
targetBlocksFeeRatesSats.putAll(feeRatesSource.getBlockTargetFeeRates(targetBlocksFeeRatesSats));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,18 +108,3 @@
|
||||||
#transactionDiagram .utxo-label:hover .button .label .text {
|
#transactionDiagram .utxo-label:hover .button .label .text {
|
||||||
-fx-fill: -fx-text-base-color;
|
-fx-fill: -fx-text-base-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tooltip-title {
|
|
||||||
-fx-alignment: center;
|
|
||||||
-fx-font-size: 12px;
|
|
||||||
-fx-padding: 0 0 5 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tooltip-series0 { -fx-text-fill: CHART_COLOR_1; }
|
|
||||||
.tooltip-series1 { -fx-text-fill: CHART_COLOR_2; }
|
|
||||||
.tooltip-series2 { -fx-text-fill: CHART_COLOR_3; }
|
|
||||||
.tooltip-series3 { -fx-text-fill: CHART_COLOR_4; }
|
|
||||||
.tooltip-series4 { -fx-text-fill: CHART_COLOR_5; }
|
|
||||||
.tooltip-series5 { -fx-text-fill: CHART_COLOR_6; }
|
|
||||||
.tooltip-series6 { -fx-text-fill: CHART_COLOR_7; }
|
|
||||||
.tooltip-series7 { -fx-text-fill: CHART_COLOR_8; }
|
|
Loading…
Reference in a new issue