
    6Dhч                         S SK Jr  S SKrS SKJrJr  S SKJr  S SK	J
r
  S SKJr  \R                  " S5      r/ SQrS rS r      SS	 jr     SS
 jr     SS jr               SS jrg)    )NumberN)
exceptionsoptional_imports)utilspandas)TaskStartFinishc                     XX /XX3/4$ )z
Returns the corner points of a scatter rectangle

:param x0: x-start
:param y0: y-lower
:param x1: x-end
:param y1: y-upper
:return: ([x], [y]), tuple of lists containing the x and y values
 )x0y0x1y1s       N/var/www/html/env/lib/python3.13/site-packages/plotly/figure_factory/_gantt.py_get_corner_pointsr      s     Rrr.//    c                    [         (       a  [        U [         R                  R                  R                  5      (       a  [
         H@  nX;  d  M
  [        R                  " SR                  SR                  [
        5      5      5      e   [        U R                  5      n/ n[        U5       H3  n0 nU  H  nU R                  U   U   XQ'   M     UR                  U5        M5     U$ [        U [        5      (       d  [        R                  " S5      e[        U 5      S::  a  [        R                  " S5      e[        U S   [         5      (       d  [        R                  " S5      eU $ )z*
Validates the inputted dataframe or list
zBThe columns in your dataframe must include the following keys: {0}z, z<You must input either a dataframe or a list of dictionaries.r   z<Your list is empty. It must contain at least one dictionary.z)Your list must only include dictionaries.)pd
isinstancecoreframe	DataFrameREQUIRED_GANTT_KEYSr   PlotlyErrorformatjoinlenindexrangeilocappendlistdict)dfkeynum_of_rowschartr   	task_dicts         r   validate_ganttr*      s)    
rjRWW]]4455&C} ,,**0&;N1O*P  ' "((m;'EI!#!4	 LL#	 (  b$$$M
 	

 2w!|$$M
 	
 beT""$$%STTIr   c                    Uc  / nU	c  / n	U
c  / n
[        [        U 5      5       H@  n[        X   S   X   S   X   S   S9nSX   ;   a
  X   S   US'   UR                  U5        MB     [        5       n[        5       nU(       a  SnOS	n/ / S
SUS.n/ / S/ [        SSSS9SSS.n[        [        U5      5       H*  nX   S   nU(       a  UU	;  d  M  U	R                  U5        M,     U(       a  U	R	                  5         Sn[        [        U5      5       GHB  nX   S   nX   S	 UnU(       a  U	R                  U5      nUU-
  X   S'   UU-   X   S'   U[        U5      :  a  SnUU   X   S'   X   S   nUU;  a  [        R                  " U5      UU'   UUU   S'   [        U5      UU   S'   UUU   S'   [        UU   S   5      S:  a7  UU   S   R                  UU   S   S   5        UU   S   R                  S5        [        X   S   X   S   X   S   X   S   5      u  nnUU   S==   U-  ss'   UU   S==   U-  ss'   UU;  a,  [        R                  " U5      UU'   UUU   S   S'   UUU   S'   UU   S   R                  X   S   5        UU   S   R                  X   S   5        UU   S   R                  U5        UU   S   R                  U5        SX   ;   a>  UU   S   R                  X   S   5        UU   S   R                  X   S   5        X   S	 O.UU   S   R                  S5        UU   S   R                  S5        US-  nGME     Un[        UUUU/ S [        UU	[        [        [        U	5      5      5      S[        U	5      S-   /SSS!9[        US[        [        [        S"S#S$S%S&9[        SS'S(S%S&9[        S)S*S(S%S&9[        SS+S,S-S&9[        SS.S,S%S&9[        S/S09/5      S19S2S39S49n[        U5       Vs/ s H  nUU   PM
     n
nU
[        U5       Vs/ s H  nUU   PM
     sn-  n
[        R                  " U
US59nU$ s  snf s  snf )6z'
Refer to create_gantt() for docstring
Nr	   r
   r   r   r   nameDescriptiondescriptionr-   skipnonetoself)xymodefill	hoverinfomarkers    r   colorsizeopacityFr3   r4   r5   textmarkerr-   
showlegendr   r   	fillcolorlegendgroupr3   r4   r   r   rA   r<   r@   closestshowgridticktexttickvalsr    	autorangezeroline   1wdaybackwardcountlabelstepstepmode1mmonth   6mYTDyeartodate1yallrT   buttonsdaterH   rL   rangeselectortypetitlerB   heightwidthshapes	hovermodeyaxisxaxisdatalayout)r    r   r$   r"   reverser   copydeepcopystrr   r#   sortedgoFigure)r(   colorsrg   	bar_width
showgrid_x
showgrid_yrh   ri   tasks
task_namesro   group_tasksshow_hover_fillshow_colorbarr   taskscatter_data_dictmarker_data_dictr7   scatter_data_templatemarker_data_templatetncolor_indexgroupIDcolor_idxsysrB   rp   kfigs                                  r   ganttr   D   s]   & }
|s5z"|G$|H%f%

 EL("',}"=DT # v		  Ra3 s5z"\&! b
2b! # Ks5z"\&!L   &&r*G$y0T$y0T #f+%K$*;$7[!<,,,*.--8M*Nh'3;(#K0.1"g(#F+5=(#M2  *3/014h',33!(+C04 h',33D9#LLLL	
B 	(#C(B.((#C(B.( ++)-7K)LX&<DX&x098@X&}5"3'..u|D/AB"3'..u|D/AB"3'..w7"3'..w7EL(X&v.55el=6QRX&v.55el=6QR]+X&v.55d;X&v.55d;q} #@ J%J01s:*+
 1DuzR1DwT1DwT1ER1Dv
S%(	 
 FD +11B*CD*CQa *CDD&1A*BC*BQa *BCCD
 ))f
-CJ ECs   Q%Qc                 B   U
c  / n
Uc  / nUc  / nSn[        [        U 5      5       HE  n[        U U   S   U U   S   U U   S   S9nSU U   ;   a  U U   S   US'   U
R                  U5        MG     [        5       n[        5       nU(       a  S	nOS
n/ / SSSUSS.n/ / S/ [        SSSS9SSSS.n/ n[        [        U
5      5       H(  nU U   U   U;  d  M  UR                  U U   U   5        M*     UR	                  5         [        U S   U   [        5      (       Ga  [        U5      S:  a  [        R                  " S5      e[        [        U
5      5       H+  nU
U   S	   nU(       a  UU;  d  M  UR                  U5        M-     U(       a  UR                  5         [        [        U
5      5       GH  nU
U   S	   nU
U   S		 UnU(       a  UR                  U5      nUU-
  U
U   S'   UU-   U
U   S'   [        R                  " U[        R                  5      nUS   nUS   nU U   U   S-  n[        R                  " UUU5      n[        R                  " U[        R                  5      nUU
U   S'   U
U   S   nUU;  a  [         R"                  " U5      UU'   UUU   S'   [%        U U   U   5      UU   S	'   UUU   S'   [        R                  " U[        R                  5      n[        UU   S   5      S:  a7  UU   S   R                  UU   S   S   5        UU   S   R                  S5        ['        U
U   S   U
U   S   U
U   S   U
U   S   5      u  n n!UU   S==   U -  ss'   UU   S==   U!-  ss'   UU;  a,  [         R"                  " U5      UU'   UUU   S    S!'   UUU   S'   UU   S   R                  U
U   S   5        UU   S   R                  U
U   S   5        UU   S   R                  U5        UU   S   R                  U5        SU
U   ;   aC  UU   S"   R                  U
U   S   5        UU   S"   R                  U
U   S   5        U
U   S	 GM  UU   S"   R                  S5        UU   S"   R                  S5        GM     US#L aI  [)        UR+                  5       5      S   n"UU"   S    R-                  [        SUS   /SUS   //S#S$SS%95        [        U S   U   [$        5      (       Ga  / n[        [        U
5      5       H(  nU U   U   U;  d  M  UR                  U U   U   5        M*     UR	                  5         [        U5      [        U5      :  a  [        R                  " S&5      e0 n#Sn$U H$  n%U$[        U5      S-
  :  a  Sn$UU$   U#U%'   U$S-  n$M&     [        [        U
5      5       H+  nU
U   S	   nU(       a  UU;  d  M  UR                  U5        M-     U(       a  UR                  5         [        [        U
5      5       GHo  nU
U   S	   nU
U   S		 UnU(       a  UR                  U5      nUU-
  U
U   S'   UU-   U
U   S'   U#U U   U      U
U   S'   U
U   S   nUU;  a  [         R"                  " U5      UU'   UUU   S'   UUU   S'   [%        U U   U   5      UU   S	'   [        R                  " U[        R                  5      n[        UU   S   5      S:  a7  UU   S   R                  UU   S   S   5        UU   S   R                  S5        ['        U
U   S   U
U   S   U
U   S   U
U   S   5      u  n n!UU   S==   U -  ss'   UU   S==   U!-  ss'   UU;  a,  [         R"                  " U5      UU'   UUU   S    S!'   UUU   S'   UU   S   R                  U
U   S   5        UU   S   R                  U
U   S   5        UU   S   R                  U5        UU   S   R                  U5        SU
U   ;   aC  UU   S"   R                  U
U   S   5        UU   S"   R                  U
U   S   5        U
U   S	 GMA  UU   S"   R                  S5        UU   S"   R                  S5        GMr     US#L a  S#nU H  n"UUU"   S''   M     [        UUUU	/ S([        UU[)        [        [        U5      5      5      S[        U5      S-   /SSS)9[        US[        [)        [        S*S+S,S-S.9[        SS/S0S-S.9[        S1S2S0S-S.9[        SS3S4S5S.9[        SS6S4S-S.9[        S7S89/5      S99S:S;9S<9n&[/        U5       V"s/ s H  n"UU"   PM
     nn"U[/        U5       V"s/ s H  n"UU"   PM
     sn"-  n[0        R2                  " UU&S=9n'U'$ s  sn"f s  sn"f )>5
Refer to FigureFactory.create_gantt() for docstring
NFr	   r
   r   r,   r.   r/   r-   r0   r1   r2   r9   )r3   r4   r5   r6   rB   r7   rD   r8   r:   r   r;   )r3   r4   r5   r@   rA   r-   rB   rD      zYou must use at least 2 colors in 'colors' if you are using a colorscale. However only the first two colors given will be used for the lower and upper bounds on the colormap.r   r   g      Y@rC   rD   r3   rE   r4   r   r   rA   r<   r@   Td   )
colorscale	showscalecmaxcminztError. The number of colors in 'colors' must be no less than the number of unique index values in your group column.rB   rF   rG   rM   rN   rO   rP   rQ   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   rb   rc   rf   rn   )r    r   r$   r"   sortr   r   r   r   rq   r   clrscolor_parserunlabel_rgbfind_intermediate_color	label_rgbrr   rs   rt   r   r#   keysupdateru   rv   rw   )(r(   rx   rg   	index_colr   ry   rz   r{   rh   ri   r|   r}   ro   r~   r   rB   r   r   r   r   r7   r   r   
index_valsrowr   r   lowcolor	highcolorintermedintermed_colorr   r   r   r   index_vals_dictc_indexr&   rp   r   s(                                           r   gantt_colorscaler      s>   ( }
|Js5z"U|G$U|H%uf%

 E%L("',}"=DT # v		  Ra3	 JSZ :i 
2eCj34 ! OO %(9%v..v;?((*  3u:&Euf%B "J"6!!"% '  3u:&Euf%BeV$ G$**2.!(9!4E%L!(9!4E%L &&vt/?/?@FayHq	IeY/58H!99(IxXN!..~t~~NN(6E%L%U|K0H00.2mm<Q.R!(+7?h'425eEl96M2Nh'/9Ah'6 &&vt~~>F $X.s34q8!(+C077%h/4R8 "(+C077='eT"eT"eT"eT"	FB h',2,h',2, //-1]];O-P *@H *84W=<D *=9X&s+225<3EFX&s+225<3EFX&s+227;X&s+227;e, *6299%,}:UV *6299%,}:UV%L/ *6299$? *6299$?I 'N D %**,-a0AQ)00!"F1IF1I?"	 %(9%s++
U$CSz)$J6!!%*Y"78 % 	v;Z(((  CVq(#)'?OC qLG	  3u:&Euf%B "J"6!!"% '  3u:&Euf%BeV$ G$**2.!(9!4E%L!(9!4E%L(7eY8O(PE%L%U|K0H00.2mm<Q.R!(+7?h'49Ah'625eEl96M2Nh'/ &&vt~~>F $X.s34q8!(+C077%h/4R8 "(+C077='eT"eT"eT"eT"	FB h',2,h',2, //-1]];O-P *@H *84W=<D *=9X&s+225<3EFX&s+225<3EFX&s+227;X&s+227;e, *6299%,}:UV *6299%,}:UV%L/ *6299$? *6299$?y '| D J&5?!!$\2 ' %J01s:*+
 1DuzR1DwT1DwT1ER1Dv
S%(	 
 FD +11B*CD*CQa *CDD&1A*BC*BQa *BCCD
 ))f
-CJ ECs   f,fc                 	   U
c  / n
Uc  / nUc  / nSn[        [        U 5      5       HE  n[        U U   S   U U   S   U U   S   S9nSU U   ;   a  U U   S   US'   U
R                  U5        MG     [        5       n[        5       nU(       a  S	nOS
n/ / SSUSS.n/ / S/ [        SSSS9SSS.n/ n[        [        U
5      5       H(  nU U   U   U;  d  M  UR                  U U   U   5        M*     UR	                  5         U H  nUU;  d  M  [
        R                  " S5      e   [        [        U
5      5       H+  nU
U   S	   nU(       a  UU;  d  M  UR                  U5        M-     U(       a  UR                  5         [        [        U
5      5       GH2  nU
U   S	   nU
U   S		 UnU(       a  UR                  U5      nUU-
  U
U   S'   UU-   U
U   S'   XU   U      U
U   S'   U
U   S   nUU;  a  [        R                  " U5      UU'   UUU   S'   UUU   S'   [        UU   S   5      S:  a7  UU   S   R                  UU   S   S   5        UU   S   R                  S5        [        U
U   S   U
U   S   U
U   S   U
U   S   5      u  nnUU   S==   U-  ss'   UU   S==   U-  ss'   UU;  a,  [        R                  " U5      UU'   UUU   S   S'   UUU   S'   UU   S   R                  U
U   S   5        UU   S   R                  U
U   S   5        UU   S   R                  U5        UU   S   R                  U5        SU
U   ;   aC  UU   S    R                  U
U   S   5        UU   S    R                  U
U   S   5        U
U   S	 GM  UU   S    R                  S5        UU   S    R                  S5        GM5     US!L a  S!nU H  n[        U5      UUU      S	'   M     [        UUUU	/ S"[        UU[        [        [        U5      5      5      S[        U5      S-   /SSS#9[        US[        [        [        S$S%S&S'S(9[        SS)S*S'S(9[        S+S,S*S'S(9[        SS-S.S/S(9[        SS0S.S'S(9[        S1S29/5      S39S4S59S69n [        U5       V!s/ s H  n!UU!   PM
     nn!U[        U5       V!s/ s H  n!UU!   PM
     sn!-  n[        R                   " UU S79n"U"$ s  sn!f s  sn!f )8r   NFr	   r
   r   r,   r.   r/   r-   r0   r1   r2   r9   )r3   r4   r5   r6   r7   rD   r8   r:   r   r;   r?   zdIf you are using colors as a dictionary, all of its keys must be all the values in the index column.r   r   rC   rD   r3   rE   r4   r   r   rA   r<   r@   TrF   rG   rM   rN   rO   rP   rQ   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   rb   rc   rf   rn   )r    r   r$   r"   r   r   r   rq   r   rr   rs   r   rt   r#   ru   rv   rw   )#r(   rx   rg   r   r   ry   rz   r{   rh   ri   r|   r}   ro   r~   r   rB   r   r   r   r   r7   r   r   r   r   r&   r   r   r   r   r   index_valuerp   r   r   s#                                      r   
gantt_dictr   U  s   * }
|Js5z"U|G$U|H%uf%

 E%L("',}"=DT # v		  Ra3 JSZ :i 
2eCj34 ! OO f((C   s5z"5\&! b
2b! # s5z"5\&!%L   &&r*G$y0eT$y0eT$*<	+B$Ce[!<,,,*.--8M*Nh'5=(#M23;(#K0  *3/014h',33!(+C04 h',33D9#%L%L%L%L	
B 	(#C(B.((#C(B.( ++)-7K)LX&<DX&x098@X&}5"3'..uU|D/AB"3'..uU|D/AB"3'..w7"3'..w7E%L(X&v.55eEl=6QRX&v.55eEl=6QRe]+X&v.55d;X&v.55d;q #t 
!9<[9I&-.v6 " %J01s:*+
 1DuzR1DwT1DwT1ER1Dv
S%(	 
 FD +11B*CD*CQa *CDD&1A*BC*BQa *BCCD
 ))f
-CJ ECs   S 5S%c                    [        U 5      nU(       aT  UUS   ;  a  [        R                  " S5      e/ nU H  nUR                  UU   5        M     [        R
                  " U5        [        U[        5      (       a  [        R                  " US5      nO[        R                  " US5      nUSL a  UR                  5         U(       dC  [        U[        5      (       a  [        R                  " S5      e[        UUUUUUU	U
SSSUUUS9nU$ [        U[        5      (       d  [        UUUUUUUUU	U
SSSUUS9nU$ [        UUUUUUUUU	U
SSSUUS9nU$ )	a  
**deprecated**, use instead
:func:`plotly.express.timeline`.

Returns figure for a gantt chart

:param (array|list) df: input data for gantt chart. Must be either a
    a dataframe or a list. If dataframe, the columns must include
    'Task', 'Start' and 'Finish'. Other columns can be included and
    used for indexing. If a list, its elements must be dictionaries
    with the same required column headers: 'Task', 'Start' and
    'Finish'.
:param (str|list|dict|tuple) colors: either a plotly scale name, an
    rgb or hex color, a color tuple or a list of colors. An rgb color
    is of the form 'rgb(x, y, z)' where x, y, z belong to the interval
    [0, 255] and a color tuple is a tuple of the form (a, b, c) where
    a, b and c belong to [0, 1]. If colors is a list, it must
    contain the valid color types aforementioned as its members.
    If a dictionary, all values of the indexing column must be keys in
    colors.
:param (str|float) index_col: the column header (if df is a data
    frame) that will function as the indexing column. If df is a list,
    index_col must be one of the keys in all the items of df.
:param (bool) show_colorbar: determines if colorbar will be visible.
    Only applies if values in the index column are numeric.
:param (bool) show_hover_fill: enables/disables the hovertext for the
    filled area of the chart.
:param (bool) reverse_colors: reverses the order of selected colors
:param (str) title: the title of the chart
:param (float) bar_width: the width of the horizontal bars in the plot
:param (bool) showgrid_x: show/hide the x-axis grid
:param (bool) showgrid_y: show/hide the y-axis grid
:param (float) height: the height of the chart
:param (float) width: the width of the chart

Example 1: Simple Gantt Chart

>>> from plotly.figure_factory import create_gantt

>>> # Make data for chart
>>> df = [dict(Task="Job A", Start='2009-01-01', Finish='2009-02-30'),
...       dict(Task="Job B", Start='2009-03-05', Finish='2009-04-15'),
...       dict(Task="Job C", Start='2009-02-20', Finish='2009-05-30')]

>>> # Create a figure
>>> fig = create_gantt(df)
>>> fig.show()


Example 2: Index by Column with Numerical Entries

>>> from plotly.figure_factory import create_gantt

>>> # Make data for chart
>>> df = [dict(Task="Job A", Start='2009-01-01',
...            Finish='2009-02-30', Complete=10),
...       dict(Task="Job B", Start='2009-03-05',
...            Finish='2009-04-15', Complete=60),
...       dict(Task="Job C", Start='2009-02-20',
...            Finish='2009-05-30', Complete=95)]

>>> # Create a figure with Plotly colorscale
>>> fig = create_gantt(df, colors='Blues', index_col='Complete',
...                    show_colorbar=True, bar_width=0.5,
...                    showgrid_x=True, showgrid_y=True)
>>> fig.show()


Example 3: Index by Column with String Entries

>>> from plotly.figure_factory import create_gantt

>>> # Make data for chart
>>> df = [dict(Task="Job A", Start='2009-01-01',
...            Finish='2009-02-30', Resource='Apple'),
...       dict(Task="Job B", Start='2009-03-05',
...            Finish='2009-04-15', Resource='Grape'),
...       dict(Task="Job C", Start='2009-02-20',
...            Finish='2009-05-30', Resource='Banana')]

>>> # Create a figure with Plotly colorscale
>>> fig = create_gantt(df, colors=['rgb(200, 50, 25)', (1, 0, 1), '#6c4774'],
...                    index_col='Resource', reverse_colors=True,
...                    show_colorbar=True)
>>> fig.show()


Example 4: Use a dictionary for colors

>>> from plotly.figure_factory import create_gantt
>>> # Make data for chart
>>> df = [dict(Task="Job A", Start='2009-01-01',
...            Finish='2009-02-30', Resource='Apple'),
...       dict(Task="Job B", Start='2009-03-05',
...            Finish='2009-04-15', Resource='Grape'),
...       dict(Task="Job C", Start='2009-02-20',
...            Finish='2009-05-30', Resource='Banana')]

>>> # Make a dictionary of colors
>>> colors = {'Apple': 'rgb(255, 0, 0)',
...           'Grape': 'rgb(170, 14, 200)',
...           'Banana': (1, 1, 0.2)}

>>> # Create a figure with Plotly colorscale
>>> fig = create_gantt(df, colors=colors, index_col='Resource',
...                    show_colorbar=True)

>>> fig.show()

Example 5: Use a pandas dataframe

>>> from plotly.figure_factory import create_gantt
>>> import pandas as pd

>>> # Make data as a dataframe
>>> df = pd.DataFrame([['Run', '2010-01-01', '2011-02-02', 10],
...                    ['Fast', '2011-01-01', '2012-06-05', 55],
...                    ['Eat', '2012-01-05', '2013-07-05', 94]],
...                   columns=['Task', 'Start', 'Finish', 'Complete'])

>>> # Create a figure with Plotly colorscale
>>> fig = create_gantt(df, colors='Blues', index_col='Complete',
...                    show_colorbar=True, bar_width=0.5,
...                    showgrid_x=True, showgrid_y=True)
>>> fig.show()
r   zIn order to use an indexing column and assign colors to the values of the index, you must choose an actual column name in the dataframe or key if a list of dictionaries is being used.rgbTzError. You have set colors to a dictionary but have not picked an index. An index is required if you are assigning colors to particular values in a dictionary.N)r|   r}   ro   r~   r   r   )r|   r}   ro   r~   r   )r*   r   r   r"   r   validate_indexr   r$   r   validate_colors_dictvalidate_colorsrq   r   r   r   )r%   rx   r   r   reverse_colorsrg   ry   rz   r{   rh   ri   r|   r}   ro   r~   r   r(   
index_list
dictionaryr   s                       r   create_ganttr   !  s   b 2EE!H$((.  
Jj34  Z( &$**659%%fe4fd##((I 
 #+'
  
&$''"' /C" J' /C" Jr   )NNNFTT)NNNFT)NNFFzGantt Chartg?FFiX  NNNNFT)numbersr   rr   plotlyr   r   plotly.colorsrx   r   plotly.figure_factoryr   plotly.graph_objectsgraph_objectsrv   
get_moduler   r   r   r*   r   r   r   r   r   r   r   <module>r      s      /  ' !  *1 0$` 	xL 	SB 	I\ 


	!ir   