Skip to content

Commit

Permalink
Fixed issue scaling ELUC slider with change slider
Browse files Browse the repository at this point in the history
  • Loading branch information
danyoungday committed Oct 8, 2024
1 parent d6afa2d commit 6b9d716
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 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,14 @@ 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":
print("Change")
outputs[3].append({min_val_rounded: f"{int(100*min_val_rounded)}",
max_val_rounded: f"{int(100*max_val_rounded)}"})
else:
print(outcome)
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 6b9d716

Please sign in to comment.