
    &e                       U d Z ddlmZ ddlZddlmZmZmZmZm	Z	m
Z
 ddlmZmZ ddlmc mc mZ ddlmZ ddl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   ee!          Z"de#d<    G d d          Z$	 	 	 	 dd dZ%h dZ&dS )!z"A Python wrapper around Vega-Lite.    )annotationsN)TYPE_CHECKINGAnyDictOptionalUnioncast)FinalLiteral)arrow)Data)StreamlitAPIException)
get_logger)ArrowVegaLiteChart)gather_metrics)DeltaGeneratorr
   LOGGERc                  Z    e Zd Z ed          	 	 	 	 ddd            Zedd            ZdS )ArrowVegaLiteMixinvega_lite_chartNF	streamlitdatar   specDict[str, Any] | Noneuse_container_widthboolthemeLiteral['streamlit'] | Nonekwargsr   return'DeltaGenerator'c                    |dk    r|dk    rt          d| d          t                      }t          |||f||d| | j                            d|          S )a  Display a chart using the Vega-Lite library.

        Parameters
        ----------
        data : pandas.DataFrame, pandas.Styler, pyarrow.Table, numpy.ndarray, Iterable, dict, or None
            Either the data to be plotted or a Vega-Lite spec containing the
            data (which more closely follows the Vega-Lite API).

        spec : dict or None
            The Vega-Lite spec for the chart. If the spec was already passed in
            the previous argument, this must be set to None. See
            https://vega.github.io/vega-lite/docs/ for more info.

        use_container_width : bool
            If True, set the chart width to the column width. This takes
            precedence over Vega-Lite's native `width` value.

        theme : "streamlit" or None
            The theme of the chart. Currently, we only support "streamlit" for the Streamlit
            defined design or None to fallback to the default behavior of the library.

        **kwargs : any
            Same as spec, but as keywords.

        Example
        -------
        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>>
        >>> chart_data = pd.DataFrame(np.random.randn(200, 3), columns=["a", "b", "c"])
        >>>
        >>> st.vega_lite_chart(
        ...    chart_data,
        ...    {
        ...        "mark": {"type": "circle", "tooltip": True},
        ...        "encoding": {
        ...            "x": {"field": "a", "type": "quantitative"},
        ...            "y": {"field": "b", "type": "quantitative"},
        ...            "size": {"field": "c", "type": "quantitative"},
        ...            "color": {"field": "c", "type": "quantitative"},
        ...        },
        ...    },
        ... )

        .. output::
           https://doc-vega-lite-chart.streamlit.app/
           height: 300px

        Examples of Vega-Lite usage without Streamlit can be found at
        https://vega.github.io/vega-lite/examples/. Most of those can be easily
        translated to the syntax shown above.

        r   NzYou set theme="us   " while Streamlit charts only support theme=”streamlit” or theme=None to fallback to the default library theme.)r   r   arrow_vega_lite_chart)r   ArrowVegaLiteChartProtomarshalldg_enqueue)selfr   r   r   r   r   protos          Blib/python3.11/site-packages/streamlit/elements/arrow_vega_lite.pyr   z"ArrowVegaLiteMixin.vega_lite_chart)   s    ~ KETMM' ]%  ]  ]  ]   ())	
 !4	
 	
 	
 	
 	
 w 7???    c                "    t          d|           S )zGet our DeltaGenerator.r   )r	   )r(   s    r*   r&   zArrowVegaLiteMixin.dgw   s     $d+++r+   NNFr   )r   r   r   r   r   r   r   r   r   r   r    r!   )r    r!   )__name__
__module____qualname__r   r   propertyr&    r+   r*   r   r   (   s|        ^%&& &*$)-8K@ K@ K@ K@ '&K@Z , , , X, , ,r+   r   Fr   r)   r$   r   r   r   Optional[Dict[str, Any]]r   r   r   !Union[None, Literal['streamlit']]c                $   t          |t                    r||}d}|t                      }nt          |          }t          |          r%t          |fi t          j        |t
                    }t          |          dk    rt          d          d|vrddd|d<   d|v rq|d                                         D ]S\  }}| j        	                                }t          |          |_        d	|_        t          j        |j        |           T|d= d
|v r2|d
         }	t          |	t                    rd|	v r|	d         }|d
= n|	}|d
= t!          j        |          | _        || _        |pd| _        |t          j        | j        |           dS dS )zZConstruct a Vega-Lite chart object.

    See DeltaGenerator.vega_lite_chart for docs.
    Nr   z/Vega-Lite charts require a non-empty spec dict.autosizefitpadding)typecontainsdatasetsTr   values )
isinstancedictlen	dicttools	unflatten	_CHANNELS
ValueErroritemsr;   addstrnamehas_namer   r%   r   jsondumpsr   r   r   )
r)   r   r   r   r   r   kvdataset	data_specs
             r*   r%   r%   }   s    $ $,
 |vv Dzz 6{{ D DCCI/	BBCC
4yyA~~JKKK$)yAAZ T$**,, 	, 	,DAqn((**Gq66GL#GN7<++++ ~~L	i&& 	9$$ *LDVD!!EJ 3E+2EKuz4((((( r+   >   xyx2y2keyrowhrefsizetextcolorfacetordershapecolumndetailxErroropacitytooltipyError2latitude	longitudefillOpacitystrokeWidthstrokeOpacityr-   )
r)   r$   r   r   r   r3   r   r   r   r4   )'__doc__
__future__r   rJ   typingr   r   r   r   r   r	   typing_extensionsr
   r    streamlit.elements.lib.dicttoolselementslibrA   streamlit.elementsr   streamlit.elements.arrowr   streamlit.errorsr   streamlit.loggerr   &streamlit.proto.ArrowVegaLiteChart_pb2r   r$   streamlit.runtime.metrics_utilr   streamlit.delta_generatorr   r.   r   __annotations__r   r%   rC   r2   r+   r*   <module>rw      s   ) ( ( " " " " " "  B B B B B B B B B B B B B B B B , , , , , , , , 4 4 4 4 4 4 4 4 4 4 4 4 $ $ $ $ $ $ ) ) ) ) ) ) 2 2 2 2 2 2 ' ' ' ' ' '      : 9 9 9 9 9 9888888 
8$$ $ $ $ $R, R, R, R, R, R, R, R,n %) %/:G) G) G) G) G)V  			r+   