
    ˀh                    b   U d dl mZ d dlZd dlmZmZmZ d dlmZ	 erd dl
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 d dlmZ d dlmZ e
j6                  dk\  rd dlmZ nd dlmZ e
j6                  dk\  rd dlmZ nd dlmZ eeeeeeef   Zde d<   e!e"ef   Z#de d<    G d d      Z$y)    )annotationsN)TYPE_CHECKINGCallableUnion)altair)ChannelColor)ChannelOrder)ChannelSize)ChannelTooltip)ChannelX)ChannelY)
EncodeKwds)	DataFrame)   
   )	TypeAlias)r      )Unpackr   Encoding	Encodingsc                      e Zd ZdZddZ	 	 	 d		 	 	 	 	 	 	 	 	 d
dZ	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 ddZeZddZ	y)DataFramePlotzDataFrame.plot namespace.c                8    t        j                  |      | _        y )N)altChart_chart)selfdfs     u/var/www/html/wine-match-dev/backend/winematch-backend/venv/lib/python3.12/site-packages/polars/dataframe/plotting.py__init__zDataFramePlot.__init__%   s    iim    Nc                   i }|||d<   |||d<   |||d<    | j                   j                  d      j                  di ||j                         S )a  
        Draw bar plot.

        Polars does not implement plotting logic itself but instead defers to
        `Altair <https://altair-viz.github.io/>`_.

        `df.plot.bar(**kwargs)` is shorthand for
        `alt.Chart(df).mark_bar().encode(**kwargs).interactive()`,
        and is provided for convenience - for full customisability, use a plotting
        library directly.

        .. versionchanged:: 1.6.0
            In prior versions of Polars, HvPlot was the plotting backend. If you would
            like to restore the previous plotting functionality, all you need to do
            is add `import hvplot.polars` at the top of your script and replace
            `df.plot` with `df.hvplot`.

        Parameters
        ----------
        x
            Column with x-coordinates of bars.
        y
            Column with y-coordinates of bars.
        color
            Column to color bars by.
        **kwargs
            Additional keyword arguments passed to Altair.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     {
        ...         "day": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] * 2,
        ...         "group": ["a"] * 7 + ["b"] * 7,
        ...         "value": [1, 3, 2, 4, 5, 6, 1, 1, 3, 2, 4, 5, 1, 2],
        ...     }
        ... )
        >>> df.plot.bar(
        ...     x="day", y="value", color="day", column="group"
        ... )  # doctest: +SKIP
        xycolorTtooltip )r   mark_barencodeinteractive)r   r#   r$   r%   kwargs	encodingss         r   barzDataFramePlot.bar(   su    b  "	=IcN=IcN!&IgDKK   .V++#)+[]	
r!   c                   i }|||d<   |||d<   |||d<   |||d<    | j                   j                  d      j                  di ||j                         S )a  
        Draw line plot.

        Polars does not implement plotting logic itself but instead defers to
        `Altair <https://altair-viz.github.io/>`_.

        `df.plot.line(**kwargs)` is shorthand for
        `alt.Chart(df).mark_line().encode(**kwargs).interactive()`,
        and is provided for convenience - for full customisatibility, use a plotting
        library directly.

        .. versionchanged:: 1.6.0
            In prior versions of Polars, HvPlot was the plotting backend. If you would
            like to restore the previous plotting functionality, all you need to do
            is add `import hvplot.polars` at the top of your script and replace
            `df.plot` with `df.hvplot`.

        Parameters
        ----------
        x
            Column with x-coordinates of lines.
        y
            Column with y-coordinates of lines.
        color
            Column to color lines by.
        order
            Column to use for order of data points in lines.
        **kwargs
            Additional keyword arguments passed to Altair.

        Examples
        --------
        >>> from datetime import date
        >>> df = pl.DataFrame(
        ...     {
        ...         "date": [date(2020, 1, 2), date(2020, 1, 3), date(2020, 1, 4)] * 2,
        ...         "price": [1, 4, 6, 1, 5, 2],
        ...         "stock": ["a", "a", "a", "b", "b", "b"],
        ...     }
        ... )
        >>> df.plot.line(x="date", y="price", color="stock")  # doctest: +SKIP
        r#   r$   r%   orderTr&   r(   )r   	mark_liner*   r+   )r   r#   r$   r%   r0   r,   r-   s          r   linezDataFramePlot.linef   s    f  "	=IcN=IcN!&Ig!&IgDKK!!$!/V++#)+[]	
r!   c                   i }|||d<   |||d<   |||d<   |||d<    | j                   j                  d      j                  di ||j                         S )a  
        Draw scatter plot.

        Polars does not implement plotting logic itself but instead defers to
        `Altair <https://altair-viz.github.io/>`_.

        `df.plot.point(**kwargs)` is shorthand for
        `alt.Chart(df).mark_point().encode(**kwargs).interactive()`,
        and is provided for convenience - for full customisatibility, use a plotting
        library directly.

        .. versionchanged:: 1.6.0
            In prior versions of Polars, HvPlot was the plotting backend. If you would
            like to restore the previous plotting functionality, all you need to do
            is add `import hvplot.polars` at the top of your script and replace
            `df.plot` with `df.hvplot`.

        Parameters
        ----------
        x
            Column with x-coordinates of points.
        y
            Column with y-coordinates of points.
        color
            Column to color points by.
        size
            Column which determines points' sizes.
        **kwargs
            Additional keyword arguments passed to Altair.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     {
        ...         "length": [1, 4, 6],
        ...         "width": [4, 5, 6],
        ...         "species": ["setosa", "setosa", "versicolor"],
        ...     }
        ... )
        >>> df.plot.point(x="length", y="width", color="species")  # doctest: +SKIP
        r#   r$   r%   sizeTr&   r(   )r   
mark_pointr*   r+   )r   r#   r$   r%   r4   r,   r-   s          r   pointzDataFramePlot.point   s    d  "	=IcN=IcN!&Ig $IfDKK""4"0V 
 []	
r!   c                   t        | j                  d| d       d| d}t        |      dt        j                        j
                  j                         D ch c]  }|j                   c}v }|rdfd}|S dfd}|S c c}w )Nmark_zAltair has no method 'mark_'r'   c                 R      d      j                   di | j                         S )NTr&   r(   r*   r+   r,   methods    r   funcz'DataFramePlot.__getattr__.<locals>.func   s'    2vd+22<V<HHJJr!   c                 N             j                   di | j                         S )Nr(   r;   r<   s    r   r>   z'DataFramePlot.__getattr__.<locals>.func   s"    &vx00<<>>r!   )r,   r   return	alt.Chart)getattrr   AttributeErrorinspect	signature
parametersvaluesname)r   attrmsgvalueaccepts_tooltip_argumentr>   r=   s         @r   __getattr__zDataFramePlot.__getattr__   s    dVnd;>/vQ7C %%#,$+$5$5f$=$H$H$O$O$Q1
 EJJ1
 $
  $K ? 1
s   B)r   r   r@   None)NNN)
r#   X | Noner$   Y | Noner%   Color | Noner,   Unpack[EncodeKwds]r@   rA   )NNNN)r#   rO   r$   rP   r%   rQ   r0   zOrder | Noner,   rR   r@   rA   )r#   rO   r$   rP   r%   rQ   r4   zSize | Noner,   rR   r@   rA   )rI   strr@   zCallable[..., alt.Chart])
__name__
__module____qualname____doc__r    r.   r2   r6   scatterrM   r(   r!   r   r   r   "   s   #$
 "	<
<
 <
 	<
 %<
 
<
@ ""@
@
 @
 	@

 @
 %@
 
@
H " B
B
 B
 	B

 B
 %B
 
B
J Gr!   r   )%
__future__r   rD   typingr   r   r   polars.dependenciesr   r   sysaltair.typingr   Colorr	   Orderr
   Sizer   Tooltipr   Xr   Yr   polarsr   version_infor   typing_extensionsr   r   __annotations__dictrS   r   r   r(   r!   r   <module>ri      s    "  1 1 -3317++( 
7"$/
7"!,1eUD' ABHiBX.Iy._ _r!   