Commit fd82a2ee authored by Christoph Jansen's avatar Christoph Jansen

updated earlier svg img fix

parent 7b5045c7
import base64
from networkx.drawing.nx_pydot import to_pydot
def draw(nx_graph, color=None, fillcolor=None, observed_fillcolor=None, highlight_color=None,
highlight_observed_fillcolor=None, encoding=None, html_img=True):
highlight_observed_fillcolor=None, encoding=None, disable_html_wrapper=None):
color = color or '#808080'
fillcolor = fillcolor or '#FFFFFF'
observed_fillcolor = observed_fillcolor or '#F0F0F0'
......@@ -42,10 +43,13 @@ def draw(nx_graph, color=None, fillcolor=None, observed_fillcolor=None, highligh
edge['color'] = highlight_color
prog = ['neato', '-n2'] if keep_pos else 'dot'
result = to_pydot(nx_graph).create_svg(prog=prog).decode(encoding)
svg = to_pydot(nx_graph).create_svg(prog=prog)
if html_img:
result = '<img>{}</img>'.format(result)
if disable_html_wrapper:
result = svg.decode(encoding)
result = base64.b64encode(svg).decode(encoding)
result = '<img src="data:image/svg+xml;base64, {}" />'.format(result)
return result
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment