use of bisq.desktop.main.market.trades.charts.volume.VolumeChart in project bisq-desktop by bisq-network.
the class TradesChartsView method createCharts.
// /////////////////////////////////////////////////////////////////////////////////////////
// Chart
// /////////////////////////////////////////////////////////////////////////////////////////
private void createCharts() {
priceSeries = new XYChart.Series<>();
priceAxisX = new NumberAxis(0, model.maxTicks + 1, 1);
priceAxisX.setTickUnit(1);
priceAxisX.setMinorTickCount(0);
priceAxisX.setForceZeroInRange(false);
priceAxisX.setTickLabelFormatter(getTimeAxisStringConverter());
priceAxisY = new NumberAxis();
priceAxisY.setForceZeroInRange(false);
priceAxisY.setAutoRanging(true);
priceAxisY.setTickLabelFormatter(new StringConverter<Number>() {
@Override
public String toString(Number object) {
String currencyCode = model.getCurrencyCode();
double doubleValue = (double) object;
if (CurrencyUtil.isCryptoCurrency(currencyCode)) {
final double value = MathUtils.scaleDownByPowerOf10(doubleValue, 8);
return formatter.formatRoundedDoubleWithPrecision(value, 8);
} else {
return formatter.formatPrice(Price.valueOf(currencyCode, MathUtils.doubleToLong(doubleValue)));
}
}
@Override
public Number fromString(String string) {
return null;
}
});
priceChart = new CandleStickChart(priceAxisX, priceAxisY, new StringConverter<Number>() {
@Override
public String toString(Number object) {
if (CurrencyUtil.isCryptoCurrency(model.getCurrencyCode())) {
final double value = MathUtils.scaleDownByPowerOf10((long) object, 8);
return formatter.formatRoundedDoubleWithPrecision(value, 8);
} else {
return formatter.formatPrice(Price.valueOf(model.getCurrencyCode(), (long) object));
}
}
@Override
public Number fromString(String string) {
return null;
}
});
priceChart.setId("price-chart");
priceChart.setMinHeight(198);
priceChart.setPrefHeight(198);
priceChart.setMaxHeight(300);
priceChart.setLegendVisible(false);
// noinspection unchecked
priceChart.setData(FXCollections.observableArrayList(priceSeries));
volumeSeries = new XYChart.Series<>();
volumeAxisX = new NumberAxis(0, model.maxTicks + 1, 1);
volumeAxisX.setTickUnit(1);
volumeAxisX.setMinorTickCount(0);
volumeAxisX.setForceZeroInRange(false);
volumeAxisX.setTickLabelFormatter(getTimeAxisStringConverter());
volumeAxisY = new NumberAxis();
volumeAxisY.setForceZeroInRange(true);
volumeAxisY.setAutoRanging(true);
volumeAxisY.setLabel(Res.get("shared.volumeWithCur", Res.getBaseCurrencyCode()));
volumeAxisY.setTickLabelFormatter(new StringConverter<Number>() {
@Override
public String toString(Number object) {
return formatter.formatCoin(Coin.valueOf(MathUtils.doubleToLong((double) object)));
}
@Override
public Number fromString(String string) {
return null;
}
});
volumeChart = new VolumeChart(volumeAxisX, volumeAxisY, new StringConverter<Number>() {
@Override
public String toString(Number object) {
return formatter.formatCoinWithCode(Coin.valueOf((long) object));
}
@Override
public Number fromString(String string) {
return null;
}
});
// noinspection unchecked
volumeChart.setId("volume-chart");
volumeChart.setData(FXCollections.observableArrayList(volumeSeries));
volumeChart.setMinHeight(148);
volumeChart.setPrefHeight(148);
volumeChart.setMaxHeight(200);
volumeChart.setLegendVisible(false);
}
Aggregations