
    g5                   t   U d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 ddl
mZmZmZmZmZmZmZmZ ddlmZ ddlmc mc mZ ddlmZmZ dd	lmZmZ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)m*Z*m+Z+ ddl,m-Z- ddl.m/Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6m7Z7 ddl8m9Z9 erddl:m;Z;m<Z< ddl=Z>ddl?m@Z@ ddlAmBZB ddlCmDZD h dZEdeFd<   dZGdeFd<   ed   ZHdeFd<    G d  d!ed"#      ZIe	 G d$ d%             ZJ	 	 	 	 	 	 d0d&ZK	 d1	 	 	 	 	 	 	 d2d'ZL	 	 	 	 d3d(ZMd4d)ZNd5d*ZO	 	 	 	 	 	 d6d+ZPd7d,ZQd8d-ZR G d. d/      ZSy)9zQCollection of chart commands that are rendered via our vega-lite chart component.    )annotationsN)nullcontext)	dataclass)TYPE_CHECKINGAnyFinalLiteral	TypedDictUnioncastoverload)	TypeAlias)dataframe_util	type_util)AddRowsMetadataChartStackType	ChartTypegenerate_chartmaybe_raise_stack_warning)AttributeDictionary)current_form_id)check_widget_policies)Keycompute_and_register_element_idto_key)StreamlitAPIException)ArrowVegaLiteChart)gather_metrics)get_script_run_ctx)WidgetCallbackregister_widget)HASHLIB_KWARGS)IterableSequence)Data)DeltaGenerator)Color>   xyx2y2keyrowhrefsizetextcolorfacetordershapecolumndetailxErroryErroropacitytooltipxError2yError2latitude	longitudefillOpacitystrokeWidthstrokeOpacityr   	_CHANNELSzdict[str, Any]r   VegaLiteSpec)z	alt.Chartzalt.ConcatChartzalt.FacetChartzalt.HConcatChartzalt.LayerChartzalt.RepeatChartzalt.VConcatChartAltairChartc                      e Zd ZU dZded<   y)VegaLiteStatea  
    The schema for the Vega-Lite event state.

    The event state is stored in a dictionary-like object that supports both
    key and attribute notation. Event states cannot be programmatically
    changed or set through Session State.

    Only selection events are supported at this time.

    Attributes
    ----------
    selection : dict
        The state of the ``on_select`` event. This attribute returns a
        dictionary-like object that supports both key and attribute notation.
        The name of each Vega-Lite selection parameter becomes an attribute in
        the ``selection`` dictionary. The format of the data within each
        attribute is determined by the selection parameter definition within
        Vega-Lite.

    Examples
    --------
    The following two examples have equivalent definitions. Each one has a
    point and interval selection parameter include in the chart definition.
    The point selection parameter is named ``"point_selection"``. The interval
    or box selection parameter is named ``"interval_selection"``.

    The follow example uses ``st.altair_chart``:

    >>> import streamlit as st
    >>> import pandas as pd
    >>> import numpy as np
    >>> import altair as alt
    >>>
    >>> if "data" not in st.session_state:
    >>>     st.session_state.data = pd.DataFrame(
    ...         np.random.randn(20, 3), columns=["a", "b", "c"]
    ...     )
    >>> df = st.session_state.data
    >>>
    >>> point_selector = alt.selection_point("point_selection")
    >>> interval_selector = alt.selection_interval("interval_selection")
    >>> chart = (
    ...     alt.Chart(df)
    ...     .mark_circle()
    ...     .encode(
    ...         x="a",
    ...         y="b",
    ...         size="c",
    ...         color="c",
    ...         tooltip=["a", "b", "c"],
    ...         fillOpacity=alt.condition(point_selector, alt.value(1), alt.value(0.3)),
    ...     )
    ...     .add_params(point_selector, interval_selector)
    ... )
    >>>
    >>> event = st.altair_chart(chart, key="alt_chart", on_select="rerun")
    >>>
    >>> event

    The following example uses ``st.vega_lite_chart``:

    >>> import streamlit as st
    >>> import pandas as pd
    >>> import numpy as np
    >>>
    >>> if "data" not in st.session_state:
    >>>     st.session_state.data = pd.DataFrame(
    ...         np.random.randn(20, 3), columns=["a", "b", "c"]
    ...     )
    >>>
    >>> spec = {
    ...     "mark": {"type": "circle", "tooltip": True},
    ...     "params": [
    ...         {"name": "interval_selection", "select": "interval"},
    ...         {"name": "point_selection", "select": "point"},
    ...     ],
    ...     "encoding": {
    ...         "x": {"field": "a", "type": "quantitative"},
    ...         "y": {"field": "b", "type": "quantitative"},
    ...         "size": {"field": "c", "type": "quantitative"},
    ...         "color": {"field": "c", "type": "quantitative"},
    ...         "fillOpacity": {
    ...             "condition": {"param": "point_selection", "value": 1},
    ...             "value": 0.3,
    ...         },
    ...     },
    ... }
    >>>
    >>> event = st.vega_lite_chart(
    ...     st.session_state.data, spec, key="vega_chart", on_select="rerun"
    ... )
    >>>
    >>> event

    Try selecting points in this interactive example. When you click a point,
    the selection will appear under the attribute, ``"point_selection"``, which
    is the name given to the point selection parameter. Similarly, when you
    make an interval selection, it will appear under the attribute
    ``"interval_selection"``. You can give your selection parameters other
    names if desired.

    If you hold ``Shift`` while selecting points, existing point selections
    will be preserved. Interval selections are not preserved when making
    additional selections.

    .. output::
        https://doc-chart-events-vega-lite-state.streamlit.app
        height: 600px

    r   	selectionN)__name__
__module____qualname____doc____annotations__     S/var/www/openai/venv/lib/python3.12/site-packages/streamlit/elements/vega_charts.pyrF   rF   n   s    m^ #"rN   rF   F)totalc                  .    e Zd ZU dZded<   dddZd	dZy)
VegaLiteStateSerdezQVegaLiteStateSerde is used to serialize and deserialize the VegaLite Chart state.zSequence[str]selection_parametersc                    dt        | j                  D ci c]  }|i  c}      i}||n+t        t        t        t	        j
                  |                  }d|vr|}t        t        t        |            S c c}w )NrG   )r   rS   r   rF   jsonloads)selfui_value	widget_idparamempty_selection_stateselection_states         rO   deserializezVegaLiteStateSerde.deserialize   s    ,(,(A(AB(Au(AB0
  "m%8H9M%NO 	 o-3OM#6#GHH Cs   
A6
c                8    t        j                  |t              S )N)default)rU   dumpsstr)rW   r\   s     rO   	serializezVegaLiteStateSerde.serialize   s    zz/377rN   N) )rX   
str | NonerY   ra   returnrF   )r\   rF   re   ra   )rH   rI   rJ   rK   rL   r]   rb   rM   rN   rO   rR   rR      s    [''I&8rN   rR   c                    t        |      r%t        | fi t        j                  |t              } nt        |       } t        |       dk(  rt        d      d| vrd| v r|r
ddd| d<   | S ddd| d<   | S )	Nr   z/Vega-Lite charts require a non-empty spec dict.autosizevconcatzfit-xpadding)typecontainsfit)lendict	dicttools	unflattenrB   r   )specuse_container_widthkwargss      rO   _prepare_vega_lite_specrt      s    
 6{
 DCI//	BC Dz
4yA~#$UVV
 !4(/YGD K ).9EDKrN   c                   d|v r|d   j                         D ]l  \  }}| j                  j                         }t        |      |_        d|_        t        |t              r|nt        j                  |      |j                  _
        n |d= d|v r'|d   }t        |t              rd|v r|d   }|d= n|}|d= |%t        j                  |      | j                  _
        yy)zhAdds the data to the proto and removes it from the spec dict.
    These operations will happen in-place.datasetsTdatavaluesN)itemsrv   addra   namehas_name
isinstancebytesr   convert_anything_to_arrow_bytesrw   rn   )protorq   rw   dataset_namedataset_datadataset	data_specs          rO   _marshall_chart_datar     s     T*.z*:*@*@*B&L,nn((*G|,GL#G lE2 #CCLQ LL +C"  ~L	i&9$ *LDV(HHN

 rN   c                   ddl }i dfd}|j                  j                  d|       |j                  j                  dk(  r|j                  j                  d      n	t               5  |j                  j                  d      5  | j                         }ddd       ddd       d<   |S # 1 sw Y   xY w# 1 sw Y   xY w)	z9Convert an Altair chart object to a Vega-Lite chart spec.r   Nc                    t        j                  |       }t        j                  di t        }|j                  t        |      j                  d             |j                         }||<   d|iS )zAltair data transformer that serializes the data,
        creates a stable name based on the hash of the data,
        stores the bytes into the datasets mapping and
        returns this name to have it be used in Altair.
        zutf-8r{   )md5)	r   r   hashlibnewr"   updatera   encode	hexdigest)rw   
data_byteshr{   rv   s       rO   id_transformz7_convert_altair_to_vega_lite_spec.<locals>.id_transform\  s_     $CCDI
KK00	Z''01{{}#~rN   idr_   nonerv   )re   zdict[str, str])altairdata_transformersregisterthemesactiveenabler   to_dict)altair_chartaltr   
chart_dictrv   s       @rO   !_convert_altair_to_vega_lite_specr   O  s      H" ""46
 '*jj&7&79&D		6	"+-	W""))$/%--/J 0 
X
 &Jz 0/ 
X	Ws$   (B8B,B8,B5	1B88Cc                L     t         fddD              sd vrt        d      y)a  Raise an exception if the spec contains a multi-view chart (view composition).

    This is intended to be used as a temporary solution to prevent selections on
    multi-view charts. There are too many edge cases to handle selections on these
    charts correctly, so we're disallowing them for now.

    More information about view compositions: https://vega.github.io/vega-lite/docs/composition.html
    c              3  &   K   | ]  }|v  
 y wNrM   ).0r,   rq   s     rO   	<genexpr>z._disallow_multi_view_charts.<locals>.<genexpr>  s     U#TCC4K#Ts   )layerhconcatrh   concatrq   encodingzSelections are not yet supported for multi-view charts (chart compositions). If you would like to use selections on multi-view charts, please upvote this [Github issue](https://github.com/streamlit/streamlit/issues/8643).N)anyr   )rq   s   `rO   _disallow_multi_view_chartsr   {  s4     	U#TUUT!#W
 	
 "rN   c                    | rd| vr
t               S t               }| d   D ]:  }|j                  d      s|j                  d      s'|j                  |d          < |S )zBExtract the names of all valid selection parameters from the spec.paramsr{   select)setgetrz   )rq   param_namesrZ   s      rO   _extract_selection_parametersr     sY    84'u%Kh 99V8!4OOE&M*   rN   c                    t        |       }|st        d      |t        |      S t        |t              r|g}|D ]  }||vst        d| d| d       t        |      S )a   Parse and check the user provided selection modes.

    This will raise an exception if no valid selection parameters are found in the spec
    or if the user provided selection modes are not defined in the spec.

    Parameters
    ----------
    spec : VegaLiteSpec
        The Vega-Lite chart specification.

    selection_mode : str, Iterable[str], or None
        The user provided selection mode(s).

    Returns
    -------
    list[str]
        The parsed selection mode(s) that should be activated.
    a  Selections are activated, but the provided chart spec does not have any selections defined. To add selections to `st.altair_chart`, check out the documentation [here](https://altair-viz.github.io/user_guide/interactions.html#selections-capturing-chart-interactions). For adding selections to `st.vega_lite_chart`, take a look at the specification [here](https://vega.github.io/vega-lite/docs/selection.html).zSelection parameter 'zH' is not defined in the chart spec. Available selection parameters are: .)r   r   sortedr}   ra   )rq   selection_modeall_selection_paramsselection_names       rO   _parse_selection_moder     s    0 9>#a
 	
 *++.#&() )!55'''7 8==Q<RRSU  ) .!!rN   c           	        t        j                  d|  d      }t        t        j	                  |j                  |                  x}rCd}t        |d      D ]  \  }}|j                  |d| |  | d      }! |j                  |d      }|S )zAltair uses a global counter for unnamed parameters and views.
    We need to reset these counters on a spec-level to make the
    spec stable across reruns and avoid changes to the element ID.
    "z\d+"__replace_prefix_o9hd101n22e1__   )startrc   )recompilelistrn   fromkeysfindall	enumeratereplace)prefix	vega_specpatternmatchesreplacement_prefixcountermatchs          rO   _reset_counter_patternr     s    
 jjAfXT*+G t}}W__Y%?@AAwA
 ? (q9NGU!))-.vhwiqAI : %%&8"=	rN   c                j    d| v rt        d|       } t        j                  d|       rt        d|       } | S )ai  Makes the chart spec stay stable across reruns and sessions.

    Altair auto creates names for unnamed parameters & views. It uses a global counter
    for the naming which will result in a different spec on every rerun.
    In Streamlit, we need the spec to be stable across reruns and sessions to prevent the chart
    from getting a new identity. So we need to replace the names with counter with a stable name.
    Having a stable chart spec is also important for features like forward message cache,
    where we don't want to have changing messages on every rerun.

    Parameter counter:
    https://github.com/vega/altair/blob/f345cd9368ae2bbc98628e9245c93fa9fb582621/altair/vegalite/v5/api.py#L196

    View counter:
    https://github.com/vega/altair/blob/f345cd9368ae2bbc98628e9245c93fa9fb582621/altair/vegalite/v5/api.py#L2885

    This is temporary solution waiting for a fix for this issue:
    https://github.com/vega/altair/issues/3416

    Other solutions we considered:
     - working on the dict object: this would require to iterate through the object and do the
       same kind of replacement; though we would need to know the structure and since we need
       the spec in String-format anyways, we deemed that executing the replacement on the
       String is the better alternative
     - resetting the counter: the counter is incremented already when the chart object is created
       (see this GitHub issue comment https://github.com/vega/altair/issues/3416#issuecomment-2098530464),
       so it would be too late here to reset the counter with a thread-lock to prevent interference
       between sessions
    z"params"param_z-"(vconcat|hconcat|facet|layer|concat|repeat)"view_)r   r   search)r   s    rO   _stabilize_vega_json_specr     s<    L Y*8Y?	 
yyA9M*7I>	rN   c                     e Zd ZdZ ed      	 d!ddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d"d       Z ed      	 d!dddddddddd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d#d	       Z ed
      	 d!ddddddddddd
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d$d       Z ed      	 d!dddddddddd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d%d       Ze	ddddd	 	 	 	 	 	 	 	 	 	 	 	 	 d&d       Z
e	dddddd	 	 	 	 	 	 	 	 	 	 	 	 	 d'd       Z
 ed      dddddd	 	 	 	 	 	 	 	 	 	 	 	 	 d(d       Z
e		 	 d)ddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d*d       Ze		 	 d)dddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d+d       Z ed      	 	 d)dddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d,d       Z	 	 	 	 	 	 d-	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d.dZ	 	 	 	 	 	 	 	 d/	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d0dZed1d        Zy)2VegaChartsMixinaM  Mix-in class for all vega-related chart commands.

    Altair is a python wrapper on top of the vega-lite spec. And our
    built-in chart commands are just another layer on-top of Altair.
    All of these chart commands will be eventually converted to a vega-lite
    spec and rendered using the same vega-lite chart component.
    
line_chartNT)r(   r)   x_labely_labelr1   widthheightrr   c                   t        t        j                  ||||||d||
      \  }
}t        d| j	                  |
|	d|            S )a]  Display a line chart.

        This is syntax-sugar around ``st.altair_chart``. The main difference
        is this command uses the data's own column and indices to figure out
        the chart's Altair spec. As a result this is easier to use for many
        "just plot this" scenarios, while being less customizable.

        If ``st.line_chart`` does not guess the data specification
        correctly, try specifying your desired chart using ``st.altair_chart``.

        Parameters
        ----------
        data : Anything supported by st.dataframe
            Data to be plotted.

        x : str or None
            Column name or key associated to the x-axis data. If ``x`` is
            ``None`` (default), Streamlit uses the data index for the x-axis
            values.

        y : str, Sequence of str, or None
            Column name(s) or key(s) associated to the y-axis data. If this is
            ``None`` (default), Streamlit draws the data of all remaining
            columns as data series. If this is a ``Sequence`` of strings,
            Streamlit draws several series on the same chart by melting your
            wide-format table into a long-format table behind the scenes.

        x_label : str or None
            The label for the x-axis. If this is ``None`` (default), Streamlit
            will use the column name specified in ``x`` if available, or else
            no label will be displayed.

        y_label : str or None
            The label for the y-axis. If this is ``None`` (default), Streamlit
            will use the column name(s) specified in ``y`` if available, or
            else no label will be displayed.

        color : str, tuple, Sequence of str, Sequence of tuple, or None
            The color to use for different lines in this chart.

            For a line chart with just one line, this can be:

            - None, to use the default color.
            - A hex string like "#ffaa00" or "#ffaa0088".
            - An RGB or RGBA tuple with the red, green, blue, and alpha
              components specified as ints from 0 to 255 or floats from 0.0 to
              1.0.

            For a line chart with multiple lines, where the dataframe is in
            long format (that is, y is None or just one column), this can be:

            - None, to use the default colors.
            - The name of a column in the dataset. Data points will be grouped
              into lines of the same color based on the value of this column.
              In addition, if the values in this column match one of the color
              formats above (hex string or color tuple), then that color will
              be used.

              For example: if the dataset has 1000 rows, but this column only
              contains the values "adult", "child", and "baby", then those 1000
              datapoints will be grouped into three lines whose colors will be
              automatically selected from the default palette.

              But, if for the same 1000-row dataset, this column contained
              the values "#ffaa00", "#f0f", "#0000ff", then then those 1000
              datapoints would still be grouped into three lines, but their
              colors would be "#ffaa00", "#f0f", "#0000ff" this time around.

            For a line chart with multiple lines, where the dataframe is in
            wide format (that is, y is a Sequence of columns), this can be:

            - None, to use the default colors.
            - A list of string colors or color tuples to be used for each of
              the lines in the chart. This list should have the same length
              as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
              for three lines).

        width : int or None
            Desired width of the chart expressed in pixels. If ``width`` is
            ``None`` (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 ``width`` is greater than the width of the
            parent container, Streamlit sets the chart width to match the width
            of the parent container.

            To use ``width``, you must set ``use_container_width=False``.

        height : int or None
            Desired height of the chart expressed in pixels. If ``height`` is
            ``None`` (default), Streamlit sets the height of the chart to fit
            its contents according to the plotting library.

        use_container_width : bool
            Whether to override ``width`` with the width of the parent
            container. If ``use_container_width`` is ``True`` (default),
            Streamlit sets the width of the chart to match the width of the
            parent container. If ``use_container_width`` is ``False``,
            Streamlit sets the chart's width according to ``width``.

        Examples
        --------
        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>>
        >>> chart_data = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"])
        >>>
        >>> st.line_chart(chart_data)

        .. output::
           https://doc-line-chart.streamlit.app/
           height: 440px

        You can also choose different columns to use for x and y, as well as set
        the color dynamically based on a 3rd column (assuming your dataframe is in
        long format):

        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>>
        >>> chart_data = pd.DataFrame(
        ...     {
        ...         "col1": np.random.randn(20),
        ...         "col2": np.random.randn(20),
        ...         "col3": np.random.choice(["A", "B", "C"], 20),
        ...     }
        ... )
        >>>
        >>> st.line_chart(chart_data, x="col1", y="col2", color="col3")

        .. output::
           https://doc-line-chart1.streamlit.app/
           height: 440px

        Finally, if your dataframe is in wide format, you can group multiple
        columns under the y argument to show multiple lines with different
        colors:

        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>>
        >>> chart_data = pd.DataFrame(
        ...     np.random.randn(20, 3), columns=["col1", "col2", "col3"]
        ... )
        >>>
        >>> st.line_chart(
        ...     chart_data,
        ...     x="col1",
        ...     y=["col2", "col3"],
        ...     color=["#FF0000", "#0000FF"],  # Optional
        ... )

        .. output::
           https://doc-line-chart2.streamlit.app/
           height: 440px

        N

chart_typerw   x_from_usery_from_userx_axis_labely_axis_labelcolor_from_usersize_from_userr   r   r&   	streamlitrr   themeadd_rows_metadata)r   r   LINEr   _altair_chart)rW   rw   r(   r)   r   r   r1   r   r   rr   chartr   s               rO   r   zVegaChartsMixin.line_chart2  sh    \ $2 ~~  !$
   $7!"3	  
 	
rN   
area_chart)	r(   r)   r   r   r1   stackr   r   rr   c       	            t        |dd       |du s|d}t        t        j                  ||||||d||	|      \  }}t	        d| j                  ||
d|	            S )
a  Display an area chart.

        This is syntax-sugar around ``st.altair_chart``. The main difference
        is this command uses the data's own column and indices to figure out
        the chart's Altair spec. As a result this is easier to use for many
        "just plot this" scenarios, while being less customizable.

        If ``st.area_chart`` does not guess the data specification
        correctly, try specifying your desired chart using ``st.altair_chart``.

        Parameters
        ----------
        data : Anything supported by st.dataframe
            Data to be plotted.

        x : str or None
            Column name or key associated to the x-axis data. If ``x`` is
            ``None`` (default), Streamlit uses the data index for the x-axis
            values.

        y : str, Sequence of str, or None
            Column name(s) or key(s) associated to the y-axis data. If this is
            ``None`` (default), Streamlit draws the data of all remaining
            columns as data series. If this is a ``Sequence`` of strings,
            Streamlit draws several series on the same chart by melting your
            wide-format table into a long-format table behind the scenes.

        x_label : str or None
            The label for the x-axis. If this is ``None`` (default), Streamlit
            will use the column name specified in ``x`` if available, or else
            no label will be displayed.

        y_label : str or None
            The label for the y-axis. If this is ``None`` (default), Streamlit
            will use the column name(s) specified in ``y`` if available, or
            else no label will be displayed.

        color : str, tuple, Sequence of str, Sequence of tuple, or None
            The color to use for different series in this chart.

            For an area chart with just 1 series, this can be:

            - None, to use the default color.
            - A hex string like "#ffaa00" or "#ffaa0088".
            - An RGB or RGBA tuple with the red, green, blue, and alpha
              components specified as ints from 0 to 255 or floats from 0.0 to
              1.0.

            For an area chart with multiple series, where the dataframe is in
            long format (that is, y is None or just one column), this can be:

            - None, to use the default colors.
            - The name of a column in the dataset. Data points will be grouped
              into series of the same color based on the value of this column.
              In addition, if the values in this column match one of the color
              formats above (hex string or color tuple), then that color will
              be used.

              For example: if the dataset has 1000 rows, but this column only
              contains the values "adult", "child", and "baby", then those 1000
              datapoints will be grouped into three series whose colors will be
              automatically selected from the default palette.

              But, if for the same 1000-row dataset, this column contained
              the values "#ffaa00", "#f0f", "#0000ff", then then those 1000
              datapoints would still be grouped into 3 series, but their
              colors would be "#ffaa00", "#f0f", "#0000ff" this time around.

            For an area chart with multiple series, where the dataframe is in
            wide format (that is, y is a Sequence of columns), this can be:

            - None, to use the default colors.
            - A list of string colors or color tuples to be used for each of
              the series in the chart. This list should have the same length
              as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
              for three lines).

        stack : bool, "normalize", "center", or None
            Whether to stack the areas. If this is ``None`` (default),
            Streamlit uses Vega's default. Other values can be as follows:

            - ``True``: The areas form a non-overlapping, additive stack within
              the chart.
            - ``False``: The areas overlap each other without stacking.
            - ``"normalize"``: The areas are stacked and the total height is
              normalized to 100% of the height of the chart.
            - ``"center"``: The areas are stacked and shifted to center their
              baseline, which creates a steamgraph.

        width : int or None
            Desired width of the chart expressed in pixels. If ``width`` is
            ``None`` (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 ``width`` is greater than the width of the
            parent container, Streamlit sets the chart width to match the width
            of the parent container.

            To use ``width``, you must set ``use_container_width=False``.

        height : int or None
            Desired height of the chart expressed in pixels. If ``height`` is
            ``None`` (default), Streamlit sets the height of the chart to fit
            its contents according to the plotting library.

        use_container_width : bool
            Whether to override ``width`` with the width of the parent
            container. If ``use_container_width`` is ``True`` (default),
            Streamlit sets the width of the chart to match the width of the
            parent container. If ``use_container_width`` is ``False``,
            Streamlit sets the chart's width according to ``width``.

        Examples
        --------
        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>>
        >>> chart_data = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"])
        >>>
        >>> st.area_chart(chart_data)

        .. output::
           https://doc-area-chart.streamlit.app/
           height: 440px

        You can also choose different columns to use for x and y, as well as set
        the color dynamically based on a 3rd column (assuming your dataframe is in
        long format):

        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>>
        >>> chart_data = pd.DataFrame(
        ...     {
        ...         "col1": np.random.randn(20),
        ...         "col2": np.random.randn(20),
        ...         "col3": np.random.choice(["A", "B", "C"], 20),
        ...     }
        ... )
        >>>
        >>> st.area_chart(chart_data, x="col1", y="col2", color="col3")

        .. output::
           https://doc-area-chart1.streamlit.app/
           height: 440px

        If your dataframe is in wide format, you can group multiple
        columns under the y argument to show multiple series with different
        colors:

        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>>
        >>> chart_data = pd.DataFrame(
        ...     np.random.randn(20, 3), columns=["col1", "col2", "col3"]
        ... )
        >>>
        >>> st.area_chart(
        ...     chart_data,
        ...     x="col1",
        ...     y=["col2", "col3"],
        ...     color=["#FF0000", "#0000FF"],  # Optional
        ... )

        .. output::
           https://doc-area-chart2.streamlit.app/
           height: 440px

        You can adjust the stacking behavior by setting ``stack``. Create a
        steamgraph:

        >>> import streamlit as st
        >>> from vega_datasets import data
        >>>
        >>> source = data.unemployment_across_industries()
        >>>
        >>> st.area_chart(source, x="date", y="count", color="series", stack="center")

        .. output::
           https://doc-area-chart-steamgraph.streamlit.app/
           height: 440px

        zst.area_chartzDhttps://docs.streamlit.io/develop/api-reference/charts/st.area_chartFNlayeredr   rw   r   r   r   r   r   r   r   r   r   r&   r   r   )r   r   r   AREAr   r   )rW   rw   r(   r)   r   r   r1   r   r   r   rr   r   r   s                rO   r   zVegaChartsMixin.area_chart  s    T 	"R	
 E>U]E#1 ~~  !$
   $7!"3	  
 	
rN   	bar_chartF)
r(   r)   r   r   r1   
horizontalr   r   r   rr   c       
           t        |dd       t        j                  d      r|du rt        d      |rt        j
                  nt        j                  }t        |||||||d|	|
|      \  }}t        d| j                  ||d	|
            S )ay!  Display a bar chart.

        This is syntax-sugar around ``st.altair_chart``. The main difference
        is this command uses the data's own column and indices to figure out
        the chart's Altair spec. As a result this is easier to use for many
        "just plot this" scenarios, while being less customizable.

        If ``st.bar_chart`` does not guess the data specification
        correctly, try specifying your desired chart using ``st.altair_chart``.

        Parameters
        ----------
        data : Anything supported by st.dataframe
            Data to be plotted.

        x : str or None
            Column name or key associated to the x-axis data. If ``x`` is
            ``None`` (default), Streamlit uses the data index for the x-axis
            values.

        y : str, Sequence of str, or None
            Column name(s) or key(s) associated to the y-axis data. If this is
            ``None`` (default), Streamlit draws the data of all remaining
            columns as data series. If this is a ``Sequence`` of strings,
            Streamlit draws several series on the same chart by melting your
            wide-format table into a long-format table behind the scenes.

        x_label : str or None
            The label for the x-axis. If this is ``None`` (default), Streamlit
            will use the column name specified in ``x`` if available, or else
            no label will be displayed.

        y_label : str or None
            The label for the y-axis. If this is ``None`` (default), Streamlit
            will use the column name(s) specified in ``y`` if available, or
            else no label will be displayed.

        color : str, tuple, Sequence of str, Sequence of tuple, or None
            The color to use for different series in this chart.

            For a bar chart with just one series, this can be:

            - None, to use the default color.
            - A hex string like "#ffaa00" or "#ffaa0088".
            - An RGB or RGBA tuple with the red, green, blue, and alpha
              components specified as ints from 0 to 255 or floats from 0.0 to
              1.0.

            For a bar chart with multiple series, where the dataframe is in
            long format (that is, y is None or just one column), this can be:

            - None, to use the default colors.
            - The name of a column in the dataset. Data points will be grouped
              into series of the same color based on the value of this column.
              In addition, if the values in this column match one of the color
              formats above (hex string or color tuple), then that color will
              be used.

              For example: if the dataset has 1000 rows, but this column only
              contains the values "adult", "child", and "baby", then those 1000
              datapoints will be grouped into three series whose colors will be
              automatically selected from the default palette.

              But, if for the same 1000-row dataset, this column contained
              the values "#ffaa00", "#f0f", "#0000ff", then then those 1000
              datapoints would still be grouped into 3 series, but their
              colors would be "#ffaa00", "#f0f", "#0000ff" this time around.

            For a bar chart with multiple series, where the dataframe is in
            wide format (that is, y is a Sequence of columns), this can be:

            - None, to use the default colors.
            - A list of string colors or color tuples to be used for each of
              the series in the chart. This list should have the same length
              as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
              for three lines).

        horizontal : bool
            Whether to make the bars horizontal. If this is ``False``
            (default), the bars display vertically. If this is ``True``,
            Streamlit swaps the x-axis and y-axis and the bars display
            horizontally.

        stack : bool, "normalize", "center", "layered", or None
            Whether to stack the bars. If this is ``None`` (default),
            Streamlit uses Vega's default. Other values can be as follows:

            - ``True``: The bars form a non-overlapping, additive stack within
              the chart.
            - ``False``: The bars display side by side.
            - ``"layered"``: The bars overlap each other without stacking.
            - ``"normalize"``: The bars are stacked and the total height is
              normalized to 100% of the height of the chart.
            - ``"center"``: The bars are stacked and shifted to center the
              total height around an axis.

        width : int or None
            Desired width of the chart expressed in pixels. If ``width`` is
            ``None`` (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 ``width`` is greater than the width of the
            parent container, Streamlit sets the chart width to match the width
            of the parent container.

            To use ``width``, you must set ``use_container_width=False``.

        height : int or None
            Desired height of the chart expressed in pixels. If ``height`` is
            ``None`` (default), Streamlit sets the height of the chart to fit
            its contents according to the plotting library.

        use_container_width : bool
            Whether to override ``width`` with the width of the parent
            container. If ``use_container_width`` is ``True`` (default),
            Streamlit sets the width of the chart to match the width of the
            parent container. If ``use_container_width`` is ``False``,
            Streamlit sets the chart's width according to ``width``.

        Examples
        --------
        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>>
        >>> chart_data = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"])
        >>>
        >>> st.bar_chart(chart_data)

        .. output::
           https://doc-bar-chart.streamlit.app/
           height: 440px

        You can also choose different columns to use for x and y, as well as set
        the color dynamically based on a 3rd column (assuming your dataframe is in
        long format):

        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>>
        >>> chart_data = pd.DataFrame(
        ...     {
        ...         "col1": list(range(20)) * 3,
        ...         "col2": np.random.randn(60),
        ...         "col3": ["A"] * 20 + ["B"] * 20 + ["C"] * 20,
        ...     }
        ... )
        >>>
        >>> st.bar_chart(chart_data, x="col1", y="col2", color="col3")

        .. output::
           https://doc-bar-chart1.streamlit.app/
           height: 440px

        If your dataframe is in wide format, you can group multiple
        columns under the y argument to show multiple series with different
        colors:

        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>>
        >>> chart_data = pd.DataFrame(
        ...     {
        ...         "col1": list(range(20)),
        ...         "col2": np.random.randn(20),
        ...         "col3": np.random.randn(20),
        ...     }
        ... )
        >>>
        >>> st.bar_chart(
        ...     chart_data,
        ...     x="col1",
        ...     y=["col2", "col3"],
        ...     color=["#FF0000", "#0000FF"],  # Optional
        ... )

        .. output::
           https://doc-bar-chart2.streamlit.app/
           height: 440px

        You can rotate your bar charts to display horizontally.

        >>> import streamlit as st
        >>> from vega_datasets import data
        >>>
        >>> source = data.barley()
        >>>
        >>> st.bar_chart(source, x="variety", y="yield", color="site", horizontal=True)

        .. output::
           https://doc-bar-chart-horizontal.streamlit.app/
           height: 440px

        You can unstack your bar charts.

        >>> import streamlit as st
        >>> from vega_datasets import data
        >>>
        >>> source = data.barley()
        >>>
        >>> st.bar_chart(source, x="year", y="yield", color="site", stack=False)

        .. output::
           https://doc-bar-chart-unstacked.streamlit.app/
           height: 440px

        zst.bar_chartzChttps://docs.streamlit.io/develop/api-reference/charts/st.bar_chart5.0.0FziStreamlit does not support non-stacked (grouped) bar charts with Altair 4.x. Please upgrade to Version 5.Nr   r&   r   r   )
r   r   is_altair_version_less_thanr   r   HORIZONTAL_BARVERTICAL_BARr   r   r   )rW   rw   r(   r)   r   r   r1   r   r   r   r   rr   bar_chart_typer   r   s                  rO   r   zVegaChartsMixin.bar_chart  s    D 	"Q	
 009eun';  )3I$$	8N8N 	 $2%  !$
   $7!"3	  
 	
rN   scatter_chart)	r(   r)   r   r   r1   r/   r   r   rr   c       	            t        t        j                  |||||||||	
      \  }}t        d| j	                  ||
d|            S )a[  Display a scatterplot chart.

        This is syntax-sugar around ``st.altair_chart``. The main difference
        is this command uses the data's own column and indices to figure out
        the chart's Altair spec. As a result this is easier to use for many
        "just plot this" scenarios, while being less customizable.

        If ``st.scatter_chart`` does not guess the data specification correctly,
        try specifying your desired chart using ``st.altair_chart``.

        Parameters
        ----------
        data : Anything supported by st.dataframe
            Data to be plotted.

        x : str or None
            Column name or key associated to the x-axis data. If ``x`` is
            ``None`` (default), Streamlit uses the data index for the x-axis
            values.

        y : str, Sequence of str, or None
            Column name(s) or key(s) associated to the y-axis data. If this is
            ``None`` (default), Streamlit draws the data of all remaining
            columns as data series. If this is a ``Sequence`` of strings,
            Streamlit draws several series on the same chart by melting your
            wide-format table into a long-format table behind the scenes.

        x_label : str or None
            The label for the x-axis. If this is ``None`` (default), Streamlit
            will use the column name specified in ``x`` if available, or else
            no label will be displayed.

        y_label : str or None
            The label for the y-axis. If this is ``None`` (default), Streamlit
            will use the column name(s) specified in ``y`` if available, or
            else no label will be displayed.

        color : str, tuple, Sequence of str, Sequence of tuple, or None
            The color of the circles representing each datapoint.

            This can be:

            - None, to use the default color.
            - A hex string like "#ffaa00" or "#ffaa0088".
            - An RGB or RGBA tuple with the red, green, blue, and alpha
              components specified as ints from 0 to 255 or floats from 0.0 to
              1.0.
            - The name of a column in the dataset where the color of that
              datapoint will come from.

              If the values in this column are in one of the color formats
              above (hex string or color tuple), then that color will be used.

              Otherwise, the color will be automatically picked from the
              default palette.

              For example: if the dataset has 1000 rows, but this column only
              contains the values "adult", "child", and "baby", then those 1000
              datapoints be shown using three colors from the default palette.

              But if this column only contains floats or ints, then those
              1000 datapoints will be shown using a colors from a continuous
              color gradient.

              Finally, if this column only contains the values "#ffaa00",
              "#f0f", "#0000ff", then then each of those 1000 datapoints will
              be assigned "#ffaa00", "#f0f", or "#0000ff" as appropriate.

            If the dataframe is in wide format (that is, y is a Sequence of
            columns), this can also be:

            - A list of string colors or color tuples to be used for each of
              the series in the chart. This list should have the same length
              as the number of y values (e.g. ``color=["#fd0", "#f0f", "#04f"]``
              for three series).

        size : str, float, int, or None
            The size of the circles representing each point.

            This can be:

            - A number like 100, to specify a single size to use for all
              datapoints.
            - The name of the column to use for the size. This allows each
              datapoint to be represented by a circle of a different size.

        width : int or None
            Desired width of the chart expressed in pixels. If ``width`` is
            ``None`` (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 ``width`` is greater than the width of the
            parent container, Streamlit sets the chart width to match the width
            of the parent container.

            To use ``width``, you must set ``use_container_width=False``.

        height : int or None
            Desired height of the chart expressed in pixels. If ``height`` is
            ``None`` (default), Streamlit sets the height of the chart to fit
            its contents according to the plotting library.

        use_container_width : bool
            Whether to override ``width`` with the width of the parent
            container. If ``use_container_width`` is ``True`` (default),
            Streamlit sets the width of the chart to match the width of the
            parent container. If ``use_container_width`` is ``False``,
            Streamlit sets the chart's width according to ``width``.

        Examples
        --------
        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>>
        >>> chart_data = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"])
        >>>
        >>> st.scatter_chart(chart_data)

        .. output::
           https://doc-scatter-chart.streamlit.app/
           height: 440px

        You can also choose different columns to use for x and y, as well as set
        the color dynamically based on a 3rd column (assuming your dataframe is in
        long format):

        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>>
        >>> chart_data = pd.DataFrame(
        ...     np.random.randn(20, 3), columns=["col1", "col2", "col3"]
        ... )
        >>> chart_data["col4"] = np.random.choice(["A", "B", "C"], 20)
        >>>
        >>> st.scatter_chart(
        ...     chart_data,
        ...     x="col1",
        ...     y="col2",
        ...     color="col4",
        ...     size="col3",
        ... )

        .. output::
           https://doc-scatter-chart1.streamlit.app/
           height: 440px

        Finally, if your dataframe is in wide format, you can group multiple
        columns under the y argument to show multiple series with different
        colors:

        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>>
        >>> chart_data = pd.DataFrame(
        ...     np.random.randn(20, 4), columns=["col1", "col2", "col3", "col4"]
        ... )
        >>>
        >>> st.scatter_chart(
        ...     chart_data,
        ...     x="col1",
        ...     y=["col2", "col3"],
        ...     size="col4",
        ...     color=["#FF0000", "#0000FF"],  # Optional
        ... )

        .. output::
           https://doc-scatter-chart2.streamlit.app/
           height: 440px

        r   r&   r   r   )r   r   SCATTERr   r   )rW   rw   r(   r)   r   r   r1   r/   r   r   rr   r   r   s                rO   r   zVegaChartsMixin.scatter_chart  sj    x $2 ((  !$
   $7!"3	  
 	
rN   r   )rr   r   r,   r   r   c                    y r   rM   rW   r   rr   r   r,   	on_selectr   s          rO   r   zVegaChartsMixin.altair_chart  s     rN   rerun)rr   r   r,   r   r   c                    y r   rM   r   s          rO   r   zVegaChartsMixin.altair_chart  s     rN   ignorec               0    | j                  ||||||      S )aZ  Display a chart using the Vega-Altair library.

        `Vega-Altair <https://altair-viz.github.io/>`_ is a declarative
        statistical visualization library for Python, based on Vega and
        Vega-Lite.

        Parameters
        ----------
        altair_chart : altair.Chart
            The Altair chart object to display. See
            https://altair-viz.github.io/gallery/ for examples of graph
            descriptions.

        use_container_width : bool or None
            Whether to override the chart's native width with the width of
            the parent container. This can be one of the following:

            - ``None`` (default): Streamlit will use the parent container's
              width for all charts except those with known incompatibility
              (``altair.Facet``, ``altair.HConcatChart``, and
              ``altair.RepeatChart``).
            - ``True``: Streamlit sets the width of the chart to match the
              width of the parent container.
            - ``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.

        theme : "streamlit" or None
            The theme of the chart. If ``theme`` is ``"streamlit"`` (default),
            Streamlit uses its own design default. If ``theme`` is ``None``,
            Streamlit falls back to the default behavior of the library.

        key : str
            An optional string to use for giving this element a stable
            identity. If ``key`` is ``None`` (default), this element's identity
            will be determined based on the values of the other parameters.

            Additionally, if selections are activated and ``key`` is provided,
            Streamlit will register the key in Session State to store the
            selection state. The selection state is read-only.

        on_select : "ignore", "rerun", or callable
            How the figure should respond to user selection events. This
            controls whether or not the figure behaves like an input widget.
            ``on_select`` can be one of the following:

            - ``"ignore"`` (default): Streamlit will not react to any selection
              events in the chart. The figure will not behave like an input
              widget.

            - ``"rerun"``: Streamlit will rerun the app when the user selects
              data in the chart. In this case, ``st.altair_chart`` will return
              the selection data as a dictionary.

            - A ``callable``: Streamlit will rerun the app and execute the
              ``callable`` as a callback function before the rest of the app.
              In this case, ``st.altair_chart`` will return the selection data
              as a dictionary.

            To use selection events, the object passed to ``altair_chart`` must
            include selection paramters. To learn about defining interactions
            in Altair and how to declare selection-type parameters, see
            `Interactive Charts             <https://altair-viz.github.io/user_guide/interactions.html>`_
            in Altair's documentation.

        selection_mode : str or Iterable of str
            The selection parameters Streamlit should use. If
            ``selection_mode`` is ``None`` (default), Streamlit will use all
            selection parameters defined in the chart's Altair spec.

            When Streamlit uses a selection parameter, selections from that
            parameter will trigger a rerun and be included in the selection
            state. When Streamlit does not use a selection parameter,
            selections from that parameter will not trigger a rerun and not be
            included in the selection state.

            Selection parameters are identified by their ``name`` property.

        Returns
        -------
        element or dict
            If ``on_select`` is ``"ignore"`` (default), this command returns an
            internal placeholder for the chart element that can be used with
            the ``.add_rows()`` method. Otherwise, this command returns a
            dictionary-like object that supports both key and attribute
            notation. The attributes are described by the ``VegaLiteState``
            dictionary schema.

        Example
        -------

        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>> import altair as alt
        >>>
        >>> chart_data = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"])
        >>>
        >>> c = (
        ...    alt.Chart(chart_data)
        ...    .mark_circle()
        ...    .encode(x="a", y="b", size="c", color="c", tooltip=["a", "b", "c"])
        ... )
        >>>
        >>> st.altair_chart(c)

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

        )r   rr   r   r,   r   r   )r   r   s          rO   r   zVegaChartsMixin.altair_chart  s/    v !!% 3) " 
 	
rN   c                    y r   rM   	rW   rw   rq   rr   r   r,   r   r   rs   s	            rO   vega_lite_chartzVegaChartsMixin.vega_lite_chartb  s     rN   c                    y r   rM   r   s	            rO   r  zVegaChartsMixin.vega_lite_chartq  s     rN   r  c               6     | j                   d|||||||d|S )a  Display a chart using the Vega-Lite library.

        `Vega-Lite <https://vega.github.io/vega-lite/>`_ is a high-level
        grammar for defining interactive graphics.

        Parameters
        ----------
        data : Anything supported by st.dataframe
            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 ``spec`` is ``None`` (default),
            Streamlit uses the spec passed in ``data``. You cannot pass a spec
            to both ``data`` and ``spec``. See
            https://vega.github.io/vega-lite/docs/ for more info.

        use_container_width : bool or None
            Whether to override the chart's native width with the width of
            the parent container. This can be one of the following:

            - ``None`` (default): Streamlit will use the parent container's
              width for all charts except those with known incompatibility
              (``altair.Facet``, ``altair.HConcatChart``, and
              ``altair.RepeatChart``).
            - ``True``: Streamlit sets the width of the chart to match the
              width of the parent container.
            - ``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.

        theme : "streamlit" or None
            The theme of the chart. If ``theme`` is ``"streamlit"`` (default),
            Streamlit uses its own design default. If ``theme`` is ``None``,
            Streamlit falls back to the default behavior of the library.

        key : str
            An optional string to use for giving this element a stable
            identity. If ``key`` is ``None`` (default), this element's identity
            will be determined based on the values of the other parameters.

            Additionally, if selections are activated and ``key`` is provided,
            Streamlit will register the key in Session State to store the
            selection state. The selection state is read-only.

        on_select : "ignore", "rerun", or callable
            How the figure should respond to user selection events. This
            controls whether or not the figure behaves like an input widget.
            ``on_select`` can be one of the following:

            - ``"ignore"`` (default): Streamlit will not react to any selection
              events in the chart. The figure will not behave like an input
              widget.

            - ``"rerun"``: Streamlit will rerun the app when the user selects
              data in the chart. In this case, ``st.vega_lite_chart`` will
              return the selection data as a dictionary.

            - A ``callable``: Streamlit will rerun the app and execute the
              ``callable`` as a callback function before the rest of the app.
              In this case, ``st.vega_lite_chart`` will return the selection data
              as a dictionary.

            To use selection events, the Vega-Lite spec defined in ``data`` or
            ``spec`` must include selection parameters from the the charting
            library. To learn about defining interactions in Vega-Lite, see
            `Dynamic Behaviors with Parameters             <https://vega.github.io/vega-lite/docs/parameter.html>`_
            in Vega-Lite's documentation.

        selection_mode : str or Iterable of str
            The selection parameters Streamlit should use. If
            ``selection_mode`` is ``None`` (default), Streamlit will use all
            selection parameters defined in the chart's Vega-Lite spec.

            When Streamlit uses a selection parameter, selections from that
            parameter will trigger a rerun and be included in the selection
            state. When Streamlit does not use a selection parameter,
            selections from that parameter will not trigger a rerun and not be
            included in the selection state.

            Selection parameters are identified by their ``name`` property.

        **kwargs : any
            The Vega-Lite spec for the chart as keywords. This is an alternative
            to ``spec``.

        Returns
        -------
        element or dict
            If ``on_select`` is ``"ignore"`` (default), this command returns an
            internal placeholder for the chart element that can be used with
            the ``.add_rows()`` method. Otherwise, this command returns a
            dictionary-like object that supports both key and attribute
            notation. The attributes are described by the ``VegaLiteState``
            dictionary schema.

        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: 450px

        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.

        )rw   rq   rr   r   r,   r   r   rM   )_vega_lite_chartr   s	            rO   r  zVegaChartsMixin.vega_lite_chart  s>    X %t$$ 	
 3)	
 	
 		
rN   c           
         t        j                  d      r|dk7  rt        d      t        |      }| j	                  d|||||||      S )zInternal method to enqueue a vega-lite chart element based on an Altair chart.

        See the `altair_chart` method docstring for more information.
        r   r   zStreamlit does not support selections with Altair 4.x. Please upgrade to Version 5. If you would like to use Altair 4.x with selections, please upvote this [Github issue](https://github.com/streamlit/streamlit/issues/8516).N)rw   rq   rr   r   r,   r   r   r   )r   r   r   r   r  )	rW   r   rr   r   r,   r   r   r   vega_lite_specs	            rO   r   zVegaChartsMixin._altair_chart  sh     009i8>S'[  ;<H$$ 3)/ % 	
 		
rN   c	                <   |dvrt        d| d      |dvrt        |      st        d| d      t        |      }|dk7  }
|
r8t        |      }t        | j                  ||rt        t        |      nddd	|
       t        |t              r|d}i |/dv xs dv xr t        fddD              }|xs
 dv xs dv  }t               }t        |fi |	t        ||       t        t        j                              |_        ||_        |xs d|_        |
rWt        j&                  |j                         }t)        |       t+        ||      }|j,                  j/                  |       t1        | j                        |_        t5               }t7        d||j2                  |j                   |j8                  j8                  |j:                  D cg c]  }|j<                   c}|||	      |_        tA        |      }tC        |j>                  t        |      r|nd|jD                  |jF                  |d      }| j                  jI                  d||       t        tJ        |jL                        S | j                  jI                  d||      S c c}w )zInternal method to enqueue a vega-lite chart element based on a vega-lite spec.

        See the `vega_lite_chart` method docstring for more information.
        )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   zYou have passed zH to `on_select`. But only 'ignore', 'rerun', or a callable is supported.r   NF)	on_changedefault_valuewrites_allowedenable_check_callback_rulesr2   r   c              3  ,   K   | ]  }|d    v   yw)r   NrM   )r   r(   rq   s     rO   r   z3VegaChartsMixin._vega_lite_chart.<locals>.<genexpr>z  s     S8R1d:..8Rs   )r-   r5   r2   r   repeatrc   arrow_vega_lite_chart)user_keyform_idr  vega_lite_datanamed_datasetsr   rr   r   string_value)on_change_handlerdeserializer
serializerctx
value_type)r   )'r   callabler   r   dgr   r    r}   rn   r   ArrowVegaLiteChartProtort   r   r   rU   r`   rq   rr   r   rV   r   r   r   extendr   r  r   r   rw   rv   r{   r   rR   r!   r]   rb   _enqueuerF   value)rW   rw   rq   rr   r   r,   r   r   r   rs   is_selection_activatedis_callbackis_facet_chartvega_lite_proto
final_specparsed_selection_modesr  r   serdewidget_states     `                 rO   r  z VegaChartsMixin._vega_lite_chart9  s   " ++'!% )! !  //8K'"9+ .7 7 
 Sk!*h!6! #9-K!=H$~y9d"$,7 dD!dlDD<D & %_ d" US8RSS 
 G)t"3Gx47G# 23&t-@KFK_dD9  9D9IJ.A+ %!O$8$89J'
3 &;:~%V"**112HI&5dgg&>O#$&C!@''//.33  /3388 =L<T<TU<T<TU$75"O  ''=>E*""/7	/B)".. ??)L GG'"3  
 |'9'9:: ww#/   
 	
3  Vs   Jc                    t        d|       S )zGet our DeltaGenerator.r&   )r   )rW   s    rO   r  zVegaChartsMixin.dg  s     $d++rN   r   )rw   r%   r(   rd   r)   str | Sequence[str] | Noner   rd   r   rd   r1    str | Color | list[Color] | Noner   
int | Noner   r*  rr   boolre   r&   )rw   r%   r(   rd   r)   r(  r   rd   r   rd   r1   r)  r   bool | ChartStackType | Noner   r*  r   r*  rr   r+  re   r&   )rw   r%   r(   rd   r)   r(  r   rd   r   rd   r1   r)  r   r+  r   r,  r   r*  r   r*  rr   r+  re   r&   )rw   r%   r(   rd   r)   r(  r   rd   r   rd   r1   r)  r/   zstr | float | int | Noner   r*  r   r*  rr   r+  re   r&   )r   rD   rr   bool | Noner   Literal['streamlit'] | Noner,   
Key | Noner   Literal['ignore']r   str | Iterable[str] | Nonere   r&   )r   rD   rr   r-  r   r.  r,   r/  r   !Literal['rerun'] | WidgetCallbackr   r1  re   rF   )r   rD   rr   r-  r   r.  r,   r/  r   +Literal['rerun', 'ignore'] | WidgetCallbackr   r1  re   DeltaGenerator | VegaLiteState)NN)rw   r%   rq   VegaLiteSpec | Nonerr   r-  r   r.  r,   r/  r   r0  r   r1  rs   r   re   r&   )rw   r%   rq   r5  rr   r-  r   r.  r,   r/  r   r2  r   r1  rs   r   re   rF   )rw   r%   rq   r5  rr   r-  r   r.  r,   r/  r   r3  r   r1  rs   r   re   r4  )Nr   Nr   NN)r   rD   rr   r-  r   r.  r,   r/  r   r3  r   r1  r   AddRowsMetadata | Nonere   r4  )NNNr   Nr   NN)rw   r%   rq   r5  rr   r-  r   r.  r,   r/  r   r3  r   r1  r   r6  rs   r   re   r4  )re   r&   )rH   rI   rJ   rK   r   r   r   r   r   r   r   r  r   r  propertyr  rM   rN   rO   r   r   )  s    L! A
 (,""26 !$(A
A
 	A

 &A
 A
 A
 0A
 A
 A
 "A
 
A
 "A
F L! n
 (,""26.2 !$(n
n
 	n

 &n
 n
 n
 0n
 ,n
 n
 n
 "n
 
n
 "n
` K  G
 (,""26 .2 !$(G
G
 	G

 &G
 G
 G
 0G
 G
 ,G
 G
 G
 "G
 
G
 !G
R O$ O
 (,""26)- !$(O
O
 	O

 &O
 O
 O
 0O
 'O
 O
 O
 "O
 
O
 %O
d 
 ,0-859	!	 )		
 +	 	 %	 3	 
	 	 
 ,0-87>59	!	 )		
 +	 	 5	 3	 
	 	 N#
 ,0-8AI59A
!A
 )	A

 +A
 A
 ?A
 3A
 
(A
 $A
H  $(
 ,0-859 "
 ) +  % 3  
   $(
 ,0-87>59 "
 ) +  5 3  
  %& $(T

 ,0-8AI59T
T
 "T

 )T
 +T
 T
 ?T
 3T
 T
 
(T
 'T
r ,0-8AI5948!
!!
 )!
 +	!

 !
 ?!
 3!
 2!
 
(!
J $(+/-8AI5948E
E
 "E
 )	E

 +E
 E
 ?E
 3E
 2E
 E
 
(E
N , ,rN   r   )rq   rC   rr   r+  re   rC   r   )r   r  rq   rC   rw   r%   re   None)r   rD   re   rC   )rq   rC   re   r8  )rq   rC   re   zset[str])rq   rC   r   r1  re   z	list[str])r   ra   r   ra   re   ra   )r   ra   re   ra   )TrK   
__future__r   r   rU   r   
contextlibr   dataclassesr   typingr   r   r   r	   r
   r   r   r   typing_extensionsr    streamlit.elements.lib.dicttoolselementslibro   r   r   r   +streamlit.elements.lib.built_in_chart_utilsr   r   r   r   r   "streamlit.elements.lib.event_utilsr   !streamlit.elements.lib.form_utilsr   streamlit.elements.lib.policiesr   streamlit.elements.lib.utilsr   r   r   streamlit.errorsr   &streamlit.proto.ArrowVegaLiteChart_pb2r   r  streamlit.runtime.metrics_utilr   7streamlit.runtime.scriptrunner_utils.script_run_contextr   streamlit.runtime.stater    r!   streamlit.utilr"   collections.abcr#   r$   r   r   streamlit.dataframe_utilr%   streamlit.delta_generatorr&   !streamlit.elements.lib.color_utilr'   rB   rL   rC   rD   rF   rR   rt   r   r   r   r   r   r   r   r   rM   rN   rO   <module>rP     s   X "   	 " !	 	 	 ( 4 4 /  C = A U U 2 : V C )2-87	5 : +i *Y p#IU p#f 8 8 88
 	D /O"/O
/O /O 
	/Od)))X
*"2"
2".2" 2"jB/dZ, Z,rN   