o
    j                     @  s   d 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
mZ ddlmZmZ ddlmZ dd	lmZmZmZmZmZ G d
d deZG dd deZG dd deZG dd deZG dd deZdS )z@Custom element classes for top-level chart-related XML elements.    )annotations)cast)	parse_xml)CT_Title)nsdeclsqn)ST_Style	XsdString)CT_TextBody)BaseOxmlElementOneAndOnlyOneRequiredAttribute
ZeroOrMore	ZeroOrOnec                   @  s   e Zd ZU dZdZededd dZededd dZed	Z	ed
edd dZ
edeZded< edd Zejdd ZedddZdd ZdS )CT_Chartz`c:chart` custom element class.)c:titlec:autoTitleDeletedzc:pivotFmtszc:view3Dzc:floorz
c:sideWallz
c:backWall
c:plotAreac:legendzc:plotVisOnlyzc:dispBlanksAszc:showDLblsOverMaxc:extLstr      N
successorsr      r   r   	   r:idstrrIdc                 C  s   | j }|du r	dS dS )zK
        True if this chart has a legend defined, False otherwise.
        NFT)legend)selfr    r    U/home/air/Certificate/back/venv/lib/python3.10/site-packages/pptx/oxml/chart/chart.py
has_legend-   s   zCT_Chart.has_legendc                 C  s2   t |du r|   dS | jdu r|   dS dS )a-  
        Add, remove, or leave alone the ``<c:legend>`` child element depending
        on current state and *bool_value*. If *bool_value* is |True| and no
        ``<c:legend>`` element is present, a new default element is added.
        When |False|, any existing legend element is removed.
        FN)bool_remove_legendr   _add_legend)r   
bool_valuer    r    r!   r"   7   s
   
returnc              
   C  s*   t ttdtd dtd d|  dS )zReturn a new `c:chart` element.z	<c:chart c rz r:id="z"/>)r   r   r   r   )r   r    r    r!   	new_chartE   s   *zCT_Chart.new_chartc                 C     t  S N)r   	new_titler   r    r    r!   
_new_titleJ      zCT_Chart._new_title)r   r   r'   r   )__name__
__module____qualname____doc___tag_seqr   titleautoTitleDeletedr   plotArear   r   r	   r   __annotations__propertyr"   setterstaticmethodr+   r0   r    r    r    r!   r      s   
 
	
r   c                   @  s   e Zd ZdZdZededd dZededd dZed	Z	ed
edd dZ
ededd dZ[edd Zedd Zedd Zdd Zedd Zedd Zedd Zdd Zdd ZdS ) CT_ChartSpacez,`c:chartSpace` root element of a chart part.)
c:date1904zc:langzc:roundedCornersc:stylezc:clrMapOvrzc:pivotSourcezc:protectionc:chartzc:spPrc:txPrc:externalDatazc:printSettingszc:userShapesr   r?   r   Nr   r@      rA   rB   
   rC      c                 C  
   | j jjS r-   )chartr9   	catAx_lstr/   r    r    r!   rI   h      
zCT_ChartSpace.catAx_lstc                 C  s   | j }|du r	dS |jS )z
        Return |True| if the `c:date1904` child element resolves truthy,
        |False| otherwise. This value indicates whether date number values
        are based on the 1900 or 1904 epoch.
        NF)date1904val)r   rK   r    r    r!   	date_1904l      zCT_ChartSpace.date_1904c                 C  s
   |  dS )Nzc:chart/c:plotArea/c:dateAx)xpathr/   r    r    r!   
dateAx_lstx   rJ   zCT_ChartSpace.dateAx_lstc                 C  s
   | j  S )z>Return the `c:title` grandchild, newly created if not present.)rH   get_or_add_titler/   r    r    r!   rQ   |   rJ   zCT_ChartSpace.get_or_add_titlec                 C  s   | j jS )zc
        Return the required `c:chartSpace/c:chart/c:plotArea` grandchild
        element.
        )rH   r9   r/   r    r    r!   r9      s   zCT_ChartSpace.plotAreac                 C  rG   r-   )rH   r9   	valAx_lstr/   r    r    r!   rR      rJ   zCT_ChartSpace.valAx_lstc                 C  s   | j }|du r	dS |jS )z
        The string in the required ``r:id`` attribute of the
        `<c:externalData>` child, or |None| if no externalData element is
        present.
        N)externalDatar   r   rS   r    r    r!   xlsx_part_rId   rN   zCT_ChartSpace.xlsx_part_rIdc                 C  s"   |   }|jdd | | |S )zu
        Always add a ``<c:autoUpdate val="0"/>`` child so auto-updating
        behavior is off by default.
        F)rL   )_new_externalData_add_autoUpdate_insert_externalDatarT   r    r    r!   _add_externalData   s   
zCT_ChartSpace._add_externalDatac                 C  r,   r-   )r
   new_txPrr/   r    r    r!   	_new_txPr   r1   zCT_ChartSpace._new_txPr)r2   r3   r4   r5   r6   r   rK   styler   rH   txPrrS   r;   rI   rM   rP   rQ   r9   rR   rU   rY   r[   r    r    r    r!   r>   N   s0    






r>   c                   @  s"   e Zd ZdZedZedeZdS )CT_ExternalDatazq
    `<c:externalData>` element, defining link to embedded Excel package part
    containing the chart data.
    zc:autoUpdater   N)	r2   r3   r4   r5   r   
autoUpdater   r	   r   r    r    r    r!   r^      s    r^   c                   @  sl   e Zd ZdZedZedZdd Zdd Ze	dd	 Z
e	d
d Ze	dd Ze	dd Ze	dd ZdS )CT_PlotAreaz#
    ``<c:plotArea>`` element.
    zc:catAxzc:valAxc                 c  s(    |   D ]}| D ]}|V  qqdS )z
        Generate each of the `c:ser` elements in this chart, ordered first by
        the document order of the containing xChart element, then by their
        ordering within the xChart element (not necessarily document order).
        N)iter_xCharts	iter_sers)r   xChartserr    r    r!   rb      s   zCT_PlotArea.iter_sersc                 c  s    t dt dt dt dt dt dt dt dt d	t d
t dt dt dt dt dt df}|  D ]}|j|vr?q7|V  q7dS )zA
        Generate each xChart child element in document.
        zc:area3DChartzc:areaChartzc:bar3DChartz
c:barChartzc:bubbleChartzc:doughnutChartzc:line3DChartzc:lineChartzc:ofPieChartzc:pie3DChartz
c:pieChartzc:radarChartzc:scatterChartzc:stockChartzc:surface3DChartzc:surfaceChartN)r   iterchildrentag)r   	plot_tagschildr    r    r!   ra      s.   
zCT_PlotArea.iter_xChartsc                 C  s    | j d }|j}|sdS |d S )z
        Return the last `<c:ser>` element in the last xChart element, based
        on series order (not necessarily the same element as document order).
        N)xChartssers)r   last_xChartrk   r    r    r!   last_ser   s
   
zCT_PlotArea.last_serc                 C  $   dd | j D }|sdS t|d S )z
        Return the next available `c:ser/c:idx` value within the scope of
        this chart, the maximum idx value found on existing series,
        incremented by one.
        c                 S     g | ]}|j jqS r    )idxrL   .0sr    r    r!   
<listcomp>       z(CT_PlotArea.next_idx.<locals>.<listcomp>r   r   rk   max)r   idx_valsr    r    r!   next_idx      zCT_PlotArea.next_idxc                 C  rn   )z
        Return the next available `c:ser/c:order` value within the scope of
        this chart, the maximum order value found on existing series,
        incremented by one.
        c                 S  ro   r    )orderrL   rq   r    r    r!   rt      ru   z*CT_PlotArea.next_order.<locals>.<listcomp>r   r   rv   )r   
order_valsr    r    r!   
next_order   rz   zCT_PlotArea.next_orderc                 C     t |  S )a  
        Return a sequence containing all the `c:ser` elements in this chart,
        ordered first by the document order of the containing xChart element,
        then by their ordering within the xChart element (not necessarily
        document order).
        )tuplerb   r/   r    r    r!   rk     s   zCT_PlotArea.sersc                 C  r~   )zv
        Return a sequence containing all the `c:{x}Chart` elements in this
        chart, in document order.
        )r   ra   r/   r    r    r!   rj     s   zCT_PlotArea.xChartsN)r2   r3   r4   r5   r   catAxvalAxrb   ra   r;   rm   ry   r}   rk   rj   r    r    r    r!   r`      s     




	r`   c                   @  s   e Zd ZdZedeZdS )CT_Stylez9
    ``<c:style>`` element; defines the chart style.
    rL   N)r2   r3   r4   r5   r   r   rL   r    r    r    r!   r     s    r   N)r5   
__future__r   typingr   	pptx.oxmlr   pptx.oxml.chart.sharedr   pptx.oxml.nsr   r   pptx.oxml.simpletypesr   r	   pptx.oxml.textr
   pptx.oxml.xmlchemyr   r   r   r   r   r   r>   r^   r`   r   r    r    r    r!   <module>   s    	9X
e