-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Theme doesn't apply when using components #4952
Comments
ping @bryevdv - any thoughts |
Not offhand, I have a vague recollection of seeing this now, so thanks for capturing the issue. |
Ran into the same or similar issue trying to set the theme of the curdoc when outputting to a notebook.
|
I've hit this too, and it looks like it is because with _ModelInDocument: Which adds the model to a document, which combined with p = figure()
curdoc().theme = Theme(json={'attrs': {'Title': {'text_color': 'pink'}}})
cudoc().add_root(p)
script, div = components(p) @bryevdv - I'm happy to look at a fix, I guess the obvious one would be to do something to preserve the theme in the |
Something like: class _ModelInDocument(object):
# 'models' can be a single Model, a single Document, or a list of either
def __init__(self, models):
from .document import Document
self._to_remove_after = []
self._theme = []
if not isinstance(models, list):
models = [models]
self._doc = _find_some_document(models)
if self._doc is None:
# oh well - just make up a doc
self._doc = Document()
for model in models:
if isinstance(model, Model):
if model.document is None:
# Gets the model theme (or None if no theme)
self._theme.append(model.themed_values())
self._to_remove_after.append(model)
def __exit__(self, type, value, traceback):
for i, model in enumerate(self._to_remove_after):
model.document.remove_root(model)
if self._theme[i] is not None:
# Applies the model theme after removing the document
model.apply_theme(self._theme[i])
def __enter__(self):
for i, model in enumerate(self._to_remove_after):
# This should preserve model theming here
self._doc.add_root(model)
if self._theme[i] is not None:
# Applies the model theme after adding the document
model.apply_theme(self._theme[i]) But I'm not sure if this would have repercussions elsewhere - otherwise this could be done around the with loop in |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Can't get themes to apply when using
bokeh.embed.components
.Have tried manually using
theme.apply_to_model(model)
, but it doesn't seem to work.The text was updated successfully, but these errors were encountered: