Skip to content

Commit

Permalink
Fixed saving
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Aug 5, 2019
1 parent 7b7711f commit 6bccf93
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 8 additions & 2 deletions holoviews/plotting/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ def plot_options(cls, obj, percent_size):


@bothmethod
def save(self_or_cls, obj, basename, fmt='auto', key={}, info={}, options=None, **kwargs):
def save(self_or_cls, obj, basename, fmt='auto', key={}, info={},
options=None, resources='cdn', **kwargs):
"""
Save a HoloViews object to file, either using an explicitly
supplied format or to the appropriate default.
Expand All @@ -453,7 +454,12 @@ def save(self_or_cls, obj, basename, fmt='auto', key={}, info={}, options=None,
plot, fmt = self_or_cls._validate(obj, fmt)

if isinstance(plot, Viewable):
plot.save(basename, embed=True)
from bokeh.resources import CDN, INLINE
if resources == 'cdn':
resources = CDN
elif resources == 'inline':
resources = INLINE
plot.layout.save(basename, embed=True, resources=resources)
return

rendered = self_or_cls(plot, fmt)
Expand Down
8 changes: 6 additions & 2 deletions holoviews/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ def register_backend_callback(cls, backend, callback):
cls._backend_hooks[backend].append(callback)


def save(obj, filename, fmt='auto', backend=None, **kwargs):
def save(obj, filename, fmt='auto', backend=None, resources='cdn', **kwargs):
"""
Saves the supplied object to file.
Expand All @@ -736,6 +736,10 @@ def save(obj, filename, fmt='auto', backend=None, **kwargs):
and if widgets are desired either 'widgets' or 'scrubber'
backend: string
A valid HoloViews rendering backend, e.g. bokeh or matplotlib
resources: string or bokeh.resource.Resources
Bokeh resources used to load bokehJS components. Defaults to
CDN, to embed resources inline for offline usage use 'inline'
or bokeh.resources.INLINE.
**kwargs: dict
Additional keyword arguments passed to the renderer,
e.g. fps for animations
Expand All @@ -754,7 +758,7 @@ def save(obj, filename, fmt='auto', backend=None, **kwargs):
fmt = formats[-1]
if formats[-1] in supported:
filename = '.'.join(formats[:-1])
return renderer_obj.save(obj, filename, fmt=fmt)
return renderer_obj.save(obj, filename, fmt=fmt, resources=resources)


def render(obj, backend=None, **kwargs):
Expand Down

0 comments on commit 6bccf93

Please sign in to comment.