-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Altair visualization library doesn't work #560
Comments
What do the dev tools show with You'll want to check the js console for error messages. |
Based on the Altair FAQ, it needs an nbextension in order to draw graphs. Link: https://altair-viz.github.io/faq.html#id2 Nbextensions are part of the notebook, not hydrogen, so it's not clear what can be done to fix this. (On phone, sorry for brevity) |
The way we handle vega in nteract/nteract right now is a custom renderer/transform for mimetypes import IPython.display
def vegify(spec):
IPython.display.display({
'application/vnd.vegalite+json': spec.to_dict()
}, raw=True) from altair import Chart, load_dataset
# load data as a pandas DataFrame
cars = load_dataset('cars')
spec = Chart(cars).mark_point().encode(
x='Horsepower',
y='Miles_per_Gallon',
color='Origin',
)
vegify(spec) Resulting notebook: |
I'd like to support vega and plotly as standard transforms in all the jupyter environments so libraries don't have to dump JS and HTML payloads for these. |
Wow, I didn't know about nteract/nteract until now – it looks super cool! 😃 I think that it makes sense to mention nteract somewhere in Hydrogen README, it can interest some of Hydrogen users. So custom handling of these mimetypes is going to be added to Hydrogen eventually? Looking forward to it, thank you for your answer! |
We would certainly welcome a pull request with that. 😄
They wouldn't be too hard to add right now, it would probably be better to do it after nteract/nteract exports more modules so we don't have to maintain it in so many places. |
Just some updates on this effort: In #655 and #705 we added support for more transforms using the packages exported by nteract. nteract also exports I wasn't able to get it working right out of the box, but I'm confident that it isn't too hard to implement with some tinkering. If anyone want's to pick up on this, any help is greatly appreciated 🎉 |
Will be fixed once Atom 1.20.0 is stable. |
Note for folks who come across this thread: For Altair version 2.0 or newer, the above If you want to use Altair in the meantime, please try another front-end, such as nteract desktop, nteract-on-jupyter, JupyterLab, Jupyter Notebook, or CoLab. |
Thank you @jakevdp for adding the comment. @lgeiger should I open an issue? |
We've had Vega 3 / Vega-lite support in github master for a little while, it just hasn't been published in a release yet. Everything should be compatible assuming that altair set up their display MIME types the same way as hydrogen and JupyterLab. |
@jakevdp is Altair only publishing the new spec now? Is it ok to deprecate the handling of the old spec at any point? |
I think moving toward deprecating the old schema version (vega v2 and vega-lite v1) will be fine Altair is now using the vegalite v2 mimetype, and I suspect that the vast majority of users will be using that soon. That said, Altair does still have the ability to generate vegalite v1 mimetypes as well... JupyterLab and the classic notebook will still be able to handle those, though it will require explicitly enabling an extra extension in order to do so. |
@jakevdp - I just checked and vega v3 and vega-lite v2 are both supported in nteract desktop: Hydrogen needs to upgrade to the latest of the display area. nteract desktop is totally fine and has been since nteract v0.6.0, which was released at the end of January. We're now on v0.8.4 so any system that allows the auto-upgrades should be all set. |
That's great to hear – thanks! |
As of today's release of Hydrogen, we support Vega 3 and Vega-lite 2. Slick interactives! |
Slick! Thanks for shipping |
Hello!
I've been working with your package lately and it's really great. Unfortunately, it fails to display the output of the Altair library. I try running this code from their homepage:
Notebook
Hydrogen
Notebook output contents
Hydrogen output contents
I am under the impression that the package that is used to embed Altair's graphics is https://github.com/vega/ipyvega, but I am not familiar with Altair's source enough to tell for sure.
So, does support for this library have to be added to Hydrogen by hand or is something broken here?
The text was updated successfully, but these errors were encountered: