
    -e                        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 ddlmZ dZe G d	 d
e                      Z G d de          Z G d de          Z G d de          ZdS )z Axis labeling policies.     )annotationsN   )abstract)AnyRefDictIntString)Model)	AllLabelsCustomLabelingPolicyLabelingPolicy	NoOverlapc                  $     e Zd ZdZd fdZ xZS )r   z# Base class for labeling policies. returnNonec                :     t                      j        |i | d S Nsuper__init__selfargskwargs	__class__s      5lib/python3.11/site-packages/bokeh/models/labeling.pyr   zLabelingPolicy.__init__3   %    $)&)))))    r   r   __name__
__module____qualname____doc__r   __classcell__r   s   @r   r   r   .   sC        --* * * * * * * * * *r   r   c                  $     e Zd ZdZd fdZ xZS )r   z) Select all labels even if they overlap. r   r   c                :     t                      j        |i | d S r   r   r   s      r   r   zAllLabels.__init__;   r   r   r   r    r&   s   @r   r   r   7   sC        33* * * * * * * * * *r   r   c                  >     e Zd ZdZd fdZ edd          Z xZS )	r   z/ Basic labeling policy avoiding label overlap. r   r   c                :     t                      j        |i | d S r   r   r   s      r   r   zNoOverlap.__init__C   r   r      z4
    Minimum distance between labels in pixels.
    defaulthelpr   )r!   r"   r#   r$   r   r   min_distancer%   r&   s   @r   r   r   ?   sV        99* * * * * * 3q ( 	 	 	LLLLLr   r   c                  Z     e Zd ZdZd
 fdZ eeed          Z edd	          Z	 xZ
S )r   ap   Select labels based on a user-defined policy function.

    .. warning::
        The explicit purpose of this Bokeh Model is to embed *raw JavaScript
        code* for a browser to execute. If any part of the code is derived
        from untrusted user inputs, then you must take appropriate care to
        sanitize the user input prior to passing it to Bokeh.

    r   r   c                :     t                      j        |i | d S r   r   r   s      r   r   zCustomLabelingPolicy.__init__W   r   r   z
    A mapping of names to Python objects. In particular, those can be Bokeh's models.
    These objects are made available to the labeling policy's code snippet as the
    values of named parameters to the callback.
    )r.    a  
    A snippet of JavaScript code that selects a subset of labels for display.

    The following arguments a are available:

      * ``indices``, a set-like object containing label indices to filter
      * ``bboxes``, an array of bounding box objects per label
      * ``distance(i, j)``, a function computing distance (in axis dimensions)
          between labels. If labels i and j overlap, then ``distance(i, j) <= 0``.
      * the keys of ``args`` mapping, if any

    Example:

        Only display labels at even indices:

        .. code-block:: javascript

            code = '''
            for (const i of indices)
              if (i % 2 == 1)
                indices.unset(i)
            '''

        Alternatively, as a generator:

        .. code-block:: javascript

            code = '''
            for (const i of indices)
              if (i % 2 == 0)
                yield i
            '''

    r,   r   )r!   r"   r#   r$   r   r   r	   r   r   coder%   r&   s   @r   r   r   K   s{         * * * * * * 4 & 	 	 	D 6" !$ !	 !	 !	DDDDDr   r   )r$   
__future__r   logging	getLoggerr!   logcore.has_propsr   core.propertiesr   r   r   r	   modelr
   __all__r   r   r   r    r   r   <module>r=      se     
 # " " " " " g!! & % % % % %                  
* * * * *U * * 
** * * * * * * *		 		 		 		 		 		 		 		6	 6	 6	 6	 6	> 6	 6	 6	 6	 6	r   