2

I am building a dashboard using Dash which has a RangeSlider in it. At the minute, the min and max arguments are set to 2015 and 2021 and the step is 0.1 as shown in the MWE, which produces me a nice slider as shown in the screenshot below:

    html.Div([
    dcc.RangeSlider(id='slider',
                    min=2015,
                    max=2021,
                    step=0.1,
                    value=[2017, 2019],
                    tooltip={'always_visible': True, 'placement': 'bottom'}
                    )
], id='myslider'),

enter image description here

Is there an easy way to represent the step as 1 day? I would want to see the date being adjusted day by day as I move the slider in a YYYY-MM-DD format (or any other format is fine too). Ideally, I would need a universal solution that would work with varying min and max arguments (they will vary depending on user input).

I'm thinking to write a function that would create a dictionary of all the dates between min and max dates and pass it to the marks= argument in RangeSlider object, but before doing that just wanted to check if there is a better solution?

  • 1
    The `marks={...}` is the way to go, you may find what you need in this [post](https://stackoverflow.com/questions/51063191/date-slider-with-plotly-dash-does-not-work). – EricLavault Jun 03 '21 at 09:01

0 Answers0