shahinrostami / plotapi

Engaging visualisations, made easy.
https://plotapi.com
MIT License
267 stars 17 forks source link

HTML display not working in Jupyter #36

Closed zedrdave closed 3 years ago

zedrdave commented 3 years ago

Just installed and ran the latest version (with a Pro licence) and can't seem to get the HTML display to work in Jupyter.

I tested with the sample code, and png works, but .show() just results in an empty output.

Digging through the browser console, I'm seeing: [Error] ReferenceError: Can't find variable: d3 (anonymous function) (Script Element 10:24)… Line 24 contains: colors = d3.schemeSet1;

There indeed seems to be a problem in how d3 is imported…

shahinrostami commented 3 years ago

Hello @zedrdave

Thanks for submitting this. I'll look into this in the morning if you can share some more information about your environment and how to reproduce this please.

Are you running Jupyter Lab or Jupyter Notebook? Chord pro only supports outputting to Jupyter Lab cells, just in case you're using the latter.

If that's not the issue, please let me know what package versions you're using, and if you are connecting via a VPN, etc! If outputting to png works, it could be Jupyter Lab plug-in causing an issue - which are installed?

Best,

Shahin

zedrdave commented 3 years ago

I am indeed running Jupyter Notebook, not Lab. I didn't realise that .show() wasn't supposed to work with the former…

The HTML seems to be mostly displayable (it even works using .to_html() and %%html), except for that strange error mentioned above.

shahinrostami commented 3 years ago

Hi @zedrdave

It seems that's the cause! Jupyter Lab had become popular as their "next-generation" [1] web interface when I first created the chord library, so I focussed support on that. It still operates on Jupyter notebooks, but functions a little differently behind the scenes [2].

I think I would need to write a Jupyter Notebook extension to get it working in both! However, I believe the diagram is being generated correctly, this is why .to_html() works (as it does from python at terminal too).

[1] https://jupyterlab.readthedocs.io/en/stable/getting_started/overview.html [2] https://github.com/shahinrostami/chord#the-chord-package