66
77from pptx .enum .chart import XL_AXIS_CROSSES , XL_TICK_LABEL_POSITION , XL_TICK_MARK
88from pptx .oxml .chart .shared import CT_Title
9- from pptx .oxml .simpletypes import ST_AxisUnit , ST_LblOffset
9+ from pptx .oxml .simpletypes import ST_AxisUnit , ST_LblOffset , ST_Orientation
1010from pptx .oxml .text import CT_TextBody
1111from pptx .oxml .xmlchemy import (
1212 BaseOxmlElement ,
@@ -30,6 +30,18 @@ def defRPr(self):
3030 defRPr = txPr .defRPr
3131 return defRPr
3232
33+ @property
34+ def orientation (self ):
35+ """Value of `val` attribute of `c:scaling/c:orientation` grandchild element.
36+
37+ Defaults to `ST_Orientation.MIN_MAX` if attribute or any ancestors are not
38+ present.
39+ """
40+ orientation = self .scaling .orientation
41+ if orientation is None :
42+ return ST_Orientation .MIN_MAX
43+ return orientation .val
44+
3345 def _new_title (self ):
3446 return CT_Title .new_title ()
3547
@@ -155,13 +167,25 @@ class CT_LblOffset(BaseOxmlElement):
155167 val = OptionalAttribute ("val" , ST_LblOffset , default = 100 )
156168
157169
170+ class CT_Orientation (BaseOxmlElement ):
171+ """`c:xAx/c:scaling/c:orientation` element, defining category order.
172+
173+ Used to reverse the order categories appear in on a bar chart so they start at the
174+ top rather than the bottom. Because we read top-to-bottom, the default way looks odd
175+ to many and perhaps most folks. Also applicable to value and date axes.
176+ """
177+
178+ val = OptionalAttribute ("val" , ST_Orientation , default = ST_Orientation .MIN_MAX )
179+
180+
158181class CT_Scaling (BaseOxmlElement ):
159182 """`c:scaling` element.
160183
161184 Defines axis scale characteristics such as maximum value, log vs. linear, etc.
162185 """
163186
164187 _tag_seq = ("c:logBase" , "c:orientation" , "c:max" , "c:min" , "c:extLst" )
188+ orientation = ZeroOrOne ("c:orientation" , successors = _tag_seq [2 :])
165189 max = ZeroOrOne ("c:max" , successors = _tag_seq [3 :])
166190 min = ZeroOrOne ("c:min" , successors = _tag_seq [4 :])
167191 del _tag_seq
0 commit comments