From 6b9d716e3c82b98cde1e8fc982147264764ccfe9 Mon Sep 17 00:00:00 2001 From: Daniel Young Date: Tue, 8 Oct 2024 12:40:06 -0700 Subject: [PATCH 1/2] Fixed issue scaling ELUC slider with change slider --- use_cases/eluc/app/components/filter.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/use_cases/eluc/app/components/filter.py b/use_cases/eluc/app/components/filter.py index 8a19654..68d8e88 100644 --- a/use_cases/eluc/app/components/filter.py +++ b/use_cases/eluc/app/components/filter.py @@ -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 ) @@ -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( From 4e22223f8836c30a268c13965b0574085e870966 Mon Sep 17 00:00:00 2001 From: Daniel Young Date: Tue, 8 Oct 2024 12:41:29 -0700 Subject: [PATCH 2/2] Removed unneeded print statements --- use_cases/eluc/app/components/filter.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/use_cases/eluc/app/components/filter.py b/use_cases/eluc/app/components/filter.py index 68d8e88..c3f6e8f 100644 --- a/use_cases/eluc/app/components/filter.py +++ b/use_cases/eluc/app/components/filter.py @@ -187,11 +187,9 @@ def update_filter_sliders(results_json: dict[str: list]) -> list: outputs[1].append(max_val_rounded) outputs[2].append([min_val_rounded, 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