mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Add total volume text fields
This commit is contained in:
parent
e91ed8a857
commit
683e768a00
6 changed files with 88 additions and 5 deletions
|
@ -2434,6 +2434,8 @@ dao.factsAndFigures.dashboard.avgUSDPrice90=90 days volume weighted average BSQ/
|
||||||
dao.factsAndFigures.dashboard.avgUSDPrice30=30 days volume weighted average BSQ/USD price
|
dao.factsAndFigures.dashboard.avgUSDPrice30=30 days volume weighted average BSQ/USD price
|
||||||
dao.factsAndFigures.dashboard.marketCap=Market capitalisation (based on 30 days average BSQ/USD price)
|
dao.factsAndFigures.dashboard.marketCap=Market capitalisation (based on 30 days average BSQ/USD price)
|
||||||
dao.factsAndFigures.dashboard.availableAmount=Total available BSQ
|
dao.factsAndFigures.dashboard.availableAmount=Total available BSQ
|
||||||
|
dao.factsAndFigures.dashboard.volumeUsd=Total trade volume in USD
|
||||||
|
dao.factsAndFigures.dashboard.volumeBtc=Total trade volume in BTC
|
||||||
|
|
||||||
dao.factsAndFigures.supply.issuedVsBurnt=BSQ issued v. BSQ burnt
|
dao.factsAndFigures.supply.issuedVsBurnt=BSQ issued v. BSQ burnt
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import bisq.core.dao.DaoFacade;
|
||||||
import bisq.core.dao.state.DaoStateListener;
|
import bisq.core.dao.state.DaoStateListener;
|
||||||
import bisq.core.dao.state.model.blockchain.Block;
|
import bisq.core.dao.state.model.blockchain.Block;
|
||||||
import bisq.core.dao.state.model.governance.IssuanceType;
|
import bisq.core.dao.state.model.governance.IssuanceType;
|
||||||
|
import bisq.core.locale.GlobalSettings;
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
import bisq.core.monetary.Price;
|
import bisq.core.monetary.Price;
|
||||||
import bisq.core.provider.price.PriceFeedService;
|
import bisq.core.provider.price.PriceFeedService;
|
||||||
|
@ -38,6 +39,7 @@ import bisq.core.util.AveragePriceUtil;
|
||||||
import bisq.core.util.FormattingUtils;
|
import bisq.core.util.FormattingUtils;
|
||||||
import bisq.core.util.coin.BsqFormatter;
|
import bisq.core.util.coin.BsqFormatter;
|
||||||
|
|
||||||
|
import bisq.common.util.MathUtils;
|
||||||
import bisq.common.util.Tuple2;
|
import bisq.common.util.Tuple2;
|
||||||
import bisq.common.util.Tuple3;
|
import bisq.common.util.Tuple3;
|
||||||
|
|
||||||
|
@ -55,10 +57,13 @@ import javafx.scene.layout.VBox;
|
||||||
|
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
|
|
||||||
|
import javafx.beans.binding.Bindings;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
|
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static bisq.desktop.util.FormBuilder.addLabelWithSubText;
|
import static bisq.desktop.util.FormBuilder.addLabelWithSubText;
|
||||||
|
@ -78,7 +83,7 @@ public class BsqDashboardView extends ActivatableView<GridPane, Void> implements
|
||||||
private final Preferences preferences;
|
private final Preferences preferences;
|
||||||
private final BsqFormatter bsqFormatter;
|
private final BsqFormatter bsqFormatter;
|
||||||
|
|
||||||
private TextField avgPrice90TextField, avgUSDPrice90TextField, marketCapTextField, availableAmountTextField;
|
private TextField avgPrice90TextField, avgUSDPrice90TextField, marketCapTextField, availableAmountTextField, usdVolumeTextField, btcVolumeTextField;
|
||||||
private TextFieldWithIcon avgPrice30TextField, avgUSDPrice30TextField;
|
private TextFieldWithIcon avgPrice30TextField, avgUSDPrice30TextField;
|
||||||
private Label marketPriceLabel;
|
private Label marketPriceLabel;
|
||||||
|
|
||||||
|
@ -133,6 +138,24 @@ public class BsqDashboardView extends ActivatableView<GridPane, Void> implements
|
||||||
updateAveragePriceFields(avgPrice90TextField, avgPrice30TextField, false);
|
updateAveragePriceFields(avgPrice90TextField, avgPrice30TextField, false);
|
||||||
updateAveragePriceFields(avgUSDPrice90TextField, avgUSDPrice30TextField, true);
|
updateAveragePriceFields(avgUSDPrice90TextField, avgUSDPrice30TextField, true);
|
||||||
updateMarketCap();
|
updateMarketCap();
|
||||||
|
|
||||||
|
usdVolumeTextField.textProperty().bind(Bindings.createStringBinding(
|
||||||
|
() -> {
|
||||||
|
DecimalFormat volumeFormat = (DecimalFormat) DecimalFormat.getNumberInstance(GlobalSettings.getLocale());
|
||||||
|
volumeFormat.setMaximumFractionDigits(0);
|
||||||
|
double scaled = MathUtils.scaleDownByPowerOf10(volumeChartView.usdVolumeProperty().get(), 4);
|
||||||
|
return volumeFormat.format(scaled) + " USD";
|
||||||
|
},
|
||||||
|
volumeChartView.usdVolumeProperty()));
|
||||||
|
|
||||||
|
btcVolumeTextField.textProperty().bind(Bindings.createStringBinding(
|
||||||
|
() -> {
|
||||||
|
DecimalFormat volumeFormat = (DecimalFormat) DecimalFormat.getNumberInstance(GlobalSettings.getLocale());
|
||||||
|
volumeFormat.setMaximumFractionDigits(4);
|
||||||
|
double scaled = MathUtils.scaleDownByPowerOf10(volumeChartView.btcVolumeProperty().get(), 8);
|
||||||
|
return volumeFormat.format(scaled) + " BTC";
|
||||||
|
},
|
||||||
|
volumeChartView.btcVolumeProperty()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,6 +163,9 @@ public class BsqDashboardView extends ActivatableView<GridPane, Void> implements
|
||||||
protected void deactivate() {
|
protected void deactivate() {
|
||||||
daoFacade.removeBsqStateListener(this);
|
daoFacade.removeBsqStateListener(this);
|
||||||
priceFeedService.updateCounterProperty().removeListener(priceChangeListener);
|
priceFeedService.updateCounterProperty().removeListener(priceChangeListener);
|
||||||
|
|
||||||
|
usdVolumeTextField.textProperty().unbind();
|
||||||
|
btcVolumeTextField.textProperty().unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -227,6 +253,11 @@ public class BsqDashboardView extends ActivatableView<GridPane, Void> implements
|
||||||
chartPane.getChildren().add(chartContainer);
|
chartPane.getChildren().add(chartContainer);
|
||||||
|
|
||||||
root.getChildren().add(chartPane);
|
root.getChildren().add(chartPane);
|
||||||
|
|
||||||
|
usdVolumeTextField = addTopLabelReadOnlyTextField(root, ++gridRow,
|
||||||
|
Res.get("dao.factsAndFigures.dashboard.volumeUsd")).second;
|
||||||
|
btcVolumeTextField = addTopLabelReadOnlyTextField(root, gridRow, 1,
|
||||||
|
Res.get("dao.factsAndFigures.dashboard.volumeBtc")).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateWithBsqBlockChainData() {
|
private void updateWithBsqBlockChainData() {
|
||||||
|
|
|
@ -54,6 +54,23 @@ public class VolumeChartDataModel extends ChartDataModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Total amounts
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
long getUsdVolume() {
|
||||||
|
return getUsdVolumeByInterval().values().stream()
|
||||||
|
.mapToLong(e -> e)
|
||||||
|
.sum();
|
||||||
|
}
|
||||||
|
|
||||||
|
long getBtcVolume() {
|
||||||
|
return getBtcVolumeByInterval().values().stream()
|
||||||
|
.mapToLong(e -> e)
|
||||||
|
.sum();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Data
|
// Data
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -25,6 +25,10 @@ import javax.inject.Inject;
|
||||||
|
|
||||||
import javafx.scene.chart.XYChart;
|
import javafx.scene.chart.XYChart;
|
||||||
|
|
||||||
|
import javafx.beans.property.LongProperty;
|
||||||
|
import javafx.beans.property.ReadOnlyLongProperty;
|
||||||
|
import javafx.beans.property.SimpleLongProperty;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -34,6 +38,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
public class VolumeChartView extends ChartView<VolumeChartViewModel> {
|
public class VolumeChartView extends ChartView<VolumeChartViewModel> {
|
||||||
private XYChart.Series<Number, Number> seriesUsdVolume, seriesBtcVolume;
|
private XYChart.Series<Number, Number> seriesUsdVolume, seriesBtcVolume;
|
||||||
|
|
||||||
|
private LongProperty usdVolumeProperty = new SimpleLongProperty();
|
||||||
|
private LongProperty btcVolumeProperty = new SimpleLongProperty();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public VolumeChartView(VolumeChartViewModel model) {
|
public VolumeChartView(VolumeChartViewModel model) {
|
||||||
super(model);
|
super(model);
|
||||||
|
@ -121,5 +128,22 @@ public class VolumeChartView extends ChartView<VolumeChartViewModel> {
|
||||||
if (activeSeries.contains(seriesBtcVolume)) {
|
if (activeSeries.contains(seriesBtcVolume)) {
|
||||||
seriesBtcVolume.getData().setAll(model.getBtcVolumeChartData());
|
seriesBtcVolume.getData().setAll(model.getBtcVolumeChartData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
usdVolumeProperty.set(model.getUsdVolume());
|
||||||
|
btcVolumeProperty.set(model.getBtcVolume());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReadOnlyLongProperty usdVolumeProperty() {
|
||||||
|
if (usdVolumeProperty.get() == 0) {
|
||||||
|
usdVolumeProperty.set(model.getUsdVolume());
|
||||||
|
}
|
||||||
|
return usdVolumeProperty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReadOnlyLongProperty btcVolumeProperty() {
|
||||||
|
if (btcVolumeProperty.get() == 0) {
|
||||||
|
btcVolumeProperty.set(model.getBtcVolume());
|
||||||
|
}
|
||||||
|
return btcVolumeProperty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,19 @@ public class VolumeChartViewModel extends ChartViewModel<VolumeChartDataModel> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Total amounts
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
long getUsdVolume() {
|
||||||
|
return dataModel.getUsdVolume();
|
||||||
|
}
|
||||||
|
|
||||||
|
long getBtcVolume() {
|
||||||
|
return dataModel.getBtcVolume();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Chart data
|
// Chart data
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -55,10 +55,6 @@ public class DaoChartView extends ChartView<DaoChartViewModel> {
|
||||||
// API Total amounts
|
// API Total amounts
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public long getCompensationAmountProperty() {
|
|
||||||
return model.getCompensationAmount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReadOnlyLongProperty compensationAmountProperty() {
|
public ReadOnlyLongProperty compensationAmountProperty() {
|
||||||
if (compensationAmountProperty.get() == 0) {
|
if (compensationAmountProperty.get() == 0) {
|
||||||
compensationAmountProperty.set(model.getCompensationAmount());
|
compensationAmountProperty.set(model.getCompensationAmount());
|
||||||
|
|
Loading…
Add table
Reference in a new issue