
    Kwgi                       d Z d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 ddl ddlmZ ddlmZmZmZmZmZmZmZm Z  ddl!m"Z"m#Z# dd	l$m%Z%m&Z&m'Z'm(Z( dd
l)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z0 dNdZ1dNdZ2dNdZ3d Z4 G d d      Z5 G d d      Z6 G d d      Z7 G d d      Z8 G d de"      Z9 G d de&      Z: G d d e9      Z;d! Z<d" Z= G d# d$      Z> G d% d&e>      Z? G d' d(e>e;      Z@ G d) d*e?e;      ZA G d+ d,      ZBd- ZC G d. d/e9      ZD G d0 d1e>eD      ZEg d2ZFg d3ZGd4 ZH G d5 d6e      ZI eI       ZJd7ZK G d8 d9eE      ZL G d: d;e?eD      ZM G d< d=      ZN G d> d?eNeE      ZO G d@ dAeM      ZP G dB dCeD      ZQ G dD dEeB      ZR G dF dGeB      ZS G dH dI      ZT G dJ dKeQeTeE      ZU G dL dMeQeTeM      ZVy)Oz3.3.0a  Collection of axes for charts.

The current collection comprises axes for charts using cartesian
coordinate systems. All axes might have tick marks and labels.
There are two dichotomies for axes: one of X and Y flavours and
another of category and value flavours.

Category axes have an ordering but no metric. They are divided
into a number of equal-sized buckets. Their tick marks or labels,
if available, go BETWEEN the buckets, and the labels are placed
below to/left of the X/Y-axis, respectively.

  Value axes have an ordering AND metric. They correspond to a nu-
  meric quantity. Value axis have a real number quantity associated
  with it. The chart tells it where to go.
  The most basic axis divides the number line into equal spaces
  and has tickmarks and labels associated with each; later we
  will add variants where you can specify the sampling
  interval.

The charts using axis tell them where the labels should be placed.

Axes of complementary X/Y flavours can be connected to each other
in various ways, i.e. with a specific reference point, like an
x/value axis to a y/value (or category) axis. In this case the
connection can be either at the top or bottom of the former or
at any absolute value (specified in points) or at some value of
the former axes in its own coordinate system.
    )log10)isNumberisNumberOrNoneisListOfStringsOrNoneisListOfNumbersisListOfNumbersOrNoneisColorOrNoneOneOf	isBoolean
SequenceOfisStringEitherOr	ValidatorNoneOrisNormalDateisNoneOrCallable)*)
normalDate)DrawingLinePolyLineRectGroupSTATE_DEFAULTS_textBoxLimits_rotatedBoxLimits)WidgetTypedPropertyCollection)LabelPMVLabelXLabelDirectDrawFlowable)nextRoundNumber)
ShadedRect)Color)isSeqNc                 r   t        | d   d         r'|r|||fd}n|fd}t        t        |fd|             } t        t        t        | D cg c]  }|D cg c]  }||	 c} c}            } t	        |       dk(  r|S  |t        t        ||                   }|r | ||      |      S |S c c}w c c}w )Nr   c                      || ||      S N )Txspecialfuncs       U/var/www/horilla/myenv/lib/python3.12/site-packages/reportlab/graphics/charts/axes.py<lambda>z"_findMinMaxValue.<locals>.<lambda>5   s    ga$6G     c                     | |   S r)   r*   )r+   r,   s     r/   r0   z"_findMinMaxValue.<locals>.<lambda>7   s
    AaD r1   c                 ,    t        t        ||             S r)   )listmap)efs     r/   r0   z"_findMinMaxValue.<locals>.<lambda>8   s    c!Ah r1   )r&   r4   r5   filterlen)Vr,   defaultr.   r-   extraMinMaxValuesr7   rs           r/   _findMinMaxValuer>   2   s    QqT!W~7GA A
sa/2
3VC!DQQ8!-!8DEFA
1vqy.T#d1+A.?4&'*FQF 9Ds   	B4B/B/!B4/B4c                 ,    t        | ||t        ||      S )zfind minimum over V[i][x]r-   r<   )r>   minr:   r,   r;   r-   r<   s        r/   _findMinrC   >   s    AaGN_``r1   c                 ,    t        | ||t        ||      S )zfind maximum over V[i][x]r@   )r>   maxrB   s        r/   _findMaxrF   B   s    AaGO`aar1   c                 D    | D ]  }	 t        |      |k7  r y y#  Y  yxY w)ztrue if all values are intr      int)valuesvs     r/   _allIntrM   F   s4     	1vqyy
 	s   c                       e Zd ZdZd Zd Zy)AxisLabelAnnotationaK  Create a grid like line using the given user value to draw the line
    v       value to use
    kwds may contain
    scaleValue  True/not given --> scale the value
                otherwise use the absolute value
    labelClass  the label class to use default Label
    all Label keywords are acceptable (including say _text)
    c                      || _         || _        y r)   _v_kwdsselfrL   kwdss      r/   __init__zAxisLabelAnnotation.__init__X       
r1   c                 v   | j                   j                         }|j                  dt              }|j                  dd      }t	        |d      s|j                           |r|j                  nd | j                        }|j                  r|j                  }|}n|}|j                  }||d<   ||d<    |di |S )	N
labelClass
scaleValueT_tickValuesc                     | S r)   r*   r,   s    r/   r0   z.AxisLabelAnnotation.__call__.<locals>.<lambda>b   s    a r1   r,   yr*   )rS   copypopr   hasattr_pseudo_configurescalerR   isYAxis_x_y)rU   axisrV   rZ   r[   svr,   r_   s           r/   __call__zAxisLabelAnnotation.__call__\   s    zz XXl51
XXl40
tM*""$7JdjjKA<<AAAAS	S	!D!!r1   N__name__
__module____qualname____doc__rW   rj   r*   r1   r/   rO   rO   O   s    "r1   rO   c                       e Zd ZdZd Zd Zy)AxisLineAnnotationa  Create a grid like line using the given user value to draw the line
    kwds may contain
    startOffset if true v is offset from the default grid start position
    endOffset   if true v is offset from the default grid end position
    scaleValue  True/not given --> scale the value
                otherwise use the absolute value
    lo          lowest coordinate to draw default 0
    hi          highest coordinate to draw at default = length
    drawAtLimit True draw line at appropriate limit if its coordinate exceeds the lo, hi range
                False ignore if it's outside the range
    all Line keywords are acceptable
    c                      || _         || _        y r)   rQ   rT   s      r/   rW   zAxisLineAnnotation.__init__z   rX   r1   c                    | j                   j                         }|j                  dd      }|j                  dd      }|j                  dd      }|j                  r|j                  }|j
                  }n|j
                  }|j                  }|j                  dd       }|j                  dd       }	||	Ft        t        |dd       d	d       }
|
rt        |
d
      r |
       }
|
r||
d   }|	|
d   }	n|d}|	d}	|j                  d|j                        |z   }|j                  dd      |z   }t        ||      t        ||      }}|j                  dd      }|j                  }|sd |_        	 | j                  }|r||z   }n|r||z   }|j                  ||z
  |	|z
  |j                  dd             }t        |d      s|j                          |j                  |      |k  s|kD  r|s		 ||_        y |k  r|n|fd|_         ||      }|j                         D ]  \  }}t!        |||        	 ||_        |S # ||_        w xY w)Nr[   T	endOffsetFstartOffsetstartendjoinAxisgetGridDimsrj   r   rH   hilodrawAtLimitc                     | S r)   r*   r^   s    r/   r0   z-AxisLineAnnotation.__call__.<locals>.<lambda>   s    1 r1   parentr\   c                     S r)   r*   )r,   ds    r/   r0   z-AxisLineAnnotation.__call__.<locals>.<lambda>   s    q r1   )rS   r`   ra   re   rf   rg   getattrrb   _lengthrA   rE   _get_line_posrR   _getLineFuncrc   itemssetattr)rU   rh   rV   r[   rt   ru   offsd0sr6   dimrz   r{   r|   oaglprL   r.   Lkr   s                      @r/   rj   zAxisLineAnnotation.__call__~   sK   zz XXl40
HH[/	hh}U3<<77DB77DBHHWT"HHU4 9	'$z$7dKCws:.e9#a&a9#a&a9!a9!aXXd4<<(+XXd1b "RjR2hh}U3""!,D	'AFF$$QtVAdF488HT3JKD4.&&(""1%Atqt"4 "'D R4AA%0"QAzz| !!A "'D "'Ds   2A=I 8AI 	INrk   r*   r1   r/   rq   rq   m   s    4r1   rq   c                       e Zd ZdZd Zd Zy)AxisBackgroundAnnotationa  Create a set of coloured bars on the background of a chart using axis ticks as the bar borders
    colors is a set of colors to use for the background bars. A colour of None is just a skip.
    Special effects if you pass a rect or Shaded rect instead.
    c                      || _         || _        y r)   )_colorsrS   )rU   colorsrV   s      r/   rW   z!AxisBackgroundAnnotation.__init__   s    
r1   c           
         | j                   }|sy | j                  j                         }|j                  }|r|j                  }|j
                  }n|j
                  }|j                  }|j                  dd       }|j                  dd       }||Ft        t        |dd       dd       }	|	rt        |	d      r |	       }	|	r||	d   }||	d   }n|d}|d}t        |d      s|j                          t        |dd       }
|
sy t               }t        |      }|j                  |
d         }t        dt        |
            D ]  }|j                  |
|         }||dz
  |z     }|r|r|}|}||z
  }||z
  }n|}|}||z
  }||z
  }t        |t              rt!        |||||d 	      }nt        |t               r<t!        ||||      }|j"                  D ]  }|d
vst%        ||t        ||               nLt        |t&              r<t'        ||||
      }|j"                  D ]  }|d
vst%        ||t        ||               |j)                         |} |S )Nrv   rw   rx   ry   rj   r   rH   r\   )	fillColorstrokeColor)r,   r_   widthheight)r   rS   r`   re   rf   rg   ra   r   rb   rc   r   r9   r   range
isinstancer%   r   __dict__r   r$   add)rU   rh   r   rV   re   r   r   r   r6   r   tvGncolorsv0iv1cr_   r,   r   r   r=   r   s                          r/   rj   z!AxisBackgroundAnnotation.__call__   sf   vzz ,,77DB77DBHHWT"HHU4 9	'$z$7dKCws:.e9#a&a9#a&a9!a9!atM*""$T--6Gf+1&qR! 	A##BqE*B!W}%AAAUFaCEAArEEqSFa&QqvdKA$'Qqv.AZZ 6$>>#Aa!56  *-"QfEAZZ 6$>>#Aa!56 aB7	8 r1   Nrk   r*   r1   r/   r   r      s    :r1   r   c                   "    e Zd ZdZd Zd Zd Zy)TickLUz$lookup special cases for tick valuesc                 @    |j                  dd      | _        || _        y )Naccuracy:0yE>)ra   r   r+   )rU   r+   rV   s      r/   rW   zTickLU.__init__   s    D1r1   c                 j    | j                   }| j                  D ]  \  }}t        ||z
        |k  s y yNTF)r   r+   absrU   tr   r,   rL   s        r/   __contains__zTickLU.__contains__   s:    ==66 	CAa1Q3x 	 r1   c                     | j                   }| j                  D ]$  \  }}t        ||z
        | j                   k  s"|c S  t        d|z        )Nzcannot locate index %r)r   r+   r   
IndexErrorr   s        r/   __getitem__zTickLU.__getitem__  sN    ==66 	CAa1Q3x%	 1A566r1   N)rl   rm   rn   ro   rW   r   r   r*   r1   r/   r   r      s    .7r1   r   c                       e Zd Zd Zd Zd Zd Zd ZddZdg i fdZ	ddg fd	Z
ddg fd
ZddZd Z ee      Zd Z ee      ZddZd Zd Zy)_AxisGc                 D    | j                  |      }	 |d   }|S #  Y |S xY wNr   )rd   )rU   rL   s     r/   r   z_AxisG._get_line_pos  s3    JJqM	!A 	s    c                 t    | j                  |      }t        || j                  |z   || j                  |z         S r)   )r   r   rg   )rU   r,   rv   rw   s       r/   _cxLinez_AxisG._cxLine  s3    q!Atww477S=99r1   c                 t    | j                  |      }t        | j                  |z   || j                  |z   |      S r)   )r   r   rf   )rU   r_   rv   rw   s       r/   _cyLinez_AxisG._cyLine  s3    q!DGGeOQ#q99r1   c           	          | j                  |      }| j                  |z   }| j                  |z   }t        ||      t        ||      }}||z   }t	        |||||z   |||z   gd      S NrH   )strokeLineJoin)r   rg   rA   rE   r   )	rU   r,   rv   rw   _3d_dx_3d_dyy0y1x1s	            r/   	_cxLine3dz_AxisG._cxLine3d  sl    q!WWu_WWs]RC2JBZ2bF2bi8JJr1   c                     | j                  |      }| j                  |z   }| j                  |z   }t        ||      t        ||      }}||z   }t	        ||||z   |||z   |gd      S r   )r   rf   rA   rE   r   )	rU   r_   rv   rw   r   r   x0r   r   s	            r/   	_cyLine3dz_AxisG._cyLine3d$  sl    q!WWu_WWs]RC2JBZAbi2f9R8JJr1   Nc                     t        |dd       }|>t        |dd       }| j                  xr | j                  xs | j                  }|||||fdS | j                  xr | j                  xs | j
                  }|||fdS )Nr   r   c                      || ||||      S )N)r   r   r*   )rL   r   r6   r7   r   r   s         r/   r0   z%_AxisG._getLineFunc.<locals>.<lambda>1  s    aPQRSTU]ckqNr r1   c                      || ||      S r)   r*   )rL   r   r6   r7   s       r/   r0   z%_AxisG._getLineFunc.<locals>.<lambda>4  s    !Aa( r1   )r   re   r   r   r   r   )rU   rv   rw   r~   r   r   r7   s          r/   r   z_AxisG._getLineFunc,  sx    .VHT2F/A4>>A$qfrr-=A$q::r1   c                    | j                  |||
      }t        | d      s| j                          r| j                  xr fdxs fd}nd }| j                  D ]|  } ||      }|r	 ||      r||_        ||_        ||_        ||_        ||_	        |	|_
        ||v r(||   j                         D ]  \  }}t        |||        |j                  |       ~ y )Nr\   c                      | j                   v S r)   )r   lexcludes    r/   r0   z#_AxisG._makeLines.<locals>.<lambda>;  s    addgo r1   c                      | j                   v S r)   )r   r   s    r/   r0   z#_AxisG._makeLines.<locals>.<lambda>;  s    QTTU\_ r1   )r   rb   rc   re   r\   r   strokeWidthstrokeDashArrayr   strokeLineCapstrokeMiterLimitr   r   r   )rU   grv   rw   r   r   r   r   r   r   r~   r   specialsr.   exfr   r   arL   s              `       r/   
_makeLinesz_AxisG._makeLines6  s      s62tM*""$,,>$=]C\CC!! 	AG3q68 + +$3!#1 "/%5"='{002 '!!A'a	r1   c                    | j                   }| j                  xs d}|r|r| j                  r| j                  }| j                  }||.|rt        |d      r |       }|r||d   }||d   }n|d}|d}|s|r{| j                  r| j                  }	n| j                  }	| j                  |||	z
  ||	z
  ||| j                  | j                  | j                  | j                  ||t        | di              | j                  |||g        y))this is only called by a container objectr   Nrj   rH   _gridSpecials)r~   r   r   )r   )gridStrokeColorgridStrokeWidthvisibleGrid	gridStartgridEndrb   re   rf   rg   r   gridStrokeDashArraygridStrokeLineJoingridStrokeLineCapgridStrokeMiterLimitr   _makeSubGrid)
rU   r   r   r~   r   r   wr   r6   r   s
             r/   makeGridz_AxisG.makeGridL  s;       %At''AAyAI73z2%Cyc!f!yc!f!ya!ya!A<<!WWd!D&4!D4L4LTMdMdeie{e{  }A  }V  }V  ^d  mt  ~E  FJ  KZ  []  ~^  _!Cr2r1   c                 D   t        | dd      r| j                  dkD  sy| j                  }| j                  xs d}|r|sy| j                  }| j
                  }||.|rt        |d      r |       }|r||d   }||d   }n|d}|d}|s|r| j                  r| j                  }	n| j                  }	| j                         }
	 | j                  |||	z
  ||	z
  ||| j                  | j                  | j                  | j                  ||       |
| _        yy# |
| _        w xY w)r   visibleSubGridr   Nrj   rH   )r~   r   )r   
subTickNumsubGridStrokeColorsubGridStrokeWidthsubGridStart
subGridEndrb   re   rf   rg   _calcSubTicksr   subGridStrokeDashArraysubGridStrokeLineJoinsubGridStrokeLineCapsubGridStrokeMiterLimitr\   )rU   r   r   r~   r   r   r   r   r6   r   otvs              r/   r   z_AxisG._makeSubGridb  sL   -a0T__Q5F####(qQOO9	ws:.e9#a&a9#a&a9!a9!a||DGGT$$$&C'!D&4!D4O4OPTPjPjko  lE  lE  FJ  Fb  Fb  jp  y@  A#&   $' s   A
D 	Dc                 z    |%| j                   | j                  f| j                     }||| j                  z   }||fS r)   )rf   rg   re   r   )rU   rv   rw   s      r/   ry   z_AxisG.getGridDims|  s=    =477477"3DLL"A%;eDLL0Syr1   c                 t    t        | dd       dk(  ry| j                  j                  }|d   dk(  xs |d d dk(  S )N
_dataIndexrH   Tr   Y   AdjYr   	__class__rl   rU   acns     r/   re   z_AxisG.isYAxis  sA    4T*A-dnn%%1vs{-c"1gvo-r1   c                 t    t        | dd       dk(  ry| j                  j                  }|d   dk(  xs |d d dk(  S )Nr   r   TX   NormalDateXr   r   s     r/   isXAxisz_AxisG.isXAxis  sB    4T*A-dnn%%1vs{5c#2h55r1   c                 ^    |t        | dg        |D ]  }|j                   ||               y )Nannotations)r   r   )rU   r   Ar,   s       r/   addAnnotationsz_AxisG.addAnnotations  s0    9gd=4 	AEE!D'N	r1   c                    t        | dg       d d  }i }dD ]]  }g j                  }g j                  }|D ]   }t        ||d      r	 ||        ||       " |j                  ||<   |j                  |d d  _ |dxx   |z  cc<   |S )Nr  )early
beforeAxis	afterAxisbeforeTicks
afterTicksbeforeTickLabelsafterTickLabelslater   r  )r   append__self__)rU   r  DrL   RPr   s          r/   _splitAnnotationsz_AxisG._splitAnnotations  s    Dr*1-* 	A 		A		A 1Qq>aDaD	
 ::AaD::AaD	 	
&	Q	r1   c                 \   t               }| j                         }| j                  ||d          | j                  r| j                  ||d          |j	                  | j                                | j                  ||d          | j                  ||d          |j	                  | j                                | j                  ||d          | j                  ||d          |j	                  | j                                | j                  ||d          | j                  ||d          |S )	Nr  r  r	  r
  r  r  r  r  )r   r  r  visibler   makeAxis	makeTicksmakeTickLabels)rU   r   r  s      r/   drawz_AxisG.draw  s   G""$Aaj)<<!L/2EE$--/"!K.1!M"23EE$.."#!L/2!$6"78EE$%%'(!$5"67Aai(r1   r)   NN)rl   rm   rn   r   r   r   r   r   r   r   r   r   ry   re   propertyr  r  r  r  r*   r1   r/   r   r     s    ::KK; BF  OQ  [] , !R 3, !%D '4
. wG6 wG
$r1   r   c                   6    e Zd Z ee eed            Zd Zy)CALabelz?where in the category range [0,1] the labels should be anchoreddesc)BASElabelPosFracc                 T    t        j                  | fi | | j                  d       y )N      ?)r"  )r    rW   _setKeywordsrU   kws     r/   rW   zCALabel.__init__  s+    $$$" 	 	r1   N)	rl   rm   rn   AttrMapr    AttrMapValuer   _attrMaprW   r*   r1   r/   r  r    s    H#H3tu
Hr1   r  c                      e Zd ZdZdZ edci d eed      d eed      d eed	      d
 eed      d eed      d eed      d ee	d      d ee
d      d e eddd      d      d e eddd      d      d eed      d eed      d ee	d      d  ee
d!      d" e eddd      d#      d$ e eddd      d%      d& eed'      d( eed)      d* eed+      d, eed-      d. ed/d0      d1 eed2      d3 ed/d4      d5 eed6      d7 eed8      d9 e ed:d;d<      d=      d> e ed?d@dAdB      dC      dD eedE      dF eedG      dH ee	dI      dJ eedK      dL eedM      dN ed/dO      dP eedQ      dR eedS      dT e edUdVdWdX      dY      dZ eed[      Zd\ Zd] Zddd^Zd_ Zd` Zda Zdb Zy/)eCategoryAxisz+Abstract category axis, unusable in itself.rH   r  Display entire object, if true.r  visibleAxisDisplay axis line, if true.visibleTicksDisplay axis ticks, if true.visibleLabelsDisplay axis labels, if true.r   Display axis grid, if true.r   Width of axis line and ticks.r   Color of axis line and ticks.r   Dash array used for axis line.r   r      #Line cap 0=butt, 1=round & 2=squarer   $Line join 0=miter, 1=round & 2=bevelr   $miter limit control miter line joinsr   Width of grid lines.r   Color of grid lines.r   Dash array used for grid lines.r   (Grid Line cap 0=butt, 1=round & 2=squarer   )Grid Line join 0=miter, 1=round & 2=bevelr   )Grid miter limit control miter line joinsr   #Start of grid lines wrt axis originr   !End of grid lines wrt axis origindrawGridLast-if true draw gridlines after everything else.labelsNHandle of the axis labels.categoryNameszList of category names.rx   Join both axes if true.joinAxisPos*Position at which to join with other axis.reverseDirection#If true reverse category direction.styleparallelstackedparallel_3dz$How common category bars are plottedlabelAxisModehighlowrh   axispmv*Like joinAxisMode, but for the axis labels	tickShiftzTick shift typicallytickStrokeWidthWidth of ticks if specified.tickStrokeColorColor of ticks if specified.loPadz*extra inner space before start of the axishiPadz'extra inner space after end of the axisr  list of annotationsloLLen*extra line length before start of the axishiLLen'extra line length after end of the axisskipGridnonetopbothbottom'grid lines to skip top bottom both noneinnerTickDraw#Callable to replace _drawInnerTicksc                 (   | j                   j                  dk7  sJ d       d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _	        d| _
        d| _        d| _        t        d   | _        t        d	   | _        t        d
   x| _        | _        t        d   x| _        | _        t        d   x| _        | _        d| _        t        d   | _        t        d	   | _        d x| _        | _        t        d
   | _        t        d   | _        t        d   | _        t7        t8              | _        d | _        d | _        d | _         d | _!        d| _"        d| _#        d| _$        d | _%        d| _&        d| _'        d| _(        d| _)        d| _*        y )Nr,  z(Abstract Class CategoryAxis Instantiated2   d   r   rH   Fr   r   r   r   r         ?rh   rO  )+r   rl   rf   rg   r   	_catCountr  r.  r0  r2  r   rD  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  rF  rH  rx   rJ  joinAxisModerR  rL  rN  _labelTextFormatrW  r\  r]  r_  ra  rU   s    r/   rW   zCategoryAxis.__init__  s   ~~&&6b8bb6  !)-8-.?@8FGW8XX$"56D_6UU!3<JK]<^^!D$9#-m<#12C#D (,,,-=>+O< ./A B-g6 " # !
 !%

r1   c                 d    t        |      | _        t        |      | _        t        |      | _        y r)   floatrf   rg   r   rU   r,   r_   lengths       r/   setPositionzCategoryAxis.setPosition#  #    ((V}r1   c                    t        t        t        t        |                  | _        |xs@ | j
                  | j                  z
  | j                  z
  t        | j                  xs d      z  | _	        | j                          | j                  dk(  rEt        | j                        D cg c]  }t        |D cg c]  }||   	 c}        c}}| _        y y c c}w c c}}w )NrH   rU  )rE   r4   r5   r9   ro  r   r\  r]  ru  	_barWidth_calcTickmarkPositionsrR  r   sum_pmv)rU   multiSeriesbarWidthr   seriess        r/   	configurezCategoryAxis.configure)  s    T#c+"678!ft||DJJ'>tzz'I5QUQ_Q_QdcdKe&e##%*MRSWSaSaMbckBFfQiBCcDI +Bcs   (C6C	CCc                    | j                   }| j                  r"t        |      D cg c]  }|dz   	 c}| _        y | j                  rt        t        d|            | _        y t        t        |dz               | _        y c c}w )Nr$  rH   )ro  rW  r   r\   rL  r4   )rU   nr   s      r/   r|  z#CategoryAxis._calcTickmarkPositions0  sc    NN>>/4Qx8!#8D$$#'b#4 #'ac
#3   9s   A?c                 B    | j                   r| j                  |z
  dz
  }|S NrH   )rL  ro  rU   idxs     r/   _scalezCategoryAxis._scale:  s"      s(:1(<#
r1   c                 <    | j                  |      | j                  fS )z/Returns the position and width in drawing unitsloScaler{  r  s     r/   rd   zCategoryAxis.scale>  s    S!4>>22r1   c                 D    | j                  |      d| j                  z  z   S )z-Returns the bar mid position in drawing unitsr$  r  r  s     r/   midScalezCategoryAxis.midScaleB  s    ||C 3t~~#555r1   r*   r)   )rl   rm   rn   ro   _nodocr(  r)  r   r   r	   r   r
   r   r   r   r*  rW   rx  r  r|  r  rd   r  r*   r1   r/   r,  r,    s   1F &
y/PQ&
"93PQ&
 $I4RS&
 %Y5TU	&

 #93PQ&
 #82QR&
 #=7VW&
 ''<Ccd&
 %U1Qq\7\]&
 &eAal8^_&
 (6\]&
 'x6LM&
 '};QR&
 ++@Ghi&
 )q1;ef&
  *%!A,<gh!&
"  ,H:ef#&
$ !6[\%&
& ~4WX'&
( $I4cd)&
* d)EF+&
, %%:AZ[-&
.  +DE/&
0 #>8de1&
2 (	8]^3&
4 U:iFGmn5&
6 %U6%	%JQ}~7&
8 !1GH9&
: '~<Z[;&
< '};YZ=&
> X,XY?&
@ X,UVA&
B #4-BCC&
D h-YZE&
F h-VWG&
H  fU6( CDmnI&
J %%5<abK&
HP4l%d436r1   r,  c                 X    | j                   sJ d| j                  j                  z         y )Nz/Cannot connect to other axes (%s), but Y- ones.)re   r   rl   rh   s    r/   _assertYAxisr  F  #    <<dJT^^MdMddd<r1   c                 X    | j                   sJ d| j                  j                  z         y )Nz/Cannot connect to other axes (%s), but X- ones.)r  r   rl   r  s    r/   _assertXAxisr  H  r  r1   c                   R    e Zd ZdZed        Zed        Zd Zd
dZd Z	d Z
d
d	Zy)_XTicksr   c                 0    t        | d| j                        S )NrX  )r   r   rr  s    r/   actualTickStrokeWidthz_XTicks.actualTickStrokeWidthN      t-d.>.>??r1   c                 0    t        | d| j                        S )NrZ  )r   r   rr  s    r/   actualTickStrokeColorz_XTicks.actualTickStrokeColorR  r  r1   c                 6   t        | dd       }|r || |||       y |s|rz| j                  }| j                  }|r|r|s||z  }n	|r|s||z  }| j                  ||| | j                  || j
                  | j                  | j                  | j                  	       y y )Nri  )	r   r  _tickTweaksr   r  r   r   r   r   )rU   tUtDr   itdsWtWs          r/   _drawTicksInnerz_XTicks._drawTicksInnerV  s    d?40R12++B!!BbBBBBOOAb"T%?%?4CWCWX\XkXklpl~l~  @D  @U  @U  V r1   Nc                 `    |xs
 t               }| j                  r| j                  |||       |S r)   )r   r0  r  )rU   r  r  r   s       r/   
_drawTicksz_XTicks._drawTicksd  s-    L  Bq)r1   c                     t        | dd      rE| j                  dkD  r5| j                         }	 d| _        | j	                  |||       | `|| _        y y y # | `|| _        w xY w)NvisibleSubTicksr   rH   )r   r   r   _subTickingr  r\   )rU   r  r  r   r   s        r/   _drawSubTicksz_XTicks._drawSubTicksj  sp    4)!,1B$$&C'#$ $$R1-$#&  2C, $#& s   A Ac                 &   | j                   }	 | j                  t        | dd            | _         | j                  | j                  | j
                        }| j                  t        | dd      t        | dd      |       ||| _         S # || _         w xY wNtickAxisModerh   	subTickHir   	subTickLo)rg   _labelAxisPosr   r  tickUptickDownr  )rU   yoldr   s      r/   r  z_XTicks.makeTickst  s{    WW	((nV)LMDGDMM:AwtK:74TU;VWXYDGdDG   A1B 	Bc                     | j                   }|r?|xs | j                  }|dk(  r|j                  S |dk(  r|j                  |j                  z   S | j                  S NrT  rS  )rx   rR  rg   r   rU   moderh   s      r/   r  z_XTicks._labelAxisPos~  Q    }}-4--Du}wwww--wwr1   r)   )rl   rm   rn   r  r  r  r  r  r  r  r  r  r*   r1   r/   r  r  K  sK    K@ @ @ @V'r1   r  c                       e Zd ZddZd Zy)_YTicksNc                     | j                   }|r?|xs | j                  }|dk(  r|j                  S |dk(  r|j                  |j                  z   S | j                  S r  )rx   rR  rf   r   r  s      r/   r  z_YTicks._labelAxisPos  r  r1   c                 &   | j                   }	 | j                  t        | dd            | _         | j                  | j                  | j
                        }| j                  t        | dd      t        | dd      |       ||| _         S # || _         w xY wr  )rf   r  r   r  	tickRighttickLeftr  )rU   xoldr   s      r/   r  z_YTicks.makeTicks  s{    WW	((nV)LMDGt}}=AwtK:74TU;VWXYDGdDGr  r)   )rl   rm   rn   r  r  r*   r1   r/   r  r    s    r1   r  c                       e Zd ZdZ ee eed       eed       e eddddd	      d
            Z	dZ
d Zd ZddZd Zd Zd Zd Zy	)XCategoryAxiszX/category axisTick length up the axis.r  Tick length down the axis.rg  re  valuepointsNIMode used for connecting axis ('bottom', 'top', 'value', 'points', None).)r!  r  r  rp  r   c                     t         j                  |        d| j                  _        d| j                  _        d| _        d| _        y )Nr  r      )r,  rW   rF  	boxAnchordyr  r  rr  s    r/   rW   zXCategoryAxis.__init__  s7    d# # r1   c                    | j                  ddd       | j                  dg       g d| _        d| j                  _        d| j                  d   _        d	| j                  d   _        t        d
d      }|j                  |        |S )N   F      
      r  (   rl  )OneTwoThreeFourFiver  r6   r   Z      rm  rx  r  rH  rF  r  angler   r   rU   r   s     r/   demozXCategoryAxis.demo  st    R%()*@ ##&A !AC	dr1   c                     t        |       |dk(  r|j                  | _        y|dk(  r|j                  |j                  z   | _        y|dk(  r|j                  |      | _        y|dk(  r|| _        yy)!Join with y-axis using some mode.rg  re  r  r  Nr  rg   r   rd   rU   yAxisr  poss       r/   
joinToAxiszXCategoryAxis.joinToAxis  sc    U8hhDGU]hh.DGW_kk#&DGXDG r1   c                     | j                   }|rH| j                  }|dv r| j                  ||       y |dv r| j                  ||| j                         y y y )Nrg  re  r  r  r  r  r  rx   rp  r  rJ  rU   jajams      r/   _joinToAxiszXCategoryAxis._joinToAxis  ]    ]]##C''-++$2B2BC ,	 r1   c                 r    | j                   | j                  z   | j                  |      | j                  z  z   S )z'returns the x position in drawing units)rf   r\  r  r{  r  s     r/   r  zXCategoryAxis.loScale  s,    ww#dkk#&6t~~&EEEr1   c                    t               }| j                          | j                  s|S t        | j                  | j
                  z
  | j                  | j                  | j                  z   | j                  z   | j                        }| j                  |_	        | j                  |_
        | j                  |_        |j                  |       |S r)   r   r  r.  r   rf   r_  rg   r   ra  r   r   r   r   rU   r   rh   s      r/   r  zXCategoryAxis.makeAxis      GDGGDKK'$''DLL2H2TVZV]V]^++++#33	dr1   c                    t               }| j                  s|S | j                  }|9| j                  }t	        |      }| j
                  }| j                  }| j                         }| j                  }| j                  dk(  r| j                  nd }	t        |      D ]  }
|r	||
z
  dz
  }n|
}||k\  r|
|z
  }|| j                  v r| j                  |   }n| j                  |
   }|	r#|j                  }|	|   x}|_
        |dk  r|dz  }nd}|j                  }||
|z   |z  z   }|j                  |||z          |j!                  ||   xs d       |j#                  |        |S NrU  rH   r    )r   r2  rH  ro  r9   rL  r{  r  rf   rR  r~  r   rF  r  r"  	setOriginsetTextr   )rU   r   rH  catCountr  rL  r  rg   rf   pmvr   iclabel_dyrL   lpfr,   s                    r/   r  zXCategoryAxis.makeTickLabels  sf   G!!!8**$~~HM"A#44~~H##%BB#119<$))$C8_ #(1*Q,Rbq5(jDKK' KK.E KKNE((C%(W,A
sC2ICC((!C%8++"S&)mB/526e'* r1   rg  Nrl   rm   rn   ro   r(  r,  r)  r   r
   r*  r   rW   r  r  r  r  r  r  r*   r1   r/   r  r    sr    Lh+--/#E(E7Hd$S\^
H J
DF$r1   r  c            
           e Zd ZdZ ee eed       eed       e ed      d            Z	dZ
d	 Zd
 ZddZd Zd Zd Zd Zy)YCategoryAxiszY/category axisTick length left of the axis.r  Tick length right of the axis.leftrightr  r  NIMode used for connecting axis ('left', 'right', 'value', 'points', None).)r!  r  r  rp  rH   c                     t         j                  |        d| j                  _        d| j                  _        d| _        d| _        y )Nr6   r  r  r   )r,  rW   rF  r  dxr  r  rr  s    r/   rW   zYCategoryAxis.__init__  s7    d# # r1   c                    | j                  ddd       | j                  dg       g d| _        d| j                  _        d| j                  d   _        d	| j                  d   _        t        d
d      }|j                  |        |S )Nrl  r  P   )r  r  r  )r  r  r  r6   r   r8  r  r  rm  r  r  s     r/   r  zYCategoryAxis.demo&  sr    R$
|$2 ##&A !AC	dr1   Nc                     t        |       |dk(  r|j                  dz  | _        y|dk(  r"|j                  |j                  z   dz  | _        y|dk(  r|j                  |      dz  | _        y|dk(  r|dz  | _        yyz!Join with x-axis using some mode.r        ?r  r  r  Nr  rf   r   rd   rU   xAxisr  r  s       r/   r  zYCategoryAxis.joinToAxis3  sv     	U6>hhnDGW_xx%--/36DGW_kk#&,DGXCiDG r1   c                     | j                   }|rH| j                  }|dv r| j                  ||       y |dv r| j                  ||| j                         y y y N)r  r  r  r  r  r  r  s      r/   r  zYCategoryAxis._joinToAxis@  r  r1   c                 X    | j                   | j                  |      | j                  z  z   S )z'Returns the y position in drawing units)rg   r  r{  r  s     r/   r  zYCategoryAxis.loScaleI  s#    wwS)$..888r1   c                    t               }| j                          | j                  s|S t        | j                  | j
                  | j                  z
  | j                  | j
                  | j                  z   | j                  z         }| j                  |_	        | j                  |_
        | j                  |_        |j                  |       |S r)   r   r  r.  r   rf   rg   r_  r   ra  r   r   r   r   r  s      r/   r  zYCategoryAxis.makeAxisM  s    GDGGTWWT[[0$''477T\\;QRVR]R];]^++++#33	dr1   c                    t               }| j                  s|S | j                  }|E| j                  }t	        |      }| j
                  }| j                  }| j                  }| j                         }| j                  }	| j                  dk(  r| j                  nd }
t        |      D ]  }|r	||z
  dz
  }n|}||k\  r||z
  }|| j                  v r| j                  |   }n| j                  |   }|j                  }|	||z   |z  z   }|
r#|j                  }|
|   x}|_        |dk  r|dz  }nd}|j                  ||z   |       |j!                  ||   xs d       |j#                  |        |S r  )r   r2  rH  ro  r9   rL  r{  rF  r  rg   rR  r~  r   r"  r  r  r  r   )rU   r   rH  r  r  rL  r  rF  rf   rg   r  r   r   r  r  r_   _dxrL   s                     r/   r  zYCategoryAxis.makeTickLabelsZ  so   G!!!8**$~~HM"A#44~~H[[F##%BB#119<$))$C8_ #(1*Q,Rbq5(jDKK' KK.E KKNE((!C%8++((C%(W,A
sC2ICC3*mB/526e'( r1   r  Nr  r*   r1   r/   r  r    sj    L02 13#E*T$U\^
H J D9$r1   r  c                       e Zd ZdZd Zy)TickLabellerztAbstract base class which may be used to indicate a change
    in the call signature for callable label formats
    c                      y)NzAbstract class instance calledr*   )rU   rh   r  s      r/   rj   zTickLabeller.__call__  s    /r1   Nrl   rm   rn   ro   rj   r*   r1   r/   r!  r!    s    0r1   r!  c                     d| z  S )Nz%.12gr*   r^   s    r/   r0   r0     s
    7Q; r1   c                      e Zd ZdZ edi d e ee ed      f      d      d eed      d eed	      d
 eed      d eed      d eed      d ee	d      d ee
d      d eed      d e eddd      d      d e eddd      d      d ee	d      d ee	d       d! ee
d"      d# eed$      d% e eddd      d&      d' e eddd      d(      d) ee	d*      d+ eed,      d- eed.      d/ eed0      d1 ee	d2      d3 ee	d4      d5 ed6d7      d8 e ed9d:d;      d<      d= ed6d>      d? ed6d@      dA eedB      dC eedD      dE eedF      dG eedH      dI eedJ      dK e ee ee	dddL      f      dM      dN e ee ee	dddL      f      dO      dP e e ee       eedddL      f      dQ      dR e edSdTdUdV      dW      dX eedY      dZ e ed[d\d]      d^      d_ e edSd`dadT      db      dc eedd      de eedf      dg eedh      di e ed9d:d;      dj      dk eedl      dm ed6dn      do ee	dp      dq ee	dr      ds ee	dt      du ee	dv      dw ee	dx      dy eedz      d{ eed|      d} ee	d       d~ ee
d"      d eed$      d e eddd      d&      d e eddd      d(      d ee	d*      d eed,      d eed.      d ee	d      d ee	d      d ee
d      d ee
d      d eed      d e edSddTd      d      d eed      d eed      d eed      Zd Zd Zd Zd Zi fdZd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#y6)	ValueAxisz(Abstract value axis, unusable in itself.	forceZeronearzEnsure zero in range if true.r  r  r-  r.  r/  r2  r3  r0  r1  r   r4  r   r5  r   r6  r   r7  r   r   rH   r8  r9  r   r:  r   r;  r   r<  r   r=  r   r>  r   r?  r   r@  r   rA  r   rB  r   rC  rD  rE  minimumTickSpacingz)Minimum value for distance between ticks.maximumTickszMaximum number of ticks.rF  NrG  rR  rS  rT  rh   rV  labelTextFormatz3Formatting string or function used for axis labels.labelTextPostFormatzExtra Formatting string.labelTextScalezScaling for label tick values.valueMinzMinimum value on axis.valueMaxzMaximum value on axis.	valueStepzStep size used between ticks.
valueStepsz&List of step sizes used between ticks.avoidBoundFracemptyOKr{   rz   z.Fraction of interval to allow above and below.avoidBoundSpacezSpace to allow above and below.abf_ignore_zerozMSet to True to make the avoidBoundFrac calculations treat zero as non-special
rangeRoundrd  rf  ceilingfloorzHow to round the axis limits
zrangePrefz!Zero range axis limit preference.rN  normalrP  rQ  zHow values are plotted!skipEndLrv   rw   zSkip high/low tick labelsorigShiftIPC"Lowest label shift interval ratio.origShiftMinMinimum amount to shift.origShiftSpecialValuezspecial value for shiftr  z$Like joinAxisMode, but for the ticksrL  rM  r  r^  r_  r`  ra  rb  r   zNumber of axis sub ticks, if >0r  zsub tick down or leftr  zsub tick up or rightr  z Display axis sub ticks, if true.r   zDisplay axis sub grid, if true.r   r   r   r   r   r   r   r   rX  rY  subTickStrokeWidthz Width of sub ticks if specified.subTickStrokeColorz Color of sub ticks if specified.rZ  r[  keepTickLabelsInsidez?Ensure tick labels do not project beyond bounds of axis if truerc  re  rg  rh  requiredRangezMinimum required value range.ri  rj  r<   z*extra values to use in min max calculationc                 "   | j                   j                  dk7  sJ d        | j                  dPi |  | j                  dPi dddddddd	d
ddddddddddddddt        d   dt        d   dt        d   dt        d   dt        d   dddt        d   dt        d   dt        d   dt        d   dt        d   dd dd d d!d"dd#dd$dd%dd&dd't        d   d(t        d   d)t        d   d*dd+t        d   d,t        d   d-d d.d d/t	        t
              d0dd1d2d3d4d5d d6d7d8d d9d d:d d;d d<d d=d d>d d?d d@d!dAdBdCddDdEdFdBdGd dHd dId dJd7dKddLddMddNddOd  d| j                  _        y )QNr&  z%Abstract Class ValueAxis Instantiated_configuredr   rf   rl  rg   r   rm  r  rH   r.  r2  r0  r   r'  r   r   r   r   r   r   r   rn  r   r   r   r   r   r   r   rD  Fr   r  r   r  r  r   r   r   r   r   r   r   r   rF  rD  r)  r  r*     rq  rR  rh   r+  r,  r-  r.  r/  r0  r2  r5  r6  r7  rd  r:  rN  r;  r<  r=  r?  rA  r  rL  r_  ra  rE  r<   r*   )r   rl   r%  r   r   r   rF  r  r&  s     r/   rW   zValueAxis.__init__  s   ~~&&3\5\\3B R	&'R	
  R	  R	 #&R	 #$R	 '(R	 )*R	 ()R	 '(R	 %&R	" '(#R	$ '5]&C%R	& +99J*K'R	( +99I*J)R	* )7(G+R	, ,::L+M-R	. +//R	0 +9*G1R	2 /==N.O3R	4 /==M.N5R	6 -;?,K7R	8 0>>P/Q9R	: %);R	< #'=R	> (-?R	@ *+AR	B +,CR	D &'ER	F %&GR	H %&IR	J 1??O0PKR	L 0>o/NMR	N 3AAS2TOR	P .2QR	R .<M-JSR	T 2@@Q1RUR	V (,WR	X &*YR	Z "9!?[R	\ 01]R	b .0cR	d ()eR	l ,0mR	n )/oR	p +/qR	r /3sR	t *.uR	~ $(R	@ $(AR	B %)CR	D *.ER	F +/GR	H +0IR	J &,KR	L &'MR	N !)OR	P "(QR	R (,SR	T (,UR	V 15WR	X (.YR	Z *+[R	\  !]R	^  !_R	` '(aR	b +/cR	f r1   c                 d    t        |      | _        t        |      | _        t        |      | _        y r)   rt  rv  s       r/   rx  zValueAxis.setPosition.  ry  r1   c                 F    | j                  |       | j                          y)a=  Let the axis configure its scale and range based on the data.

        Called after setPosition. Let it look at a list of lists of
        numbers determine the tick mark intervals.  If valueMin,
        valueMax and valueStep are configured then it
        will use them; if any of them are set to None it
        will look at the data and make some sensible decision.
        You may override this to build custom axes with
        irregular intervals.  It creates an internal
        variable self._values, which is a list of numbers
        to use in plotting.
        N)	_setRange_configure_end)rU   
dataSeriess     r/   r  zValueAxis.configure4  s     	z"r1   c                 R    | j                          | j                          d| _        y r  )r|  _calcScaleFactorrG  rr  s    r/   rL  zValueAxis._configure_endD  s"    ##%r1   c                     	 ||f}||   }|S #  || _         || _        | j                         \  }}|||dz  fx}|<   Y |S xY w)Nr   )	_valueMin	_valueMax_calcStepAndTickPositions)rU   r.  r/  cacheKr=   r0  r+   s           r/   _getValueStepAndTickszValueAxis._getValueStepAndTicksI  sf    	8(#AaA 	8%DN%DN88:KIa$a477Aas	   	 0A c                    | j                   }|dkD  rm||z
  }||k  rcd||z   z  }|dz  }t        ||z
  |      }t        ||z   |      }|dk\  r|dk  r|dz   |z
  }d}n|dk\  r|dk  r||z
  }d}|x}| _        |x}| _        ||fS )Nr   r$  rm  )rE  rA   rE   
_cValueMin
_cValueMax)rU   r.  r/  rrr=   mr   y2s           r/   _preRangeAdjustzValueAxis._preRangeAdjustT  s    a48#At(*+c	2h'2h'S=RVcBBBq[RTbBB-//4?-//4?  r1   c                 \	   | j                   x}}| j                  x}}|)t        || j                  d| j                        x}| _        |)t        || j                  d| j                        x}| _        ||k(  rU|dk(  r<|(|&t        | dd      }|dkD  r|}d}n5|dk  rd}|}n+d}d}n&| j                   d}nd}n|dkD  rd|z  }d}nd}d|z  }t        | dd      rt        t        |d	d            }d
}|||z
  z  }	|	| _
        || _        || j                  z  | _        |	|fd}
|+t        || j                  d|
| j                        x}| _        |+t        || j                  d|
| j                        x}| _        | j                  ||      \  }}| j                  }|}|}| j                   }|r=|dk(  r't#        t%        |      t%        |            d||z
  z  k  }|r|dk  rd}n|dkD  rd}| j&                  }t        | dd       }|xr |}t)        |      s||f}t        | dd      }t)        |      s||f}|dk7  xr |}|r	|dv }|dv }ndx}}| j*                  }|}|rt)        |      s||f}t        | j                        }|xs |xs |}i }d}|r;|dk  r5|dz  }d}|s|r| j-                  |||      \  }}}|r||d   z  }||d   z  }ndx}}|r,||z
  |z  } t/        ||d   | z        }t/        ||d   | z        }|r|d   }!n|}!||z
  }"|d   st%        |!      |kD  r|!|"|z   k\  r|"}d}|r|d   }!n|}!||z   }"|d   st%        |!      |kD  r|!|"|z
  k  r|"}d}|rg| j-                  |||      \  }}}|r&||d   |z
  k  r|d   |z
  }d}n||d   |z   k\  }|d   }|r&||d   |z   kD  r|d   |z   }d}n||d   |z
  k  }|d   }|r|dk  r5|r
|s| _        nd| _        || _        || _        | j6                  }#| j8                  }$|$|#| j:                  }%| j=                          | j4                  | j2                  }}|%t%        |%|z
        dk  rJ|#r|#| j>                  z  }&nd}&|$rt/        |&||z
  |$z  | j                  z        }&| xj2                  |&z  c_        | jA                          y)zSet minimum and maximum axis values.

        The dataSeries argument is assumed to be a list of data
        vectors. Each vector is itself a list or tuple of numbers.

        Returns a min, max tuple.
        Nr   r:  g{Gz?g{Gz333333?        _bubblePlotr8  rn  c                 ~    	 | d   }|||z  dz  z  } || |   |z   | |   |z
        S # t         $ r t        dz  }Y 4w xY w)Nr8  皙?r$  )r   	bubbleMAx)r+   r,   r.   bubbleV	bubbleMaxrL   s         r/   r-   z$ValueAxis._setRange.<locals>.special  s\    &!A AiK#--AaDL1g66 " &!#A&s   ' <<r@   r(  r  r1  r6  Frd  rf  r9  rf  r8  r  rH   r  ư>)!r.  r/  rC   r   r<   rX  rF   rY  r   ru  _bubbleV
_bubbleMaxr   _bubbleRadiusr]  r7  r'  rA   r   r2  r&   r5  rV  rE   _computedValueSteprQ  rR  r=  r?  rA  _calcValueStep
_valueStep_rangeAdjust)'rU   rM  oMinr.  oMaxr/  zrprf  fracre  r-   r7  cMincMaxr'  abfdo_rrdo_abfabfizrrnrrxabSdo_absaLgorT  iterr0  r+   fuzzi0i1sfrL   ur=  r?  rA  r[  s'                                          r/   rK  zValueAxis._setRangeh  s    --'x--'x(:doo^_aeawaw:xxX(:doo^_aeawaw:xxXx{<DL!$|A6C1u#&#$Q#$#&#'#(]]*$H#HA:"8|H"H"H"8|H4d+hz!A67ID(8+,G#DM'DO!%dll!2D)09 7 |(:doo^_ho  CG  CY  CY  ;Z  ZX|(:doo^_ho  CG  CY  CY  ;Z  ZX!11(8D(__
NN	& Hc(m<8HCT@UU	A:xaZA!!Dd33Szs(C.6U|5LEf$. 00C 22CMC#"":3h4<< &f&T2XAIDB%)%?%?(TY%Z"	1d"3q6)B"3q6)BKB"8+R/BRAr	*BRAr	*BAaD"aG!HAtAdF HBAbE"aG!HAtAdF HB%)%?%?(TY%Z"	1d!T	)#$Q4	>%qtDy0#$Q4"d
*#$R5?%quTz1#$R5U T2XV &/D#&*D#!!((((#|'?$($>$>!!!%hH$,4I(4R0STX0X$T__4AAAx0,>t||KLA!#r1   c                     | j                   | _        | j                  | _        t	        | d      r| `| j                          y )N_subTickValues)r.  rQ  r/  rR  rb   r  rL  rr  s    r/   rc   zValueAxis._pseudo_configure
  s4    4()t/Br1   c                      y)zOverride this if you want to alter the calculated range.

        E.g. if want a minumamum range of 30% or don't want 100%
        as the first point.
        Nr*   rr  s    r/   rp  zValueAxis._rangeAdjust  s     	r1   c                      y)zOverride if you want to put slack at the ends of the axis
        eg if you don't want the last tick to be at the bottom etc
        Nr*   rr  s    r/   _adjustAxisTickszValueAxis._adjustAxisTicks  s     	r1   c                     | j                   t        | j                  | j                  z
        z  | _        | j                  S zCalculate the axis' scale factor.
        This should be called only *after* the axis' range is set.
        Returns a number.
        )r   ru  rR  rQ  _scaleFactorrr  s    r/   rO  zValueAxis._calcScaleFactor  s3    
 !LL5$..1P+QQ   r1   c                    t        | dd       }|r
| `|| _        n| j                          | j                  }| j                  }| j
                  }d|z  }| j                  }t        t        |      |z        }||z  }|dv r|||z   kD  r|dz  }n|||z
  k  r|dz  }t        t        |      |z        }||z  }|dv r|||z
  k  r|dz  }n|||z   kD  r|dz  }|t        ||dz         D 	cg c]  }	|	|z  	 c}	fS c c}	w )Nrm  r   rg  rH   rh  )
r   rm  ro  rn  rQ  rR  r7  rJ   ru  r   )
rU   r0  r.  r/  r  r7  r  rL   r  r   s
             r/   rS  z#ValueAxis._calcStepAndTickPositions&  s   D!5d;	''DO!I>>>>I~__
x*+yL))$ax}_bAgbx*+yL++$ax}_bAgbuR1~>!!I+>>>>s   'C7c                 (    | j                         d   S r  )rS  rr  s    r/   _calcTickPositionszValueAxis._calcTickPositions>  s    --/22r1   c                    t        | d      s| j                          | j                  }t        | d      s| j                  j                  }|d d dk(  r	d}t
        }nd}d }|D cg c]  }t        |dd	      s| }}g j                  }t        | j                        }t        |      }	|	d
k  r	g | _
        n|	d
k(  r|d	   |d   z
  }
n7|	dk(  rt        |d	   |d   z
  |d
   |d	   z
        }
n|	d	z  }	||	d	z      ||	   z
  }
|
|z  }| j                  |z   }| j                  |z
  }|d   |kD  r|j                  d|d   |
z
         |d   |k  r|j                  |d   |
z          |
t        |d	z         z  }
t!        |d d       D ]9  \  }	}t#        |      D ]&  }| ||d	z   |
z        z   }||k  s||k\  r ||       ( ; |j$                  | _
        | j                  | _        |S c c}w )Nr\   r  r   r   r   r   c                     | S r)   r*   r^   s    r/   r0   z)ValueAxis._calcSubTicks.<locals>.<lambda>L  s     r1   _doSubTicksrH   r8     r  )rb   rc   r\   r   rl   rJ   r   r  r   r9   r  rE   rQ  rR  insertru  	enumerater   r  )rU   r   r   iFuzzdCnvr   OTVr+   nstr   dstr  vnvxr,   jr   s                    r/   r   zValueAxis._calcSubTicksA  s   tM*""$t,-..))C3Bx&! #C"wr-'B2CCC		Adoo&CCAs&(#a4a&Q-CTc!fSVmCF3q6M:C!GAac(SV+C5y^^D(^^D(q6"9cjj3q6#:6r72:szz#b'#+6uSU|#$S"X. CAa"3Z dAaC9o-b5ArE8!
 '(jj#..
7 Ds   &G"9G"c                     t        | dd      | _        | j                  r| j                  S | j                         | _        | j                          | j                  S )zKCalculate a list of tick positions on the axis.  Returns a list of numbers.r1  N)r   r\   r  r  rr  s    r/   r|  z ValueAxis._calcTickmarkPositionsk  sP    "4T:D$4$44224r1   c                    | j                   o| j                  | j                  z
  }|t        t	        | j
                  dz
        t	        | j                        | j                  z        z  }t        |      | _	        y| j                   | _	        y)8Calculate _valueStep for the axis or get from valueStep.NrH   )
r0  rR  rQ  rA   ru  r*  r   r)  r#   ro  )rU   rawRangerawIntervals      r/   rn  zValueAxis._calcValueSteps  sk    >>!~~6H"St/@/@/B)CU4<<EXY]YpYpEp%rrK-k:DO"nnDOr1   c                 ,    t        | j                        S r)   )rM   r\   rr  s    r/   _allIntTickszValueAxis._allIntTicks|  s    t''((r1   c                    t               }| j                  s|S | j                  }|+| j                  xs | j	                         xr dxs t
        }nB|t        u r| j	                         rd}n't        |d      r|j                  | j                         | j                  }| j                  }| j                  | j                  g}| j                  }| j                         |d|z
  <   | j                   }| j"                  dk7  r\| j$                  r| j                  }n| j                  }| j"                  dk(  r|g}n&||| j&                  z   g}| j"                  dk(  r|d= ng }t)        | j                        }	|	dz
  }
t+        | j                        D ]  \  }}||	z
  }||v r||   }n||   }|s|j,                  s+| j/                  |      }|r|D ]  }t1        ||z
        dk  sd } n |]|||z  }n|}t3        |t              r||z  }n_t5        |      r|t)        |      k  r||   }n@d	}n=t        |d
      r#t3        |t6              r
 || |      }n ||      }nt9        d|z        |r||z  }|||<    |j:                  |  |j=                  |       | j>                  rt3        | t@              r| j                  }|s<|jC                         \  }}}}||k  r"|jE                  |jF                  |z   |z
        }||
k(  rK|| j&                  z   }|jC                         \  }}}}||kD  r"|jE                  |jF                  |z
  |z         }|jI                  |        |S )Nz%.0f
calcPlacesrH   rd  rv   rw   r   ri  r  rj   zInvalid labelTextFormat %s)r  )%r   r2  rq  r+  r  _defaultLabelFormatterstrrb   r  r\   r,  r-  rf   rg   r   r  rF  r<  r  r   r9   r  r  rd   r   r   r&   r!  
ValueErrorr  r  rD  
XValueAxis	getBoundscloner  r   )rU   r   r7   postsclr  r   rF  sknticksnticks1r   tickr  rL   skvr   txta_xr   r   r   r   a_x1s                           r/   r  zValueAxis.makeTickLabels  s4   G!!!8!!9$$b):):)<)G)aKaA#X$++-6qQ|$LL))*''!!ww OO%%'AaC==& ||WWWW}}g%TDLL)==%'1BT%%&1* 0 01 2	!FAdfHEuq	U]]JJt$! "s1u:d? $A!" = H !!S)Q3qs1v:"#A$C"$C :.%a5"#D)C"#A$C()E)IJJ4#:SCF#EOOS)MM#& 00%dJ7"&''C#$161BBB#%8,1KK588c>B;NK,OE 'z'*DLL'8161BBB#%9*/++"T9I+*JEEE%Le2	!h r1   c                     | j                   sJ d       |d}| j                  | j                  f| j                     }| j                  }| j
                  r| }|| j                  z  }|||| j                  z
  z  z   S )zvConverts a numeric value to a plotarea position.
        The chart first configures the axis, then asks it to
        1Axis cannot scale numbers before it is configuredr   )rG  rf   rg   r   r  rL  r   rQ  )rU   r  orgr  s       r/   rd   zValueAxis.scale  s     T!TT=!% ww 1  B4<<CR/000r1   r*   )$rl   rm   rn   ro   r(  r)  r   r   r
   r   r	   r   r   r   r   r   r*  rW   rx  r  rL  rV  r]  rK  rc   rp  r  rO  rS  r  r   r|  rn  r  r  rd   r*   r1   r/   r&  r&    s   . F
 9U6]*C!DKjkF
y/PQF
 #93PQF
 %Y5TU	F

 $I4RSF
 #93PQF
 #82QRF
 #=7VWF
 ''<CcdF
 %U1Qq\7\]F
 &eAal8^_F
 (6\]F
 'x6LMF
 '};QRF
 ++@GhiF
  )q1;ef!F
" *%!A,<gh#F
$  ,H:ef%F
& !6[\'F
( ~4WX)F
* $I4cd+F
, *(9de-F
. $H3MN/F
0 d)EF1F
2 %U6%%?Frs3F
4 't2gh5F
6 +46PQ7F
8 &n;[\9F
:  5MN;F
<  5MN=F
> !6UV?F
@ ""7>fgAF
B &hz([\`aef?g/h&i  qa  bCF
D 'x
8\]abfg@h0i'j  rS  TEF
F 'x	1B:i`aefjkCl0m'n  vE  FGF
H  fVIg FGefIF
J ".7Z[KF
L U8ImDE^_MF
N  fWU6 BIdeOF
P $N9]^QF
R $N9STSF
T !-^B[ \UF
V $E&v$>EklWF
X (	8]^YF
Z #4-BC[F
\ h-YZ]F
^ h-VW_F
` "(1RSaF
b !0GHcF
d !0FGeF
f 'y7YZgF
h &i6WXiF
j *(9OPkF
l *->TUmF
n "..CJk!loF
p  ,E!AaL>hiqF
r !-U1Qq\?j ksF
t #/x=h"iuF
v $N9^_wF
x ".7Z[yF
z 'x6TU{F
| *(9[\}F
~ *->`aF
@ '};YZAF
B  ,I<}~CF
D  fU6( CDmnEF
F %^:YZGF
H %%5<abIF
J ))>EqrKF
HPVp% 
 >@ 	!(`D!?03(T -)Tl1r1   r&  c                       e Zd ZdZ ee eed       eed       edd       e eddd	d
d      d       ee	d            Z
dZd Zd ZddZd Zd Zy)r  zX/value axisr  r  r  NrI  rg  re  r  r  r  rK  )r!  r  r  rx   rp  rJ  r   c                     t        j                  | fi | d| j                  _        d| j                  _        d| j                  _        d| _        d| _        d | _        d | _	        d | _
        y )Nr  r   r  r  )r&  rW   rF  r  r  r  r  r  rx   rp  rJ  r&  s     r/   rW   zXValueAxis.__init__  s\    4%"% # r1   c                     | j                  ddd       | j                  dg       t        dd      }|j                  |        |S )Nr  rl     r  r  rm  rx  r  r   r   r  s     r/   r  zXValueAxis.demo  s@    R%()*C	dr1   c                     t        |       |dk(  r|j                  dz  | _        y|dk(  r"|j                  |j                  z   dz  | _        y|dk(  r|j                  |      dz  | _        y|dk(  r|dz  | _        yy)r  rg  r  re  r  r  Nr  r  s       r/   r  zXValueAxis.joinToAxis  su    U8hhnDGU]xx%--/36DGW_kk#&,DGXCiDG r1   c                     | j                   }|rL| j                  xs d}|dv r| j                  ||       y |dv r| j                  ||| j                         y y y )Nrg  r  r  r  r  r  r  s      r/   r  zXValueAxis._joinToAxis  sb    ]]##/xC''-++$2B2BC ,	 r1   c                    t               }| j                          | j                  s|S t        | j                  | j
                  z
  | j                  | j                  | j                  z   | j                  z   | j                        }| j                  |_	        | j                  |_
        | j                  |_        |j                  |       |S r)   r  r  s      r/   r  zXValueAxis.makeAxis"  r  r1   r  rl   rm   rn   ro   r(  r&  r)  r   r
   r   r*  r   rW   r  r  r  r  r*   r1   r/   r  r    s    Ih+--/*,#E(E7Hd$S\^">=?
H J 
 Dr1   r  )janfebmaraprmayjunjulaugsepoctnovdec)      r  r  r  r  r  r  r  r  r  r  c                     | j                  d      \  }}t        |      }|j                         }t        j	                  |      dz   }|t
        |dz
     k  sJ ||fS )a  This accepts and validates strings like "31-Dec" i.e. dates
    of no particular year.  29 Feb is allowed.  These can be used
    for recurring dates.  It returns a (dd, mm) pair where mm is the
    month integer.  If the text is not valid it raises an error.
    -rH   )splitrJ   lower_monthsindex_maxDays)dmstrdstrmstrddmms        r/   parseDayAndMonthr  ;  s\     S!JD$	TB::<D	t	q	 B"Q$8Or1   c                       e Zd ZdZd Zd Zy)_isListOfDaysAndMonthszThis accepts and validates lists of strings like "31-Dec" i.e. dates
    of no particular year.  29 Feb is allowed.  These can be used
    for recurring dates.
    c                 `    t        |      rd}|D ]  }	 t        |      \  }} |S y#  d}Y xY wr   )r&   r  )rU   r,   answerelementr  r  s         r/   testz_isListOfDaysAndMonths.testN  sF    8F ##-g6FB#
 M	#"Fs   '-c                     |S r)   r*   )rU   r,   s     r/   	normalizez _isListOfDaysAndMonths.normalizeZ  s    r1   N)rl   rm   rn   ro   r  r  r*   r1   r/   r  r  I  s    
r1   r  )rH   r8  r           <   x         i,  ih  i  i  i  iX  i  iH  i  i8  i  i`	  c                      e Zd ZdZ ee eed       eed       eed       eed       ee	d       edd	       e e
ed
dd      d       e e
ed
dd      d       eed       e e e
e            d       eed       e edddd      d            Zej"                  Zd Zd Zd Zd Zd Zd Zd Zy) NormalDateXValueAxiszAn X axis applying additional rules.

    Depending on the data and some built-in rules, the axis
    displays normalDate values as nicely formatted dates.

    The client chart should have NormalDate X values.
    z.Fractional amount used to adjust label spacingr  z$Flag for displaying months 'nicely'.z0Flag for enforced displaying of last date value.z1Flag for enforced displaying of first date value.zList of dates in format "31-Dec","1-Jan".  If present they will always be used for tick marks in the current year, rather than the dates chosen by the automatic algorithm. Hyphen compulsory, case of month optional.Nz3Label format string (e.g. '{mm}/{yy}') or function.r   rH  r3  zWeekday names.r  zMonth names.zATrue if we are to assume daily data to be ticked at end of month.z/Actual tick values to use; no calculations donez@clear rather than delete close ticks when forced first/end datesrd  re  rf  rg  rh  )r!  bottomAxisLabelSlack	niceMonthforceEndDateforceFirstDateforceDatesEachYearxLabelFormatdayOfWeekName	monthName	dailyFreqspecifiedTickDatesspecialTickClearrc  c                     t        j                  | fi | d| _        d| _        d| _        d| _        g | _        d| _        d| _        g d| _	        g d| _
        d| _        d x| _        | _        y )Nrc  rH   r   z	{mm}/{yy})MondayTuesday	WednesdayThursdayFridaySaturdaySunday)JanuaryFebruaryMarchAprilMayJuneJulyAugust	SeptemberOctoberNovemberDecember)r  rW   r  r  r  r  r  r  r  r  r  r  r1  r  r&  s     r/   rW   zNormalDateXValueAxis.__init__}  sv    D&2& %(!"$'kV !488$1r1   c                 H    | j                         }|j                  |       |S )z'Convert a scalar to a NormalDate value.)_valueClassr  )rU   r,   r   s      r/   
_scalar2NDzNormalDateXValueAxis._scalar2ND  s     	Ar1   c                    t        |t        j                        s| j                  |      }t        j                  t        j
                  }}	 | j                  | j                  ct        _        t        _        |j                  | j                        ||ct        _        t        _        S # ||ct        _        t        _        w xY w)z(Create a formatted label for some value.)
r   r   
NormalDater  _dayOfWeekName
_monthNamer  r  formatMSr  )rU   rL   r   r[  s       r/   _dateFormatterz#NormalDateXValueAxis._dateFormatter  s    !J112"A((**?*?1	D?C?Q?QSWSaSa<J%z'<::d//0?@!<J%z'<q!<J%z'<s   AB* *Cc                      j                   } j                  } j                  }t        |t              r fd} j
                  s|d   n | j
                        } j                  s|d   n | j                        } j                  }|j                  |j                  |j                  }
}	}|j                  |j                  |j                  }}}t         ||      j                  d      ||	|
xs d|	z  ||      }t!        |d   |d   |d   |d   |      }|d   |d   z
  }|d   |d   z
  }t#        ||j$                  xs d j&                        }|| j(                  z  z   }g }g } j*                  } j,                  r߉ j,                  D cg c]
  } ||       }}|D cg c]
  } ||       }} j.                  rF||d   k(  r>|t1        |d   |d   z
        z  |d   |d   z
  z  |k  r j2                  rd	|d<   n|d= |d=  j4                  rI||d   k(  rA|t1        |d   |d   z
        z  |d   |d
   z
  z  |k  r j2                  r	d	|d
<   ||fS |d
= |d
= ||fS  j6                  rt9        t;        t<         j6                              }|j?                         }|j?                         }g }g }|}||k  ra|D ]Q  \  }}tA        jB                  |||f      }||k\  s$||k  s*|jE                  |       |jE                   ||             S |dz  }||k  ra j.                  rp||d   k7  rh|jG                  d|       |jG                  d ||             |t1        |d   |d   z
        z  |d   |d   z
  z  |k  r j2                  rd	|d<   n|d= |d=  j4                  rq||d   k7  ri|jE                  |       |jE                   ||             |t1        |d   |d   z
        z  |d   |d
   z
  z  |k  r j2                  r	d	|d
<   ||fS |d
= |d
= ||fS ||||fd}tI        |      }tJ        D ]  }||z  } | |k  s| |z  |k  s|dz
  }! jL                  rC|jO                         |dk  xr |xs dz  }"|"r# j4                  r ||!       d|d   _(        |!|"z  }!	 |jO                         |d   jO                         k(  }#|!|#k\  r ||!       |!|z  }!|!|#k\  r j.                  rX|d   |k7  rP |d       d|d   _(        |t1        |d   |d   z
        z  |d   |d   z
  z  |k  r j2                  rd	|d<   n|d= |d=  j4                  rL jL                  r@"r>|t1        |d   |d   z
        z  |d   |d
   z
  z  |k  r j2                  rd	|d
<   n|d
= |d
= 	 |d   r|d   |d   k(  r|d= |d= ||fc S  tU        d      c c}w c c}w #  d}#Y xY w# tR        $ r Y 1w xY w)zComplex stuff...

        Needs explanation...

        Yes please says Andy :-(.  Modified on 19 June 2006 to attempt to allow
        a mode where one can specify recurring days and months.
        c                 (    j                  |       S r)   )r  )r  rU   s    r/   	formatterz4NormalDateXValueAxis._xAxisTicker.<locals>.formatter  s    **455r1   r   r  
r_  rH   r8  r  r  r  c                 d    |j                  d||           |j                  d |||                 y r   )r  )r   xValsr  ticksrF  s        r/   addTickz2NormalDateXValueAxis._xAxisTicker.<locals>.addTick  s+    LL58$MM!IeAh/0r1   r  z6Problem selecting NormalDate value axis tick positions)+r  r   r  r   r!  r.  r/  rF  fontNamefontSizeleading
textAnchorr  r  r   r  r   rE   r   r)  r  r*  r  r  ru  r  r  r  r4   r5   r  yearr   NDr  r  r9   _NDINTMr  monthr  r   r  )$rU   r  VC
axisLengthr  	firstDateendDaterF  r!  r"  r#  r$  r  r  RBLxLabelWxLabelHr   Wr  r*  r,   r   forcedPartialDates	firstYearlastYearyyyyr  r  theDater   r  r   r   r  wfds$   `                                   r/   _xAxisTickerz!NormalDateXValueAxis._xAxisTicker  s    \\
''	i-6$(MME!Hr$--7H	#'==%)b6G&,oovG('-'8'8&:J:JFLLuI
Yy177=hW4HZ	KAs1vc!fSVUCa&Q-a&Q-)$*A*ABa))))((""$($;$;<qRU<E<,12qil2F2""y%(':
5QVWYQZ[`ab[cQcKd@dglmngopuvwpxgx?y{|?|(( "F1Ia&)  WeBi%7ZeTViX]^_X`N`Ha=adijldmnstvnwdw<xz{<{((!#F2J &=  b	6":&= 
 ""!%c*:D<S<S&T!U "(I||~HEFD (" 2 :HR(mmT2rN;G)+70BW-i&89	:
 	 (" ""y%(':Q	*a	) 45uU2YuQx%78858E!H;LMqP,,$&q	!!HfQi  WeBi%7W%i01uU2YuQx%78859U2Y;NOQRR,,%'r

 &=  ""Ivbz &= "iuV 	1 J  *	%A!A,1Q3*#4aC>>1b5;Q+<"=A,,#AJ12E!H0Q#//+uQx~~/??C fAJFA f &&58Y+>AJ)*E!H("5r58);#<<uQxa?PQSTT00(*F1I %a&)$$A"5r58);#<<uRyr?RSUVV00)+F2J %b	6":ayVAYq	%9!!HfQi f}$U*	%V QRRW =2\C. " s*   W(W	#$WWW	W$#W$c                     | j                   }|D ]=  }t        t        |            D ]$  }||   \  }}t        ||      r ||      |f||<   & ? y)z1Convert all XValues to a standard normalDate typeN)r  r   r9   r   )rU   datar)  r  r   r,   r_   s          r/   
_convertXVzNormalDateXValueAxis._convertXV,  s]      	%A3q6] %t1!!B'qE!9AaD%	%r1   c                 .   | j                   rrg }d}|d   }|D ].  }|j                         }||k7  r|r|j                  |       |}|}0 |d   }|d   k7  r|j                  |       | j                  |      \  }}||fS | j                  |      \  }}||fS )Nr   r  )r  r(  r  r7  )	rU   r  xEOMpmpxr,   r[  stepsrF  s	            r/   _getStepsAndLabelsz'NormalDateXValueAxis._getStepsAndLabels6  s    >>DBqB GGIq54;;r?B rBBx{DKKO --d3ME6 f} !--e4ME6f}r1   c                    | j                  |       t               }|D ]  }|D ]  }|j                  |d            t        |      }|j	                          | j
                  }| j                  |      \  }}| j                  | j                  }	}||d   n ||      }|	|d   n ||	      }	||	c| _	        | _
        || _        || _        | j                  t        |	|z
        z  | _        || _        d| _        y )Nr   r  rH   )r:  setr   r4   sortr  r@  r.  r/  rQ  rR  r\   rq  r   ru  r  rG  )
rU   r9  r  r,   dvr)  r?  rF  r.  r/  s
             r/   r  zNormalDateXValueAxis.configureH  s     	!A !		"Q% !	! U

..u5f!]]DMM( ( 058bl ( 059bl)18&  & LL5H1D+EE r1   )rl   rm   rn   ro   r(  r  r)  r   r   isListOfDaysAndMonthsr   r   r   r   r
   r*  r   r&  r  rW   r  r  r7  r:  r@  r  r*   r1   r/   r  r  a  s    j+H;kl 1WX#I4fg%i6ij)*? Gk l $D/de$Za1%MTde HQ"!KR`a 1tu)&L1I*J  RC  D'	8z{fU6( CDmn
H" --K9"	DKSZ%$r1   r  c                       e Zd ZdZ ee eed       eed       edd       e ed      d       ee	d	      
      Z
dZd Zd ZddZd Zd Zy)
YValueAxiszY/value axisr  r  r	  NrI  r
  r  rK  )r!  r  r  rx   rp  rJ  rH   c                     t         j                  |        d| j                  _        d| j                  _        d| j                  _        d| _        d| _        d | _        d | _	        d | _
        y )Nr6   r  r   r  )r&  rW   rF  r  r  r  r  r  rx   rp  rJ  rr  s    r/   rW   zYValueAxis.__init__p  sW    4  # r1   c                     dg}| j                  ddd       | j                  |       t        dd      }|j                  |        |S )N)r  r  r  *   rm  r  r  r  r  )rU   r9  drawings      r/   r  zYValueAxis.demo~  sE     !b"%t#s#Dr1   c                     t        |       |dk(  r|j                  dz  | _        y|dk(  r"|j                  |j                  z   dz  | _        y|dk(  r|j                  |      dz  | _        y|dk(  r|dz  | _        yyr  r  r  s       r/   r  zYValueAxis.joinToAxis  st    U6>hhnDGW_xx%--/36DGW_kk#&,DGXCiDG r1   c                     | j                   }|rH| j                  }|dv r| j                  ||       y |dv r| j                  ||| j                         y y y r  r  r  s      r/   r  zYValueAxis._joinToAxis  r  r1   c                    t               }| j                          | j                  s|S t        | j                  | j
                  | j                  z
  | j                  | j
                  | j                  z   | j                  z         }| j                  |_	        | j                  |_
        | j                  |_        |j                  |       |S r)   r  r  s      r/   r  zYValueAxis.makeAxis  s    GDGGTWWT[[0$''477T\\;QRVR]R];]^++++#33	dr1   r  r  r*   r1   r/   rG  rG  ]  sz    I02 13*,#E*T$U\^">=?
H J 
 D
r1   rG  c                   6    e Zd ZdZdez  Zdez  Zd Zd Zd Zy)TimeValueAxisr  r  c                 L    | j                   s| j                  | _         i | _        y r)   )r+  timeLabelTextFormatter_saved_tickInforU   argsrV   s      r/   rW   zTimeValueAxis.__init__  s!    ###'#>#>D !r1   c                 :   | j                   | j                  | j                  z
  }|t        t	        | j
                  dz
        t	        | j                        | j                  z        z  }|| j                  k\  r| j                  }d| _	        nO|| j                  k\  r| j                  }d| _	        n,|| j                  k\  r| j                  }d| _	        n	d}d| _	        || _        |dkD  rt        ||z        }t        |      |z  | _        y| j                   | _        y)r  NrH   dayshoursminutesseconds)r0  rR  rQ  rA   ru  r*  r   r)  _dc_unit_hc_mc_unitdrJ   r#   ro  )rU   r  r  r   s       r/   rn  zTimeValueAxis._calcValueStep  s    >>!~~6H"St/@/@/B)CU4<<EXY]YpYpEp%rrKdhh&HH#
(HH$
(HH&
&
DKs!+a-0-k:Q>DO"nnDOr1   c                    | j                   }|t        | j                        f}|| j                  v r| j                  |   }nt	        |      }| j                  D cg c]  }||z  	 }}| j
                  d   }t        |      r||fd}n|D cg c]  }d|z  	 }	}t        d |	D              }
|dk(  r
|d|
z  fd}nx|| j                  k(  rdnd	}|D cg c]  }|t        |      z
  |z   }}t        |      r1|| j                  k(  rd
n|| j                  k(  rdnd}||d||fz  fd}n|d|
|fz  fd}|| j                  |<    ||      S c c}w c c}w c c}w )Nr   c                     d| |z  |fz  S )Nz%.0f%sr*   )r,   ufr   s      r/   r0   z6TimeValueAxis.timeLabelTextFormatter.<locals>.<lambda>  s    H"Qx,? r1   z%.10fc              3   z   K   | ]3  }t        |j                  d             |j                  d      z
  dz
   5 yw)0.rH   N)r9   rstripr  ).0rL   s     r/   	<genexpr>z7TimeValueAxis.timeLabelTextFormatter.<locals>.<genexpr>  s/     L1C.qwws|;A=Ls   9;rH   z%%.%dfsc                     || |z  z  S r)   r*   r,   rb  fmts      r/   r0   z6TimeValueAxis.timeLabelTextFormatter.<locals>.<lambda>  s    sad| r1   r  r  hr[  r   z%%d%s%%d%%sc           	      d    |t        | |z        t        | |z  t        | |z        z
  |z        fz  S r)   rI   )r,   rb  fmrk  s       r/   r0   z6TimeValueAxis.timeLabelTextFormatter.<locals>.<lambda>  sC    PSWZ[\]_[_W`adfghjfjmpqrsuqumvfvxzeza{V|P| r1   z%%.%df%sc                     || |z  z  S r)   r*   rj  s      r/   r0   z6TimeValueAxis.timeLabelTextFormatter.<locals>.<lambda>  s    qQSt r1   )r_  tupler\   rS  ru  r\  rM   rE   r[  rJ   r^  )rU   valr  r   rk  rb  rL   r   r   stvstvlrn  fvs1s                 r/   rR  z$TimeValueAxis.timeLabelTextFormatter  se   KKuT%%&'$$$&&q)CqB $ 0 011!B$1B1

1Ar{#%?,./qw{//LLLa4&(Y-=KC  !$(({B356a1s1v:r/6B6r{$%txxKSQ[cc*,28N|*,tAh1FT&)D  #3x) 2
 0 7s   EEEN)	rl   rm   rn   r^  r]  r[  rW   rn  rR  r*   r1   r/   rP  rP    s(    
C
S&C
S&C"
-2r1   rP  c                       e Zd Zd Zy)XTimeValueAxisc                 h    t        j                  | g|i | t        j                  | g|i | y r)   )r  rW   rP  rT  s      r/   rW   zXTimeValueAxis.__init__  s2    D.$..t1T1D1r1   Nrl   rm   rn   rW   r*   r1   r/   rw  rw    s    2r1   rw  c                       e Zd ZdZ ee eed       eed       eed       e e	ee
f      d       eed            Zd	 Zd
 Zy)AdjYValueAxiszA Y-axis applying additional rules.

    Depending on the data and some built-in rules, the axis
    may choose to adjust its range and origin.
    z+When true add percent sign to label values.r  r>  r@  z8Skip/Keep lowest tick label when true/false.
Or skiplistzadd this to the labels)r!  leftAxisPercentleftAxisOrigShiftIPCleftAxisOrigShiftMinleftAxisSkipLL0labelVOffsetc                     t        j                  | fi | d| _        d| _        d| _        d| _        dx| _        | _        d | _        y )Nr  rH   g333333?r  r   )	rG  rW   rE  r|  r}  r~  r  r  r1  r&  s     r/   rW   zAdjYValueAxis.__init__  sL    D&2& $(!$&!344t0r1   c           	      8   ddl m}m} | j                  | j                  }}| j
                  }t        t        |fdg d            }|s|g}| j                  | j                  }}|r||z
  |k  r{ |||||      dd \  }	}
|
|	z
  |k  rR|	|
z   dz  }t        ||dz  z
  |      }	t        ||dz  z   |      }
|d	k\  r|	d	k  r|
d	z   |	z
  }
d	}	n|dk\  r|	dk  r|
|	z
  }
d}	|	|
c| _        | _         || j                  | j                  d
|| j                  || j                        \  }}| j                  }|r|d
   |d   z
  }t        |      s||z  x}}n||d   z  }||d
   z  }t!        | d|d         }t!        | d|d         }||d   z
  |k  r| j                  |z
  | _        |d   |z
  |k  r| j                  |z   | _         || j                  | j                  d
|| j                  || j                        \  }}|d   | _        |d   | _        || _        | j$                  || _        n| j$                  | _        t)        | j                  d	z
        dk  r|| j+                          | j                  | j                  }}t        | j,                  | j.                  z  ||z
  | j0                  z  | j2                  z        }| j                  |z
  | _        | j4                  r2t        | j4                        r| j4                  D ]  }	 d||<   
 d|d<   yy# t6        $ r Y w xY w)z$Adjusts the value range of the axis.r   )find_good_gridr  c                     | |k  S r)   r*   )r,   r[  s     r/   r0   z,AdjYValueAxis._rangeAdjust.<locals>.<lambda>  s
    ad r1   )r   r  r  rH     	   )r  gridNr8  r$  rm  rH   )r  r  percentr  r  rX  rY  r  ri  r  )reportlab.graphics.charts.utilsr  r  rQ  rR  r*  r4   r8   r0  rE  rA   rE   r|  r  r2  r&   r   r\   r+  rq  r   rn  r}  ro  r~  r   r  r   )rU   r  r  y_miny_maxr[  r  r0  rE  r   r\  ymr+   r   rw  r  r  _nrf   vMaxvMinr,   s                         r/   rp  zAdjYValueAxis._rangeAdjust  sP    	J~~t~~u1*=9:qc!#'>>43E3E=	UU]]:#E51)DRaHFBBw&eS[M#--e4M#--e4#:"S&cBBBAX"Q$bBB-/*DNDNT^^T^^14K_K_en  ~B  ~O  ~O  P1!!A$qt)B:S& RAYAYl1Q40Bl1R51BAaDy2~0Ct~uRx"}t~~/BdnqAtOcOcir  BF  BS  BS  TDAq12'$%D!$($8$8D!t~~c!"4'!$DD--doo=$Y 9 99$,,FHA!^^a/DNT))*-- A!!
 AaD  
 & s   ?L	LLN)rl   rm   rn   ro   r(  rG  r)  r   r   r   r   r*  rW   rp  r*   r1   r/   r{  r{    sg    
 j&y7de+H;_`+H;UV&x?0K'L  TO  P#H3KL
H=r1   r{  c                   $    e Zd Zd Zd Zd Zd Zy)LogValueAxisc                     | j                   t        t        | j                        t        | j                        z
        z  | _        | j
                  S r  )r   ru  
math_log10rR  rQ  r  rr  s    r/   rO  zLogValueAxis._calcScaleFactorG  sD    
 !LL5t~~&DNN)CC,E E   r1   c                    | j                   }| j                  }t        || j                  d| j                        }t        || j                  d| j                        }||}||}||kD  r$t        d| j                  j                  |fz        |dk  r%t        | j                  j                  d|d      | j                  }|rt        |      }t        |      }t        |      s||f}|d   xs d}	|d   xs d}
| j                  |	|
z   z
  }||z
  t        |      z  }||	|z  z  }||
|z  z  }t        |d|z        }t!        |d|z        }|| _        || _        y )Nr   )r<   z7%s: valueMin=%r should not be greater than valueMax=%r!z: valueMin=z! negative values are not allowed!rH   r  )r.  r/  rC   r   r<   rF   r  r   _LogValueAxis__name__valueMinrl   r5  r  r&   r   ru  rA   rE   rQ  rR  )rU   rM  r.  r/  aMinaMaxr}  lMinlMaxa0a1r   r  s                r/   rK  zLogValueAxis._setRangeQ  su   ====
4??1tG]G]^
4??1tG]G]^XXHVZ^ZhZhZyZy  |D  ZE  E  F  FQ;SWSaSaSjSjkstuu""d#Dd#D:S#XsQ1BQ1BR(At)U1X%BBrEMDBrEMD8BH-H8BH-H!!r1   c                 X   t        | j                        x}}t        | j                        x}}| j                  }|r6|dv rt	        |      }||k  r|dz   n|}|dv rt	        |      }||kD  r|dz
  n|}g j
                  }t	        |      }||k  r|dz  }t	        |      |z
  dz   }	t        t	        |	| j                  z        d      }||	z  | j                  kD  r|dz  }|| _        	 ||kD  rn||k\  r |d|z         ||z  }||k7  r
d|z  | _        ||k7  r
d|z  | _        |j                  S )Nrh  rH   rg  r  )
r  rQ  rR  r7  rJ   r  rE   r*  	_powerIncr  )
rU   r.  ru  r/  rv  rZ  r   r+   r   r  s
             r/   r  zLogValueAxis._calcTickPositionsl  sD   $T^^444$T^^444__''M%&xZAEQ%%M%&xZAEQII]h;aMB"Ad'''(+Q3t   !q&!({E8|Qr2vY!GB  T>BL4>T>BL4>zzr1   c                 D   t        | d      s| j                          | j                  }t        | d      sYg j                  }t	        | j
                        }t	        | j                        dz   }t        |      }| j                  }|dk(  rdt        | j                        z  }d}| j                  dk(  rd}||k  rt        || j                        D ]5  }	||	z  d|z  z  }
|
| j
                  kD  s|
| j                  k  s. ||
       7 ||z  }||k  rYnit        | j                  dz   |dz
        }|r||z  dk(  r||z  }n
|dz  }|rd}t        |      }	 d|z  }
|
| j                  k\  rn|
|vr ||
       ||z  }'|j                  | _        | j                  | _        |S )Nr\   r  rH   r  r8  r   )rb   rc   r\   r  r  rQ  rR  roundr  ru  r   r   rA   r  r  )rU   r   r+   r.  r/  r   r   facrv   r  rL   ngs               r/   r   zLogValueAxis._calcSubTicks  s   tM*""$t,-		A!$..1H!$..1!3HxBA!t511??b(!%8m"59 !E2r6Nt~~-!dnn2DaD! !GB 8m *1Q3/B{R!GB	  A8_BADNN*E|!!GB  #$**D..
r1   N)rl   rm   rn   rO  rK  r  r   r*   r1   r/   r  r  E  s    !"68&r1   r  c                       e Zd Zd Zy)LogAxisTickLabellerc                 j    t        |      }t        |dk  r|dz
  n|dz         }|dk(  ry|dk(  ryd|z  S )Nr   MbP?1rH   10z10<sup>%s</sup>)r  rJ   )rU   rh   r  r6   s       r/   rj   zLogAxisTickLabeller.__call__  sC    u1Q3%AeG,a4a4 1$$r1   N)rl   rm   rn   rj   r*   r1   r/   r  r    s    %r1   r  c                       e Zd ZdZd Zy)LogAxisTickLabellerSzZsimple log axis labeller tries to use integers
    and short forms else exponential formatc                     t        |      }t        |dk  r|dz
  n|dz         }|dk(  ry|dkD  rd|dz  z   ndd|z    dz  z   dz   }d|z  }t        |      t        |      k  r|S |S )Nr   r  r  rd  z0.rH   z%.0e)r  rJ   r9   )rU   rh   r  r6   pr   ses          r/   rj   zLogAxisTickLabellerS.__call__  sz    u1Q3%AeG,a41C#I$!A#s
"3C"7e^WSV^r**r1   Nr#  r*   r1   r/   r  r    s    /+r1   r  c                       e Zd Zd Zy)LogAxisLabellingSetupc                 b   t         t        t              | _        | j                  dk(  r4d| j                  _        d| j                  _        d| j                  _        n3d| j                  _        d| j                  _        d| j                  _        t               | _	        y t               | _	        y )NrH   r6   r  r   r  )r"   r   r!   rF  r   r  r  r  r  r+  r  rr  s    r/   rW   zLogAxisLabellingSetup.__init__  sz    )1&9DK!(+%!#!"(+%!"!##6#8D #7#9D r1   Nry  r*   r1   r/   r  r    s    :r1   r  c                   *    e Zd Z ee      Zd Zd Zy)LogXValueAxisr!  c                 X    t         j                  |        t        j                  |        y r)   )r  rW   r  rr  s    r/   rW   zLogXValueAxis.__init__      D!&&t,r1   c                    d}| j                   sJ |       |d}|dk(  r/| j                  | j                  t        | j                        z  z
  S | j                  | j                  t        |      t        | j                        z
  z  z   S zConverts a numeric value to a Y position.

        The chart first configures the axis, then asks it to
        work out the x value for each point when plotting
        lines or bars.  You could override this to do
        logarithmic axes.
        r  r   r`  )rG  rf   r  r  rQ  rU   r  msgs      r/   rd   zLogXValueAxis.scale       B$$=EB;77T..DNN1KKKKww**j.?*T^^B\.\]]]r1   N)rl   rm   rn   r(  r  r*  rW   rd   r*   r1   r/   r  r    s    J'H-^r1   r  c                   *    e Zd Z ee      Zd Zd Zy)LogYValueAxisr  c                 X    t         j                  |        t        j                  |        y r)   )rG  rW   r  rr  s    r/   rW   zLogYValueAxis.__init__  r  r1   c                    d}| j                   sJ |       |d}|dk(  r/| j                  | j                  t        | j                        z  z
  S | j                  | j                  t        |      t        | j                        z
  z  z   S r  )rG  rg   r  r  rQ  r  s      r/   rd   zLogYValueAxis.scale  r  r1   N)rl   rm   rn   r(  rG  r*  rW   rd   r*   r1   r/   r  r    s    J'H-^r1   r  r  )W__version__ro   mathr   r  reportlab.lib.validatorsr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   reportlab.lib.attrmapreportlab.libr   reportlab.graphics.shapesr   r   r   r   r   r   r   r   reportlab.graphics.widgetbaser   r   $reportlab.graphics.charts.textlabelsr   r    r!   r"   r  r#    reportlab.graphics.widgets.gridsr$   reportlab.lib.colorsr%   reportlab.lib.utilsr&   r>   rC   rF   rM   rO   rq   r   r   r   r  r,  r  r  r  r  r  r  r!  r  r&  r  r  r  r  r  rE  r'  r  rG  rP  rw  r{  r  r  r  r  r  r  r*   r1   r/   <module>r     s   	< %G G G G G $ $ } } } I ] ] ; 7 & %
Gab" "<E ENC CJ7 7$jV jXh B66 B6Hee; ;zg ,oGL oboGL ob0 0 / W	1 W	1rI Ij T;Y * /0 
Yz: zxI IV> >D2]: 2
TJ Tli9 iX%, %	+< 	+: : ^L!6z ^0^L!6z ^r1   