Paper Office
paper-pptxAPI referenceparts.chart

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

attributeblobbytes

bytes XML serialization of this part.

chart

attributechart

Chart object representing the chart in this part.

chart_workbook

attributechart_workbook

The ChartWorkbook object providing access to the external chart data in a linked or embedded Excel workbook.

content_type

attributecontent_typestr

Content-type (MIME-type) of this part.

package

attributepackagePackage

Package this part belongs to.

part

attributepart

This 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

attributepartnamePackURI

PackURI partname for this part, e.g. "/ppt/slides/slide1.xml".

partname_template

attributepartname_template
= '/ppt/charts/chart%d.xml'

rels

attributerels_Relationships

Collection of relationships from this part to other parts.

Functions

drop_rel

funcdrop_rel(rId: str) -> None

Remove 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.

paramrIdstr

Returns

None

load

funcload(partname: PackURI, content_type: str, package: Package, blob: bytes)

Return instance of cls loaded with parsed XML from blob.

parampartnamePackURI
paramcontent_typestr
parampackagePackage
paramblobbytes

load_rels_from_xml

funcload_rels_from_xml(xml_rels: CT_Relationships, parts: dict[PackURI, Part]) -> None

load _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_Relationships
parampartsdict[PackURI, Part]

Returns

None

new

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_TYPE
paramchart_dataChartData
parampackagePackage
funcpart_related_by(reltype: str) -> Part

Return (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.

paramreltypestr

Returns

pptx.opc.package.Part

relate_to

funcrelate_to(target: Part | str, reltype: str, is_external: bool = False) -> str

Return 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 | str
paramreltypestr
paramis_externalbool
= False

Returns

str
funcrelated_part(rId: str) -> Part

Return related Part subtype identified by rId.

paramrIdstr

Returns

pptx.opc.package.Part

target_ref

functarget_ref(rId: str) -> str

Return URL contained in target ref of relationship identified by rId.

paramrIdstr

Returns

str

On this page