
    -eV                    J   d Z ddlmZ ddlZ ej        e          ZddlmZ ddl	m
Z
mZmZmZmZmZ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mZmZmZmZm Z 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,Z,m-Z-m.Z.m/Z/ ddl0m1Z1 ddl2m3Z3m4Z4 ddl5m6Z6 ddl7m8Z8 ddl9m:Z:m;Z; ddl<m=Z= ddl>m?Z? ddl@mAZA ddlBmCZCmDZD ddlEmFZF ddlGmHZHmIZI dZJe G d deF                      ZK G d deK          ZL G d deK          ZM G d d e6          ZN G d! d"eF          ZO G d# d$eF          ZPdS )%z

    )annotationsN)Any   )AlignAlternationPolicyAnchorLegendClickPolicyLegendLocationLocationOrientation)abstract)AutoBoolDictEitherEnumFloatIncludeInstanceInstanceDefaultIntListNonNegativeNullableNullStringSpecOverridePositiveSeqStringTextLikeTuplevalue)Field)ScalarFillPropsScalarHatchPropsScalarLinePropsScalarTextProps)error)BAD_COLUMN_NAME2NON_MATCHING_DATA_SOURCES_ON_LEGEND_ITEM_RENDERERS)Model   )TickFormatter)LabelingPolicy	NoOverlap)ColorMapper)Range)GlyphRenderer)FixedTickerTicker   )
Annotation)DimensionalMetricLength)ColorBarContourColorBarLegend
LegendItemScaleBarc                  0    e Zd ZdZd6 fdZ e ee           ee	e	          dd          Z
 e ee          edd	          Z eeed
          Z eeed          Z e	dd          Z eed          Z eedd          Z ed          Z ed          Z edd          Z e ee          edd          Z e ee          edd          Z  e! ee	e"          ei d          Z# ee$ e%e&          d          Z' edd          Z( edd          Z) eed d!          Z* ed"          Z+ ed#d$          Z, ee-d%d&          Z. ed'          Z/ ed#d(          Z0 ed)d*          Z1 ee-d+d,          Z2 ed-          Z3 ed)d.          Z4 ed)d*          Z5 ee-d/d0          Z6 ed-          Z7 ee-d1d2          Z8 ed-          Z9 ee:d3d4          Z; ed'          Z< ed5          Z= xZ>S )7BaseColorBarz* Abstract base class for color bars.

    returnNonec                :     t                      j        |i | d S Nsuper__init__selfargskwargs	__class__s      @lib/python3.11/site-packages/bokeh/models/annotations/legends.pyrF   zBaseColorBar.__init__f   %    $)&)))))    	top_righta  
    The location where the color bar should draw itself. It's either one of
    ``bokeh.core.enums.Anchor``'s enumerated values, or a ``(x, y)``
    tuple indicating an absolute location absolute location in screen
    coordinates (pixels from the bottom-left corner).

    .. warning::
        If the color bar is placed in a side panel, the location will likely
        have to be set to `(0,0)`.
    defaulthelpautozN
    Whether the color bar should be oriented vertically or horizontally.
    zD
    The height (in pixels) that the color scale should occupy.
    rR   zC
    The width (in pixels) that the color scale should occupy.
    g      ?z9
    The alpha with which to render the color scale.
    #
    The title text to render.
    title/
    The {prop} values for the title text.
    prefixrR   13pxrQ   italicr,   zL
    The distance (in pixels) to separate the title from the color bar.
    zE
    A Ticker to use for computing locations of axis components.
    zS
    A ``TickFormatter`` to use for formatting the visual appearance of ticks.
    zm
    Provide explicit tick label values for specific tick locations that
    override normal formatting.
    zN
    Allows to filter out labels, e.g. declutter labels to avoid overlap.
       zK
    Amount of margin (in pixels) around the outside of the color bar.
    
   zU
    Amount of padding (in pixels) between the color scale and color bar border.
    major_labelz.
    The {prop} of the major tick labels.
    11px   zR
    The distance (in pixels) to separate the tick labels from the color bar.
    
major_tickz(
    The {prop} of the major ticks.
    #ffffffz^
    The distance (in pixels) that major ticks should extend into the
    main plot area.
    r   z`
    The distance (in pixels) that major ticks should extend out of the
    main plot area.
    
minor_tickz(
    The {prop} of the minor ticks.
    Nz^
    The distance (in pixels) that minor ticks should extend into the
    main plot area.
    barz5
    The {prop} for the color scale bar outline.
    borderz6
    The {prop} for the color bar border outline.
    
backgroundz8
    The {prop} for the color bar background style.
    ffffff?r@   rA   )?__name__
__module____qualname____doc__rF   r   r   r   r!   r   locationr   r   orientationr   heightwidthscale_alphar   r    rV   r   r'   title_propsr   title_text_font_sizetitle_text_font_styletitle_standoffr   r4   tickerr-   	formatterr   r   major_label_overridesr.   r   r/   major_label_policymarginpaddingmajor_label_propsmajor_label_text_font_sizelabel_standoffr&   major_tick_propsmajor_tick_line_colormajor_tick_inmajor_tick_outminor_tick_propsminor_tick_line_colorminor_tick_inminor_tick_out	bar_propsbar_line_colorborder_propsborder_line_colorr$   background_propsbackground_fill_colorbackground_fill_alpha__classcell__rK   s   @rL   r?   r?   _   st        
* * * * * * vdd6llEE%$7$7 	T 		 		 		H &k**D& H 	 	 	K VD# % 	 	 	F F4 $ 	 	 	E % # 	 	 	K HX % 	 	 	E '/' A 	 	 	K $8F333$HX666S " 	 	 	N VHHV$$dF B 	 	 	F xx..f L 	 	 	I !Dv!6!6" T 	 	 	
 ".//):T:T \ 	 	 	 S  	 	 	F c"  	 	 	G   M 	 	 	 "*&!9!9!9S " 	 	 	N w| K 	 	 	 %HY777C ) 	 	 	M
 S * 	 	 	N
 w| K 	 	 	 %HT222C ) 	 	 	M
 S * 	 	 	N
  = 	 	 	I Xd+++N7?8 C 	 	 	L !...w| K 	 	 	 %HY777$HT222rN   r?   c                  r     e Zd ZdZd	 fdZ eed          Z ee	d          Z
 ee	d          Z xZS )
r9   z Render a color bar based on a color mapper.

    See :ref:`ug_basic_annotations_color_bars` for information on plotting color bars.

    r@   rA   c                :     t                      j        |i | d S rC   rD   rG   s      rL   rF   zColorBar.__init__   rM   rN   a  
    A color mapper containing a color palette to render.

    .. warning::
        If the `low` and `high` attributes of the ``ColorMapper`` aren't set, ticks
        and tick labels won't be rendered. Additionally, if a ``LogTicker`` is
        passed to the `ticker` argument and either or both of the logarithms
        of `low` and `high` values of the color_mapper are non-numeric
        (i.e. `low=0`), the tick and tick labels won't be rendered.
    rT   zx
    The lowest value to display in the color bar. The whole of the color entry
    containing this value is shown.
    zy
    The highest value to display in the color bar. The whole of the color entry
    containing this value is shown.
    ri   )rj   rk   rl   rm   rF   r   r0   color_mapperr   r   display_lowdisplay_highr   r   s   @rL   r9   r9      s         * * * * * * 8K 	/ 		 		 		L (5 ( 	 	 	K
 8E ) 	 	 	LLLLLrN   r9   c                  t     e Zd ZdZd
 fdZ eed          Z eed          Z e	e
g d	          Z xZS )r:   z Color bar used for contours.

    Supports displaying hatch patterns and line styles that contour plots may
    have as well as the usual fill styles.

    Do not create these objects manually, instead use ``ContourRenderer.color_bar``.

    r@   rA   c                :     t                      j        |i | d S rC   rD   rG   s      rL   rF   zContourColorBar.__init__  rM   rN   z:
    Glyph renderer used for filled contour polygons.
    rT   z0
    Glyph renderer used for contour lines.
    z6
    Levels at which the contours are calculated.
    rP   ri   )rj   rk   rl   rm   rF   r   r2   fill_rendererline_rendererr   r   levelsr   r   s   @rL   r:   r:     s         * * * * * * H] 2 	 	 	M H] 2 	 	 	M S * 	 	 	FFFFFrN   r:   c                       e Zd ZdZd fdZ ed          Z e ee	          d          Z
 eed          Z ed	d
          Z ee          d             Z ee          d             Z xZS )r<   z

    r@   rA   c                     t                      j        |i | t          | j        t                    rt          | j                  | _        d S d S rC   )rE   rF   
isinstancelabelstrr"   rG   s      rL   rF   zLegendItem.__init__*  sR    $)&)))dj#&& 	+tz**DJJJ	+ 	+rN   z
    A label for this legend. Can be a string, or a column of a
    ColumnDataSource. If ``label`` is a field, then it must
    be in the renderers' data_source.
    rT   z
    A list of the glyph renderers to draw in the legend. If ``label`` is a field,
    then all data_sources of renderers must be the same.
    a  
    The column data index to use for drawing the representative items.

    If None (the default), then Bokeh will automatically choose an index to
    use. If the label does not refer to a data column name, this is typically
    the first data point in the data source. Otherwise, if the label does
    refer to a column name, the legend will have "groupby" behavior, and will
    choose and display representative points from every "group" in the column.

    If set to a number, Bokeh will use that number as the index in all cases.
    Tz
    Whether the legend item should be displayed. See
    :ref:`ug_basic_annotations_legends_item_visibility` in the user guide.
    rP   c                    t          | j        t                    r1t          d | j        D                       dk    rt          |           S d S d S )Nc                    h | ]	}|j         
S  )data_source).0rs     rL   	<setcomp>z>LegendItem._check_data_sources_on_renderers.<locals>.<setcomp>O  s    :::aAM:::rN   r5   )r   r   r#   len	renderersr   )rH   s    rL    _check_data_sources_on_renderersz+LegendItem._check_data_sources_on_renderersL  sV    dj%(( 	!::4>:::;;q@@4yy 	! 	!@@rN   c                    t          | j        t                    r[t          | j                  dk     rt          |           S | j        d         j        }| j        j        |j        vrt          |           S d S d S )Nr5   r   )	r   r   r#   r   r   r   r   fieldcolumn_names)rH   sources     rL   !_check_field_label_on_data_sourcez,LegendItem._check_field_label_on_data_sourceR  sw    dj%(( 	!4>""Q&&4yy ^A&2Fzv':::4yy 	! 	! ;:rN   ri   )rj   rk   rl   rm   rF   r   r   r   r   r2   r   r   r   indexr   visibler(   r*   r   r)   r   r   r   s   @rL   r<   r<   &  s        + + + + + + N ! 	 	 	E XXm,, 4 	 	 	I
 HS 
  
	 
	 
	E d4 ' 	 	 	G
 U=>>! ! ?>!
 U?! ! ! ! ! ! !rN   r<   c                      e Zd ZdZd< fdZ e ee           ee	e	          dd          Z
 eedd	          Z e ee          ed
d          Z e ee          ed
d          Z eed          Z eedd          Z ed          Z ed          Z eedd          Z edd          Z eedd          Z ed          Z  ed          Z! ee"dd          Z# ee"dd           Z$ ee"d!d"          Z% ee&d#d$          Z' ee(d#d%          Z) ed&          Z* ed'          Z+ ed(          Z, ed)          Z- ed*          Z. ed+          Z/ eed,d-          Z0 ed.          Z1 ed          Z2 edd/          Z3 ed0d1          Z4 ed0d2          Z5 ed0d3          Z6 ed0d4          Z7 ed5d6          Z8 ed5d7          Z9 ed8d9          Z: e; e<e=          d:          >                     e; ee e; e<e?                                        d;           Z@ xZAS )=r;   z Render informational legends for a plot.

    See :ref:`ug_basic_annotations_legends` for information on plotting legends.

    r@   rA   c                :     t                      j        |i | d S rC   rD   rG   s      rL   rF   zLegend.__init__c  rM   rN   rO   a  
    The location where the legend should draw itself. It's either one of
    :class:`~bokeh.core.enums.LegendLocation`'s enumerated values, or a ``(x, y)``
    tuple indicating an absolute location absolute location in screen
    coordinates (pixels from the bottom-left corner).
    rP   verticalzi
    Whether the legend entries should be placed vertically or horizontally
    when they are drawn.
    rS   z
    The number of columns in the legend's layout. By default it's either
    one column if the orientation is vertical or the number of items in
    the legend otherwise. ``ncols`` takes precendence over ``nrows`` for
    horizonal orientation.
    z
    The number of rows in the legend's layout. By default it's either
    one row if the orientation is horizonal or the number of items in
    the legend otherwise. ``nrows`` takes precendence over ``ncols``
    for vertical orientation.
    rU   rT   rV   rW   rX   rZ   r[   r\   abovez
    Specifies on which side of the legend the title will be located.
    Titles on the left or right side will be rotated accordingly.
    ra   zI
    The distance (in pixels) to separate the title from the legend.
    rf   z3
    The {prop} for the legend border outline.
    #e5e5e5      ?rg   z5
    The {prop} for the legend background style.
    item_backgroundz<
    The {prop} for the legend items' background style.
    inactivez
    The {prop} for the legend item style when inactive. These control an overlay
    on the item that can be used to obscure it when the corresponding glyph
    is inactive (e.g. by making it semi-transparent).
    nonez@
    Defines what happens when a lengend's item is clicked.
    zR
    Defines which items to style, if ``item_background_fill`` is configured.
    rc   rh   z#f1f1f1g?whitegffffff?r   z+
    The {prop} for the legend labels.
    middlezS
    The distance (in pixels) to separate the label from its associated glyph.
       zV
    The minimum height (in pixels) of the area that legend labels should occupy.
    zU
    The minimum width (in pixels) of the area that legend labels should occupy.
    zN
    The height (in pixels) that the rendered legend glyph should occupy.
    zM
    The width (in pixels) that the rendered legend glyph should occupy.
    r^   z-
    Amount of margin around the legend.
    z
    Amount of padding around the contents of the legend. Only applicable when
    border is visible, otherwise collapses to 0.
    r   z?
    Amount of spacing (in pixels) between legend entries.
    a  
    A list of :class:`~bokeh.model.annotations.LegendItem` instances to be
    rendered in the legend.

    This can be specified explicitly, for instance:

    .. code-block:: python

        legend = Legend(items=[
            LegendItem(label="sin(x)",   renderers=[r0, r1]),
            LegendItem(label="2*sin(x)", renderers=[r2]),
            LegendItem(label="3*sin(x)", renderers=[r3, r4])
        ])

    But as a convenience, can also be given more compactly as a list of tuples:

    .. code-block:: python

        legend = Legend(items=[
            ("sin(x)",   [r0, r1]),
            ("2*sin(x)", [r2]),
            ("3*sin(x)", [r3, r4])
        ])

    where each tuple is of the form: *(label, renderers)*.

    c                    d | D             S )Nc                H    g | ]}t          |d          |d                    S )r   r5   )r   r   )r<   )r   items     rL   
<listcomp>z#Legend.<lambda>.<locals>.<listcomp>  s-    VVVzQ47CCCVVVrN   r   )itemss    rL   <lambda>zLegend.<lambda>  s    VVPUVVV rN   ri   )Brj   rk   rl   rm   rF   r   r   r
   r!   r   rn   r   ro   r   r   r   ncolsnrowsr   r   rV   r   r'   rs   r   rt   ru   r   title_locationrv   r&   r   r   border_line_alphar$   r   item_background_propsinactive_propsr	   click_policyr   item_background_policyr   r   item_background_fill_coloritem_background_fill_alphainactive_fill_colorinactive_fill_alphalabel_propslabel_text_baselinelabel_text_font_sizer   label_heightlabel_widthglyph_heightglyph_widthr{   r|   spacingr   r   r<   acceptsr2   r   r   r   s   @rL   r;   r;   [  s        * * * * * * vdd>**EE%,?,? \ 	 	 	H ${J > 	 	 	K
 F88C==$ > 	 	 	E F88C==$ > 	 	 	E HV # 	 	 	E '/' A 	 	 	K $8F333$HX666T(G ; 	 	 	N
 S " 	 	 	N 7?8 C 	 	 	L !333 ---w| K 	 	 	 $GO<M U 	 	 	 W_Z G 	 	 	N 4)6 A 	 	 	L "T"3V K 	 	 	 %HY777$HT222!))!<!<!<!)#!6!6!6"(7333"(3///'/' A 	 	 	K #(8444#8F333S " 	 	 	N 3r ! 	 	 	L #b   	 	 	K 3r ! 	 	 	L #b   	 	 	K S  	 	 	F c"  	 	 	G
 c!  	 	 	G D*%% - 	 	 	4 
eeFDD-)@)@$A$ABBCCVV
X 
X5 
EEEErN   r;   c                      e Zd ZdZd@ fdZ e ee          edd	
          Z	 e
dd
          Z ee ee          d
          Z eed          Z eedd
          Z eddd          Z  e eee                    dd
          Z eedd          Z edd
          Z edd
          Z e
dd
          Z ee dd           Z! ee"d!d"
          Z# ee$d#d$
          Z% ed%d&
          Z& e
d'd(
          Z' ee d)d*          Z( ee"d!d+
          Z) ee$d,d-
          Z* ed%d.
          Z+ ee, ee-g /          d0
          Z. eed1d2          Z/ ee0d3d4          Z1 ee2d3d5          Z3 e4d67          Z5 e4d87          Z6 e4d97          Z7 e4d:7          Z8 e4d;7          Z9 e4d<7          Z: e4d=7          Z; e4d>7          Z< e4d=7          Z= e4d?7          Z> xZ?S )Ar=   z( Represents a scale bar annotation.
    rI   r   rJ   r@   rA   c                :     t                      j        |i | d S rC   rD   rG   s      rL   rF   zScaleBar.__init__
  rM   rN   rS   z
    The range for which to display the scale.

    This can be either a range reference or ``"auto"``, in which case the
    scale bar will pick the default x or y range of the frame, depending
    on the orientation of the scale bar.
    rP   mz-
    The unit of the ``range`` property.
    z+
    Defines the units of measurement.
    zN
    Whether the scale bar should be oriented horizontally or vertically.
    rT   rO   z4
    Location anchor for positioning scale bar.
    adaptiveexacta]  
    Defines how the length of the bar is interpreted.

    This can either be:
    * ``"adaptive"`` - the computed length is fit into a set of ticks provided
        be the dimensional model. If no ticks are provided, then the behavior
        is the same as if ``"exact"`` sizing was used
    * ``"exact"`` - the computed length is used as-is
    g?zV
    The length of the bar, either a fraction of the frame or a number of pixels.
    re   z3
    The {prop} values for the bar line style.
    rX   r^   zK
    Amount of margin (in pixels) around the outside of the scale bar.
    za
    Amount of padding (in pixels) between the contents of the scale bar
    and its border.
    z@{value} @{unit}aV  
    The label template.

    This can use special variables:
    * ``@{value}`` The current value. Optionally can provide a number
        formatter with e.g. ``@{value}{%.2f}``.
    * ``@{unit}`` The unit of measure, by default in the short form.
        Optionally can provide a format ``@{unit}{short}`` or
        ``@{unit}{long}``.
    r   z5
    The {prop} values for the label text style.
    centerz
    Specifies where to align scale bar's label along the bar.

    This property effective when placing the label above or below
    a horizontal scale bar, or left or right of a vertical one.
    belowzM
    Specifies on which side of the scale bar the label will be located.
    ra   zL
    The distance (in pixels) to separate the label from the scale bar.
     rU   rV   z5
    The {prop} values for the title text style.
    z
    Specifies where to align scale bar's title along the bar.

    This property effective when placing the title above or below
    a horizontal scale bar, or left or right of a vertical one.
    r   zJ
    Specifies on which side of the legend the title will be located.
    zL
    The distance (in pixels) to separate the title from the scale bar.
    )ticksz
    A ticker to use for computing locations of axis components.

    Note that if using the default fixed ticker with no predefined ticks,
    then the appearance of the scale bar will be just a solid bar with
    no additional markings.
    rf   z9
    The {prop} for the scale bar border line style.
    rg   z=
    The {prop} for the scale bar background fill style.
    z>
    The {prop} for the scale bar background hatch style.
    r,   r[   r   r   r5   rc   rh   rZ   r   r\   )rI   r   rJ   r   r@   rA   )@rj   rk   rl   rm   rF   r   r   r1   r   ranger   unitr7   r   r8   dimensionalr   r   ro   r   rn   length_sizingr   r   r   
bar_lengthr   r&   bar_liner{   r|   r   r'   
label_textr   label_alignr   label_locationr   rV   
title_texttitle_alignr   rv   r4   r3   rw   border_liner$   background_fillr%   background_hatchr   bar_line_widthr   r   border_line_widthr   r   r   r   rt   ru   r   r   s   @rL   r=   r=     sI        * * * * * * F88E??D& @ 	 	 	E 6# % 	 	 	D (;0M0M U 	 	 	K ${ * 	 	 	K tFK 7 	 	 	H DW 4 	 	 	M 1VVE3//00 D 	 	 	J wu < 	 	 	H S # 	 	 	F c" $ 	 	 	G
 F- 	5 		 		 		E  @ 	 	 	J $uh 6 	 	 	K T(G ; 	 	 	N S * 	 	 	N F2 % 	 	 	E  @ 	 	 	J $uh 6 	 	 	K T(G ; 	 	 	N S * 	 	 	N Xfook&L&L&L T 	 	 	F '/( B 	 	 	K gol J 	 	 	O w/ L 	 	 	 Xa(((N 333 --- +++$HY777$HT222#8F333"(8444#8F333$HX666rN   r=   )Qrm   
__future__r   logging	getLoggerrj   logtypingr   
core.enumsr   r   r   r	   r
   r   r   core.has_propsr   core.propertiesr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   core.property.vectorizationr#   core.property_mixinsr$   r%   r&   r'   core.validationr(   core.validation.errorsr)   r*   modelr+   
formattersr-   labelingr.   r/   mappersr0   rangesr1   r   r2   tickersr3   r4   
annotationr6   r   r7   r8   __all__r?   r9   r:   r<   r;   r=   r   rN   rL   <module>r     s    # " " " " " g!!                        ' & & & & &                                             . 1 0 0 0 0 0            % $ $ $ $ $ i i i i i i i i       & & & & & & 0 0 0 0 0 0 0 0 ! ! ! ! ! !       % % % % % % ) ) ) ) ) ) ) ) " " " " " " 2 2 2 2 2 2 2 2 
I3 I3 I3 I3 I3: I3 I3 
I3X	 	 	 	 	| 	 	 	@	 	 	 	 	l 	 	 	43! 3! 3! 3! 3! 3! 3! 3!jhX hX hX hX hXZ hX hX hXTM7 M7 M7 M7 M7z M7 M7 M7 M7 M7rN   