Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Range Slider updated by dropdown list?

$
0
0

@antjes88 wrote:

I am trying to make a range slider that would be moduified by a dropdown list. Basically, to give some context, range slider would be for time and the dropdown list is stablishing date from.

My code looks like this:

#################################
#######HERE THE LAYOUT###############
#################################

df_call = call_to_db_analysis(‘Incomes’, dt(2019, 1, 1))
df_to = df_call[‘Date’].drop_duplicates().to_frame().reset_index(drop=True)
df_to[‘Date_str’] = df_to[‘Date’].dt.strftime(’%b-%Y’)
options_ =
for i in df_to.index:
options_.append({‘label’: df_to.loc[i, ‘Date_str’], ‘value’: df_to.loc[i, ‘Date’]})

dd_from_analysis = dcc.Dropdown(id=‘dropdown-date-from-analysis’,
options=options_,
value=df_to.loc[11, ‘Date’],
style={‘text-align’: ‘left’})

app_cuentas_dash.layout = html.Div([
dcc.RangeSlider(id=“range-slider-analysis”),
dd_from_analysis
]
)

#################################
#######HERE THE CALLBACK#############
#################################

@app_cuentas_dash.callback([Output(‘range-slider-analysis’, ‘min’),
Output(‘range-slider-analysis’, ‘max’),
Output(‘range-slider-analysis’, ‘marks’),
Output(‘range-slider-analysis’, ‘value’)],
[Input(‘dropdown-date-from-analysis’, ‘value’)])
def update_figure(value_from_date):
df_rs = analysis.call_to_db_analysis(‘Incomes’,
value_from_date)[‘Date’].drop_duplicates().to_frame().reset_index(drop=True)
min_rs, max_rs, marks_rs, value_rs = analysis.rs_analysis(df_rs)
return min_rs, max_rs, marks_rs, value_rs

###################################################
#############DEFINITON OF RANGE SLIDER PARAMETERS##########
##################################################

def rs_analysis(df_rs):
min_rs = 0
max_rs = df_rs[‘Date’].shape[0] - 1
marks_rs = marks_dict_analysis(df_rs, type_=2),
value_rs = [0, df_rs[‘Date’].shape[0] - 1]
return min_rs, max_rs, marks_rs, value_rs

###############################################

I am having problems to pass any parameters to the range slider.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles