8000 Fix embed themed models by jsignell · Pull Request #5932 · bokeh/bokeh · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@jsignell
Copy link
Contributor
@jsignell jsignell commented Feb 28, 2017

Changes to using curdoc rather than new doc when embedding

@bryevdv
Copy link
Member
bryevdv commented Feb 28, 2017

AFAICT the only remaining place _ModelInEmptyDocument is used is in tests that test _ModelInEmptyDocument itself:

https://github.com/bokeh/bokeh/blob/master/bokeh/tests/test_model.py#L9-L37

I'd be +1 on removing it altogether in this PR.

@jsignell
Copy link
Contributor Author

@bryevdv I can also probably get rid of _ModelInDocument in this PR if you don't think it is out of scope

p1 = figure(title='PINK')
p1.scatter(x1, y1)

theme = Theme(json={'attrs': {'Title': {'text_color': 'pink'}}})
Copy link
Member

Choose a reason for hiding this comment

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

Maybe also add a dark (grey?) background, and make the CSS page background match? Then the lighter title will stand out more and also it gives an example of matching a plot to its background in the page.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you mean the background of the plot should match background-color for css class embed-wrapper?

@bryevdv
Copy link
Member
bryevdv commented Feb 28, 2017

I can also probably get rid of _ModelInDocument in this PR if you don't think it is out of scope

My experience has been that if things like this aren't done immediately as the opportunity arises they often never get done, or languish. So I'm generally +1 on reasonable, incremental code gardening in "regular" PRs as opposed to giant "cleanup" PRs that try to do lots of it at once.

@jsignell
Copy link
Contributor Author

After thinking about it some more it seems like maybe having a context manager for _ModelInDocument is actually not such a bad idea. It doesn't just get used in embed.

@jsignell
Copy link
Contributor Author

The example looks like this now:
screen shot 2017-02-28 at 11 36 38 am

Pretty ugly, but proves the point I think.

@bryevdv
Copy link
Member
bryevdv commented Feb 28, 2017

Pretty ugly, but proves the point I think.

Maybe more like the crossdfilter demo? (in terms of colors)

People ask for how to have a "dark" theme with some regularity so have a basic but reasonable one would be nice to demonstrate.

bokeh/model.py Outdated
yield model
if len(existing_docs) == 0:
# no existing docs, use the current doc
doc = curdoc()
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure curdoc is advised here. Although I have not seen it done, it's not a huge stretch to imagine a Bokeh app that produces embedded stand alone bokeh plots as some kind of output. Then this code would intertwine the "produced" standalone plots with the bokeh app curdoc and I doubt that is desirable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that curdoc is what fixes the theme.

Copy link
Member

Choose a reason for hiding this comment

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

It's one way, but it seems that copying any theme to a new Document should also be feasible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it fits the expectation that the curdoc would get rendered when embedding. This would happen for show() or save()

@bryevdv
Copy link
Member
bryevdv commented Feb 28, 2017

I'm not sure I favor keeping the context manager, but I guess I don't feel too strongly against it. But if we are going to do so we should own it, i.e. rename it ModelInDocument, add tests and documentation, and move it some place better like bokeh.util


p1 = figure(title='PINK TITLE')
p1.background_fill_color = "#999999"
p1.border_fill_color = "#999999"
Copy link
Member

Choose a reason for hiding this comment

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

these colors can go in the theme, sorry I was not explicit but I was suggesting making the theme have a bit more content.

@jsignell
Copy link
Contributor Author
jsignell commented Mar 1, 2017

screen shot 2017-02-28 at 3 12 23 pm

@bryevdv
Copy link
Member
bryevdv commented Mar 1, 2017

This LGTM, you may need to merge master to get things green (see #5938)

{{ script }}
<style>
body {
text-rendering: optimizeLegibility;
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the purpose of setting this? text-rendering is a SVG property.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I was copying from another example. I will take it out.

@bryevdv bryevdv merged commit 6564383 into bokeh:master Mar 1, 2017
@github-actions
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 28, 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.

Theme doesn't apply when using components curdoc().theme = Theme(json=yaml.load()) is not applied to charts when used in Jupyter notebook

3 participants

0