L iUdZddlmZddlmZmZmZmZddlm Z ddl m Z m Z ddl mZmZmZmZmZddlmZddlmZdd lmZdd lmZer dd lZdd lmZed ddefZ de!d<GddZ" ddZ#y )z&Streamlit support for GraphViz charts.) annotations) TYPE_CHECKING TypeAliasUnioncast) type_util)make_deprecated_name_warningshow_deprecation_warning)Height LayoutConfigWidthvalidate_heightvalidate_width)StreamlitAPIException) GraphVizChart)gather_metrics)calc_md5N)DeltaGeneratorzgraphviz.Graphzgraphviz.Digraphzgraphviz.Sourcer FigureOrDotcZeZdZed dddd ddZed dZy) GraphvizMixingraphviz_chartNcontentwidthheightc f|!ttdddddd|rdnd }|jj}t |j }t }t|||t|d t|d t|| }|jjd ||S)agDisplay a graph using the dagre-d3 library. .. Important:: You must install ``graphviz>=0.19.0`` to use this command. You can install all charting dependencies (except Bokeh) as an extra with Streamlit: .. code-block:: shell pip install streamlit[charts] Parameters ---------- figure_or_dot : graphviz.dot.Graph, graphviz.dot.Digraph, graphviz.sources.Source, str The Graphlib graph object or dot string to display use_container_width : bool Whether to override the figure's native width with the width of the parent container. If ``use_container_width`` is ``False`` (default), Streamlit sets the width of the chart to fit its contents according to the plotting library, up to the width of the parent container. If ``use_container_width`` is ``True``, Streamlit sets the width of the figure to match the width of the parent container. .. deprecated:: ``use_container_width`` is deprecated and will be removed in a future release. For ``use_container_width=True``, use ``width="stretch"``. For ``use_container_width=False``, use ``width="content"``. width : "content", "stretch", or int The width of the chart element. This can be one of the following: - ``"content"`` (default): The width of the element matches the width of its content, but doesn't exceed the width of the parent container. - ``"stretch"``: The width of the element matches the width of the parent container. - An integer specifying the width in pixels: The element has a fixed width. If the specified width is greater than the width of the parent container, the width of the element matches the width of the parent container. height : "content", "stretch", or int The height of the chart element. This can be one of the following: - ``"content"`` (default): The height of the element matches the height of its content. - ``"stretch"``: The height of the element matches the height of its content or the height of the parent container, whichever is larger. If the element is not in a parent container, the height of the element matches the height of its content. - An integer specifying the height in pixels: The element has a fixed height. If the content is larger than the specified height, scrolling is enabled. Example ------- >>> import streamlit as st >>> import 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) Or you can render the chart from the graph using GraphViz's Dot language: >>> 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 } ''') .. output:: https://doc-graphviz-chart.streamlit.app/ height: 600px use_container_widthrz 2025-12-31znFor `use_container_width=True`, use `width='stretch'`. For `use_container_width=False`, use `width='content'`.F)include_st_prefix)show_in_browserstretchrT) allow_contentrr) layout_config) r r dg_get_delta_path_strrencodeGraphVizChartProtomarshallrrr _enqueue) self figure_or_dotrrr delta_path element_idgraphviz_chart_protor#s g/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/elements/graphviz_chart.pyrzGraphvizMixin.graphviz_chart1sd  * $,) N&+ !& "5I)EWW002 j//12 13%}jA uD1d3$5@ ww 2-   ctd|S)zGet our DeltaGenerator.r)r)r*s r/r$zGraphvizMixin.dgs$d++r0)N) r+rrz bool | Nonerr rr returnr)r2r)__name__ __module__ __qualname__rrpropertyr$r0r/rr0sy$%,0N !" N "N )N  N  N  N &N `,,r0rctj|r|j}|j}n,t |t r|}d}nt dt|||_||_||_ y)zXConstruct a GraphViz chart object. See DeltaGenerator.graphviz_chart for docs. dotz#Unhandled type for graphviz chart: N) ris_graphviz_chartsourceengine isinstancestrrtypespecr-)protor+r-r9r<s r/r(r(sq""=1""%% M3 '#1$}2E1F G  EJEL!Er0)rAr'r+rr-r>r2None)$__doc__ __future__rtypingrrrr streamlitrstreamlit.deprecation_utilr r #streamlit.elements.lib.layout_utilsr r r rrstreamlit.errorsr!streamlit.proto.GraphVizChart_pb2rr'streamlit.runtime.metrics_utilrstreamlit.utilrgraphvizstreamlit.delta_generatorrr>r__annotations__rr(r7r0r/rPs-"883Q9#8(*;S@ Y U,U,p" """ "r0