
    hip3                       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 ddlmZ ddlmZmZ dd	lmZ  G d
 de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Zd Z G d d e          Zd!S )"zPlot-related objects.

A plot is known as a chart group in the MS API. A chart can have more than one plot overlayed on
each other, such as a line plot layered over a bar plot.
    )annotations)
Categories)
DataLabels)SeriesCollection)XL_CHART_TYPE)qn)	ST_BarDirST_Grouping)lazypropertyc                       e Zd ZdZ fdZed             Zed             Zed             Z	ed             Z
e
j        d             Z
ed             Zed	             Zej        d
             Z xZS )	_BasePlotz
    A distinct plot that appears in the plot area of a chart. A chart may
    have more than one plot, in which case they appear as superimposed
    layers, such as a line plot appearing on top of a bar chart.
    c                r    t          t          |                                            || _        || _        d S N)superr   __init___element_chart)selfxChartchart	__class__s      g/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/pptx/chart/plot.pyr   z_BasePlot.__init__   s1    i'')))    c                *    t          | j                  S )a  
        Returns a |category.Categories| sequence object containing
        a |category.Category| object for each of the category labels
        associated with this plot. The |category.Category| class derives from
        ``str``, so the returned value can be treated as a simple sequence of
        strings for the common case where all you need is the labels in the
        order they appear on the chart. |category.Categories| provides
        additional properties for dealing with hierarchical categories when
        required.
        )r   r   r   s    r   
categoriesz_BasePlot.categories   s     $-(((r   c                    | j         S )z:
        The |Chart| object containing this plot.
        )r   r   s    r   r   z_BasePlot.chart,   s    
 {r   c                Z    | j         j        }|t          d          t          |          S )z
        |DataLabels| instance providing properties and methods on the
        collection of data labels associated with this plot.
        Nz9plot has no data labels, set has_data_labels = True first)r   dLbls
ValueErrorr   )r   r   s     r   data_labelsz_BasePlot.data_labels3   s0     #=XYYY%   r   c                    | j         j        duS )z
        Read/write boolean, |True| if the series has data labels. Assigning
        |True| causes data labels to be added to the plot. Assigning False
        removes any existing data labels.
        N)r   r   r   s    r   has_data_labelsz_BasePlot.has_data_labels>   s     }"$..r   c                    t          |          du r| j                                         dS | j        j        '| j                                        }d|j        _        dS dS )aZ  
        Add, remove, or leave alone the ``<c:dLbls>`` child element depending
        on current state and assigned *value*. If *value* is |True| and no
        ``<c:dLbls>`` element is present, a new default element is added with
        default child elements and settings. When |False|, any existing dLbls
        element is removed.
        FNT)boolr   _remove_dLblsr   
_add_dLblsshowValval)r   valuer   s      r   r#   z_BasePlot.has_data_labelsG   se     ;;%M'')))))}"*0022$(!!! +*r   c                *    t          | j                  S )z
        A sequence of |Series| objects representing the series in this plot,
        in the order they appear in the plot.
        )r   r   r   s    r   seriesz_BasePlot.seriesW   s      ...r   c                0    | j         j        }|dS |j        S )a  
        Read/write boolean value specifying whether to use a different color
        for each of the points in this plot. Only effective when there is
        a single series; PowerPoint automatically varies color by series when
        more than one series is present.
        NT)r   
varyColorsr)   )r   r.   s     r   vary_by_categoriesz_BasePlot.vary_by_categories_   s!     ]-
4~r   c                \    t          |          | j                                        _        d S r   )r%   r   get_or_add_varyColorsr)   r   r*   s     r   r/   z_BasePlot.vary_by_categoriesl   s$    48KK++--111r   )__name__
__module____qualname____doc__r   r   r   propertyr   r!   r#   setterr,   r/   __classcell__)r   s   @r   r   r      s)            
 ) ) \)   X ! ! X! / / X/ ) ) ) / / \/ 
 
 X
 @ @ @ @ @ @ @r   r   c                      e Zd ZdZdS )AreaPlotz
    An area plot.
    Nr3   r4   r5   r6    r   r   r;   r;   q              r   r;   c                      e Zd ZdZdS )
Area3DPlotz$
    A 3-dimensional area plot.
    Nr<   r=   r   r   r@   r@   w   r>   r   r@   c                  ~    e Zd ZdZed             Zej        d             Zed             Zej        d             ZdS )BarPlotz!
    A bar chart-style plot.
    c                0    | j         j        }|dS |j        S )z
        Width of gap between bar(s) of each category, as an integer
        percentage of the bar width. The default value for a new bar chart is
        150, representing 150% or 1.5 times the width of a single bar.
        N   )r   gapWidthr)   )r   rE   s     r   	gap_widthzBarPlot.gap_width   s!     =)3|r   c                F    | j                                         }||_        d S r   )r   get_or_add_gapWidthr)   )r   r*   rE   s      r   rF   zBarPlot.gap_width   s     =4466r   c                0    | j         j        }|dS |j        S )a  
        Read/write int value in range -100..100 specifying a percentage of
        the bar width by which to overlap adjacent bars in a multi-series bar
        chart. Default is 0. A setting of -100 creates a gap of a full bar
        width and a setting of 100 causes all the bars in a category to be
        superimposed. A stacked bar plot has overlap of 100 by default.
        Nr   )r   overlapr)   )r   rJ   s     r   rJ   zBarPlot.overlap   s      -'?1{r   c                    |dk    r| j                                          dS || j                                         _        dS )z
        Set the value of the ``<c:overlap>`` child element to *int_value*,
        or remove the overlap element if *int_value* is 0.
        r   N)r   _remove_overlapget_or_add_overlapr)   r2   s     r   rJ   zBarPlot.overlap   sB     A::M))+++F16((**...r   N)r3   r4   r5   r6   r7   rF   r8   rJ   r=   r   r   rB   rB   }   s          	 	 X	      X ^7 7 ^7 7 7r   rB   c                  H    e Zd ZdZed             Zej        d             ZdS )
BubblePlotz
    A bubble chart plot.
    c                0    | j         j        }|dS |j        S )z
        An integer between 0 and 300 inclusive indicating the percentage of
        the default size at which bubbles should be displayed. Assigning
        |None| produces the same behavior as assigning `100`.
        Nd   )r   bubbleScaler)   )r   rR   s     r   bubble_scalezBubblePlot.bubble_scale   s!     m/3r   c                z    | j         }|                                 |d S |                                }||_        d S r   )r   _remove_bubbleScale_add_bubbleScaler)   )r   r*   bubbleChartrR   s       r   rS   zBubblePlot.bubble_scale   sA    m'')))=F!2244r   N)r3   r4   r5   r6   r7   rS   r8   r=   r   r   rO   rO      sX          	 	 X	          r   rO   c                      e Zd ZdZdS )DoughnutPlotz
    An doughnut plot.
    Nr<   r=   r   r   rY   rY      r>   r   rY   c                      e Zd ZdZdS )LinePlotz"
    A line chart-style plot.
    Nr<   r=   r   r   r[   r[      r>   r   r[   c                      e Zd ZdZdS )PiePlotz!
    A pie chart-style plot.
    Nr<   r=   r   r   r]   r]      r>   r   r]   c                      e Zd ZdZdS )	RadarPlotz
    A radar-style plot.
    Nr<   r=   r   r   r_   r_      r>   r   r_   c                      e Zd ZdZdS )XyPlotz
    An XY (scatter) plot.
    Nr<   r=   r   r   ra   ra      r>   r   ra   c                   	 t          d          t          t          d          t          t          d          t          t          d          t          t          d          t
          t          d          t          t          d          t          t          d          t          t          d	          t          i	| j
                 }n%# t          $ r t          d
| j
        z            w xY w || |          S )zk
    Return an instance of the appropriate subclass of _BasePlot based on the
    tagname of *xChart*.
    zc:areaChartzc:area3DChartz
c:barChartzc:bubbleChartzc:doughnutChartzc:lineChartz
c:pieChartzc:radarChartzc:scatterChartzunsupported plot type %s)r   r;   r@   rB   rO   rY   r[   r]   r_   ra   tagKeyErrorr    )r   r   PlotClss      r   PlotFactoryrf      s    
B}x|g !!<}x|g~	  &

 *
  B B B3fj@AAAB 765!!!s   CC "C&c                      e Zd ZdZed             Zed             Zed             Zed             Zed             Z	ed             Z
ed             Zed	             Zed
             Zed             ZdS )PlotTypeInspectorz
    "One-shot" service object that knows how to identify the type of a plot
    as a member of the XL_CHART_TYPE enumeration.
    c           
        	 | j         | j        | j        | j        | j        | j        | j        | j        | j        d	|j	        j
                 }n*# t          $ r t          d|j	        j
        z            w xY w ||          S )zo
        Return the member of :ref:`XlChartType` that corresponds to the chart
        type of *plot*.
        )	r;   r@   rB   rO   rY   r[   r]   r_   ra   z#chart_type() not implemented for %s)_differentiate_area_chart_type!_differentiate_area_3d_chart_type_differentiate_bar_chart_type _differentiate_bubble_chart_type"_differentiate_doughnut_chart_type_differentiate_line_chart_type_differentiate_pie_chart_type_differentiate_radar_chart_type_differentiate_xy_chart_typer   r3   rd   NotImplementedError)clsplotchart_type_methods      r   
chart_typezPlotTypeInspector.chart_type  s    	>!C<!B # F>< @:
! 
! n%
!'  	 	 	%58OO  	 ! &&&s   A	A 'A3c                    t           j        t          j        t           j        t          j        t           j        t          j        i|j        j	                 S r   )
r
   STANDARDXLTHREE_D_AREASTACKEDTHREE_D_AREA_STACKEDPERCENT_STACKEDTHREE_D_AREA_STACKED_100r   grouping_valrt   ru   s     r   rk   z3PlotTypeInspector._differentiate_area_3d_chart_type  s=      "/!8')D
 -
$	& 	&r   c                    t           j        t          j        t           j        t          j        t           j        t          j        i|j        j	                 S r   )
r
   ry   rz   AREAr|   AREA_STACKEDr~   AREA_STACKED_100r   r   r   s     r   rj   z0PlotTypeInspector._differentiate_area_chart_type#  s<      "'')<
 -
$	& 	&r   c                   |j         }|j        j        t          j        k    rOt
          j        t          j        t
          j	        t          j
        t
          j        t          j        i|j                 S |j        j        t          j        k    rOt
          j        t          j        t
          j	        t          j        t
          j        t          j        i|j                 S t%          d|j        j        z            )Nz"invalid barChart.barDir value '%s')r   barDirr)   r	   BARr
   	CLUSTEREDrz   BAR_CLUSTEREDr|   BAR_STACKEDr~   BAR_STACKED_100r   COLCOLUMN_CLUSTEREDCOLUMN_STACKEDCOLUMN_STACKED_100r    )rt   ru   barCharts      r   rl   z/PlotTypeInspector._differentiate_bar_chart_type+  s    =?)-//%r'7#R^+R-? #	% %
 ?)-//%r':#R%6+R-B #	% %
 =@SSTTTr   c                    d }|j         } ||          }|t          j        S |j        rt          j        S t          j        S )Nc                D    |                      d          }|r|d         nd S )Nzc:ser/c:bubble3Dr   xpath)rW   resultss     r   first_bubble3DzJPlotTypeInspector._differentiate_bubble_chart_type.<locals>.first_bubble3D>  s)    !''(:;;G!(271::d2r   )r   rz   BUBBLEr)   BUBBLE_THREE_D_EFFECT)rt   ru   r   rW   bubble3Ds        r   rm   z2PlotTypeInspector._differentiate_bubble_chart_type<  sR    	3 	3 	3 m!>+..9< 	,++yr   c                n    |j         }|                    d          }|rt          j        nt          j        S Nz./c:ser/c:explosion)r   r   rz   DOUGHNUT_EXPLODEDDOUGHNUT)rt   ru   doughnutChart	explosions       r   rn   z4PlotTypeInspector._differentiate_doughnut_chart_typeK  s2    !''(=>>	'0Ar##bkAr   c                   |j         fd} |            rTt          j        t          j        t          j        t          j        t          j        t          j        i|j         j	                 S t          j        t          j
        t          j        t          j        t          j        t          j        i|j         j	                 S )Nc                 :                         d          } | rdS dS )Nz$c:ser/c:marker/c:symbol[@val="none"]FTr   )matches	lineCharts    r   has_line_markerszJPlotTypeInspector._differentiate_line_chart_type.<locals>.has_line_markersU  s'    oo&LMMG u4r   )r   r
   ry   rz   LINE_MARKERSr|   LINE_MARKERS_STACKEDr~   LINE_MARKERS_STACKED_100r   LINELINE_STACKEDLINE_STACKED_100)rt   ru   r   r   s      @r   ro   z0PlotTypeInspector._differentiate_line_chart_typeQ  s    M		 	 	 	 	  	*$bo#R%<+R-H m(	* * $bg#R_+R-@ m(	* *r   c                n    |j         }|                    d          }|rt          j        nt          j        S r   )r   r   rz   PIE_EXPLODEDPIE)rt   ru   pieChartr   s       r   rp   z/PlotTypeInspector._differentiate_pie_chart_typeh  s.    =NN#899	"+7r7r   c                    |j                             d          d                             d          }fd}|t          j        S |dk    rt          j        S  |            rt          j        S t          j        S )Nzc:radarStyler   r)   c                 x                         d          } | r!| d                             d          dk    rdS dS Nzc:ser/c:marker/c:symbolr   r)   noneTFr   get)r   
radarCharts    r   	noMarkerszDPlotTypeInspector._differentiate_radar_chart_type.<locals>.noMarkerss  sC     &&'@AAG 71:>>%00F::t5r   filled)r   r   r   rz   RADARRADAR_FILLEDRADAR_MARKERS)rt   ru   radar_styler   r   s       @r   rq   z1PlotTypeInspector._differentiate_radar_chart_typen  s    ]
 &&~66q9==eDD	 	 	 	 	 8O(""?"9;; 	8Or   c                f   |j         fd}fd}                    d          d                             d          }|dk    r8 |            rt          j        S  |            rt          j        S t          j        S |dk    r" |            rt          j        S t          j        S t          j        S )Nc                 H    t                               d                    S )Nzc:ser/c:spPr/a:ln/a:noFill)r%   r   )scatterCharts   r   noLinez>PlotTypeInspector._differentiate_xy_chart_type.<locals>.noLine  s     **+GHHIIIr   c                 x                         d          } | r!| d                             d          dk    rdS dS r   r   )symbolsr   s    r   r   zAPlotTypeInspector._differentiate_xy_chart_type.<locals>.noMarkers  sC    "(()BCCG 71:>>%00F::t5r   zc:scatterStyler   r)   
lineMarkersmoothMarker)	r   r   r   rz   
XY_SCATTERXY_SCATTER_LINES_NO_MARKERSXY_SCATTER_LINESXY_SCATTER_SMOOTH_NO_MARKERSXY_SCATTER_SMOOTH)rt   ru   r   r   scatter_styler   s        @r   rr   z.PlotTypeInspector._differentiate_xy_chart_type  s    }	J 	J 	J 	J 	J	 	 	 	 	 %**+;<<Q?CCEJJL((vxx %}$y{{ 655&&N**y{{ 766''}r   N)r3   r4   r5   r6   classmethodrw   rk   rj   rl   rm   rn   ro   rp   rq   rr   r=   r   r   rh   rh      s2        
 ' ' ['. & & [& & & [& U U [U    [ B B [B
 * * [*, 8 8 [8
     [ $   [  r   rh   N) r6   
__future__r   pptx.chart.categoryr   pptx.chart.datalabelr   pptx.chart.seriesr   pptx.enum.chartr   rz   pptx.oxml.nsr   pptx.oxml.simpletypesr	   r
   	pptx.utilr   objectr   r;   r@   rB   rO   rY   r[   r]   r_   ra   rf   rh   r=   r   r   <module>r      s    # " " " " " * * * * * * + + + + + + . . . . . . / / / / / /       8 8 8 8 8 8 8 8 " " " " " "\@ \@ \@ \@ \@ \@ \@ \@~    y          -7 -7 -7 -7 -7i -7 -7 -7`               6    9       y       i       	       Y   " " "._ _ _ _ _ _ _ _ _ _r   