Hello Dash Community,
I am working on plotly dash app and I am trying to create a month range slider to appear on my frontend.
Following the post on the forum here I have worked out on how to create a range slider. Below is the code
maxmarks = 12
tday = pd.Timestamp.today() # gets timestamp of today
m1date = tday.month # first month on slider
datelist = pd.date_range(tday, periods=maxmarks, freq='M') # list of months as dates
dlist = pd.DatetimeIndex(datelist).normalize()
tags = {} # dictionary relating marks on slider to tags. tags are shown as "Apr', "May', etc
datevalues = {} # dictionary relating mark to date value
x = m1date
for i in dlist:
tags[x] = (i + DateOffset(months=0)).strftime('%b') # gets the string representation of next month ex:'Apr'
datevalues[x] = i
x = x + 1
if x >= 13:
x = x - 12
html.Div([
dcc.RangeSlider(
id='month_slider',
# updatemode='drag',
# count=1,
min=1,
max=maxmarks,
step=1,
value=[maxmarks - 1, maxmarks],
marks=tags,
pushable=1
),
However, I am looking for a way to allow a maximum of two tags selection on the range slider. Can someone please help me how to make this possible.
Thanks a lot in advance !!