MCPcopy Create free account
hub / github.com/scanny/python-pptx / _insert_dLbl_in_sequence

Method _insert_dLbl_in_sequence

src/pptx/oxml/chart/datalabel.py:206–224  ·  view source on GitHub ↗

Return a newly created `c:dLbl` element having `c:idx` child of *idx* and inserted in numeric sequence among the `c:dLbl` children of this element.

(self, idx)

Source from the content-addressed store, hash-verified

204 )
205
206 def _insert_dLbl_in_sequence(self, idx):
207 """
208 Return a newly created `c:dLbl` element having `c:idx` child of *idx*
209 and inserted in numeric sequence among the `c:dLbl` children of this
210 element.
211 """
212 new_dLbl = self._new_dLbl()
213 new_dLbl.idx.val = idx
214
215 dLbl = None
216 for dLbl in self.dLbl_lst:
217 if dLbl.idx_val > idx:
218 dLbl.addprevious(new_dLbl)
219 return new_dLbl
220 if dLbl is not None:
221 dLbl.addnext(new_dLbl)
222 else:
223 self.insert(0, new_dLbl)
224 return new_dLbl
225
226 def _new_dLbl(self):
227 return CT_DLbl.new_dLbl()

Callers 1

Calls 2

_new_dLblMethod · 0.95
insertMethod · 0.80

Tested by

no test coverage detected