Open cscetbon opened 4 years ago
Hi @cscetbon,
I've never used or even heard of Jupyter so I can't really say anything here. However could you say something about the use case for this and what output you want to get? Because running this without a DOM seems quite useless to me.
@Thomaash, in Jupyter notebooks you can display images inline. So if the vis-network has a way to provide an array of pixels or a stream object that can be used to extract those pixels I could use something like https://matplotlib.org/tutorials/introductory/images.html#importing-image-data-into-numpy-arrays
I'm afraid there's no good way to do this. It's possible to get images from Vis Network. We do it for examples index but that's done by running a Chromium instance to render into a canvas in the DOM so that's only an option if you can prerender the images. It's also possible to convert the canvas into an image but then you have to have the canvas somewhere. In case you have access to document.createElement
it may be possible to use the element as a container and get an image from the canvas even if it isn't in DOM but I've never tried it so I don't know if it actually works.
Other than that something would have to be implemented in Vis Network to support this (contribution opportunity here :wink:).
@Thomaash I might be able to use something like https://stackoverflow.com/a/43514776
@cscetbon @Thomaash
Here is an example of using VisJS in regular Jupyter notebook, we need to use require
here.
https://www.kaggle.com/evgenyskvortsov/another-visjs/edit
Here is an example of using it in Google CoLab, which treats JS differently, so we can do it plainly: https://colab.research.google.com/github/EvgSkv/logica/blob/main/examples/more/Generic-VisJS.ipynb
Here is an example of using an open-source python library that draws graphs with VisJS: https://colab.research.google.com/github/EvgSkv/logica/blob/main/examples/Logica_example_Drawing_Graphs.ipynb#scrollTo=snWJQtjDp0qA
Hope this helps. Let me know if you have any questions, or if this would be useful to add to any documentation.
I'm trying to use your library in a Notebook but it requires a DOM which I don't have. Is there any way to do without or do you have an example on how to do it using Jupyter ?