Update marks component of dcc.slider

How to update min and max values of marks of a dcc.slider?

What I try to achieve:

dcc.Slider(
id=‘slider’,
min=2010,
max=2020,
marks={ some dict }
)

@app.callback(
[Output(‘slider’, ‘marks’),
Output(‘slider’, ‘value’)],
[Input(‘var’, ‘value’)])
def update_marks(var):

# filter df by var

# 1: find min_year, max_year
min_year = min(df["year"])
max_year = max(df["year"]) + 1 
value = min(df["year"])

# 2: marks for GEO_slider (dict)
marks = {year : {'label':year} for year in range(min_year, max_year) } 

return marks , value

Hi @upu710 and welcome to the Dash community

You can update the min and max the same way that you update the ‘marks’ and ‘value’ in your example.

So in your callback, you would also include:

Output('slider', 'min'), Output('slider', 'max')

and then the return would be:

return marks, value, min_year, max_year

In fact, almost all properties of components can be updated in a callback. I say almost because there are a few exceptions, but those are noted in the reference docs.