From 623ff976d096990a58361eb86856201eb83b5db6 Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Wed, 13 Dec 2023 19:17:26 -0500 Subject: [PATCH] Add "jupyter" renderer based on JupyterChart --- altair/vegalite/v5/display.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/altair/vegalite/v5/display.py b/altair/vegalite/v5/display.py index 93926e62b..7b23e0710 100644 --- a/altair/vegalite/v5/display.py +++ b/altair/vegalite/v5/display.py @@ -86,6 +86,13 @@ def svg_renderer(spec: dict, **metadata) -> Dict[str, str]: ) +def render_jupyter(spec): + """Render chart using the JupyterChart Jupyter Widget""" + from altair import Chart, JupyterChart + + return JupyterChart(chart=Chart.from_dict(spec))._repr_mimebundle_() + + html_renderer = HTMLRenderer( mode="vega-lite", template="universal", @@ -105,6 +112,7 @@ def svg_renderer(spec: dict, **metadata) -> Dict[str, str]: renderers.register("json", json_renderer) renderers.register("png", png_renderer) renderers.register("svg", svg_renderer) +renderers.register("jupyter", render_jupyter) renderers.enable("default")