Is there a way to Add TICKS/Labels in RangeSlider for Plotly (javascript)?

Viewed 304

I have a line chart that uses Range slider and I want to just add some ticks/labels below the range slider. I've search PLOTLY docs but couldn't seem to find a parameter to imply ticks to the chart. Any insights?

enter image description here

1 Answers

Javascript

With the regular slider, we can set a label to each of the defined steps, but it seems there is no possibility to do the same with the rangeslider.


Python

You can use the marks property to set labels (and optionally add styles or even restrict which values can be selected), eg. :

dcc.RangeSlider(
    min=min,
    max=max,
    step=1,
    marks={ m: str(m) for m in range(min, max+1) },
    value=[min, max]
)

Note :

If slider marks are defined and step is set to None then the slider will only be able to select values that have been predefined by the marks. Note that the default is step=1, so you must explicitly specify None to get this behavior.

@see Marks and Steps

Related