
    lip3                    d   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y!)"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                F    t         t        |           || _        || _        y N)superr   __init___element_chart)selfxChartchart	__class__s      M/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/pptx/chart/plot.pyr   z_BasePlot.__init__   s    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                ^    | j                   j                  }|t        d      t        |      S )z
        |DataLabels| instance providing properties and methods on the
        collection of data labels associated with this plot.
        z9plot has no data labels, set has_data_labels = True first)r   dLbls
ValueErrorr   )r   r   s     r   data_labelsz_BasePlot.data_labels3   s/     ##=XYY%  r   c                2    | 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                  j                          y| j                  j                  ,| j                  j	                         }d|j
                  _        yy)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   sS     ;%MM'')}}""*00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                L    | j                   j                  }|y|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.
        T)r   
varyColorsr)   )r   r.   s     r   vary_by_categoriesz_BasePlot.vary_by_categories_   s&     ]]--
~~r   c                T    t        |      | j                  j                         _        y r   )r%   r   get_or_add_varyColorsr)   r   r*   s     r   r/   z_BasePlot.vary_by_categoriesl   s    48K++-1r   )__name__
__module____qualname____doc__r   r   r   propertyr   r!   r#   setterr,   r/   __classcell__)r   s   @r   r   r      s    
 ) )   ! ! / / ) ) / / 
 
 @ @r   r   c                      e Zd ZdZy)AreaPlotz
    An area plot.
    Nr3   r4   r5   r6    r   r   r;   r;   q       r   r;   c                      e Zd ZdZy)
Area3DPlotz$
    A 3-dimensional area plot.
    Nr<   r=   r   r   r@   r@   w   r>   r   r@   c                  x    e Zd ZdZed        Zej                  d        Zed        Zej                  d        Zy)BarPlotz!
    A bar chart-style plot.
    c                L    | j                   j                  }|y|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.
           )r   gapWidthr)   )r   rE   s     r   	gap_widthzBarPlot.gap_width   s&     ==))||r   c                F    | j                   j                         }||_        y r   )r   get_or_add_gapWidthr)   )r   r*   rE   s      r   rF   zBarPlot.gap_width   s    ==446r   c                L    | j                   j                  }|y|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.
        r   )r   overlapr)   )r   rJ   s     r   rJ   zBarPlot.overlap   s%     --''?{{r   c                    |dk(  r| j                   j                          y|| j                   j                         _        y)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   s3     A:MM))+16((*.r   N)r3   r4   r5   r6   r7   rF   r8   rJ   r=   r   r   rB   rB   }   sa     	 	     ^^7 7r   rB   c                  D    e Zd ZdZed        Zej                  d        Zy)
BubblePlotz
    A bubble chart plot.
    c                L    | j                   j                  }|y|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`.
        d   )r   bubbleScaler)   )r   rR   s     r   bubble_scalezBubblePlot.bubble_scale   s&     mm//r   c                p    | j                   }|j                          |y |j                         }||_        y r   )r   _remove_bubbleScale_add_bubbleScaler)   )r   r*   bubbleChartrR   s       r   rS   zBubblePlot.bubble_scale   s4    mm'')=!224r   N)r3   r4   r5   r6   r7   rS   r8   r=   r   r   rO   rO      s5     	 	    r   rO   c                      e Zd ZdZy)DoughnutPlotz
    An doughnut plot.
    Nr<   r=   r   r   rY   rY      r>   r   rY   c                      e Zd ZdZy)LinePlotz"
    A line chart-style plot.
    Nr<   r=   r   r   r[   r[      r>   r   r[   c                      e Zd ZdZy)PiePlotz!
    A pie chart-style plot.
    Nr<   r=   r   r   r]   r]      r>   r   r]   c                      e Zd ZdZy)	RadarPlotz
    A radar-style plot.
    Nr<   r=   r   r   r_   r_      r>   r   r_   c                      e Zd ZdZy)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                     } || |      S # t        $ r t        d
| j                  z        w xY w)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~	 &

 **
 65!!  B3fjj@AABs   BB! !"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y)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           
     l   	 | j                   | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  d	|j                  j                     } ||      S # t        $ r# t        d|j                  j                  z        w xY w)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C<<!BB # F F>><< @@::
! nn%%
!' !&&	  	%58O8OO 	s   A=B ,B3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  sS       "//!8!8'')D)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#  sQ       "'''')<)<
 --
$
$	& 	&r   c                   |j                   }|j                  j                  t        j                  k(  rit
        j                  t        j                  t
        j                  t        j                  t
        j                  t        j                  i|j                     S |j                  j                  t        j                  k(  rit
        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'7##R^^++R-?-? ##	% %
 ??)--/%%r':':##R%6%6++R-B-B ##	% %
 =@S@SSTTr   c                    d }|j                   } ||      }|t        j                  S |j                  rt        j                  S t        j                  S )Nc                6    | j                  d      }|r|d   S d S )Nzc:ser/c:bubble3Dr   xpath)rW   resultss     r   first_bubble3DzJPlotTypeInspector._differentiate_bubble_chart_type.<locals>.first_bubble3D>  s$    !''(:;G!(71:2d2r   )r   rz   BUBBLEr)   BUBBLE_THREE_D_EFFECT)rt   ru   r   rW   bubble3Ds        r   rm   z2PlotTypeInspector._differentiate_bubble_chart_type<  sI    	3 mm!+.99<<+++yyr   c                    |j                   }|j                  d      }|rt        j                  S 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  s3    !''(=>	'0r##AbkkAr   c                    |j                   fd} |       rst        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                 .    j                  d      } | ryy)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MGr   )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    MM		 $$boo##R%<%<++R-H-H mm((	* * $$bgg##R__++R-@-@ mm((	* *r   c                    |j                   }|j                  d      }|rt        j                  S 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	"+r77r   c                   |j                   j                  d      d   j                  d      }fd}|t        j                  S |dk(  rt        j
                  S  |       rt        j                  S t        j                  S )Nzc:radarStyler   r)   c                 \    j                  d      } | r| d   j                  d      dk(  ryyNzc:ser/c:marker/c:symbolr   r)   noneTFr   get)r   
radarCharts    r   	noMarkerszDPlotTypeInspector._differentiate_radar_chart_type.<locals>.noMarkerss  s1     &&'@AG71:>>%0F:r   filled)r   r   r   rz   RADARRADAR_FILLEDRADAR_MARKERS)rt   ru   radar_styler   r   s       @r   rq   z1PlotTypeInspector._differentiate_radar_chart_typen  sn    ]]
 &&~6q9==eD	 88O("??";88Or   c                t   |j                   fd}fd}j                  d      d   j                  d      }|dk(  r> |       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                 8    t         j                  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IIr   c                 \    j                  d      } | r| d   j                  d      dk(  ryyr   r   )symbolsr   s    r   r   zAPlotTypeInspector._differentiate_xy_chart_type.<locals>.noMarkers  s1    "(()BCG71:>>%0F:r   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	 %**+;<Q?CCEJL(x}}${555&&&N*{666'''}}r   N)r3   r4   r5   r6   classmethodrw   rk   rj   rl   rm   rn   ro   rp   rq   rr   r=   r   r   rh   rh      s    
 ' '. & & & & U U    B B
 * *, 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 "\@ \@~y  -7i -7`   69 y i 	 Y "._ _r   