I am trying to make a simple python-pptx xy scatter chart with x and y series data but unsuccessful so far.
from pptx import Presentation
from pptx.util import Inches,Pt
from pptx.enum.chart import XL_CHART_TYPE
from pptx.chart.data import XySeriesData
prs = Presentation()
title_slide_layout = prs.slide_layouts[0]
blank_slide_layout = prs.slide_layouts[6]
slide = prs.slides.add_slide(title_slide_layout)
slide2 = prs.slides.add_slide(blank_slide_layout)
title = slide.shapes.title
subtitle = slide.placeholders[1]
title.text = "Hello, World!"
subtitle.text = "python-pptx was here!"
chart_data = XySeriesData
chart_data.x_values=[0,1,2,3,4,5]
chart_data.y_values=[10,22,33,38,40,43]
x, y, cx, cy = Inches(1), Inches(2), Inches(8), Inches(3)
chart = slide2.shapes.add_chart(XL_CHART_TYPE.XY_SCATTER, x, y, cx, cy, chart_data).chart
prs.save('test1.pptx')
The error i get is
File "C:\Users\adnan\Google Drive\Learning\Python\5g_tti_parser\untitled0.py", line 31, in chart = slide2.shapes.add_chart(XL_CHART_TYPE.XY_SCATTER, x, y, cx, cy, chart_data).chart
File "C:\ProgramData\Anaconda3\lib\site-packages\pptx\shapes\shapetree.py", line 250, in add_chart rId = self.part.add_chart_part(chart_type, chart_data)
File "C:\ProgramData\Anaconda3\lib\site-packages\pptx\parts\slide.py", line 174, in add_chart_part chart_part = ChartPart.new(chart_type, chart_data, self.package)
File "C:\ProgramData\Anaconda3\lib\site-packages\pptx\parts\chart.py", line 30, in new chart_blob = chart_data.xml_bytes(chart_type)
AttributeError: type object 'XySeriesData' has no attribute 'xml_bytes'