From ac8e42442cc628f4a9eb858e0cf644c3b3760bb7 Mon Sep 17 00:00:00 2001 From: Antonio Piccolboni Date: Tue, 18 Sep 2018 21:59:51 -0700 Subject: [PATCH] support for altair figures --- pweave/altair/__init__.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 pweave/altair/__init__.py diff --git a/pweave/altair/__init__.py b/pweave/altair/__init__.py new file mode 100644 index 0000000..69ddf9a --- /dev/null +++ b/pweave/altair/__init__.py @@ -0,0 +1,29 @@ +from IPython.core.display import display_html +import hashlib + +display_html( + """ + + + +""", + raw=True) + + +def show(plot): + """ + Include an Altair (vega) figure in Pweave document. + Generates html output. + """ + json = plot.to_json() + id = "A" + hashlib.sha256(json.encode()).hexdigest() + display_html( + """ +
+ + """.format(id=id, json=json), + raw=True)