Basic display using _repr_mimebundle_
@@ -6,6 +6,7 @@ DSL mapping Vega types to IPython traitlets.
import os
import functools
import operator
+import uuid
import traitlets as T
import pandas as pd
@@ -300,14 +301,16 @@ class TopLevelMixin(object):
return self._update_subtraits(('config', 'facet', 'scale'),
*args, **kwargs)
- # Display related methods
- def _ipython_display_(self):
- from IPython.display import display
+ def _repr_mimebundle_(self, include, exclude, **kwargs):
+ """Return a MIME-bundle for rich display in the Jupyter Notebook."""
spec = self.to_dict()
- data = {'application/vnd.vegalite+json': spec}
- display(data, raw=True)
+ bundle = {}
+ bundle['text/plain'] = '<altair.VegaLite object>'
+ bundle['application/vnd.vegalite.v1+json'] = spec
+ return bundle
def display(self):
+ """Display the Chart using the Jupyter Notebook's rich output."""
from IPython.display import display
display(self)
