o
    ȷe*                    @   s   d dl Z d dlZd dlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
 ddlmZ dd	lmZ dd
lmZ ddlmZ G dd dejZdS )    Nwarn   )Shape)	xmlwriter)get_rgb_color)xl_rowcol_to_cell)xl_range_formula)supported_datetime)datetime_to_excel_datetime)quote_sheetnamec                       s  e Zd ZdZd fdd	ZdddZdd Zd	d
 Zdd Zdd Z	dddZ
dd Zdd Zdd Zdd Zdd Zdd ZdddZddd Zdd!d"Zdd#d$Zdd%d&Zdd'd(Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Z d=d> Z!d?d@ Z"dAdB Z#ddCdDZ$dEdF Z%dGdH Z&dIdJ Z'dKdL Z(dMdN Z)dOdP Z*dQdR Z+dSdT Z,dUdV Z-dWdX Z.dYdZ Z/d[d\ Z0d]d^ Z1d_d` Z2dadb Z3dcdd Z4dedf Z5dgdh Z6didj Z7dkdl Z8dmdn Z9dodp Z:dqdr Z;dsdt Z<dudv Z=dwdx Z>dydz Z?d{d| Z@d}d~ ZAdd ZBdd ZCdd ZDdd ZEdd ZFdd ZGdd ZHdd ZIdd ZJdd ZKdd ZLdd ZMdd ZNdd ZOdd ZPdd ZQdd ZRdd ZSdd ZTdddZUdd ZVdddZWdd ZXdd ZYdddZZdd Z[dd Z\dd Z]dd Z^dd Z_dd Z`dd Zadd ZbdddZcdddĄZdddƄ ZeddȄ Zfddʄ Zgdd̄ Zhdd΄ ZiddЄ Zjdd҄ ZkddԄ Zlddք Zmdd؄ ZndddۄZo	ِddd݄Zpdd߄ Zqdd Zrdd Zsdd Ztdd Zudd Zvdd Zwdd Zxdd Zydd Zzdd Z{dd Z|dd Z}dd Z~dd ZdddZdd Zd d Zdd Zdd Zdd Zdd	 Zd
d Z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dd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; Zd<d= Zd>d? Zd@dA ZdBdC ZdDdE ZdFdG ZdHdI ZdJdK ZdLdM ZdNdO ZdPdQ ZdRdS ZdTdU ZdVdW ZdXdY ZdZd[ Zd\d] Zd^d_ Zd`da Zdbdc Zddde Zdfdg Zdhdi Zdjdk Zdldm Zdndo Zdpdq Zdrds Zdtdu Zdvdw Zdxdy Zdzd{ Zd|d} Zd~d Zdd Zdd ZÐdd ZĐdd ZŐdd ZƐdd Zǐdd ZȐdd Zɐdd Zʐdd Zːdd Z̐dd Z͐dd Zΐdd Zχ  ZS (  Chartz:
    A class for writing the Excel XLSX Chart file.


    Nc                    s  t t|   d| _d| _d| _g | _d| _d| _d| _	d| _
g | _g | _d| _d| _i | _d| _d| _i | _g | _d| _d	| _d| _i | _i | _i | _i | _i | _i | _d
| _d| _d| _d	| _ d| _!d| _"d	| _#d	| _$d| _%d| _&d| _'d| _(d| _)d| _*d| _+d| _,d| _-d| _.d| _/d| _0d| _1d| _2d| _3d| _4d| _5d| _6d| _7d| _8d| _9d| _:d| _;i | _<d
| _=d| _>d| _?d| _@d| _A| B  dS )z
        Constructor.

        Ni   r      Fblr    gapi  i   betweenT)Csuperr   __init__subtype
sheet_typeorientationseriesembeddedidseries_indexstyle_idaxis_ids	axis2_idscat_has_num_fmtrequires_categorylegendcat_axis_positionval_axis_positionformula_idsformula_datahoriz_cat_axishoriz_val_axis
protection	chartareaplotareax_axisy_axisy2_axisx2_axis
chart_nameshow_blanksshow_hiddenshow_crosseswidthheightx_scaley_scalex_offsety_offsettablecross_betweendefault_markerseries_gap_1series_gap_2series_overlap_1series_overlap_2
drop_lineshi_low_linesup_down_barssmooth_allowed
title_font
title_nametitle_formulatitle_data_idtitle_layouttitle_overlay
title_nonedate_category	date_1904remove_timezonelabel_positionslabel_position_defaultalready_insertedcombinedis_secondarywarn_sheetname_set_default_propertiesselfoptions	__class__ G/var/www/ideatree/venv/lib/python3.10/site-packages/xlsxwriter/chart.pyr   #   s   zChart.__init__c                 C   s  |du ri }d|vrt d dS | jrd|vrt d dS t| jdkr*t d dS | |d}| |d}| |d|d	\}}| ||d
}| ||d}| ||d}t	|d}	|drwt	|d }	t
|d}
t|d}t|d}|rd| _|rd}d}
| |d}| |d}|d}| |d}| |d}||d}| |d}| |d}|dd}|d}|d}|s|rd| _|ddur|r|d | _n|d | _|d r|r|d  | _n|d  | _i d|d|d|d	|d!|d"|d#|d|	d|
d|d|d|d|d$|d%|d|d||||d&}| j| dS )'z
        Add a data series to a chart.

        Args:
            options:  A dictionary of chart series options.

        Returns:
            Nothing.

        Nvaluesz%Must specify 'values' in add_series()
categoriesz=Must specify 'categories' in add_series() for this chart type   zGThe maximum number of series that can be added to an Excel Chart is 255namename_formulacategories_datavalues_data	name_datalineborderfillpatterngradientmarker	trendlinesmoothy_error_barsx_error_bars)ro   rn   pointsdata_labelsinvert_if_negativeFr0   r/   Tr   overlapname_idval_data_idcat_data_idlabelsinvert_if_neg)rp   
error_barsrm   )r   r"   lenr   _list_to_formulaget_process_names_get_data_idr   _get_line_properties_get_fill_properties_get_pattern_properties_get_gradient_propertiesrh   _get_marker_properties_get_trendline_properties_get_error_bars_props_get_points_properties_get_labels_propertiesrT   r?   r>   rA   r@   append)rX   rY   r^   r_   ra   rb   cat_idval_idrt   rf   rh   ri   rj   rk   rl   rm   rn   ro   ry   rp   rw   rx   r0   r/   r   r\   r\   r]   
add_seriesl   s   





	
zChart.add_seriesc                 C      |  | j|}|| _dS )z
        Set the chart X axis options.

        Args:
            options:  A dictionary of axis options.

        Returns:
            Nothing.

        N)_convert_axis_argsr-   rX   rY   axisr\   r\   r]   
set_x_axis      
zChart.set_x_axisc                 C   r   )z
        Set the chart Y axis options.

        Args:
            options: A dictionary of axis options.

        Returns:
            Nothing.

        N)r   r.   r   r\   r\   r]   
set_y_axis  r   zChart.set_y_axisc                 C   r   )z
        Set the chart secondary X axis options.

        Args:
            options: A dictionary of axis options.

        Returns:
            Nothing.

        N)r   r0   r   r\   r\   r]   set_x2_axis  r   zChart.set_x2_axisc                 C   r   )z
        Set the chart secondary Y axis options.

        Args:
            options: A dictionary of axis options.

        Returns:
            Nothing.

        N)r   r/   r   r\   r\   r]   set_y2_axis&  r   zChart.set_y2_axisc                 C   s   |du ri }|  |d|d\}}| ||d}|| _|| _|| _| |d| _| |dd| _	|d| _
|d	| _dS )
z
        Set the chart title options.

        Args:
            options: A dictionary of chart title options.

        Returns:
            Nothing.

        Nra   rb   data	name_fontlayoutToverlaynone)r}   r|   r~   rG   rH   rI   _convert_font_argsrF   _get_layout_propertiesrJ   rK   rL   )rX   rY   ra   rb   data_idr\   r\   r]   	set_title5  s   zChart.set_titlec                 C      |  || _dS )z
        Set the chart legend options.

        Args:
            options: A dictionary of chart legend options.

        Returns:
            Nothing.
        N)_get_legend_propertiesr#   rW   r\   r\   r]   
set_legendX     zChart.set_legendc                 C   r   )z
        Set the chart plot area options.

        Args:
            options: A dictionary of chart plot area options.

        Returns:
            Nothing.
        N)_get_area_propertiesr,   rW   r\   r\   r]   set_plotareae  r   zChart.set_plotareac                 C   r   )z
        Set the chart area options.

        Args:
            options: A dictionary of chart area options.

        Returns:
            Nothing.
        N)r   r+   rW   r\   r\   r]   set_chartarear  r   zChart.set_chartareac                 C   s*   |du rd}|dk s|dkrd}|| _ dS )z
        Set the chart style type.

        Args:
            style_id: An int representing the chart style.

        Returns:
            Nothing.
        Nr   r   0   )r   )rX   r   r\   r\   r]   	set_style  s
   
zChart.set_stylec                 C   s6   |sdS dddd}||vrt d|  dS || _dS )z
        Set the option for displaying blank data in a chart.

        Args:
            option: A string representing the display option.

        Returns:
            Nothing.
        Nr   )r   zerospanz$Unknown show_blanks_as() option '%s')r   r2   )rX   optionvalid_optionsr\   r\   r]   show_blanks_as  s   

zChart.show_blanks_asc                 C   s
   d| _ dS )z
        Display data on charts from hidden rows or columns.

        Args:
            option: A string representing the display option.

        Returns:
            Nothing.
        r   N)r3   rX   r\   r\   r]   show_hidden_data  s   

zChart.show_hidden_datac                 C   sh   |du ri }| d| j| _| d| j| _| dd| _| dd| _| dd| _| d	d| _dS )
z
        Set size or scale of the chart.

        Args:
            options: A dictionary of chart size options.

        Returns:
            Nothing.
        Nr5   r6   r7   r   r8   r9   r   r:   )r|   r5   r6   r7   r8   r9   r:   rW   r\   r\   r]   set_size  s   
zChart.set_sizec                 C   sn   |du ri }i }| dd|d< | dd|d< | dd|d< | dd|d< | | d|d< || _dS )	z
        Set properties for an axis data table.

        Args:
            options: A dictionary of axis table options.

        Returns:
            Nothing.

        N
horizontalr   verticaloutline	show_keysr   font)r|   r   r;   )rX   rY   r;   r\   r\   r]   	set_table  s   
zChart.set_tablec                 C   s   |du ri }d}d}d}d}| dr@d|d v r"t|d d }d|d v r1t|d d }d|d v r@t|d d }| drrd|d v rTt|d d }d|d v rct|d d }d|d v rrt|d d }||d||dd| _dS )	z
        Set properties for the chart up-down bars.

        Args:
            options: A dictionary of options.

        Returns:
            Nothing.

        Nuprg   rf   rh   down)rf   rh   )r   r   )r|   r   r   r   rD   )rX   rY   up_lineup_fill	down_line	down_fillr\   r\   r]   set_up_down_bars  s8   

zChart.set_up_down_barsc                 C   v   |du ri }t |d}t |d}t |d}t |d}|r+d| _|r1d}d}||||d| _dS )z
        Set properties for the chart drop lines.

        Args:
            options: A dictionary of options.

        Returns:
            Nothing.

        Nrf   rh   ri   rj   rf   rh   ri   rj   )r   r   r|   r   r   r   rh   rB   rX   rY   rf   rh   ri   rj   r\   r\   r]   set_drop_lines      zChart.set_drop_linesc                 C   r   )z
        Set properties for the chart high-low lines.

        Args:
            options: A dictionary of options.

        Returns:
            Nothing.

        Nrf   rh   ri   rj   r   )r   r   r|   r   r   r   rh   rC   r   r\   r\   r]   set_high_low_lines>  r   zChart.set_high_low_linesc                 C   s   |du rdS || _ dS )z
        Create a combination chart with a secondary chart.

        Args:
            chart: The secondary chart to combine with the primary chart.

        Returns:
            Nothing.

        N)rS   )rX   chartr\   r\   r]   combinec  s   
zChart.combinec                 C   s`   |    |   |   |   |   |   | | j | jr%| 	  | 
d |   d S )Nc:chartSpace)_xml_declaration_write_chart_space_write_lang_write_style_write_protection_write_chart_write_sp_prr+   r   _write_print_settings_xml_end_tag
_xml_closer   r\   r\   r]   _assemble_xml_filey  s   
zChart._assemble_xml_filec                 C   s  |d   }|| | |d|d\}}| ||d}i 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|v r|d|d< nd|d< | |d |d< |dd|d< |dr|d d r| |d |d< |d r|d  d r| |d  |d < |dr|d  d! |d< |dr|d d"krd#|d< n|d d$kr
nd |d< |d%rd| _|d&r$d| _d|d&< |dr=t	|d r=t
|d | j| j|d< |d	rVt	|d	 rVt
|d	 | j| j|d	< |drot	|d rot
|d | j| j|d< | |d'|d'< | |d(|d(< | |d)d|d)< t|d*|d*< t|d+|d+< t|d,|d,< t|d-|d-< |d,rd |d+< |d-rd |d,< d |d+< | |d.|d.< | |d/|d/< |S )0Ndefaultsra   rb   r   formular   reverseminmax
minor_unit
major_unitminor_unit_typemajor_unit_typedisplay_unitslog_basecrossingposition_axispositionlabel_positionlabel_align
num_formatnum_format_linkedinterval_unitinterval_tickF)r   r   r   r   r   	text_axisvisibler   display_units_visibleTmajor_gridlinesminor_gridlinesr   on_tickmidCatr   	date_axisr   num_fontr   name_layoutrf   rh   ri   rj   minor_tick_markmajor_tick_mark)copyupdater}   r|   r~   _get_display_units_get_gridline_propertieslowerrM   r
   r   rN   rO   r   r   r   r   r   r   r   _get_tick_type)rX   r   user_optionsrY   ra   rb   r   r\   r\   r]   r     s   





	















zChart._convert_axis_argsc                 C   s   |sd S | d| d| d| d| d| d| d| d| d	d
| dd
}|d r>t|d d |d< |d rLdt|d  |d< |S )Nra   colorsizebolditalic	underlinepitch_familycharsetbaseliner   rotation)
ra   r   r   r   r   r   r   r   r   r   d   `  )r|   int)rX   rY   r   r\   r\   r]   r      s$   
zChart._convert_font_argsc                 C   sB   t |tur|rd|v rd|vr| jrtd|  |S t| }|S )N 'zSSheetname in '%s' contains spaces but isn't quoted. This may cause errors in Excel.)typelistrU   r   r	   )rX   r   r   r\   r\   r]   r{   <  s   zChart._list_to_formulac                 C   sd   |d ur.t |tr$t|d |d dd}t|d d | }d}||fS td|r.|}d}||fS )Nr   r   Tr   !r   ^=?[^!]+!\$?[A-Z]+\$?[0-9]+)
isinstancer  r   r   rematch)rX   ra   rb   cellr\   r\   r]   r}   L  s   
zChart._process_namesc              	   C   s~   |d u s
t |dkrdS t|d trdS |D ]%}|d u rqt|tkr+d|v r+ dS zt| W q ty<   Y  dS w dS )Nr   r   	multi_str_strnum)rz   r	  r  r  r  float
ValueError)rX   r   tokenr\   r\   r]   _get_data_type\  s   zChart._get_data_typec                 C   sp   |sd S | dr|d}|| jvr%t| j}| j| || j|< |S | j| }| j| d u r6|| j|< |S )N=)
startswithlstripr&   rz   r'   r   )rX   r   r   
formula_idr\   r\   r]   r~   y  s   	




	

zChart._get_data_idc                 C   s   |sd S t |}dddddddddd	d	d
ddd}|d}|d ur6||v r.|| |d< ntd|  d S t|d}d|v rIt|d }t|d}t|d}t|d}|rfd | _	|rld }d }||d< ||d< ||d< ||d< |S )N	automaticr   squarediamondtrianglexstardotdashcirclepluspicture)r  r   r  r  r  r  r  r  
short_dashr   	long_dashr!  r"  r#  r  zUnknown marker type '%srf   rg   rh   ri   rj   
r   deepcopyr|   r   r   r   r   r   r   rh   )rX   rk   typesmarker_typerf   rh   ri   rj   r\   r\   r]   r     sP   

zChart._get_marker_propertiesc                 C   s   |sd S t |}ddddddd}|d}||v r"|| |d< ntd	|  d S t|d
}d|v r=t|d }t|d}t|d}t|d}|rZd | _	|r`d }d }||d
< ||d< ||d< ||d< |S )Nexplinearlog	movingAvgpolypower)exponentialr+  r,  moving_average
polynomialr/  r  zUnknown trendline type '%s'rf   rg   rh   ri   rj   r&  )rX   rl   r(  
trend_typerf   rh   ri   rj   r\   r\   r]   r     s>   


zChart._get_trendline_propertiesc                 C   s  |sd S ddddd}dddddd	}|d
 }||v r"|| |d
< nt d|  d S d|v r4|d |d< d|v r>|d |d< d|v rY|d dkrMd|d< n|d dkrXd|d< n	 |d|d< |d|d< |d|d< |d|d< t|d|d< |S )NfixedValr   both)r  valueendcap	direction
percentagestdDevstdErrcust)fixedr9  standard_deviationstandard_errorcustomr  zUnknown error bars type '%sr6  	end_styler7  r8  minusr"  plus_valuesminus_values	plus_data
minus_datarf   )r   r|   r   r   )rX   rY   ry   r(  
error_typer\   r\   r]   r     sD   	

zChart._get_error_bars_propsc                 C   s&   d| di}t| d|d< |S )Nr   rf   )r|   r   r   )rX   rY   gridliner\   r\   r]   r   V  s   zChart._get_gridline_propertiesc                 C   sr  |sd S t |}|d}|r/|| jv r'|| jkrd |d< n| j| |d< ntd|  d S |d}dddddd	}|rO||v rI|| |d< ntd
 d S | |d|d< t|d}d|v rlt|d }t	|d}t
|d}t|d}|rd | _|rd }d }||d< ||d< ||d< ||d< |dr7|d D ]}	|	d u rq|	d}
|
rtdt|
r|
|	d< |	d}|r|dr|d|	d< | ||	d}||	d< | |	d|	d< t|	d}d|	v rt|	d }t	|	d}t
|	d}t|	d}|rd | _|r&d }d }||	d< ||	d< ||	d< ||	d< q|S )Nr   z3Unsupported label position '%s' for this chart type	separatorz, z; z. 
r  ),;.rJ  r  zUnsupported label separatorr   rf   rg   rh   ri   rj   r@  r6  r  r   r  r   r   )r   r'  r|   rP   rQ   r   r   r   r   r   r   r   rh   r
  r  r  r  r  r~   )rX   rw   r   rI  
separatorsrf   rh   ri   rj   labelr6  r   r   r\   r\   r]   r   a  s   










zChart._get_labels_propertiesc                 C   s   i }t |d}|drt |d }t |d}t |d}t |d}|r3d | _|r9d }d }| |dd}||d< ||d< ||d< ||d< ||d< |S )Nrf   rg   rh   ri   rj   r   F)r   r   r|   r   r   r   rh   r   )rX   rY   arearf   rh   ri   rj   r   r\   r\   r]   r     s&   
zChart._get_area_propertiesc                 C   s  i }|d u ri }| dd|d< | d|d< | | d|d< | | dd|d< | dr5d|d< t| d}| d	rIt|d	 }t| d
}t| d}t| d}|rfd | _|rld }d }| | dd}||d< ||d
< ||d< ||d< ||d< |S )Nr   rightdelete_seriesr   r   Fr   rf   rg   rh   ri   rj   )	r|   r   r   r   r   r   r   r   rh   )rX   rY   r#   rf   rh   ri   rj   r   r\   r\   r]   r     s:   

zChart._get_legend_propertiesc              	   C   s   i }|sd S |rd}nd}|  D ]}||vr td|   d S q|D ]H}||  vr4td|   d S || }zt| W n tyQ   td||f  Y  d S w |dk sZ|dkretd||f   d S d	| ||< q#|S )
N)r  y)r  rS  r5   r6   z+Property '%s' allowed not in layout optionsz1Property '%s' must be specified in layout optionsz2Property '%s' value '%s' must be numeric in layoutr   r   zFProperty '%s' value '%s' must be in range 0 < x <= 1 in layout optionsz%.17g)keysr   r  r  )rX   argsis_textr   
propertieskeypropr6  r\   r\   r]   r   <  sB   zChart._get_layout_propertiesc           	      C   s   g }|sd S |D ]S}i }|d urVt |d}d|v r#t |d }t |d}t |d}t |d}|r@d | _|rFd }d }||d< ||d< ||d< ||d< || q|S )Nrf   rg   rh   ri   rj   )r   r   r|   r   r   r   rh   r   )	rX   user_pointsrp   
user_pointpointrf   rh   ri   rj   r\   r\   r]   r   h  s2   zChart._get_points_propertiesc                 C   sh   d}d}| d}| d}| dr|d d rd}| dr(|d d r(d}|s2|s2|s2|s2dS dS )NFri   rj   rh   definedTrf   )r|   )rX   elementhas_fillhas_linehas_patternhas_gradientr\   r\   r]   _has_fill_formatting  s   

zChart._has_fill_formattingc              
   C   sD   |sd S ddddddddd	d
	}||v r|| }|S t d|  d S )Nhundreds	thousandstenThousandshundredThousandsmillionstenMillionshundredMillionsbillions	trillions)	rd  re  ten_thousandshundred_thousandsrh  ten_millionshundred_millionsrk  rl  zUnknown display_units type '%s'r   )rX   r   r(  r\   r\   r]   r     s"   zChart._get_display_unitsc                 C   s:   |sd S ddddd}||v r|| }|S t d|  d S )Noutinr   cross)outsideinsider   rs  zUnknown tick_type  '%s'r   )rX   	tick_typer(  r\   r\   r]   r     s   zChart._get_tick_typec                 C   s&   g }| j D ]}|d s|| q|S Nr/   r   r   )rX   primary_axes_seriesr   r\   r\   r]   _get_primary_axes_series     

zChart._get_primary_axes_seriesc                 C   s&   g }| j D ]}|d r|| q|S rw  rx  )rX   secondary_axes_seriesr   r\   r\   r]   _get_secondary_axes_series  r{  z Chart._get_secondary_axes_seriesc                 C   s   dt | j }dt| j t| j }d||f }d||d f }|d r1| j| | j| |d sC| j| | j| d S d S )Ni  r   z%04d%04dprimary_axes)r  r   rz   r    r   r   )rX   rU  chart_id
axis_countid1id2r\   r\   r]   _add_axis_ids  s   zChart._add_axis_idsc                 C   s   dddid| j d< dddid| jd< ddddd	| jd< dddid
dd| jd< | i  | i  | i  | i  d S )NGeneralr   r   )r   r   r   r   r   r   )r   r   r   r   rQ  )r   r   r   r   )r-   r.   r0   r/   r   r   r   r   r   r\   r\   r]   rV     s(   


zChart._set_default_propertiesc                 C   sB   d}|d }|d }|d }d|fd|fd|fg}|  d| d S )	Nz"http://schemas.openxmlformats.org/zdrawingml/2006/chartzdrawingml/2006/mainz!officeDocument/2006/relationshipszxmlns:czxmlns:azxmlns:rr   )_xml_start_tag)rX   schemaxmlns_cxmlns_axmlns_r
attributesr\   r\   r]   r   #  s   zChart._write_chart_spacec                 C      d}d|fg}|  d| d S )Nen-USvalzc:lang_xml_empty_tagrX   r  r  r\   r\   r]   r   2     
zChart._write_langc                 C   ,   | j }|dkr	d S d|fg}| d| d S )Nr   r  zc:style)r   r  )rX   r   r  r\   r\   r]   r   :  
   
zChart._write_stylec                 C   s   |  d | jr|   n'| jd ur"| | j| jd | j| j| j n| j	d ur4| 
| j	d | j| j| j |   |   |   |   | d d S )Nzc:chart)r  rL   _write_c_auto_title_deletedrH   _write_title_formularI   rF   rJ   rK   rG   _write_title_rich_write_plot_area_write_legend_write_plot_vis_only_write_disp_blanks_asr   r   r\   r\   r]   r   F  s.   



zChart._write_chartc                 C   r  )Nr   r  zc:dispBlanksAs)r2   r  r  r\   r\   r]   r  k  r  zChart._write_disp_blanks_asc                 C   sD  |  d | | jdd | ddi | ddi | j}|rF|jr,d| j |_n| j|_| j|_| j	|_	|ddi |ddi | j
| j| jd}| jrX| | n| | | | | j| j| jd}| | |r|jr|j|j|jd}|| | jr| | n| | |   | | j | d d S )	Nz
c:plotArear   plotr~  TF  )r-   r.   r   )r  _write_layoutr,   r|   _write_chart_typerS   rT   r   fhr   r-   r.   r   rM   _write_date_axis_write_cat_axis_write_val_axisr0   r/   r    _write_d_tabler   r   )rX   second_chartrU  r\   r\   r]   r  w  sL   






zChart._write_plot_areac                 C   s6   |s	|  d d S | d | || | d d S )Nc:layout)r  r  _write_manual_layoutr   rX   r   layout_typer\   r\   r]   r    s
   
zChart._write_layoutc                 C   s   |  d |dkr| ddg | ddg | ddg | dd	|d
 fg | dd	|d fg |dkrN| dd	|d fg | dd	|d fg | d d S )Nzc:manualLayoutr  zc:layoutTarget)r  innerzc:xMode)r  edgezc:yModezc:xr  r  zc:yrS  textzc:wr5   zc:hr6   r  r  r   r  r\   r\   r]   r    s   
zChart._write_manual_layoutc                 C   s   d S Nr\   rW   r\   r\   r]   r    s   zChart._write_chart_typec                 C      d|fg}|  d| d S )Nr  z
c:groupingr  r  r\   r\   r]   _write_grouping     
zChart._write_groupingc                 C   s   |  | d S r  )
_write_serrX   r   r\   r\   r]   _write_series     zChart._write_seriesc                 C   s   | j }|  j d7  _ | d | | | | | | | | | |d  | |d  | |d  | 	|d  | 
|d  | |d  | | | | | jra| |d	  | d d S )
Nr   zc:serrk   rx   rp   rw   rl   ry   rm   )r   r  
_write_idx_write_order_write_series_namer   _write_marker_write_c_invert_if_negative_write_d_pt_write_d_lbls_write_trendline_write_error_bars
_write_cat
_write_valrE   _write_c_smoothr   )rX   r   indexr\   r\   r]   r    s$   






zChart._write_serc                 C   r  )Nr  zc:idxr  r  r\   r\   r]   r       
zChart._write_idxc                 C   r  )Nr  c:orderr  r  r\   r\   r]   r  %  r  zChart._write_orderc                 C   sF   |d d ur|  |d |d  d S |d d ur!| |d  d S d S )Nrb   rt   ra   )_write_tx_formula_write_tx_valuer  r\   r\   r]   r  ,  s
   zChart._write_series_namec                 C   s   |r|  ddg d S d S )Nzc:smooth)r  1r  )rX   rm   r\   r\   r]   r  4  s   zChart._write_c_smoothc                 C   s   |d }|d }d }|d ur| j | }|sd S | d | |}|dkr0d| _| ||| n|dkr>d| _| || n
d| _| ||| | d d S )Nr_   rv   zc:catr  r   r  r   )r'   r  r  r!   _write_str_ref_write_multi_lvl_str_ref_write_num_refr   )rX   r   r   r   r   cat_typer\   r\   r]   r  :  s$   


zChart._write_catc                 C   s@   |d }|d }| j | }| d | ||d | d d S )Nr^   ru   c:valr  )r'   r  r  r   )rX   r   r   r   r   r\   r\   r]   r  ]  s   

zChart._write_valc                 C   H   |  d | | |dkr| | n	|dkr| | | d d S )Nzc:numRefr  r  r  _write_series_formula_write_num_cache_write_str_cacher   rX   r   r   ref_typer\   r\   r]   r  k  s   


zChart._write_num_refc                 C   r  )Nzc:strRefr  r  r  r  r\   r\   r]   r  {  s   


zChart._write_str_refc                 C   s   |sd S |  d | | |  d t|d }| | t|D ]}|  d t|D ]\}}| |||  q-| d q"| d | d d S )Nzc:multiLvlStrRefzc:multiLvlStrCacher   zc:lvl)r  r  rz   _write_pt_countreversed	enumerate	_write_ptr   )rX   r   r   countcat_datair\  r\   r\   r]   r    s   





zChart._write_multi_lvl_str_refc                 C   s$   | dr
|d}| d| d S )Nr  zc:f)r  r  _xml_data_element)rX   r   r\   r\   r]   r    s   

zChart._write_series_formulac                 C   sZ   |  | |d r| | jd  | | jd  d S | | jd  | | jd  d S )Nr~  r   r   )r  _write_axis_idr   r    )rX   rU  r\   r\   r]   _write_axis_ids  s   
zChart._write_axis_idsc                 C   r  )Nr  zc:axIdr  r  r\   r\   r]   r    r  zChart._write_axis_idc                 C   s.  |d }|d }|d }|d u st |sd S | j}| j}|dr%|d }| d | |d  | |dd d d  |dsF| d	 | ||d | 	|d
 | 
|d |d d urw| |d |d ||d |d  n|d d ur| |d ||d |d  | | | |d | |d | |d | | | |d | |d	  | js|dr|dd u s|ddks|d dkr| |d n| |d |ds| d	 | |d | d | |d | |d | d d S )Nr-   r.   r   r   zc:catAxr   r   r   r   r   r   r   r   r   r   ra   r   r   r   r   r   r   r   r   r   r   r   r   )rz   r$   r(   r|   r  r  _write_scaling_write_delete_write_axis_pos_write_major_gridlines_write_minor_gridlinesr  r  _write_cat_number_format_write_major_tick_mark_write_minor_tick_mark_write_tick_label_posr   _write_axis_font_write_cross_axisr4   _write_crosses_write_c_crosses_at_write_auto_write_label_align_write_label_offset_write_c_tick_lbl_skip_write_c_tick_mark_skipr   rX   rU  r-   r.   r   r   	is_y_axisr\   r\   r]   r    sl   










zChart._write_cat_axisc                 C   s0  |d }|d }|d }| d| j}| j}|d u st|s d S | dp&|}| d | |d  | | d| d| d	| d
 | dsQ| d | || d | 	| d | 
| d |d d ur| |d |d ||d |d  n|d d ur| |d || d| d | | | | d | | d | | d | | | | d | |d  | dd u s|d d	ks|d dkr| | d n| | d | | d | | d | | d | | d| d | d d S )Nr-   r.   r   r   c:valAxr   r   r   r   r   r   r   r   r   r   r   r   ra   r   r   r   r   r   r   r   r   r   r   r   )r|   r%   r)   rz   r  r  r  r  r  r  r  r  r  _write_number_formatr  r  r  r   r  r  r  r  _write_cross_between_write_c_major_unit_write_c_minor_unit_write_disp_unitsr   r  r\   r\   r]   r  2  sh   






zChart._write_val_axisc                 C   s,  |d }|d }|d }|d p| j }| j}|d u st|s d S |dp&|}| d | |d  | |d|d|d	|d
 |dsQ| d | ||d | 	|d | 
|d |d d ur| |d |d ||d |d  n|d d ur| |d ||d |d  | | | |d | |d | |d | | | |d | |d  |dd u s|d d	ks|d dkr| |d n| |d | |d | |d | |d | |d|d | d d S )Nr-   r.   r   r   r  r   r   r   r   r   r   r   r   r   r   r   r   r   ra   r   r   r   r   r   r   r   r   r   r   )r%   r)   rz   r|   r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r   r  r\   r\   r]   _write_cat_val_axis  sh   






zChart._write_cat_val_axisc                 C   sp  |d }|d }|d }|d u st |sd S | j}|dp|}| d | |d  | |d|d|d	|d
 |dsJ| d | ||d | |d | 	|d |d d ur{| 
|d |d d |d |d  n|d d ur| |d d |d |d  | | | |d | |d | |d | | | |d | |d  | js|dr|dd u s|dd	ks|d dkr| |d n| |d | d | d | |d | |d | |d |dr| |d  | |d |dr1| |d  | d d S ) Nr-   r.   r   r   zc:dateAxr   r   r   r   r   r   r   r   r   r   r   r   r   ra   r   r   r   r   r   r   r   r   r   r   r   r   )rz   r$   r|   r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r4   r  r  r  r  r  r  r  _write_c_major_time_unitr  _write_c_minor_time_unitr   )rX   rU  r-   r.   r   r   r\   r\   r]   r    sp   








zChart._write_date_axisc                 C   s@   |  d | | | | | | | | | d d S )Nz	c:scaling)r  _write_c_log_base_write_orientation_write_c_max_write_c_minr   )rX   r   min_valmax_valr   r\   r\   r]   r  h	  s   




zChart._write_scalingc                 C   "   |sd S d|fg}|  d| d S )Nr  z	c:logBaser  r  r\   r\   r]   r  {	     
zChart._write_c_log_basec                 C   s&   d}|rd}d|fg}|  d| d S )NminMaxmaxMinr  zc:orientationr  )rX   r   r  r  r\   r\   r]   r  	  
   
zChart._write_orientationc                 C   &   |d u rd S d|fg}|  d| d S )Nr  zc:maxr  )rX   r  r  r\   r\   r]   r  	     
zChart._write_c_maxc                 C   r  )Nr  zc:minr  )rX   r  r  r\   r\   r]   r  	  r  zChart._write_c_minc                 C   s6   |r|dkrd}|dkrd}d|fg}|  d| d S )Nr   rr   tr  zc:axPosr  )rX   r  r   r  r\   r\   r]   r  	  s   
zChart._write_axis_posc                 C   sX   | d}d}|d ur||d d krd}| drd}d|fd|fg}| d| d S 	Nr   r   r   r   r   
formatCodesourceLinkedc:numFmt)r|   r  )rX   r   format_codesource_linkedr  r\   r\   r]   r  	  s   

zChart._write_number_formatc                 C   sn   | d}d}d}|d ur||d d krd}d}| dr d}| js'|r'd S d|fd|fg}| d| d S r	  )r|   r!   r  )rX   r   r  r  default_formatr  r\   r\   r]   r  	  s   


zChart._write_cat_number_formatc                 C   s$   d}d|fd|fg}|  d| d S )Nr   r
  r  r  r  )rX   r  r  r  r\   r\   r]   _write_data_label_number_format	  s
   z%Chart._write_data_label_number_formatc                 C   r   )Nr  zc:majorTickMarkr  r  r\   r\   r]   r  	  r  zChart._write_major_tick_markc                 C   r   )Nr  zc:minorTickMarkr  r  r\   r\   r]   r  	  r  zChart._write_minor_tick_markc                 C   s.   |d u s|dkr
d}d|fg}|  d| d S )Nnext_tonextTor  zc:tickLblPosr  r  r\   r\   r]   r  
  s   
zChart._write_tick_label_posc                 C   r  )Nr  z	c:crossAxr  r  r\   r\   r]   r  
  r  zChart._write_cross_axisc                 C   &   |d u rd}d|fg}|  d| d S )NautoZeror  z	c:crossesr  r  r\   r\   r]   r  
     
zChart._write_crossesc                 C   r  )Nr  zc:crossesAtr  r  r\   r\   r]   r  
  r  zChart._write_c_crosses_atc                 C   r  )Nr  zc:autor  r  r\   r\   r]   r  $
  r  zChart._write_autoc                 C   s>   |d u rd}|dkrd}|dkrd}d|fg}|  d| d S )NctrrQ  r  leftr   r  z	c:lblAlgnr  r  r\   r\   r]   r  +
  s   
zChart._write_label_alignc                 C   r  )Nr  zc:lblOffsetr  r  r\   r\   r]   r  ;
  r  zChart._write_label_offsetc                 C   r  )Nr  zc:tickLblSkipr  r  r\   r\   r]   r  B
  r  zChart._write_c_tick_lbl_skipc                 C   r  )Nr  zc:tickMarkSkipr  r  r\   r\   r]   r  K
  r  zChart._write_c_tick_mark_skipc                 C   P   |sd S |d s
d S |d d r!|  d | | | d d S | d d S )Nr   rf   r]  zc:majorGridlinesr  r   r   r  rX   	gridlinesr\   r\   r]   r  T
     

zChart._write_major_gridlinesc                 C   r  )Nr   rf   r]  zc:minorGridlinesr  r  r\   r\   r]   r  g
  r  zChart._write_minor_gridlinesc                 C   s(   |d u r| j }d|fg}| d| d S )Nr  zc:crossBetween)r<   r  r  r\   r\   r]   r  z
  s   
zChart._write_cross_betweenc                 C   r   )Nr  zc:majorUnitr  r  r\   r\   r]   r  
  r  zChart._write_c_major_unitc                 C   r   )Nr  zc:minorUnitr  r  r\   r\   r]   r  
  r  zChart._write_c_minor_unitc                 C   r  )Ndaysr  zc:majorTimeUnitr  r  r\   r\   r]   r  
  r  zChart._write_c_major_time_unitc                 C   r  )Nr  r  zc:minorTimeUnitr  r  r\   r\   r]   r  
  r  zChart._write_c_minor_time_unitc                 C   s   | j }|dd}|d}g }d}|dr#t|d tu r#|d }|dr0|dd}d}d	d
dddd}|dkr>d S ||vrDd S || }| d | | |D ]}| | qT| 	|dd |rk| 
  |rr| | | | | d d S )Nr   rQ  r   r   rR  overlay_r   r   r  r   r  r   tr)rQ  r  topbottom	top_rightr   zc:legendr   r#   )r#   r|   r  r  r  replacer  _write_legend_pos_write_legend_entryr  _write_overlay_write_tx_prr   r   )rX   r#   r   r   rR  r   allowedr  r\   r\   r]   r  
  sB   






zChart._write_legendc                 C   r  )Nr  zc:legendPosr  r  r\   r\   r]   r$  
  r  zChart._write_legend_posc                 C   s,   |  d | | | d | d d S )Nzc:legendEntryr   )r  r  r  r   )rX   r  r\   r\   r]   r%  
     


zChart._write_legend_entryc                 C   r  )Nr   r  z	c:overlayr  r  r\   r\   r]   r&  
  r  zChart._write_overlayc                 C   s(   d}| j rd S d|fg}| d| d S )Nr   r  zc:plotVisOnly)r3   r  r  r\   r\   r]   r  
  s
   
zChart._write_plot_vis_onlyc                 C   s0   |  d |   |   |   | d d S )Nzc:printSettings)r  _write_header_footer_write_page_margins_write_page_setupr   r   r\   r\   r]   r   
  s
   
zChart._write_print_settingsc                 C      |  d d S )Nzc:headerFooterr  r   r\   r\   r]   r*    r  zChart._write_header_footerc                 C   sP   d}d}d}d}d}d}d|fd|fd|fd|fd|fd	|fg}|  d
| d S )Ng      ?gffffff?g333333?r   r   r  r  headerfooterzc:pageMarginsr  )rX   r!  r  rQ  r   r.  r/  r  r\   r\   r]   r+    s   	zChart._write_page_marginsc                 C   r-  )Nzc:pageSetupr  r   r\   r\   r]   r,  1  r  zChart._write_page_setupc                 C   s   |  ddg d S )Nzc:autoTitleDeletedr  r   r  r   r\   r\   r]   r  5  s   z!Chart._write_c_auto_title_deletedFc                 C   s>   |  d | ||| | |d |r|   | d d S Nzc:titler  )r  _write_tx_richr  r&  r   )rX   titler  r   r   r   r\   r\   r]   r  9  s   
zChart._write_title_richc                 C   sH   |  d | || | |d |r|   | || | d d S r1  )r  r  r  r&  r'  r   )rX   r3  r   r  r   r   r   r\   r\   r]   r  J  s   
zChart._write_title_formulac                 C   s*   |  d | j|||dd | d d S )Nc:txF)ignore_rich_pr)r  _write_richr   )rX   r3  r  r   r\   r\   r]   r2  _  s   
zChart._write_tx_richc                 C   "   |  d | | | d d S )Nr4  r  _write_vr   rX   r3  r\   r\   r]   r  i     

zChart._write_tx_valuec                 C   s<   d }|d ur| j | }| d | ||d | d d S )Nr4  r  )r'   r  r  r   )rX   r3  r   r   r\   r\   r]   r  s  s   

zChart._write_tx_formulac                 C   sZ   |r| dd ur|d }nd }| d | || |   | ||| | d d S )Nr   zc:rich)r|   r  _write_a_body_pr_write_a_lst_style_write_a_p_richr   )rX   r3  r   r  r5  r   r\   r\   r]   r6    s   

zChart._write_richc                 C   s   g }|d u r
|r
d}|d ur8|dkr| d | d n|dkr,| d | d n| d|f | d | d	| d S )
Ni@i@1 )rotr   )vertwordArtVerti )r@  eaVertr?  )r@  horzza:bodyPr)r   r  )rX   r   r  r  r\   r\   r]   r<    s   


zChart._write_a_body_prc                 C   r-  )Nz
a:lstStyler  r   r\   r\   r]   r=    r  zChart._write_a_lst_stylec                 C   s2   |  d |s| | | || | d d S Na:p)r  _write_a_p_pr_rich
_write_a_rr   )rX   r3  r   r5  r\   r\   r]   r>    s
   

zChart._write_a_p_richc                 C   s*   |  d | | |   | d d S rD  )r  _write_a_p_pr_formula_write_a_end_para_rprr   rX   r   r\   r\   r]   _write_a_p_formula  s   

zChart._write_a_p_formulac                 C   r7  Nza:pPrr  _write_a_def_rprr   rJ  r\   r\   r]   rF    r;  zChart._write_a_p_pr_richc                 C   r7  rL  rM  rJ  r\   r\   r]   rH    r;  zChart._write_a_p_pr_formulac                 C   s   d}t |}t |}|r|dd urd}|s|r:| d| |r,| d|d i |r3| | | d d S | d| d S )Nr   r   r   za:defRPr)	r   _get_font_style_attributes_get_font_latin_attributesr|   r  _write_a_solid_fill_write_a_latinr   r  )rX   r   	has_colorstyle_attributeslatin_attributesr\   r\   r]   rN    s   


zChart._write_a_def_rprc                 C   r  )Nr  langza:endParaRPrr  )rX   rV  r  r\   r\   r]   rI    r  zChart._write_a_end_para_rprc                 C   s,   |  d | | | | | d d S )Nza:r)r  _write_a_r_pr
_write_a_tr   )rX   r3  r   r\   r\   r]   rG    r)  zChart._write_a_rc                 C   s   d}d}t |}t |}|r|d d urd}|dd|f |s$|rC| d| |r5| d|d i |r<| | | d d S | d| d S )Nr   r  r   r   rV  za:rPr)	r   rO  rP  insertr  rQ  rR  r   r  )rX   r   rS  rV  rT  rU  r\   r\   r]   rW    s   


zChart._write_a_r_prc                 C      |  d| d S )Nza:tr  r:  r\   r\   r]   rX  &     zChart._write_a_tc                 C   sV   |r| dd ur|d }nd }| d | || |   | | | d d S )Nr   c:txPr)r|   r  r<  r=  rK  r   )rX   r   r  r   r\   r\   r]   r'  +  s   


zChart._write_tx_prc                 C   sn   |d u r| j }|sd S |d dkrd S | d | |d  |dr+| |d  | | | d d S )Nr  r  zc:markerr   )r=   r  _write_symbolr|   _write_marker_sizer   r   )rX   rk   r\   r\   r]   r  @  s   


zChart._write_markerc                 C   r  )Nr  zc:sizer  r  r\   r\   r]   r_  Y  r  zChart._write_marker_sizec                 C   r  )Nr  zc:symbolr  r  r\   r\   r]   r^  `  r  zChart._write_symbolc                 C   s   |  |sd S | d |dr)|d d r)d|d v r"|   n| |d  |dr5| |d  |drA| |d  |drS|d d rS| |d  | d d S )Nc:spPrrh   r]  r   ri   rj   rf   )	rc  r  r|   _write_a_no_fillrQ  _write_a_patt_fill_write_a_grad_fill_write_a_lnr   r  r\   r\   r]   r   g  s   




zChart._write_sp_prc                 C   s   g }| d}|r t|d d d }tdd|  }d|fg}| d| d	|v r/|   n	d
|v r8| | | d}|rD| | | d d S )Nr5   g      ?   g      @g      ?i1  wza:lnr   r   	dash_type)r|   r  r  ra  rQ  _write_a_prst_dashr   )rX   rf   r  r5   	line_typer\   r\   r]   rd    s   





zChart._write_a_lnc                 C   r-  )Nza:noFillr  r   r\   r\   r]   ra    r  zChart._write_a_no_fillc                 C   sB   |  d d|v rt|d }|d}| || | d d S )Nza:solidFillr   transparency)r  r   r|   _write_a_srgb_clrr   )rX   rh   r   rj  r\   r\   r]   rQ    s   

zChart._write_a_solid_fillc                 C   sB   d|fg}|r|  d| | | | d d S | d| d S )Nr  z	a:srgbClr)r  _write_a_alphar   r  )rX   r  rj  r  r\   r\   r]   rk    s   

zChart._write_a_srgb_clrc                 C   s.   t dt | d }d|fg}| d| d S )Nr   r  r  za:alphar  r  r  r\   r\   r]   rl    s   
zChart._write_a_alphac                 C   r  )Nr  z
a:prstDashr  r  r\   r\   r]   rh    r  zChart._write_a_prst_dashc                 C   s   |sd S |  d | |d | | | |d  |d dkr+| |d |d dkr9| |d | |d | |d	 d
|v rT| 	|d
  |dr]| 
  |drj|   |   | d d S )Nzc:trendlinera   r  r.  orderr-  periodforwardbackward	interceptdisplay_r_squareddisplay_equation)r  _write_namer|   r   _write_trendline_type_write_trendline_order_write_period_write_forward_write_backward_write_c_intercept_write_c_disp_rsqr_write_c_disp_eq_write_c_trendline_lblr   )rX   rl   r\   r\   r]   r    s(   



zChart._write_trendlinec                 C   r  )Nr  zc:trendlineTyper  r  r\   r\   r]   rv    r  zChart._write_trendline_typec                 C   s   |d u rd S |  d| d S )Nzc:namer[  rX   r   r\   r\   r]   ru    s   zChart._write_namec                 C   &   |dk rd}d|fg}|  d| d S )Nr   r  r  r  r  r\   r\   r]   rw    r  zChart._write_trendline_orderc                 C   r  )Nr   r  zc:periodr  r  r\   r\   r]   rx    r  zChart._write_periodc                 C   r   )Nr  z	c:forwardr  r  r\   r\   r]   ry  (  r  zChart._write_forwardc                 C   r   )Nr  z
c:backwardr  r  r\   r\   r]   rz  2  r  zChart._write_backwardc                 C   r  )Nr  zc:interceptr  r  r\   r\   r]   r{  <  r  zChart._write_c_interceptc                 C      dg}|  d| d S )Nr0  zc:dispEqr  rX   r  r\   r\   r]   r}  B     zChart._write_c_disp_eqc                 C   r  )Nr0  z
c:dispRSqrr  r  r\   r\   r]   r|  H  r  zChart._write_c_disp_rsqrc                 C   s,   |  d | d d  |   | d d S )Nzc:trendlineLbl)r  r  _write_trendline_num_fmtr   r   r\   r\   r]   r~  N  s   
zChart._write_c_trendline_lblc                 C   s   ddg}|  d| d S )N)r
  r  )r  r   r  r  r  r\   r\   r]   r  Z  s   zChart._write_trendline_num_fmtc                 C   sV   | j }|d u r	d S d|v r$|d d r$| d | | | d d S | d d S )Nrf   r]  zc:hiLowLines)rC   r  r   r   r  )rX   rC   r\   r\   r]   _write_hi_low_linesc  s   

zChart._write_hi_low_linesc                 C   sN   | j }|d u r	d S |d d r | d | | | d d S | d d S )Nrf   r]  zc:dropLines)rB   r  r   r   r  )rX   rB   r\   r\   r]   _write_drop_linesu  s   

zChart._write_drop_linesc                 C   r  )Nr  z	c:overlapr  r  r\   r\   r]   _write_overlap  r  zChart._write_overlapc              	   C   s   |rt |}nd}| d | d | | t|D ]#}|| }|d u r'qzt| W n ty8   d}Y nw | || q| d d S )Nr   z
c:numCacher  	rz   r  _write_format_coder  ranger  r  r  r   rX   r   r  r  r  r\   r\   r]   r    s"   



zChart._write_num_cachec                 C   sH   t |}| d | | t|D ]
}| |||  q| d d S )Nz
c:strCache)rz   r  r  r  r  r   )rX   r   r  r  r\   r\   r]   r    s   

zChart._write_str_cachec                 C   rZ  )Nzc:formatCoder[  r  r\   r\   r]   r    r\  zChart._write_format_codec                 C   r  )Nr  z	c:ptCountr  r  r\   r\   r]   r    r  zChart._write_pt_countc                 C   s:   |d u rd S d|fg}|  d| | | | d d S )Nidxzc:ptr8  )rX   r  r6  r  r\   r\   r]   r    s   

zChart._write_ptc                 C   rZ  )Nzc:vr[  r  r\   r\   r]   r9    r\  zChart._write_vc                 C   s   | j sd S | d d S )Nzc:protection)r*   r  r   r\   r\   r]   r     s   zChart._write_protectionc                 C   s4   d}|sd S |D ]}|d7 }|sq|  || qd S )Nr   r   )_write_d_pt_point)rX   rp   r  r\  r\   r\   r]   r    s   zChart._write_d_ptc                 C   s,   |  d | | | | | d d S )Nzc:dPt)r  r  r   r   )rX   r  r\  r\   r\   r]   r    r)  zChart._write_d_pt_pointc                 C   s  |sd S |  d |dr| ||d  |dr"| |d  | | |dr3| |d  |dr?| |d  |drH|   |drQ|   |drZ| 	  |d	rc| 
  |d
rl|   |drx| |d  |dr|   | d d S )Nzc:dLblsr@  r   r   r   
legend_keyr6  categoryseries_namer9  rI  leader_lines)r  r|   _write_custom_labelsr  r   r  _write_d_lbl_pos_write_show_legend_key_write_show_val_write_show_cat_name_write_show_ser_name_write_show_percent_write_separator_write_show_leader_linesr   )rX   rw   r\   r\   r]   r    s6   












zChart._write_d_lblsc                 C   s2  d}|D ]}|d7 }|d u rq|  d | |d  |d}|r(| d ni|drZ| | |dr>| |d  |drG|   |drP|   |d	rY|   n7|dr| 	| |drp| |d  |dry|   |dr|   |d	r|   n| 
| | d qd S )
Nr   r   zc:dLbldeleter   r   r6  r  r  )r  r  r|   r  _write_custom_label_formular  r  r  r  _write_custom_label_str_write_custom_label_format_onlyr   )rX   parentrw   r  rO  delete_labelr\   r\   r]   r  ;  sF   














zChart._write_custom_labelsc                 C   s^   | d}| d}| |}| d d  | d | ||d|  | d | | d S )Nr6  r   r4  F)r|   rc  r  r  r6  r   r   )rX   rO  r3  r   has_formattingr\   r\   r]   r  m  s   




zChart._write_custom_label_strc                 C   sf   | d}| d}d }|d ur| j| }| d d  | d | ||d | d | | d S )Nr   r   r4  r  )r|   r'   r  r  r  r   r  )rX   rO  r   r   r   r\   r\   r]   r    s   




z!Chart._write_custom_label_formulac                 C   sP   | d}| |}|r| | | | d S |r&| d | | d S d S )Nr   r`  )r|   rc  r   r'  r  )rX   rO  r   r  r\   r\   r]   r    s   



z%Chart._write_custom_label_format_onlyc                 C   r  )Nr  r  zc:showLegendKeyr  r  r\   r\   r]   r    r  zChart._write_show_legend_keyc                 C   r  )Nr   r  z	c:showValr  r  r\   r\   r]   r    r  zChart._write_show_valc                 C   r  )Nr   r  zc:showCatNamer  r  r\   r\   r]   r    r  zChart._write_show_cat_namec                 C   r  )Nr   r  zc:showSerNamer  r  r\   r\   r]   r    r  zChart._write_show_ser_namec                 C   r  )Nr   r  zc:showPercentr  r  r\   r\   r]   r    r  zChart._write_show_percentc                 C   rZ  )Nzc:separatorr[  r  r\   r\   r]   r       zChart._write_separatorc                 C   r  )Nr   r  zc:showLeaderLinesr  r  r\   r\   r]   r    r  zChart._write_show_leader_linesc                 C   r  )Nr  z	c:dLblPosr  r  r\   r\   r]   r    r  zChart._write_d_lbl_posc                 C   r  )Nr  zc:deleter  r  r\   r\   r]   r    r  zChart._write_deletec                 C   s&   d}|sd S d|fg}|  d| d S )Nr   r  zc:invertIfNegativer  )rX   invertr  r  r\   r\   r]   r    r  z!Chart._write_c_invert_if_negativec                 C   s`   |sd S |  d | |dd  |   |  d | | |   | d | d d S )Nr]  r   rE  )r  r<  r|   r=  rF  rI  r   rJ  r\   r\   r]   r    s   



zChart._write_axis_fontc                 C   rZ  )Nza:latinr  r  r\   r\   r]   rR     r  zChart._write_a_latinc                 C   s|   | j }|sd S | d |d r|   |d r|   |d r$|   |d r,|   |d r7| |d  | d d S )Nzc:dTabler   r   r   r   r   )r;   r  _write_show_horz_border_write_show_vert_border_write_show_outline_write_show_keysr'  r   )rX   r;   r\   r\   r]   r    s   
zChart._write_d_tablec                 C   r  )Nr0  zc:showHorzBorderr  r  r\   r\   r]   r  #  r  zChart._write_show_horz_borderc                 C   r  )Nr0  zc:showVertBorderr  r  r\   r\   r]   r  )  r  zChart._write_show_vert_borderc                 C   r  )Nr0  zc:showOutliner  r  r\   r\   r]   r  /  r  zChart._write_show_outlinec                 C   r  )Nr0  z
c:showKeysr  r  r\   r\   r]   r  5  r  zChart._write_show_keysc                 C   s@   |sd S |d r|  d|d  |d r|  d|d  d S d S )Nro   r  rn   rS  )_write_err_barsrX   ry   r\   r\   r]   r  ;  s   zChart._write_error_barsc                 C   s   |sd S |  d | | | |d  | |d  |d s$|   |d dkr+n|d dkr7| | n| |d  | | | d d S )Nz	c:errBarsr8  r  r7  r;  r<  r6  )	r  _write_err_dir_write_err_bar_type_write_err_val_type_write_no_end_cap_write_custom_error_write_error_valr   r   )rX   r8  ry   r\   r\   r]   r  G  s   


zChart._write_err_barsc                 C   r  )Nr  zc:errDirr  r  r\   r\   r]   r  k  r  zChart._write_err_dirc                 C   r  )Nr  zc:errBarTyper  r  r\   r\   r]   r  r  r  zChart._write_err_bar_typec                 C   r  )Nr  zc:errValTyper  r  r\   r\   r]   r  y  r  zChart._write_err_val_typec                 C   r  )Nr0  z
c:noEndCapr  r  r\   r\   r]   r    r  zChart._write_no_end_capc                 C   r  )Nr  r  r  r  r\   r\   r]   r    r  zChart._write_error_valc                 C   s   |d r(|  d t|d tr| |d  n| |d |d d | d |d rR|  d t|d tr@| |d  n| |d |d d | d d S d S )NrC  zc:plusrE  r  rD  zc:minusrF  )r  r	  r  _write_num_litr  r   r  r\   r\   r]   r    s&   




zChart._write_custom_errorc              	   C   s   t |}| d | d | | t|D ]#}|| }|d u r"qzt| W n ty3   d}Y nw | || q| d d S )Nzc:numLitr  r   r  r  r\   r\   r]   r    s   


zChart._write_num_litc                 C   sT   | j }|d u r	d S | d | d | |d | |d | d d S )Nzc:upDownBars   r   r   )rD   r  _write_gap_width_write_up_barsr|   _write_down_barsr   )rX   rD   r\   r\   r]   _write_up_down_bars  s   

zChart._write_up_down_barsc                 C   r  )Nr  z
c:gapWidthr  r  r\   r\   r]   r    r  zChart._write_gap_widthc                 C   D   |d r|d d r|  d | | | d d S | d d S )Nrf   r]  zc:upBarsr  rX   
bar_formatr\   r\   r]   r    
   

zChart._write_up_barsc                 C   r  )Nrf   r]  z
c:downBarsr  r  r\   r\   r]   r    r  zChart._write_down_barsc                 C   sX   |sd S d|fg}|  d | d| |r%|  d | d | d | d d S )Nr  zc:dispUnitszc:builtInUnitzc:dispUnitsLblr  r  )rX   unitsdisplayr  r\   r\   r]   r    s   




zChart._write_disp_unitsc                 C   st   ddg}|d dkrg }|  d| | | |d dkr%| |d  n| |d  | |d  | d d S )N)flipr   )rotWithShaper  r  r+  z
a:gradFillangle)r  _write_a_gs_lst_write_a_lin_write_a_path_write_a_tile_rectr   )rX   rj   r  r\   r\   r]   rc    s   
zChart._write_a_grad_fillc                 C   s   |d }|d }|  d tt|D ]%}t|| d }d|fg}|  d| t|| }| | | d q| d d S )N	positionscolorsza:gsLstr  posza:gs)r  r  rz   r  r   rk  r   )rX   rj   r  r  r  r  r  r   r\   r\   r]   r  )  s   


zChart._write_a_gs_lstc                 C   s(   t d| }d|fdg}| d| d S )Nr  ang)scaled0za:linrm  )rX   r  r  r\   r\   r]   r  >  s
   zChart._write_a_linc                 C   s.   d|fg}|  d| | | | d d S )Npathza:path)r  _write_a_fill_to_rectr   rX   gradient_typer  r\   r\   r]   r  J  s   

zChart._write_a_pathc                 C   s*   |dkr	g d}nddg}|  d| d S )Nshape))r   50000)r  r  )r  r  )r   r  )r   100000)r  r  za:fillToRectr  r  r\   r\   r]   r  V  s   
zChart._write_a_fill_to_rectc                 C   s&   |dkrg }nddg}|  d| d S )Nr  )r  -100000)r   r  z
a:tileRectr  r  r\   r\   r]   r  h  s   zChart._write_a_tile_rectc                 C   sD   d|d fg}|  d| | |d  | |d  | d d S )Nprstri   z
a:pattFillfg_colorbg_color)r  _write_a_fg_clr_write_a_bg_clrr   )rX   ri   r  r\   r\   r]   rb  u  s
   zChart._write_a_patt_fillc                 C   *   t |}| d | | | d d S )Nza:fgClrr   r  rk  r   rX   r   r\   r\   r]   r       

zChart._write_a_fg_clrc                 C   r  )Nza:bgClrr  r  r\   r\   r]   r    r  zChart._write_a_bg_clrr  )F)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r{   r}   r  r~   r   r   r   r   r   r   r   r   r   rc  r   r   rz  r}  r  rV   r   r   r   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r$  r%  r&  r  r   r*  r+  r,  r  r  r  r2  r  r  r6  r<  r=  r>  rK  rF  rH  rN  rI  rG  rW  rX  r'  r  r_  r^  r   rd  ra  rQ  rk  rl  rh  r  rv  ru  rw  rx  ry  rz  r{  r}  r|  r~  r  r  r  r  r  r  r  r  r  r9  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rR  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rc  r  r  r  r  r  rb  r  r  __classcell__r\   r\   rZ   r]   r      s   I #5%%! "E;;~(5,0

'%F1#	ibcq




					

		9



"	0		

	
 92$
r   )r
  r   warningsr   r  r   r   r   utilityr   r   r	   r
   r   r   	XMLwriterr   r\   r\   r\   r]   <module>   s   