Merge pull request #2763 from sqrrm/market-view-precision

Use same precision for all x-axis labels
This commit is contained in:
Christoph Atteneder 2019-04-24 11:20:11 +02:00 committed by GitHub
commit 3a1f69472c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -214,15 +214,18 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
String code = tradeCurrency.getCode();
volumeColumnLabel.set(Res.get("shared.amountWithCur", code));
xAxis.setTickLabelFormatter(new StringConverter<>() {
int cryptoPrecision = 3;
@Override
public String toString(Number object) {
final double doubleValue = (double) object;
if (CurrencyUtil.isCryptoCurrency(model.getCurrencyCode())) {
final String withPrecision3 = formatter.formatRoundedDoubleWithPrecision(doubleValue, 3);
if (withPrecision3.equals("0.000"))
return formatter.formatRoundedDoubleWithPrecision(doubleValue, 8);
else
return withPrecision3;
final String withCryptoPrecision = formatter.formatRoundedDoubleWithPrecision(doubleValue, cryptoPrecision);
if (withCryptoPrecision.equals("0.000")) {
cryptoPrecision = 8;
return formatter.formatRoundedDoubleWithPrecision(doubleValue, cryptoPrecision);
} else {
return withCryptoPrecision;
}
} else {
return formatter.formatRoundedDoubleWithPrecision(doubleValue, 2);
}