使用dagre-d3 库显示图表。
函数签名
st.graphviz_chart(figure_or_dot, use_container_width=False)
参数 | 说明 |
---|---|
figure_or_dot (graphviz.dot.Graph, graphviz.dot.Digraph, str) | 要显示的 Graphlib 图形对象或点串 |
use_container_width (bool) | 如果为 True,则将图表宽度设置为列宽。这优先于图窗的原生 |
示例
import streamlit as st
import graphviz as graphviz
# Create a graphlib graph object
graph = graphviz.Digraph()
graph.edge('run', 'intr')
graph.edge('intr', 'runbl')
graph.edge('runbl', 'run')
graph.edge('run', 'kernel')
graph.edge('kernel', 'zombie')
graph.edge('kernel', 'sleep')
graph.edge('kernel', 'runmem')
graph.edge('sleep', 'swap')
graph.edge('swap', 'runswap')
graph.edge('runswap', 'new')
graph.edge('runswap', 'runmem')
graph.edge('new', 'runmem')
graph.edge('sleep', 'runmem')
st.graphviz_chart(graph)
或者您可以使用 GraphViz 的 Dot 语言从图表中渲染图表:
st.graphviz_chart('''
digraph {
run -> intr
intr -> runbl
runbl -> run
run -> kernel
kernel -> zombie
kernel -> sleep
kernel -> runmem
sleep -> swap
swap -> runswap
runswap -> new
runswap -> runmem
new -> runmem
sleep -> runmem
}
''')
相关用法
- Python Streamlit st.experimental_singleton.clear用法及代码示例
- Python Streamlit st.bokeh_chart用法及代码示例
- Python Streamlit st.caption用法及代码示例
- Python Streamlit st.text_input用法及代码示例
- Python Streamlit st.area_chart用法及代码示例
- Python Streamlit st.title用法及代码示例
- Python Streamlit st.cache用法及代码示例
- Python Streamlit st.experimental_singleton用法及代码示例
- Python Streamlit st.empty用法及代码示例
- Python Streamlit st.error用法及代码示例
- Python Streamlit st.video用法及代码示例
- Python Streamlit st.vega_lite_chart用法及代码示例
- Python Streamlit st.slider用法及代码示例
- Python Streamlit st.header用法及代码示例
- Python Streamlit st.container用法及代码示例
- Python Streamlit st.form_submit_button用法及代码示例
- Python Streamlit st.form用法及代码示例
- Python Streamlit st.plotly_chart用法及代码示例
- Python Streamlit st.bar_chart用法及代码示例
- Python Streamlit st.code用法及代码示例
- Python Streamlit st.experimental_memo.clear用法及代码示例
- Python Streamlit st.warning用法及代码示例
- Python Streamlit st.image用法及代码示例
- Python Streamlit st.markdown用法及代码示例
- Python Streamlit st.expander用法及代码示例
注:本文由纯净天空筛选整理自streamlit.io大神的英文原创作品 st.graphviz_chart。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。