Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checkbox to hide extreme offers in chart #2884

Merged
merged 4 commits into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ public void initialize() {
tupleSell.second.setUserData(OfferPayload.Direction.SELL.name());
bottomHBox.getChildren().addAll(tupleBuy.second, tupleSell.second);


root.getChildren().addAll(currencyComboBoxTuple.first, chartPane, bottomHBox);
}

Expand Down Expand Up @@ -215,6 +214,7 @@ protected void activate() {
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;
Expand Down Expand Up @@ -374,18 +374,21 @@ private void updateChartData() {
final Supplier<Optional<? extends XYChart.Data>> optionalMinSupplier = () ->
Optional.of(new XYChart.Data<>(Double.MIN_VALUE, Double.MIN_VALUE));

// Hide buy offers that are more than a factor 5 higher than the lowest buy offer
final Optional<XYChart.Data> buyMaxOptional = model.getBuyData().stream()
.filter(o -> (double) o.getXValue() < (double) buyMinOptional.get().getXValue() * 3)
.max(Comparator.comparingDouble(o -> (double) o.getXValue()))
.or(optionalMinSupplier);

final Optional<XYChart.Data> sellMinOptional = model.getSellData().stream()
.min(Comparator.comparingDouble(o -> (double) o.getXValue()))
.or(optionalMaxSupplier);

final Optional<XYChart.Data> sellMaxOptional = model.getSellData().stream()
.max(Comparator.comparingDouble(o -> (double) o.getXValue()))
.or(optionalMinSupplier);

final Optional<XYChart.Data> sellMinOptional = model.getSellData().stream()
.filter(o -> (double) o.getXValue() > (double) sellMaxOptional.get().getXValue() / 3)
.min(Comparator.comparingDouble(o -> (double) o.getXValue()))
.or(optionalMaxSupplier);

final double minValue = Double.min((double) buyMinOptional.get().getXValue(), (double) sellMinOptional.get().getXValue());
final double maxValue = Double.max((double) buyMaxOptional.get().getXValue(), (double) sellMaxOptional.get().getXValue());

Expand Down
5 changes: 5 additions & 0 deletions desktop/src/main/java/bisq/desktop/util/FormBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -745,9 +745,14 @@ public static CheckBox addCheckBox(GridPane gridPane, int rowIndex, String check
}

public static CheckBox addCheckBox(GridPane gridPane, int rowIndex, String checkBoxTitle, double top) {
return addCheckBox(gridPane, rowIndex, 0, checkBoxTitle, 0);
}

public static CheckBox addCheckBox(GridPane gridPane, int rowIndex, int colIndex, String checkBoxTitle, double top) {
CheckBox checkBox = new AutoTooltipCheckBox(checkBoxTitle);
GridPane.setMargin(checkBox, new Insets(top, 0, 0, 0));
GridPane.setRowIndex(checkBox, rowIndex);
GridPane.setColumnIndex(checkBox, colIndex);
gridPane.getChildren().add(checkBox);
return checkBox;
}
Expand Down