import streamlit as st
import graphviz as gv
g = gv.Graph('hello')
g.node('hello', image='heart.png', shape='box')
g.node('world', label="world", shape='ellipse')
g.edge('hello', 'world')
st.graphviz_chart(g)
No matter where I place the heart.png, I cannot get the image to be displayed. I even used imagepath keyword, but the image would not be rendered.
A second problem is if I use a label with HTML in it such as the following, the graph will not even be drawn:
import streamlit as st
import graphviz as gv
g = gv.Graph('hello')
g.node('hello', label="<<h1>Hello</h1>>", shape='box')
g.node('world', label="world\r", shape='ellipse')
g.edge('hello', 'world')
st.graphviz_chart(g)
I don’t have much experience with graphviz, but have you tested your code in another environment to make sure it works properly? Meaning, if you develop your graph in Jupyter Notebook or something and it displays properly, but doesn’t display in st.graphviz_chart, then I can pass that on to our engineers.
So, when I try rendering the image as a png or pdf under Jupyter via: g.render(view=True, format=“png”), then the image does show up correctly. If I try svg, the image does not show up. Does this help?
Thanks for confirming @ddutt. I wonder if this is a similar issue to this one…this user is also reporting that SVG isn’t working correctly for a different use case:
Could you add your use to that thread, just to highlight they might be related?
I’m not sure the issues are related, unless I do a bit more investigation. I’ll do so and reply here if I don’t think they’re related OR add to the bug as you suggest, if they are.
Hope that works. Thanks,
Dinesh
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.