Interactive Graph Vis for Streamlit.
Project description
Based on react-d3-graph
Install
pip install streamlit-agraph
Use
import streamlit
from streamlit_agraph import agraph, Node, Edge, Config
nodes = []
edges = []
nodes.append( Node(id="Spiderman",
label="Peter Parker",
size=400,
svg="http://marvel-force-chart.surge.sh/marvel_force_chart_img/top_spiderman.png")
) # includes **kwargs
nodes.append( Node(id="Captain_Marvel",
size=400,
svg="http://marvel-force-chart.surge.sh/marvel_force_chart_img/top_captainmarvel.png")
)
edges.append( Edge(source="Captain_Marvel",
label="friend_of",
target="Spiderman",
type="CURVE_SMOOTH")
) # includes **kwargs
config = Config(width=500,
height=500,
directed=True,
nodeHighlightBehavior=True,
highlightColor="#F7A7A6", # or "blue"
collapsible=True,
node={'labelProperty':'label'},
link={'labelProperty': 'label', 'renderLabel': True}
# **kwargs e.g. node_size=1000 or node_color="blue"
)
return_value = agraph(nodes=nodes,
edges=edges,
config=config)
You may also want to use the TripleStore (untested & incomplete - yet):
from rdflib import Graph
from streamlit_agraph import TripleStore, agraph
graph = Graph()
graph.parse("http://www.w3.org/People/Berners-Lee/card")
store = TripleStore()
for subj, pred, obj in graph:
store.add_triple(subj, pred, obj, "")
agraph(list(store.getNodes()), (store.getEdges()), config)
Also graph algos can dirctly supported via the networkx API (untested & incomplete - yet):
from streamlit_agraph import GraphAlgos
algos = GraphAlgos(store)
algos.shortest_path("Spiderman", "Captain_Marvel")
algos.density()
Formating the graph with hierachies is also possible, see examples/iris_decision_tree.py
:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
streamlit-agraph-0.0.37.tar.gz
(689.6 kB
view hashes)
Built Distribution
Close
Hashes for streamlit_agraph-0.0.37-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76b6ba6aa4d7ce3a1f5ca399170865cec356aa57731efe1d63bfdb84ae3e2386 |
|
MD5 | d5adbe2efe2e2f6b05638d19563eb07a |
|
BLAKE2b-256 | 05b18e9630ef62e985eaf213d6d1c0f7070798380ac315d63a9e1a7e1aed40c4 |