Skip to content

Commit

Permalink
Ensure that Design does not override properties on HoloViews pane (#6051
Browse files Browse the repository at this point in the history
)
  • Loading branch information
philippjfr committed Dec 15, 2023
1 parent 600d2ce commit 47b65fd
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
9 changes: 9 additions & 0 deletions panel/pane/holoviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,15 @@ def _sync_sizing_mode(self, plot):
finally:
self._syncing_props = False

def _process_param_change(self, params):
if self._plots:
# Handles a design applying custom parameters on the plot
# which have to be mapped to properties by the underlying
# plot pane, e.g. Bokeh, Matplotlib or Plotly
_, pane = next(iter(self._plots.values()))
return pane._process_param_change(params)
return super()._process_param_change(params)

#----------------------------------------------------------------
# Model API
#----------------------------------------------------------------
Expand Down
7 changes: 4 additions & 3 deletions panel/pane/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,10 @@ def _get_model(
self, doc: Document, root: Optional[Model] = None,
parent: Optional[Model] = None, comm: Optional[Comm] = None
) -> Model:
self._bokeh_model = lazy_load(
'panel.models.plotly', 'PlotlyPlot', isinstance(comm, JupyterComm), root
)
if not hasattr(self, '_bokeh_model'):
self._bokeh_model = lazy_load(
'panel.models.plotly', 'PlotlyPlot', isinstance(comm, JupyterComm), root
)
return super()._get_model(doc, root, parent, comm)

def _update(self, ref: str, model: Model) -> None:
Expand Down
30 changes: 26 additions & 4 deletions panel/tests/pane/test_holoviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
plotly_available = pytest.mark.skipif(hv_plotly is None, reason="requires plotly backend")

from bokeh.models import (
Column as BkColumn, ColumnDataSource, GlyphRenderer, GridPlot, Line,
Row as BkRow, Scatter, Select as BkSelect, Slider as BkSlider,
Spacer as BkSpacer,
Column as BkColumn, ColumnDataSource, GlyphRenderer, GridPlot,
ImportedStyleSheet, Line, Row as BkRow, Scatter, Select as BkSelect,
Slider as BkSlider, Spacer as BkSpacer,
)
from bokeh.plotting import figure

Expand All @@ -30,8 +30,11 @@
from panel.layout import (
Column, FlexBox, HSpacer, Row,
)
from panel.pane import HoloViews, PaneBase, panel
from panel.pane import (
HoloViews, PaneBase, Plotly, panel,
)
from panel.tests.util import hv_available, mpl_available
from panel.theme import Native
from panel.util.warnings import PanelDeprecationWarning
from panel.widgets import (
Checkbox, DiscreteSlider, FloatSlider, Select,
Expand Down Expand Up @@ -225,6 +228,25 @@ def test_holoviews_pane_reflect_responsive_plotly(document, comm):
assert row.sizing_mode is None
assert pane.sizing_mode is None


@hv_available
@plotly_available
def test_holoviews_pane_inherits_design_stylesheets(document, comm):
curve = hv.Curve([1, 2, 3]).opts(responsive=True, backend='plotly')
pane = HoloViews(curve, backend='plotly')


# Create pane
row = pane.get_root(document, comm=comm)

Native().apply(pane, row)

plotly_model = row.children[0]

assert len(plotly_model.stylesheets) == 6
stylesheets = [st.url for st in plotly_model.stylesheets if isinstance(st, ImportedStyleSheet)]
assert all(st in stylesheets for st in Plotly._stylesheets)

@hv_available
def test_holoviews_widgets_from_dynamicmap(document, comm):
range_dim = hv.Dimension('A', range=(0, 10.))
Expand Down

0 comments on commit 47b65fd

Please sign in to comment.