Hello,
I’m trying to apply one style to the odd elements of a RangeSlider, and another style to the even elements of this RangeSlider.
For the even elements, I do it this way:
marks={
i : {
'label' : available_dates_rangeslider[i],
'style':{'transform':'rotate(-90deg)', 'font-size':'10px', 'margin-top':'10px'}
} for i in range(0, len(available_dates_barchart)) if i %2==0
},
But how to write the loop so that it adds a style for the “else” ? Still a newbie with python.
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 
1 Like