
    -Ph%3                         d dl Z d dlmZmZ d dlmZ d dlmZ d dlZd dl	m
Z  ej        d          Zd Zddddddddddi fd	ZdS )
    N)
exceptionsoptional_imports)utilspandasc                 
   t          |           }|dk    r|nd}|dk    rdn|}|	sd|z  }	|
sd|z  }
t          j                            ||d|	|
          }|d                             t          g           dd	d
ddg t          |dk    rdnd                     |d                             |           |dk    rd}d}nd}d}|d         D ]i}d|v sd|v r"d|d         |         d<   d|d         |         d<   ||v rd|d         |         d<   ||v r$d|d         |         d<   ddg|d         |         d<   j|dk    rddg|d         |dz            d<   |sddg}|sddg}t          |          D ]}t          t          | j        |         d                              D ](}t          j	        |d         |d         t          | j        |         d                    d!          }|dk    r*t          | j        |         d                    d"|z
           gndg}|dk    rdgn)t          | j        |         d                    d"|z
           g}t          j        ||t          |d"|z
           #          d |dk    rd$nd%|d&dd'                    |dz             d(                    |dz             )
  
        }|                    |           *t          t          | j        |         d*                             D ](}t          j	        |d         |d         t          | j        |         d*                   d!          }|dk    r*t          | j        |         d*                   d"|z
           gnd+g}|dk    rd+gn)t          | j        |         d*                   d"|z
           g}t          j        ||t          |d"|z
           #          d*|dk    rd$nd%|ddd'                    |dz             d(                    |dz             )
  
        }|                    |           *|dk    r| j        |         d,         nd+g}|dk    rd+gn| j        |         d,         }t          j        d7||d,|dk    rd$nd%d'                    |dz             d(                    |dz             d-|}|                    |           | j        |         d.         }d/| v r'd0                    | j        |         d/                   }nd1}d2                    |          |z   }t!          j        ||dk    r||z
  n|dz   ||dk    r|
n|	|dk    rd3nd4|dk    rd5ndd          }|d         d6xx         |fz  cc<   |S )8Nh   g      ?F)
print_gridhorizontal_spacingvertical_spacinglayout)shapeszBullet ChartiX  i  stackx   P   )l)titleheightwidth
showlegendbarmodeannotationsmarginyaxisxaxisshowgridzeroline	tickwidthshowticklabelsr   rangeg?g333333?1domainrgb(200, 200, 200)rgb(245, 245, 245)rgb(31, 119, 180)rgb(176, 196, 221)rangesrgb)colorxy   zx{}zy{})
r+   r,   markername	hoverinfoorientationr   baser   r   measuresg      ?markers)r+   r,   r/   r0   r   r   titles	subtitlesz<br>{} z	<b>{}</b>rowcolTr    )lenplotlysubplotsmake_subplotsupdatedictr    ilocclrsn_colorssortedgoBarformat	add_traceScatterr   annotation_dict_for_label)dfr4   r3   r'   r6   r5   r1   range_colorsmeasure_colorsr   r   scatter_optionslayout_optionsnum_of_lanesnum_of_rowsnum_of_colsfig
width_axislength_axiskeyr8   idxinter_colorsr+   r,   barr   subtitlelabelannots                                 ]/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/plotly/figure_factory/_bullet.py_bulletr^      s    r77L"-"4"4,,!K"c))!!|K 0 </ .-
/
'
'-) (  C MB[C//ccR888  	 	 	 M(((c

8} 1 1c>>W^^-2CM#z*-2CM#z*#./CM#{+38CM#/0+,a&CM#w' q58#JHj3&'1 D,.BC E-/CD\"" ]1 ]1RWS\(34455 	 	C=Qa#bgcl86L2M2Mu L
 #%% X.//S9::S  #%% RWS\(344R#X>? 
 &,rCx"8999!,!3!3##'ll37++ll37++  C MM# RWS\*56677 	 	C=q!q!BGCL,--	 L #%% Z011"s(;<<U  #%% RWS\*566rCx@A 
 &,rCx"8999!,!3!3##'ll37++ll37++  C MM# (3c'9'9BGCL##u C''SEERWS\)-D* 
(C//ccS,,sQw'',,sQw''
 
 
 
 	g X&"rws|K'@AAHHH""5))H4/#.##5#5\C37 +s 2 28J C''EEU3&&DDE
 
 	Hm$$$0$$$$J    r   )r#   r$   )r%   r&   c                    t           st          d          t          j        |           r.t	          d | D                       st          j        d          n.t          | t           j                  st          j        d          g d}t          j        |           rt                               rfd| D             ndgt          |           z  rfd| D             ndgt          |           z  rfd	| D             ng gt          |           z  rfd
| D             ng gt          |           z  rfd| D             ng gt          |           z  g|          }nt          | t           j                  rt                               r|          
                                ndgt          |           z  r|          
                                ndgt          |           z  r|          
                                ng gt          |           z  r|          
                                ng gt          |           z  r|          
                                ng gt          |           z  g|          }t           j                            |          }dD ]Q}t          ||                   D ]9\  }}	 t          j        |          }|s|g ||         |<   *# t          $ r Y 6w xY wR||fD ]Z}|rVt          |          dk    rt          j        d          t!          j        |           t!          j        |d          d         }[dddddi}|i k    r|                    |           n,|d         D ]#}||d         vr|d         |         |d         |<   $t)          |||||	|
||          }|S )a  
    **deprecated**, use instead the plotly.graph_objects trace
    :class:`plotly.graph_objects.Indicator`.

    :param (pd.DataFrame | list | tuple) data: either a list/tuple of
        dictionaries or a pandas DataFrame.
    :param (str) markers: the column name or dictionary key for the markers in
        each subplot.
    :param (str) measures: the column name or dictionary key for the measure
        bars in each subplot. This bar usually represents the quantitative
        measure of performance, usually a list of two values [a, b] and are
        the blue bars in the foreground of each subplot by default.
    :param (str) ranges: the column name or dictionary key for the qualitative
        ranges of performance, usually a 3-item list [bad, okay, good]. They
        correspond to the grey bars in the background of each chart.
    :param (str) subtitles: the column name or dictionary key for the subtitle
        of each subplot chart. The subplots are displayed right underneath
        each title.
    :param (str) titles: the column name or dictionary key for the main label
        of each subplot chart.
    :param (bool) orientation: if 'h', the bars are placed horizontally as
        rows. If 'v' the bars are placed vertically in the chart.
    :param (list) range_colors: a tuple of two colors between which all
        the rectangles for the range are drawn. These rectangles are meant to
        be qualitative indicators against which the marker and measure bars
        are compared.
        Default=('rgb(200, 200, 200)', 'rgb(245, 245, 245)')
    :param (list) measure_colors: a tuple of two colors which is used to color
        the thin quantitative bars in the bullet chart.
        Default=('rgb(31, 119, 180)', 'rgb(176, 196, 221)')
    :param (float) horizontal_spacing: see the 'horizontal_spacing' param in
        plotly.tools.make_subplots. Ranges between 0 and 1.
    :param (float) vertical_spacing: see the 'vertical_spacing' param in
        plotly.tools.make_subplots. Ranges between 0 and 1.
    :param (dict) scatter_options: describes attributes for the scatter trace
        in each subplot such as name and marker size. Call
        help(plotly.graph_objs.Scatter) for more information on valid params.
    :param layout_options: describes attributes for the layout of the figure
        such as title, height and width. Call help(plotly.graph_objs.Layout)
        for more information on valid params.

    Example 1: Use a Dictionary

    >>> import plotly.figure_factory as ff

    >>> data = [
    ...   {"label": "revenue", "sublabel": "us$, in thousands",
    ...    "range": [150, 225, 300], "performance": [220,270], "point": [250]},
    ...   {"label": "Profit", "sublabel": "%", "range": [20, 25, 30],
    ...    "performance": [21, 23], "point": [26]},
    ...   {"label": "Order Size", "sublabel":"US$, average","range": [350, 500, 600],
    ...    "performance": [100,320],"point": [550]},
    ...   {"label": "New Customers", "sublabel": "count", "range": [1400, 2000, 2500],
    ...    "performance": [1000, 1650],"point": [2100]},
    ...   {"label": "Satisfaction", "sublabel": "out of 5","range": [3.5, 4.25, 5],
    ...    "performance": [3.2, 4.7], "point": [4.4]}
    ... ]

    >>> fig = ff.create_bullet(
    ...     data, titles='label', subtitles='sublabel', markers='point',
    ...     measures='performance', ranges='range', orientation='h',
    ...     title='my simple bullet chart'
    ... )
    >>> fig.show()

    Example 2: Use a DataFrame with Custom Colors

    >>> import plotly.figure_factory as ff
    >>> import pandas as pd
    >>> data = pd.read_json('https://cdn.rawgit.com/plotly/datasets/master/BulletData.json')

    >>> fig = ff.create_bullet(
    ...     data, titles='title', markers='markers', measures='measures',
    ...     orientation='v', measure_colors=['rgb(14, 52, 75)', 'rgb(31, 141, 127)'],
    ...     scatter_options={'marker': {'symbol': 'circle'}}, width=700)
    >>> fig.show()
    z3'pandas' must be installed for this figure factory.c              3   @   K   | ]}t          |t                    V  d S )N)
isinstancer@   ).0items     r]   	<genexpr>z create_bullet.<locals>.<genexpr>  s,      ;;d:dD));;;;;;r_   zGEvery entry of the data argument list, tuple, etc must be a dictionary.z=You must input a pandas DataFrame, or a list of dictionaries.)r5   rZ   r4   r3   r'   c                      g | ]
}|         S r:   r:   )rc   dr5   s     r]   
<listcomp>z!create_bullet.<locals>.<listcomp>'      )))q6)))r_   r7   c                      g | ]
}|         S r:   r:   )rc   rg   r6   s     r]   rh   z!create_bullet.<locals>.<listcomp>(  s    ,,,!9,,,r_   c                      g | ]
}|         S r:   r:   )rc   rg   r4   s     r]   rh   z!create_bullet.<locals>.<listcomp>)  s    ***7***r_   c                      g | ]
}|         S r:   r:   )rc   rg   r3   s     r]   rh   z!create_bullet.<locals>.<listcomp>*  s    +++8+++r_   c                      g | ]
}|         S r:   r:   )rc   rg   r'   s     r]   rh   z!create_bullet.<locals>.<listcomp>+  ri   r_   )index)r'   r3   r4   Nr-   zKBoth 'range_colors' or 'measure_colors' must be a list of two valid colors.r(   r   r.      zdiamond-tallzrgb(0, 0, 0))sizesymbolr*   )pdImportErrorr   is_sequenceallr   PlotlyErrorrb   	DataFramer;   tolist	transpose	enumeratemathisnan	TypeErrorrB   validate_colorsconvert_colors_to_same_typer?   r^   )datar4   r3   r'   r6   r5   r1   rL   rM   r   r   rN   rO   	col_namesrK   
needed_keyrW   rr_is_nancolors_listdefault_scatterkrS   s    `````                 r]   create_bulletr      s   z  QOPPP 

;;d;;;;; 	(#  	 bl++ 
$K
 
 	

 HGGI 
\\-3I))))D))))"D		9I09O,,,,t,,,,tc$ii?O.5K****T****B4#d));K/7M++++d++++bTCII=M-3I))))D))))"D		9I   	
 	
 
D",	'	' 

\\)/EV##%%%bTCII5E,5KY&&(((B4#d));K*1GW$$&&&tc$ii7G+3IX%%'''"D		9I)/EV##%%%bTCII5E   	
 	
 
			#	#B 8  
:// 	 	FC:a== -qy*,BzN3'   	 %n5 R R 	R;1$$ ,+    ---:;NNqQK 	2.QQO "//// !* 	L 	LA111/>x/H/K)!,

 C  Js   #K++
K87K8)r{   r<   r   r   plotly.colorscolorsrB   plotly.figure_factoryr   plotly.graph_objs
graph_objsrE   
get_modulerr   r^   r   r:   r_   r]   <module>r      s     / / / / / / / /       ' ' ' ' ' '         **f f fV =>x x x x x xr_   