Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions examples/streamlit-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pathlib

from neo4j_viz.pandas import from_dfs
from neo4j_viz import VisualizationGraph
from neo4j_viz import VisualizationGraph, Layout

# Path to this file
script_path = pathlib.Path(__file__).resolve()
Expand Down Expand Up @@ -37,9 +37,9 @@ def create_visualization_graph() -> VisualizationGraph:

@st.cache_data
def render_graph(
_VG: VisualizationGraph, height: int, initial_zoom: float = 0.1
_VG: VisualizationGraph, height: int, layout: Layout, initial_zoom: float = 0.1
) -> HTML:
return VG.render(initial_zoom=initial_zoom, height=f"{height}px")
return VG.render(initial_zoom=initial_zoom, height=f"{height}px", layout=layout)


VG = create_visualization_graph()
Expand All @@ -52,6 +52,10 @@ def render_graph(

with st.sidebar:
height = st.slider("Height in pixels", 100, 2000, 600, 50)
layout = st.radio(
"Layout",
[Layout.FORCE_DIRECTED, Layout.HIERARCHICAL, Layout.GRID],
)
show_code = st.checkbox("Show code")

st.header("Visualization")
Expand All @@ -61,7 +65,7 @@ def render_graph(
)

components.html(
render_graph(VG, height=height).data,
render_graph(VG, height=height, layout=layout).data,
height=height,
)

Expand Down