o
    7 h                     @  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    ]/var/www/html/figdemos/bartoux_crm/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)boolZ_remove_legendr   Z_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   titleZautoTitleDeletedr   plotArear   r   r	   r   __annotations__propertyr"   setterstaticmethodr)   r.   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=      r>   r?   
   r@      c                 C  
   | j jjS r+   )chartr6   	catAx_lstr-   r    r    r!   rF   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   rH   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   rG   zCT_ChartSpace.dateAx_lstc                 C  s
   | j  S )z>Return the `c:title` grandchild, newly created if not present.)rE   get_or_add_titler-   r    r    r!   rN   |   rG   zCT_ChartSpace.get_or_add_titlec                 C  s   | j jS )zc
        Return the required `c:chartSpace/c:chart/c:plotArea` grandchild
        element.
        )rE   r6   r-   r    r    r!   r6      s   zCT_ChartSpace.plotAreac                 C  rD   r+   )rE   r6   	valAx_lstr-   r    r    r!   rO      rG   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   rP   r    r    r!   xlsx_part_rId   rK   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)rI   )Z_new_externalDataZ_add_autoUpdateZ_insert_externalDatarQ   r    r    r!   _add_externalData   s   
zCT_ChartSpace._add_externalDatac                 C  r*   r+   )r
   new_txPrr-   r    r    r!   	_new_txPr   r/   zCT_ChartSpace._new_txPr)r0   r1   r2   r3   r4   r   rH   styler   rE   txPrrP   r8   rF   rJ   rM   rN   r6   rO   rR   rS   rU   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)	r0   r1   r2   r3   r   Z
autoUpdater   r	   r   r    r    r    r!   rX      s    rX   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   ZxChartZserr    r    r!   r[      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   Z	plot_tagschildr    r    r!   rZ      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   Zlast_xChartra   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    )idxrI   .0sr    r    r!   
<listcomp>       z(CT_PlotArea.next_idx.<locals>.<listcomp>r   r   ra   max)r   Zidx_valsr    r    r!   next_idx      zCT_PlotArea.next_idxc                 C  rc   )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  rd   r    )orderrI   rf   r    r    r!   ri      rj   z*CT_PlotArea.next_order.<locals>.<listcomp>r   r   rk   )r   Z
order_valsr    r    r!   
next_order   rn   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).
        )tupler[   r-   r    r    r!   ra     s   zCT_PlotArea.sersc                 C  rq   )zv
        Return a sequence containing all the `c:{x}Chart` elements in this
        chart, in document order.
        )rr   rZ   r-   r    r    r!   r`     s   zCT_PlotArea.xChartsN)r0   r1   r2   r3   r   ZcatAxZvalAxr[   rZ   r8   rb   rm   rp   ra   r`   r    r    r    r!   rY      s     




	rY   c                   @  s   e Zd ZdZedeZdS )CT_Stylez9
    ``<c:style>`` element; defines the chart style.
    rI   N)r0   r1   r2   r3   r   r   rI   r    r    r    r!   rs     s    rs   N)r3   
__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;   rX   rY   rs   r    r    r    r!   <module>   s    	9X
e