๐ย ย Diagrams
Submitted by Arnaud Miribel
Summary
Render mingrammer/diagrams architecture diagrams in Streamlit, plus a built-in Streamlit node.
Functions
st_diagram
Render a diagrams architecture diagram in Streamlit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diagram
|
Diagram
|
A |
required |
format
|
Literal['svg', 'png']
|
Output format. |
'svg'
|
width
|
int | Literal['stretch', 'content']
|
Image width. |
'stretch'
|
caption
|
str | None
|
Optional caption displayed below the diagram. |
None
|
Source code in src/streamlit_extras/diagrams/__init__.py
Import:
- You should add this to the top of your .py file
Examples
example
def example() -> None:
try:
from diagrams import Diagram
from diagrams.aws.compute import EC2
from diagrams.aws.database import RDS
from diagrams.aws.network import ELB
with Diagram(
"Streamlit App Architecture",
show=False,
direction="LR",
graph_attr={"pad": "0.5", "labelloc": "t"},
) as diag:
StreamlitNode("Frontend") >> ELB("Load Balancer") >> EC2("API Server") >> RDS("Database")
st_diagram(diag, caption="Built with the diagrams library")
except ImportError:
st.warning(
"This example requires the `diagrams` package and Graphviz. "
"Install with `pip install diagrams` and [install Graphviz](https://graphviz.org/download/)."
)