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

Nested plotly tabs produce AttributeError #2459

Closed
thomasbangels opened this issue Jun 30, 2021 · 1 comment · Fixed by #2463
Closed

Nested plotly tabs produce AttributeError #2459

thomasbangels opened this issue Jun 30, 2021 · 1 comment · Fixed by #2463
Labels
type: bug Something isn't correct or isn't working
Milestone

Comments

@thomasbangels
Copy link

Thanks to #2418, plotly figures have the desired interactivity when displayed in tabs. However, when the plotly figures are inside nested tabs, the following AttributeError is triggered:

Traceback (most recent call last):
  File "panel_bug_report_nested_tabs.py", line 27, in <module>
    plots.save("nested_tabs_depth_2.html", resources="inline")
  File "/home/bangels/.local/lib/python3.8/site-packages/panel/viewable.py", line 766, in save
    return save(self, filename, title, resources, template,
  File "/home/bangels/.local/lib/python3.8/site-packages/panel/io/save.py", line 210, in save
    model = panel.get_root(doc, comm)
  File "/home/bangels/.local/lib/python3.8/site-packages/panel/viewable.py", line 514, in get_root
    self._preprocess(root)
  File "/home/bangels/.local/lib/python3.8/site-packages/panel/viewable.py", line 448, in _preprocess
    hook(self, root)
  File "/home/bangels/.local/lib/python3.8/site-packages/panel/pane/plotly.py", line 338, in _patch_tabs_plotly
    if not any(tabs.select_one(pt) for pt in parent_tabs if pt is not tabs):
  File "/home/bangels/.local/lib/python3.8/site-packages/panel/pane/plotly.py", line 338, in <genexpr>
    if not any(tabs.select_one(pt) for pt in parent_tabs if pt is not tabs):
  File "/home/bangels/.local/lib/python3.8/site-packages/bokeh/model.py", line 584, in select_one
    result = list(self.select(selector))
  File "/home/bangels/.local/lib/python3.8/site-packages/bokeh/core/query.py", line 88, in <genexpr>
    return (obj for obj in objs if match(obj, selector, context))
  File "/home/bangels/.local/lib/python3.8/site-packages/bokeh/core/query.py", line 160, in match
    for key, val in selector.items():
AttributeError: 'Tabs' object has no attribute 'items'

Code snippet to produce the error:

import numpy as np
import panel as pn
import plotly.graph_objects as go

pn.extension('plotly')

plots = pn.Tabs(tabs_location="left")
plots_normal = pn.Tabs(tabs_location="left")
plots_inverse = pn.Tabs(tabs_location="left")
plots.append(("normal", plots_normal))
plots.append(("inverse", plots_inverse))

x = np.arange(10)
pn1 = go.Scatter(x=x, y=x**2, marker={"color": "red"})
pn2 = go.Scatter(x=x, y=x**3, marker={"color": "green"})
pi1 = go.Scatter(x=x**2, y=x, marker={"color": "blue"})
pi2 = go.Scatter(x=x**3, y=x, marker={"color": "black"})
plots_normal.append(("quadratic", pn1))
plots_normal.append(("third power", pn2))
plots_inverse.append(("quadratic", pi1))
plots_inverse.append(("third power", pi2))

# no nested tabs, works
plots_normal.save("nested_tabs_depth_1.html", resources="inline")

# nested tabs, gives 'items' attribute error with bokeh Tabs
plots.save("nested_tabs_depth_2.html", resources="inline")

Version info:

panel   0.12.0a22 
bokeh   2.3.2
param   1.10.1    
plotly  4.9.0
python  3.8.5
OS      Ubuntu 20.04
@philippjfr philippjfr added the type: bug Something isn't correct or isn't working label Jun 30, 2021
@philippjfr
Copy link
Member

Thanks for catching this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants