Skip to content

Commit

Permalink
Merge pull request #2884 from sqrrm/hide-extremes
Browse files Browse the repository at this point in the history
Add checkbox to hide extreme offers in chart
  • Loading branch information
ripcurlx authored Jul 12, 2019
2 parents d9e088f + 664c7c6 commit 3b915a3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
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

0 comments on commit 3b915a3

Please sign in to comment.