New component for interactive graph visualization: yFiles Graphs for Streamlit

Hi there!

We’ve built a free Streamlit component for interactive graph visualizations: yFiles Graphs for Streamlit.

Here is a small example that lets you interactively explore the graph data of Little Alchemy: https://little-alchemy-explorer.streamlit.app/

You can install the component from PyPI with:

pip install yfiles_graphs_for_streamlit

The interactive viewer and API provide many useful features, such as:

  • Data-driven item visualization
  • Automatic graph layouts
  • Heatmap visualization
  • Geospatial data mapping
  • Grouping and interactive folding of groups
  • Data imports for popular modules (e.g., Neo4j, NetworkX, pandas, …)

In general, it imports structured node and edge lists. A very simple example looks like this:

import streamlit as st
from yfiles_graphs_for_streamlit import StreamlitGraphWidget, Node, Edge

nodes = [
    Node(id=0, properties={"firstName": "Alpha", "label": "Person A"}),
    Node(id=1, properties={"firstName": "Bravo", "label": "Person B"}),
    Node(id=2, properties={"firstName": "Charlie", "label": "Person C", "has_hat": False}),
    Node(id=3, properties={"firstName": "Delta", "label": "Person D", "likes_pizza": True})
]
edges = [
    Edge(start=0, end=1, properties={"since": "1992", "label": "knows"}),
    Edge(start=1, end=3, properties={"label": "knows", "since": "1992"}),
    Edge(start=2, end=3, properties={"label": "knows", "since": "1992"}),
    Edge(start=0, end=2, properties={"label": "knows", "since": 234})
]

StreamlitGraphWidget(nodes, edges).show()

You can find more information here:

This would make a great addition to the “Graphs” components listed here Components • Streamlit but we haven’t found a way to contribute to that page yet. If you know how we can add it, please let us know.

Anyhow, let us know what you think!