I am using a slider but sometimes there are too many marks and the name of marks just smush in to each other. I would like to make the mark labels hang vertically, would that be possible.
thank you.
I am using a slider but sometimes there are too many marks and the name of marks just smush in to each other. I would like to make the mark labels hang vertically, would that be possible.
thank you.
sorry I just found the solution by using this
style={âcolorâ: âblueâ, âfontSizeâ: 14,âwriting-modeâ: âvertical-rlâ,âtext-orientationâ: âuprightâ}
Nice, thanks for sharing writing-mode
, Iâve never seen that before. Here are some more examples: https://developer.mozilla.org/en-US/docs/Web/CSS/text-orientation, it looks like: writingMode: 'vertical-rl', 'textOrientation: 'mixed'
would be a good combination too.
For features like these, make sure to check out the browser compatibility: https://developer.mozilla.org/en-US/docs/Web/CSS/text-orientation#Browser_compatibility
Using âwriting-modeâ and âtext-orientationâ donât seem to have the desired effect for me. This is i=how iâm using them:
html.Div([
dcc.RangeSlider(
id='my-range-slider',
min=0,
max=noDays-1,
step=1,
value=[0, noDays-1], # default values
marks = dateDict,
updatemode='drag',
) # slider dcc
],
style ={
'margin-bottom': '50px',
'margin-left': '20px',
'margin-right': '20px',
'writing-mode': 'vertical-lr',
'text-orientation': 'sideways'
}
) # slider div
Any advise?
I think you should set the style of the markers within the dcc.RangeSlider
componentâs prop marks
like for this example :
marks={
str(h): {'label': str(h), 'style': {'color': 'red'}}
for h in range(0, 24)
},
The style
prop you provided in your post will apply to the html.Div
component
Ah, I see! I wasnât sure how to add style within the dcc, I understand the formatting now.
Thanks for your help!
Hi,
I was able to replicate the vertical markers, however i am having issues with the alignment of the marks to the dots.
When the browser width is resized (shrinked) or when the webpage is zoomed beyond 100%, the marks get aligned but when browser is in full screen or zoomed below 100%, the marks are not aligned.
Full Screen or zoomed <=100% (rightmost mark scales outside viewable area)
Resized browser or zoomed >100% (marks scales perfectly under the dots)
My Code;
app = dash.Dash(name)
app.css.config.serve_locally = True
app.scripts.config.serve_locally = Trueapp.layout = html.Div([
html.H2(âRange Selectorâ),
html.Div([
dcc.RangeSlider(
id=âmy-range-sliderâ,
min=0,
max=len(df_volpanalysis.columns)-1,
step=1,
value=[0,1],
allowCross=False,
marks= {(i):{âlabelâ:str(df_volpanalysis.columns[i]),
âstyleâ:{âcolorâ:âredâ,âwriting-modeâ: âvertical-rlâ,âtext-orientationâ: âuse-glyph-orientationâ}
}for i in range(len(df_volpanalysis.columns))}
)],className=âsix columnsâ),html.Div(id=âoutput-container-range-sliderâ)
])
app.css.append_css({
âexternal_urlâ:âhttps://codepen.io/chriddyp/pen/bWLwgP.cssâ
})@app.callback(
dash.dependencies.Output(âoutput-container-range-sliderâ, âchildrenâ),
[dash.dependencies.Input(âmy-range-sliderâ, âvalueâ)])
def update_output(value):
return âYou have selected â{}ââ.format(value)if name == âmainâ:
app.run_server(debug=False)
Appreciate if anyone could help me.