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

Enable automatic responsive sizing for Vega pane #949

Merged
merged 1 commit into from
Jan 16, 2020
Merged
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
12 changes: 11 additions & 1 deletion panel/pane/vega.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pyviz_comms import JupyterComm

from ..viewable import Layoutable
from ..util import string_types
from .base import PaneBase

def ds_as_cds(dataset):
Expand Down Expand Up @@ -116,12 +117,21 @@ def _get_dimensions(cls, json, props):
view['height'] = size_config[h]

for p in ('width', 'height'):
if p not in view:
if p not in view or isinstance(view[p], string_types):
continue
if props.get(p) is None or p in view and props.get(p) < view[p]:
v = view[p]
props[p] = v+22 if isinstance(v, int) else v

responsive_height = json.get('height') == 'container'
responsive_width = json.get('width') == 'container'
if responsive_height and responsive_width:
props['sizing_mode'] = 'stretch_both'
elif responsive_width:
props['sizing_mode'] = 'stretch_width'
elif responsive_height:
props['sizing_mode'] = 'stretch_height'

def _get_model(self, doc, root=None, parent=None, comm=None):
if 'panel.models.vega' not in sys.modules:
if isinstance(comm, JupyterComm):
Expand Down