ChartPart
paper-pptx 0.2.0 API reference
A chart part.
Corresponds to parts having partnames matching ppt/charts/chart[1-9][0-9]*.xml
Attributes
blob
attributeblobbytesbytes XML serialization of this part.
chart
attributechartChart object representing the chart in this part.
chart_workbook
attributechart_workbookThe ChartWorkbook object providing access to the external chart
data in a linked or embedded Excel workbook.
content_type
attributecontent_typestrContent-type (MIME-type) of this part.
package
attributepackagePackagePackage this part belongs to.
part
attributepartThis part.
This is part of the parent protocol, "children" of the document will not know the part that contains them so must ask their parent object. That chain of delegation ends here for child objects.
partname
attributepartnamePackURIPackURI partname for this part, e.g. "/ppt/slides/slide1.xml".
partname_template
attributepartname_template= '/ppt/charts/chart%d.xml'rels
attributerels_RelationshipsCollection of relationships from this part to other parts.
Functions
drop_rel
funcdrop_rel(rId: str) -> NoneRemove relationship identified by rId if its reference count is under 2.
Relationships with a reference count of 0 are implicit relationships. Note that only XML parts can drop relationships.
paramrIdstrReturns
Noneload
funcload(partname: PackURI, content_type: str, package: Package, blob: bytes)Return instance of cls loaded with parsed XML from blob.
parampartnamePackURIparamcontent_typestrparampackagePackageparamblobbytesload_rels_from_xml
funcload_rels_from_xml(xml_rels: CT_Relationships, parts: dict[PackURI, Part]) -> Noneload _Relationships for this part from xml_rels.
Part references are resolved using the parts dict that maps each partname to the loaded
part with that partname. These relationships are loaded from a serialized package and so
already have assigned rIds. This method is only used during package loading.
paramxml_relsCT_Relationshipsparampartsdict[PackURI, Part]Returns
Nonenew
funcnew(chart_type: XL_CHART_TYPE, chart_data: ChartData, package: Package)Return new ChartPart instance added to package.
Returned chart-part contains a chart of chart_type depicting chart_data.
paramchart_typeXL_CHART_TYPEparamchart_dataChartDataparampackagePackagepart_related_by
funcpart_related_by(reltype: str) -> PartReturn (single) part having relationship to this package of reltype.
Raises KeyError if no such relationship is found and ValueError if more than one such
relationship is found.
paramreltypestrReturns
pptx.opc.package.Partrelate_to
funcrelate_to(target: Part | str, reltype: str, is_external: bool = False) -> strReturn rId key of relationship of reltype to target.
If such a relationship already exists, its rId is returned. Otherwise the relationship is added and its new rId returned.
paramtargetPart | strparamreltypestrparamis_externalbool= FalseReturns
strrelated_part
funcrelated_part(rId: str) -> PartReturn related Part subtype identified by rId.
paramrIdstrReturns
pptx.opc.package.Parttarget_ref
functarget_ref(rId: str) -> strReturn URL contained in target ref of relationship identified by rId.
paramrIdstrReturns
str