File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -234,11 +234,18 @@ def enable_button(_):
234234 def select_ssp_dropdown (value ):
235235 """
236236 When we select a dropdown value, update the sliders.
237+ If we clear the dropdown, reset the sliders to the default values.
237238 """
238- scenario = f"{ value } -Baseline"
239- row = self .context_df [self .context_df ["scenario" ] == scenario ].iloc [0 ]
240239 input_specs = load_input_specs ()
241- return [row [id_to_varid (self .context [i ], input_specs )] for i in range (4 )]
240+
241+ # If the value is a scenario, find the corresponding row in context_df.
242+ scenario = f"{ value } -Baseline"
243+ if scenario in self .context_df ["scenario" ].unique ():
244+ row = self .context_df [self .context_df ["scenario" ] == scenario ].iloc [0 ]
245+ return [row [id_to_varid (self .context [i ], input_specs )] for i in range (4 )]
246+
247+ # Default case: if the scenario is not found just get the default values
248+ return [input_specs [input_specs ["id" ] == self .context [i ]]["defaultValue" ].iloc [0 ] for i in range (4 )]
242249
243250 @app .callback (
244251 Output ("ssp-dropdown" , "value" , allow_duplicate = True ),
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ def _create_timeline_events(self,
4444 Returns a dict with the year as the key and the event as the value.
4545 """
4646 # Parse details into ids instead of varids
47+ details = dict (details .items ())
4748 if "start" in details :
4849 details ["start" ] = varid_to_id (details ["start" ], self .input_specs )
4950 if "stop" in details :
You can’t perform that action at this time.
0 commit comments