ps-python-pptx 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pptx/__init__.py +84 -0
- pptx/action.py +270 -0
- pptx/api.py +49 -0
- pptx/chart/__init__.py +0 -0
- pptx/chart/axis.py +523 -0
- pptx/chart/category.py +200 -0
- pptx/chart/chart.py +280 -0
- pptx/chart/data.py +864 -0
- pptx/chart/datalabel.py +288 -0
- pptx/chart/legend.py +79 -0
- pptx/chart/marker.py +70 -0
- pptx/chart/plot.py +412 -0
- pptx/chart/point.py +101 -0
- pptx/chart/series.py +258 -0
- pptx/chart/xlsx.py +272 -0
- pptx/chart/xmlwriter.py +1840 -0
- pptx/dml/__init__.py +0 -0
- pptx/dml/chtfmt.py +40 -0
- pptx/dml/color.py +301 -0
- pptx/dml/effect.py +41 -0
- pptx/dml/fill.py +468 -0
- pptx/dml/line.py +100 -0
- pptx/enum/__init__.py +0 -0
- pptx/enum/action.py +71 -0
- pptx/enum/base.py +175 -0
- pptx/enum/chart.py +492 -0
- pptx/enum/dml.py +405 -0
- pptx/enum/lang.py +685 -0
- pptx/enum/shapes.py +1029 -0
- pptx/enum/text.py +371 -0
- pptx/exc.py +23 -0
- pptx/media.py +197 -0
- pptx/opc/__init__.py +0 -0
- pptx/opc/constants.py +331 -0
- pptx/opc/oxml.py +188 -0
- pptx/opc/package.py +762 -0
- pptx/opc/packuri.py +109 -0
- pptx/opc/serialized.py +296 -0
- pptx/opc/shared.py +20 -0
- pptx/opc/spec.py +44 -0
- pptx/oxml/__init__.py +492 -0
- pptx/oxml/action.py +53 -0
- pptx/oxml/chart/__init__.py +0 -0
- pptx/oxml/chart/axis.py +297 -0
- pptx/oxml/chart/chart.py +282 -0
- pptx/oxml/chart/datalabel.py +252 -0
- pptx/oxml/chart/legend.py +72 -0
- pptx/oxml/chart/marker.py +61 -0
- pptx/oxml/chart/plot.py +345 -0
- pptx/oxml/chart/series.py +254 -0
- pptx/oxml/chart/shared.py +219 -0
- pptx/oxml/coreprops.py +288 -0
- pptx/oxml/dml/__init__.py +0 -0
- pptx/oxml/dml/color.py +111 -0
- pptx/oxml/dml/fill.py +197 -0
- pptx/oxml/dml/line.py +12 -0
- pptx/oxml/ns.py +129 -0
- pptx/oxml/presentation.py +130 -0
- pptx/oxml/shapes/__init__.py +19 -0
- pptx/oxml/shapes/autoshape.py +455 -0
- pptx/oxml/shapes/connector.py +107 -0
- pptx/oxml/shapes/graphfrm.py +342 -0
- pptx/oxml/shapes/groupshape.py +280 -0
- pptx/oxml/shapes/picture.py +270 -0
- pptx/oxml/shapes/shared.py +523 -0
- pptx/oxml/simpletypes.py +740 -0
- pptx/oxml/slide.py +347 -0
- pptx/oxml/table.py +588 -0
- pptx/oxml/text.py +748 -0
- pptx/oxml/theme.py +29 -0
- pptx/oxml/xmlchemy.py +717 -0
- pptx/package.py +222 -0
- pptx/parts/__init__.py +0 -0
- pptx/parts/chart.py +95 -0
- pptx/parts/coreprops.py +167 -0
- pptx/parts/embeddedpackage.py +93 -0
- pptx/parts/image.py +275 -0
- pptx/parts/media.py +37 -0
- pptx/parts/presentation.py +126 -0
- pptx/parts/slide.py +297 -0
- pptx/parts/theme.py +13 -0
- pptx/presentation.py +113 -0
- pptx/py.typed +0 -0
- pptx/shapes/__init__.py +26 -0
- pptx/shapes/autoshape.py +355 -0
- pptx/shapes/base.py +293 -0
- pptx/shapes/connector.py +297 -0
- pptx/shapes/freeform.py +337 -0
- pptx/shapes/graphfrm.py +166 -0
- pptx/shapes/group.py +69 -0
- pptx/shapes/picture.py +203 -0
- pptx/shapes/placeholder.py +407 -0
- pptx/shapes/shapetree.py +1190 -0
- pptx/shared.py +82 -0
- pptx/slide.py +577 -0
- pptx/spec.py +632 -0
- pptx/table.py +520 -0
- pptx/templates/default.pptx +0 -0
- pptx/templates/docx-icon.emf +0 -0
- pptx/templates/generic-icon.emf +0 -0
- pptx/templates/notes.xml +23 -0
- pptx/templates/notesMaster.xml +352 -0
- pptx/templates/pptx-icon.emf +0 -0
- pptx/templates/theme.xml +321 -0
- pptx/templates/xlsx-icon.emf +0 -0
- pptx/text/__init__.py +0 -0
- pptx/text/fonts.py +399 -0
- pptx/text/layout.py +325 -0
- pptx/text/text.py +770 -0
- pptx/theme.py +135 -0
- pptx/types.py +36 -0
- pptx/util.py +284 -0
- ps_python_pptx-1.1.0.dist-info/METADATA +75 -0
- ps_python_pptx-1.1.0.dist-info/RECORD +117 -0
- ps_python_pptx-1.1.0.dist-info/WHEEL +5 -0
- ps_python_pptx-1.1.0.dist-info/licenses/LICENSE +20 -0
- ps_python_pptx-1.1.0.dist-info/top_level.txt +1 -0
pptx/oxml/chart/plot.py
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
"""Plot-related oxml objects."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pptx.oxml.chart.datalabel import CT_DLbls
|
|
6
|
+
from pptx.oxml.simpletypes import (
|
|
7
|
+
ST_BarDir,
|
|
8
|
+
ST_BubbleScale,
|
|
9
|
+
ST_GapAmount,
|
|
10
|
+
ST_Grouping,
|
|
11
|
+
ST_Overlap,
|
|
12
|
+
)
|
|
13
|
+
from pptx.oxml.xmlchemy import (
|
|
14
|
+
BaseOxmlElement,
|
|
15
|
+
OneAndOnlyOne,
|
|
16
|
+
OptionalAttribute,
|
|
17
|
+
ZeroOrMore,
|
|
18
|
+
ZeroOrOne,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class BaseChartElement(BaseOxmlElement):
|
|
23
|
+
"""
|
|
24
|
+
Base class for barChart, lineChart, and other plot elements.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
@property
|
|
28
|
+
def cat(self):
|
|
29
|
+
"""
|
|
30
|
+
Return the `c:cat` element of the first series in this xChart, or
|
|
31
|
+
|None| if not present.
|
|
32
|
+
"""
|
|
33
|
+
cats = self.xpath("./c:ser[1]/c:cat")
|
|
34
|
+
return cats[0] if cats else None
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
def cat_pt_count(self):
|
|
38
|
+
"""
|
|
39
|
+
Return the value of the `c:ptCount` descendent of this xChart
|
|
40
|
+
element. Its parent can be one of three element types. This value
|
|
41
|
+
represents the true number of (leaf) categories, although they might
|
|
42
|
+
not all have a corresponding `c:pt` sibling; a category with no label
|
|
43
|
+
does not get a `c:pt` element. Returns 0 if there is no `c:ptCount`
|
|
44
|
+
descendent.
|
|
45
|
+
"""
|
|
46
|
+
cat_ptCounts = self.xpath("./c:ser//c:cat//c:ptCount")
|
|
47
|
+
if not cat_ptCounts:
|
|
48
|
+
return 0
|
|
49
|
+
return cat_ptCounts[0].val
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def cat_pts(self):
|
|
53
|
+
"""
|
|
54
|
+
Return a sequence representing the `c:pt` elements under the `c:cat`
|
|
55
|
+
element of the first series in this xChart element. A category having
|
|
56
|
+
no value will have no corresponding `c:pt` element; |None| will
|
|
57
|
+
appear in that position in such cases. Items appear in `idx` order.
|
|
58
|
+
Only those in the first ``<c:lvl>`` element are included in the case
|
|
59
|
+
of multi-level categories.
|
|
60
|
+
"""
|
|
61
|
+
cat_pts = self.xpath("./c:ser[1]/c:cat//c:lvl[1]/c:pt")
|
|
62
|
+
if not cat_pts:
|
|
63
|
+
cat_pts = self.xpath("./c:ser[1]/c:cat//c:pt")
|
|
64
|
+
|
|
65
|
+
cat_pt_dict = dict((pt.idx, pt) for pt in cat_pts)
|
|
66
|
+
|
|
67
|
+
return [cat_pt_dict.get(idx, None) for idx in range(self.cat_pt_count)]
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
def grouping_val(self):
|
|
71
|
+
"""
|
|
72
|
+
Return the value of the ``./c:grouping{val=?}`` attribute, taking
|
|
73
|
+
defaults into account when items are not present.
|
|
74
|
+
"""
|
|
75
|
+
grouping = self.grouping
|
|
76
|
+
if grouping is None:
|
|
77
|
+
return ST_Grouping.STANDARD
|
|
78
|
+
val = grouping.val
|
|
79
|
+
if val is None:
|
|
80
|
+
return ST_Grouping.STANDARD
|
|
81
|
+
return val
|
|
82
|
+
|
|
83
|
+
def iter_sers(self):
|
|
84
|
+
"""
|
|
85
|
+
Generate each ``<c:ser>`` child element in this xChart in
|
|
86
|
+
c:order/@val sequence (not document or c:idx order).
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
def ser_order(ser):
|
|
90
|
+
return ser.order.val
|
|
91
|
+
|
|
92
|
+
return (ser for ser in sorted(self.xpath("./c:ser"), key=ser_order))
|
|
93
|
+
|
|
94
|
+
@property
|
|
95
|
+
def sers(self):
|
|
96
|
+
"""
|
|
97
|
+
Sequence of ``<c:ser>`` child elements in this xChart in c:order/@val
|
|
98
|
+
sequence (not document or c:idx order).
|
|
99
|
+
"""
|
|
100
|
+
return tuple(self.iter_sers())
|
|
101
|
+
|
|
102
|
+
def _new_dLbls(self):
|
|
103
|
+
return CT_DLbls.new_dLbls()
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class CT_Area3DChart(BaseChartElement):
|
|
107
|
+
"""
|
|
108
|
+
``<c:area3DChart>`` element.
|
|
109
|
+
"""
|
|
110
|
+
|
|
111
|
+
grouping = ZeroOrOne(
|
|
112
|
+
"c:grouping",
|
|
113
|
+
successors=(
|
|
114
|
+
"c:varyColors",
|
|
115
|
+
"c:ser",
|
|
116
|
+
"c:dLbls",
|
|
117
|
+
"c:dropLines",
|
|
118
|
+
"c:gapDepth",
|
|
119
|
+
"c:axId",
|
|
120
|
+
),
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class CT_AreaChart(BaseChartElement):
|
|
125
|
+
"""
|
|
126
|
+
``<c:areaChart>`` element.
|
|
127
|
+
"""
|
|
128
|
+
|
|
129
|
+
_tag_seq = (
|
|
130
|
+
"c:grouping",
|
|
131
|
+
"c:varyColors",
|
|
132
|
+
"c:ser",
|
|
133
|
+
"c:dLbls",
|
|
134
|
+
"c:dropLines",
|
|
135
|
+
"c:axId",
|
|
136
|
+
"c:extLst",
|
|
137
|
+
)
|
|
138
|
+
grouping = ZeroOrOne("c:grouping", successors=_tag_seq[1:])
|
|
139
|
+
varyColors = ZeroOrOne("c:varyColors", successors=_tag_seq[2:])
|
|
140
|
+
ser = ZeroOrMore("c:ser", successors=_tag_seq[3:])
|
|
141
|
+
dLbls = ZeroOrOne("c:dLbls", successors=_tag_seq[4:])
|
|
142
|
+
del _tag_seq
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class CT_BarChart(BaseChartElement):
|
|
146
|
+
"""
|
|
147
|
+
``<c:barChart>`` element.
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
_tag_seq = (
|
|
151
|
+
"c:barDir",
|
|
152
|
+
"c:grouping",
|
|
153
|
+
"c:varyColors",
|
|
154
|
+
"c:ser",
|
|
155
|
+
"c:dLbls",
|
|
156
|
+
"c:gapWidth",
|
|
157
|
+
"c:overlap",
|
|
158
|
+
"c:serLines",
|
|
159
|
+
"c:axId",
|
|
160
|
+
"c:extLst",
|
|
161
|
+
)
|
|
162
|
+
barDir = OneAndOnlyOne("c:barDir")
|
|
163
|
+
grouping = ZeroOrOne("c:grouping", successors=_tag_seq[2:])
|
|
164
|
+
varyColors = ZeroOrOne("c:varyColors", successors=_tag_seq[3:])
|
|
165
|
+
ser = ZeroOrMore("c:ser", successors=_tag_seq[4:])
|
|
166
|
+
dLbls = ZeroOrOne("c:dLbls", successors=_tag_seq[5:])
|
|
167
|
+
gapWidth = ZeroOrOne("c:gapWidth", successors=_tag_seq[6:])
|
|
168
|
+
overlap = ZeroOrOne("c:overlap", successors=_tag_seq[7:])
|
|
169
|
+
del _tag_seq
|
|
170
|
+
|
|
171
|
+
@property
|
|
172
|
+
def grouping_val(self):
|
|
173
|
+
"""
|
|
174
|
+
Return the value of the ``./c:grouping{val=?}`` attribute, taking
|
|
175
|
+
defaults into account when items are not present.
|
|
176
|
+
"""
|
|
177
|
+
grouping = self.grouping
|
|
178
|
+
if grouping is None:
|
|
179
|
+
return ST_Grouping.CLUSTERED
|
|
180
|
+
val = grouping.val
|
|
181
|
+
if val is None:
|
|
182
|
+
return ST_Grouping.CLUSTERED
|
|
183
|
+
return val
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
class CT_BarDir(BaseOxmlElement):
|
|
187
|
+
"""
|
|
188
|
+
``<c:barDir>`` child of a barChart element, specifying the orientation of
|
|
189
|
+
the bars, 'bar' if they are horizontal and 'col' if they are vertical.
|
|
190
|
+
"""
|
|
191
|
+
|
|
192
|
+
val = OptionalAttribute("val", ST_BarDir, default=ST_BarDir.COL)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
class CT_BubbleChart(BaseChartElement):
|
|
196
|
+
"""
|
|
197
|
+
``<c:bubbleChart>`` custom element class
|
|
198
|
+
"""
|
|
199
|
+
|
|
200
|
+
_tag_seq = (
|
|
201
|
+
"c:varyColors",
|
|
202
|
+
"c:ser",
|
|
203
|
+
"c:dLbls",
|
|
204
|
+
"c:axId",
|
|
205
|
+
"c:bubble3D",
|
|
206
|
+
"c:bubbleScale",
|
|
207
|
+
"c:showNegBubbles",
|
|
208
|
+
"c:sizeRepresents",
|
|
209
|
+
"c:axId",
|
|
210
|
+
"c:extLst",
|
|
211
|
+
)
|
|
212
|
+
ser = ZeroOrMore("c:ser", successors=_tag_seq[2:])
|
|
213
|
+
dLbls = ZeroOrOne("c:dLbls", successors=_tag_seq[3:])
|
|
214
|
+
bubble3D = ZeroOrOne("c:bubble3D", successors=_tag_seq[5:])
|
|
215
|
+
bubbleScale = ZeroOrOne("c:bubbleScale", successors=_tag_seq[6:])
|
|
216
|
+
del _tag_seq
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
class CT_BubbleScale(BaseChartElement):
|
|
220
|
+
"""
|
|
221
|
+
``<c:bubbleScale>`` custom element class
|
|
222
|
+
"""
|
|
223
|
+
|
|
224
|
+
val = OptionalAttribute("val", ST_BubbleScale, default=100)
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
class CT_DoughnutChart(BaseChartElement):
|
|
228
|
+
"""
|
|
229
|
+
``<c:doughnutChart>`` element.
|
|
230
|
+
"""
|
|
231
|
+
|
|
232
|
+
_tag_seq = (
|
|
233
|
+
"c:varyColors",
|
|
234
|
+
"c:ser",
|
|
235
|
+
"c:dLbls",
|
|
236
|
+
"c:firstSliceAng",
|
|
237
|
+
"c:holeSize",
|
|
238
|
+
"c:extLst",
|
|
239
|
+
)
|
|
240
|
+
varyColors = ZeroOrOne("c:varyColors", successors=_tag_seq[1:])
|
|
241
|
+
ser = ZeroOrMore("c:ser", successors=_tag_seq[2:])
|
|
242
|
+
dLbls = ZeroOrOne("c:dLbls", successors=_tag_seq[3:])
|
|
243
|
+
del _tag_seq
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
class CT_GapAmount(BaseOxmlElement):
|
|
247
|
+
"""
|
|
248
|
+
``<c:gapWidth>`` child of ``<c:barChart>`` element, also used for other
|
|
249
|
+
purposes like error bars.
|
|
250
|
+
"""
|
|
251
|
+
|
|
252
|
+
val = OptionalAttribute("val", ST_GapAmount, default=150)
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
class CT_Grouping(BaseOxmlElement):
|
|
256
|
+
"""
|
|
257
|
+
``<c:grouping>`` child of an xChart element, specifying a value like
|
|
258
|
+
'clustered' or 'stacked'. Also used for variants with the same tag name
|
|
259
|
+
like CT_BarGrouping.
|
|
260
|
+
"""
|
|
261
|
+
|
|
262
|
+
val = OptionalAttribute("val", ST_Grouping)
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
class CT_LineChart(BaseChartElement):
|
|
266
|
+
"""
|
|
267
|
+
``<c:lineChart>`` custom element class
|
|
268
|
+
"""
|
|
269
|
+
|
|
270
|
+
_tag_seq = (
|
|
271
|
+
"c:grouping",
|
|
272
|
+
"c:varyColors",
|
|
273
|
+
"c:ser",
|
|
274
|
+
"c:dLbls",
|
|
275
|
+
"c:dropLines",
|
|
276
|
+
"c:hiLowLines",
|
|
277
|
+
"c:upDownBars",
|
|
278
|
+
"c:marker",
|
|
279
|
+
"c:smooth",
|
|
280
|
+
"c:axId",
|
|
281
|
+
"c:extLst",
|
|
282
|
+
)
|
|
283
|
+
grouping = ZeroOrOne("c:grouping", successors=(_tag_seq[1:]))
|
|
284
|
+
varyColors = ZeroOrOne("c:varyColors", successors=_tag_seq[2:])
|
|
285
|
+
ser = ZeroOrMore("c:ser", successors=_tag_seq[3:])
|
|
286
|
+
dLbls = ZeroOrOne("c:dLbls", successors=(_tag_seq[4:]))
|
|
287
|
+
del _tag_seq
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
class CT_Overlap(BaseOxmlElement):
|
|
291
|
+
"""
|
|
292
|
+
``<c:overlap>`` element specifying bar overlap as an integer percentage
|
|
293
|
+
of bar width, in range -100 to 100.
|
|
294
|
+
"""
|
|
295
|
+
|
|
296
|
+
val = OptionalAttribute("val", ST_Overlap, default=0)
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
class CT_PieChart(BaseChartElement):
|
|
300
|
+
"""
|
|
301
|
+
``<c:pieChart>`` custom element class
|
|
302
|
+
"""
|
|
303
|
+
|
|
304
|
+
_tag_seq = ("c:varyColors", "c:ser", "c:dLbls", "c:firstSliceAng", "c:extLst")
|
|
305
|
+
varyColors = ZeroOrOne("c:varyColors", successors=_tag_seq[1:])
|
|
306
|
+
ser = ZeroOrMore("c:ser", successors=_tag_seq[2:])
|
|
307
|
+
dLbls = ZeroOrOne("c:dLbls", successors=_tag_seq[3:])
|
|
308
|
+
del _tag_seq
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
class CT_RadarChart(BaseChartElement):
|
|
312
|
+
"""
|
|
313
|
+
``<c:radarChart>`` custom element class
|
|
314
|
+
"""
|
|
315
|
+
|
|
316
|
+
_tag_seq = (
|
|
317
|
+
"c:radarStyle",
|
|
318
|
+
"c:varyColors",
|
|
319
|
+
"c:ser",
|
|
320
|
+
"c:dLbls",
|
|
321
|
+
"c:axId",
|
|
322
|
+
"c:extLst",
|
|
323
|
+
)
|
|
324
|
+
varyColors = ZeroOrOne("c:varyColors", successors=_tag_seq[2:])
|
|
325
|
+
ser = ZeroOrMore("c:ser", successors=_tag_seq[3:])
|
|
326
|
+
dLbls = ZeroOrOne("c:dLbls", successors=(_tag_seq[4:]))
|
|
327
|
+
del _tag_seq
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
class CT_ScatterChart(BaseChartElement):
|
|
331
|
+
"""
|
|
332
|
+
``<c:scatterChart>`` custom element class
|
|
333
|
+
"""
|
|
334
|
+
|
|
335
|
+
_tag_seq = (
|
|
336
|
+
"c:scatterStyle",
|
|
337
|
+
"c:varyColors",
|
|
338
|
+
"c:ser",
|
|
339
|
+
"c:dLbls",
|
|
340
|
+
"c:axId",
|
|
341
|
+
"c:extLst",
|
|
342
|
+
)
|
|
343
|
+
varyColors = ZeroOrOne("c:varyColors", successors=_tag_seq[2:])
|
|
344
|
+
ser = ZeroOrMore("c:ser", successors=_tag_seq[3:])
|
|
345
|
+
del _tag_seq
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"""Series-related oxml objects."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pptx.oxml.chart.datalabel import CT_DLbls
|
|
6
|
+
from pptx.oxml.simpletypes import XsdUnsignedInt
|
|
7
|
+
from pptx.oxml.xmlchemy import (
|
|
8
|
+
BaseOxmlElement,
|
|
9
|
+
OneAndOnlyOne,
|
|
10
|
+
OxmlElement,
|
|
11
|
+
RequiredAttribute,
|
|
12
|
+
ZeroOrMore,
|
|
13
|
+
ZeroOrOne,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class CT_AxDataSource(BaseOxmlElement):
|
|
18
|
+
"""
|
|
19
|
+
``<c:cat>`` custom element class used in category charts to specify
|
|
20
|
+
category labels and hierarchy.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
multiLvlStrRef = ZeroOrOne("c:multiLvlStrRef", successors=())
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def lvls(self):
|
|
27
|
+
"""
|
|
28
|
+
Return a list containing the `c:lvl` descendent elements in document
|
|
29
|
+
order. These will only be present when the required single child
|
|
30
|
+
is a `c:multiLvlStrRef` element. Returns an empty list when no
|
|
31
|
+
`c:lvl` descendent elements are present.
|
|
32
|
+
"""
|
|
33
|
+
return self.xpath(".//c:lvl")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class CT_DPt(BaseOxmlElement):
|
|
37
|
+
"""
|
|
38
|
+
``<c:dPt>`` custom element class, containing visual properties for a data
|
|
39
|
+
point.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
_tag_seq = (
|
|
43
|
+
"c:idx",
|
|
44
|
+
"c:invertIfNegative",
|
|
45
|
+
"c:marker",
|
|
46
|
+
"c:bubble3D",
|
|
47
|
+
"c:explosion",
|
|
48
|
+
"c:spPr",
|
|
49
|
+
"c:pictureOptions",
|
|
50
|
+
"c:extLst",
|
|
51
|
+
)
|
|
52
|
+
idx = OneAndOnlyOne("c:idx")
|
|
53
|
+
marker = ZeroOrOne("c:marker", successors=_tag_seq[3:])
|
|
54
|
+
spPr = ZeroOrOne("c:spPr", successors=_tag_seq[6:])
|
|
55
|
+
del _tag_seq
|
|
56
|
+
|
|
57
|
+
@classmethod
|
|
58
|
+
def new_dPt(cls):
|
|
59
|
+
"""
|
|
60
|
+
Return a newly created "loose" `c:dPt` element containing its default
|
|
61
|
+
subtree.
|
|
62
|
+
"""
|
|
63
|
+
dPt = OxmlElement("c:dPt")
|
|
64
|
+
dPt.append(OxmlElement("c:idx"))
|
|
65
|
+
return dPt
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class CT_Lvl(BaseOxmlElement):
|
|
69
|
+
"""
|
|
70
|
+
``<c:lvl>`` custom element class used in multi-level categories to
|
|
71
|
+
specify a level of hierarchy.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
pt = ZeroOrMore("c:pt", successors=())
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class CT_NumDataSource(BaseOxmlElement):
|
|
78
|
+
"""
|
|
79
|
+
``<c:yVal>`` custom element class used in XY and bubble charts, and
|
|
80
|
+
perhaps others.
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
numRef = OneAndOnlyOne("c:numRef")
|
|
84
|
+
|
|
85
|
+
@property
|
|
86
|
+
def ptCount_val(self):
|
|
87
|
+
"""
|
|
88
|
+
Return the value of `./c:numRef/c:numCache/c:ptCount/@val`,
|
|
89
|
+
specifying how many `c:pt` elements are in this numeric data cache.
|
|
90
|
+
Returns 0 if no `c:ptCount` element is present, as this is the least
|
|
91
|
+
disruptive way to degrade when no cached point data is available.
|
|
92
|
+
This situation is not expected, but is valid according to the schema.
|
|
93
|
+
"""
|
|
94
|
+
results = self.xpath(".//c:ptCount/@val")
|
|
95
|
+
return int(results[0]) if results else 0
|
|
96
|
+
|
|
97
|
+
def pt_v(self, idx):
|
|
98
|
+
"""
|
|
99
|
+
Return the Y value for data point *idx* in this cache, or None if no
|
|
100
|
+
value is present for that data point.
|
|
101
|
+
"""
|
|
102
|
+
results = self.xpath(".//c:pt[@idx=%d]" % idx)
|
|
103
|
+
return results[0].value if results else None
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class CT_SeriesComposite(BaseOxmlElement):
|
|
107
|
+
"""
|
|
108
|
+
``<c:ser>`` custom element class. Note there are several different series
|
|
109
|
+
element types in the schema, such as ``CT_LineSer`` and ``CT_BarSer``,
|
|
110
|
+
but they all share the same tag name. This class acts as a composite and
|
|
111
|
+
depends on the caller not to do anything invalid for a series belonging
|
|
112
|
+
to a particular plot type.
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
_tag_seq = (
|
|
116
|
+
"c:idx",
|
|
117
|
+
"c:order",
|
|
118
|
+
"c:tx",
|
|
119
|
+
"c:spPr",
|
|
120
|
+
"c:invertIfNegative",
|
|
121
|
+
"c:pictureOptions",
|
|
122
|
+
"c:marker",
|
|
123
|
+
"c:explosion",
|
|
124
|
+
"c:dPt",
|
|
125
|
+
"c:dLbls",
|
|
126
|
+
"c:trendline",
|
|
127
|
+
"c:errBars",
|
|
128
|
+
"c:cat",
|
|
129
|
+
"c:val",
|
|
130
|
+
"c:xVal",
|
|
131
|
+
"c:yVal",
|
|
132
|
+
"c:shape",
|
|
133
|
+
"c:smooth",
|
|
134
|
+
"c:bubbleSize",
|
|
135
|
+
"c:bubble3D",
|
|
136
|
+
"c:extLst",
|
|
137
|
+
)
|
|
138
|
+
idx = OneAndOnlyOne("c:idx")
|
|
139
|
+
order = OneAndOnlyOne("c:order")
|
|
140
|
+
tx = ZeroOrOne("c:tx", successors=_tag_seq[3:])
|
|
141
|
+
spPr = ZeroOrOne("c:spPr", successors=_tag_seq[4:])
|
|
142
|
+
invertIfNegative = ZeroOrOne("c:invertIfNegative", successors=_tag_seq[5:])
|
|
143
|
+
marker = ZeroOrOne("c:marker", successors=_tag_seq[7:])
|
|
144
|
+
dPt = ZeroOrMore("c:dPt", successors=_tag_seq[9:])
|
|
145
|
+
dLbls = ZeroOrOne("c:dLbls", successors=_tag_seq[10:])
|
|
146
|
+
cat = ZeroOrOne("c:cat", successors=_tag_seq[13:])
|
|
147
|
+
val = ZeroOrOne("c:val", successors=_tag_seq[14:])
|
|
148
|
+
xVal = ZeroOrOne("c:xVal", successors=_tag_seq[15:])
|
|
149
|
+
yVal = ZeroOrOne("c:yVal", successors=_tag_seq[16:])
|
|
150
|
+
smooth = ZeroOrOne("c:smooth", successors=_tag_seq[18:])
|
|
151
|
+
bubbleSize = ZeroOrOne("c:bubbleSize", successors=_tag_seq[19:])
|
|
152
|
+
del _tag_seq
|
|
153
|
+
|
|
154
|
+
@property
|
|
155
|
+
def bubbleSize_ptCount_val(self):
|
|
156
|
+
"""
|
|
157
|
+
Return the number of bubble size values as reflected in the `val`
|
|
158
|
+
attribute of `./c:bubbleSize//c:ptCount`, or 0 if not present.
|
|
159
|
+
"""
|
|
160
|
+
vals = self.xpath("./c:bubbleSize//c:ptCount/@val")
|
|
161
|
+
if not vals:
|
|
162
|
+
return 0
|
|
163
|
+
return int(vals[0])
|
|
164
|
+
|
|
165
|
+
@property
|
|
166
|
+
def cat_ptCount_val(self):
|
|
167
|
+
"""
|
|
168
|
+
Return the number of categories as reflected in the `val` attribute
|
|
169
|
+
of `./c:cat//c:ptCount`, or 0 if not present.
|
|
170
|
+
"""
|
|
171
|
+
vals = self.xpath("./c:cat//c:ptCount/@val")
|
|
172
|
+
if not vals:
|
|
173
|
+
return 0
|
|
174
|
+
return int(vals[0])
|
|
175
|
+
|
|
176
|
+
def get_dLbl(self, idx):
|
|
177
|
+
"""
|
|
178
|
+
Return the `c:dLbl` element representing the label for the data point
|
|
179
|
+
at offset *idx* in this series, or |None| if not present.
|
|
180
|
+
"""
|
|
181
|
+
dLbls = self.dLbls
|
|
182
|
+
if dLbls is None:
|
|
183
|
+
return None
|
|
184
|
+
return dLbls.get_dLbl_for_point(idx)
|
|
185
|
+
|
|
186
|
+
def get_or_add_dLbl(self, idx):
|
|
187
|
+
"""
|
|
188
|
+
Return the `c:dLbl` element representing the label of the point at
|
|
189
|
+
offset *idx* in this series, newly created if not yet present.
|
|
190
|
+
"""
|
|
191
|
+
dLbls = self.get_or_add_dLbls()
|
|
192
|
+
return dLbls.get_or_add_dLbl_for_point(idx)
|
|
193
|
+
|
|
194
|
+
def get_or_add_dPt_for_point(self, idx):
|
|
195
|
+
"""
|
|
196
|
+
Return the `c:dPt` child representing the visual properties of the
|
|
197
|
+
data point at index *idx*.
|
|
198
|
+
"""
|
|
199
|
+
matches = self.xpath('c:dPt[c:idx[@val="%d"]]' % idx)
|
|
200
|
+
if matches:
|
|
201
|
+
return matches[0]
|
|
202
|
+
dPt = self._add_dPt()
|
|
203
|
+
dPt.idx.val = idx
|
|
204
|
+
return dPt
|
|
205
|
+
|
|
206
|
+
@property
|
|
207
|
+
def xVal_ptCount_val(self):
|
|
208
|
+
"""
|
|
209
|
+
Return the number of X values as reflected in the `val` attribute of
|
|
210
|
+
`./c:xVal//c:ptCount`, or 0 if not present.
|
|
211
|
+
"""
|
|
212
|
+
vals = self.xpath("./c:xVal//c:ptCount/@val")
|
|
213
|
+
if not vals:
|
|
214
|
+
return 0
|
|
215
|
+
return int(vals[0])
|
|
216
|
+
|
|
217
|
+
@property
|
|
218
|
+
def yVal_ptCount_val(self):
|
|
219
|
+
"""
|
|
220
|
+
Return the number of Y values as reflected in the `val` attribute of
|
|
221
|
+
`./c:yVal//c:ptCount`, or 0 if not present.
|
|
222
|
+
"""
|
|
223
|
+
vals = self.xpath("./c:yVal//c:ptCount/@val")
|
|
224
|
+
if not vals:
|
|
225
|
+
return 0
|
|
226
|
+
return int(vals[0])
|
|
227
|
+
|
|
228
|
+
def _new_dLbls(self):
|
|
229
|
+
"""Override metaclass method that creates `c:dLbls` element."""
|
|
230
|
+
return CT_DLbls.new_dLbls()
|
|
231
|
+
|
|
232
|
+
def _new_dPt(self):
|
|
233
|
+
"""
|
|
234
|
+
Overrides the metaclass generated method to get `c:dPt` with minimal
|
|
235
|
+
subtree.
|
|
236
|
+
"""
|
|
237
|
+
return CT_DPt.new_dPt()
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
class CT_StrVal_NumVal_Composite(BaseOxmlElement):
|
|
241
|
+
"""
|
|
242
|
+
``<c:pt>`` element, can be either CT_StrVal or CT_NumVal complex type.
|
|
243
|
+
Using this class for both, differentiating as needed.
|
|
244
|
+
"""
|
|
245
|
+
|
|
246
|
+
v = OneAndOnlyOne("c:v")
|
|
247
|
+
idx = RequiredAttribute("idx", XsdUnsignedInt)
|
|
248
|
+
|
|
249
|
+
@property
|
|
250
|
+
def value(self):
|
|
251
|
+
"""
|
|
252
|
+
The float value of the text in the required ``<c:v>`` child.
|
|
253
|
+
"""
|
|
254
|
+
return float(self.v.text)
|