Skip to content

Commit

Permalink
Merge pull request #105 from Project-Resilience/filter-app
Browse files Browse the repository at this point in the history
Fixed issue scaling ELUC slider with change slider
  • Loading branch information
danyoungday authored Oct 8, 2024
2 parents 95f48ac + 4e22223 commit 60bc6e0
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions use_cases/eluc/app/components/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,20 @@ def create_outcome_sliders(self):
units = ["tC/ha", "%"]
sliders = []
for outcome in constants.CAO_MAPPING["outcomes"]:
tooltip = {
"placement": "bottom",
"always_visible": True
}
if outcome == "change":
tooltip["transform"] = "percentSlider"

slider = dcc.RangeSlider(
id={"type": "filter-slider", "index": outcome},
min=0,
max=1,
value=[0, 1],
marks={0: "0", 1: "100"},
tooltip={
"placement": "bottom",
"always_visible": True,
"transform": "percentSlider"
},
tooltip=tooltip,
allowCross=False,
disabled=False
)
Expand Down Expand Up @@ -183,8 +186,12 @@ def update_filter_sliders(results_json: dict[str: list]) -> list:
outputs[0].append(min_val_rounded)
outputs[1].append(max_val_rounded)
outputs[2].append([min_val_rounded, max_val_rounded])
outputs[3].append({min_val_rounded: f"{int(100*min_val_rounded)}",
max_val_rounded: f"{int(100*max_val_rounded)}"})
if outcome == "change":
outputs[3].append({min_val_rounded: f"{int(100*min_val_rounded)}",
max_val_rounded: f"{int(100*max_val_rounded)}"})
else:
outputs[3].append({min_val_rounded: f"{min_val_rounded:.2f}",
max_val_rounded: f"{max_val_rounded:.2f}"})
return outputs

@app.callback(
Expand Down

0 comments on commit 60bc6e0

Please sign in to comment.