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

document how to extend length of labels #1759

Open
weichm opened this issue Oct 15, 2017 · 9 comments
Open

document how to extend length of labels #1759

weichm opened this issue Oct 15, 2017 · 9 comments

Comments

@weichm
Copy link
Contributor

weichm commented Oct 15, 2017

Original title: selectionrangeslider: too short, cuts off labels

import pandas as pd
import datetime
import ipywidgets as widgets

start = datetime.datetime(2017,1,1)
end = datetime.datetime(2017,12,31)

dates = list(pd.date_range(start, end, freq='D'))
options = [(i.strftime('%d.%m.%Y'), i) for i in dates]
index = (0, len(dates)-1)
widgets.SelectionRangeSlider(
    options = options,
    index = index,
    description = 'Test',
    orientation = 'horizontal'
)

The widget is displayed as
image

The last part of the end date is incorrectly cut off.

Same problem if slider is oriented vertical.

ipywidgets.__version__ is 7.0.1 and jupyter-notebook --version is 5.2.0.

Is there some workaraound?
Thanks!

@pbugnion
Copy link
Member

Thanks for raising this.

A workaround for this would be to specify an absolute width for the slider:

widgets.SelectionRangeSlider(
    options=options,
    index=index,
    description='Test',
    orientation='horizontal',
    layout={'width': '500px'}
)

Beyond workarounds, I am not sure if expanding the label size depending on the options was part of the design. I could see that getting very tricky if the label strings have very different lengths.

@weichm
Copy link
Contributor Author

weichm commented Oct 16, 2017

Thanks, that worked for me!

However, I don't close this issue, as I consider it a bug?

@jasongrout
Copy link
Member

jasongrout commented Oct 16, 2017

It's a bit tricky, in that we made the tiling design of widgets and the size of the label for the slider before we had a selection range slider. We don't know how big the item text will be, so we can't easily make it always work and still have widgets tile nicely. So we have a default width for the slider, and make it easy to make it bigger if the things you are selecting have wider text.

So I would say it's a limitation of our current design with an accepted workaround more than a bug.

@jasongrout jasongrout added this to the Reference milestone Oct 16, 2017
@pbugnion pbugnion changed the title selectionrangeslider: too short, cuts of labels selectionrangeslider: too short, cuts off labels Oct 18, 2017
@jasongrout
Copy link
Member

It sounds like we should add a note to the docs about the workaround.

@jasongrout jasongrout modified the milestones: Reference, 7.1 Oct 18, 2017
@jasongrout jasongrout changed the title selectionrangeslider: too short, cuts off labels document how to extend length of labels Oct 18, 2017
@jasongrout jasongrout modified the milestones: 7.x, 7.0.x Oct 27, 2017
@peristeri
Copy link
Contributor

@jasongrout I'm interested on working this issue. I was thinking of introducing a styling section in the Embedding Jupyter Widgets in Other Contexts than the Notebook page.

@jasongrout
Copy link
Member

@peristeri - that would be great! I think a natural place for it would be in this section of the documentation: http://ipywidgets.readthedocs.io/en/stable/examples/Widget%20Styling.html#Description (that's in this notebook: https://github.com/jupyter-widgets/ipywidgets/blob/master/docs/source/examples/Widget%20Styling.ipynb)

@alfredo-gimenez
Copy link

Unfortunately this fix doesn't work for me--looks like the width of the slider occupies a fixed percentage of the layout width, so with a long enough string it still gets cut off.

Alternatively, is there a way to put the range values below the slider?

@labodyn
Copy link

labodyn commented Sep 15, 2018

Fix does not work for me, same issue.

@LeoWu1993
Copy link

Same issue

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

No branches or pull requests

8 participants