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

Fixed HoloViews axis linking across Template roots #980

Merged
merged 1 commit into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion panel/io/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ def _server_url(url, port):
return 'http://%s:%d%s' % (url.split(':')[0], port, "/")

def _eval_panel(panel, server_id, title, doc):
from ..template import Template
from ..pane import panel as as_panel

if isinstance(panel, FunctionType):
if isinstance(panel, Template):
return panel._modify_doc(server_id, title, doc)
elif isinstance(panel, FunctionType):
panel = panel()
return as_panel(panel)._modify_doc(server_id, title, doc)

Expand Down
6 changes: 3 additions & 3 deletions panel/pane/holoviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,11 +535,11 @@ def link_axes(root_view, root_model):

fig = p.state
if fig.x_range.tags:
range_map[(fig.x_range.tags[0], plot.root.ref['id'])].append((fig, p, fig.xaxis[0], fig.x_range))
range_map[fig.x_range.tags[0]].append((fig, p, fig.xaxis[0], fig.x_range))
if fig.y_range.tags:
range_map[(fig.y_range.tags[0], plot.root.ref['id'])].append((fig, p, fig.yaxis[0], fig.y_range))
range_map[fig.y_range.tags[0]].append((fig, p, fig.yaxis[0], fig.y_range))

for (tag, _), axes in range_map.items():
for (tag), axes in range_map.items():
fig, p, ax, axis = axes[0]
for fig, p, pax, _ in axes[1:]:
changed = []
Expand Down
8 changes: 5 additions & 3 deletions panel/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from .io.notebook import render_template
from .io.state import state
from .layout import Column
from .pane import panel as _panel, HTML, Str
from .pane import panel as _panel, HTML, Str, HoloViews
from .viewable import ServableMixin, Viewable
from .widgets import Button

Expand Down Expand Up @@ -113,11 +113,13 @@ def _init_doc(self, doc=None, comm=None, title=None, notebook=False):
ref = preprocess_root.ref['id']
for name, (obj, tags) in self._render_items.items():
model = obj.get_root(doc, comm)
doc.on_session_destroyed(obj._server_destroy)
for sub in obj.select(Viewable):
sub._models[ref] = sub._models.get(model.ref['id'])
if isinstance(sub, HoloViews):
sub._plots[ref] = sub._plots.get(model.ref['id'])
col.objects.append(obj)
obj._documents[doc] = model
doc.on_session_destroyed(obj._server_destroy)
col.append(obj)
model.name = name
model.tags = tags
add_to_doc(model, doc, hold=bool(comm))
Expand Down
4 changes: 2 additions & 2 deletions panel/tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def test_template_links_axes(document, comm):
(_, (m1, _)) = list(p1._models.items())[0]
(_, (m2, _)) = list(p2._models.items())[0]
(_, (m3, _)) = list(p3._models.items())[0]
assert m1.x_range is not m2.x_range
assert m1.y_range is not m2.y_range
assert m1.x_range is m2.x_range
assert m1.y_range is m2.y_range
assert m2.x_range is m3.x_range
assert m2.y_range is m3.y_range

Expand Down