o
    h4                     @  s   U d Z ddlmZ ddlZddlmZmZmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ er=dd	lmZ dd
lmZ dZded< G dd dZdddZdS )zA Python wrapper around Bokeh.    )annotationsN)TYPE_CHECKINGFinalcast)StreamlitAPIException)
BokehChart)gather_metrics)calc_md5)Figure)DeltaGeneratorz2.4.3r   ST_BOKEH_VERSIONc                   @  s0   e Zd Zed	ddd	d
ZedddZdS )
BokehMixinbokeh_chartTfigurer
   use_container_widthboolreturnr   c                 C  sh   ddl }|jtkrtdt d|j dt d| j }t| }t }t	|||| | j
d|S )a>  Display an interactive Bokeh chart.

        Bokeh is a charting library for Python. The arguments to this function
        closely follow the ones for Bokeh's ``show`` function. You can find
        more about Bokeh at https://bokeh.pydata.org.

        To show Bokeh charts in Streamlit, call ``st.bokeh_chart``
        wherever you would call Bokeh's ``show``.

        .. Important::
            You must install ``bokeh==2.4.3`` and ``numpy<2`` to use this
            command.

            If you need a newer version of Bokeh, use our |streamlit-bokeh|_
            custom component instead.

        .. |streamlit-bokeh| replace:: ``streamlit-bokeh``
        .. _streamlit-bokeh: https://github.com/streamlit/streamlit-bokeh

        Parameters
        ----------
        figure : bokeh.plotting.figure.Figure
            A Bokeh figure to plot.

        use_container_width : bool
            Whether to override the figure's native width with the width of
            the parent container. If ``use_container_width`` is ``True`` (default),
            Streamlit sets the width of the figure to match the width of the parent
            container. If ``use_container_width`` is ``False``, Streamlit sets the
            width of the chart to fit its contents according to the plotting library,
            up to the width of the parent container.

        Example
        -------
        >>> import streamlit as st
        >>> from bokeh.plotting import figure
        >>>
        >>> x = [1, 2, 3, 4, 5]
        >>> y = [6, 7, 2, 4, 5]
        >>>
        >>> p = figure(title="simple line example", x_axis_label="x", y_axis_label="y")
        >>> p.line(x, y, legend_label="Trend", line_width=2)
        >>>
        >>> st.bokeh_chart(p)

        .. output::
           https://doc-bokeh-chart.streamlit.app/
           height: 700px

        r   Nz&Streamlit only supports Bokeh version z, but you have version zG installed. Please run `pip install --force-reinstall --no-deps bokeh==z` to install the correct version.


To use the latest version of Bokeh, install our custom component, [streamlit-bokeh](https://github.com/streamlit/streamlit-bokeh).r   )bokeh__version__r   r   dg_get_delta_path_strr	   encodeBokehChartProtomarshall_enqueue)selfr   r   r   
delta_path
element_idbokeh_chart_proto r   R/var/www/vscode/kcb/lib/python3.10/site-packages/streamlit/elements/bokeh_chart.pyr   $   s   8


zBokehMixin.bokeh_chartc                 C  s
   t d| S )zGet our DeltaGenerator.r   )r   )r   r   r   r    r   p   s   
zBokehMixin.dgN)T)r   r
   r   r   r   r   )r   r   )__name__
__module____qualname__r   r   propertyr   r   r   r   r    r   #   s    Kr   protor   r   r
   r   r   r   strr   Nonec                 C  s0   ddl m} ||}t|| _|| _|| _dS )zRConstruct a Bokeh chart object.

    See DeltaGenerator.bokeh_chart for docs.
    r   )	json_itemN)bokeh.embedr(   jsondumpsr   r   r   )r%   r   r   r   r(   datar   r   r    r   v   s
   

r   )
r%   r   r   r
   r   r   r   r&   r   r'   )__doc__
__future__r   r*   typingr   r   r   streamlit.errorsr   streamlit.proto.BokehChart_pb2r   r   streamlit.runtime.metrics_utilr   streamlit.utilr	   bokeh.plotting.figurer
   streamlit.delta_generatorr   r   __annotations__r   r   r   r   r   r    <module>   s   S