Skip to content

Commit

Permalink
Added Renderer.export_widgets method
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Dec 3, 2015
1 parent 8bbc924 commit cdd5d76
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions holoviews/plotting/renderer.py
Expand Up @@ -220,10 +220,9 @@ def html(self, obj, fmt=None, css=None):

def static_html(self, obj, fmt=None, template=None):
"""
Generates a static HTML with the rendered object in
the supplied format. Allows supplying a template
formatting string with fields to interpolate 'js',
'css' and the main 'html'.
Generates a static HTML with the rendered object in the
supplied format. Allows supplying a template formatting string
with fields to interpolate 'js', 'css' and the main 'html'.
"""
cls_type = type(self)

Expand Down Expand Up @@ -269,6 +268,29 @@ def get_widget(self, plot, widget_type, **kwargs):
return widget_cls(plot, renderer=self, embed=embed, **kwargs)


def export_widgets(self, obj, fmt=None, template=None, json=False, json_path=None):
"""

This comment has been minimized.

Copy link
@jlstevens

jlstevens Dec 4, 2015

Contributor

Isn't **kwargs missing from this signature to set all the other widget parameters?

Render and export object as a widget to a static HTML
file. Allows supplying a custom template formatting string
with fields to interpolate 'js', 'css' and the main 'html'
containing the widget. Also provides options to export widget
data to a json file in the supplied json_path (defaults to
current path).
"""
if fmt not in self.widgets.keys()+['auto', None]:
raise ValueError("Renderer.export_widget may only export "
"registered widget types.")

if not isinstance(obj, NdWidget):
kwargs = dict(export_json=json)
if json_path is not None:
kwargs['json_path'] = json_path
widget = self.get_widget(obj, fmt, **kwargs)
else:
widget = obj
return self.static_html(widget, fmt, template)


@classmethod
def plotting_class(cls, obj):
"""
Expand Down

0 comments on commit cdd5d76

Please sign in to comment.