Use same precision for all x-axis labels

This commit is contained in:
sqrrm 2019-04-21 23:53:17 +02:00
parent f36823f145
commit 7f00fe227f
No known key found for this signature in database
GPG Key ID: 45235F9EF87089EC

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 precision3 = 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
final String withPrecision3 = formatter.formatRoundedDoubleWithPrecision(doubleValue, precision3);
if (withPrecision3.equals("0.000")) {
precision3 = 8;
return formatter.formatRoundedDoubleWithPrecision(doubleValue, precision3);
} else {
return withPrecision3;
}
} else {
return formatter.formatRoundedDoubleWithPrecision(doubleValue, 2);
}