TutteInstitute / datamapplot

Creating beautiful plots of data maps
MIT License
777 stars 50 forks source link

Interactive plot with selection does not render #44

Open akshayka opened 1 month ago

akshayka commented 1 month ago

I attempted the tutorial on creating a plot with selection, but was met with an infinitely spinning spinner.

Here is a Colab notebook that demonstrates the issue. I am using datamapplot==0.4.2:

https://colab.research.google.com/drive/14Taj65FefFboB-7Ipi-RAZ1ADVeZWvpc?usp=sharing

I encountered the same issue in a local marimo notebook. I did not try in a local Jupyter notebook.

lmcinnes commented 1 month ago

I believe this is specific to having inline_data=False, since it saves separate data files off which the HTML then fetches and parses. This works fine for general serving of webpages, but gets trickier when going through an iframe srcdoc inside of a notebook.

There is some special code that hacks the html so that things work within Jupyter. I believe colab has slightly different paths/properties. I'm sure Marimo doesn't have Jupyter's convolutions. We may need to have similar contortions specific to colab, and then other handling for Marimo. Let me see if I can work out colab. For your reference the handling is here, and amounts to working around the fact that you can't actually fetch files via jupyters web address because jupyter intercepts the requests, so it rewrites what works for ordinarily served web-pages to work within jupyter, as well as trying to handle the fact that we are buried in a srcdoc, so some other wrangling needs to be done to get the server address.

lmcinnes commented 1 month ago

So inline_data=False is simply not going to work with colab unfortunately, since it doesn't save files in a way that you can fetch them without integrati8ng with google drive (which I can understand people not wanting to do). What I can hopefully do is detect if it is being run in google colab and providing a warning that things won't work as intended.

akshayka commented 1 month ago

Thanks for the source pointer. I can see if I can get it working in marimo