Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support text wrap for titles and subtitles #4819

Open
ndrezn opened this issue Oct 22, 2024 · 3 comments
Open

Support text wrap for titles and subtitles #4819

ndrezn opened this issue Oct 22, 2024 · 3 comments

Comments

@ndrezn
Copy link
Member

ndrezn commented Oct 22, 2024

Titles and subtitles in Plotly charts overflow by default. It's impossible to have them wrap.

With subtitle support, having long strings in this area is more common (and more useful), so we should automatically wrap text if it gets too long in the title or subtitle area.

fig = px.line(x=[1,2,3], y=[4,5,6], title="This is a really really really really really really really really really really really really really really reallyy long title")
fig.update_layout(title_subtitle_text="This is a really really really really really really really really really really really really really really  really really really really really really really long subtitle")
fig

Image

@eliasdabbas
Copy link

FWIW, I usually use <br> to introduce line breaks, but would love to see how this evolves, and if it changes. Maybe support more HTML tags than what is currently supported.

fig = px.line(x=[1,2,3], y=[4,5,6], title="This is a really really really really really really <br>really really really really really really <br>really really reallyy long title", height=600)
fig.update_layout(title_subtitle_text="This is a really really really really really really really<br> really really really really really really<br> really  really really really really really really really long subtitle")
fig.layout.margin.t = 220
fig

Image

@ndrezn
Copy link
Member Author

ndrezn commented Oct 24, 2024

Yeah, <br> is a solid workaround, but in the context of responsive design we want automatic text wrapping.

Would be nice too to support more HTML tags! Although it's another can of worms to fully (and safely) support inner HTML 😉

@eliasdabbas
Copy link

Oh, I didn't think of the effects on responsiveness. Great point.
I realize it can be tough to safely add more HTML tags :)
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants