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

Added better support for computing bokeh plot size #1140

Merged
merged 1 commit into from
Feb 21, 2017

Conversation

philippjfr
Copy link
Member

The current BokehRenderer.get_size method only supports very simple plots that are not part of a layout grid, or contain toolbars and tables. This PR computes the size of a bokeh plot more accurately for all these cases, which can be very useful when wanting to embed the plot in HTML and know the size ahead of time.

@philippjfr
Copy link
Member Author

Ready for review and merge.

width, height = plot.plot_width, plot.plot_height
elif isinstance(plot, (Plot, Div, DataTable)):
width, height = plot.width, plot.height
if width is None: width = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this an error condition? What are you going to do with a plot that is either zero width, zero height or both?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certain models do not declare a width/height and rather than guess at it I'd take the hit and just say it's zero. The only thing that I've found that's actually affected by this is the Div model used to add titles to grid plots.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I'll just add an explicit branch for the Div model, and make a comment about this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I'll just add an explicit branch for the Div model, and make a comment about this.

Sounds like a good idea.

@jlstevens
Copy link
Contributor

I made one comment (although I can't say I follow all the detailed size computation logic!) but generally it looks good.

The main thing I checked was that get_size is defined as a @bothmethod which means it is easy to get the size of bokeh plot as long as you can import the BokehRenderer class.

Happy to merge once you address my comment.

@philippjfr
Copy link
Member Author

@jlstevens Ready to merge.

@jlstevens
Copy link
Contributor

Looks good. Merging.

@jlstevens jlstevens merged commit 938ee7c into master Feb 21, 2017
@jbednar jbednar deleted the bokeh_renderer_get_size branch February 22, 2017 16:11
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants