U
    '1e                  !   @   s  d Z dZddlmZ ddlT ddlT ddlmZmZ ddl	m
Z
mZmZmZmZmZ ddlmZmZmZ ddlmZ dd	lmZmZmZmZ ddlT dd
lmZmZ ddlm Z m!Z!m"Z" ddl#m$Z$m%Z% ddl&m'Z' ddl(m)Z) G dd deZ*G dd de+Z,G dd deZ-G dd dZ.G dd dZ/G dd de/e"Z0G dd de/eZ1ddl2m3Z3 G dd  d e3Z4G d!d" d"e4Z5d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBg d#dCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dag gZ6G dbdc dce4Z7G ddde dee7Z8G dfdg dge4Z9G dhdi die9Z:djdk Z;G dldm dme4Z<dndo Z=dpdq Z>drds Z?dtdu Z@dvdw ZAdxdy ZBdzS ){z3.3.0z9This module defines a very preliminary Line Plot example.    colors)*)flattenisStr)DrawingGroupRectPolyLinePolygon_SetKeyWordArgs)TypedPropertyCollection
PropHolder
tpcGetItem)Label)
XValueAxis
YValueAxisAdjYValueAxisNormalDateXValueAxis)uSymbol2Symbol
makeMarker)Grid
DoubleGridShadedPolygon)stringWidthgetFont)PlotArea   )FillPairedDatac                   @   sv   e Zd Zeeeddeeddeeddeeddedddd	edd
dd	edddd	eeddee	ddd	d	Z
dS )LinePlotPropertieszWidth of a line.desczColor of a line.zDash array of a line.z,Color of infill defaults to the strokeColor.NzWidget placed at data points.r   r!   ZadvancedUsagezShader Class.zFiller Class.zName of the line.zIf true flood fill to x axis)	strokeWidthstrokeColorstrokeDashArray	fillColorsymbolshaderfillernameinFill)__name__
__module____qualname__AttrMapAttrMapValueisNumberisColorOrNoneZisListOfNumbersOrNoneZisStringOrNone	isBoolean_attrMap r5   r5   G/tmp/pip-unpacked-wheel-109iniqw/reportlab/graphics/charts/lineplots.pyr      s   




r   c                   @   s   e Zd ZdddZdS )InFillValueNc                 C   s   t | |}||_|S N)int__new__yValue)clsvr;   selfr5   r5   r6   r:   &   s    zInFillValue.__new__)N)r,   r-   r.   r:   r5   r5   r5   r6   r7   %   s   r7   c                	   @   s<   e Zd ZeeeeddeeeddddddZ	dd Z
d	S )
ShaderzIf true shade to x axisr       )lohiz(AxisColor, LineColor))BASEverticalr   c                 C   sF   d d g}t | d|p|}|d s2t |dtj|d< |d sB||d< d S )Nr   r   r&   r   )getattrr   Zwhite)r>   lpgrowNorowColorrowcr5   r5   r6   shade1   s      zShader.shadeN)r,   r-   r.   r/   r   r0   r3   Z
SequenceOfr2   r4   rL   r5   r5   r5   r6   r?   +   s
   
r?   c                   @   s   e Zd Zdd ZdS )NoFillerc                 C   s   d S r8   r5   r>   rF   rG   rH   rI   pointsr5   r5   r6   fill8   s    zNoFiller.fillN)r,   r-   r.   rP   r5   r5   r5   r6   rM   7   s   rM   c                   @   sF   e Zd ZdZeeeddeeddeedddZdd Z	d	d
 Z
dS )Fillerz#mixin providing simple polygon fillzfiller interior colorr    zfiller edge colorzfiller edge widthr&   r$   r#   c                 K   s
   || _ d S r8   )__dict__)r>   kwr5   r5   r6   __init__B   s    zFiller.__init__c              
   C   s2   | t|t| d|t| d|t| ddd d S )Nr&   r$   r#   皙?rR   )addr   rE   rN   r5   r5   r6   rP   E   s
    


zFiller.fillN)r,   r-   r.   __doc__r/   r0   r2   isNumberOrNoner4   rU   rP   r5   r5   r5   r6   rQ   ;   s   


rQ   c                   @   s   e Zd ZdS )ShadedPolyFillerNr,   r-   r.   r5   r5   r5   r6   rZ   K   s   rZ   c                   @   s   e Zd ZdS )
PolyFillerNr[   r5   r5   r5   r6   r\   N   s   r\   )AbstractLineChartc                   @   s  e Zd ZdZeeeedddeedddedddedd	dedd
deeddee	ddee	ddedddedddedddedddeddddeedddeeddddZ
dd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zejdd$fd%d&ZdS )'LinePlotzLine plot with multiple lines.

    Both x- and y-axis are value axis (so there are no seperate
    X and Y versions of this class).
    zIf true reverse plot order.r   r"   z,Distance between a data point and its label.Nz(Handle to the list of data point labels.r    z9Formatting string or function used for data point labels.zHexplicit array of line label values, must match size of data if present.z.Display data points joined with lines if true.z.Color used for background border of plot area.0Color used for background interior of plot area.zHandle of the lines.zHandle of the x axis.zHandle of the y axis.z2Data to be plotted, list of (lists of) x/y tuples.z<list of callables, will be called with self, xscale, yscale.z If true use separate line group.z#If true use draw grids before axes.)rC   reversePlotOrderlineLabelNudge
lineLabelslineLabelFormatlineLabelArrayjoinedLinesr$   r&   lines
xValueAxis
yValueAxisdataannotations
behindAxes	gridFirstc                 C   s   t |  d| _t | _t | _ddg| _tt	| _
d| j
_tj| j
d _tj| j
d _tt| _d | _d | _d| _d| _d | _g | _d| _d| _d S )Nr   )r   r   )r@   r@   )      @r   )   ro   )      )r   r@   r@   ro   rn   r@   )ro   rp   rp      r   
   )r   rU   r`   r   rg   r   rh   ri   r   r   rf   r#   r   redr$   bluer   rb   rc   rd   ra   re   _inFillrj   rk   rl   r>   r5   r5   r6   rU   j   s(    


zLinePlot.__init__c                 C   s   t dd}ddg}t }d|_d|_d|_d|_||_d|_d	|_t	j
|_t	j|jd
 _td|jd
 _t	j|jd _td|jd _d
|j_d|j_d|j_d
|j_d|j_d|j_|| |S )z Shows basic use of a line chart.     rm   rr   rs   rt   )g      @rq   ru   2   }   ,  r   %2.0fr   FilledCircleFilledDiamondrq      )r   r^   xyheightwidthri   re   rc   r   blackr$   rx   rf   r   r'   ry   rg   valueMinvalueMax	valueSteprh   rW   )r>   drawingri   rF   r5   r5   r6   demo   s2    

zLinePlot.democ                 C   sP  t | j| _tttt | j| _t }g j}| j	j
}| jj
}| j}t |}t|D ]\}}t|tr|j}	d|	  kr|k rn n$|	|krtd| |||	f ntd||	f g j}
t|D ]@\}}|d }|
t|r|tt|n||||d f q||
j qT|j}|D ]\}}	t|| |	||< qt || _|| _dS )zWorks out where they go.

        Sets an attribute _positions which is a list of
        lists of (x, y) matching the data.
        r   z)data row %r may not be paired with itselfz.data row %r is paired with invalid data row %rr   N)lenri   _seriesCountmaxlistmapZ
_rowLengthsetappendrg   scalerh   	enumerate
isinstancer   other
ValueErrorrW   r   mktimemkTimeTuple__self___pairInFills
_positions)r>   pairsPZxscaleZyscaleri   nrH   rJ   r   linecolNodatumxvr5   r5   r6   calcPositions   s<    


zLinePlot.calcPositionsc           	      C   s   | j }| j| | d }|dkr&d}nht|trR|dkrH| j| | }q|| }n<t|drt|dsp||}q|| ||||}ntd| |r| j||f }|jsdS |dkr|	||| j
  n|	||| j
  || nd}|S )z*Draw a label for a given item in the list.r   Nvalues__call__Z__labelFmtEX__z6Unknown formatter type %s, expected string or functionr   )rc   ri   r   strrd   hasattrr   rb   ZvisibleZ	setOriginra   setText)	r>   rH   r   r   r   labelFmtZ
labelValueZ	labelTextlabelr5   r5   r6   _innerDrawLabel   s.    




 zLinePlot._innerDrawLabelc                 C   s   | | |||| dS )zLDraw a label for a given item in the list.
        G must have an add methodN)rW   r   )r>   GrH   r   r   r   r5   r5   r6   	drawLabel  s    zLinePlot.drawLabelc           )   	      s@  t  }| j}| j}t| dd }|r6t|j|j}|j}| j}| j}t| dd }	| j	 t
 |	s| js fddtt
|D rt|	dd }
|
d kr|j}
n
||
}
|j}||j }t| d|}t| d|}tt
|}| jrt|}|D ]J}|| }| } | }t|dd }t|d	|}t|d
|	}t|dd }t|drP|j}nt drd j}nd }| jr^t|}|st|trt|dd }t|tr|tt||j  }n||
g| ||
g }|r|| |||| n*|t||||kr |nd |p
dd |r,|dks,||kr^t||ddd}|rH||_|rT||_|| t|drr|j}nt dr j}nd }|rN|r| j | }t!|D ]\}} ||f krt ||f d|}!n|}!|!|kr|}"|}#n|!}"t|"d	|}#t"t#|"|| d | d |#}"|"r|r>||| d | d  |"_$||" qn|r^| j | }t!|D ]\}} t ||f dd }!|!sqft|!d	t|!d|}#t"|!| d | d |#}"|"rf|r||| d | d  |"_$||" qft!|D ]$\}$}%|%\}&}'| %|||$|&|' qt|dd }(|(r|(&| |||| q|S )N_bubblePlotrz   c                    s$   g | ]}t  |  d dr|qS )r+   FrE   ).0rH   rf   
styleCountr5   r6   
<listcomp>  s    z&LinePlot.makeLines.<locals>.<listcomp>r;   _inFillG_lineGr$   r&   r+   r%   r#   r)   rV   rR   r@   r   r   )r$   ZstrokeLineCapZstrokeLineJoinr'         ?r(   )'r   rh   rg   rE   minZ_bubbleRadiusZ
_bubbleMaxrc   r   rf   r   r   range_yr   _x_lengthr`   reversedr   r#   re   r   r   r   r   rP   rW   r   r
   r%   r'   ri   r   r   r   sizer   rL   ))r>   rG   yAxA
bubblePlotZbubbleRZ	bubbleMaxr   r   rz   ZinFillYZinFillX0ZinFillX1ZinFillGZlGRrH   rJ   Z
styleRowNorowStyler$   r&   r+   dashr   rO   r)   Zfpointsr   uSymbolZdrowjxyZjuSymbolr'   ZsymColorr   r   x1y1r(   r5   r   r6   	makeLines  s    


 
*
 

 
  zLinePlot.makeLinesc                 C   s4  | j }| j}t| dd r$d |_|_|| j| j| j |rB||_|rL||_|	| j
 |d}|| j| j ks||| jk r| j}n|}|| j|| j |	| j
 |   t }||   | js| jr|  | jrt | _|| j | jrt | _|| j |  |  |jr0|jgp2g }|jrF|jgpHg }t|dd}|d kr|dkr|||j|j  |dkr||j t|dd}|d kr|dkr||j|j  |dkr||j | jr
|j|| |j|d |j|| |j|d ||  ||  | jszt|d	d
}	t|d	d
}
|	s`|j|| |j|d |
sz|j|| |j|d t| dg }|D ]*}t|dd r||| |j|j q||   | js |	r|j|| |j|d |
r |j|| |j|d |D ]*}t|dd s||| |j|j q|S )Nr   r   r   skipGridnone)bothtop)r   Zbottom)parentZdimexcludeZdrawGridLastFrj   beforeLines) rh   rg   rE   r   setPositionr   r   r   joinAxis	configureri   r   r   r   r   rW   makeBackgroundrz   rk   Z_joinToAxisr   r   ZvisibleAxisr   r   r   r   rl   ZmakeGridZgetGridDimsdrawr   )r>   r   r   xAxisCrossesAtr   rG   ZxAexZyAexr   ZxAdglZyAdglrj   ar5   r5   r6   r     s      






    zLinePlot.drawTc           	         sZ   ddl m m fddt| dg D } fdd}||_|| || _d S )Nr   )r   Linec                    s    g | ]}t |d d kr|qS )r*   Nr   )r   r   )r*   r5   r6   r     s      z)LinePlot.addCrossHair.<locals>.<listcomp>rj   c              
      sn   |}|}  }|j }||j||j|j |d |j }|||j||j|j d |S )N)r$   r#   )r   rW   r   r   r   )r>   ZxScaleZyScaler   r   rG   r   r   )r   r   r$   r#   r   yvr5   r6   
annotation  s    $$z)LinePlot.addCrossHair.<locals>.annotation)reportlab.graphics.shapesr   r   rE   r   r   rj   )	r>   r*   r   r   r$   r#   r   rj   r   r5   )r   r   r*   r$   r#   r   r   r6   addCrossHair  s    	
zLinePlot.addCrossHair)r,   r-   r.   rX   r/   r   r0   r3   r1   r2   r4   rU   r   r   r   r   r   r   r   r   r   r5   r5   r5   r6   r^   R   s4   









)'+"sEr^   c                	   @   sn   e Zd ZeeeeddeeddeeddeedddZdZdZ	dZ
d	Zd
d Zdd Zdd Zdd ZdS )
LinePlot3Dzdx/dzr    zdy/dzzdepth of an individual serieszz gap around series)rC   theta_xtheta_yzDepthzSpacer   rw   ro   c                 C   sf   t |  | j}| j}| j}| jjdkr>|| |d |  }n|d|  }| j| | _| j	| | _
d S )Nparallel_3dr   r@   )r^   r   r   r   r   rg   styler   Z_3d_dxr   Z_3d_dy)r>   ZnSeriesr   r   Z	_3d_depthr5   r5   r6   r     s    
zLinePlot3D.calcPositionsc                 C   s.   | j }| jjdkr&|| j|  | }n|}|S )Nr   )r   rg   r   r   )r>   rH   r   z0r5   r5   r6   _calc_z0  s
    zLinePlot3D._calc_z0c                 C   s   ||| j   ||| j  fS r8   )r   r   )r>   r   r   zr5   r5   r6   _zadjust  s    zLinePlot3D._zadjustc           .      C   sX  t | dd }|rtd| j}| j}ttt|}| jrB|  t | dd }|rZtd| j	}| j
}| j}| j}	ddlm}
 |
 }ddlm}m} | jjdkr8t | d	d
}t | dd r2ddlm} tt||}|||d}d }|D ]@\}}}}||kr
|}d}n|d
7 }|| || ||f qd }n|}nd }|}t| j}|D ]}|| }t|}| j||  }|j}t |dd }| |}|| } t|dr|j}!nt| jdr| jj}!nd }!| jr<|r<|| }"|"d \}#}$td
t|"D ]D}%|"|% \}&}'|||#|&|$|'|| ||	|d |d d d dd |&|' }#}$qt|drP|j}(nt| jdrh| jj}(nd }(|(r|D ]T})||% \}&}'||&|'|\}&}'t|(|)d |)d
 |}*|*rv|d
|||&|'|*f qvt|D ]N}%||% \}&}'||&|'|\}&}'|  ||%|&|'}+|+r|d|||&|'|+f qԐqN|!  t" },|# D ]}-|,|-d  q>|,S )Nr   z$_bubblePlot not supported for 3d yetrz   zinFill not supported for 3d yetr   )
_FakeGroup)_make_3d_line_infofind_intersectionsr   Z_3d_tilewidthr   Z_find_intersections)copy)smallr%   r#   rV   )ZfillColorShaded	tileWidthr$   r#   r%   Zshadingr'   r@   )$rE   AssertionErrorrc   r   r   r   r   r`   reverser   r   r   r   $reportlab.graphics.charts.linechartsr   Z!reportlab.graphics.charts.utils3dr   r   rg   r   r   r   insertrf   r$   r   r   r#   re   r'   r   rW   r   sortr   value).r>   r   r   Z	positionsr   r+   r   r   r   r   r   Fr   r   r   r   Z
fpositionsIZicir   r   r   Zjcr   rH   rJ   r   r   rI   r   r   Zz1r   ZfrowZx0Zy0r   r   r   r   r   r'   LrG   r=   r5   r5   r6   r     s     




     
   zLinePlot3D.makeLinesN)r,   r-   r.   r/   r^   r0   r1   r4   r   r   r   r   r   r   r   r   r5   r5   r5   r6   r     s   



r   )i0      Y@)韼0gq"Uo
Y@)c0gt	dY@)0gY@)+0g=hY@)0gkRY@)0g#޺Y@)V0g޴ϙY@)0grwY@)0g_i]^Z@)0g#T[@)0g/+^v[@)J0bȺ[@)0r  )s1gY?[@)1gr[@);1ga:{[@)1g'Q=c[@)1gCU[@)f1gL[@)1gі⠍[@)/	1g`[@)	1g R\@)	1g%^O.\@)Z
1gc3v\@)
1g+m\@)-1g^;[@)-1gP[@)K.1g&}kS\@).1g[@)/1gUP[@)v/1g|\pSe\@)r   r   )r   g333333Y@)r  g     Y@)r  gyY@)r       Y@)r  r  )r  fffffY@)r  r   )r  g33333Y@)r  gffffffZ@)r	  g33333[@)r
  gfffff[@)r  g[@)r  gfffffF\@)r  ǧ[@)r  g33333[@)r  g33333\@)r  gfffff[@)r  g33333S[@)r  g[@)r  g[@)r  fffff&\@)r  gL\@)r  皙y\@)r  g\@)r  g,\@)r  r"  )r  g33333\@)r  g\@)r  r!  )r  gfffff\@c                   @   s   e Zd ZdZdd ZdS )SimpleTimeSeriesPlotzsA customized version of LinePlot.
    It uses NormalDateXValueAxis() and AdjYValueAxis() for the X and Y axes.
    c                 C   s$   t |  t | _t | _t| _d S r8   )r^   rU   r   rg   r   rh   _monthlyIndexDatari   r{   r5   r5   r6   rU     s    
zSimpleTimeSeriesPlot.__init__N)r,   r-   r.   rX   rU   r5   r5   r5   r6   r#    s   r#  c                   @   sH   e Zd ZdZeeedddeedddZdd Z	dd	d
Z
dd ZdS )GridLinePlota  A customized version of SimpleTimeSeriesSPlot.
    It uses NormalDateXValueAxis() and AdjYValueAxis() for the X and Y axes.
    The chart has a default grid background with thin horizontal lines
    aligned with the tickmarks (and labels). You can change the back-
    ground to be any Grid or ShadedRect, or scale the whole chart.
    If you do provide a background, you can specify the colours of the
    stripes with 'background.stripeColors'.
    Nz3Background for chart area (now Grid or ShadedRect).r    z&Scalefactor to apply to whole drawing.)rC   
backgroundscaleFactorc                 C   sR   ddl m} t|  d | _t | _d| j_d| j_d| j_	d| j_
|j| j_d S )Nr   r   
horizontalr   r   )reportlab.libr   r#  rU   r'  r   r&  orientationZuseRectsZuseLinesr#   r   r$   )r>   r   r5   r5   r6   rU     s    
zGridLinePlot.__init__c                 C   sR  ddl m} |stdd}t }d|_d|_d|_d|_t|_	d|_
|j|_|jd	d
dddd	d}||jd _d|jd _d |jd _|jdddddd	d}||jd _d|jd _ddg|jd _d|jj_d|jj_d|jj_d|jj_d|jj_d|jj_d|j_d|j_d|j_d|jj_t |_|j|j g|j_!d|j_"|#|d |S )Nr   r   r|   r}   r   r   r   r   d   A      zPANTONE 288 CV)ZspotNameZdensityr@   O   [   zPANTONE Wm Red CVro   rw   startwiiz	{mm}/{yy}z%5d%% rq   rD   Zplot)$r)  r   r   r%  r   r   r   r   r$  ri   re   r   r$   Z
PCMYKColorrf   r#   r%   rg   labelsfontSizeZ
textAnchor	boxAnchorangledxdyZxLabelFormatrh   labelTextFormattickLeftr   r&  ZpinkZ	lightblueZstripeColorsr*  rW   )r>   r   r   rF   Zc0Zc1r5   r5   r6   r     sD    







zGridLinePlot.democ                 C   s  | j | j }}|r||_|r"||_|| j| j| j || j |	d}|| j| j ksf|| jk rn| j}n|}|| j|| j
 || j | j}t|trz|jdkr|jrtt|j	|jg|j }g }tt|d D ]}|||d  ||   q||_nj|jdkr|jrtt|j	|jg|j }	g }tt|	d D ] }||	|d  |	|   qN||_nt|tr| j|j_| j|j_| j
|j_
| j|j_| j|j_| j|j_| j
|j_
| j|j_|jjdkrF|jrFtt|j	|jg|j }g }tt|d D ] }|||d  ||   q||j_nn|jjdkr|jrtt|j	|jg|j }	g }tt|	d D ] }||	|d  |	|   q||j_|jjdkr$|jr$tt|j	|jg|j }g }tt|d D ] }|||d  ||   q||j_nn|jjdkr|jrtt|j	|jg|j }	g }tt|	d D ] }||	|d  |	|   qh||j_|   | j
| j| j  }
}}|r|dkr|dd|ddf|_nt }||   || j  || j ||    |S )Nr   rD   r   r(  )!rg   rh   r   r   r   r   r   r   ri   r   r   r&  r   r   r*  Z_tickValuesr   r   Z	_valueMinr   r   r   Z
deltaStepsr   Zgrid0Zgrid1r   r'  Z	transformr   rW   r   r   )r>   ZxvaZyvar   r   backZxposZstepsr   Zyposr   r   r'  rG   r5   r5   r6   r     s      











zGridLinePlot.draw)N)r,   r-   r.   rX   r/   r^   r0   rY   r4   rU   r   r   r5   r5   r5   r6   r%    s   	


$r%  c                   @   s    e Zd ZdZdd Zdd ZdS )AreaLinePlotz@we're given data in the form [(X1,Y11,..Y1M)....(Xn,Yn1,...YnM)]c                 C   s&   t |  d| _d| _dddg| _d S )Nr   )r      r+  r-  )r@      r      )ro   r>  F   (   )r^   rU   rz   r`   ri   r{   r5   r5   r6   rU   D  s    
zAreaLinePlot.__init__c                 C   s   z| j }t|}t|d }|dg }g | _ td|D ]T}g }t|D ]6}|| || |  ||< ||| d || f qF| j | q6t| W S || _ X d S )Nr   r   )ri   r   r   r   r^   r   )r>   odatar   mSr   Dr   r5   r5   r6   r   J  s    
zAreaLinePlot.drawN)r,   r-   r.   rX   rU   r   r5   r5   r5   r6   r;  B  s   r;  c                   @   s   e Zd Zdd ZdS )SplitLinePlotc                 C   s
  t |  t | _t | _ddddddddd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddg| _d | j_d| j_d| j_	d| j_
tdʡ| jd _tdˡ| jd _td͡| jd _d S )N)i1ffffff?皙?        )i1rF  rG  rH  )iQ1rF  rG  rH  )i1rF  rG  rH  )i1rF  rG  rH  )i}1rF  rG  rH  )i1rF  rG  rH  )i1rF  rG  rH  )i	1rF  rG  rH  )im1rF  rG  rH  )i1rF  rG  rH  )i51rF  rG  rH  )i1rF  rG  rH  )i1rF  rG  rH  )ia1rF  rG  rH  )i1rF  rG  rH  )i)1rF  rG  rH  )i1rF  rG  rH  )i1rF  rG  rH  )i1rF  rG  rH  )i1rF  rG  rH  )i}1rF  rG  rH  )i1rF  rG  rH  )iE1rF  rG  rH  )i1rF  rG  rH  )i1rF  rG  rH  )iq1rF  rG  rH  )i1rF  rG  rH  )i91rF  rG  rH  )i1rF  rG  rH  )i1rF  rG  rH  )i2rF  rG  rH  )i)2rF  rG  rH  )i2rF  rG  rH  )i2rF  rG  rH  )iU2rF  rG  rH  )i2rF  rG  rH  )i2rF  rG  rH  )i2rF  rG  rH  )i2rF  rG  rH  )iI2rF  rG  rH  )i2rF  rG  rH  )i2rF  rG  rH  )i>2rF  rG  rH  )i9?2rF  rG  rH  )i?2rF  rG  rH  )i@2rF  rG  rH  )ie@2rF  rG  rH  )i@2rF  rG  rH  )i-A2rF  rG  rH  )iA2rF  rG  rH  )iA2rF  rG  rH  )iYB2rF  rG  rH  )iB2rF  rG  rH  )i!C2rF  rG  rH  )ie2rF  rG  rH  )iIf2rF  rG  rH  )if2rF  rG  rH  )ig2rF  rG  rH  )iug2rF  rG  rH  )ig2rF  rG  rH  )i=h2rF  rG  rH  )ih2rF  rG  rH  )ii2rF  rG  rH  )iii2rF  rG  rH  )ii2rF  rG  rH  )i1j2rF  rG  rH  )i2rF  rG  rH  )iY2Q?
ףp=
?rH  )i2rI  rJ  rH  )i!2rI  rJ  rH  )i2rI  rJ  rH  )i2rI  rJ  rH  )iM2rI  rJ  rH  )i2rI  rJ  rH  )i2rI  rJ  rH  )iy2rI  rJ  rH  )iݐ2rI  rJ  rH  )iA2rI  rJ  rH  )i2rI  rJ  rH  )ii2Q?RQ?rH  )iʹ2rK  rL  rH  )i12rK  rL  rH  )i2rK  rL  rH  )i2rK  rL  rH  )i]2rK  rL  rH  )i2rK  rL  rH  )i%2rK  rL  rH  )i2rK  rL  rH  )i2rK  rL  rH  )iQ2rK  rL  rH  )i2rK  rL  rH  )iy2
ףp=
?Q?rH  )i2rM  rN  rH  )iA2rM  rN  rH  )i2rM  rN  rH  )i	2rM  rN  rH  )im2rM  rN  rH  )i2rM  rN  rH  )i52rM  rN  rH  )i2rM  rN  rH  )i2rM  rN  rH  )ia2rM  rN  rH  )i%3rM  rN  rH  )i3(\?Gz?rH  )i3rO  rP  rH  )iQ3rO  rP  rH  )i3rO  rP  rH  )i3rO  rP  rH  )i}3rO  rP  rH  )i3rO  rP  rH  )iE3rO  rP  rH  )i3rO  rP  rH  )i3rO  rP  rH  )iq3rO  rP  rH  )i5)3rO  rP  rH  )i)3)\(?Q?rH  )i)3rQ  rR  rH  )ia*3rQ  rR  rH  )i*3rQ  rR  rH  )i)+3rQ  rR  rH  )i+3rQ  rR  rH  )i+3rQ  rR  rH  )iU,3rQ  rR  rH  )i,3rQ  rR  rH  )i-3rQ  rR  rH  )i-3rQ  rR  rH  )iEP3rQ  rR  rH  )iP3
ףp=
?r   Q?)iQ3rS  r   rT  )iqQ3rS  r   rT  )iQ3rS  r   rT  )i9R3rS  r   rT  )iR3rS  r   rT  )iS3rS  r   rT  )ieS3rS  r   rT  )iS3rS  r   rT  )i-T3rS  r   rT  )iT3rS  r   rT  )iUw3rS  r   rT  )iw3333333?=
ףp=?(\?)ix3rU  rV  rW  )ix3rU  rV  rW  )ix3rU  rV  rW  )iIy3rU  rV  rW  )iy3rU  rV  rW  )iz3rU  rV  rW  )iuz3rU  rV  rW  )iz3rU  rV  rW  )i={3rU  rV  rW  )i{3rU  rV  rW  )ie3rU  rV  rW  )iɞ3p=
ף?rS  RQ?)i-3rX  rS  rY  )i3rX  rS  rY  )i3rX  rS  rY  )iY3rX  rS  rY  )i3rX  rS  rY  )i!3rX  rS  rY  )i3rX  rS  rY  )i3rX  rS  rY  )iM3rX  rS  rY  )i3rX  rS  rY  )iu3rX  rS  rY  )i3皙?rU  r   )i=3rZ  rU  r   )i3rZ  rU  r   )i3rZ  rU  r   )ii3rZ  rU  r   )i3rZ  rU  r   )i13rZ  rU  r   )i3rZ  rU  r   )i3rZ  rU  r   )i]3rZ  rU  r   )i3rZ  rU  r   )i3rZ  rU  r   )i3p=
ף?Gz?r   )iM3r[  r\  r   )i3r[  r\  r   )i3r[  r\  r   )iy3r[  r\  r   )i3r[  r\  r   )iA3r[  r\  r   )i3r[  r\  r   )i	3r[  r\  r   )im3r[  r\  r   )i3r[  r\  r   )i4r[  r\  r   )i4rV   皙?r   )i]4rV   r]  r   )i4rV   r]  r   )i%4rV   r]  r   )i4rV   r]  r   )i4rV   r]  r   )iQ4rV   r]  r   )i4rV   r]  r   )i4rV   r]  r   )i}4rV   r]  r   )i4rV   r]  r   )i:4rV   r]  r   r   i3  iÙ r   i3  r@   )r;  rU   r   rg   r   rh   ri   ZrequiredRangeZleftAxisPercentZleftAxisOrigShiftMinZleftAxisOrigShiftIPCr   toColorrf   r$   r{   r5   r5   r6   rU   \  s    
 zSplitLinePlot.__init__N)r,   r-   r.   rU   r5   r5   r5   r6   rE  [  s   rE  c                 C   sH   t | ttfs| f} dd | D } | rDtttt||fdd| pFdS )z0return max stringWidth for the list of strings Tc                 S   s   g | ]}|r|qS r5   r5   )r   _fr5   r5   r6   r   l  s      z_maxWidth.<locals>.<listcomp>c                 S   s   || ||S r8   r5   )tZsWZfNZfSr5   r5   r6   <lambda>m      z_maxWidth.<locals>.<lambda>r   )r   tupler   r   r   r   )TfontNamer3  r5   r5   r6   	_maxWidthi  s     rf  c                   @   s   e Zd ZdZeeeeddeeddeeddee	ddee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ddeeddeedddZdd Zdd ZdddZdd ZdS ) ScatterPlotzA scatter plot widgetz!Width of the area inside the axesr    z"Height of the area inside the axesz/Is there an outer border (continuation of axes)zColor of outer border (if any)z.Space between label and Axis (or other labels)r   r"   zLenth of the ticks on both axeszStroke width for both axeszLabel for the whole X-AxiszLabel for the whole Y-Axisz#Data points - a list of x/y tuples.z#Color used for border of plot area.r_   zPadding on left of drawingzPadding on right of drawingzPadding at top of drawingzPadding at bottom of drawing)rC   r   r   outerBorderOnouterBorderColorZlabelOffsetZaxisTickLengthsZaxisStrokeWidthxLabelyLabelri   r$   r&   leftPaddingrightPadding
topPaddingbottomPaddingc                 C   s  t |  d| _d| _d| _tj| _d | _d}d}d}d | j	_
d | j	_d | j	_d| j	_d| _d	| jj_d
| _d	| j	j_dddg| _d| _d| _d| _d| _d| _| j| |d  | _| jtt| j	j| j	jj| j	jj | _| j| | | jjj | _| | jj_|| j_|| j_ d| j_!| | j	j_"|| j	_#|| j	_ d| j	_!d| _$d| j%_d| j%_&d| j%_"d| _'t(ddd| j)_*t(ddd| j)d _*t(ddd| j)d _*tj+| j)d _,d S )N   M   r   ro   r@   r   z%szX Lablerv   zY Lable))gQ?g=
ףp]O@)gl?gX9v.K@)g~jt?gX91@))g(\?gˡE='@)gx&1?g rhI@)g+?gE<Q@))gv?gFԸU@)gMb?g
ףp=A@)gK7A?gfffffB@r   rq   rw   r   z%.2fer   )r   r   ZFilledSquare)-r^   rU   r   r   rh  r   r   ri  r&  rh   r   r   r   r8  rj  rg   r2  r3  rk  ri   re   rl  rm  rn  ro  r   rf  r   re  r   r7  tickDownr#   Z
rangeRoundr6  r9  rc   rb   r4  ra   r   rf   r'   Zgreenr$   )r>   Z_labelOffsetZ_axisTickLengthsZ_axisStrokeWidthr5   r5   r6   rU     s\    


(zScatterPlot.__init__c                 C   s   | j | jj | jjjd  | jjj }|dtt| jj	| jjj
| jjj  }|| j | j }d| jj	 }|t|| jjj
| jjj }| j| jj | jjjd  | jjjd  }|| jjj | j | j }||fS )Nr@   rq   z%.2f%%)rl  rh   r9  r2  r6  rg   r3  rf  r   r   re  r   rm  ro  rt  r7  r   rn  )r>   txr`  tyr5   r5   r6   _getDrawingDimensions  s    &(*z!ScatterPlot._getDrawingDimensionsNc                 C   s,   |s|   \}}t||}||   |S r8   )rw  r   rW   r   )r>   r   ru  rv  r5   r5   r6   r     s
    
zScatterPlot.democ                 C   s*  t | jjjjj}|dkrd}|| jjj }t| }| j	}|rt
 }| j| j d |_d|_| jjj|_| jjj|_|| || | j}|rt
 }d|_d|_| j| jd  |_| jjj|_| jjj|_|| || | jr|t| j| j| j| j| j| jjd d || j| j |S )Nr   g`"?g       @Z   )r$   r#   r&   )r   rg   r2  re  faceascentr3  r^   r   rj  r   r   r   r   r   rW   rk  r5  r   rh   rh  r	   ri  r#   shiftrl  ro  )r>   rz  rF   rj  Zxlrk  Zylr5   r5   r6   r     s@    




zScatterPlot.draw)N)r,   r-   r.   rX   r/   r^   r0   r1   r3   r2   ZisStringZ
isAnythingr4   rU   rw  r   r   r5   r5   r5   r6   rg  o  s.   














B
rg  c                  C   s   t dd} ddg}t }d|_d|_d|_d|_||_d|_tj	|_
td	|j_d
|jd _d|jd _d|j_d|j_d|j_d|j_d|j_d|j_| | | S )2A line plot with non-equidistant points in x-axis.r|   r}   rm   r~   r   r   r   r   ZUK_Flagr@   r   rp   rq   r   )r   r^   r   r   r   r   ri   re   r   r   r$   r   rf   r'   r#   rg   r   r   r   rh   rW   r   ri   rF   r5   r5   r6   sample1a  s.    

r~  c                  C   s   t dd} ddg}t }d|_d|_d|_d|_||_d|_td	|j	_
d
|_tj|_d|j_d|j_ddddddg|j_d|j_d|j_d|j_d|j_| | | S )r|  r|   r}   rm   r~   r   r   r   r   Circler   r   rq   r@   rn   ro   rp   %2.1fr   )r   r^   r   r   r   r   ri   re   r   rf   r'   rc   r   r   r$   rg   r   r   
valueStepsr8  rh   r   rW   r}  r5   r5   r6   sample1b(  s.    

r  c                  C   s   t dd} ddg}t }d|_d|_d|_d|_||_d|_td	|j	d
 _
td|j	d _
d|_tj|_d
|j_d|j_ddddddg|j_d|j_d
|j_d|j_dddddg|j_| | | S )r|  r|   r}   rm   r~   r   r   r   r   r   r   r  r   rq   r@   rn   ro   rp   r  r   rv   )r   r^   r   r   r   r   ri   re   r   rf   r'   rc   r   r   r$   rg   r   r   r  r8  rh   rW   r}  r5   r5   r6   sample1cL  s0    

r  c                 C   s   dd | D S )z=Convert date strings into seconds and multiply values by 100.c                 S   s$   g | ]}t |d  |d d fqS )r   r   r+  )Zstr2seconds)r   r   r5   r5   r6   r   t  s     z"preprocessData.<locals>.<listcomp>r5   )Zseriesr5   r5   r6   preprocessDataq  s    r  c            
      C   s*  t dd} dg}t|d |d< t }d|_d|_d|_d|_||_d|_t	d	|j
_tj|_ttd
}ttd}ttd}ttd}ttd}ttd}ttd}	||j_|	|j_|||||||	g|j_t|j_d|jjd _d|jjd _d|j_d|j_d|j_d|j_| | | S )r|  r|   r}   ))
25/11/1991r   )
30/11/1991gea?)
31/12/1991ga+e?)z
31/01/1992gvq-?)z
29/02/1992gm4@?)
31/03/1992gyT?)z
30/04/1992g )
k?)z
31/05/1992gcȎ{?)
30/06/1992gy,?)z
31/07/1992gQ צ?)z
31/08/1992g[B>٬?)
30/09/1992gY)?)z
31/10/1992g~@?)z
30/11/1992g30?)
31/12/1992g`"?r   r   r   r   r   r   r  r  r  r  r  r  r  iir@   z%4.2fr+  n   )r   r  r^   r   r   r   r   ri   re   r   rf   r'   r   r   r$   r   r   rg   r   r   r  Zseconds2strr8  r2  r7  rh   r   rW   )
r   ri   rF   r0  t0t1t2t3Zt4endr5   r5   r6   sample2w  s@    

r  c                  C   sn   t dd} t }| | t|jd d|jd g|_ttddd d|jd _	d |jd _
d |jd _
| S )Nr|   r}   r   r   z#9f9f9f)r&   r#   r$   )r   r#  rW   r   ri   rQ   r   r^  rf   r)   r$   )dZchartr5   r5   r6   sampleFillPairedData  s    

r  N)C__version__rX   r)  r   Zreportlab.lib.validatorsZreportlab.lib.attrmapZreportlab.lib.utilsr   r   r   r   r   r	   r
   r   r   Zreportlab.graphics.widgetbaser   r   r   Z$reportlab.graphics.charts.textlabelsr   Zreportlab.graphics.charts.axesr   r   r   r   Zreportlab.graphics.charts.utilsZ"reportlab.graphics.widgets.markersr   r   Z reportlab.graphics.widgets.gridsr   r   r   Zreportlab.pdfbase.pdfmetricsr   r   Zreportlab.graphics.charts.areasr   utilsr   r   r9   r7   r?   rM   rQ   rZ   r\   r   r]   r^   r   r$  r#  r%  r;  rE  rf  rg  r~  r  r  r  r  r  r5   r5   r5   r6   <module>   s         A
  &$%<