Python - What's the correct Syntax to add a condition in my loop?

I fixed this declaring a function at the top of my code:

marks=dict()
def GenerateMarksForRangeSlider():
    for i in range(0, len(available_dates_barchart)):
        if i %2==0:
            marks[i]={
                'label' : available_dates_rangeslider[i], 
                'style': {'transform':'rotate(-90deg)', 'font-size':'9.25px', 'margin-top':'25px'}
            }
        else:
            marks[i]={
                'label' : available_dates_rangeslider[i], 
                'style': {'transform':'rotate(-90deg)', 'font-size':'9.25px', 'margin-top':'-35px'}
            }
    return marks

and then in my dcc.RangeSlider code:
[…]
marks=GenerateMarksForRangeSlider(),
[…]

Dont know if there are better way. But it works and I can display 65 marks on 300px wide screens, which was the goal.

Circular RangeSliders could be interesting for such use, I guess :slight_smile:

1 Like