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

Method insert_chart

src/pptx/shapes/placeholder.py:283–300  ·  view source on GitHub ↗

Return a |PlaceholderGraphicFrame| object containing a new chart of *chart_type* depicting *chart_data* and having the same position and size as this placeholder. *chart_type* is one of the :ref:`XlChartType` enumeration values. *chart_data* is a |ChartData|

(self, chart_type, chart_data)

Source from the content-addressed store, hash-verified

281 """Placeholder shape that can only accept a chart."""
282
283 def insert_chart(self, chart_type, chart_data):
284 """
285 Return a |PlaceholderGraphicFrame| object containing a new chart of
286 *chart_type* depicting *chart_data* and having the same position and
287 size as this placeholder. *chart_type* is one of the
288 :ref:`XlChartType` enumeration values. *chart_data* is a |ChartData|
289 object populated with the categories and series values for the chart.
290 Note that the new |Chart| object is not returned directly. The chart
291 object may be accessed using the
292 :attr:`~.PlaceholderGraphicFrame.chart` property of the returned
293 |PlaceholderGraphicFrame| object.
294 """
295 rId = self.part.add_chart_part(chart_type, chart_data)
296 graphicFrame = self._new_chart_graphicFrame(
297 rId, self.left, self.top, self.width, self.height
298 )
299 self._replace_placeholder_with(graphicFrame)
300 return PlaceholderGraphicFrame(graphicFrame, self._parent)
301
302 def _new_chart_graphicFrame(self, rId, x, y, cx, cy):
303 """

Calls 4

add_chart_partMethod · 0.80

Tested by 1