Hey community, recently I did a new component called stvis for rendering pyvis graphs. This was for the Tigergraph hackaton, and it is based on a previous work, but hopefully it could be of help for someone else.
here is how it looks:
So if you want to play with this, you can pip install by doing:
pip install stvis
and here is a working example:
from pyvis import network as net
import streamlit as st
from stvis import pv_static
g=net.Network(height='500px', width='500px',heading='')
g.add_node(1)
g.add_node(2)
g.add_node(3)
g.add_edge(1,2)
g.add_edge(2,3)
pv_static(g)
Hi, I tried. the program generate a graph.html, but its content is blank. no point is showed, I just saw a border without graph. can you tell me why will be like this?
Hi @BeyondMyself, thanks for testing the component. I did check on a different computer, and also see a blank as you but only on Safari, however on firefox or chrome it works Ok. So, I need to check with more detail what is happening. Could you tell me what web browser are you using??
Thanks for the reply @BeyondMyself.
You also need to install pyvis, as the component is based on it.
So in principle, you must do something like this for working in a virtual environment:
I find the reason, besides I had solved it.
the program generated the graph.html and the html relies on a javascripts file called vis-network.min.js.
My server can not viste the cdn url, so its graph can not be displayed on browser webpage window.
After I save the content of vis-network.min.js to my python program foulder and fresh the graph.html, the points appear.
Thanks for your amazing work.
I have some new ideas to share with you:
1.may we can add or delete the new point on webpage, through a input button?
this function can set by user to show on webpage or not in python program.
2.maybe we can define the color and shape of new point and their line width, color between each other.
3.after quantity of points is fixed, maybe we can let the graph move randomly like a animation
I also whether let the graph move or not should permit user to set in python program will be better.
Because some user want the graph moving like a animation, other people want see a static page.
Hi @BeyondMyself, sorry for the delay. Glad that you managed the component to work, and good to know about that issue.
About your suggestions, I think that all are razonable, but on the other side, the idea with the component is that anyone just need to know how pyvis work in order to do whatever is desired, and for example I think your three points are more or less easily done just with pyvis functions. But I will keep in mind your request, and maybe later I will come back with something
Anyway, whoever is interested and wanted to contribute, here is the repo for this component:
Hey, this component is amazing. I do not want the graph to also be shown on a new HTML Page. That is, I only want the graph on my streamlit app without it getting opened in a new tab as well. What should I change?
Hi @Sharan19, that is weird it doesn’t works like that on my side… could you share with me your code, and which browser are you using?? I need to figure out how to fix that behaviour.
Thanks for testing the component!!
Regards
from pyvis import network as net
import streamlit as st
from stvis import pv_static
g=net.Network(height='500px', width='500px',heading='Constructed Graph')
g.add_node(1)
g.add_node(2)
g.add_node(3)
g.add_edge(1,2)
g.add_edge(2,3)
pv_static(g)
Hi, I think that I’ve fixed the issue with the graph opening in a new tab. This is corrected in the new version of stvis.
You can install it with
pip install stvis==0.0.2
Please, if the problem persists let me know, I had not faced that problem before, but recently I was aware of that undesired behavior. Not it seems fixed.
Regards!!
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.