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)